Skip to contentSkip to conversation

pwm: sun4i: direct clock output support for Allwinner A64

PATCH Superseded Peter Vasil 3 participants 3 messages Apr 26, 2020 – Apr 28, 2020

Subsystems (3)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 pwm: sun4i: direct clock output support for Allwinner A64

Allwinner A64 is capable of a direct clock output on PWM (see A64 User Manual chapter 3.10). Add support for this in the sun4i PWM driver and adjust compatibility in sun50i-a64 base device tree.

---
 arch/arm64/boot/dts/allwinner/sun50i-a64.dtsi | 6 ++----
 drivers/pwm/pwm-sun4i.c                       | 9 +++++++++
 2 files changed, 11 insertions(+), 4 deletions(-)
arch/arm64/boot/dts/allwinner/sun50i-a64.dtsi +2 -4
index 31143fe64d91..c334fd106854 100644
@@ -1069,8 +1069,7 @@ gic: interrupt-controller@1c81000 {
 		};
 
 		pwm: pwm@1c21400 {
-			compatible = "allwinner,sun50i-a64-pwm",
-				     "allwinner,sun5i-a13-pwm";
+			compatible = "allwinner,sun50i-a64-pwm";
 			reg = <0x01c21400 0x400>;
 			clocks = <&osc24M>;
 			pinctrl-names = "default";
@@ -1252,8 +1251,7 @@ r_ir: ir@1f02000 {
 		};
 
 		r_pwm: pwm@1f03800 {
-			compatible = "allwinner,sun50i-a64-pwm",
-				     "allwinner,sun5i-a13-pwm";
+			compatible = "allwinner,sun50i-a64-pwm";
 			reg = <0x01f03800 0x400>;
 			clocks = <&osc24M>;
 			pinctrl-names = "default";
drivers/pwm/pwm-sun4i.c +9 -0
index 5c677c563349..18fbbe3277d0 100644
@@ -352,6 +352,12 @@ static const struct sun4i_pwm_data sun4i_pwm_single_bypass = {
 	.npwm = 1,
 };
 
+static const struct sun4i_pwm_data sun50i_a64_pwm_data = {
+	.has_prescaler_bypass = true,
+	.has_direct_mod_clk_output = true,
+	.npwm = 1,
+};
+
 static const struct sun4i_pwm_data sun50i_h6_pwm_data = {
 	.has_prescaler_bypass = true,
 	.has_direct_mod_clk_output = true,
@@ -374,6 +380,9 @@ static const struct of_device_id sun4i_pwm_dt_ids[] = {
 	}, {
 		.compatible = "allwinner,sun8i-h3-pwm",
 		.data = &sun4i_pwm_single_bypass,
+	}, {
+		.compatible = "allwinner,sun50i-a64-pwm",
+		.data = &sun50i_a64_pwm_data,
 	}, {
 		.compatible = "allwinner,sun50i-h6-pwm",
 		.data = &sun50i_h6_pwm_data,
Signature · 1 line
2.25.1
#1 lore raw

Hi,

Quoted 25 lines · Peter Vasil

Allwinner A64 is capable of a direct clock output on PWM (see A64 User Manual chapter 3.10). Add support for this in the sun4i PWM driver and adjust compatibility in sun50i-a64 base device tree.

---
 arch/arm64/boot/dts/allwinner/sun50i-a64.dtsi | 6 ++----
 drivers/pwm/pwm-sun4i.c                       | 9 +++++++++
 2 files changed, 11 insertions(+), 4 deletions(-)
arch/arm64/boot/dts/allwinner/sun50i-a64.dtsi +1 -2
index 31143fe64d91..c334fd106854 100644
@@ -1069,8 +1069,7 @@ gic: interrupt-controller@1c81000 {
 		};
 
 		pwm: pwm@1c21400 {
-			compatible = "allwinner,sun50i-a64-pwm",
-				     "allwinner,sun5i-a13-pwm";
+			compatible = "allwinner,sun50i-a64-pwm";
 			reg = <0x01c21400 0x400>;
 			clocks = <&osc24M>;
 			pinctrl-names = "default";

arch/arm64/boot/dts/allwinner/sun50i-a64.dtsi r_ir: ir@1f02000 { · line 1254

Quoted 6 lines
arch/arm64/boot/dts/allwinner/sun50i-a64.dtsi +1 -2
@@ -1252,8 +1251,7 @@ r_ir: ir@1f02000 {
 		};
 
 		r_pwm: pwm@1f03800 {
-			compatible = "allwinner,sun50i-a64-pwm",
-				     "allwinner,sun5i-a13-pwm";
+			compatible = "allwinner,sun50i-a64-pwm";

There's no need to remove that compatible, it's actually working as intended..

Quoted 21 lines
arch/arm64/boot/dts/allwinner/sun50i-a64.dtsi +0 -0
 			reg = <0x01f03800 0x400>;
 			clocks = <&osc24M>;
 			pinctrl-names = "default";
drivers/pwm/pwm-sun4i.c +6 -0
index 5c677c563349..18fbbe3277d0 100644
@@ -352,6 +352,12 @@ static const struct sun4i_pwm_data sun4i_pwm_single_bypass = {
 	.npwm = 1,
 };
 
+static const struct sun4i_pwm_data sun50i_a64_pwm_data = {
+	.has_prescaler_bypass = true,
+	.has_direct_mod_clk_output = true,
+	.npwm = 1,
+};
+
 static const struct sun4i_pwm_data sun50i_h6_pwm_data = {
 	.has_prescaler_bypass = true,
 	.has_direct_mod_clk_output = true,

drivers/pwm/pwm-sun4i.c static const struct of_device_id sun4i_pwm_dt_ids[] = { · line 385

Quoted 6 lines
drivers/pwm/pwm-sun4i.c +3 -0
@@ -374,6 +380,9 @@ static const struct of_device_id sun4i_pwm_dt_ids[] = {
 	}, {
 		.compatible = "allwinner,sun8i-h3-pwm",
 		.data = &sun4i_pwm_single_bypass,
+	}, {
+		.compatible = "allwinner,sun50i-a64-pwm",
+		.data = &sun50i_a64_pwm_data,

Ie, if the OS only has support for the A13, then it will use it as an A13, and if it has support for the A64 variant, then it can use some more advanced features.

Maxime

#2 lore raw

Hello Maxime,

Quoted 69 lines · Maxime Ripard

Hi,

Review

Quoted 11 lines · Peter Vasil

Allwinner A64 is capable of a direct clock output on PWM (see A64 User Manual chapter 3.10). Add support for this in the sun4i PWM driver and adjust compatibility in sun50i-a64 base device tree.

---
 arch/arm64/boot/dts/allwinner/sun50i-a64.dtsi | 6 ++----
 drivers/pwm/pwm-sun4i.c                       | 9 +++++++++
 2 files changed, 11 insertions(+), 4 deletions(-)
(quoted diff) +0 -0

b/arch/arm64/boot/dts/allwinner/sun50i-a64.dtsi

Quoted 14 lines

index 31143fe64d91..c334fd106854 100644

arch/arm64/boot/dts/allwinner/sun50i-a64.dtsi +1 -2
@@ -1069,8 +1069,7 @@ gic: interrupt-controller@1c81000 {
              };
 
              pwm: pwm@1c21400 {
-                     compatible = "allwinner,sun50i-a64-pwm",
-                                  "allwinner,sun5i-a13-pwm";
+                     compatible = "allwinner,sun50i-a64-pwm";
                      reg = <0x01c21400 0x400>;
                      clocks = <&osc24M>;
                      pinctrl-names = "default";

arch/arm64/boot/dts/allwinner/sun50i-a64.dtsi r_ir: ir@1f02000 { · line 1254

Quoted 6 lines
arch/arm64/boot/dts/allwinner/sun50i-a64.dtsi +1 -2
@@ -1252,8 +1251,7 @@ r_ir: ir@1f02000 {
              };
 
              r_pwm: pwm@1f03800 {
-                     compatible = "allwinner,sun50i-a64-pwm",
-                                  "allwinner,sun5i-a13-pwm";
+                     compatible = "allwinner,sun50i-a64-pwm";

There's no need to remove that compatible, it's actually working as intended..

drivers/pwm/pwm-sun4i.c static const struct sun4i_pwm_data

Quoted 8 lines
arch/arm64/boot/dts/allwinner/sun50i-a64.dtsi +0 -0
                      reg = <0x01f03800 0x400>;
                      clocks = <&osc24M>;
                      pinctrl-names = "default";
drivers/pwm/pwm-sun4i.c +0 -0
index 5c677c563349..18fbbe3277d0 100644
@@ -352,6 +352,12 @@ static const struct sun4i_pwm_data

sun4i_pwm_single_bypass = {

drivers/pwm/pwm-sun4i.c static const struct of_device_id sun4i_pwm_dt_ids[]

Quoted 13 lines
drivers/pwm/pwm-sun4i.c +6 -0
      .npwm = 1,
 };
 
+static const struct sun4i_pwm_data sun50i_a64_pwm_data = {
+     .has_prescaler_bypass = true,
+     .has_direct_mod_clk_output = true,
+     .npwm = 1,
+};
+
 static const struct sun4i_pwm_data sun50i_h6_pwm_data = {
      .has_prescaler_bypass = true,
      .has_direct_mod_clk_output = true,
@@ -374,6 +380,9 @@ static const struct of_device_id sun4i_pwm_dt_ids[]

= {

drivers/pwm/pwm-sun4i.c static const struct of_device_id sun4i_pwm_dt_ids[] = { · line 385

Quoted 6 lines
drivers/pwm/pwm-sun4i.c +3 -0
      }, {
              .compatible = "allwinner,sun8i-h3-pwm",
              .data = &sun4i_pwm_single_bypass,
+     }, {
+             .compatible = "allwinner,sun50i-a64-pwm",
+             .data = &sun50i_a64_pwm_data,
Quoted 6 lines

Ie, if the OS only has support for the A13, then it will use it as an A13, and
if it has support for the A64 variant, then it can use some more advanced features.

True, I didn't realize that when I was replicating H6 config. I just

tested the original compatibility on Remix Mini and it works fine, I'll send an amended patch shortly.

Maxime

Quoted 1 line

Thanks!
Peter