devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/6] arm64: dts: qcom: sc8280xp: remove duplication in PMIC declarations
@ 2023-03-29  0:08 Dmitry Baryshkov
  2023-03-29  0:08 ` [PATCH 1/6] dt-bindings: iio: qcom,spmi-adc7-pmk8350.h: include sid into defines Dmitry Baryshkov
                   ` (5 more replies)
  0 siblings, 6 replies; 18+ messages in thread
From: Dmitry Baryshkov @ 2023-03-29  0:08 UTC (permalink / raw)
  To: Andy Gross, Bjorn Andersson, Konrad Dybcio, Rob Herring,
	Krzysztof Kozlowski
  Cc: linux-arm-msm, Johan Hovold, devicetree, Jonathan Cameron,
	Lars-Peter Clausen, linux-iio

The sc8280xp platform uses its own copy of PMIC declarations. This can
easily end up with the issues that are fixed in the main PMIC include
file, but are not fixed for sc8280xp (and vice versa). For example
commit c0ee8e0ba5cc ("arm64: dts: qcom: pmk8350: Use the correct PON
compatible") changed pmk8350 to use "qcom,pmk8350-pon" compat for the
PON device, while sc8280xp-pmic.dtsi still has the incorrect
"qcom,pm8998-pon".

Another example is pm8280_2_temp_alarm device, which uses interrupts
tied to SID 2, while having SID 3. This can be easily left unnoticed.

Employ a small amount of C preprocessor magic to make
sc8280xp-pmics.dtsi use standard PMIC include files.

Dmitry Baryshkov (6):
  dt-bindings: iio: qcom,spmi-adc7-pmk8350.h: include sid into defines
  arm64: dts: qcom: pmk8350: rename pon label
  arm64: dts: qcom: use main pmk8350.dtsi for sc8280xp platform
  arm64: dts: qcom: pm8350: include SID into labels
  arm64: dts: qcom: sc8280xp*: use pm8350.dtsi
  arm64: dts: qcom: sc8280xp*: use pm8350c.dtsi and pmr735a.dtsi

 .../bindings/iio/adc/qcom,spmi-vadc.yaml      |   2 +-
 .../bindings/thermal/qcom-spmi-adc-tm5.yaml   |   4 +-
 arch/arm64/boot/dts/qcom/pm8350.dtsi          |  31 ++-
 arch/arm64/boot/dts/qcom/pmk8350.dtsi         |  13 +-
 arch/arm64/boot/dts/qcom/sc7280-idp.dtsi      |   2 +-
 arch/arm64/boot/dts/qcom/sc7280-qcard.dtsi    |   2 +-
 arch/arm64/boot/dts/qcom/sc8280xp-crd.dts     |  24 +-
 .../qcom/sc8280xp-lenovo-thinkpad-x13s.dts    |  52 ++---
 arch/arm64/boot/dts/qcom/sc8280xp-pmics.dtsi  | 210 ++----------------
 .../boot/dts/qcom/sm7225-fairphone-fp4.dts    |   2 +-
 arch/arm64/boot/dts/qcom/sm8350-mtp.dts       |   8 +-
 .../dts/qcom/sm8350-sony-xperia-sagami.dtsi   |  12 +-
 .../dts/qcom/sm8450-sony-xperia-nagara.dtsi   |   8 +-
 .../dt-bindings/iio/qcom,spmi-adc7-pmk8350.h  |  52 ++---
 14 files changed, 128 insertions(+), 294 deletions(-)

-- 
2.30.2


^ permalink raw reply	[flat|nested] 18+ messages in thread

* [PATCH 1/6] dt-bindings: iio: qcom,spmi-adc7-pmk8350.h: include sid into defines
  2023-03-29  0:08 [PATCH 0/6] arm64: dts: qcom: sc8280xp: remove duplication in PMIC declarations Dmitry Baryshkov
@ 2023-03-29  0:08 ` Dmitry Baryshkov
  2023-03-29  0:21   ` Konrad Dybcio
                     ` (2 more replies)
  2023-03-29  0:08 ` [PATCH 2/6] arm64: dts: qcom: pmk8350: rename pon label Dmitry Baryshkov
                   ` (4 subsequent siblings)
  5 siblings, 3 replies; 18+ messages in thread
From: Dmitry Baryshkov @ 2023-03-29  0:08 UTC (permalink / raw)
  To: Andy Gross, Bjorn Andersson, Konrad Dybcio, Rob Herring,
	Krzysztof Kozlowski
  Cc: linux-arm-msm, Johan Hovold, devicetree, Jonathan Cameron,
	Lars-Peter Clausen, linux-iio

pmk8350 can take different addresses on SPMI bus. Rather than having a
default SID, follow the pm8350's example and make the sid explicit when
specifying ADC channels.

Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
---
 .../bindings/iio/adc/qcom,spmi-vadc.yaml      |  2 +-
 .../bindings/thermal/qcom-spmi-adc-tm5.yaml   |  4 +-
 arch/arm64/boot/dts/qcom/sc7280-idp.dtsi      |  2 +-
 arch/arm64/boot/dts/qcom/sc7280-qcard.dtsi    |  2 +-
 .../qcom/sc8280xp-lenovo-thinkpad-x13s.dts    |  4 +-
 .../boot/dts/qcom/sm7225-fairphone-fp4.dts    |  2 +-
 .../dt-bindings/iio/qcom,spmi-adc7-pmk8350.h  | 52 +++++++++----------
 7 files changed, 32 insertions(+), 36 deletions(-)

diff --git a/Documentation/devicetree/bindings/iio/adc/qcom,spmi-vadc.yaml b/Documentation/devicetree/bindings/iio/adc/qcom,spmi-vadc.yaml
index bd6e0d6f6e0c..df317901e7d0 100644
--- a/Documentation/devicetree/bindings/iio/adc/qcom,spmi-vadc.yaml
+++ b/Documentation/devicetree/bindings/iio/adc/qcom,spmi-vadc.yaml
@@ -293,7 +293,7 @@ examples:
 
             /* Other properties are omitted */
             xo-therm@44 {
-                reg = <PMK8350_ADC7_AMUX_THM1_100K_PU>;
+                reg = <PMK8350_ADC7_AMUX_THM1_100K_PU(0)>;
                 qcom,ratiometric;
                 qcom,hw-settle-time = <200>;
             };
diff --git a/Documentation/devicetree/bindings/thermal/qcom-spmi-adc-tm5.yaml b/Documentation/devicetree/bindings/thermal/qcom-spmi-adc-tm5.yaml
index 52ec18cf1eda..ff07d27775dc 100644
--- a/Documentation/devicetree/bindings/thermal/qcom-spmi-adc-tm5.yaml
+++ b/Documentation/devicetree/bindings/thermal/qcom-spmi-adc-tm5.yaml
@@ -218,7 +218,7 @@ examples:
 
             /* Other properties are omitted */
             xo-therm@44 {
-                reg = <PMK8350_ADC7_AMUX_THM1_100K_PU>;
+                reg = <PMK8350_ADC7_AMUX_THM1_100K_PU(0)>;
                 qcom,ratiometric;
                 qcom,hw-settle-time = <200>;
             };
@@ -240,7 +240,7 @@ examples:
 
             pmk8350-xo-therm@0 {
                 reg = <0>;
-                io-channels = <&pmk8350_vadc PMK8350_ADC7_AMUX_THM1_100K_PU>;
+                io-channels = <&pmk8350_vadc PMK8350_ADC7_AMUX_THM1_100K_PU(0)>;
                 qcom,decimation = <340>;
                 qcom,ratiometric;
                 qcom,hw-settle-time-us = <200>;
diff --git a/arch/arm64/boot/dts/qcom/sc7280-idp.dtsi b/arch/arm64/boot/dts/qcom/sc7280-idp.dtsi
index 5dc9bee28e7f..14c9bdaa46ed 100644
--- a/arch/arm64/boot/dts/qcom/sc7280-idp.dtsi
+++ b/arch/arm64/boot/dts/qcom/sc7280-idp.dtsi
@@ -433,7 +433,7 @@ &pcie1_phy {
 
 &pmk8350_vadc {
 	pmk8350-die-temp@3 {
-		reg = <PMK8350_ADC7_DIE_TEMP>;
+		reg = <PMK8350_ADC7_DIE_TEMP(0)>;
 		label = "pmk8350_die_temp";
 		qcom,pre-scaling = <1 1>;
 	};
diff --git a/arch/arm64/boot/dts/qcom/sc7280-qcard.dtsi b/arch/arm64/boot/dts/qcom/sc7280-qcard.dtsi
index cb0cc2ba2fa3..e3919e074ebd 100644
--- a/arch/arm64/boot/dts/qcom/sc7280-qcard.dtsi
+++ b/arch/arm64/boot/dts/qcom/sc7280-qcard.dtsi
@@ -389,7 +389,7 @@ &pm8350c_pwm {
 
 &pmk8350_vadc {
 	pmk8350-die-temp@3 {
-		reg = <PMK8350_ADC7_DIE_TEMP>;
+		reg = <PMK8350_ADC7_DIE_TEMP(0)>;
 		label = "pmk8350_die_temp";
 		qcom,pre-scaling = <1 1>;
 	};
diff --git a/arch/arm64/boot/dts/qcom/sc8280xp-lenovo-thinkpad-x13s.dts b/arch/arm64/boot/dts/qcom/sc8280xp-lenovo-thinkpad-x13s.dts
index 46c7fdafb840..590400985055 100644
--- a/arch/arm64/boot/dts/qcom/sc8280xp-lenovo-thinkpad-x13s.dts
+++ b/arch/arm64/boot/dts/qcom/sc8280xp-lenovo-thinkpad-x13s.dts
@@ -824,13 +824,13 @@ &pmk8280_vadc {
 	status = "okay";
 
 	pmic-die-temp@3 {
-		reg = <PMK8350_ADC7_DIE_TEMP>;
+		reg = <PMK8350_ADC7_DIE_TEMP(0)>;
 		qcom,pre-scaling = <1 1>;
 		label = "pmk8350_die_temp";
 	};
 
 	xo-therm@44 {
-		reg = <PMK8350_ADC7_AMUX_THM1_100K_PU>;
+		reg = <PMK8350_ADC7_AMUX_THM1_100K_PU(0)>;
 		qcom,hw-settle-time = <200>;
 		qcom,ratiometric;
 		label = "pmk8350_xo_therm";
diff --git a/arch/arm64/boot/dts/qcom/sm7225-fairphone-fp4.dts b/arch/arm64/boot/dts/qcom/sm7225-fairphone-fp4.dts
index 7ae6aba5d2ec..af6cf4fbddc7 100644
--- a/arch/arm64/boot/dts/qcom/sm7225-fairphone-fp4.dts
+++ b/arch/arm64/boot/dts/qcom/sm7225-fairphone-fp4.dts
@@ -516,7 +516,7 @@ &pmk8350_rtc {
 
 &pmk8350_vadc {
 	adc-chan@644 {
-		reg = <PMK8350_ADC7_AMUX_THM1_100K_PU>;
+		reg = <PMK8350_ADC7_AMUX_THM1_100K_PU(0)>;
 		qcom,ratiometric;
 		qcom,hw-settle-time = <200>;
 		qcom,pre-scaling = <1 1>;
diff --git a/include/dt-bindings/iio/qcom,spmi-adc7-pmk8350.h b/include/dt-bindings/iio/qcom,spmi-adc7-pmk8350.h
index 6c296870e95b..ca85a2d69453 100644
--- a/include/dt-bindings/iio/qcom,spmi-adc7-pmk8350.h
+++ b/include/dt-bindings/iio/qcom,spmi-adc7-pmk8350.h
@@ -6,41 +6,37 @@
 #ifndef _DT_BINDINGS_QCOM_SPMI_VADC_PMK8350_H
 #define _DT_BINDINGS_QCOM_SPMI_VADC_PMK8350_H
 
-#ifndef PMK8350_SID
-#define PMK8350_SID					0
-#endif
-
 /* ADC channels for PMK8350_ADC for PMIC7 */
-#define PMK8350_ADC7_REF_GND			(PMK8350_SID << 8 | 0x0)
-#define PMK8350_ADC7_1P25VREF			(PMK8350_SID << 8 | 0x01)
-#define PMK8350_ADC7_VREF_VADC			(PMK8350_SID << 8 | 0x02)
-#define PMK8350_ADC7_DIE_TEMP			(PMK8350_SID << 8 | 0x03)
+#define PMK8350_ADC7_REF_GND(sid)			((sid) << 8 | 0x0)
+#define PMK8350_ADC7_1P25VREF(sid)			((sid) << 8 | 0x01)
+#define PMK8350_ADC7_VREF_VADC(sid)			((sid) << 8 | 0x02)
+#define PMK8350_ADC7_DIE_TEMP(sid)			((sid) << 8 | 0x03)
 
-#define PMK8350_ADC7_AMUX_THM1			(PMK8350_SID << 8 | 0x04)
-#define PMK8350_ADC7_AMUX_THM2			(PMK8350_SID << 8 | 0x05)
-#define PMK8350_ADC7_AMUX_THM3			(PMK8350_SID << 8 | 0x06)
-#define PMK8350_ADC7_AMUX_THM4			(PMK8350_SID << 8 | 0x07)
-#define PMK8350_ADC7_AMUX_THM5			(PMK8350_SID << 8 | 0x08)
+#define PMK8350_ADC7_AMUX_THM1(sid)			((sid) << 8 | 0x04)
+#define PMK8350_ADC7_AMUX_THM2(sid)			((sid) << 8 | 0x05)
+#define PMK8350_ADC7_AMUX_THM3(sid)			((sid) << 8 | 0x06)
+#define PMK8350_ADC7_AMUX_THM4(sid)			((sid) << 8 | 0x07)
+#define PMK8350_ADC7_AMUX_THM5(sid)			((sid) << 8 | 0x08)
 
 /* 30k pull-up1 */
-#define PMK8350_ADC7_AMUX_THM1_30K_PU		(PMK8350_SID << 8 | 0x24)
-#define PMK8350_ADC7_AMUX_THM2_30K_PU		(PMK8350_SID << 8 | 0x25)
-#define PMK8350_ADC7_AMUX_THM3_30K_PU		(PMK8350_SID << 8 | 0x26)
-#define PMK8350_ADC7_AMUX_THM4_30K_PU		(PMK8350_SID << 8 | 0x27)
-#define PMK8350_ADC7_AMUX_THM5_30K_PU		(PMK8350_SID << 8 | 0x28)
+#define PMK8350_ADC7_AMUX_THM1_30K_PU(sid)		((sid) << 8 | 0x24)
+#define PMK8350_ADC7_AMUX_THM2_30K_PU(sid)		((sid) << 8 | 0x25)
+#define PMK8350_ADC7_AMUX_THM3_30K_PU(sid)		((sid) << 8 | 0x26)
+#define PMK8350_ADC7_AMUX_THM4_30K_PU(sid)		((sid) << 8 | 0x27)
+#define PMK8350_ADC7_AMUX_THM5_30K_PU(sid)		((sid) << 8 | 0x28)
 
 /* 100k pull-up2 */
-#define PMK8350_ADC7_AMUX_THM1_100K_PU		(PMK8350_SID << 8 | 0x44)
-#define PMK8350_ADC7_AMUX_THM2_100K_PU		(PMK8350_SID << 8 | 0x45)
-#define PMK8350_ADC7_AMUX_THM3_100K_PU		(PMK8350_SID << 8 | 0x46)
-#define PMK8350_ADC7_AMUX_THM4_100K_PU		(PMK8350_SID << 8 | 0x47)
-#define PMK8350_ADC7_AMUX_THM5_100K_PU		(PMK8350_SID << 8 | 0x48)
+#define PMK8350_ADC7_AMUX_THM1_100K_PU(sid)		((sid) << 8 | 0x44)
+#define PMK8350_ADC7_AMUX_THM2_100K_PU(sid)		((sid) << 8 | 0x45)
+#define PMK8350_ADC7_AMUX_THM3_100K_PU(sid)		((sid) << 8 | 0x46)
+#define PMK8350_ADC7_AMUX_THM4_100K_PU(sid)		((sid) << 8 | 0x47)
+#define PMK8350_ADC7_AMUX_THM5_100K_PU(sid)		((sid) << 8 | 0x48)
 
 /* 400k pull-up3 */
-#define PMK8350_ADC7_AMUX_THM1_400K_PU		(PMK8350_SID << 8 | 0x64)
-#define PMK8350_ADC7_AMUX_THM2_400K_PU		(PMK8350_SID << 8 | 0x65)
-#define PMK8350_ADC7_AMUX_THM3_400K_PU		(PMK8350_SID << 8 | 0x66)
-#define PMK8350_ADC7_AMUX_THM4_400K_PU		(PMK8350_SID << 8 | 0x67)
-#define PMK8350_ADC7_AMUX_THM5_400K_PU		(PMK8350_SID << 8 | 0x68)
+#define PMK8350_ADC7_AMUX_THM1_400K_PU(sid)		((sid) << 8 | 0x64)
+#define PMK8350_ADC7_AMUX_THM2_400K_PU(sid)		((sid) << 8 | 0x65)
+#define PMK8350_ADC7_AMUX_THM3_400K_PU(sid)		((sid) << 8 | 0x66)
+#define PMK8350_ADC7_AMUX_THM4_400K_PU(sid)		((sid) << 8 | 0x67)
+#define PMK8350_ADC7_AMUX_THM5_400K_PU(sid)		((sid) << 8 | 0x68)
 
 #endif /* _DT_BINDINGS_QCOM_SPMI_VADC_PMK8350_H */
-- 
2.30.2


^ permalink raw reply related	[flat|nested] 18+ messages in thread

* [PATCH 2/6] arm64: dts: qcom: pmk8350: rename pon label
  2023-03-29  0:08 [PATCH 0/6] arm64: dts: qcom: sc8280xp: remove duplication in PMIC declarations Dmitry Baryshkov
  2023-03-29  0:08 ` [PATCH 1/6] dt-bindings: iio: qcom,spmi-adc7-pmk8350.h: include sid into defines Dmitry Baryshkov
@ 2023-03-29  0:08 ` Dmitry Baryshkov
  2023-03-29  0:22   ` Konrad Dybcio
  2023-03-29  0:08 ` [PATCH 3/6] arm64: dts: qcom: use main pmk8350.dtsi for sc8280xp platform Dmitry Baryshkov
                   ` (3 subsequent siblings)
  5 siblings, 1 reply; 18+ messages in thread
From: Dmitry Baryshkov @ 2023-03-29  0:08 UTC (permalink / raw)
  To: Andy Gross, Bjorn Andersson, Konrad Dybcio, Rob Herring,
	Krzysztof Kozlowski
  Cc: linux-arm-msm, Johan Hovold, devicetree, Jonathan Cameron,
	Lars-Peter Clausen, linux-iio

To reduce a possibility of the conflicts, rename pmk8350's pon_pwrkey
and pon_resin to contain the PMIC name too.

Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
---
 arch/arm64/boot/dts/qcom/pmk8350.dtsi                   | 4 ++--
 arch/arm64/boot/dts/qcom/sm8350-mtp.dts                 | 8 ++++----
 arch/arm64/boot/dts/qcom/sm8350-sony-xperia-sagami.dtsi | 8 ++++----
 arch/arm64/boot/dts/qcom/sm8450-sony-xperia-nagara.dtsi | 4 ++--
 4 files changed, 12 insertions(+), 12 deletions(-)

diff --git a/arch/arm64/boot/dts/qcom/pmk8350.dtsi b/arch/arm64/boot/dts/qcom/pmk8350.dtsi
index f26fb7d32faf..455ffffb5f5c 100644
--- a/arch/arm64/boot/dts/qcom/pmk8350.dtsi
+++ b/arch/arm64/boot/dts/qcom/pmk8350.dtsi
@@ -25,14 +25,14 @@ pmk8350_pon: pon@1300 {
 			reg = <0x1300>, <0x800>;
 			reg-names = "hlos", "pbs";
 
-			pon_pwrkey: pwrkey {
+			pmk8350_pon_pwrkey: pwrkey {
 				compatible = "qcom,pmk8350-pwrkey";
 				interrupts = <PMK8350_SID 0x13 0x7 IRQ_TYPE_EDGE_BOTH>;
 				linux,code = <KEY_POWER>;
 				status = "disabled";
 			};
 
-			pon_resin: resin {
+			pmk8350_pon_resin: resin {
 				compatible = "qcom,pmk8350-resin";
 				interrupts = <PMK8350_SID 0x13 0x6 IRQ_TYPE_EDGE_BOTH>;
 				status = "disabled";
diff --git a/arch/arm64/boot/dts/qcom/sm8350-mtp.dts b/arch/arm64/boot/dts/qcom/sm8350-mtp.dts
index d21d2aacf201..152601832cbc 100644
--- a/arch/arm64/boot/dts/qcom/sm8350-mtp.dts
+++ b/arch/arm64/boot/dts/qcom/sm8350-mtp.dts
@@ -285,17 +285,17 @@ &mpss {
 	firmware-name = "qcom/sm8350/modem.mbn";
 };
 
-&pmk8350_rtc {
+&pmk8350_pon_pwrkey {
 	status = "okay";
 };
 
-&pon_pwrkey {
+&pmk8350_pon_resin {
 	status = "okay";
+	linux,code = <KEY_VOLUMEDOWN>;
 };
 
-&pon_resin {
+&pmk8350_rtc {
 	status = "okay";
-	linux,code = <KEY_VOLUMEDOWN>;
 };
 
 &qupv3_id_0 {
diff --git a/arch/arm64/boot/dts/qcom/sm8350-sony-xperia-sagami.dtsi b/arch/arm64/boot/dts/qcom/sm8350-sony-xperia-sagami.dtsi
index 89382ad73133..e28f49e31b9f 100644
--- a/arch/arm64/boot/dts/qcom/sm8350-sony-xperia-sagami.dtsi
+++ b/arch/arm64/boot/dts/qcom/sm8350-sony-xperia-sagami.dtsi
@@ -618,17 +618,17 @@ vol_down_n: vol-down-n-state {
 	};
 };
 
-&pmk8350_rtc {
+&pmk8350_pon_pwrkey {
 	status = "okay";
 };
 
-&pon_pwrkey {
+&pmk8350_pon_resin {
 	status = "okay";
+	linux,code = <KEY_VOLUMEUP>;
 };
 
-&pon_resin {
+&pmk8350_rtc {
 	status = "okay";
-	linux,code = <KEY_VOLUMEUP>;
 };
 
 &qupv3_id_0 {
diff --git a/arch/arm64/boot/dts/qcom/sm8450-sony-xperia-nagara.dtsi b/arch/arm64/boot/dts/qcom/sm8450-sony-xperia-nagara.dtsi
index 67538b5a557e..99e9b776b93d 100644
--- a/arch/arm64/boot/dts/qcom/sm8450-sony-xperia-nagara.dtsi
+++ b/arch/arm64/boot/dts/qcom/sm8450-sony-xperia-nagara.dtsi
@@ -684,11 +684,11 @@ &pmk8350_gpios {
 			  "PMK8350_OPTION";
 };
 
-&pon_pwrkey {
+&pmk8350_pon_pwrkey {
 	status = "okay";
 };
 
-&pon_resin {
+&pmk8350_pon_resin {
 	linux,code = <KEY_VOLUMEUP>;
 	status = "okay";
 };
-- 
2.30.2


^ permalink raw reply related	[flat|nested] 18+ messages in thread

* [PATCH 3/6] arm64: dts: qcom: use main pmk8350.dtsi for sc8280xp platform
  2023-03-29  0:08 [PATCH 0/6] arm64: dts: qcom: sc8280xp: remove duplication in PMIC declarations Dmitry Baryshkov
  2023-03-29  0:08 ` [PATCH 1/6] dt-bindings: iio: qcom,spmi-adc7-pmk8350.h: include sid into defines Dmitry Baryshkov
  2023-03-29  0:08 ` [PATCH 2/6] arm64: dts: qcom: pmk8350: rename pon label Dmitry Baryshkov
@ 2023-03-29  0:08 ` Dmitry Baryshkov
  2023-03-29  0:27   ` Konrad Dybcio
  2023-03-29  0:08 ` [PATCH 4/6] arm64: dts: qcom: pm8350: include SID into labels Dmitry Baryshkov
                   ` (2 subsequent siblings)
  5 siblings, 1 reply; 18+ messages in thread
From: Dmitry Baryshkov @ 2023-03-29  0:08 UTC (permalink / raw)
  To: Andy Gross, Bjorn Andersson, Konrad Dybcio, Rob Herring,
	Krzysztof Kozlowski
  Cc: linux-arm-msm, Johan Hovold, devicetree, Jonathan Cameron,
	Lars-Peter Clausen, linux-iio

Employ existing PMK8350_SID and switch sc8280xp-pmics to use
pmk8350.dtsi to reduce duplication and possible discrepancies.

For example, this changes sc8280xp platforms to use qcom,pmk8350-pon
for the pon device compatibility rather than the incorrect
qcom,pm8998-pon.

Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
---
 arch/arm64/boot/dts/qcom/pmk8350.dtsi         |  9 +++
 arch/arm64/boot/dts/qcom/sc8280xp-crd.dts     |  6 +-
 .../qcom/sc8280xp-lenovo-thinkpad-x13s.dts    | 30 ++++-----
 arch/arm64/boot/dts/qcom/sc8280xp-pmics.dtsi  | 67 ++-----------------
 4 files changed, 31 insertions(+), 81 deletions(-)

diff --git a/arch/arm64/boot/dts/qcom/pmk8350.dtsi b/arch/arm64/boot/dts/qcom/pmk8350.dtsi
index 455ffffb5f5c..26e40dbfc173 100644
--- a/arch/arm64/boot/dts/qcom/pmk8350.dtsi
+++ b/arch/arm64/boot/dts/qcom/pmk8350.dtsi
@@ -66,6 +66,15 @@ pmk8350_rtc: rtc@6100 {
 			status = "disabled";
 		};
 
+		pmk8350_sdam_6: nvram@8500 {
+			compatible = "qcom,spmi-sdam";
+			reg = <0x8500>;
+			#address-cells = <1>;
+			#size-cells = <1>;
+			ranges = <0 0x8500 0x100>;
+			status = "disabled";
+		};
+
 		pmk8350_gpios: gpio@b000 {
 			compatible = "qcom,pmk8350-gpio", "qcom,spmi-gpio";
 			reg = <0xb000>;
diff --git a/arch/arm64/boot/dts/qcom/sc8280xp-crd.dts b/arch/arm64/boot/dts/qcom/sc8280xp-crd.dts
index d7b537284990..d32594b5a4e7 100644
--- a/arch/arm64/boot/dts/qcom/sc8280xp-crd.dts
+++ b/arch/arm64/boot/dts/qcom/sc8280xp-crd.dts
@@ -559,18 +559,18 @@ &pmc8280c_lpg {
 	status = "okay";
 };
 
-&pmk8280_pon_pwrkey {
+&pmk8350_pon_pwrkey {
 	status = "okay";
 };
 
-&pmk8280_rtc {
+&pmk8350_rtc {
 	nvmem-cells = <&rtc_offset>;
 	nvmem-cell-names = "offset";
 
 	status = "okay";
 };
 
-&pmk8280_sdam_6 {
+&pmk8350_sdam_6 {
 	status = "okay";
 
 	rtc_offset: rtc-offset@bc {
diff --git a/arch/arm64/boot/dts/qcom/sc8280xp-lenovo-thinkpad-x13s.dts b/arch/arm64/boot/dts/qcom/sc8280xp-lenovo-thinkpad-x13s.dts
index 590400985055..7d61108daede 100644
--- a/arch/arm64/boot/dts/qcom/sc8280xp-lenovo-thinkpad-x13s.dts
+++ b/arch/arm64/boot/dts/qcom/sc8280xp-lenovo-thinkpad-x13s.dts
@@ -275,7 +275,7 @@ thermal-zones {
 		skin-temp-thermal {
 			polling-delay-passive = <250>;
 			polling-delay = <0>;
-			thermal-sensors = <&pmk8280_adc_tm 5>;
+			thermal-sensors = <&pmk8350_adc_tm 5>;
 
 			trips {
 				skin_temp_alert0: trip-point0 {
@@ -729,12 +729,12 @@ &pmc8280c_lpg {
 	status = "okay";
 };
 
-&pmk8280_adc_tm {
+&pmk8350_adc_tm {
 	status = "okay";
 
 	sys-therm@0 {
 		reg = <0>;
-		io-channels = <&pmk8280_vadc PM8350_ADC7_AMUX_THM1_100K_PU(1)>;
+		io-channels = <&pmk8350_vadc PM8350_ADC7_AMUX_THM1_100K_PU(1)>;
 		qcom,hw-settle-time-us = <200>;
 		qcom,avg-samples = <2>;
 		qcom,ratiometric;
@@ -742,7 +742,7 @@ sys-therm@0 {
 
 	sys-therm@1 {
 		reg = <1>;
-		io-channels = <&pmk8280_vadc PM8350_ADC7_AMUX_THM2_100K_PU(1)>;
+		io-channels = <&pmk8350_vadc PM8350_ADC7_AMUX_THM2_100K_PU(1)>;
 		qcom,hw-settle-time-us = <200>;
 		qcom,avg-samples = <2>;
 		qcom,ratiometric;
@@ -750,7 +750,7 @@ sys-therm@1 {
 
 	sys-therm@2 {
 		reg = <2>;
-		io-channels = <&pmk8280_vadc PM8350_ADC7_AMUX_THM3_100K_PU(1)>;
+		io-channels = <&pmk8350_vadc PM8350_ADC7_AMUX_THM3_100K_PU(1)>;
 		qcom,hw-settle-time-us = <200>;
 		qcom,avg-samples = <2>;
 		qcom,ratiometric;
@@ -758,7 +758,7 @@ sys-therm@2 {
 
 	sys-therm@3 {
 		reg = <3>;
-		io-channels = <&pmk8280_vadc PM8350_ADC7_AMUX_THM4_100K_PU(1)>;
+		io-channels = <&pmk8350_vadc PM8350_ADC7_AMUX_THM4_100K_PU(1)>;
 		qcom,hw-settle-time-us = <200>;
 		qcom,avg-samples = <2>;
 		qcom,ratiometric;
@@ -766,7 +766,7 @@ sys-therm@3 {
 
 	sys-therm@4 {
 		reg = <4>;
-		io-channels = <&pmk8280_vadc PM8350_ADC7_AMUX_THM1_100K_PU(3)>;
+		io-channels = <&pmk8350_vadc PM8350_ADC7_AMUX_THM1_100K_PU(3)>;
 		qcom,hw-settle-time-us = <200>;
 		qcom,avg-samples = <2>;
 		qcom,ratiometric;
@@ -774,7 +774,7 @@ sys-therm@4 {
 
 	sys-therm@5 {
 		reg = <5>;
-		io-channels = <&pmk8280_vadc PM8350_ADC7_AMUX_THM2_100K_PU(3)>;
+		io-channels = <&pmk8350_vadc PM8350_ADC7_AMUX_THM2_100K_PU(3)>;
 		qcom,hw-settle-time-us = <200>;
 		qcom,avg-samples = <2>;
 		qcom,ratiometric;
@@ -782,7 +782,7 @@ sys-therm@5 {
 
 	sys-therm@6 {
 		reg = <6>;
-		io-channels = <&pmk8280_vadc PM8350_ADC7_AMUX_THM3_100K_PU(3)>;
+		io-channels = <&pmk8350_vadc PM8350_ADC7_AMUX_THM3_100K_PU(3)>;
 		qcom,hw-settle-time-us = <200>;
 		qcom,avg-samples = <2>;
 		qcom,ratiometric;
@@ -790,29 +790,29 @@ sys-therm@6 {
 
 	sys-therm@7 {
 		reg = <7>;
-		io-channels = <&pmk8280_vadc PM8350_ADC7_AMUX_THM4_100K_PU(3)>;
+		io-channels = <&pmk8350_vadc PM8350_ADC7_AMUX_THM4_100K_PU(3)>;
 		qcom,hw-settle-time-us = <200>;
 		qcom,avg-samples = <2>;
 		qcom,ratiometric;
 	};
 };
 
-&pmk8280_pon_pwrkey {
+&pmk8350_pon_pwrkey {
 	status = "okay";
 };
 
-&pmk8280_pon_resin {
+&pmk8350_pon_resin {
 	status = "okay";
 };
 
-&pmk8280_rtc {
+&pmk8350_rtc {
 	nvmem-cells = <&rtc_offset>;
 	nvmem-cell-names = "offset";
 
 	status = "okay";
 };
 
-&pmk8280_sdam_6 {
+&pmk8350_sdam_6 {
 	status = "okay";
 
 	rtc_offset: rtc-offset@bc {
@@ -820,7 +820,7 @@ rtc_offset: rtc-offset@bc {
 	};
 };
 
-&pmk8280_vadc {
+&pmk8350_vadc {
 	status = "okay";
 
 	pmic-die-temp@3 {
diff --git a/arch/arm64/boot/dts/qcom/sc8280xp-pmics.dtsi b/arch/arm64/boot/dts/qcom/sc8280xp-pmics.dtsi
index c35e7f6bd657..781fb6448a52 100644
--- a/arch/arm64/boot/dts/qcom/sc8280xp-pmics.dtsi
+++ b/arch/arm64/boot/dts/qcom/sc8280xp-pmics.dtsi
@@ -51,70 +51,11 @@ trip1 {
 	};
 };
 
-&spmi_bus {
-	pmk8280: pmic@0 {
-		compatible = "qcom,pmk8350", "qcom,spmi-pmic";
-		reg = <0x0 SPMI_USID>;
-		#address-cells = <1>;
-		#size-cells = <0>;
-
-		pmk8280_pon: pon@1300 {
-			compatible = "qcom,pm8998-pon";
-			reg = <0x1300>;
-
-			pmk8280_pon_pwrkey: pwrkey {
-				compatible = "qcom,pmk8350-pwrkey";
-				interrupts-extended = <&spmi_bus 0x0 0x13 0x7 IRQ_TYPE_EDGE_BOTH>;
-				linux,code = <KEY_POWER>;
-				status = "disabled";
-			};
-
-			pmk8280_pon_resin: resin {
-				compatible = "qcom,pmk8350-resin";
-				interrupts-extended = <&spmi_bus 0x0 0x13 0x6 IRQ_TYPE_EDGE_BOTH>;
-				status = "disabled";
-			};
-		};
-
-		pmk8280_vadc: adc@3100 {
-			compatible = "qcom,spmi-adc7";
-			reg = <0x3100>;
-			interrupts-extended = <&spmi_bus 0x0 0x31 0x0 IRQ_TYPE_EDGE_RISING>;
-			#address-cells = <1>;
-			#size-cells = <0>;
-			#io-channel-cells = <1>;
-			status = "disabled";
-		};
-
-		pmk8280_adc_tm: adc-tm@3400 {
-			compatible = "qcom,spmi-adc-tm5-gen2";
-			reg = <0x3400>;
-			interrupts-extended = <&spmi_bus 0x0 0x34 0x0 IRQ_TYPE_EDGE_RISING>;
-			#address-cells = <1>;
-			#size-cells = <0>;
-			#thermal-sensor-cells = <1>;
-			status = "disabled";
-		};
-
-		pmk8280_rtc: rtc@6100 {
-			compatible = "qcom,pmk8350-rtc";
-			reg = <0x6100>, <0x6200>;
-			reg-names = "rtc", "alarm";
-			interrupts = <0x0 0x62 0x1 IRQ_TYPE_EDGE_RISING>;
-			wakeup-source;
-			status = "disabled";
-		};
-
-		pmk8280_sdam_6: nvram@8500 {
-			compatible = "qcom,spmi-sdam";
-			reg = <0x8500>;
-			#address-cells = <1>;
-			#size-cells = <1>;
-			ranges = <0 0x8500 0x100>;
-			status = "disabled";
-		};
-	};
+#define PMK8350_SID 0
+#include "pmk8350.dtsi"
+#undef PMK8350_SID
 
+&spmi_bus {
 	pmc8280_1: pmic@1 {
 		compatible = "qcom,pm8350", "qcom,spmi-pmic";
 		reg = <0x1 SPMI_USID>;
-- 
2.30.2


^ permalink raw reply related	[flat|nested] 18+ messages in thread

* [PATCH 4/6] arm64: dts: qcom: pm8350: include SID into labels
  2023-03-29  0:08 [PATCH 0/6] arm64: dts: qcom: sc8280xp: remove duplication in PMIC declarations Dmitry Baryshkov
                   ` (2 preceding siblings ...)
  2023-03-29  0:08 ` [PATCH 3/6] arm64: dts: qcom: use main pmk8350.dtsi for sc8280xp platform Dmitry Baryshkov
@ 2023-03-29  0:08 ` Dmitry Baryshkov
  2023-03-29  0:33   ` Konrad Dybcio
  2023-03-29  0:08 ` [PATCH 5/6] arm64: dts: qcom: sc8280xp*: use pm8350.dtsi Dmitry Baryshkov
  2023-03-29  0:08 ` [PATCH 6/6] arm64: dts: qcom: sc8280xp*: use pm8350c.dtsi and pmr735a.dtsi Dmitry Baryshkov
  5 siblings, 1 reply; 18+ messages in thread
From: Dmitry Baryshkov @ 2023-03-29  0:08 UTC (permalink / raw)
  To: Andy Gross, Bjorn Andersson, Konrad Dybcio, Rob Herring,
	Krzysztof Kozlowski
  Cc: linux-arm-msm, Johan Hovold, devicetree, Jonathan Cameron,
	Lars-Peter Clausen, linux-iio

The platform can use several instances of PM8350 PMIC. Include SID into
all the labels to simplify such platforms configuration.

Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
---
 arch/arm64/boot/dts/qcom/pm8350.dtsi          | 31 +++++++++++++------
 .../dts/qcom/sm8350-sony-xperia-sagami.dtsi   |  4 +--
 .../dts/qcom/sm8450-sony-xperia-nagara.dtsi   |  4 +--
 3 files changed, 26 insertions(+), 13 deletions(-)

diff --git a/arch/arm64/boot/dts/qcom/pm8350.dtsi b/arch/arm64/boot/dts/qcom/pm8350.dtsi
index 2dfeb99300d7..f1ef242760f2 100644
--- a/arch/arm64/boot/dts/qcom/pm8350.dtsi
+++ b/arch/arm64/boot/dts/qcom/pm8350.dtsi
@@ -6,21 +6,30 @@
 #include <dt-bindings/interrupt-controller/irq.h>
 #include <dt-bindings/spmi/spmi.h>
 
+/* (Sadly) this PMIC can be configured to be at different SIDs */
+#ifndef PM8350_SID
+	#define PM8350_SID 1
+#endif
+
+#define __LABEL(pmic, sid, name) pmic ## _ ## sid ## _ ## name
+#define _LABEL(pmic, sid, name) __LABEL(pmic, sid, name)
+#define LABEL(name) _LABEL(pm8350, PM8350_SID, name)
+
 / {
 	thermal-zones {
-		pm8350_thermal: pm8350c-thermal {
+		LABEL(thermal): pm8350c-thermal {
 			polling-delay-passive = <100>;
 			polling-delay = <0>;
-			thermal-sensors = <&pm8350_temp_alarm>;
+			thermal-sensors = <&LABEL(temp_alarm)>;
 
 			trips {
-				pm8350_trip0: trip0 {
+				LABEL(trip0): trip0 {
 					temperature = <95000>;
 					hysteresis = <0>;
 					type = "passive";
 				};
 
-				pm8350_crit: pm8350c-crit {
+				LABEL(crit): pm8350c-crit {
 					temperature = <115000>;
 					hysteresis = <0>;
 					type = "critical";
@@ -33,25 +42,29 @@ pm8350_crit: pm8350c-crit {
 &spmi_bus {
 	pm8350: pmic@1 {
 		compatible = "qcom,pm8350", "qcom,spmi-pmic";
-		reg = <0x1 SPMI_USID>;
+		reg = <PM8350_SID SPMI_USID>;
 		#address-cells = <1>;
 		#size-cells = <0>;
 
-		pm8350_temp_alarm: temp-alarm@a00 {
+		LABEL(temp_alarm): temp-alarm@a00 {
 			compatible = "qcom,spmi-temp-alarm";
 			reg = <0xa00>;
-			interrupts = <0x1 0xa 0x0 IRQ_TYPE_EDGE_BOTH>;
+			interrupts = <PM8350_SID 0xa 0x0 IRQ_TYPE_EDGE_BOTH>;
 			#thermal-sensor-cells = <0>;
 		};
 
-		pm8350_gpios: gpio@8800 {
+		LABEL(gpios): gpio@8800 {
 			compatible = "qcom,pm8350-gpio", "qcom,spmi-gpio";
 			reg = <0x8800>;
 			gpio-controller;
-			gpio-ranges = <&pm8350_gpios 0 0 10>;
+			gpio-ranges = <&LABEL(gpios) 0 0 10>;
 			#gpio-cells = <2>;
 			interrupt-controller;
 			#interrupt-cells = <2>;
 		};
 	};
 };
+
+#undef LABEL
+#undef _LABEL
+#undef __LABEL
diff --git a/arch/arm64/boot/dts/qcom/sm8350-sony-xperia-sagami.dtsi b/arch/arm64/boot/dts/qcom/sm8350-sony-xperia-sagami.dtsi
index e28f49e31b9f..5c09b1d8881b 100644
--- a/arch/arm64/boot/dts/qcom/sm8350-sony-xperia-sagami.dtsi
+++ b/arch/arm64/boot/dts/qcom/sm8350-sony-xperia-sagami.dtsi
@@ -72,7 +72,7 @@ key-camera-snapshot {
 
 		key-google-assist {
 			label = "Google Assistant Key";
-			gpios = <&pm8350_gpios 9 GPIO_ACTIVE_LOW>;
+			gpios = <&pm8350_1_gpios 9 GPIO_ACTIVE_LOW>;
 			linux,code = <KEY_LEFTMETA>;
 			debounce-interval = <15>;
 			linux,can-disable;
@@ -564,7 +564,7 @@ &mpss {
 	firmware-name = "qcom/sm8350/Sony/sagami/modem.mbn";
 };
 
-&pm8350_gpios {
+&pm8350_1_gpios {
 	gpio-line-names = "ASSIGN1_THERM", /* GPIO_1 */
 			  "LCD_ID",
 			  "SDR_MMW_THERM",
diff --git a/arch/arm64/boot/dts/qcom/sm8450-sony-xperia-nagara.dtsi b/arch/arm64/boot/dts/qcom/sm8450-sony-xperia-nagara.dtsi
index 99e9b776b93d..d90e3fedb742 100644
--- a/arch/arm64/boot/dts/qcom/sm8450-sony-xperia-nagara.dtsi
+++ b/arch/arm64/boot/dts/qcom/sm8450-sony-xperia-nagara.dtsi
@@ -56,7 +56,7 @@ key-camera-snapshot {
 		key-volume-down {
 			label = "Volume Down";
 			linux,code = <KEY_VOLUMEDOWN>;
-			gpios = <&pm8350_gpios 6 GPIO_ACTIVE_LOW>;
+			gpios = <&pm8350_1_gpios 6 GPIO_ACTIVE_LOW>;
 			debounce-interval = <15>;
 			linux,can-disable;
 			wakeup-source;
@@ -622,7 +622,7 @@ &pcie0_phy {
 	status = "okay";
 };
 
-&pm8350_gpios {
+&pm8350_1_gpios {
 	gpio-line-names = "ASSIGN1_THERM", /* GPIO_1 */
 			  "LCD_ID",
 			  "SDR_MMW_THERM",
-- 
2.30.2


^ permalink raw reply related	[flat|nested] 18+ messages in thread

* [PATCH 5/6] arm64: dts: qcom: sc8280xp*: use pm8350.dtsi
  2023-03-29  0:08 [PATCH 0/6] arm64: dts: qcom: sc8280xp: remove duplication in PMIC declarations Dmitry Baryshkov
                   ` (3 preceding siblings ...)
  2023-03-29  0:08 ` [PATCH 4/6] arm64: dts: qcom: pm8350: include SID into labels Dmitry Baryshkov
@ 2023-03-29  0:08 ` Dmitry Baryshkov
  2023-03-29  0:08 ` [PATCH 6/6] arm64: dts: qcom: sc8280xp*: use pm8350c.dtsi and pmr735a.dtsi Dmitry Baryshkov
  5 siblings, 0 replies; 18+ messages in thread
From: Dmitry Baryshkov @ 2023-03-29  0:08 UTC (permalink / raw)
  To: Andy Gross, Bjorn Andersson, Konrad Dybcio, Rob Herring,
	Krzysztof Kozlowski
  Cc: linux-arm-msm, Johan Hovold, devicetree, Jonathan Cameron,
	Lars-Peter Clausen, linux-iio

Employ PM8350_SID and switch sc8280xp-pmics to use pm8350.dtsi to reduce
duplication and possible discrepancies.

Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
---
 arch/arm64/boot/dts/qcom/sc8280xp-crd.dts     | 12 +--
 .../qcom/sc8280xp-lenovo-thinkpad-x13s.dts    | 12 +--
 arch/arm64/boot/dts/qcom/sc8280xp-pmics.dtsi  | 98 ++-----------------
 3 files changed, 19 insertions(+), 103 deletions(-)

diff --git a/arch/arm64/boot/dts/qcom/sc8280xp-crd.dts b/arch/arm64/boot/dts/qcom/sc8280xp-crd.dts
index d32594b5a4e7..58a14c39633b 100644
--- a/arch/arm64/boot/dts/qcom/sc8280xp-crd.dts
+++ b/arch/arm64/boot/dts/qcom/sc8280xp-crd.dts
@@ -25,7 +25,7 @@ aliases {
 	backlight: backlight {
 		compatible = "pwm-backlight";
 		pwms = <&pmc8280c_lpg 3 1000000>;
-		enable-gpios = <&pmc8280_1_gpios 8 GPIO_ACTIVE_HIGH>;
+		enable-gpios = <&pm8350_1_gpios 8 GPIO_ACTIVE_HIGH>;
 		power-supply = <&vreg_edp_bl>;
 
 		pinctrl-names = "default";
@@ -137,7 +137,7 @@ vreg_edp_bl: regulator-edp-bl {
 		regulator-min-microvolt = <3600000>;
 		regulator-max-microvolt = <3600000>;
 
-		gpio = <&pmc8280_1_gpios 9 GPIO_ACTIVE_HIGH>;
+		gpio = <&pm8350_1_gpios 9 GPIO_ACTIVE_HIGH>;
 		enable-active-high;
 
 		pinctrl-names = "default";
@@ -167,7 +167,7 @@ vreg_misc_3p3: regulator-misc-3p3 {
 		regulator-min-microvolt = <3300000>;
 		regulator-max-microvolt = <3300000>;
 
-		gpio = <&pmc8280_1_gpios 1 GPIO_ACTIVE_HIGH>;
+		gpio = <&pm8350_1_gpios 1 GPIO_ACTIVE_HIGH>;
 		enable-active-high;
 
 		pinctrl-names = "default";
@@ -200,7 +200,7 @@ vreg_wwan: regulator-wwan {
 		regulator-min-microvolt = <3300000>;
 		regulator-max-microvolt = <3300000>;
 
-		gpio = <&pmc8280_2_gpios 1 GPIO_ACTIVE_HIGH>;
+		gpio = <&pm8350_3_gpios 1 GPIO_ACTIVE_HIGH>;
 		enable-active-high;
 
 		pinctrl-names = "default";
@@ -686,7 +686,7 @@ &xo_board_clk {
 
 /* PINCTRL - additions to nodes defined in sc8280xp.dtsi */
 
-&pmc8280_1_gpios {
+&pm8350_1_gpios {
 	edp_bl_en: edp-bl-en-state {
 		pins = "gpio8";
 		function = "normal";
@@ -703,7 +703,7 @@ misc_3p3_reg_en: misc-3p3-reg-en-state {
 	};
 };
 
-&pmc8280_2_gpios {
+&pm8350_3_gpios {
 	wwan_sw_en: wwan-sw-en-state {
 		pins = "gpio1";
 		function = "normal";
diff --git a/arch/arm64/boot/dts/qcom/sc8280xp-lenovo-thinkpad-x13s.dts b/arch/arm64/boot/dts/qcom/sc8280xp-lenovo-thinkpad-x13s.dts
index 7d61108daede..023ccb7725ef 100644
--- a/arch/arm64/boot/dts/qcom/sc8280xp-lenovo-thinkpad-x13s.dts
+++ b/arch/arm64/boot/dts/qcom/sc8280xp-lenovo-thinkpad-x13s.dts
@@ -55,7 +55,7 @@ wcd938x: audio-codec {
 	backlight: backlight {
 		compatible = "pwm-backlight";
 		pwms = <&pmc8280c_lpg 3 1000000>;
-		enable-gpios = <&pmc8280_1_gpios 8 GPIO_ACTIVE_HIGH>;
+		enable-gpios = <&pm8350_1_gpios 8 GPIO_ACTIVE_HIGH>;
 		power-supply = <&vreg_edp_bl>;
 
 		pinctrl-names = "default";
@@ -178,7 +178,7 @@ vreg_edp_bl: regulator-edp-bl {
 		regulator-min-microvolt = <3600000>;
 		regulator-max-microvolt = <3600000>;
 
-		gpio = <&pmc8280_1_gpios 9 GPIO_ACTIVE_HIGH>;
+		gpio = <&pm8350_1_gpios 9 GPIO_ACTIVE_HIGH>;
 		enable-active-high;
 
 		pinctrl-names = "default";
@@ -194,7 +194,7 @@ vreg_misc_3p3: regulator-misc-3p3 {
 		regulator-min-microvolt = <3300000>;
 		regulator-max-microvolt = <3300000>;
 
-		gpio = <&pmc8280_1_gpios 1 GPIO_ACTIVE_HIGH>;
+		gpio = <&pm8350_1_gpios 1 GPIO_ACTIVE_HIGH>;
 		enable-active-high;
 
 		pinctrl-names = "default";
@@ -253,7 +253,7 @@ vreg_wwan: regulator-wwan {
 		regulator-min-microvolt = <3300000>;
 		regulator-max-microvolt = <3300000>;
 
-		gpio = <&pmc8280_2_gpios 1 GPIO_ACTIVE_HIGH>;
+		gpio = <&pm8350_3_gpios 1 GPIO_ACTIVE_HIGH>;
 		enable-active-high;
 
 		pinctrl-names = "default";
@@ -1148,7 +1148,7 @@ &lpass_tlmm {
 	status = "okay";
 };
 
-&pmc8280_1_gpios {
+&pm8350_1_gpios {
 	edp_bl_en: edp-bl-en-state {
 		pins = "gpio8";
 		function = "normal";
@@ -1165,7 +1165,7 @@ misc_3p3_reg_en: misc-3p3-reg-en-state {
 	};
 };
 
-&pmc8280_2_gpios {
+&pm8350_3_gpios {
 	wwan_sw_en: wwan-sw-en-state {
 		pins = "gpio1";
 		function = "normal";
diff --git a/arch/arm64/boot/dts/qcom/sc8280xp-pmics.dtsi b/arch/arm64/boot/dts/qcom/sc8280xp-pmics.dtsi
index 781fb6448a52..505bb8f9a13c 100644
--- a/arch/arm64/boot/dts/qcom/sc8280xp-pmics.dtsi
+++ b/arch/arm64/boot/dts/qcom/sc8280xp-pmics.dtsi
@@ -7,79 +7,19 @@
 #include <dt-bindings/interrupt-controller/irq.h>
 #include <dt-bindings/spmi/spmi.h>
 
-/ {
-	thermal-zones {
-		pm8280_1_thermal: pm8280-1-thermal {
-			polling-delay-passive = <100>;
-			polling-delay = <0>;
-			thermal-sensors = <&pm8280_1_temp_alarm>;
-
-			trips {
-				trip0 {
-					temperature = <95000>;
-					hysteresis = <0>;
-					type = "passive";
-				};
-
-				trip1 {
-					temperature = <115000>;
-					hysteresis = <0>;
-					type = "critical";
-				};
-			};
-		};
-
-		pm8280_2_thermal: pm8280-2-thermal {
-			polling-delay-passive = <100>;
-			polling-delay = <0>;
-			thermal-sensors = <&pm8280_2_temp_alarm>;
-
-			trips {
-				trip0 {
-					temperature = <95000>;
-					hysteresis = <0>;
-					type = "passive";
-				};
-
-				trip1 {
-					temperature = <115000>;
-					hysteresis = <0>;
-					type = "critical";
-				};
-			};
-		};
-	};
-};
-
 #define PMK8350_SID 0
 #include "pmk8350.dtsi"
 #undef PMK8350_SID
 
-&spmi_bus {
-	pmc8280_1: pmic@1 {
-		compatible = "qcom,pm8350", "qcom,spmi-pmic";
-		reg = <0x1 SPMI_USID>;
-		#address-cells = <1>;
-		#size-cells = <0>;
+#define PM8350_SID 1
+#include "pm8350.dtsi"
+#undef PM8350_SID
 
-		pm8280_1_temp_alarm: temp-alarm@a00 {
-			compatible = "qcom,spmi-temp-alarm";
-			reg = <0xa00>;
-			interrupts-extended = <&spmi_bus 0x1 0xa 0x0 IRQ_TYPE_EDGE_BOTH>;
-			#thermal-sensor-cells = <0>;
-		};
-
-		pmc8280_1_gpios: gpio@8800 {
-			compatible = "qcom,pm8350-gpio", "qcom,spmi-gpio";
-			reg = <0x8800>;
-			gpio-controller;
-			gpio-ranges = <&pmc8280_1_gpios 0 0 10>;
-			#gpio-cells = <2>;
-			interrupt-controller;
-			#interrupt-cells = <2>;
-		};
-	};
+#define PM8350_SID 3
+#include "pm8350.dtsi"
+#undef PM8350_SID
 
+&spmi_bus {
 	pmc8280c: pmic@2 {
 		compatible = "qcom,pm8350c", "qcom,spmi-pmic";
 		reg = <0x2 SPMI_USID>;
@@ -108,30 +48,6 @@ pmc8280c_lpg: pwm {
 		};
 	};
 
-	pmc8280_2: pmic@3 {
-		compatible = "qcom,pm8350", "qcom,spmi-pmic";
-		reg = <0x3 SPMI_USID>;
-		#address-cells = <1>;
-		#size-cells = <0>;
-
-		pm8280_2_temp_alarm: temp-alarm@a00 {
-			compatible = "qcom,spmi-temp-alarm";
-			reg = <0xa00>;
-			interrupts-extended = <&spmi_bus 0x2 0xa 0x0 IRQ_TYPE_EDGE_BOTH>;
-			#thermal-sensor-cells = <0>;
-		};
-
-		pmc8280_2_gpios: gpio@8800 {
-			compatible = "qcom,pm8350-gpio", "qcom,spmi-gpio";
-			reg = <0x8800>;
-			gpio-controller;
-			gpio-ranges = <&pmc8280_2_gpios 0 0 10>;
-			#gpio-cells = <2>;
-			interrupt-controller;
-			#interrupt-cells = <2>;
-		};
-	};
-
 	pmr735a: pmic@4 {
 		compatible = "qcom,pmr735a", "qcom,spmi-pmic";
 		reg = <0x4 SPMI_USID>;
-- 
2.30.2


^ permalink raw reply related	[flat|nested] 18+ messages in thread

* [PATCH 6/6] arm64: dts: qcom: sc8280xp*: use pm8350c.dtsi and pmr735a.dtsi
  2023-03-29  0:08 [PATCH 0/6] arm64: dts: qcom: sc8280xp: remove duplication in PMIC declarations Dmitry Baryshkov
                   ` (4 preceding siblings ...)
  2023-03-29  0:08 ` [PATCH 5/6] arm64: dts: qcom: sc8280xp*: use pm8350.dtsi Dmitry Baryshkov
@ 2023-03-29  0:08 ` Dmitry Baryshkov
  5 siblings, 0 replies; 18+ messages in thread
From: Dmitry Baryshkov @ 2023-03-29  0:08 UTC (permalink / raw)
  To: Andy Gross, Bjorn Andersson, Konrad Dybcio, Rob Herring,
	Krzysztof Kozlowski
  Cc: linux-arm-msm, Johan Hovold, devicetree, Jonathan Cameron,
	Lars-Peter Clausen, linux-iio

Stop duplicating declarations of pm8350c and pmr735a PMICs, use existing
files to prevent possible future issues.

Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
---
 arch/arm64/boot/dts/qcom/sc8280xp-crd.dts     |  6 +--
 .../qcom/sc8280xp-lenovo-thinkpad-x13s.dts    |  6 +--
 arch/arm64/boot/dts/qcom/sc8280xp-pmics.dtsi  | 51 ++-----------------
 3 files changed, 11 insertions(+), 52 deletions(-)

diff --git a/arch/arm64/boot/dts/qcom/sc8280xp-crd.dts b/arch/arm64/boot/dts/qcom/sc8280xp-crd.dts
index 58a14c39633b..aabdacc15aab 100644
--- a/arch/arm64/boot/dts/qcom/sc8280xp-crd.dts
+++ b/arch/arm64/boot/dts/qcom/sc8280xp-crd.dts
@@ -24,7 +24,7 @@ aliases {
 
 	backlight: backlight {
 		compatible = "pwm-backlight";
-		pwms = <&pmc8280c_lpg 3 1000000>;
+		pwms = <&pm8350c_pwm 3 1000000>;
 		enable-gpios = <&pm8350_1_gpios 8 GPIO_ACTIVE_HIGH>;
 		power-supply = <&vreg_edp_bl>;
 
@@ -555,7 +555,7 @@ &pcie4_phy {
 	status = "okay";
 };
 
-&pmc8280c_lpg {
+&pm8350c_pwm {
 	status = "okay";
 };
 
@@ -710,7 +710,7 @@ wwan_sw_en: wwan-sw-en-state {
 	};
 };
 
-&pmc8280c_gpios {
+&pm8350c_gpios {
 	edp_bl_pwm: edp-bl-pwm-state {
 		pins = "gpio8";
 		function = "func1";
diff --git a/arch/arm64/boot/dts/qcom/sc8280xp-lenovo-thinkpad-x13s.dts b/arch/arm64/boot/dts/qcom/sc8280xp-lenovo-thinkpad-x13s.dts
index 023ccb7725ef..7e589e5f6a2e 100644
--- a/arch/arm64/boot/dts/qcom/sc8280xp-lenovo-thinkpad-x13s.dts
+++ b/arch/arm64/boot/dts/qcom/sc8280xp-lenovo-thinkpad-x13s.dts
@@ -54,7 +54,7 @@ wcd938x: audio-codec {
 
 	backlight: backlight {
 		compatible = "pwm-backlight";
-		pwms = <&pmc8280c_lpg 3 1000000>;
+		pwms = <&pm8350c_pwm 3 1000000>;
 		enable-gpios = <&pm8350_1_gpios 8 GPIO_ACTIVE_HIGH>;
 		power-supply = <&vreg_edp_bl>;
 
@@ -725,7 +725,7 @@ &pcie4_phy {
 	status = "okay";
 };
 
-&pmc8280c_lpg {
+&pm8350c_pwm {
 	status = "okay";
 };
 
@@ -1172,7 +1172,7 @@ wwan_sw_en: wwan-sw-en-state {
 	};
 };
 
-&pmc8280c_gpios {
+&pm8350c_gpios {
 	edp_bl_pwm: edp-bl-pwm-state {
 		pins = "gpio8";
 		function = "func1";
diff --git a/arch/arm64/boot/dts/qcom/sc8280xp-pmics.dtsi b/arch/arm64/boot/dts/qcom/sc8280xp-pmics.dtsi
index 505bb8f9a13c..a37fe4b1458c 100644
--- a/arch/arm64/boot/dts/qcom/sc8280xp-pmics.dtsi
+++ b/arch/arm64/boot/dts/qcom/sc8280xp-pmics.dtsi
@@ -15,53 +15,12 @@
 #include "pm8350.dtsi"
 #undef PM8350_SID
 
+/* SID 2 */
+#include "pm8350c.dtsi"
+
 #define PM8350_SID 3
 #include "pm8350.dtsi"
 #undef PM8350_SID
 
-&spmi_bus {
-	pmc8280c: pmic@2 {
-		compatible = "qcom,pm8350c", "qcom,spmi-pmic";
-		reg = <0x2 SPMI_USID>;
-		#address-cells = <1>;
-		#size-cells = <0>;
-
-		pmc8280c_gpios: gpio@8800 {
-			compatible = "qcom,pm8350c-gpio", "qcom,spmi-gpio";
-			reg = <0x8800>;
-			gpio-controller;
-			gpio-ranges = <&pmc8280c_gpios 0 0 9>;
-			#gpio-cells = <2>;
-			interrupt-controller;
-			#interrupt-cells = <2>;
-		};
-
-		pmc8280c_lpg: pwm {
-			compatible = "qcom,pm8350c-pwm";
-
-			#address-cells = <1>;
-			#size-cells = <0>;
-
-			#pwm-cells = <2>;
-
-			status = "disabled";
-		};
-	};
-
-	pmr735a: pmic@4 {
-		compatible = "qcom,pmr735a", "qcom,spmi-pmic";
-		reg = <0x4 SPMI_USID>;
-		#address-cells = <1>;
-		#size-cells = <0>;
-
-		pmr735a_gpios: gpio@8800 {
-			compatible = "qcom,pmr735a-gpio", "qcom,spmi-gpio";
-			reg = <0x8800>;
-			gpio-controller;
-			gpio-ranges = <&pmr735a_gpios 0 0 4>;
-			#gpio-cells = <2>;
-			interrupt-controller;
-			#interrupt-cells = <2>;
-		};
-	};
-};
+/* SID 4 */
+#include "pmr735a.dtsi"
-- 
2.30.2


^ permalink raw reply related	[flat|nested] 18+ messages in thread

* Re: [PATCH 1/6] dt-bindings: iio: qcom,spmi-adc7-pmk8350.h: include sid into defines
  2023-03-29  0:08 ` [PATCH 1/6] dt-bindings: iio: qcom,spmi-adc7-pmk8350.h: include sid into defines Dmitry Baryshkov
@ 2023-03-29  0:21   ` Konrad Dybcio
  2023-03-30  7:49   ` Krzysztof Kozlowski
  2023-04-01 14:48   ` Jonathan Cameron
  2 siblings, 0 replies; 18+ messages in thread
From: Konrad Dybcio @ 2023-03-29  0:21 UTC (permalink / raw)
  To: Dmitry Baryshkov, Andy Gross, Bjorn Andersson, Rob Herring,
	Krzysztof Kozlowski
  Cc: linux-arm-msm, Johan Hovold, devicetree, Jonathan Cameron,
	Lars-Peter Clausen, linux-iio



On 29.03.2023 02:08, Dmitry Baryshkov wrote:
> pmk8350 can take different addresses on SPMI bus. Rather than having a
> default SID, follow the pm8350's example and make the sid explicit when
> specifying ADC channels.
> 
> Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
> ---
Reviewed-by: Konrad Dybcio <konrad.dybcio@linaro.org>

Konrad
>  .../bindings/iio/adc/qcom,spmi-vadc.yaml      |  2 +-
>  .../bindings/thermal/qcom-spmi-adc-tm5.yaml   |  4 +-
>  arch/arm64/boot/dts/qcom/sc7280-idp.dtsi      |  2 +-
>  arch/arm64/boot/dts/qcom/sc7280-qcard.dtsi    |  2 +-
>  .../qcom/sc8280xp-lenovo-thinkpad-x13s.dts    |  4 +-
>  .../boot/dts/qcom/sm7225-fairphone-fp4.dts    |  2 +-
>  .../dt-bindings/iio/qcom,spmi-adc7-pmk8350.h  | 52 +++++++++----------
>  7 files changed, 32 insertions(+), 36 deletions(-)
> 
> diff --git a/Documentation/devicetree/bindings/iio/adc/qcom,spmi-vadc.yaml b/Documentation/devicetree/bindings/iio/adc/qcom,spmi-vadc.yaml
> index bd6e0d6f6e0c..df317901e7d0 100644
> --- a/Documentation/devicetree/bindings/iio/adc/qcom,spmi-vadc.yaml
> +++ b/Documentation/devicetree/bindings/iio/adc/qcom,spmi-vadc.yaml
> @@ -293,7 +293,7 @@ examples:
>  
>              /* Other properties are omitted */
>              xo-therm@44 {
> -                reg = <PMK8350_ADC7_AMUX_THM1_100K_PU>;
> +                reg = <PMK8350_ADC7_AMUX_THM1_100K_PU(0)>;
>                  qcom,ratiometric;
>                  qcom,hw-settle-time = <200>;
>              };
> diff --git a/Documentation/devicetree/bindings/thermal/qcom-spmi-adc-tm5.yaml b/Documentation/devicetree/bindings/thermal/qcom-spmi-adc-tm5.yaml
> index 52ec18cf1eda..ff07d27775dc 100644
> --- a/Documentation/devicetree/bindings/thermal/qcom-spmi-adc-tm5.yaml
> +++ b/Documentation/devicetree/bindings/thermal/qcom-spmi-adc-tm5.yaml
> @@ -218,7 +218,7 @@ examples:
>  
>              /* Other properties are omitted */
>              xo-therm@44 {
> -                reg = <PMK8350_ADC7_AMUX_THM1_100K_PU>;
> +                reg = <PMK8350_ADC7_AMUX_THM1_100K_PU(0)>;
>                  qcom,ratiometric;
>                  qcom,hw-settle-time = <200>;
>              };
> @@ -240,7 +240,7 @@ examples:
>  
>              pmk8350-xo-therm@0 {
>                  reg = <0>;
> -                io-channels = <&pmk8350_vadc PMK8350_ADC7_AMUX_THM1_100K_PU>;
> +                io-channels = <&pmk8350_vadc PMK8350_ADC7_AMUX_THM1_100K_PU(0)>;
>                  qcom,decimation = <340>;
>                  qcom,ratiometric;
>                  qcom,hw-settle-time-us = <200>;
> diff --git a/arch/arm64/boot/dts/qcom/sc7280-idp.dtsi b/arch/arm64/boot/dts/qcom/sc7280-idp.dtsi
> index 5dc9bee28e7f..14c9bdaa46ed 100644
> --- a/arch/arm64/boot/dts/qcom/sc7280-idp.dtsi
> +++ b/arch/arm64/boot/dts/qcom/sc7280-idp.dtsi
> @@ -433,7 +433,7 @@ &pcie1_phy {
>  
>  &pmk8350_vadc {
>  	pmk8350-die-temp@3 {
> -		reg = <PMK8350_ADC7_DIE_TEMP>;
> +		reg = <PMK8350_ADC7_DIE_TEMP(0)>;
>  		label = "pmk8350_die_temp";
>  		qcom,pre-scaling = <1 1>;
>  	};
> diff --git a/arch/arm64/boot/dts/qcom/sc7280-qcard.dtsi b/arch/arm64/boot/dts/qcom/sc7280-qcard.dtsi
> index cb0cc2ba2fa3..e3919e074ebd 100644
> --- a/arch/arm64/boot/dts/qcom/sc7280-qcard.dtsi
> +++ b/arch/arm64/boot/dts/qcom/sc7280-qcard.dtsi
> @@ -389,7 +389,7 @@ &pm8350c_pwm {
>  
>  &pmk8350_vadc {
>  	pmk8350-die-temp@3 {
> -		reg = <PMK8350_ADC7_DIE_TEMP>;
> +		reg = <PMK8350_ADC7_DIE_TEMP(0)>;
>  		label = "pmk8350_die_temp";
>  		qcom,pre-scaling = <1 1>;
>  	};
> diff --git a/arch/arm64/boot/dts/qcom/sc8280xp-lenovo-thinkpad-x13s.dts b/arch/arm64/boot/dts/qcom/sc8280xp-lenovo-thinkpad-x13s.dts
> index 46c7fdafb840..590400985055 100644
> --- a/arch/arm64/boot/dts/qcom/sc8280xp-lenovo-thinkpad-x13s.dts
> +++ b/arch/arm64/boot/dts/qcom/sc8280xp-lenovo-thinkpad-x13s.dts
> @@ -824,13 +824,13 @@ &pmk8280_vadc {
>  	status = "okay";
>  
>  	pmic-die-temp@3 {
> -		reg = <PMK8350_ADC7_DIE_TEMP>;
> +		reg = <PMK8350_ADC7_DIE_TEMP(0)>;
>  		qcom,pre-scaling = <1 1>;
>  		label = "pmk8350_die_temp";
>  	};
>  
>  	xo-therm@44 {
> -		reg = <PMK8350_ADC7_AMUX_THM1_100K_PU>;
> +		reg = <PMK8350_ADC7_AMUX_THM1_100K_PU(0)>;
>  		qcom,hw-settle-time = <200>;
>  		qcom,ratiometric;
>  		label = "pmk8350_xo_therm";
> diff --git a/arch/arm64/boot/dts/qcom/sm7225-fairphone-fp4.dts b/arch/arm64/boot/dts/qcom/sm7225-fairphone-fp4.dts
> index 7ae6aba5d2ec..af6cf4fbddc7 100644
> --- a/arch/arm64/boot/dts/qcom/sm7225-fairphone-fp4.dts
> +++ b/arch/arm64/boot/dts/qcom/sm7225-fairphone-fp4.dts
> @@ -516,7 +516,7 @@ &pmk8350_rtc {
>  
>  &pmk8350_vadc {
>  	adc-chan@644 {
> -		reg = <PMK8350_ADC7_AMUX_THM1_100K_PU>;
> +		reg = <PMK8350_ADC7_AMUX_THM1_100K_PU(0)>;
>  		qcom,ratiometric;
>  		qcom,hw-settle-time = <200>;
>  		qcom,pre-scaling = <1 1>;
> diff --git a/include/dt-bindings/iio/qcom,spmi-adc7-pmk8350.h b/include/dt-bindings/iio/qcom,spmi-adc7-pmk8350.h
> index 6c296870e95b..ca85a2d69453 100644
> --- a/include/dt-bindings/iio/qcom,spmi-adc7-pmk8350.h
> +++ b/include/dt-bindings/iio/qcom,spmi-adc7-pmk8350.h
> @@ -6,41 +6,37 @@
>  #ifndef _DT_BINDINGS_QCOM_SPMI_VADC_PMK8350_H
>  #define _DT_BINDINGS_QCOM_SPMI_VADC_PMK8350_H
>  
> -#ifndef PMK8350_SID
> -#define PMK8350_SID					0
> -#endif
> -
>  /* ADC channels for PMK8350_ADC for PMIC7 */
> -#define PMK8350_ADC7_REF_GND			(PMK8350_SID << 8 | 0x0)
> -#define PMK8350_ADC7_1P25VREF			(PMK8350_SID << 8 | 0x01)
> -#define PMK8350_ADC7_VREF_VADC			(PMK8350_SID << 8 | 0x02)
> -#define PMK8350_ADC7_DIE_TEMP			(PMK8350_SID << 8 | 0x03)
> +#define PMK8350_ADC7_REF_GND(sid)			((sid) << 8 | 0x0)
> +#define PMK8350_ADC7_1P25VREF(sid)			((sid) << 8 | 0x01)
> +#define PMK8350_ADC7_VREF_VADC(sid)			((sid) << 8 | 0x02)
> +#define PMK8350_ADC7_DIE_TEMP(sid)			((sid) << 8 | 0x03)
>  
> -#define PMK8350_ADC7_AMUX_THM1			(PMK8350_SID << 8 | 0x04)
> -#define PMK8350_ADC7_AMUX_THM2			(PMK8350_SID << 8 | 0x05)
> -#define PMK8350_ADC7_AMUX_THM3			(PMK8350_SID << 8 | 0x06)
> -#define PMK8350_ADC7_AMUX_THM4			(PMK8350_SID << 8 | 0x07)
> -#define PMK8350_ADC7_AMUX_THM5			(PMK8350_SID << 8 | 0x08)
> +#define PMK8350_ADC7_AMUX_THM1(sid)			((sid) << 8 | 0x04)
> +#define PMK8350_ADC7_AMUX_THM2(sid)			((sid) << 8 | 0x05)
> +#define PMK8350_ADC7_AMUX_THM3(sid)			((sid) << 8 | 0x06)
> +#define PMK8350_ADC7_AMUX_THM4(sid)			((sid) << 8 | 0x07)
> +#define PMK8350_ADC7_AMUX_THM5(sid)			((sid) << 8 | 0x08)
>  
>  /* 30k pull-up1 */
> -#define PMK8350_ADC7_AMUX_THM1_30K_PU		(PMK8350_SID << 8 | 0x24)
> -#define PMK8350_ADC7_AMUX_THM2_30K_PU		(PMK8350_SID << 8 | 0x25)
> -#define PMK8350_ADC7_AMUX_THM3_30K_PU		(PMK8350_SID << 8 | 0x26)
> -#define PMK8350_ADC7_AMUX_THM4_30K_PU		(PMK8350_SID << 8 | 0x27)
> -#define PMK8350_ADC7_AMUX_THM5_30K_PU		(PMK8350_SID << 8 | 0x28)
> +#define PMK8350_ADC7_AMUX_THM1_30K_PU(sid)		((sid) << 8 | 0x24)
> +#define PMK8350_ADC7_AMUX_THM2_30K_PU(sid)		((sid) << 8 | 0x25)
> +#define PMK8350_ADC7_AMUX_THM3_30K_PU(sid)		((sid) << 8 | 0x26)
> +#define PMK8350_ADC7_AMUX_THM4_30K_PU(sid)		((sid) << 8 | 0x27)
> +#define PMK8350_ADC7_AMUX_THM5_30K_PU(sid)		((sid) << 8 | 0x28)
>  
>  /* 100k pull-up2 */
> -#define PMK8350_ADC7_AMUX_THM1_100K_PU		(PMK8350_SID << 8 | 0x44)
> -#define PMK8350_ADC7_AMUX_THM2_100K_PU		(PMK8350_SID << 8 | 0x45)
> -#define PMK8350_ADC7_AMUX_THM3_100K_PU		(PMK8350_SID << 8 | 0x46)
> -#define PMK8350_ADC7_AMUX_THM4_100K_PU		(PMK8350_SID << 8 | 0x47)
> -#define PMK8350_ADC7_AMUX_THM5_100K_PU		(PMK8350_SID << 8 | 0x48)
> +#define PMK8350_ADC7_AMUX_THM1_100K_PU(sid)		((sid) << 8 | 0x44)
> +#define PMK8350_ADC7_AMUX_THM2_100K_PU(sid)		((sid) << 8 | 0x45)
> +#define PMK8350_ADC7_AMUX_THM3_100K_PU(sid)		((sid) << 8 | 0x46)
> +#define PMK8350_ADC7_AMUX_THM4_100K_PU(sid)		((sid) << 8 | 0x47)
> +#define PMK8350_ADC7_AMUX_THM5_100K_PU(sid)		((sid) << 8 | 0x48)
>  
>  /* 400k pull-up3 */
> -#define PMK8350_ADC7_AMUX_THM1_400K_PU		(PMK8350_SID << 8 | 0x64)
> -#define PMK8350_ADC7_AMUX_THM2_400K_PU		(PMK8350_SID << 8 | 0x65)
> -#define PMK8350_ADC7_AMUX_THM3_400K_PU		(PMK8350_SID << 8 | 0x66)
> -#define PMK8350_ADC7_AMUX_THM4_400K_PU		(PMK8350_SID << 8 | 0x67)
> -#define PMK8350_ADC7_AMUX_THM5_400K_PU		(PMK8350_SID << 8 | 0x68)
> +#define PMK8350_ADC7_AMUX_THM1_400K_PU(sid)		((sid) << 8 | 0x64)
> +#define PMK8350_ADC7_AMUX_THM2_400K_PU(sid)		((sid) << 8 | 0x65)
> +#define PMK8350_ADC7_AMUX_THM3_400K_PU(sid)		((sid) << 8 | 0x66)
> +#define PMK8350_ADC7_AMUX_THM4_400K_PU(sid)		((sid) << 8 | 0x67)
> +#define PMK8350_ADC7_AMUX_THM5_400K_PU(sid)		((sid) << 8 | 0x68)
>  
>  #endif /* _DT_BINDINGS_QCOM_SPMI_VADC_PMK8350_H */

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH 2/6] arm64: dts: qcom: pmk8350: rename pon label
  2023-03-29  0:08 ` [PATCH 2/6] arm64: dts: qcom: pmk8350: rename pon label Dmitry Baryshkov
@ 2023-03-29  0:22   ` Konrad Dybcio
  0 siblings, 0 replies; 18+ messages in thread
From: Konrad Dybcio @ 2023-03-29  0:22 UTC (permalink / raw)
  To: Dmitry Baryshkov, Andy Gross, Bjorn Andersson, Rob Herring,
	Krzysztof Kozlowski
  Cc: linux-arm-msm, Johan Hovold, devicetree, Jonathan Cameron,
	Lars-Peter Clausen, linux-iio



On 29.03.2023 02:08, Dmitry Baryshkov wrote:
> To reduce a possibility of the conflicts, rename pmk8350's pon_pwrkey
> and pon_resin to contain the PMIC name too.
> 
> Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
> ---
Reviewed-by: Konrad Dybcio <konrad.dybcio@linaro.org>

Konrad
>  arch/arm64/boot/dts/qcom/pmk8350.dtsi                   | 4 ++--
>  arch/arm64/boot/dts/qcom/sm8350-mtp.dts                 | 8 ++++----
>  arch/arm64/boot/dts/qcom/sm8350-sony-xperia-sagami.dtsi | 8 ++++----
>  arch/arm64/boot/dts/qcom/sm8450-sony-xperia-nagara.dtsi | 4 ++--
>  4 files changed, 12 insertions(+), 12 deletions(-)
> 
> diff --git a/arch/arm64/boot/dts/qcom/pmk8350.dtsi b/arch/arm64/boot/dts/qcom/pmk8350.dtsi
> index f26fb7d32faf..455ffffb5f5c 100644
> --- a/arch/arm64/boot/dts/qcom/pmk8350.dtsi
> +++ b/arch/arm64/boot/dts/qcom/pmk8350.dtsi
> @@ -25,14 +25,14 @@ pmk8350_pon: pon@1300 {
>  			reg = <0x1300>, <0x800>;
>  			reg-names = "hlos", "pbs";
>  
> -			pon_pwrkey: pwrkey {
> +			pmk8350_pon_pwrkey: pwrkey {
>  				compatible = "qcom,pmk8350-pwrkey";
>  				interrupts = <PMK8350_SID 0x13 0x7 IRQ_TYPE_EDGE_BOTH>;
>  				linux,code = <KEY_POWER>;
>  				status = "disabled";
>  			};
>  
> -			pon_resin: resin {
> +			pmk8350_pon_resin: resin {
>  				compatible = "qcom,pmk8350-resin";
>  				interrupts = <PMK8350_SID 0x13 0x6 IRQ_TYPE_EDGE_BOTH>;
>  				status = "disabled";
> diff --git a/arch/arm64/boot/dts/qcom/sm8350-mtp.dts b/arch/arm64/boot/dts/qcom/sm8350-mtp.dts
> index d21d2aacf201..152601832cbc 100644
> --- a/arch/arm64/boot/dts/qcom/sm8350-mtp.dts
> +++ b/arch/arm64/boot/dts/qcom/sm8350-mtp.dts
> @@ -285,17 +285,17 @@ &mpss {
>  	firmware-name = "qcom/sm8350/modem.mbn";
>  };
>  
> -&pmk8350_rtc {
> +&pmk8350_pon_pwrkey {
>  	status = "okay";
>  };
>  
> -&pon_pwrkey {
> +&pmk8350_pon_resin {
>  	status = "okay";
> +	linux,code = <KEY_VOLUMEDOWN>;
>  };
>  
> -&pon_resin {
> +&pmk8350_rtc {
>  	status = "okay";
> -	linux,code = <KEY_VOLUMEDOWN>;
>  };
>  
>  &qupv3_id_0 {
> diff --git a/arch/arm64/boot/dts/qcom/sm8350-sony-xperia-sagami.dtsi b/arch/arm64/boot/dts/qcom/sm8350-sony-xperia-sagami.dtsi
> index 89382ad73133..e28f49e31b9f 100644
> --- a/arch/arm64/boot/dts/qcom/sm8350-sony-xperia-sagami.dtsi
> +++ b/arch/arm64/boot/dts/qcom/sm8350-sony-xperia-sagami.dtsi
> @@ -618,17 +618,17 @@ vol_down_n: vol-down-n-state {
>  	};
>  };
>  
> -&pmk8350_rtc {
> +&pmk8350_pon_pwrkey {
>  	status = "okay";
>  };
>  
> -&pon_pwrkey {
> +&pmk8350_pon_resin {
>  	status = "okay";
> +	linux,code = <KEY_VOLUMEUP>;
>  };
>  
> -&pon_resin {
> +&pmk8350_rtc {
>  	status = "okay";
> -	linux,code = <KEY_VOLUMEUP>;
>  };
>  
>  &qupv3_id_0 {
> diff --git a/arch/arm64/boot/dts/qcom/sm8450-sony-xperia-nagara.dtsi b/arch/arm64/boot/dts/qcom/sm8450-sony-xperia-nagara.dtsi
> index 67538b5a557e..99e9b776b93d 100644
> --- a/arch/arm64/boot/dts/qcom/sm8450-sony-xperia-nagara.dtsi
> +++ b/arch/arm64/boot/dts/qcom/sm8450-sony-xperia-nagara.dtsi
> @@ -684,11 +684,11 @@ &pmk8350_gpios {
>  			  "PMK8350_OPTION";
>  };
>  
> -&pon_pwrkey {
> +&pmk8350_pon_pwrkey {
>  	status = "okay";
>  };
>  
> -&pon_resin {
> +&pmk8350_pon_resin {
>  	linux,code = <KEY_VOLUMEUP>;
>  	status = "okay";
>  };

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH 3/6] arm64: dts: qcom: use main pmk8350.dtsi for sc8280xp platform
  2023-03-29  0:08 ` [PATCH 3/6] arm64: dts: qcom: use main pmk8350.dtsi for sc8280xp platform Dmitry Baryshkov
@ 2023-03-29  0:27   ` Konrad Dybcio
  2023-03-29  0:29     ` Konrad Dybcio
  0 siblings, 1 reply; 18+ messages in thread
From: Konrad Dybcio @ 2023-03-29  0:27 UTC (permalink / raw)
  To: Dmitry Baryshkov, Andy Gross, Bjorn Andersson, Rob Herring,
	Krzysztof Kozlowski
  Cc: linux-arm-msm, Johan Hovold, devicetree, Jonathan Cameron,
	Lars-Peter Clausen, linux-iio



On 29.03.2023 02:08, Dmitry Baryshkov wrote:
> Employ existing PMK8350_SID and switch sc8280xp-pmics to use
> pmk8350.dtsi to reduce duplication and possible discrepancies.
> 
> For example, this changes sc8280xp platforms to use qcom,pmk8350-pon
> for the pon device compatibility rather than the incorrect
> qcom,pm8998-pon.
> 
> Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
> ---
Bit of a loaded patch..

This could probably go like:

1. outer join 8280 on pmk8350 (for feature parity)
2. rename all labels in 8280 to 8350 (for 3.)
3. switch over to the actual 8350 file, remove 8280 (with Fixes:)

[...]

> +#define PMK8350_SID 0
> +#include "pmk8350.dtsi"
> +#undef PMK8350_SID
Not sure if this undef is necessary

With or without all that though, the goal lgtm..

Konrad

>  
> +&spmi_bus {
>  	pmc8280_1: pmic@1 {
>  		compatible = "qcom,pm8350", "qcom,spmi-pmic";
>  		reg = <0x1 SPMI_USID>;

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH 3/6] arm64: dts: qcom: use main pmk8350.dtsi for sc8280xp platform
  2023-03-29  0:27   ` Konrad Dybcio
@ 2023-03-29  0:29     ` Konrad Dybcio
  2023-03-29  0:35       ` Konrad Dybcio
  0 siblings, 1 reply; 18+ messages in thread
From: Konrad Dybcio @ 2023-03-29  0:29 UTC (permalink / raw)
  To: Dmitry Baryshkov, Andy Gross, Bjorn Andersson, Rob Herring,
	Krzysztof Kozlowski
  Cc: linux-arm-msm, Johan Hovold, devicetree, Jonathan Cameron,
	Lars-Peter Clausen, linux-iio



On 29.03.2023 02:27, Konrad Dybcio wrote:
> 
> 
> On 29.03.2023 02:08, Dmitry Baryshkov wrote:
>> Employ existing PMK8350_SID and switch sc8280xp-pmics to use
>> pmk8350.dtsi to reduce duplication and possible discrepancies.
>>
>> For example, this changes sc8280xp platforms to use qcom,pmk8350-pon
>> for the pon device compatibility rather than the incorrect
>> qcom,pm8998-pon.
>>
>> Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
>> ---
> Bit of a loaded patch..
> 
> This could probably go like:
> 
> 1. outer join 8280 on pmk8350 (for feature parity)
> 2. rename all labels in 8280 to 8350 (for 3.)
> 3. switch over to the actual 8350 file, remove 8280 (with Fixes:)
> 
> [...]
> 
>> +#define PMK8350_SID 0
>> +#include "pmk8350.dtsi"
>> +#undef PMK8350_SID
> Not sure if this undef is necessary
It looks like it would be for multiple instances though

Konrad
> 
> With or without all that though, the goal lgtm..
> 
> Konrad
> 
>>  
>> +&spmi_bus {
>>  	pmc8280_1: pmic@1 {
>>  		compatible = "qcom,pm8350", "qcom,spmi-pmic";
>>  		reg = <0x1 SPMI_USID>;

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH 4/6] arm64: dts: qcom: pm8350: include SID into labels
  2023-03-29  0:08 ` [PATCH 4/6] arm64: dts: qcom: pm8350: include SID into labels Dmitry Baryshkov
@ 2023-03-29  0:33   ` Konrad Dybcio
  2023-03-29 10:51     ` Dmitry Baryshkov
  0 siblings, 1 reply; 18+ messages in thread
From: Konrad Dybcio @ 2023-03-29  0:33 UTC (permalink / raw)
  To: Dmitry Baryshkov, Andy Gross, Bjorn Andersson, Rob Herring,
	Krzysztof Kozlowski
  Cc: linux-arm-msm, Johan Hovold, devicetree, Jonathan Cameron,
	Lars-Peter Clausen, linux-iio



On 29.03.2023 02:08, Dmitry Baryshkov wrote:
> The platform can use several instances of PM8350 PMIC. Include SID into
> all the labels to simplify such platforms configuration.
> 
> Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
> ---
>  arch/arm64/boot/dts/qcom/pm8350.dtsi          | 31 +++++++++++++------
>  .../dts/qcom/sm8350-sony-xperia-sagami.dtsi   |  4 +--
>  .../dts/qcom/sm8450-sony-xperia-nagara.dtsi   |  4 +--
>  3 files changed, 26 insertions(+), 13 deletions(-)
> 
> diff --git a/arch/arm64/boot/dts/qcom/pm8350.dtsi b/arch/arm64/boot/dts/qcom/pm8350.dtsi
> index 2dfeb99300d7..f1ef242760f2 100644
> --- a/arch/arm64/boot/dts/qcom/pm8350.dtsi
> +++ b/arch/arm64/boot/dts/qcom/pm8350.dtsi
> @@ -6,21 +6,30 @@
>  #include <dt-bindings/interrupt-controller/irq.h>
>  #include <dt-bindings/spmi/spmi.h>
>  
> +/* (Sadly) this PMIC can be configured to be at different SIDs */
> +#ifndef PM8350_SID
> +	#define PM8350_SID 1
> +#endif
> +
> +#define __LABEL(pmic, sid, name) pmic ## _ ## sid ## _ ## name
> +#define _LABEL(pmic, sid, name) __LABEL(pmic, sid, name)
Perhaps that should go to some Qcom PMIC-common include now!

Also, at one point, an idea came up to stop writing so much dt, I'm
not necessarily a fan of creating .dtsc (like ACPI-C sources), but
perhaps we could explore having e.g. a "gen_dt.py" which would take
in some data and generate device trees based on that.. Not very
related to this patch, but I'm just throwing it in the open


Konrad
> +#define LABEL(name) _LABEL(pm8350, PM8350_SID, name)
> +
>  / {
>  	thermal-zones {
> -		pm8350_thermal: pm8350c-thermal {
> +		LABEL(thermal): pm8350c-thermal {
>  			polling-delay-passive = <100>;
>  			polling-delay = <0>;
> -			thermal-sensors = <&pm8350_temp_alarm>;
> +			thermal-sensors = <&LABEL(temp_alarm)>;
>  
>  			trips {
> -				pm8350_trip0: trip0 {
> +				LABEL(trip0): trip0 {
>  					temperature = <95000>;
>  					hysteresis = <0>;
>  					type = "passive";
>  				};
>  
> -				pm8350_crit: pm8350c-crit {
> +				LABEL(crit): pm8350c-crit {
>  					temperature = <115000>;
>  					hysteresis = <0>;
>  					type = "critical";
> @@ -33,25 +42,29 @@ pm8350_crit: pm8350c-crit {
>  &spmi_bus {
>  	pm8350: pmic@1 {
>  		compatible = "qcom,pm8350", "qcom,spmi-pmic";
> -		reg = <0x1 SPMI_USID>;
> +		reg = <PM8350_SID SPMI_USID>;
>  		#address-cells = <1>;
>  		#size-cells = <0>;
>  
> -		pm8350_temp_alarm: temp-alarm@a00 {
> +		LABEL(temp_alarm): temp-alarm@a00 {
>  			compatible = "qcom,spmi-temp-alarm";
>  			reg = <0xa00>;
> -			interrupts = <0x1 0xa 0x0 IRQ_TYPE_EDGE_BOTH>;
> +			interrupts = <PM8350_SID 0xa 0x0 IRQ_TYPE_EDGE_BOTH>;
>  			#thermal-sensor-cells = <0>;
>  		};
>  
> -		pm8350_gpios: gpio@8800 {
> +		LABEL(gpios): gpio@8800 {
>  			compatible = "qcom,pm8350-gpio", "qcom,spmi-gpio";
>  			reg = <0x8800>;
>  			gpio-controller;
> -			gpio-ranges = <&pm8350_gpios 0 0 10>;
> +			gpio-ranges = <&LABEL(gpios) 0 0 10>;
>  			#gpio-cells = <2>;
>  			interrupt-controller;
>  			#interrupt-cells = <2>;
>  		};
>  	};
>  };
> +
> +#undef LABEL
> +#undef _LABEL
> +#undef __LABEL
> diff --git a/arch/arm64/boot/dts/qcom/sm8350-sony-xperia-sagami.dtsi b/arch/arm64/boot/dts/qcom/sm8350-sony-xperia-sagami.dtsi
> index e28f49e31b9f..5c09b1d8881b 100644
> --- a/arch/arm64/boot/dts/qcom/sm8350-sony-xperia-sagami.dtsi
> +++ b/arch/arm64/boot/dts/qcom/sm8350-sony-xperia-sagami.dtsi
> @@ -72,7 +72,7 @@ key-camera-snapshot {
>  
>  		key-google-assist {
>  			label = "Google Assistant Key";
> -			gpios = <&pm8350_gpios 9 GPIO_ACTIVE_LOW>;
> +			gpios = <&pm8350_1_gpios 9 GPIO_ACTIVE_LOW>;
>  			linux,code = <KEY_LEFTMETA>;
>  			debounce-interval = <15>;
>  			linux,can-disable;
> @@ -564,7 +564,7 @@ &mpss {
>  	firmware-name = "qcom/sm8350/Sony/sagami/modem.mbn";
>  };
>  
> -&pm8350_gpios {
> +&pm8350_1_gpios {
>  	gpio-line-names = "ASSIGN1_THERM", /* GPIO_1 */
>  			  "LCD_ID",
>  			  "SDR_MMW_THERM",
> diff --git a/arch/arm64/boot/dts/qcom/sm8450-sony-xperia-nagara.dtsi b/arch/arm64/boot/dts/qcom/sm8450-sony-xperia-nagara.dtsi
> index 99e9b776b93d..d90e3fedb742 100644
> --- a/arch/arm64/boot/dts/qcom/sm8450-sony-xperia-nagara.dtsi
> +++ b/arch/arm64/boot/dts/qcom/sm8450-sony-xperia-nagara.dtsi
> @@ -56,7 +56,7 @@ key-camera-snapshot {
>  		key-volume-down {
>  			label = "Volume Down";
>  			linux,code = <KEY_VOLUMEDOWN>;
> -			gpios = <&pm8350_gpios 6 GPIO_ACTIVE_LOW>;
> +			gpios = <&pm8350_1_gpios 6 GPIO_ACTIVE_LOW>;
>  			debounce-interval = <15>;
>  			linux,can-disable;
>  			wakeup-source;
> @@ -622,7 +622,7 @@ &pcie0_phy {
>  	status = "okay";
>  };
>  
> -&pm8350_gpios {
> +&pm8350_1_gpios {
>  	gpio-line-names = "ASSIGN1_THERM", /* GPIO_1 */
>  			  "LCD_ID",
>  			  "SDR_MMW_THERM",

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH 3/6] arm64: dts: qcom: use main pmk8350.dtsi for sc8280xp platform
  2023-03-29  0:29     ` Konrad Dybcio
@ 2023-03-29  0:35       ` Konrad Dybcio
  2023-03-29 11:54         ` Dmitry Baryshkov
  0 siblings, 1 reply; 18+ messages in thread
From: Konrad Dybcio @ 2023-03-29  0:35 UTC (permalink / raw)
  To: Dmitry Baryshkov, Andy Gross, Bjorn Andersson, Rob Herring,
	Krzysztof Kozlowski
  Cc: linux-arm-msm, Johan Hovold, devicetree, Jonathan Cameron,
	Lars-Peter Clausen, linux-iio



On 29.03.2023 02:29, Konrad Dybcio wrote:
> 
> 
> On 29.03.2023 02:27, Konrad Dybcio wrote:
>>
>>
>> On 29.03.2023 02:08, Dmitry Baryshkov wrote:
>>> Employ existing PMK8350_SID and switch sc8280xp-pmics to use
>>> pmk8350.dtsi to reduce duplication and possible discrepancies.
>>>
>>> For example, this changes sc8280xp platforms to use qcom,pmk8350-pon
>>> for the pon device compatibility rather than the incorrect
>>> qcom,pm8998-pon.
>>>
>>> Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
>>> ---
>> Bit of a loaded patch..
>>
>> This could probably go like:
>>
>> 1. outer join 8280 on pmk8350 (for feature parity)
>> 2. rename all labels in 8280 to 8350 (for 3.)
>> 3. switch over to the actual 8350 file, remove 8280 (with Fixes:)
>>
>> [...]
>>
>>> +#define PMK8350_SID 0
>>> +#include "pmk8350.dtsi"
>>> +#undef PMK8350_SID
>> Not sure if this undef is necessary
> It looks like it would be for multiple instances though
> 
> Konrad
Also, it'd be a good idea to use interrupt-parent, as:

1) it would be a regression for OpenBSD and friends to remove it
2) the interrupts=<> is dangerously long with SPMI

Konrad
>>
>> With or without all that though, the goal lgtm..
>>
>> Konrad
>>
>>>  
>>> +&spmi_bus {
>>>  	pmc8280_1: pmic@1 {
>>>  		compatible = "qcom,pm8350", "qcom,spmi-pmic";
>>>  		reg = <0x1 SPMI_USID>;

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH 4/6] arm64: dts: qcom: pm8350: include SID into labels
  2023-03-29  0:33   ` Konrad Dybcio
@ 2023-03-29 10:51     ` Dmitry Baryshkov
  0 siblings, 0 replies; 18+ messages in thread
From: Dmitry Baryshkov @ 2023-03-29 10:51 UTC (permalink / raw)
  To: Konrad Dybcio
  Cc: Andy Gross, Bjorn Andersson, Rob Herring, Krzysztof Kozlowski,
	linux-arm-msm, Johan Hovold, devicetree, Jonathan Cameron,
	Lars-Peter Clausen, linux-iio

On Wed, 29 Mar 2023 at 03:33, Konrad Dybcio <konrad.dybcio@linaro.org> wrote:
>
>
>
> On 29.03.2023 02:08, Dmitry Baryshkov wrote:
> > The platform can use several instances of PM8350 PMIC. Include SID into
> > all the labels to simplify such platforms configuration.
> >
> > Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
> > ---
> >  arch/arm64/boot/dts/qcom/pm8350.dtsi          | 31 +++++++++++++------
> >  .../dts/qcom/sm8350-sony-xperia-sagami.dtsi   |  4 +--
> >  .../dts/qcom/sm8450-sony-xperia-nagara.dtsi   |  4 +--
> >  3 files changed, 26 insertions(+), 13 deletions(-)
> >
> > diff --git a/arch/arm64/boot/dts/qcom/pm8350.dtsi b/arch/arm64/boot/dts/qcom/pm8350.dtsi
> > index 2dfeb99300d7..f1ef242760f2 100644
> > --- a/arch/arm64/boot/dts/qcom/pm8350.dtsi
> > +++ b/arch/arm64/boot/dts/qcom/pm8350.dtsi
> > @@ -6,21 +6,30 @@
> >  #include <dt-bindings/interrupt-controller/irq.h>
> >  #include <dt-bindings/spmi/spmi.h>
> >
> > +/* (Sadly) this PMIC can be configured to be at different SIDs */
> > +#ifndef PM8350_SID
> > +     #define PM8350_SID 1
> > +#endif
> > +
> > +#define __LABEL(pmic, sid, name) pmic ## _ ## sid ## _ ## name
> > +#define _LABEL(pmic, sid, name) __LABEL(pmic, sid, name)
> Perhaps that should go to some Qcom PMIC-common include now!

I usually prefer to have a "second case" before generalizing things. I
think we might have it with sa8540p-pmics (which includes 4 instances
of pmm8540). However I didn't dare to touch that as I do not know if
they are really the same PMICs or there are some differences, etc.

> Also, at one point, an idea came up to stop writing so much dt, I'm
> not necessarily a fan of creating .dtsc (like ACPI-C sources), but
> perhaps we could explore having e.g. a "gen_dt.py" which would take
> in some data and generate device trees based on that.. Not very
> related to this patch, but I'm just throwing it in the open

Standard issue: one has to find a balance between the generated source
and the actual code. Given that most of the blocks are more or less
standard, we might be able to create a DSL for describing PMICs. But
then we have all kinds of strange nodes (like Type-C handler), which
do not follow the reset.

>
>
> Konrad
> > +#define LABEL(name) _LABEL(pm8350, PM8350_SID, name)
> > +
> >  / {
> >       thermal-zones {
> > -             pm8350_thermal: pm8350c-thermal {
> > +             LABEL(thermal): pm8350c-thermal {
> >                       polling-delay-passive = <100>;
> >                       polling-delay = <0>;
> > -                     thermal-sensors = <&pm8350_temp_alarm>;
> > +                     thermal-sensors = <&LABEL(temp_alarm)>;
> >
> >                       trips {
> > -                             pm8350_trip0: trip0 {
> > +                             LABEL(trip0): trip0 {
> >                                       temperature = <95000>;
> >                                       hysteresis = <0>;
> >                                       type = "passive";
> >                               };
> >
> > -                             pm8350_crit: pm8350c-crit {
> > +                             LABEL(crit): pm8350c-crit {
> >                                       temperature = <115000>;
> >                                       hysteresis = <0>;
> >                                       type = "critical";
> > @@ -33,25 +42,29 @@ pm8350_crit: pm8350c-crit {
> >  &spmi_bus {
> >       pm8350: pmic@1 {
> >               compatible = "qcom,pm8350", "qcom,spmi-pmic";
> > -             reg = <0x1 SPMI_USID>;
> > +             reg = <PM8350_SID SPMI_USID>;
> >               #address-cells = <1>;
> >               #size-cells = <0>;
> >
> > -             pm8350_temp_alarm: temp-alarm@a00 {
> > +             LABEL(temp_alarm): temp-alarm@a00 {
> >                       compatible = "qcom,spmi-temp-alarm";
> >                       reg = <0xa00>;
> > -                     interrupts = <0x1 0xa 0x0 IRQ_TYPE_EDGE_BOTH>;
> > +                     interrupts = <PM8350_SID 0xa 0x0 IRQ_TYPE_EDGE_BOTH>;
> >                       #thermal-sensor-cells = <0>;
> >               };
> >
> > -             pm8350_gpios: gpio@8800 {
> > +             LABEL(gpios): gpio@8800 {
> >                       compatible = "qcom,pm8350-gpio", "qcom,spmi-gpio";
> >                       reg = <0x8800>;
> >                       gpio-controller;
> > -                     gpio-ranges = <&pm8350_gpios 0 0 10>;
> > +                     gpio-ranges = <&LABEL(gpios) 0 0 10>;
> >                       #gpio-cells = <2>;
> >                       interrupt-controller;
> >                       #interrupt-cells = <2>;
> >               };
> >       };
> >  };
> > +
> > +#undef LABEL
> > +#undef _LABEL
> > +#undef __LABEL
> > diff --git a/arch/arm64/boot/dts/qcom/sm8350-sony-xperia-sagami.dtsi b/arch/arm64/boot/dts/qcom/sm8350-sony-xperia-sagami.dtsi
> > index e28f49e31b9f..5c09b1d8881b 100644
> > --- a/arch/arm64/boot/dts/qcom/sm8350-sony-xperia-sagami.dtsi
> > +++ b/arch/arm64/boot/dts/qcom/sm8350-sony-xperia-sagami.dtsi
> > @@ -72,7 +72,7 @@ key-camera-snapshot {
> >
> >               key-google-assist {
> >                       label = "Google Assistant Key";
> > -                     gpios = <&pm8350_gpios 9 GPIO_ACTIVE_LOW>;
> > +                     gpios = <&pm8350_1_gpios 9 GPIO_ACTIVE_LOW>;
> >                       linux,code = <KEY_LEFTMETA>;
> >                       debounce-interval = <15>;
> >                       linux,can-disable;
> > @@ -564,7 +564,7 @@ &mpss {
> >       firmware-name = "qcom/sm8350/Sony/sagami/modem.mbn";
> >  };
> >
> > -&pm8350_gpios {
> > +&pm8350_1_gpios {
> >       gpio-line-names = "ASSIGN1_THERM", /* GPIO_1 */
> >                         "LCD_ID",
> >                         "SDR_MMW_THERM",
> > diff --git a/arch/arm64/boot/dts/qcom/sm8450-sony-xperia-nagara.dtsi b/arch/arm64/boot/dts/qcom/sm8450-sony-xperia-nagara.dtsi
> > index 99e9b776b93d..d90e3fedb742 100644
> > --- a/arch/arm64/boot/dts/qcom/sm8450-sony-xperia-nagara.dtsi
> > +++ b/arch/arm64/boot/dts/qcom/sm8450-sony-xperia-nagara.dtsi
> > @@ -56,7 +56,7 @@ key-camera-snapshot {
> >               key-volume-down {
> >                       label = "Volume Down";
> >                       linux,code = <KEY_VOLUMEDOWN>;
> > -                     gpios = <&pm8350_gpios 6 GPIO_ACTIVE_LOW>;
> > +                     gpios = <&pm8350_1_gpios 6 GPIO_ACTIVE_LOW>;
> >                       debounce-interval = <15>;
> >                       linux,can-disable;
> >                       wakeup-source;
> > @@ -622,7 +622,7 @@ &pcie0_phy {
> >       status = "okay";
> >  };
> >
> > -&pm8350_gpios {
> > +&pm8350_1_gpios {
> >       gpio-line-names = "ASSIGN1_THERM", /* GPIO_1 */
> >                         "LCD_ID",
> >                         "SDR_MMW_THERM",



-- 
With best wishes
Dmitry

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH 3/6] arm64: dts: qcom: use main pmk8350.dtsi for sc8280xp platform
  2023-03-29  0:35       ` Konrad Dybcio
@ 2023-03-29 11:54         ` Dmitry Baryshkov
  0 siblings, 0 replies; 18+ messages in thread
From: Dmitry Baryshkov @ 2023-03-29 11:54 UTC (permalink / raw)
  To: Konrad Dybcio
  Cc: Andy Gross, Bjorn Andersson, Rob Herring, Krzysztof Kozlowski,
	linux-arm-msm, Johan Hovold, devicetree, Jonathan Cameron,
	Lars-Peter Clausen, linux-iio

On Wed, 29 Mar 2023 at 03:35, Konrad Dybcio <konrad.dybcio@linaro.org> wrote:
>
>
>
> On 29.03.2023 02:29, Konrad Dybcio wrote:
> >
> >
> > On 29.03.2023 02:27, Konrad Dybcio wrote:
> >>
> >>
> >> On 29.03.2023 02:08, Dmitry Baryshkov wrote:
> >>> Employ existing PMK8350_SID and switch sc8280xp-pmics to use
> >>> pmk8350.dtsi to reduce duplication and possible discrepancies.
> >>>
> >>> For example, this changes sc8280xp platforms to use qcom,pmk8350-pon
> >>> for the pon device compatibility rather than the incorrect
> >>> qcom,pm8998-pon.
> >>>
> >>> Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
> >>> ---
> >> Bit of a loaded patch..
> >>
> >> This could probably go like:
> >>
> >> 1. outer join 8280 on pmk8350 (for feature parity)
> >> 2. rename all labels in 8280 to 8350 (for 3.)
> >> 3. switch over to the actual 8350 file, remove 8280 (with Fixes:)
> >>
> >> [...]
> >>
> >>> +#define PMK8350_SID 0
> >>> +#include "pmk8350.dtsi"
> >>> +#undef PMK8350_SID
> >> Not sure if this undef is necessary
> > It looks like it would be for multiple instances though
> >
> > Konrad
> Also, it'd be a good idea to use interrupt-parent, as:
>
> 1) it would be a regression for OpenBSD and friends to remove it

Ack, I forgot about interrupts/interrupts-extended. I'll fix that for v2.

> 2) the interrupts=<> is dangerously long with SPMI

I don't think we can do anything about this.

>
> Konrad
> >>
> >> With or without all that though, the goal lgtm..
> >>
> >> Konrad
> >>
> >>>
> >>> +&spmi_bus {
> >>>     pmc8280_1: pmic@1 {
> >>>             compatible = "qcom,pm8350", "qcom,spmi-pmic";
> >>>             reg = <0x1 SPMI_USID>;



-- 
With best wishes
Dmitry

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH 1/6] dt-bindings: iio: qcom,spmi-adc7-pmk8350.h: include sid into defines
  2023-03-29  0:08 ` [PATCH 1/6] dt-bindings: iio: qcom,spmi-adc7-pmk8350.h: include sid into defines Dmitry Baryshkov
  2023-03-29  0:21   ` Konrad Dybcio
@ 2023-03-30  7:49   ` Krzysztof Kozlowski
  2023-04-01 14:48   ` Jonathan Cameron
  2 siblings, 0 replies; 18+ messages in thread
From: Krzysztof Kozlowski @ 2023-03-30  7:49 UTC (permalink / raw)
  To: Dmitry Baryshkov, Andy Gross, Bjorn Andersson, Konrad Dybcio,
	Rob Herring, Krzysztof Kozlowski
  Cc: linux-arm-msm, Johan Hovold, devicetree, Jonathan Cameron,
	Lars-Peter Clausen, linux-iio

On 29/03/2023 02:08, Dmitry Baryshkov wrote:
> pmk8350 can take different addresses on SPMI bus. Rather than having a
> default SID, follow the pm8350's example and make the sid explicit when
> specifying ADC channels.
> 
> Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>


Reviewed-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>

Best regards,
Krzysztof


^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH 1/6] dt-bindings: iio: qcom,spmi-adc7-pmk8350.h: include sid into defines
  2023-03-29  0:08 ` [PATCH 1/6] dt-bindings: iio: qcom,spmi-adc7-pmk8350.h: include sid into defines Dmitry Baryshkov
  2023-03-29  0:21   ` Konrad Dybcio
  2023-03-30  7:49   ` Krzysztof Kozlowski
@ 2023-04-01 14:48   ` Jonathan Cameron
  2023-04-01 14:59     ` Dmitry Baryshkov
  2 siblings, 1 reply; 18+ messages in thread
From: Jonathan Cameron @ 2023-04-01 14:48 UTC (permalink / raw)
  To: Dmitry Baryshkov
  Cc: Andy Gross, Bjorn Andersson, Konrad Dybcio, Rob Herring,
	Krzysztof Kozlowski, linux-arm-msm, Johan Hovold, devicetree,
	Lars-Peter Clausen, linux-iio

On Wed, 29 Mar 2023 03:08:28 +0300
Dmitry Baryshkov <dmitry.baryshkov@linaro.org> wrote:

> pmk8350 can take different addresses on SPMI bus. Rather than having a
> default SID, follow the pm8350's example and make the sid explicit when
> specifying ADC channels.
> 
> Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>

Hi Dmitry,

How do you want this applied? I can take it through IIO if you like but
I'm not sure if that will cause trouble for other dts patches in flight.

I'm fine with it going via another tree though and don't expect
to see any clashes. If so.

Acked-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>

> ---
>  .../bindings/iio/adc/qcom,spmi-vadc.yaml      |  2 +-
>  .../bindings/thermal/qcom-spmi-adc-tm5.yaml   |  4 +-
>  arch/arm64/boot/dts/qcom/sc7280-idp.dtsi      |  2 +-
>  arch/arm64/boot/dts/qcom/sc7280-qcard.dtsi    |  2 +-
>  .../qcom/sc8280xp-lenovo-thinkpad-x13s.dts    |  4 +-
>  .../boot/dts/qcom/sm7225-fairphone-fp4.dts    |  2 +-
>  .../dt-bindings/iio/qcom,spmi-adc7-pmk8350.h  | 52 +++++++++----------
>  7 files changed, 32 insertions(+), 36 deletions(-)
> 
> diff --git a/Documentation/devicetree/bindings/iio/adc/qcom,spmi-vadc.yaml b/Documentation/devicetree/bindings/iio/adc/qcom,spmi-vadc.yaml
> index bd6e0d6f6e0c..df317901e7d0 100644
> --- a/Documentation/devicetree/bindings/iio/adc/qcom,spmi-vadc.yaml
> +++ b/Documentation/devicetree/bindings/iio/adc/qcom,spmi-vadc.yaml
> @@ -293,7 +293,7 @@ examples:
>  
>              /* Other properties are omitted */
>              xo-therm@44 {
> -                reg = <PMK8350_ADC7_AMUX_THM1_100K_PU>;
> +                reg = <PMK8350_ADC7_AMUX_THM1_100K_PU(0)>;
>                  qcom,ratiometric;
>                  qcom,hw-settle-time = <200>;
>              };
> diff --git a/Documentation/devicetree/bindings/thermal/qcom-spmi-adc-tm5.yaml b/Documentation/devicetree/bindings/thermal/qcom-spmi-adc-tm5.yaml
> index 52ec18cf1eda..ff07d27775dc 100644
> --- a/Documentation/devicetree/bindings/thermal/qcom-spmi-adc-tm5.yaml
> +++ b/Documentation/devicetree/bindings/thermal/qcom-spmi-adc-tm5.yaml
> @@ -218,7 +218,7 @@ examples:
>  
>              /* Other properties are omitted */
>              xo-therm@44 {
> -                reg = <PMK8350_ADC7_AMUX_THM1_100K_PU>;
> +                reg = <PMK8350_ADC7_AMUX_THM1_100K_PU(0)>;
>                  qcom,ratiometric;
>                  qcom,hw-settle-time = <200>;
>              };
> @@ -240,7 +240,7 @@ examples:
>  
>              pmk8350-xo-therm@0 {
>                  reg = <0>;
> -                io-channels = <&pmk8350_vadc PMK8350_ADC7_AMUX_THM1_100K_PU>;
> +                io-channels = <&pmk8350_vadc PMK8350_ADC7_AMUX_THM1_100K_PU(0)>;
>                  qcom,decimation = <340>;
>                  qcom,ratiometric;
>                  qcom,hw-settle-time-us = <200>;
> diff --git a/arch/arm64/boot/dts/qcom/sc7280-idp.dtsi b/arch/arm64/boot/dts/qcom/sc7280-idp.dtsi
> index 5dc9bee28e7f..14c9bdaa46ed 100644
> --- a/arch/arm64/boot/dts/qcom/sc7280-idp.dtsi
> +++ b/arch/arm64/boot/dts/qcom/sc7280-idp.dtsi
> @@ -433,7 +433,7 @@ &pcie1_phy {
>  
>  &pmk8350_vadc {
>  	pmk8350-die-temp@3 {
> -		reg = <PMK8350_ADC7_DIE_TEMP>;
> +		reg = <PMK8350_ADC7_DIE_TEMP(0)>;
>  		label = "pmk8350_die_temp";
>  		qcom,pre-scaling = <1 1>;
>  	};
> diff --git a/arch/arm64/boot/dts/qcom/sc7280-qcard.dtsi b/arch/arm64/boot/dts/qcom/sc7280-qcard.dtsi
> index cb0cc2ba2fa3..e3919e074ebd 100644
> --- a/arch/arm64/boot/dts/qcom/sc7280-qcard.dtsi
> +++ b/arch/arm64/boot/dts/qcom/sc7280-qcard.dtsi
> @@ -389,7 +389,7 @@ &pm8350c_pwm {
>  
>  &pmk8350_vadc {
>  	pmk8350-die-temp@3 {
> -		reg = <PMK8350_ADC7_DIE_TEMP>;
> +		reg = <PMK8350_ADC7_DIE_TEMP(0)>;
>  		label = "pmk8350_die_temp";
>  		qcom,pre-scaling = <1 1>;
>  	};
> diff --git a/arch/arm64/boot/dts/qcom/sc8280xp-lenovo-thinkpad-x13s.dts b/arch/arm64/boot/dts/qcom/sc8280xp-lenovo-thinkpad-x13s.dts
> index 46c7fdafb840..590400985055 100644
> --- a/arch/arm64/boot/dts/qcom/sc8280xp-lenovo-thinkpad-x13s.dts
> +++ b/arch/arm64/boot/dts/qcom/sc8280xp-lenovo-thinkpad-x13s.dts
> @@ -824,13 +824,13 @@ &pmk8280_vadc {
>  	status = "okay";
>  
>  	pmic-die-temp@3 {
> -		reg = <PMK8350_ADC7_DIE_TEMP>;
> +		reg = <PMK8350_ADC7_DIE_TEMP(0)>;
>  		qcom,pre-scaling = <1 1>;
>  		label = "pmk8350_die_temp";
>  	};
>  
>  	xo-therm@44 {
> -		reg = <PMK8350_ADC7_AMUX_THM1_100K_PU>;
> +		reg = <PMK8350_ADC7_AMUX_THM1_100K_PU(0)>;
>  		qcom,hw-settle-time = <200>;
>  		qcom,ratiometric;
>  		label = "pmk8350_xo_therm";
> diff --git a/arch/arm64/boot/dts/qcom/sm7225-fairphone-fp4.dts b/arch/arm64/boot/dts/qcom/sm7225-fairphone-fp4.dts
> index 7ae6aba5d2ec..af6cf4fbddc7 100644
> --- a/arch/arm64/boot/dts/qcom/sm7225-fairphone-fp4.dts
> +++ b/arch/arm64/boot/dts/qcom/sm7225-fairphone-fp4.dts
> @@ -516,7 +516,7 @@ &pmk8350_rtc {
>  
>  &pmk8350_vadc {
>  	adc-chan@644 {
> -		reg = <PMK8350_ADC7_AMUX_THM1_100K_PU>;
> +		reg = <PMK8350_ADC7_AMUX_THM1_100K_PU(0)>;
>  		qcom,ratiometric;
>  		qcom,hw-settle-time = <200>;
>  		qcom,pre-scaling = <1 1>;
> diff --git a/include/dt-bindings/iio/qcom,spmi-adc7-pmk8350.h b/include/dt-bindings/iio/qcom,spmi-adc7-pmk8350.h
> index 6c296870e95b..ca85a2d69453 100644
> --- a/include/dt-bindings/iio/qcom,spmi-adc7-pmk8350.h
> +++ b/include/dt-bindings/iio/qcom,spmi-adc7-pmk8350.h
> @@ -6,41 +6,37 @@
>  #ifndef _DT_BINDINGS_QCOM_SPMI_VADC_PMK8350_H
>  #define _DT_BINDINGS_QCOM_SPMI_VADC_PMK8350_H
>  
> -#ifndef PMK8350_SID
> -#define PMK8350_SID					0
> -#endif
> -
>  /* ADC channels for PMK8350_ADC for PMIC7 */
> -#define PMK8350_ADC7_REF_GND			(PMK8350_SID << 8 | 0x0)
> -#define PMK8350_ADC7_1P25VREF			(PMK8350_SID << 8 | 0x01)
> -#define PMK8350_ADC7_VREF_VADC			(PMK8350_SID << 8 | 0x02)
> -#define PMK8350_ADC7_DIE_TEMP			(PMK8350_SID << 8 | 0x03)
> +#define PMK8350_ADC7_REF_GND(sid)			((sid) << 8 | 0x0)
> +#define PMK8350_ADC7_1P25VREF(sid)			((sid) << 8 | 0x01)
> +#define PMK8350_ADC7_VREF_VADC(sid)			((sid) << 8 | 0x02)
> +#define PMK8350_ADC7_DIE_TEMP(sid)			((sid) << 8 | 0x03)
>  
> -#define PMK8350_ADC7_AMUX_THM1			(PMK8350_SID << 8 | 0x04)
> -#define PMK8350_ADC7_AMUX_THM2			(PMK8350_SID << 8 | 0x05)
> -#define PMK8350_ADC7_AMUX_THM3			(PMK8350_SID << 8 | 0x06)
> -#define PMK8350_ADC7_AMUX_THM4			(PMK8350_SID << 8 | 0x07)
> -#define PMK8350_ADC7_AMUX_THM5			(PMK8350_SID << 8 | 0x08)
> +#define PMK8350_ADC7_AMUX_THM1(sid)			((sid) << 8 | 0x04)
> +#define PMK8350_ADC7_AMUX_THM2(sid)			((sid) << 8 | 0x05)
> +#define PMK8350_ADC7_AMUX_THM3(sid)			((sid) << 8 | 0x06)
> +#define PMK8350_ADC7_AMUX_THM4(sid)			((sid) << 8 | 0x07)
> +#define PMK8350_ADC7_AMUX_THM5(sid)			((sid) << 8 | 0x08)
>  
>  /* 30k pull-up1 */
> -#define PMK8350_ADC7_AMUX_THM1_30K_PU		(PMK8350_SID << 8 | 0x24)
> -#define PMK8350_ADC7_AMUX_THM2_30K_PU		(PMK8350_SID << 8 | 0x25)
> -#define PMK8350_ADC7_AMUX_THM3_30K_PU		(PMK8350_SID << 8 | 0x26)
> -#define PMK8350_ADC7_AMUX_THM4_30K_PU		(PMK8350_SID << 8 | 0x27)
> -#define PMK8350_ADC7_AMUX_THM5_30K_PU		(PMK8350_SID << 8 | 0x28)
> +#define PMK8350_ADC7_AMUX_THM1_30K_PU(sid)		((sid) << 8 | 0x24)
> +#define PMK8350_ADC7_AMUX_THM2_30K_PU(sid)		((sid) << 8 | 0x25)
> +#define PMK8350_ADC7_AMUX_THM3_30K_PU(sid)		((sid) << 8 | 0x26)
> +#define PMK8350_ADC7_AMUX_THM4_30K_PU(sid)		((sid) << 8 | 0x27)
> +#define PMK8350_ADC7_AMUX_THM5_30K_PU(sid)		((sid) << 8 | 0x28)
>  
>  /* 100k pull-up2 */
> -#define PMK8350_ADC7_AMUX_THM1_100K_PU		(PMK8350_SID << 8 | 0x44)
> -#define PMK8350_ADC7_AMUX_THM2_100K_PU		(PMK8350_SID << 8 | 0x45)
> -#define PMK8350_ADC7_AMUX_THM3_100K_PU		(PMK8350_SID << 8 | 0x46)
> -#define PMK8350_ADC7_AMUX_THM4_100K_PU		(PMK8350_SID << 8 | 0x47)
> -#define PMK8350_ADC7_AMUX_THM5_100K_PU		(PMK8350_SID << 8 | 0x48)
> +#define PMK8350_ADC7_AMUX_THM1_100K_PU(sid)		((sid) << 8 | 0x44)
> +#define PMK8350_ADC7_AMUX_THM2_100K_PU(sid)		((sid) << 8 | 0x45)
> +#define PMK8350_ADC7_AMUX_THM3_100K_PU(sid)		((sid) << 8 | 0x46)
> +#define PMK8350_ADC7_AMUX_THM4_100K_PU(sid)		((sid) << 8 | 0x47)
> +#define PMK8350_ADC7_AMUX_THM5_100K_PU(sid)		((sid) << 8 | 0x48)
>  
>  /* 400k pull-up3 */
> -#define PMK8350_ADC7_AMUX_THM1_400K_PU		(PMK8350_SID << 8 | 0x64)
> -#define PMK8350_ADC7_AMUX_THM2_400K_PU		(PMK8350_SID << 8 | 0x65)
> -#define PMK8350_ADC7_AMUX_THM3_400K_PU		(PMK8350_SID << 8 | 0x66)
> -#define PMK8350_ADC7_AMUX_THM4_400K_PU		(PMK8350_SID << 8 | 0x67)
> -#define PMK8350_ADC7_AMUX_THM5_400K_PU		(PMK8350_SID << 8 | 0x68)
> +#define PMK8350_ADC7_AMUX_THM1_400K_PU(sid)		((sid) << 8 | 0x64)
> +#define PMK8350_ADC7_AMUX_THM2_400K_PU(sid)		((sid) << 8 | 0x65)
> +#define PMK8350_ADC7_AMUX_THM3_400K_PU(sid)		((sid) << 8 | 0x66)
> +#define PMK8350_ADC7_AMUX_THM4_400K_PU(sid)		((sid) << 8 | 0x67)
> +#define PMK8350_ADC7_AMUX_THM5_400K_PU(sid)		((sid) << 8 | 0x68)
>  
>  #endif /* _DT_BINDINGS_QCOM_SPMI_VADC_PMK8350_H */


^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH 1/6] dt-bindings: iio: qcom,spmi-adc7-pmk8350.h: include sid into defines
  2023-04-01 14:48   ` Jonathan Cameron
@ 2023-04-01 14:59     ` Dmitry Baryshkov
  0 siblings, 0 replies; 18+ messages in thread
From: Dmitry Baryshkov @ 2023-04-01 14:59 UTC (permalink / raw)
  To: Jonathan Cameron
  Cc: Andy Gross, Bjorn Andersson, Konrad Dybcio, Rob Herring,
	Krzysztof Kozlowski, linux-arm-msm, Johan Hovold, devicetree,
	Lars-Peter Clausen, linux-iio

On 01/04/2023 17:48, Jonathan Cameron wrote:
> On Wed, 29 Mar 2023 03:08:28 +0300
> Dmitry Baryshkov <dmitry.baryshkov@linaro.org> wrote:
> 
>> pmk8350 can take different addresses on SPMI bus. Rather than having a
>> default SID, follow the pm8350's example and make the sid explicit when
>> specifying ADC channels.
>>
>> Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
> 
> Hi Dmitry,
> 
> How do you want this applied? I can take it through IIO if you like but
> I'm not sure if that will cause trouble for other dts patches in flight.
> 
> I'm fine with it going via another tree though and don't expect
> to see any clashes. If so.

I think it would be better to get this through qcom -> arm-soc tree 
together with the rest of the patchset. Thank you for your permission.

> 
> Acked-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
> 
>> ---
>>   .../bindings/iio/adc/qcom,spmi-vadc.yaml      |  2 +-
>>   .../bindings/thermal/qcom-spmi-adc-tm5.yaml   |  4 +-
>>   arch/arm64/boot/dts/qcom/sc7280-idp.dtsi      |  2 +-
>>   arch/arm64/boot/dts/qcom/sc7280-qcard.dtsi    |  2 +-
>>   .../qcom/sc8280xp-lenovo-thinkpad-x13s.dts    |  4 +-
>>   .../boot/dts/qcom/sm7225-fairphone-fp4.dts    |  2 +-
>>   .../dt-bindings/iio/qcom,spmi-adc7-pmk8350.h  | 52 +++++++++----------
>>   7 files changed, 32 insertions(+), 36 deletions(-)
>>
>> diff --git a/Documentation/devicetree/bindings/iio/adc/qcom,spmi-vadc.yaml b/Documentation/devicetree/bindings/iio/adc/qcom,spmi-vadc.yaml
>> index bd6e0d6f6e0c..df317901e7d0 100644
>> --- a/Documentation/devicetree/bindings/iio/adc/qcom,spmi-vadc.yaml
>> +++ b/Documentation/devicetree/bindings/iio/adc/qcom,spmi-vadc.yaml
>> @@ -293,7 +293,7 @@ examples:
>>   
>>               /* Other properties are omitted */
>>               xo-therm@44 {
>> -                reg = <PMK8350_ADC7_AMUX_THM1_100K_PU>;
>> +                reg = <PMK8350_ADC7_AMUX_THM1_100K_PU(0)>;
>>                   qcom,ratiometric;
>>                   qcom,hw-settle-time = <200>;
>>               };
>> diff --git a/Documentation/devicetree/bindings/thermal/qcom-spmi-adc-tm5.yaml b/Documentation/devicetree/bindings/thermal/qcom-spmi-adc-tm5.yaml
>> index 52ec18cf1eda..ff07d27775dc 100644
>> --- a/Documentation/devicetree/bindings/thermal/qcom-spmi-adc-tm5.yaml
>> +++ b/Documentation/devicetree/bindings/thermal/qcom-spmi-adc-tm5.yaml
>> @@ -218,7 +218,7 @@ examples:
>>   
>>               /* Other properties are omitted */
>>               xo-therm@44 {
>> -                reg = <PMK8350_ADC7_AMUX_THM1_100K_PU>;
>> +                reg = <PMK8350_ADC7_AMUX_THM1_100K_PU(0)>;
>>                   qcom,ratiometric;
>>                   qcom,hw-settle-time = <200>;
>>               };
>> @@ -240,7 +240,7 @@ examples:
>>   
>>               pmk8350-xo-therm@0 {
>>                   reg = <0>;
>> -                io-channels = <&pmk8350_vadc PMK8350_ADC7_AMUX_THM1_100K_PU>;
>> +                io-channels = <&pmk8350_vadc PMK8350_ADC7_AMUX_THM1_100K_PU(0)>;
>>                   qcom,decimation = <340>;
>>                   qcom,ratiometric;
>>                   qcom,hw-settle-time-us = <200>;
>> diff --git a/arch/arm64/boot/dts/qcom/sc7280-idp.dtsi b/arch/arm64/boot/dts/qcom/sc7280-idp.dtsi
>> index 5dc9bee28e7f..14c9bdaa46ed 100644
>> --- a/arch/arm64/boot/dts/qcom/sc7280-idp.dtsi
>> +++ b/arch/arm64/boot/dts/qcom/sc7280-idp.dtsi
>> @@ -433,7 +433,7 @@ &pcie1_phy {
>>   
>>   &pmk8350_vadc {
>>   	pmk8350-die-temp@3 {
>> -		reg = <PMK8350_ADC7_DIE_TEMP>;
>> +		reg = <PMK8350_ADC7_DIE_TEMP(0)>;
>>   		label = "pmk8350_die_temp";
>>   		qcom,pre-scaling = <1 1>;
>>   	};
>> diff --git a/arch/arm64/boot/dts/qcom/sc7280-qcard.dtsi b/arch/arm64/boot/dts/qcom/sc7280-qcard.dtsi
>> index cb0cc2ba2fa3..e3919e074ebd 100644
>> --- a/arch/arm64/boot/dts/qcom/sc7280-qcard.dtsi
>> +++ b/arch/arm64/boot/dts/qcom/sc7280-qcard.dtsi
>> @@ -389,7 +389,7 @@ &pm8350c_pwm {
>>   
>>   &pmk8350_vadc {
>>   	pmk8350-die-temp@3 {
>> -		reg = <PMK8350_ADC7_DIE_TEMP>;
>> +		reg = <PMK8350_ADC7_DIE_TEMP(0)>;
>>   		label = "pmk8350_die_temp";
>>   		qcom,pre-scaling = <1 1>;
>>   	};
>> diff --git a/arch/arm64/boot/dts/qcom/sc8280xp-lenovo-thinkpad-x13s.dts b/arch/arm64/boot/dts/qcom/sc8280xp-lenovo-thinkpad-x13s.dts
>> index 46c7fdafb840..590400985055 100644
>> --- a/arch/arm64/boot/dts/qcom/sc8280xp-lenovo-thinkpad-x13s.dts
>> +++ b/arch/arm64/boot/dts/qcom/sc8280xp-lenovo-thinkpad-x13s.dts
>> @@ -824,13 +824,13 @@ &pmk8280_vadc {
>>   	status = "okay";
>>   
>>   	pmic-die-temp@3 {
>> -		reg = <PMK8350_ADC7_DIE_TEMP>;
>> +		reg = <PMK8350_ADC7_DIE_TEMP(0)>;
>>   		qcom,pre-scaling = <1 1>;
>>   		label = "pmk8350_die_temp";
>>   	};
>>   
>>   	xo-therm@44 {
>> -		reg = <PMK8350_ADC7_AMUX_THM1_100K_PU>;
>> +		reg = <PMK8350_ADC7_AMUX_THM1_100K_PU(0)>;
>>   		qcom,hw-settle-time = <200>;
>>   		qcom,ratiometric;
>>   		label = "pmk8350_xo_therm";
>> diff --git a/arch/arm64/boot/dts/qcom/sm7225-fairphone-fp4.dts b/arch/arm64/boot/dts/qcom/sm7225-fairphone-fp4.dts
>> index 7ae6aba5d2ec..af6cf4fbddc7 100644
>> --- a/arch/arm64/boot/dts/qcom/sm7225-fairphone-fp4.dts
>> +++ b/arch/arm64/boot/dts/qcom/sm7225-fairphone-fp4.dts
>> @@ -516,7 +516,7 @@ &pmk8350_rtc {
>>   
>>   &pmk8350_vadc {
>>   	adc-chan@644 {
>> -		reg = <PMK8350_ADC7_AMUX_THM1_100K_PU>;
>> +		reg = <PMK8350_ADC7_AMUX_THM1_100K_PU(0)>;
>>   		qcom,ratiometric;
>>   		qcom,hw-settle-time = <200>;
>>   		qcom,pre-scaling = <1 1>;
>> diff --git a/include/dt-bindings/iio/qcom,spmi-adc7-pmk8350.h b/include/dt-bindings/iio/qcom,spmi-adc7-pmk8350.h
>> index 6c296870e95b..ca85a2d69453 100644
>> --- a/include/dt-bindings/iio/qcom,spmi-adc7-pmk8350.h
>> +++ b/include/dt-bindings/iio/qcom,spmi-adc7-pmk8350.h
>> @@ -6,41 +6,37 @@
>>   #ifndef _DT_BINDINGS_QCOM_SPMI_VADC_PMK8350_H
>>   #define _DT_BINDINGS_QCOM_SPMI_VADC_PMK8350_H
>>   
>> -#ifndef PMK8350_SID
>> -#define PMK8350_SID					0
>> -#endif
>> -
>>   /* ADC channels for PMK8350_ADC for PMIC7 */
>> -#define PMK8350_ADC7_REF_GND			(PMK8350_SID << 8 | 0x0)
>> -#define PMK8350_ADC7_1P25VREF			(PMK8350_SID << 8 | 0x01)
>> -#define PMK8350_ADC7_VREF_VADC			(PMK8350_SID << 8 | 0x02)
>> -#define PMK8350_ADC7_DIE_TEMP			(PMK8350_SID << 8 | 0x03)
>> +#define PMK8350_ADC7_REF_GND(sid)			((sid) << 8 | 0x0)
>> +#define PMK8350_ADC7_1P25VREF(sid)			((sid) << 8 | 0x01)
>> +#define PMK8350_ADC7_VREF_VADC(sid)			((sid) << 8 | 0x02)
>> +#define PMK8350_ADC7_DIE_TEMP(sid)			((sid) << 8 | 0x03)
>>   
>> -#define PMK8350_ADC7_AMUX_THM1			(PMK8350_SID << 8 | 0x04)
>> -#define PMK8350_ADC7_AMUX_THM2			(PMK8350_SID << 8 | 0x05)
>> -#define PMK8350_ADC7_AMUX_THM3			(PMK8350_SID << 8 | 0x06)
>> -#define PMK8350_ADC7_AMUX_THM4			(PMK8350_SID << 8 | 0x07)
>> -#define PMK8350_ADC7_AMUX_THM5			(PMK8350_SID << 8 | 0x08)
>> +#define PMK8350_ADC7_AMUX_THM1(sid)			((sid) << 8 | 0x04)
>> +#define PMK8350_ADC7_AMUX_THM2(sid)			((sid) << 8 | 0x05)
>> +#define PMK8350_ADC7_AMUX_THM3(sid)			((sid) << 8 | 0x06)
>> +#define PMK8350_ADC7_AMUX_THM4(sid)			((sid) << 8 | 0x07)
>> +#define PMK8350_ADC7_AMUX_THM5(sid)			((sid) << 8 | 0x08)
>>   
>>   /* 30k pull-up1 */
>> -#define PMK8350_ADC7_AMUX_THM1_30K_PU		(PMK8350_SID << 8 | 0x24)
>> -#define PMK8350_ADC7_AMUX_THM2_30K_PU		(PMK8350_SID << 8 | 0x25)
>> -#define PMK8350_ADC7_AMUX_THM3_30K_PU		(PMK8350_SID << 8 | 0x26)
>> -#define PMK8350_ADC7_AMUX_THM4_30K_PU		(PMK8350_SID << 8 | 0x27)
>> -#define PMK8350_ADC7_AMUX_THM5_30K_PU		(PMK8350_SID << 8 | 0x28)
>> +#define PMK8350_ADC7_AMUX_THM1_30K_PU(sid)		((sid) << 8 | 0x24)
>> +#define PMK8350_ADC7_AMUX_THM2_30K_PU(sid)		((sid) << 8 | 0x25)
>> +#define PMK8350_ADC7_AMUX_THM3_30K_PU(sid)		((sid) << 8 | 0x26)
>> +#define PMK8350_ADC7_AMUX_THM4_30K_PU(sid)		((sid) << 8 | 0x27)
>> +#define PMK8350_ADC7_AMUX_THM5_30K_PU(sid)		((sid) << 8 | 0x28)
>>   
>>   /* 100k pull-up2 */
>> -#define PMK8350_ADC7_AMUX_THM1_100K_PU		(PMK8350_SID << 8 | 0x44)
>> -#define PMK8350_ADC7_AMUX_THM2_100K_PU		(PMK8350_SID << 8 | 0x45)
>> -#define PMK8350_ADC7_AMUX_THM3_100K_PU		(PMK8350_SID << 8 | 0x46)
>> -#define PMK8350_ADC7_AMUX_THM4_100K_PU		(PMK8350_SID << 8 | 0x47)
>> -#define PMK8350_ADC7_AMUX_THM5_100K_PU		(PMK8350_SID << 8 | 0x48)
>> +#define PMK8350_ADC7_AMUX_THM1_100K_PU(sid)		((sid) << 8 | 0x44)
>> +#define PMK8350_ADC7_AMUX_THM2_100K_PU(sid)		((sid) << 8 | 0x45)
>> +#define PMK8350_ADC7_AMUX_THM3_100K_PU(sid)		((sid) << 8 | 0x46)
>> +#define PMK8350_ADC7_AMUX_THM4_100K_PU(sid)		((sid) << 8 | 0x47)
>> +#define PMK8350_ADC7_AMUX_THM5_100K_PU(sid)		((sid) << 8 | 0x48)
>>   
>>   /* 400k pull-up3 */
>> -#define PMK8350_ADC7_AMUX_THM1_400K_PU		(PMK8350_SID << 8 | 0x64)
>> -#define PMK8350_ADC7_AMUX_THM2_400K_PU		(PMK8350_SID << 8 | 0x65)
>> -#define PMK8350_ADC7_AMUX_THM3_400K_PU		(PMK8350_SID << 8 | 0x66)
>> -#define PMK8350_ADC7_AMUX_THM4_400K_PU		(PMK8350_SID << 8 | 0x67)
>> -#define PMK8350_ADC7_AMUX_THM5_400K_PU		(PMK8350_SID << 8 | 0x68)
>> +#define PMK8350_ADC7_AMUX_THM1_400K_PU(sid)		((sid) << 8 | 0x64)
>> +#define PMK8350_ADC7_AMUX_THM2_400K_PU(sid)		((sid) << 8 | 0x65)
>> +#define PMK8350_ADC7_AMUX_THM3_400K_PU(sid)		((sid) << 8 | 0x66)
>> +#define PMK8350_ADC7_AMUX_THM4_400K_PU(sid)		((sid) << 8 | 0x67)
>> +#define PMK8350_ADC7_AMUX_THM5_400K_PU(sid)		((sid) << 8 | 0x68)
>>   
>>   #endif /* _DT_BINDINGS_QCOM_SPMI_VADC_PMK8350_H */
> 

-- 
With best wishes
Dmitry


^ permalink raw reply	[flat|nested] 18+ messages in thread

end of thread, other threads:[~2023-04-01 14:59 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-03-29  0:08 [PATCH 0/6] arm64: dts: qcom: sc8280xp: remove duplication in PMIC declarations Dmitry Baryshkov
2023-03-29  0:08 ` [PATCH 1/6] dt-bindings: iio: qcom,spmi-adc7-pmk8350.h: include sid into defines Dmitry Baryshkov
2023-03-29  0:21   ` Konrad Dybcio
2023-03-30  7:49   ` Krzysztof Kozlowski
2023-04-01 14:48   ` Jonathan Cameron
2023-04-01 14:59     ` Dmitry Baryshkov
2023-03-29  0:08 ` [PATCH 2/6] arm64: dts: qcom: pmk8350: rename pon label Dmitry Baryshkov
2023-03-29  0:22   ` Konrad Dybcio
2023-03-29  0:08 ` [PATCH 3/6] arm64: dts: qcom: use main pmk8350.dtsi for sc8280xp platform Dmitry Baryshkov
2023-03-29  0:27   ` Konrad Dybcio
2023-03-29  0:29     ` Konrad Dybcio
2023-03-29  0:35       ` Konrad Dybcio
2023-03-29 11:54         ` Dmitry Baryshkov
2023-03-29  0:08 ` [PATCH 4/6] arm64: dts: qcom: pm8350: include SID into labels Dmitry Baryshkov
2023-03-29  0:33   ` Konrad Dybcio
2023-03-29 10:51     ` Dmitry Baryshkov
2023-03-29  0:08 ` [PATCH 5/6] arm64: dts: qcom: sc8280xp*: use pm8350.dtsi Dmitry Baryshkov
2023-03-29  0:08 ` [PATCH 6/6] arm64: dts: qcom: sc8280xp*: use pm8350c.dtsi and pmr735a.dtsi Dmitry Baryshkov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).