diff mbox series

[v2,12/22] arm64: dts: qcom: pm8350: allow overriding SID and label

Message ID 20230401220810.3563708-13-dmitry.baryshkov@linaro.org
State New
Headers show
Series arm64: dts: qcom: remove duplication in PMIC declarations | expand

Commit Message

Dmitry Baryshkov April 1, 2023, 10:08 p.m. UTC
The platform can use several instances of PM8350 PMIC. Allow overriding
the SID and node labels inside pm8350.dtsi.

Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
---
 arch/arm64/boot/dts/qcom/pm8350.dtsi          | 29 ++++++++++++++-----
 arch/arm64/boot/dts/qcom/pmic-dyn-footer.dtsi |  3 ++
 arch/arm64/boot/dts/qcom/pmic-dyn-header.dtsi |  6 ++++
 3 files changed, 30 insertions(+), 8 deletions(-)
diff mbox series

Patch

diff --git a/arch/arm64/boot/dts/qcom/pm8350.dtsi b/arch/arm64/boot/dts/qcom/pm8350.dtsi
index 9fb963df4b41..b7b14b5fe67d 100644
--- a/arch/arm64/boot/dts/qcom/pm8350.dtsi
+++ b/arch/arm64/boot/dts/qcom/pm8350.dtsi
@@ -6,12 +6,23 @@ 
 #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 PMIC_SID
+	#define PMIC_SID 1
+#endif
+
+#ifndef PMIC_LABEL
+	#define PMIC_LABEL pm8350
+#endif
+
+#include "pmic-dyn-header.dtsi"
+
 / {
 	thermal-zones {
-		pm8350-thermal {
+		NODE(thermal) {
 			polling-delay-passive = <100>;
 			polling-delay = <0>;
-			thermal-sensors = <&pm8350_temp_alarm>;
+			thermal-sensors = <&LABEL(temp_alarm)>;
 
 			trips {
 				trip0 {
@@ -31,27 +42,29 @@  crit {
 };
 
 &spmi_bus {
-	pm8350: pmic@1 {
+	PMIC_LABEL: pmic@PMIC_SID {
 		compatible = "qcom,pm8350", "qcom,spmi-pmic";
-		reg = <0x1 SPMI_USID>;
+		reg = <PMIC_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 = <PMIC_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>;
 		};
 	};
 };
+
+#include "pmic-dyn-footer.dtsi"
diff --git a/arch/arm64/boot/dts/qcom/pmic-dyn-footer.dtsi b/arch/arm64/boot/dts/qcom/pmic-dyn-footer.dtsi
index 1c81269f0783..29b10e7fb8c3 100644
--- a/arch/arm64/boot/dts/qcom/pmic-dyn-footer.dtsi
+++ b/arch/arm64/boot/dts/qcom/pmic-dyn-footer.dtsi
@@ -9,5 +9,8 @@ 
 #undef _LABEL
 #undef __LABEL
 
+#undef NODE
+
 #undef PMIC_SID
 #undef PMIC_LABEL
+#undef PMIC_NODE
diff --git a/arch/arm64/boot/dts/qcom/pmic-dyn-header.dtsi b/arch/arm64/boot/dts/qcom/pmic-dyn-header.dtsi
index 75f0448568bd..bb41c9387aba 100644
--- a/arch/arm64/boot/dts/qcom/pmic-dyn-header.dtsi
+++ b/arch/arm64/boot/dts/qcom/pmic-dyn-header.dtsi
@@ -9,6 +9,12 @@ 
  * pmic-dyn-footer.dtsi.
  */
 
+#ifndef PMIC_NODE
+	#define PMIC_NODE PMIC_LABEL
+#endif
+
 #define LABEL(name) _LABEL(PMIC_LABEL, name)
 #define _LABEL(pmic, name) __LABEL(pmic, name)
 #define __LABEL(pmic, name) pmic ## _ ## name
+
+#define NODE(name) PMIC_NODE ##-##  name