Re: [PATCH 3/5] i2c: qcom-cci: Detect capabilities from CCI_HW_VERSION at runtime

From: Loic Poulain

Date: Tue Oct 13 2026 - 04:34:21 EST


On Mon, Oct 12, 2026 at 3:58 PM Konrad Dybcio
<konrad.dybcio@xxxxxxxxxxxxxxxx> wrote:
>
> On 10/4/26 9:09 PM, Loic Poulain wrote:
> > In theory, every SoC integrating a CCI revision that differs from
> > an existing one should introduce a dedicated compatible string.
>
> [...]
>
> > diff --git a/drivers/i2c/busses/i2c-qcom-cci.c b/drivers/i2c/busses/i2c-qcom-cci.c
> > index 099da0069251681cc52e351fb656bd73e78a96c9..c0b39d419e296454a083d38ce302940875b8ad2b 100644
> > --- a/drivers/i2c/busses/i2c-qcom-cci.c
> > +++ b/drivers/i2c/busses/i2c-qcom-cci.c
> > @@ -14,6 +14,10 @@
> > #include <linux/pm_opp.h>
> >
> > #define CCI_HW_VERSION 0x0
> > +#define CCI_HW_VERSION_MAJOR(val) (((val) >> 28) & 0xf)
> > +#define CCI_HW_VERSION_MINOR(val) (((val) >> 16) & 0xfff)
> > +#define CCI_HW_VERSION_STEP(val) ((val) & 0xffff)
>
> GENMASK/FIELD_GET(), please
>
> [...]
>
> > static const struct of_device_id cci_dt_match[] = {
> > - { .compatible = "qcom,msm8226-cci", .data = &cci_v1_data},
> > - { .compatible = "qcom,msm8953-cci", .data = &cci_v2_data},
> > - { .compatible = "qcom,msm8974-cci", .data = &cci_v1_5_data},
> > - { .compatible = "qcom,msm8996-cci", .data = &cci_v2_data},
> > + { .compatible = "qcom,msm8226-cci", .data = (void *)1 },
> > + { .compatible = "qcom,msm8953-cci", .data = (void *)NUM_MASTERS },
> > + { .compatible = "qcom,msm8974-cci", .data = (void *)NUM_MASTERS },
> > + { .compatible = "qcom,msm8996-cci", .data = (void *)NUM_MASTERS },
> >
> >
> > /*
> > * Legacy compatibles kept for backwards compatibility.
> > * Do not add any new ones unless they introduce a new config
> > */
> > - { .compatible = "qcom,msm8916-cci", .data = &cci_v1_data},
> > - { .compatible = "qcom,sdm845-cci", .data = &cci_v2_data},
> > - { .compatible = "qcom,sm8250-cci", .data = &cci_v2_data},
> > - { .compatible = "qcom,sm8450-cci", .data = &cci_v2_data},
> > + { .compatible = "qcom,msm8916-cci", .data = (void *)1 },
> > + { .compatible = "qcom,sdm845-cci", .data = (void *)NUM_MASTERS },
> > + { .compatible = "qcom,sm8250-cci", .data = (void *)NUM_MASTERS },
> > + { .compatible = "qcom,sm8450-cci", .data = (void *)NUM_MASTERS },
>
> This looks a little sloppy - can we infer the number of masters at
> runtime somehow?

Yes, we can either add a small msm8916-specific condition in the probe
path, or derive the number of masters dynamically from the number of
master subnodes present in the Device Tree.

Regards,
Loic