[01/11] dt-bindings: iio: qcom: adc7-pm8350: Allow specifying SID for channels
Commit Message
As per the new ADC7 architecture used by the Qualcomm PMICs, each PMIC
has the static Slave ID (SID) assigned by default. The primary PMIC
PMK8350 is responsible for collecting the temperature/voltage data from
the slave PMICs and exposing them via it's registers.
For getting the measurements from the slave PMICs, PMK8350 uses the
channel ID encoded with the SID of the relevant PMIC. So far, the
dt-binding for the slave PMIC PM8350 assumed that there will be only
one PM8350 in a system. So it harcoded SID 1 with channel IDs.
But this got changed in platforms such as Lenovo X13s where there are a
couple of PM8350 PMICs available. So to address multiple PM8350s, change
the binding to accept the SID specified by the user and use it for
encoding the channel ID.
It should be noted that, even though the SID is static it is not
globally unique. Only the primary PMIC has the unique SID id 0.
Signed-off-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
---
.../bindings/thermal/qcom-spmi-adc-tm5.yaml | 6 +-
.../dt-bindings/iio/qcom,spmi-adc7-pm8350.h | 90 +++++++++----------
2 files changed, 46 insertions(+), 50 deletions(-)
Comments
On 27/10/2022 02:29, Manivannan Sadhasivam wrote:
> As per the new ADC7 architecture used by the Qualcomm PMICs, each PMIC
> has the static Slave ID (SID) assigned by default. The primary PMIC
> PMK8350 is responsible for collecting the temperature/voltage data from
> the slave PMICs and exposing them via it's registers.
>
> For getting the measurements from the slave PMICs, PMK8350 uses the
> channel ID encoded with the SID of the relevant PMIC. So far, the
> dt-binding for the slave PMIC PM8350 assumed that there will be only
> one PM8350 in a system. So it harcoded SID 1 with channel IDs.
>
> But this got changed in platforms such as Lenovo X13s where there are a
> couple of PM8350 PMICs available. So to address multiple PM8350s, change
> the binding to accept the SID specified by the user and use it for
> encoding the channel ID.
>
> It should be noted that, even though the SID is static it is not
> globally unique. Only the primary PMIC has the unique SID id 0.
>
> Signed-off-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
> ---
> .../bindings/thermal/qcom-spmi-adc-tm5.yaml | 6 +-
> .../dt-bindings/iio/qcom,spmi-adc7-pm8350.h | 90 +++++++++----------
> 2 files changed, 46 insertions(+), 50 deletions(-)
>
> diff --git a/Documentation/devicetree/bindings/thermal/qcom-spmi-adc-tm5.yaml b/Documentation/devicetree/bindings/thermal/qcom-spmi-adc-tm5.yaml
> index feb390d50696..d20569b9b763 100644
> --- a/Documentation/devicetree/bindings/thermal/qcom-spmi-adc-tm5.yaml
> +++ b/Documentation/devicetree/bindings/thermal/qcom-spmi-adc-tm5.yaml
> @@ -222,8 +222,8 @@ examples:
> qcom,hw-settle-time = <200>;
> };
>
> - conn-therm@47 {
> - reg = <PM8350_ADC7_AMUX_THM4_100K_PU>;
> + conn-therm@147 {
> + reg = <PM8350_ADC7_AMUX_THM4_100K_PU(1)>;
> qcom,ratiometric;
> qcom,hw-settle-time = <200>;
> };
> @@ -247,7 +247,7 @@ examples:
>
> conn-therm@1 {
> reg = <1>;
> - io-channels = <&pmk8350_vadc PM8350_ADC7_AMUX_THM4_100K_PU>;
> + io-channels = <&pmk8350_vadc PM8350_ADC7_AMUX_THM4_100K_PU(1)>;
> qcom,avg-samples = <2>;
> qcom,ratiometric;
> qcom,hw-settle-time-us = <200>;
> diff --git a/include/dt-bindings/iio/qcom,spmi-adc7-pm8350.h b/include/dt-bindings/iio/qcom,spmi-adc7-pm8350.h
> index 9426f27a1946..50de5adfe6ac 100644
> --- a/include/dt-bindings/iio/qcom,spmi-adc7-pm8350.h
> +++ b/include/dt-bindings/iio/qcom,spmi-adc7-pm8350.h
> @@ -6,62 +6,58 @@
> #ifndef _DT_BINDINGS_QCOM_SPMI_VADC_PM8350_H
> #define _DT_BINDINGS_QCOM_SPMI_VADC_PM8350_H
>
> -#ifndef PM8350_SID
> -#define PM8350_SID 1
> -#endif
> -
> /* ADC channels for PM8350_ADC for PMIC7 */
> -#define PM8350_ADC7_REF_GND (PM8350_SID << 8 | 0x0)
> -#define PM8350_ADC7_1P25VREF (PM8350_SID << 8 | 0x01)
> -#define PM8350_ADC7_VREF_VADC (PM8350_SID << 8 | 0x02)
> -#define PM8350_ADC7_DIE_TEMP (PM8350_SID << 8 | 0x03)
> -
> -#define PM8350_ADC7_AMUX_THM1 (PM8350_SID << 8 | 0x04)
> -#define PM8350_ADC7_AMUX_THM2 (PM8350_SID << 8 | 0x05)
> -#define PM8350_ADC7_AMUX_THM3 (PM8350_SID << 8 | 0x06)
> -#define PM8350_ADC7_AMUX_THM4 (PM8350_SID << 8 | 0x07)
> -#define PM8350_ADC7_AMUX_THM5 (PM8350_SID << 8 | 0x08)
> -#define PM8350_ADC7_GPIO1 (PM8350_SID << 8 | 0x0a)
> -#define PM8350_ADC7_GPIO2 (PM8350_SID << 8 | 0x0b)
> -#define PM8350_ADC7_GPIO3 (PM8350_SID << 8 | 0x0c)
> -#define PM8350_ADC7_GPIO4 (PM8350_SID << 8 | 0x0d)
> +#define PM8350_ADC7_REF_GND(sid) (sid << 8 | 0x0)
As it is macro, I think it argument should be in parens: (sid)
Best regards,
Krzysztof
@@ -222,8 +222,8 @@ examples:
qcom,hw-settle-time = <200>;
};
- conn-therm@47 {
- reg = <PM8350_ADC7_AMUX_THM4_100K_PU>;
+ conn-therm@147 {
+ reg = <PM8350_ADC7_AMUX_THM4_100K_PU(1)>;
qcom,ratiometric;
qcom,hw-settle-time = <200>;
};
@@ -247,7 +247,7 @@ examples:
conn-therm@1 {
reg = <1>;
- io-channels = <&pmk8350_vadc PM8350_ADC7_AMUX_THM4_100K_PU>;
+ io-channels = <&pmk8350_vadc PM8350_ADC7_AMUX_THM4_100K_PU(1)>;
qcom,avg-samples = <2>;
qcom,ratiometric;
qcom,hw-settle-time-us = <200>;
@@ -6,62 +6,58 @@
#ifndef _DT_BINDINGS_QCOM_SPMI_VADC_PM8350_H
#define _DT_BINDINGS_QCOM_SPMI_VADC_PM8350_H
-#ifndef PM8350_SID
-#define PM8350_SID 1
-#endif
-
/* ADC channels for PM8350_ADC for PMIC7 */
-#define PM8350_ADC7_REF_GND (PM8350_SID << 8 | 0x0)
-#define PM8350_ADC7_1P25VREF (PM8350_SID << 8 | 0x01)
-#define PM8350_ADC7_VREF_VADC (PM8350_SID << 8 | 0x02)
-#define PM8350_ADC7_DIE_TEMP (PM8350_SID << 8 | 0x03)
-
-#define PM8350_ADC7_AMUX_THM1 (PM8350_SID << 8 | 0x04)
-#define PM8350_ADC7_AMUX_THM2 (PM8350_SID << 8 | 0x05)
-#define PM8350_ADC7_AMUX_THM3 (PM8350_SID << 8 | 0x06)
-#define PM8350_ADC7_AMUX_THM4 (PM8350_SID << 8 | 0x07)
-#define PM8350_ADC7_AMUX_THM5 (PM8350_SID << 8 | 0x08)
-#define PM8350_ADC7_GPIO1 (PM8350_SID << 8 | 0x0a)
-#define PM8350_ADC7_GPIO2 (PM8350_SID << 8 | 0x0b)
-#define PM8350_ADC7_GPIO3 (PM8350_SID << 8 | 0x0c)
-#define PM8350_ADC7_GPIO4 (PM8350_SID << 8 | 0x0d)
+#define PM8350_ADC7_REF_GND(sid) (sid << 8 | 0x0)
+#define PM8350_ADC7_1P25VREF(sid) (sid << 8 | 0x01)
+#define PM8350_ADC7_VREF_VADC(sid) (sid << 8 | 0x02)
+#define PM8350_ADC7_DIE_TEMP(sid) (sid << 8 | 0x03)
+
+#define PM8350_ADC7_AMUX_THM1(sid) (sid << 8 | 0x04)
+#define PM8350_ADC7_AMUX_THM2(sid) (sid << 8 | 0x05)
+#define PM8350_ADC7_AMUX_THM3(sid) (sid << 8 | 0x06)
+#define PM8350_ADC7_AMUX_THM4(sid) (sid << 8 | 0x07)
+#define PM8350_ADC7_AMUX_THM5(sid) (sid << 8 | 0x08)
+#define PM8350_ADC7_GPIO1(sid) (sid << 8 | 0x0a)
+#define PM8350_ADC7_GPIO2(sid) (sid << 8 | 0x0b)
+#define PM8350_ADC7_GPIO3(sid) (sid << 8 | 0x0c)
+#define PM8350_ADC7_GPIO4(sid) (sid << 8 | 0x0d)
/* 30k pull-up1 */
-#define PM8350_ADC7_AMUX_THM1_30K_PU (PM8350_SID << 8 | 0x24)
-#define PM8350_ADC7_AMUX_THM2_30K_PU (PM8350_SID << 8 | 0x25)
-#define PM8350_ADC7_AMUX_THM3_30K_PU (PM8350_SID << 8 | 0x26)
-#define PM8350_ADC7_AMUX_THM4_30K_PU (PM8350_SID << 8 | 0x27)
-#define PM8350_ADC7_AMUX_THM5_30K_PU (PM8350_SID << 8 | 0x28)
-#define PM8350_ADC7_GPIO1_30K_PU (PM8350_SID << 8 | 0x2a)
-#define PM8350_ADC7_GPIO2_30K_PU (PM8350_SID << 8 | 0x2b)
-#define PM8350_ADC7_GPIO3_30K_PU (PM8350_SID << 8 | 0x2c)
-#define PM8350_ADC7_GPIO4_30K_PU (PM8350_SID << 8 | 0x2d)
+#define PM8350_ADC7_AMUX_THM1_30K_PU(sid) (sid << 8 | 0x24)
+#define PM8350_ADC7_AMUX_THM2_30K_PU(sid) (sid << 8 | 0x25)
+#define PM8350_ADC7_AMUX_THM3_30K_PU(sid) (sid << 8 | 0x26)
+#define PM8350_ADC7_AMUX_THM4_30K_PU(sid) (sid << 8 | 0x27)
+#define PM8350_ADC7_AMUX_THM5_30K_PU(sid) (sid << 8 | 0x28)
+#define PM8350_ADC7_GPIO1_30K_PU(sid) (sid << 8 | 0x2a)
+#define PM8350_ADC7_GPIO2_30K_PU(sid) (sid << 8 | 0x2b)
+#define PM8350_ADC7_GPIO3_30K_PU(sid) (sid << 8 | 0x2c)
+#define PM8350_ADC7_GPIO4_30K_PU(sid) (sid << 8 | 0x2d)
/* 100k pull-up2 */
-#define PM8350_ADC7_AMUX_THM1_100K_PU (PM8350_SID << 8 | 0x44)
-#define PM8350_ADC7_AMUX_THM2_100K_PU (PM8350_SID << 8 | 0x45)
-#define PM8350_ADC7_AMUX_THM3_100K_PU (PM8350_SID << 8 | 0x46)
-#define PM8350_ADC7_AMUX_THM4_100K_PU (PM8350_SID << 8 | 0x47)
-#define PM8350_ADC7_AMUX_THM5_100K_PU (PM8350_SID << 8 | 0x48)
-#define PM8350_ADC7_GPIO1_100K_PU (PM8350_SID << 8 | 0x4a)
-#define PM8350_ADC7_GPIO2_100K_PU (PM8350_SID << 8 | 0x4b)
-#define PM8350_ADC7_GPIO3_100K_PU (PM8350_SID << 8 | 0x4c)
-#define PM8350_ADC7_GPIO4_100K_PU (PM8350_SID << 8 | 0x4d)
+#define PM8350_ADC7_AMUX_THM1_100K_PU(sid) (sid << 8 | 0x44)
+#define PM8350_ADC7_AMUX_THM2_100K_PU(sid) (sid << 8 | 0x45)
+#define PM8350_ADC7_AMUX_THM3_100K_PU(sid) (sid << 8 | 0x46)
+#define PM8350_ADC7_AMUX_THM4_100K_PU(sid) (sid << 8 | 0x47)
+#define PM8350_ADC7_AMUX_THM5_100K_PU(sid) (sid << 8 | 0x48)
+#define PM8350_ADC7_GPIO1_100K_PU(sid) (sid << 8 | 0x4a)
+#define PM8350_ADC7_GPIO2_100K_PU(sid) (sid << 8 | 0x4b)
+#define PM8350_ADC7_GPIO3_100K_PU(sid) (sid << 8 | 0x4c)
+#define PM8350_ADC7_GPIO4_100K_PU(sid) (sid << 8 | 0x4d)
/* 400k pull-up3 */
-#define PM8350_ADC7_AMUX_THM1_400K_PU (PM8350_SID << 8 | 0x64)
-#define PM8350_ADC7_AMUX_THM2_400K_PU (PM8350_SID << 8 | 0x65)
-#define PM8350_ADC7_AMUX_THM3_400K_PU (PM8350_SID << 8 | 0x66)
-#define PM8350_ADC7_AMUX_THM4_400K_PU (PM8350_SID << 8 | 0x67)
-#define PM8350_ADC7_AMUX_THM5_400K_PU (PM8350_SID << 8 | 0x68)
-#define PM8350_ADC7_GPIO1_400K_PU (PM8350_SID << 8 | 0x6a)
-#define PM8350_ADC7_GPIO2_400K_PU (PM8350_SID << 8 | 0x6b)
-#define PM8350_ADC7_GPIO3_400K_PU (PM8350_SID << 8 | 0x6c)
-#define PM8350_ADC7_GPIO4_400K_PU (PM8350_SID << 8 | 0x6d)
+#define PM8350_ADC7_AMUX_THM1_400K_PU(sid) (sid << 8 | 0x64)
+#define PM8350_ADC7_AMUX_THM2_400K_PU(sid) (sid << 8 | 0x65)
+#define PM8350_ADC7_AMUX_THM3_400K_PU(sid) (sid << 8 | 0x66)
+#define PM8350_ADC7_AMUX_THM4_400K_PU(sid) (sid << 8 | 0x67)
+#define PM8350_ADC7_AMUX_THM5_400K_PU(sid) (sid << 8 | 0x68)
+#define PM8350_ADC7_GPIO1_400K_PU(sid) (sid << 8 | 0x6a)
+#define PM8350_ADC7_GPIO2_400K_PU(sid) (sid << 8 | 0x6b)
+#define PM8350_ADC7_GPIO3_400K_PU(sid) (sid << 8 | 0x6c)
+#define PM8350_ADC7_GPIO4_400K_PU(sid) (sid << 8 | 0x6d)
/* 1/3 Divider */
-#define PM8350_ADC7_GPIO4_DIV3 (PM8350_SID << 8 | 0x8d)
+#define PM8350_ADC7_GPIO4_DIV3(sid) (sid << 8 | 0x8d)
-#define PM8350_ADC7_VPH_PWR (PM8350_SID << 8 | 0x8e)
+#define PM8350_ADC7_VPH_PWR(sid) (sid << 8 | 0x8e)
#endif /* _DT_BINDINGS_QCOM_SPMI_VADC_PM8350_H */