Skip to contentSkip to conversation

pinctrl: sunxi: Add H3 R_PIO controller support

PATCH Superseded Krzysztof Adamski 6 participants 26 messages Feb 2, 2016 – Feb 25, 2016

Subsystems (6)

v2 of 5 Superseded Latest is v5 →

lore
Share & tools
lore
#0 lore raw

v2 cover pinctrl: sunxi: Add H3 R_PIO controller support

This patch series is extension of my original single patch with the same subject. It adds support for R_PIO so that GPIO port L can be used in H3 based devices. It was tested on OrangePi PC where PL is connected amount others to an onboard led, a switch and IR receiver and some VCC controllers.

Patchset was based on next-20160129.

---

Changes since v1:
- splited patch to two separate - dtsi and c files
- added APB0 clocks a parent for R_PIO
- added fix in sunxi_pinctrl_gpio_get for getting pin value when in irq mode and on 2nd pinctrl
- fixed a "pwn" > "pwm" typo
- fixed order in allwinner,sunxi-pinctrl.txt

Krzysztof Adamski (5):
clk: sunxi: Add apb0 gates for H3
dts: sun8i-h3: Add APB0 related clocks and resets
pinctrl: sunxi: Add H3 R_PIO controller support
ARM: dts: sun8i-h3: Add R_PIO controller node to the dtsi
pinctrl: sunxi: Use pin number when calling sunxi_pmx_set

 Documentation/devicetree/bindings/clock/sunxi.txt  |   1 +
 .../bindings/pinctrl/allwinner,sunxi-pinctrl.txt   |   1 +
 arch/arm/boot/dts/sun8i-h3.dtsi                    |  44 +++++++++
 drivers/clk/sunxi/clk-simple-gates.c               |   2 +
 drivers/pinctrl/sunxi/Kconfig                      |   4 +
 drivers/pinctrl/sunxi/Makefile                     |   1 +
 drivers/pinctrl/sunxi/pinctrl-sun8i-h3-r.c         | 106 +++++++++++++++++++++
 drivers/pinctrl/sunxi/pinctrl-sunxi.c              |   9 +-
 8 files changed, 165 insertions(+), 3 deletions(-)
 create mode 100644 drivers/pinctrl/sunxi/pinctrl-sun8i-h3-r.c
Signature · 1 line
2.1.4
#1 lore raw

PATCH v2 1/5 clk: sunxi: Add apb0 gates for H3

This patch adds support for APB0 in H3. It seems to be compatible with earlier SOCs. apb0 gates controls R_ block peripherals (R_PIO, R_IR, etc).

---
 Documentation/devicetree/bindings/clock/sunxi.txt | 1 +
 drivers/clk/sunxi/clk-simple-gates.c              | 2 ++
 2 files changed, 3 insertions(+)
Documentation/devicetree/bindings/clock/sunxi.txt +1 -0
index e59f57b..6ee6875 100644
@@ -32,6 +32,7 @@ Required properties:
 	"allwinner,sun8i-h3-ahb2-clk" - for the AHB2 clock on H3
 	"allwinner,sun6i-a31-ahb1-gates-clk" - for the AHB1 gates on A31
 	"allwinner,sun8i-a23-ahb1-gates-clk" - for the AHB1 gates on A23
+	"allwinner,sun8i-h3-abp0-gates-clk" - for the APB0 gates on H3
 	"allwinner,sun9i-a80-ahb0-gates-clk" - for the AHB0 gates on A80
 	"allwinner,sun9i-a80-ahb1-gates-clk" - for the AHB1 gates on A80
 	"allwinner,sun9i-a80-ahb2-gates-clk" - for the AHB2 gates on A80
drivers/clk/sunxi/clk-simple-gates.c +2 -0
index f4da52b..8a1fa3e 100644
@@ -130,6 +130,8 @@ CLK_OF_DECLARE(sun8i_a23_apb2, "allwinner,sun8i-a23-apb2-gates-clk",
 	       sunxi_simple_gates_init);
 CLK_OF_DECLARE(sun8i_a33_ahb1, "allwinner,sun8i-a33-ahb1-gates-clk",
 	       sunxi_simple_gates_init);
+CLK_OF_DECLARE(sun8i_h3_abp0, "allwinner,sun8i-h3-abp0-gates-clk",
+	       sunxi_simple_gates_init);
 CLK_OF_DECLARE(sun9i_a80_ahb0, "allwinner,sun9i-a80-ahb0-gates-clk",
 	       sunxi_simple_gates_init);
 CLK_OF_DECLARE(sun9i_a80_ahb1, "allwinner,sun9i-a80-ahb1-gates-clk",
Signature · 1 line
2.1.4
#2 lore raw

Re: [PATCH v2 1/5] clk: sunxi: Add apb0 gates for H3

Quoted 15 lines · Krzysztof Adamski

This patch adds support for APB0 in H3. It seems to be compatible with earlier SOCs. apb0 gates controls R_ block peripherals (R_PIO, R_IR, etc).

---
 Documentation/devicetree/bindings/clock/sunxi.txt | 1 +
 drivers/clk/sunxi/clk-simple-gates.c              | 2 ++
 2 files changed, 3 insertions(+)
Documentation/devicetree/bindings/clock/sunxi.txt +0 -0
index e59f57b..6ee6875 100644

Documentation/devicetree/bindings/clock/sunxi.txt Required properties: · line 35

Quoted 4 lines
Documentation/devicetree/bindings/clock/sunxi.txt +1 -0
@@ -32,6 +32,7 @@ Required properties:
        "allwinner,sun8i-h3-ahb2-clk" - for the AHB2 clock on H3
        "allwinner,sun6i-a31-ahb1-gates-clk" - for the AHB1 gates on A31
        "allwinner,sun8i-a23-ahb1-gates-clk" - for the AHB1 gates on A23
+       "allwinner,sun8i-h3-abp0-gates-clk" - for the APB0 gates on H3

The list is grouped by clock type (AHB/APB/...) then family then SoC. Please put this in the apb0 section below.

ChenYu

Quoted 19 lines
Documentation/devicetree/bindings/clock/sunxi.txt +0 -0
        "allwinner,sun9i-a80-ahb0-gates-clk" - for the AHB0 gates on A80
        "allwinner,sun9i-a80-ahb1-gates-clk" - for the AHB1 gates on A80
        "allwinner,sun9i-a80-ahb2-gates-clk" - for the AHB2 gates on A80
drivers/clk/sunxi/clk-simple-gates.c +2 -1
index f4da52b..8a1fa3e 100644
@@ -130,6 +130,8 @@ CLK_OF_DECLARE(sun8i_a23_apb2, "allwinner,sun8i-a23-apb2-gates-clk",
               sunxi_simple_gates_init);
 CLK_OF_DECLARE(sun8i_a33_ahb1, "allwinner,sun8i-a33-ahb1-gates-clk",
               sunxi_simple_gates_init);
+CLK_OF_DECLARE(sun8i_h3_abp0, "allwinner,sun8i-h3-abp0-gates-clk",
+              sunxi_simple_gates_init);
 CLK_OF_DECLARE(sun9i_a80_ahb0, "allwinner,sun9i-a80-ahb0-gates-clk",
               sunxi_simple_gates_init);
 CLK_OF_DECLARE(sun9i_a80_ahb1, "allwinner,sun9i-a80-ahb1-gates-clk",
--

2.1.4

#3 lore raw

PATCH v2 2/5 dts: sun8i-h3: Add APB0 related clocks and resets

In reply to Krzysztof Adamski

APB0 is bearly mentioned in H3 User Manual and it is only setup in the Allwinners kernel dump for CIR. I have verified experimentally that the gate for R_PIO exists and works, though. There are probably other gates there but I don't know their order right now and I don't have access to their peripherals on my board to test them.

---
 arch/arm/boot/dts/sun8i-h3.dtsi | 32 ++++++++++++++++++++++++++++++++
 1 file changed, 32 insertions(+)
arch/arm/boot/dts/sun8i-h3.dtsi +32 -0
index 1524130e..ce35e93 100644
@@ -276,6 +276,32 @@
 			clocks = <&osc24M>, <&pll6 1>, <&pll5>;
 			clock-output-names = "mbus";
 		};
+
+		ahb0: ahb0_clk {
+			compatible = "fixed-factor-clock";
+			#clock-cells = <0>;
+			clock-div = <1>;
+			clock-mult = <1>;
+			clocks = <&osc24M>, <&osc32k>;
+			clock-output-names = "ahb0";
+		};
+
+		apb0: clk at 01f0140c {
+			compatible = "allwinner,sun8i-a23-apb0-clk";
+			reg = <0x01f0140c 0x4>;
+			#clock-cells = <0>;
+			clocks = <&ahb0>;
+			clock-output-names = "apb0";
+		};
+
+		apb0_gates: clk at 01f01428 {
+			compatible = "allwinner,sun8i-h3-abp0-gates-clk";
+			reg = <0x01f01428 0x4>;
+			#clock-cells = <1>;
+			clocks = <&apb0>;
+			clock-indices = <0>, <1>;
+			clock-output-names = "apb0_pio", "apb0_ir";
+		};
 	};
 
 	soc {
@@ -493,5 +519,11 @@
 			interrupts = <GIC_SPI 40 IRQ_TYPE_LEVEL_HIGH>,
 				     <GIC_SPI 41 IRQ_TYPE_LEVEL_HIGH>;
 		};
+
+		apb0_reset: reset at 01f014b0 {
+			reg = <0x01f014b0 0x4>;
+			compatible = "allwinner,sun6i-a31-clock-reset";
+			#reset-cells = <1>;
+		};
 	};
 };
Signature · 1 line
2.1.4
#4 lore raw

Re: [PATCH v2 2/5] dts: sun8i-h3: Add APB0 related clocks and resets

Hi,

Quoted 18 lines · Krzysztof Adamski

APB0 is bearly mentioned in H3 User Manual and it is only setup in the Allwinners kernel dump for CIR. I have verified experimentally that the gate for R_PIO exists and works, though. There are probably other gates there but I don't know their order right now and I don't have access to their peripherals on my board to test them.

---
 arch/arm/boot/dts/sun8i-h3.dtsi | 32 ++++++++++++++++++++++++++++++++
 1 file changed, 32 insertions(+)
arch/arm/boot/dts/sun8i-h3.dtsi +0 -0
index 1524130e..ce35e93 100644
@@ -276,6 +276,32 @@
 			clocks = <&osc24M>, <&pll6 1>, <&pll5>;
 			clock-output-names = "mbus";

arch/arm/boot/dts/sun8i-h3.dtsi line 287

Quoted 10 lines
arch/arm/boot/dts/sun8i-h3.dtsi +9 -0
 		};
+
+		ahb0: ahb0_clk {
+			compatible = "fixed-factor-clock";
+			#clock-cells = <0>;
+			clock-div = <1>;
+			clock-mult = <1>;
+			clocks = <&osc24M>, <&osc32k>;
+			clock-output-names = "ahb0";
+		};

I'm not sure what you mean there. The fixed factor clocks only take a single parent, and you provided two.

Maxime

Signature · 10 lines
Maxime Ripard, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20160203/1086294a/attachment.sig>
#5 lore raw

Re: [PATCH v2 2/5] dts: sun8i-h3: Add APB0 related clocks and resets

Quoted 26 lines · Maxime Ripard

Hi,

Quoted 23 lines · Krzysztof Adamski

APB0 is bearly mentioned in H3 User Manual and it is only setup in the Allwinners kernel dump for CIR. I have verified experimentally that the gate for R_PIO exists and works, though. There are probably other gates there but I don't know their order right now and I don't have access to their peripherals on my board to test them.

---
 arch/arm/boot/dts/sun8i-h3.dtsi | 32 ++++++++++++++++++++++++++++++++
 1 file changed, 32 insertions(+)
arch/arm/boot/dts/sun8i-h3.dtsi +4 -0
index 1524130e..ce35e93 100644
@@ -276,6 +276,32 @@
 			clocks = <&osc24M>, <&pll6 1>, <&pll5>;
 			clock-output-names = "mbus";
 		};
+
+		ahb0: ahb0_clk {
+			compatible = "fixed-factor-clock";
+			#clock-cells = <0>;
Quoted 8 lines

arch/arm/boot/dts/sun8i-h3.dtsi line 287

Quoted 5 lines
arch/arm/boot/dts/sun8i-h3.dtsi +5 -0
+			clock-div = <1>;
+			clock-mult = <1>;
+			clocks = <&osc24M>, <&osc32k>;
+			clock-output-names = "ahb0";
+		};

I'm not sure what you mean there. The fixed factor clocks only take a single parent, and you provided two.

True, I that's actually some stupid leftover. As mentioned in the commit message I didn't really know how the clock tree looks like here so I wanted to just pretend it's connectet to osc24M. After some experiments I think that 0x01f0140c register does not exist on H3 and I was finally (hopefully) able to understand how this clock is set up in Allwinner's code. So I changed the clock to factors clock with possible osc32k and osc24M parrents. Will send it in v3.

#6 lore raw

Re: [PATCH v2 2/5] dts: sun8i-h3: Add APB0 related clocks and resets

Quoted 6 lines · Krzysztof Adamski
Quoted 4 lines · Maxime Ripard

Hi,

I'm not sure what you mean there. The fixed factor clocks only take a single parent, and you provided two.

Quoted 7 lines

True, I that's actually some stupid leftover. As mentioned in the commit message I didn't really know how the clock tree looks like here so I wanted to just pretend it's connectet to osc24M. After some experiments I think that 0x01f0140c register does not exist on H3 and I was finally (hopefully) able to understand how this clock is set up in Allwinner's code. So I changed the clock to factors clock with possible osc32k and osc24M parrents. Will send it in v3.

I've changed my mind about using factors clock. The clock I was thinking about is only setup for CIR peripheral and I have no information on how r_pio is clocked other than the fact it works by default so I assume it's clocked from 24M oscillator. New patchset send, let me know what you think.

#7 lore raw

PATCH v2 3/5 pinctrl: sunxi: Add H3 R_PIO controller support

In reply to Krzysztof Adamski

H3 has additional PIO controller similar to what we can find on A23. It's a 12 pin port, described in H3 Datasheet rev 1.1, pages 345-350.

---
 drivers/pinctrl/sunxi/Kconfig              |   4 ++
 drivers/pinctrl/sunxi/Makefile             |   1 +
 drivers/pinctrl/sunxi/pinctrl-sun8i-h3-r.c | 106 +++++++++++++++++++++++++++++
 3 files changed, 111 insertions(+)
 create mode 100644 drivers/pinctrl/sunxi/pinctrl-sun8i-h3-r.c
drivers/pinctrl/sunxi/Kconfig +4 -0
index f8dbc8b..75a26c9 100644
@@ -55,6 +55,10 @@ config PINCTRL_SUN8I_H3
 	def_bool MACH_SUN8I
 	select PINCTRL_SUNXI_COMMON
 
+config PINCTRL_SUN8I_H3_R
+	def_bool MACH_SUN8I
+	select PINCTRL_SUNXI_COMMON
+
 config PINCTRL_SUN9I_A80
 	def_bool MACH_SUN9I
 	select PINCTRL_SUNXI_COMMON
drivers/pinctrl/sunxi/Makefile +1 -0
index ef82f22..a5d56f1 100644
@@ -14,5 +14,6 @@ obj-$(CONFIG_PINCTRL_SUN8I_A23_R)	+= pinctrl-sun8i-a23-r.o
 obj-$(CONFIG_PINCTRL_SUN8I_A33)		+= pinctrl-sun8i-a33.o
 obj-$(CONFIG_PINCTRL_SUN8I_A83T)	+= pinctrl-sun8i-a83t.o
 obj-$(CONFIG_PINCTRL_SUN8I_H3)		+= pinctrl-sun8i-h3.o
+obj-$(CONFIG_PINCTRL_SUN8I_H3_R)	+= pinctrl-sun8i-h3-r.o
 obj-$(CONFIG_PINCTRL_SUN9I_A80)		+= pinctrl-sun9i-a80.o
 obj-$(CONFIG_PINCTRL_SUN9I_A80_R)	+= pinctrl-sun9i-a80-r.o
drivers/pinctrl/sunxi/pinctrl-sun8i-h3-r.c new file +106 -0

106 lines not on this page · raw message

Signature · 1 line
2.1.4
Acked-by on v2 3/5
#8 lore raw
Quoted 4 lines · Krzysztof Adamski

H3 has additional PIO controller similar to what we can find on A23. It's a 12 pin port, described in H3 Datasheet rev 1.1, pages 345-350.

Thanks!
Maxime

Signature · 10 lines
Maxime Ripard, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20160203/79ba258a/attachment.sig>
#10 lore raw
Quoted 8 lines · Linus Walleij
Quoted 4 lines · Krzysztof Adamski

H3 has additional PIO controller similar to what we can find on A23. It's a 12 pin port, described in H3 Datasheet rev 1.1, pages 345-350.

Patch applied with Maxime's ACK.

Hi Linus,

You took v2 which does not add documentation for allwinner,sun8i-h3-r-pinctrl compatible that is added in this patch. This was fixed in v3. Should I prepare a patch for you that only adds this to the documentation or you can handle this by taking v3/v4 instead of this patch?

Best regards,
Krzysztof Adamski

#11 lore raw
Quoted 13 lines · Krzysztof Adamski
Quoted 10 lines · Linus Walleij
Quoted 4 lines · Krzysztof Adamski

H3 has additional PIO controller similar to what we can find on A23. It's a 12 pin port, described in H3 Datasheet rev 1.1, pages 345-350.

Patch applied with Maxime's ACK.

Quoted 6 lines

Hi Linus,

You took v2 which does not add documentation for allwinner,sun8i-h3-r-pinctrl compatible that is added in this patch. This was fixed in v3. Should I prepare a patch for you that only adds this to the documentation or you can handle this by taking v3/v4 instead of this patch?

Ooops please send a fixup patch, I don't like to rebase the tree if possible. Sorry for the mess and thanks for your help.

Yours,
Linus Walleij

#12 lore raw

PATCH 1/1 clk: sunxi: Add missing H3 apb0 clock documentation

allwinner,sun8i-h3-apb0-gates-clk was added by
commit ba83a11104ae ("pinctrl: sunxi: Add H3 R_PIO controller support") but the patch was missing proper binding documentation. This patch fixes this issue.

---
 Documentation/devicetree/bindings/clock/sunxi.txt | 1 +
 1 file changed, 1 insertion(+)
Documentation/devicetree/bindings/clock/sunxi.txt +1 -0
index c09f59b..37d0fd6 100644
@@ -38,6 +38,7 @@ Required properties:
 	"allwinner,sun4i-a10-apb0-clk" - for the APB0 clock
 	"allwinner,sun6i-a31-apb0-clk" - for the APB0 clock on A31
 	"allwinner,sun8i-a23-apb0-clk" - for the APB0 clock on A23
+	"allwinner,sun8i-h3-apb0-gates-clk" - for the APB0 gates on H3
 	"allwinner,sun9i-a80-apb0-clk" - for the APB0 bus clock on A80
 	"allwinner,sun8i-a83t-apb0-gates-clk" - for the APB0 gates on A83T
 	"allwinner,sun4i-a10-apb0-gates-clk" - for the APB0 gates on A10
Signature · 1 line
2.1.4
#13 lore raw

Re: [PATCH] clk: sunxi: Add missing H3 apb0 clock documentation

Quoted 4 lines · Krzysztof Adamski

allwinner,sun8i-h3-apb0-gates-clk was added by
commit ba83a11104ae ("pinctrl: sunxi: Add H3 R_PIO controller support") but the patch was missing proper binding documentation. This patch fixes this issue.

What are you talking about? The commit you mentioned only adds the pinctrl driver. Your H3 PRCM related clock and reset patches are still pending. No need for this patch as your earlier patches includes this.

ChenYu

Quoted 21 lines
---
 Documentation/devicetree/bindings/clock/sunxi.txt | 1 +
 1 file changed, 1 insertion(+)
Documentation/devicetree/bindings/clock/sunxi.txt +1 -1
index c09f59b..37d0fd6 100644
@@ -38,6 +38,7 @@ Required properties:
        "allwinner,sun4i-a10-apb0-clk" - for the APB0 clock
        "allwinner,sun6i-a31-apb0-clk" - for the APB0 clock on A31
        "allwinner,sun8i-a23-apb0-clk" - for the APB0 clock on A23
+       "allwinner,sun8i-h3-apb0-gates-clk" - for the APB0 gates on H3
        "allwinner,sun9i-a80-apb0-clk" - for the APB0 bus clock on A80
        "allwinner,sun8i-a83t-apb0-gates-clk" - for the APB0 gates on A83T
        "allwinner,sun4i-a10-apb0-gates-clk" - for the APB0 gates on A10
--

2.1.4

#14 lore raw

Re: [linux-sunxi] Re: [PATCH] clk: sunxi: Add missing H3 apb0 clock documentation

Quoted 10 lines · Chen-Yu Tsai
Quoted 4 lines · Krzysztof Adamski

allwinner,sun8i-h3-apb0-gates-clk was added by
commit ba83a11104ae ("pinctrl: sunxi: Add H3 R_PIO controller support") but the patch was missing proper binding documentation. This patch fixes this issue.

What are you talking about? The commit you mentioned only adds the pinctrl driver. Your H3 PRCM related clock and reset patches are still pending. No need for this patch as your earlier patches includes this.

Damn, I messed up patches, I must have been tired or something. It was documentation for "allwinner,sun8i-h3-r-pinctrl" that was missing. I'm sending a new patch. Sorry for confusion.

Best regards,
Krzysztof Adamski

#15 lore raw

PATCH 1/1 pinctrl: sunxi: Add missing H3 R_PIO binding documentation

In reply to Linus Walleij

allwinner,sun8i-h3-r-pinctrl was added by
commit ba83a11104ae ("pinctrl: sunxi: Add H3 R_PIO controller support") but the patch was missing proper binding documentation. This patch fixes this issue.

---
 Documentation/devicetree/bindings/pinctrl/allwinner,sunxi-pinctrl.txt | 1 +
 1 file changed, 1 insertion(+)
Documentation/devicetree/bindings/pinctrl/allwinner,sunxi-pinctrl.txt +1 -0
index 9213b27..3e56b16 100644
@@ -21,6 +21,7 @@ Required properties:
   "allwinner,sun9i-a80-r-pinctrl"
   "allwinner,sun8i-a83t-pinctrl"
   "allwinner,sun8i-h3-pinctrl"
+  "allwinner,sun8i-h3-r-pinctrl"
 
 - reg: Should contain the register physical address and length for the
   pin controller.
Signature · 1 line
2.1.4
Acked-by on v1 1/1
#16 lore raw

Re: [PATCH] pinctrl: sunxi: Add missing H3 R_PIO binding documentation

Quoted 6 lines · Krzysztof Adamski

allwinner,sun8i-h3-r-pinctrl was added by
commit ba83a11104ae ("pinctrl: sunxi: Add H3 R_PIO controller support") but the patch was missing proper binding documentation. This patch fixes this issue.

#17 lore raw

Re: [PATCH] pinctrl: sunxi: Add missing H3 R_PIO binding documentation

In reply to Krzysztof Adamski
Quoted 6 lines · Krzysztof Adamski

allwinner,sun8i-h3-r-pinctrl was added by
commit ba83a11104ae ("pinctrl: sunxi: Add H3 R_PIO controller support") but the patch was missing proper binding documentation. This patch fixes this issue.

Patch applied with Chen-Yu's ACK.

Yours,
Linus Walleij

#18 lore raw

PATCH v2 4/5 ARM: dts: sun8i-h3: Add R_PIO controller node to the dtsi

In reply to Krzysztof Adamski

Add the corresponding device node for R_PIO on H3 to the dtsi. Support for the controller was added in earlier commit.

---
 .../devicetree/bindings/pinctrl/allwinner,sunxi-pinctrl.txt  |  1 +
 arch/arm/boot/dts/sun8i-h3.dtsi                              | 12 ++++++++++++
 2 files changed, 13 insertions(+)
Documentation/devicetree/bindings/pinctrl/allwinner,sunxi-pinctrl.txt +1 -0
index 9213b27..3e56b16 100644
@@ -21,6 +21,7 @@ Required properties:
   "allwinner,sun9i-a80-r-pinctrl"
   "allwinner,sun8i-a83t-pinctrl"
   "allwinner,sun8i-h3-pinctrl"
+  "allwinner,sun8i-h3-r-pinctrl"
 
 - reg: Should contain the register physical address and length for the
   pin controller.
arch/arm/boot/dts/sun8i-h3.dtsi +12 -0
index ce35e93..1593e2d 100644
@@ -525,5 +525,17 @@
 			compatible = "allwinner,sun6i-a31-clock-reset";
 			#reset-cells = <1>;
 		};
+
+		r_pio: pinctrl at 01f02c00 {
+			compatible = "allwinner,sun8i-h3-r-pinctrl";
+			reg = <0x01f02c00 0x400>;
+			interrupts = <GIC_SPI 45 IRQ_TYPE_LEVEL_HIGH>;
+			clocks = <&apb0_gates 0>;
+			resets = <&apb0_reset 0>;
+			gpio-controller;
+			#gpio-cells = <3>;
+			interrupt-controller;
+			#interrupt-cells = <2>;
+		};
 	};
 };
Signature · 1 line
2.1.4
#19 lore raw

Re: [linux-sunxi] [PATCH v2 4/5] ARM: dts: sun8i-h3: Add R_PIO controller node to the dtsi

Hi Krzysztof,

Quoted 14 lines · Krzysztof Adamski

Add the corresponding device node for R_PIO on H3 to the dtsi. Support for the controller was added in earlier commit.

---
 .../devicetree/bindings/pinctrl/allwinner,sunxi-pinctrl.txt  |  1 +
 arch/arm/boot/dts/sun8i-h3.dtsi                              | 12 ++++++++++++
 2 files changed, 13 insertions(+)
Documentation/devicetree/bindings/pinctrl/allwinner,sunxi-pinctrl.txt +0 -0
index 9213b27..3e56b16 100644

Documentation/devicetree/bindings/pinctrl/allwinner,sunxi-pinctrl.txt Required properties: · line 24

Quoted 4 lines
Documentation/devicetree/bindings/pinctrl/allwinner,sunxi-pinctrl.txt +1 -0
@@ -21,6 +21,7 @@ Required properties:
   "allwinner,sun9i-a80-r-pinctrl"
   "allwinner,sun8i-a83t-pinctrl"
   "allwinner,sun8i-h3-pinctrl"
+  "allwinner,sun8i-h3-r-pinctrl"

Shouldn't this change go in the patch that introduces the driver for this pinctl?

Thanks,

Signature · 4 lines
Julian Calaby

Email: julian.calaby at gmail.com
Profile: http://www.google.com/profiles/julian.calaby/
#20 lore raw

PATCH v2 5/5 pinctrl: sunxi: Use pin number when calling sunxi_pmx_set

In reply to Krzysztof Adamski

sunxi_pmx_set accepts pin number and then calculates offset by subtracting pin_base from it. sunxi_pinctrl_gpio_get, on the other hand, gets offset so we have to convert it to pin number so we won't get negative value in sunxi_pmx_set.

This was only used on A10 so far, where there is only one GPIO chip with pin_base set to 0 so it didn't matter. However H3 also requires this workaround but have two pinmux sections, triggering problem for PL port.

---
 drivers/pinctrl/sunxi/pinctrl-sunxi.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)
drivers/pinctrl/sunxi/pinctrl-sunxi.c +6 -3
index 7a2465f..9e5bac9 100644
@@ -460,14 +460,17 @@ static int sunxi_pinctrl_gpio_get(struct gpio_chip *chip, unsigned offset)
 	u32 set_mux = pctl->desc->irq_read_needs_mux &&
 			test_bit(FLAG_USED_AS_IRQ, &chip->desc[offset].flags);
 	u32 val;
+	u32 pin;
 
-	if (set_mux)
-		sunxi_pmx_set(pctl->pctl_dev, offset, SUN4I_FUNC_INPUT);
+	if (set_mux) {
+		pin = offset + pctl->desc->pin_base;
+		sunxi_pmx_set(pctl->pctl_dev, pin, SUN4I_FUNC_INPUT);
+	}
 
 	val = (readl(pctl->membase + reg) >> index) & DATA_PINS_MASK;
 
 	if (set_mux)
-		sunxi_pmx_set(pctl->pctl_dev, offset, SUN4I_FUNC_IRQ);
+		sunxi_pmx_set(pctl->pctl_dev, pin, SUN4I_FUNC_IRQ);
 
 	return !!val;
 }
Signature · 1 line
2.1.4
#21 lore raw

Re: [PATCH v2 5/5] pinctrl: sunxi: Use pin number when calling sunxi_pmx_set

Hi,

Quoted 19 lines · Krzysztof Adamski

sunxi_pmx_set accepts pin number and then calculates offset by subtracting pin_base from it. sunxi_pinctrl_gpio_get, on the other hand, gets offset so we have to convert it to pin number so we won't get negative value in sunxi_pmx_set.

This was only used on A10 so far, where there is only one GPIO chip with pin_base set to 0 so it didn't matter. However H3 also requires this workaround but have two pinmux sections, triggering problem for PL port.

---
 drivers/pinctrl/sunxi/pinctrl-sunxi.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)
drivers/pinctrl/sunxi/pinctrl-sunxi.c +0 -0
index 7a2465f..9e5bac9 100644

drivers/pinctrl/sunxi/pinctrl-sunxi.c static int sunxi_pinctrl_gpio_get(struct gpio_chip *chip, unsigned offset) · line 466

Quoted 9 lines
drivers/pinctrl/sunxi/pinctrl-sunxi.c +3 -2
@@ -460,14 +460,17 @@ static int sunxi_pinctrl_gpio_get(struct gpio_chip *chip, unsigned offset)
        u32 set_mux = pctl->desc->irq_read_needs_mux &&
                        test_bit(FLAG_USED_AS_IRQ, &chip->desc[offset].flags);
        u32 val;
+       u32 pin;
 
-       if (set_mux)
-               sunxi_pmx_set(pctl->pctl_dev, offset, SUN4I_FUNC_INPUT);
+       if (set_mux) {
+               pin = offset + pctl->desc->pin_base;

You can use chip->base directly. It's value is set to pin_base in the init function.
You could also move this out of the if block, and not add the braces.

Otherwise this looks good.

ChenYu

Quoted 14 lines
drivers/pinctrl/sunxi/pinctrl-sunxi.c +3 -2
+               sunxi_pmx_set(pctl->pctl_dev, pin, SUN4I_FUNC_INPUT);
+       }
 
        val = (readl(pctl->membase + reg) >> index) & DATA_PINS_MASK;
 
        if (set_mux)
-               sunxi_pmx_set(pctl->pctl_dev, offset, SUN4I_FUNC_IRQ);
+               sunxi_pmx_set(pctl->pctl_dev, pin, SUN4I_FUNC_IRQ);
 
        return !!val;
 }
--

2.1.4

#22 lore raw

Re: [PATCH v2 5/5] pinctrl: sunxi: Use pin number when calling sunxi_pmx_set

In reply to Krzysztof Adamski
Quoted 10 lines · Krzysztof Adamski

sunxi_pmx_set accepts pin number and then calculates offset by subtracting pin_base from it. sunxi_pinctrl_gpio_get, on the other hand, gets offset so we have to convert it to pin number so we won't get negative value in sunxi_pmx_set.

This was only used on A10 so far, where there is only one GPIO chip with pin_base set to 0 so it didn't matter. However H3 also requires this workaround but have two pinmux sections, triggering problem for PL port.

Waiting for Maxime to review this. I guess this patch can be merged independently of the other patches?

Yours,
Linus Walleij

#23 lore raw

Re: [linux-sunxi] Re: [PATCH v2 5/5] pinctrl: sunxi: Use pin number when calling sunxi_pmx_set

Quoted 7 lines · Linus Walleij
Quoted 5 lines · Krzysztof Adamski

sunxi_pmx_set accepts pin number and then calculates offset by subtracting pin_base from it. sunxi_pinctrl_gpio_get, on the other hand, gets offset so we have to convert it to pin number so we won't get negative value in sunxi_pmx_set.

Quoted 8 lines
Quoted 5 lines

This was only used on A10 so far, where there is only one GPIO chip with pin_base set to 0 so it didn't matter. However H3 also requires this workaround but have two pinmux sections, triggering problem for PL port.

Waiting for Maxime to review this. I guess this patch can be merged independently of the other patches?

Yes it can but it won't have any effect, as stated in the commit message, since other SoCs either don't use this flag or have only one port so theri pin_base=0.

Best regards,
Krzysztof Adamski

#24 lore raw

Re: [linux-sunxi] Re: [PATCH v2 5/5] pinctrl: sunxi: Use pin number when calling sunxi_pmx_set

Quoted 16 lines · Krzysztof Adamski
Quoted 15 lines · Linus Walleij
Quoted 10 lines · Krzysztof Adamski

sunxi_pmx_set accepts pin number and then calculates offset by subtracting pin_base from it. sunxi_pinctrl_gpio_get, on the other hand, gets offset so we have to convert it to pin number so we won't get negative value in sunxi_pmx_set.

This was only used on A10 so far, where there is only one GPIO chip with pin_base set to 0 so it didn't matter. However H3 also requires this workaround but have two pinmux sections, triggering problem for PL port.

Quoted 6 lines
Quoted 2 lines

Waiting for Maxime to review this. I guess this patch can be merged independently of the other patches?

Yes it can but it won't have any effect, as stated in the commit message, since other SoCs either don't use this flag or have only one port so theri pin_base=0.

Who cares as long as it will be used eventually.

Merged v4 as stated earlier.

Yours,
Linus Walleij

#25 lore raw

Re: [PATCH v2 5/5] pinctrl: sunxi: Use pin number when calling sunxi_pmx_set

In reply to Linus Walleij

Hi,

Quoted 7 lines · Linus Walleij
Quoted 5 lines · Krzysztof Adamski

sunxi_pmx_set accepts pin number and then calculates offset by subtracting pin_base from it. sunxi_pinctrl_gpio_get, on the other hand, gets offset so we have to convert it to pin number so we won't get negative value in sunxi_pmx_set.

Quoted 8 lines
Quoted 5 lines

This was only used on A10 so far, where there is only one GPIO chip with pin_base set to 0 so it didn't matter. However H3 also requires this workaround but have two pinmux sections, triggering problem for PL port.

Waiting for Maxime to review this. I guess this patch can be merged independently of the other patches?

FYI there's a v4 of this patch that both Maxime and I acked.

ChenYu