pwm: sun4i: Add Allwinner H3 support
Subsystems (4)
PATCH 1/2 pwm: sun4i: Add Allwinner H3 support
According to the latest datasheet (v1.2), H3 has single PWM channel. H3 PWM controller has same register layout as sun4i driver, so it works by adding H3 specific data.
And the second PWM channel is not supported, so the pinctrl function is removed.
Datasheet:
http://linux-sunxi.org/File:Allwinner_H3_Datasheet_V1.2.pdf
Test environment:
Tested on Nano Pi M1 board, but PA5 pin is assigned for UART0. So the debug console should be changed to other port like UART1.
Ex)
aliases {
serial0 = &uart1;
};
&uart1 {
pinctrl-names = "default";
pinctrl-0 = <&uart1_pins_a>;
status = "okay";
};--- Documentation/devicetree/bindings/pwm/pwm-sun4i.txt | 1 + arch/arm/boot/dts/sun8i-h3.dtsi | 15 +++++++++++++++ drivers/pinctrl/sunxi/pinctrl-sun8i-h3.c | 1 - drivers/pwm/pwm-sun4i.c | 9 +++++++++ 4 files changed, 25 insertions(+), 1 deletion(-)
Documentation/devicetree/bindings/pwm/pwm-sun4i.txt +1 -0
@@ -6,6 +6,7 @@ Required properties: - "allwinner,sun5i-a10s-pwm" - "allwinner,sun5i-a13-pwm" - "allwinner,sun7i-a20-pwm" + - "allwinner,sun8i-h3-pwm" - reg: physical base address and length of the controller's registers - #pwm-cells: should be 3. See pwm.txt in this directory for a description of the cells format.
arch/arm/boot/dts/sun8i-h3.dtsi +15 -0
@@ -512,6 +512,13 @@ allwinner,pull = <SUN4I_PINCTRL_NO_PULL>; }; + pwm0_pin_a: pwm0@0 { + allwinner,pins = "PA5"; + allwinner,function = "pwm0"; + allwinner,drive = <SUN4I_PINCTRL_10_MA>; + allwinner,pull = <SUN4I_PINCTRL_NO_PULL>; + }; + uart0_pins_a: uart0@0 { allwinner,pins = "PA4", "PA5"; allwinner,function = "uart0";
@@ -585,6 +592,14 @@ interrupts = <GIC_SPI 25 IRQ_TYPE_LEVEL_HIGH>; }; + pwm: pwm@01c21400 { + compatible = "allwinner,sun8i-h3-pwm"; + reg = <0x01c21400 0x8>; + clocks = <&osc24M>; + #pwm-cells = <3>; + status = "disabled"; + }; + uart0: serial@01c28000 { compatible = "snps,dw-apb-uart"; reg = <0x01c28000 0x400>;
drivers/pinctrl/sunxi/pinctrl-sun8i-h3.c +0 -1
@@ -60,7 +60,6 @@ static const struct sunxi_desc_pin sun8i_h3_pins[] = { SUNXI_FUNCTION(0x0, "gpio_in"), SUNXI_FUNCTION(0x1, "gpio_out"), SUNXI_FUNCTION(0x2, "sim"), /* PWREN */ - SUNXI_FUNCTION(0x3, "pwm1"), SUNXI_FUNCTION_IRQ_BANK(0x6, 0, 6)), /* PA_EINT6 */ SUNXI_PIN(SUNXI_PINCTRL_PIN(A, 7), SUNXI_FUNCTION(0x0, "gpio_in"),
drivers/pwm/pwm-sun4i.c +9 -0
@@ -284,6 +284,12 @@ static const struct sun4i_pwm_data sun4i_pwm_data_a20 = { .npwm = 2, }; +static const struct sun4i_pwm_data sun4i_pwm_data_h3 = { + .has_prescaler_bypass = true, + .has_rdy = true, + .npwm =1 , +}; +static const struct of_device_id sun4i_pwm_dt_ids[] = { { .compatible ="allwinner,sun4i-a10-pwm" ,
@@ -298,6 +304,9 @@ static const struct of_device_id sun4i_pwm_dt_ids[] = { .compatible = "allwinner,sun7i-a20-pwm", .data = &sun4i_pwm_data_a20, }, { + .compatible = "allwinner,sun8i-h3-pwm", + .data = &sun4i_pwm_data_h3, + }, {/* sentinel */ }, };
Signature · 1 line
1.9.1
PATCH 2/2 ARM: dts: sun8i-h3: Add UART1 pinctrl
In H3, PA5 can be used as PWM and UART0. If the PWM is used, the console UART should be moved to other port.
This patch enables UART1 pinctrl to support this case.
PA5: PWM
PG6, PG7: debug console
--- arch/arm/boot/dts/sun8i-h3.dtsi | 7 +++++++ 1 file changed, 7 insertions(+)
arch/arm/boot/dts/sun8i-h3.dtsi +7 -0
@@ -526,6 +526,13 @@ allwinner,pull = <SUN4I_PINCTRL_NO_PULL>; }; + uart1_pins_a: uart1@0 { + allwinner,pins = "PG6", "PG7"; + allwinner,function = "uart1"; + allwinner,drive = <SUN4I_PINCTRL_10_MA>; + allwinner,pull = <SUN4I_PINCTRL_NO_PULL>; + }; + mmc0_pins_a: mmc0@0 { allwinner,pins = "PF0", "PF1", "PF2", "PF3", "PF4", "PF5";
Signature · 1 line
1.9.1
Re: [PATCH 2/2] ARM: dts: sun8i-h3: Add UART1 pinctrl
Hi Milo,
Quoted 20 lines · Milo Kim
In H3, PA5 can be used as PWM and UART0. If the PWM is used, the console UART should be moved to other port.
This patch enables UART1 pinctrl to support this case.PA5: PWM
PG6, PG7: debug consoleCc Chen-Yu Tsai <[email protected]>Cc Maxime Ripard <[email protected]>Cc Rob Herring <[email protected]>Signed-off-by Milo Kim <[email protected]>--- arch/arm/boot/dts/sun8i-h3.dtsi | 7 +++++++ 1 file changed, 7 insertions(+)arch/arm/boot/dts/sun8i-h3.dtsi +0
-0
arch/arm/boot/dts/sun8i-h3.dtsi line 535
Quoted 10 lines
arch/arm/boot/dts/sun8i-h3.dtsi +7
-0@@ -526,6 +526,13 @@ allwinner,pull = <SUN4I_PINCTRL_NO_PULL>; }; + uart1_pins_a: uart1@0 { + allwinner,pins = "PG6", "PG7"; + allwinner,function = "uart1"; + allwinner,drive = <SUN4I_PINCTRL_10_MA>; + allwinner,pull = <SUN4I_PINCTRL_NO_PULL>; + }; +
Our policy is that we don't introduce new pinctrl nodes that are not used by any board to avoid bloating the DT too much with unused nodes.
If you have a board using it, please submit that change as well.
Thanks!
Maxime
Signature · 3 lines
Maxime Ripard, Free Electrons Embedded Linux and Kernel engineering http://free-electrons.com
Re: [PATCH 2/2] ARM: dts: sun8i-h3: Add UART1 pinctrl
Quoted 11 lines · Maxime Ripard
Quoted 7 lines
arch/arm/boot/dts/sun8i-h3.dtsi +1
-0+ uart1_pins_a: uart1@0 {arch/arm/boot/dts/sun8i-h3.dtsi line 535
Quoted 6 lines
arch/arm/boot/dts/sun8i-h3.dtsi +6
-0+ allwinner,pins = "PG6", "PG7"; + allwinner,function = "uart1"; + allwinner,drive = <SUN4I_PINCTRL_10_MA>; + allwinner,pull = <SUN4I_PINCTRL_NO_PULL>; + }; +Our policy is that we don't introduce new pinctrl nodes that are not used by any board to avoid bloating the DT too much with unused nodes.
If you have a board using it, please submit that change as well.
OK, I agree.
However, this pinmux is only useful in case PA5 is assigned for PWM.
PA5 is commonly used for UART0_RX, so I'd like to add UART1 node into *.dts and disable it (status = "disabled"). Does it make sense?
Best regards,
Milo
Re: [PATCH 2/2] ARM: dts: sun8i-h3: Add UART1 pinctrl
Hi Milo,
Quoted 11 lines · Milo Kim
Quoted 10 lines · Maxime Ripard
Quoted 7 lines
arch/arm/boot/dts/sun8i-h3.dtsi +1
-0+ uart1_pins_a: uart1@0 {arch/arm/boot/dts/sun8i-h3.dtsi line 535
Quoted 6 lines
arch/arm/boot/dts/sun8i-h3.dtsi +6
-0+ allwinner,pins = "PG6", "PG7"; + allwinner,function = "uart1"; + allwinner,drive = <SUN4I_PINCTRL_10_MA>; + allwinner,pull = <SUN4I_PINCTRL_NO_PULL>; + }; +Our policy is that we don't introduce new pinctrl nodes that are not used by any board to avoid bloating the DT too much with unused nodes.
Quoted 7 lines
Quoted 1 line
If you have a board using it, please submit that change as well.
OK, I agree.
However, this pinmux is only useful in case PA5 is assigned for PWM. PA5 is commonly used for
UART0_RX, so I'd like to add UART1 node into *.dts and disable it (status = "disabled"). Does it make sense?
I guess UART1 is either used or not used on that board. In the former case, it should be enabled, in the latter, left out of the DTS entirely.
Maxime
Signature · 3 lines
Maxime Ripard, Free Electrons Embedded Linux and Kernel engineering http://free-electrons.com
Re: [PATCH 2/2] ARM: dts: sun8i-h3: Add UART1 pinctrl
In reply to Maxime RipardHi Maxime,
Quoted 37 lines · Maxime Ripard
Hi Milo,
Quoted 20 lines · Milo Kim
In H3, PA5 can be used as PWM and UART0. If the PWM is used, the console UART should be moved to other port.
This patch enables UART1 pinctrl to support this case.PA5: PWM
PG6, PG7: debug consoleCc Chen-Yu Tsai <[email protected]>Cc Maxime Ripard <[email protected]>Cc Rob Herring <[email protected]>Signed-off-by Milo Kim <[email protected]>--- arch/arm/boot/dts/sun8i-h3.dtsi | 7 +++++++ 1 file changed, 7 insertions(+)arch/arm/boot/dts/sun8i-h3.dtsi +0
-0arch/arm/boot/dts/sun8i-h3.dtsi line 535
Quoted 10 lines
arch/arm/boot/dts/sun8i-h3.dtsi +7
-0@@ -526,6 +526,13 @@ allwinner,pull = <SUN4I_PINCTRL_NO_PULL>; }; + uart1_pins_a: uart1@0 { + allwinner,pins = "PG6", "PG7"; + allwinner,function = "uart1"; + allwinner,drive = <SUN4I_PINCTRL_10_MA>; + allwinner,pull = <SUN4I_PINCTRL_NO_PULL>; + }; +Our policy is that we don't introduce new pinctrl nodes that are not used by any board to avoid bloating the DT too much with unused nodes.
Quoted 1 line
If you have a board using it, please submit that change as well.
UART1 was already added in sun8i-h3.dtsi, so I drop this change in v2.
Commit-ID: 966c11a3b5e4
Best regards,
Milo
Hi Milo,
Remember to use get_maintainers to send your patches, you missed a few mailing lists (linux-arm-kernel, for example), developpers (Alexandre Belloni, the original author of the driver) and maintainers (Linus Walleij for the pinctrl changes).
Quoted 7 lines · Milo Kim
According to the latest datasheet (v1.2), H3 has single PWM channel. H3 PWM controller has same register layout as sun4i driver, so it works by adding H3 specific data.
And the second PWM channel is not supported, so the pinctrl function is removed.Datasheet:
http://linux-sunxi.org/File:Allwinner_H3_Datasheet_V1.2.pdf
That should be in your cover letter, but not in your commit log. A commit log is here forever, this link will very likely not.
Quoted 6 lines
Test environment:
Tested on Nano Pi M1 board, but PA5 pin is assigned for UART0. So the debug console should be changed to other port like UART1.Ex)
Quoted 9 lines
aliases {
serial0 = &uart1;
};
&uart1 {
pinctrl-names = "default";
pinctrl-0 = <&uart1_pins_a>;
status = "okay";
};That should be part of your cover letter too.
Quoted 10 lines
Cc Chen-Yu Tsai <[email protected]>Cc Maxime Ripard <[email protected]>Cc Rob Herring <[email protected]>Cc Thierry Reding <[email protected]>Signed-off-by Milo Kim <[email protected]>--- Documentation/devicetree/bindings/pwm/pwm-sun4i.txt | 1 + arch/arm/boot/dts/sun8i-h3.dtsi | 15 +++++++++++++++ drivers/pinctrl/sunxi/pinctrl-sun8i-h3.c | 1 - drivers/pwm/pwm-sun4i.c | 9 +++++++++
Please split these changes into several patches:
Quoted 19 lines
4 files changed, 25 insertions(+), 1 deletion(-)Documentation/devicetree/bindings/pwm/pwm-sun4i.txt +1
-0@@ -6,6 +6,7 @@ Required properties: - "allwinner,sun5i-a10s-pwm" - "allwinner,sun5i-a13-pwm" - "allwinner,sun7i-a20-pwm" + - "allwinner,sun8i-h3-pwm" - reg: physical base address and length of the controller's registers - #pwm-cells: should be 3. See pwm.txt in this directory for a description of the cells format.arch/arm/boot/dts/sun8i-h3.dtsi +0
-0
arch/arm/boot/dts/sun8i-h3.dtsi line 521
Quoted 10 lines
arch/arm/boot/dts/sun8i-h3.dtsi +7
-0@@ -512,6 +512,13 @@ allwinner,pull = <SUN4I_PINCTRL_NO_PULL>; }; + pwm0_pin_a: pwm0@0 { + allwinner,pins = "PA5"; + allwinner,function = "pwm0"; + allwinner,drive = <SUN4I_PINCTRL_10_MA>; + allwinner,pull = <SUN4I_PINCTRL_NO_PULL>; + }; +
One to add the new pin...
Quoted 5 lines
arch/arm/boot/dts/sun8i-h3.dtsi +0
-0uart0_pins_a: uart0@0 { allwinner,pins = "PA4", "PA5"; allwinner,function = "uart0";@@ -585,6 +592,14 @@ interrupts = <GIC_SPI 25 IRQ_TYPE_LEVEL_HIGH>;
arch/arm/boot/dts/sun8i-h3.dtsi line 602
Quoted 10 lines
arch/arm/boot/dts/sun8i-h3.dtsi +8
-0}; + pwm: pwm@01c21400 { + compatible = "allwinner,sun8i-h3-pwm"; + reg = <0x01c21400 0x8>; + clocks = <&osc24M>; + #pwm-cells = <3>; + status = "disabled"; + }; +
... one to add the controller node ...
drivers/pinctrl/sunxi/pinctrl-sun8i-h3.c static const struct sunxi_desc_pin sun8i_h3_pins[] = { · line 63
Quoted 12 lines
arch/arm/boot/dts/sun8i-h3.dtsi +0
-0uart0: serial@01c28000 { compatible = "snps,dw-apb-uart"; reg = <0x01c28000 0x400>;drivers/pinctrl/sunxi/pinctrl-sun8i-h3.c +0
-1@@ -60,7 +60,6 @@ static const struct sunxi_desc_pin sun8i_h3_pins[] = {SUNXI_FUNCTION (0x0 ,"gpio_in" ),SUNXI_FUNCTION (0x1 ,"gpio_out" ), SUNXI_FUNCTION(0x2, "sim"), /* PWREN */ - SUNXI_FUNCTION(0x3, "pwm1"),
... one to remove the pinctrl pin ...
Quoted 21 lines
drivers/pinctrl/sunxi/pinctrl-sun8i-h3.c +0
-0SUNXI_FUNCTION_IRQ_BANK(0x6, 0, 6)), /* PA_EINT6 */ SUNXI_PIN(SUNXI_PINCTRL_PIN(A, 7), SUNXI_FUNCTION(0x0, "gpio_in"),drivers/pwm/pwm-sun4i.c +6
-0@@ -284,6 +284,12 @@ static const struct sun4i_pwm_data sun4i_pwm_data_a20 = { .npwm = 2, }; +static const struct sun4i_pwm_data sun4i_pwm_data_h3 = { + .has_prescaler_bypass = true, + .has_rdy = true, + .npwm =1 , +}; +static const struct of_device_id sun4i_pwm_dt_ids[] = { { .compatible ="allwinner,sun4i-a10-pwm" ,
drivers/pwm/pwm-sun4i.c static const struct of_device_id sun4i_pwm_dt_ids[] = { · line 309
Quoted 6 lines
drivers/pwm/pwm-sun4i.c +3
-0@@ -298,6 +304,9 @@ static const struct of_device_id sun4i_pwm_dt_ids[] = { .compatible = "allwinner,sun7i-a20-pwm", .data = &sun4i_pwm_data_a20, }, { + .compatible = "allwinner,sun8i-h3-pwm", + .data = &sun4i_pwm_data_h3, + }, {
... and one to add the H3 support in the driver.
It looks good otherwise, thanks!
Maxime
Signature · 3 lines
Maxime Ripard, Free Electrons Embedded Linux and Kernel engineering http://free-electrons.com
Hi Maxime,
Quoted 4 lines · Maxime Ripard
Remember to use
get_maintainersto send your patches, you missed a few mailing lists (linux-arm-kernel, for example), developpers (Alexandre Belloni, the original author of the driver) and maintainers (Linus Walleij for the pinctrl changes).
Thanks for this tip and your review regarding splitting pinctrl patch. Let me prepare the 2nd patch-set.
Best regards,
Milo
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html