Skip to contentSkip to conversation

pwm: meson: add pwm support for A1

PATCH Superseded George Stark 2 participants 6 messages Jul 1, 2024 – Jul 2, 2024

Subsystems (3)

v2 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

v2 cover pwm: meson: add pwm support for A1

Add support for Amlogic meson A1 SoC family PWM.

Changes in v2:
add patch with optional power-domains to pwm bindings;
fix syntax in a1 bindigns patch:
- use enum over const for amlogic,meson-a1-pwm beacuse adding more devices here are expected
- leave only base compatible amlogic,meson-s4-pwm in check section dt_binding_check and dtbs_check run ok now;
previos version: [1]

[1] https://lore.kernel.org/lkml/[email protected]/T/

George Stark (3):
dt-bindings: pwm: amlogic: Add new bindings for meson A1 PWM
dt-bindings: pwm: amlogic: Add optional power-domains
arm64: dts: meson: a1: add definitions for meson PWM

 .../devicetree/bindings/pwm/pwm-amlogic.yaml  |   7 +
 arch/arm64/boot/dts/amlogic/meson-a1.dtsi     | 215 ++++++++++++++++++
 2 files changed, 222 insertions(+)

--
2.25.1

#1 lore raw

PATCH v2 1/3 dt-bindings: pwm: amlogic: Add new bindings for meson A1 PWM

The chip has 3 dual-channel PWM modules PWM_AB, PWM_CD, PWM_EF.

---
 Documentation/devicetree/bindings/pwm/pwm-amlogic.yaml | 4 ++++
 1 file changed, 4 insertions(+)
Documentation/devicetree/bindings/pwm/pwm-amlogic.yaml +4 -0
index 1d71d4f8f328..da22cb3ed878 100644
@@ -37,6 +37,10 @@ properties:
       - enum:
           - amlogic,meson8-pwm-v2
           - amlogic,meson-s4-pwm
+      - items:
+          - enum:
+              - amlogic,meson-a1-pwm
+          - const: amlogic,meson-s4-pwm
       - items:
           - enum:
               - amlogic,meson8b-pwm-v2
Signature · 1 line
2.25.1
#2 lore raw

PATCH v2 2/3 dt-bindings: pwm: amlogic: Add optional power-domains

In reply to George Stark

On newer SoCs, the PWM can require a power-domain to operate so add it as optional.

---
 Documentation/devicetree/bindings/pwm/pwm-amlogic.yaml | 3 +++
 1 file changed, 3 insertions(+)
Documentation/devicetree/bindings/pwm/pwm-amlogic.yaml +3 -0
index da22cb3ed878..c814d88748dd 100644
@@ -60,6 +60,9 @@ properties:
     minItems: 1
     maxItems: 2
 
+  power-domains:
+    maxItems: 1
+
   "#pwm-cells":
     const: 3
 
Signature · 1 line
2.25.1
maintainer
#3 lore raw

Re: [PATCH v2 2/3] dt-bindings: pwm: amlogic: Add optional power-domains

Quoted 2 lines · George Stark

On newer SoCs, the PWM can require a power-domain to operate so add it as optional.

If required, then how is it optional?

If the 'newer SoCs' means the one you just added, then this should be squashed into the prior patch with a conditional schema making it required for the new compatible.

Quoted 23 lines
---
 Documentation/devicetree/bindings/pwm/pwm-amlogic.yaml | 3 +++
 1 file changed, 3 insertions(+)
Documentation/devicetree/bindings/pwm/pwm-amlogic.yaml +3 -0
index da22cb3ed878..c814d88748dd 100644
@@ -60,6 +60,9 @@ properties:
     minItems: 1
     maxItems: 2
 
+  power-domains:
+    maxItems: 1
+
   "#pwm-cells":
     const: 3
 
Signature · 1 line
2.25.1
#4 lore raw

Re: [PATCH v2 2/3] dt-bindings: pwm: amlogic: Add optional power-domains

Hello Rob

Thanks for the review.

Quoted 5 lines · Rob Herring
Quoted 2 lines · George Stark

On newer SoCs, the PWM can require a power-domain to operate so add it as optional.

If required, then how is it optional?

Newly adding SoC's PWM definitely requires power-domains, older SoCs don't have dedicated power-domain for that that kind of periphery. But I can't say other new SoCs won't require it too that's why I made it by a separate patch. And squash the power-domians patch into main one is ok too.

Quoted 29 lines

If the 'newer SoCs' means the one you just added, then this should be squashed into the prior patch with a conditional schema making it required for the new compatible.

Quoted 23 lines
---
  Documentation/devicetree/bindings/pwm/pwm-amlogic.yaml | 3 +++
  1 file changed, 3 insertions(+)
Documentation/devicetree/bindings/pwm/pwm-amlogic.yaml +3 -0
index da22cb3ed878..c814d88748dd 100644
@@ -60,6 +60,9 @@ properties:
      minItems: 1
      maxItems: 2
 
+  power-domains:
+    maxItems: 1
+
    "#pwm-cells":
      const: 3
 
Signature · 1 line
2.25.1
Signature · 2 lines
Best regards
George
#5 lore raw

PATCH v2 3/3 arm64: dts: meson: a1: add definitions for meson PWM

In reply to George Stark

From: George Stark <[email protected]>

The chip has 3 dual-channel PWM modules PWM_AB, PWM_CD, PWM_EF those can be connected to various digital I/O pins.

Each of 6 PWM is driven by individually selected clock parent and 8-bit divider. The PWM signal is generated using two 16-bit counters.

---
 arch/arm64/boot/dts/amlogic/meson-a1.dtsi | 215 ++++++++++++++++++++++
 1 file changed, 215 insertions(+)
arch/arm64/boot/dts/amlogic/meson-a1.dtsi +215 -0
index 2a69e1e41bdc..d93b10bd156b 100644
@@ -307,6 +307,188 @@ mux {
 					};
 				};
 
+				pwm_a_pins1: pwm-a-pins1 {
+					mux {
+						groups = "pwm_a_x6";
+						function = "pwm_a";
+					};
+				};
+
+				pwm_a_pins2: pwm-a-pins2 {
+					mux {
+						groups = "pwm_a_x7";
+						function = "pwm_a";
+					};
+				};
+
+				pwm_a_pins3: pwm-a-pins3 {
+					mux {
+						groups = "pwm_a_f10";
+						function = "pwm_a";
+					};
+				};
+
+				pwm_a_pins4: pwm-a-pins4 {
+					mux {
+						groups = "pwm_a_f6";
+						function = "pwm_a";
+					};
+				};
+
+				pwm_a_pins5: pwm-a-pins5 {
+					mux {
+						groups = "pwm_a_a";
+						function = "pwm_a";
+					};
+				};
+
+				pwm_b_pins1: pwm-b-pins1 {
+					mux {
+						groups = "pwm_b_x";
+						function = "pwm_b";
+					};
+				};
+
+				pwm_b_pins2: pwm-b-pins2 {
+					mux {
+						groups = "pwm_b_f";
+						function = "pwm_b";
+					};
+				};
+
+				pwm_b_pins3: pwm-b-pins3 {
+					mux {
+						groups = "pwm_b_a";
+						function = "pwm_b";
+					};
+				};
+
+				pwm_c_pins1: pwm-c-pins1 {
+					mux {
+						groups = "pwm_c_x";
+						function = "pwm_c";
+					};
+				};
+
+				pwm_c_pins2: pwm-c-pins2 {
+					mux {
+						groups = "pwm_c_f3";
+						function = "pwm_c";
+					};
+				};
+
+				pwm_c_pins3: pwm-c-pins3 {
+					mux {
+						groups = "pwm_c_f8";
+						function = "pwm_c";
+					};
+				};
+
+				pwm_c_pins4: pwm-c-pins4 {
+					mux {
+						groups = "pwm_c_a";
+						function = "pwm_c";
+					};
+				};
+
+				pwm_d_pins1: pwm-d-pins1 {
+					mux {
+						groups = "pwm_d_x15";
+						function = "pwm_d";
+					};
+				};
+
+				pwm_d_pins2: pwm-d-pins2 {
+					mux {
+						groups = "pwm_d_x13";
+						function = "pwm_d";
+					};
+				};
+
+				pwm_d_pins3: pwm-d-pins3 {
+					mux {
+						groups = "pwm_d_x10";
+						function = "pwm_d";
+					};
+				};
+
+				pwm_d_pins4: pwm-d-pins4 {
+					mux {
+						groups = "pwm_d_f";
+						function = "pwm_d";
+					};
+				};
+
+				pwm_e_pins1: pwm-e-pins1 {
+					mux {
+						groups = "pwm_e_p";
+						function = "pwm_e";
+					};
+				};
+
+				pwm_e_pins2: pwm-e-pins2 {
+					mux {
+						groups = "pwm_e_x16";
+						function = "pwm_e";
+					};
+				};
+
+				pwm_e_pins3: pwm-e-pins3 {
+					mux {
+						groups = "pwm_e_x14";
+						function = "pwm_e";
+					};
+				};
+
+				pwm_e_pins4: pwm-e-pins4 {
+					mux {
+						groups = "pwm_e_x2";
+						function = "pwm_e";
+					};
+				};
+
+				pwm_e_pins5: pwm-e-pins5 {
+					mux {
+						groups = "pwm_e_f";
+						function = "pwm_e";
+					};
+				};
+
+				pwm_e_pins6: pwm-e-pins6 {
+					mux {
+						groups = "pwm_e_a";
+						function = "pwm_e";
+					};
+				};
+
+				pwm_f_pins1: pwm-f-pins1 {
+					mux {
+						groups = "pwm_f_b";
+						function = "pwm_f";
+					};
+				};
+
+				pwm_f_pins2: pwm-f-pins2 {
+					mux {
+						groups = "pwm_f_x";
+						function = "pwm_f";
+					};
+				};
+
+				pwm_f_pins3: pwm-f-pins3 {
+					mux {
+						groups = "pwm_f_f4";
+						function = "pwm_f";
+					};
+				};
+
+				pwm_f_pins4: pwm-f-pins4 {
+					mux {
+						groups = "pwm_f_f12";
+						function = "pwm_f";
+					};
+				};
+
 				sdio_pins: sdio {
 					mux0 {
 						groups = "sdcard_d0_x",
@@ -648,6 +830,28 @@ uart_AO_B: serial@2000 {
 				status = "disabled";
 			};
 
+			pwm_ab: pwm@2400 {
+				compatible = "amlogic,meson-a1-pwm",
+					     "amlogic,meson-s4-pwm";
+				reg = <0x0 0x2400 0x0 0x24>;
+				#pwm-cells = <3>;
+				clocks = <&clkc_periphs CLKID_PWM_A>,
+					 <&clkc_periphs CLKID_PWM_B>;
+				power-domains = <&pwrc PWRC_I2C_ID>;
+				status = "disabled";
+			};
+
+			pwm_cd: pwm@2800 {
+				compatible = "amlogic,meson-a1-pwm",
+					     "amlogic,meson-s4-pwm";
+				reg = <0x0 0x2800 0x0 0x24>;
+				#pwm-cells = <3>;
+				clocks = <&clkc_periphs CLKID_PWM_C>,
+					 <&clkc_periphs CLKID_PWM_D>;
+				power-domains = <&pwrc PWRC_I2C_ID>;
+				status = "disabled";
+			};
+
 			saradc: adc@2c00 {
 				compatible = "amlogic,meson-g12a-saradc",
 					"amlogic,meson-saradc";
@@ -731,6 +935,17 @@ sec_AO: ao-secure@5a20 {
 				amlogic,has-chip-id;
 			};
 
+			pwm_ef: pwm@5400 {
+				compatible = "amlogic,meson-a1-pwm",
+					     "amlogic,meson-s4-pwm";
+				reg = <0x0 0x5400 0x0 0x24>;
+				#pwm-cells = <3>;
+				clocks = <&clkc_periphs CLKID_PWM_E>,
+					 <&clkc_periphs CLKID_PWM_F>;
+				power-domains = <&pwrc PWRC_I2C_ID>;
+				status = "disabled";
+			};
+
 			clkc_pll: pll-clock-controller@7c80 {
 				compatible = "amlogic,a1-pll-clkc";
 				reg = <0 0x7c80 0 0x18c>;
Signature · 1 line
2.25.1