Skip to contentSkip to conversation

ARM: dts: da850: use gpio-ranges

PATCH Applied David Lechner 3 participants 5 messages Feb 19, 2018 – Apr 16, 2018 Device tree bindings

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ARM: dts: da850: use gpio-ranges

This makes use of the gpio-ranges feature that connects GPIO controllers and PINMUX controllers.

In da850.dtsi, pinctrl-single,gpio-range is added to the pinmux node and gpio-ranges is added to the GPIO node. Unfortunately, the way the pinctrl-single driver enumerates the pins (starting with LSB) causes them to be in reverse order compared to the way the gpios are assigned. As a result, we have to declare the mapping for each GPIO individually.

This also lets us remove all of the GPIO pinmuxes from da850-lego-ev3.dts. (Other da850 boards do not currently have any GPIO pinmuxes declared.)

---

There are a couple of dependencies needed for this to actually work.

- "gpio: davinci: add support for pinmux gpio ranges" [1]
- "pinctrl: pinctrl-single: Fix pcs_request_gpio() when bits_per_mux != 0" [2]

[1]: https://git.kernel.org/pub/scm/linux/kernel/git/linusw/linux-gpio.git/commit/?h=for-next&id=3c87d7c874b2119c1cff4eee5586b9a6bc0b7fe9
[2]: https://patchwork.kernel.org/patch/10229139/

 arch/arm/boot/dts/da850-lego-ev3.dts |  81 +-----------------
 arch/arm/boot/dts/da850.dtsi         | 154 +++++++++++++++++++++++++++++++++++
 2 files changed, 158 insertions(+), 77 deletions(-)
arch/arm/boot/dts/da850-lego-ev3.dts +4 -77
index fa21add..401d808 100644
@@ -37,7 +37,7 @@
 		#size-cells = <0>;
 		label = "EV3 Brick Buttons";
 		pinctrl-names = "default";
-		pinctrl-0 = <&button_pins>, <&button_bias>;
+		pinctrl-0 = <&button_bias>;
 
 		center {
 			label = "Center";
@@ -81,8 +81,6 @@
 	 */
 	leds {
 		compatible = "gpio-leds";
-		pinctrl-names = "default";
-		pinctrl-0 = <&led_pins>;
 
 		left_green {
 			label = "led0:green:brick-status";
@@ -119,8 +117,6 @@
 	gpio-poweroff {
 		compatible = "gpio-poweroff";
 		gpios = <&gpio 107 GPIO_ACTIVE_LOW>;
-		pinctrl-names = "default";
-		pinctrl-0 = <&system_power_pin>;
 	};
 
 	sound {
@@ -145,8 +141,6 @@
 	 * the sensor (input) ports, the motor (output) ports and the A/DC.
 	 */
 	vcc5v: regulator1 {
-		pinctrl-names = "default";
-		pinctrl-0 = <&vcc5v_pins>;
 		compatible = "regulator-fixed";
 		regulator-name = "vcc5v";
 		regulator-min-microvolt = <5000000>;
@@ -174,8 +168,6 @@
 	 * This is the amplifier for the speaker.
 	 */
 	amp: regulator3 {
-		pinctrl-names = "default";
-		pinctrl-0 = <&amp_pins>;
 		compatible = "regulator-fixed";
 		regulator-name = "amp";
 		gpio = <&gpio 111 GPIO_ACTIVE_HIGH>;
@@ -186,8 +178,6 @@
 	 * The EV3 can use 6-AA batteries or a rechargeable Li-ion battery pack.
 	 */
 	battery {
-		pinctrl-names = "default";
-		pinctrl-0 = <&battery_pins>;
 		compatible = "lego,ev3-battery";
 		io-channels = <&adc 4>, <&adc 3>;
 		io-channel-names = "voltage", "current";
@@ -223,73 +213,10 @@
 &pmx_core {
 	status = "okay";
 
-	mmc0_cd_pin: pinmux_mmc0_cd {
-		pinctrl-single,bits = <
-			/* GP5[14] */
-			0x2C 0x00000080 0x000000f0
-		>;
-	};
-
-	button_pins: pinmux_button_pins {
-		pinctrl-single,bits = <
-			/* GP1[13] */
-			0x8 0x00000800 0x00000f00
-			/* GP6[10] */
-			0x34 0x00800000 0x00f00000
-			/* GP6[6] */
-			0x38 0x00000080 0x000000f0
-			/* GP7[12], GP7[14], GP7[15] */
-			0x40 0x00808800 0x00f0ff00
-		>;
-	};
-
-	led_pins: pinmux_led_pins {
-		pinctrl-single,bits = <
-			/* GP6[12], GP6[13], GP6[14] */
-			0x34 0x00008880 0x0000fff0
-			/* GP6[7] */
-			0x38 0x00000008 0x0000000f
-		>;
-	};
-
-	system_power_pin: pinmux_system_power {
-		pinctrl-single,bits = <
-			/* GP6[11] */
-			0x34 0x00080000 0x000f0000
-		>;
-	};
-
-	vcc5v_pins: pinmux_vcc5v {
-		pinctrl-single,bits = <
-			/* GP6[5] */
-			0x40 0x00000080 0x000000f0
-			/* GP6[3] */
-			0x4c 0x00008000 0x0000f000
-		>;
-	};
-
-	amp_pins: pinmux_amp_pins {
-		pinctrl-single,bits = <
-			/* GP6[15] */
-			0x34 0x00000008 0x0000000f
-		>;
-	};
-
-	battery_pins: pinmux_battery_pins {
-		pinctrl-single,bits = <
-			/* GP0[6] */
-			0x04 0x00000080 0x000000f0
-			/* GP8[8] */
-			0x4c 0x00000080 0x000000f0
-		>;
-	};
-
 	ev3_lcd_pins: pinmux_lcd {
 		pinctrl-single,bits = <
-			/* SIMO, GP2[11], GP2[12], CLK */
-			0x14 0x00188100 0x00ffff00
-			/* GP5[0] */
-			0x30 0x80000000 0xf0000000
+			/* SIMO, CLK */
+			0x14 0x00100100 0x00f00f00
 		>;
 	};
 };
@@ -344,7 +271,7 @@
 	bus-width = <4>;
 	cd-gpios = <&gpio 94 GPIO_ACTIVE_LOW>;
 	pinctrl-names = "default";
-	pinctrl-0 = <&mmc0_pins>, <&mmc0_cd_pin>;
+	pinctrl-0 = <&mmc0_pins>;
 };
 
 &spi0 {
arch/arm/boot/dts/da850.dtsi +154 -0

168 lines not on this page · raw message

Signature · 1 line
2.7.4
Acked-by on v1 1/1
#1 lore raw
Quoted 9 lines · David Lechner

This makes use of the gpio-ranges feature that connects GPIO controllers and PINMUX controllers.

In da850.dtsi, pinctrl-single,gpio-range is added to the pinmux node and gpio-ranges is added to the GPIO node. Unfortunately, the way the pinctrl-single driver enumerates the pins (starting with LSB) causes them to be in reverse order compared to the way the gpios are assigned. As a result, we have to declare the mapping for each GPIO individually.

Quoted 5 lines

This also lets us remove all of the GPIO pinmuxes from da850-lego-ev3.dts. (Other da850 boards do not currently have any GPIO pinmuxes declared.)

Nice,

Quoted 6 lines
arch/arm/boot/dts/da850.dtsi +6 -0
+                       gpio-ranges = <&pmx_core   0  15 1>,
+                                     <&pmx_core   1  14 1>,
+                                     <&pmx_core   2  13 1>,
+                                     <&pmx_core   3  12 1>,
+                                     <&pmx_core   4  11 1>,
+                                     <&pmx_core   5  10 1>,

arch/arm/boot/dts/da850.dtsi line 767

Quoted 10 lines
arch/arm/boot/dts/da850.dtsi +10 -0
+                                     <&pmx_core   6   9 1>,
+                                     <&pmx_core   7   8 1>,
+                                     <&pmx_core   8   7 1>,
+                                     <&pmx_core   9   6 1>,
+                                     <&pmx_core  10   5 1>,
+                                     <&pmx_core  11   4 1>,
+                                     <&pmx_core  12   3 1>,
+                                     <&pmx_core  13   2 1>,
+                                     <&pmx_core  14   1 1>,
+                                     <&pmx_core  15   0 1>,

Heh the map moves backward how funny.

Sorry that we don't have an option to map that
any better in the ranges but hey, this works.

Yours,
Linus Walleij

#2 lore raw
Quoted 11 lines · Linus Walleij
Quoted 9 lines · David Lechner

This makes use of the gpio-ranges feature that connects GPIO controllers and PINMUX controllers.

In da850.dtsi, pinctrl-single,gpio-range is added to the pinmux node and gpio-ranges is added to the GPIO node. Unfortunately, the way the pinctrl-single driver enumerates the pins (starting with LSB) causes them to be in reverse order compared to the way the gpios are assigned. As a result, we have to declare the mapping for each GPIO individually.

Quoted 8 lines
Quoted 5 lines

This also lets us remove all of the GPIO pinmuxes from da850-lego-ev3.dts. (Other da850 boards do not currently have any GPIO pinmuxes declared.)

Nice,

Looks good to me too. And quite painstakingly done!

I suppose this needs to wait a bit due to the dependencies? Let me know once its okay to merge.

Thanks,
Sekhar

#3 lore raw
Quoted 21 lines · Sekhar Nori
Quoted 11 lines · Linus Walleij
Quoted 9 lines · David Lechner

This makes use of the gpio-ranges feature that connects GPIO controllers and PINMUX controllers.

In da850.dtsi, pinctrl-single,gpio-range is added to the pinmux node and gpio-ranges is added to the GPIO node. Unfortunately, the way the pinctrl-single driver enumerates the pins (starting with LSB) causes them to be in reverse order compared to the way the gpios are assigned. As a result, we have to declare the mapping for each GPIO individually.

Quoted 8 lines
Quoted 5 lines

This also lets us remove all of the GPIO pinmuxes from da850-lego-ev3.dts. (Other da850 boards do not currently have any GPIO pinmuxes declared.)

Nice,

Quoted 8 lines

Looks good to me too. And quite painstakingly done!

I suppose this needs to wait a bit due to the dependencies? Let me know once its okay to merge.

Thanks,
Sekhar

Hi Sekhar,

The dependencies are in v4.17-rc1 so you can pick up this patch now.

Applied
#4 lore raw
Quoted 28 lines · David Lechner
Quoted 27 lines · Sekhar Nori
Quoted 12 lines · Linus Walleij
Quoted 9 lines · David Lechner

This makes use of the gpio-ranges feature that connects GPIO controllers and PINMUX controllers.

In da850.dtsi, pinctrl-single,gpio-range is added to the pinmux node and gpio-ranges is added to the GPIO node. Unfortunately, the way the pinctrl-single driver enumerates the pins (starting with LSB) causes them to be in reverse order compared to the way the gpios are assigned. As a result, we have to declare the mapping for each GPIO individually.

Quoted 8 lines
Quoted 5 lines

This also lets us remove all of the GPIO pinmuxes from da850-lego-ev3.dts. (Other da850 boards do not currently have any GPIO pinmuxes declared.)

Nice,

Looks good to me too. And quite painstakingly done!

I suppose this needs to wait a bit due to the dependencies? Let me know once its okay to merge.

Quoted 7 lines
Quoted 3 lines

Thanks,
Sekhar

Hi Sekhar,

The dependencies are in v4.17-rc1 so you can pick up this patch now.

applied to v4.18/dt. I had to manually adjust the patch to make it apply, probably because it was based off your common clock conversion branch.

Thanks,
Sekhar