All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/2 v2] gpio-omap: ensure a stable gpio numbering
@ 2016-06-14 18:57 ` Uwe Kleine-König
  0 siblings, 0 replies; 12+ messages in thread
From: Uwe Kleine-König @ 2016-06-14 18:57 UTC (permalink / raw)
  To: Grygorii Strashko, Santosh Shilimkar, Kevin Hilman,
	Linus Walleij, Alexandre Courbot
  Cc: linux-omap, linux-gpio, linux-arm-kernel, kernel

Hello,

this series' first patch is v2 of the patch I sent earlier. This now also
compiles without CONFIG_OF_GPIO.

The second patch is new and adds the respective aliases to all device trees
that make use of the gpio-omap driver.

Best regards
Uwe

Uwe Kleine-König (2):
  gpio: omap: make gpio numbering deterministical by using of aliases
  ARM: dts: add aliases for ti,omap[234]-gpio devices

 arch/arm/boot/dts/am33xx.dtsi   |  4 ++++
 arch/arm/boot/dts/am4372.dtsi   |  6 ++++++
 arch/arm/boot/dts/dm814x.dtsi   |  2 ++
 arch/arm/boot/dts/dm816x.dtsi   |  2 ++
 arch/arm/boot/dts/dra7.dtsi     |  8 ++++++++
 arch/arm/boot/dts/omap2420.dtsi |  7 +++++++
 arch/arm/boot/dts/omap2430.dtsi |  8 ++++++++
 arch/arm/boot/dts/omap3.dtsi    |  6 ++++++
 arch/arm/boot/dts/omap4.dtsi    |  6 ++++++
 arch/arm/boot/dts/omap5.dtsi    |  8 ++++++++
 drivers/gpio/gpio-omap.c        | 19 ++++++++++++++++++-
 11 files changed, 75 insertions(+), 1 deletion(-)

-- 
2.8.1

--
To unsubscribe from this list: send the line "unsubscribe linux-gpio" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [PATCH 0/2 v2] gpio-omap: ensure a stable gpio numbering
@ 2016-06-14 18:57 ` Uwe Kleine-König
  0 siblings, 0 replies; 12+ messages in thread
From: Uwe Kleine-König @ 2016-06-14 18:57 UTC (permalink / raw)
  To: linux-arm-kernel

Hello,

this series' first patch is v2 of the patch I sent earlier. This now also
compiles without CONFIG_OF_GPIO.

The second patch is new and adds the respective aliases to all device trees
that make use of the gpio-omap driver.

Best regards
Uwe

Uwe Kleine-K?nig (2):
  gpio: omap: make gpio numbering deterministical by using of aliases
  ARM: dts: add aliases for ti,omap[234]-gpio devices

 arch/arm/boot/dts/am33xx.dtsi   |  4 ++++
 arch/arm/boot/dts/am4372.dtsi   |  6 ++++++
 arch/arm/boot/dts/dm814x.dtsi   |  2 ++
 arch/arm/boot/dts/dm816x.dtsi   |  2 ++
 arch/arm/boot/dts/dra7.dtsi     |  8 ++++++++
 arch/arm/boot/dts/omap2420.dtsi |  7 +++++++
 arch/arm/boot/dts/omap2430.dtsi |  8 ++++++++
 arch/arm/boot/dts/omap3.dtsi    |  6 ++++++
 arch/arm/boot/dts/omap4.dtsi    |  6 ++++++
 arch/arm/boot/dts/omap5.dtsi    |  8 ++++++++
 drivers/gpio/gpio-omap.c        | 19 ++++++++++++++++++-
 11 files changed, 75 insertions(+), 1 deletion(-)

-- 
2.8.1

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [PATCH 1/2 v2] gpio: omap: make gpio numbering deterministical by using of aliases
  2016-06-14 18:57 ` Uwe Kleine-König
@ 2016-06-14 18:57   ` Uwe Kleine-König
  -1 siblings, 0 replies; 12+ messages in thread
From: Uwe Kleine-König @ 2016-06-14 18:57 UTC (permalink / raw)
  To: Grygorii Strashko, Santosh Shilimkar, Kevin Hilman,
	Linus Walleij, Alexandre Courbot
  Cc: linux-omap, linux-gpio, linux-arm-kernel, kernel

Traditionally the n-th gpio device probed by the omap gpio driver got
the gpio number range [n*32 .. n*32+31].
When order of the devices probed by the driver changes (which can happen
already now when some devices have a pinctrl and so the first probe
attempt returns -ENODEV) the numbering changes.

To ensure a deterministical numbering use of_alias_get_id to determine
the base for a given device. If no respective alias exists fall back to
the traditional numbering.

For the unusual case where only a part of the gpio devices have a
matching alias some of them might fail to probe. But if none of them has
an alias or all, there is no conflict which should be good enough to
maintain backward compatibility.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
---
 drivers/gpio/gpio-omap.c | 19 ++++++++++++++++++-
 1 file changed, 18 insertions(+), 1 deletion(-)

diff --git a/drivers/gpio/gpio-omap.c b/drivers/gpio/gpio-omap.c
index b98ede78c9d8..4d91792e7266 100644
--- a/drivers/gpio/gpio-omap.c
+++ b/drivers/gpio/gpio-omap.c
@@ -1053,9 +1053,26 @@ static int omap_gpio_chip_init(struct gpio_bank *bank, struct irq_chip *irqc)
 			bank->chip.parent = &omap_mpuio_device.dev;
 		bank->chip.base = OMAP_MPUIO(0);
 	} else {
+		int gpio_alias_id __maybe_unused;
+
 		bank->chip.label = "gpio";
-		bank->chip.base = gpio;
+
+#if defined(CONFIG_OF_GPIO)
+		/*
+		 * Traditionally the base is given out in first-come-first-serve
+		 * order.  This might shuffle the numbering of gpios if the
+		 * probe order changes.  So make the base deterministical if the
+		 * device tree specifies alias ids.
+		 */
+		gpio_alias_id = of_alias_get_id(bank->chip.of_node, "gpio");
+		if (gpio_alias_id >= 0)
+			bank->chip.base = bank->width * gpio_alias_id;
+		else
+#endif
+			bank->chip.base = gpio;
 	}
+
+
 	bank->chip.ngpio = bank->width;
 
 	ret = gpiochip_add_data(&bank->chip, bank);
-- 
2.8.1

--
To unsubscribe from this list: send the line "unsubscribe linux-gpio" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH 1/2 v2] gpio: omap: make gpio numbering deterministical by using of aliases
@ 2016-06-14 18:57   ` Uwe Kleine-König
  0 siblings, 0 replies; 12+ messages in thread
From: Uwe Kleine-König @ 2016-06-14 18:57 UTC (permalink / raw)
  To: linux-arm-kernel

Traditionally the n-th gpio device probed by the omap gpio driver got
the gpio number range [n*32 .. n*32+31].
When order of the devices probed by the driver changes (which can happen
already now when some devices have a pinctrl and so the first probe
attempt returns -ENODEV) the numbering changes.

To ensure a deterministical numbering use of_alias_get_id to determine
the base for a given device. If no respective alias exists fall back to
the traditional numbering.

For the unusual case where only a part of the gpio devices have a
matching alias some of them might fail to probe. But if none of them has
an alias or all, there is no conflict which should be good enough to
maintain backward compatibility.

Signed-off-by: Uwe Kleine-K?nig <u.kleine-koenig@pengutronix.de>
---
 drivers/gpio/gpio-omap.c | 19 ++++++++++++++++++-
 1 file changed, 18 insertions(+), 1 deletion(-)

diff --git a/drivers/gpio/gpio-omap.c b/drivers/gpio/gpio-omap.c
index b98ede78c9d8..4d91792e7266 100644
--- a/drivers/gpio/gpio-omap.c
+++ b/drivers/gpio/gpio-omap.c
@@ -1053,9 +1053,26 @@ static int omap_gpio_chip_init(struct gpio_bank *bank, struct irq_chip *irqc)
 			bank->chip.parent = &omap_mpuio_device.dev;
 		bank->chip.base = OMAP_MPUIO(0);
 	} else {
+		int gpio_alias_id __maybe_unused;
+
 		bank->chip.label = "gpio";
-		bank->chip.base = gpio;
+
+#if defined(CONFIG_OF_GPIO)
+		/*
+		 * Traditionally the base is given out in first-come-first-serve
+		 * order.  This might shuffle the numbering of gpios if the
+		 * probe order changes.  So make the base deterministical if the
+		 * device tree specifies alias ids.
+		 */
+		gpio_alias_id = of_alias_get_id(bank->chip.of_node, "gpio");
+		if (gpio_alias_id >= 0)
+			bank->chip.base = bank->width * gpio_alias_id;
+		else
+#endif
+			bank->chip.base = gpio;
 	}
+
+
 	bank->chip.ngpio = bank->width;
 
 	ret = gpiochip_add_data(&bank->chip, bank);
-- 
2.8.1

^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH 2/2 v2] ARM: dts: add aliases for ti,omap[234]-gpio devices
  2016-06-14 18:57 ` Uwe Kleine-König
@ 2016-06-14 18:57   ` Uwe Kleine-König
  -1 siblings, 0 replies; 12+ messages in thread
From: Uwe Kleine-König @ 2016-06-14 18:57 UTC (permalink / raw)
  To: Grygorii Strashko, Santosh Shilimkar, Kevin Hilman,
	Linus Walleij, Alexandre Courbot
  Cc: linux-omap, linux-gpio, linux-arm-kernel, kernel

This together with the corresponding change to the gpio-omap driver
ensures that the gpio numbering is independant of the probing order.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
---
 arch/arm/boot/dts/am33xx.dtsi   | 4 ++++
 arch/arm/boot/dts/am4372.dtsi   | 6 ++++++
 arch/arm/boot/dts/dm814x.dtsi   | 2 ++
 arch/arm/boot/dts/dm816x.dtsi   | 2 ++
 arch/arm/boot/dts/dra7.dtsi     | 8 ++++++++
 arch/arm/boot/dts/omap2420.dtsi | 7 +++++++
 arch/arm/boot/dts/omap2430.dtsi | 8 ++++++++
 arch/arm/boot/dts/omap3.dtsi    | 6 ++++++
 arch/arm/boot/dts/omap4.dtsi    | 6 ++++++
 arch/arm/boot/dts/omap5.dtsi    | 8 ++++++++
 10 files changed, 57 insertions(+)

diff --git a/arch/arm/boot/dts/am33xx.dtsi b/arch/arm/boot/dts/am33xx.dtsi
index 52be48bbd2dd..fbfc17ab56d8 100644
--- a/arch/arm/boot/dts/am33xx.dtsi
+++ b/arch/arm/boot/dts/am33xx.dtsi
@@ -35,6 +35,10 @@
 		phy1 = &usb1_phy;
 		ethernet0 = &cpsw_emac0;
 		ethernet1 = &cpsw_emac1;
+		gpio0 = &gpio0;
+		gpio1 = &gpio1;
+		gpio2 = &gpio2;
+		gpio3 = &gpio3;
 	};
 
 	cpus {
diff --git a/arch/arm/boot/dts/am4372.dtsi b/arch/arm/boot/dts/am4372.dtsi
index 12fcde4d4d2e..0f5a915ba94b 100644
--- a/arch/arm/boot/dts/am4372.dtsi
+++ b/arch/arm/boot/dts/am4372.dtsi
@@ -31,6 +31,12 @@
 		ethernet0 = &cpsw_emac0;
 		ethernet1 = &cpsw_emac1;
 		spi0 = &qspi;
+		gpio0 = &gpio0;
+		gpio1 = &gpio1;
+		gpio2 = &gpio2;
+		gpio3 = &gpio3;
+		gpio4 = &gpio4;
+		gpio5 = &gpio5;
 	};
 
 	cpus {
diff --git a/arch/arm/boot/dts/dm814x.dtsi b/arch/arm/boot/dts/dm814x.dtsi
index d4537dc61497..d5a49ad31d50 100644
--- a/arch/arm/boot/dts/dm814x.dtsi
+++ b/arch/arm/boot/dts/dm814x.dtsi
@@ -25,6 +25,8 @@
 		usb1 = &usb1;
 		phy0 = &usb0_phy;
 		phy1 = &usb1_phy;
+		gpio0 = &gpio1;
+		gpio1 = &gpio2;
 	};
 
 	cpus {
diff --git a/arch/arm/boot/dts/dm816x.dtsi b/arch/arm/boot/dts/dm816x.dtsi
index 44e39c743b53..500d9091701e 100644
--- a/arch/arm/boot/dts/dm816x.dtsi
+++ b/arch/arm/boot/dts/dm816x.dtsi
@@ -21,6 +21,8 @@
 		serial2 = &uart3;
 		ethernet0 = &eth0;
 		ethernet1 = &eth1;
+		gpio0 = &gpio1;
+		gpio1 = &gpio2;
 	};
 
 	cpus {
diff --git a/arch/arm/boot/dts/dra7.dtsi b/arch/arm/boot/dts/dra7.dtsi
index e0074014385a..4d6e2309a742 100644
--- a/arch/arm/boot/dts/dra7.dtsi
+++ b/arch/arm/boot/dts/dra7.dtsi
@@ -42,6 +42,14 @@
 		d_can0 = &dcan1;
 		d_can1 = &dcan2;
 		spi0 = &qspi;
+		gpio0 = &gpio1;
+		gpio1 = &gpio2;
+		gpio2 = &gpio3;
+		gpio3 = &gpio4;
+		gpio4 = &gpio5;
+		gpio5 = &gpio6;
+		gpio6 = &gpio7;
+		gpio7 = &gpio8;
 	};
 
 	timer {
diff --git a/arch/arm/boot/dts/omap2420.dtsi b/arch/arm/boot/dts/omap2420.dtsi
index fb712b9aa874..933e4415d3d2 100644
--- a/arch/arm/boot/dts/omap2420.dtsi
+++ b/arch/arm/boot/dts/omap2420.dtsi
@@ -13,6 +13,13 @@
 / {
 	compatible = "ti,omap2420", "ti,omap2";
 
+	aliases {
+		gpio0 = &gpio1;
+		gpio1 = &gpio2;
+		gpio2 = &gpio3;
+		gpio3 = &gpio4;
+	};
+
 	ocp {
 		l4: l4@48000000 {
 			compatible = "ti,omap2-l4", "simple-bus";
diff --git a/arch/arm/boot/dts/omap2430.dtsi b/arch/arm/boot/dts/omap2430.dtsi
index 455aaea407dd..8c0e5555a550 100644
--- a/arch/arm/boot/dts/omap2430.dtsi
+++ b/arch/arm/boot/dts/omap2430.dtsi
@@ -13,6 +13,14 @@
 / {
 	compatible = "ti,omap2430", "ti,omap2";
 
+	aliases {
+		gpio0 = &gpio1;
+		gpio1 = &gpio2;
+		gpio2 = &gpio3;
+		gpio3 = &gpio4;
+		gpio4 = &gpio5;
+	};
+
 	ocp {
 		l4_wkup: l4_wkup@49000000 {
 			compatible = "ti,omap2-l4-wkup", "simple-bus";
diff --git a/arch/arm/boot/dts/omap3.dtsi b/arch/arm/boot/dts/omap3.dtsi
index 9fbda38528dc..2676c34c5830 100644
--- a/arch/arm/boot/dts/omap3.dtsi
+++ b/arch/arm/boot/dts/omap3.dtsi
@@ -25,6 +25,12 @@
 		serial0 = &uart1;
 		serial1 = &uart2;
 		serial2 = &uart3;
+		gpio0 = &gpio1;
+		gpio1 = &gpio2;
+		gpio2 = &gpio3;
+		gpio3 = &gpio4;
+		gpio4 = &gpio5;
+		gpio5 = &gpio6;
 	};
 
 	cpus {
diff --git a/arch/arm/boot/dts/omap4.dtsi b/arch/arm/boot/dts/omap4.dtsi
index 3fdc51cd0fad..367a2fb04829 100644
--- a/arch/arm/boot/dts/omap4.dtsi
+++ b/arch/arm/boot/dts/omap4.dtsi
@@ -25,6 +25,12 @@
 		serial1 = &uart2;
 		serial2 = &uart3;
 		serial3 = &uart4;
+		gpio0 = &gpio1;
+		gpio1 = &gpio2;
+		gpio2 = &gpio3;
+		gpio3 = &gpio4;
+		gpio4 = &gpio5;
+		gpio5 = &gpio6;
 	};
 
 	cpus {
diff --git a/arch/arm/boot/dts/omap5.dtsi b/arch/arm/boot/dts/omap5.dtsi
index 84c10195e79b..017edd442390 100644
--- a/arch/arm/boot/dts/omap5.dtsi
+++ b/arch/arm/boot/dts/omap5.dtsi
@@ -32,6 +32,14 @@
 		serial3 = &uart4;
 		serial4 = &uart5;
 		serial5 = &uart6;
+		gpio0 = &gpio1;
+		gpio1 = &gpio2;
+		gpio2 = &gpio3;
+		gpio3 = &gpio4;
+		gpio4 = &gpio5;
+		gpio5 = &gpio6;
+		gpio6 = &gpio7;
+		gpio7 = &gpio8;
 	};
 
 	cpus {
-- 
2.8.1

--
To unsubscribe from this list: send the line "unsubscribe linux-gpio" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH 2/2 v2] ARM: dts: add aliases for ti,omap[234]-gpio devices
@ 2016-06-14 18:57   ` Uwe Kleine-König
  0 siblings, 0 replies; 12+ messages in thread
From: Uwe Kleine-König @ 2016-06-14 18:57 UTC (permalink / raw)
  To: linux-arm-kernel

This together with the corresponding change to the gpio-omap driver
ensures that the gpio numbering is independant of the probing order.

Signed-off-by: Uwe Kleine-K?nig <u.kleine-koenig@pengutronix.de>
---
 arch/arm/boot/dts/am33xx.dtsi   | 4 ++++
 arch/arm/boot/dts/am4372.dtsi   | 6 ++++++
 arch/arm/boot/dts/dm814x.dtsi   | 2 ++
 arch/arm/boot/dts/dm816x.dtsi   | 2 ++
 arch/arm/boot/dts/dra7.dtsi     | 8 ++++++++
 arch/arm/boot/dts/omap2420.dtsi | 7 +++++++
 arch/arm/boot/dts/omap2430.dtsi | 8 ++++++++
 arch/arm/boot/dts/omap3.dtsi    | 6 ++++++
 arch/arm/boot/dts/omap4.dtsi    | 6 ++++++
 arch/arm/boot/dts/omap5.dtsi    | 8 ++++++++
 10 files changed, 57 insertions(+)

diff --git a/arch/arm/boot/dts/am33xx.dtsi b/arch/arm/boot/dts/am33xx.dtsi
index 52be48bbd2dd..fbfc17ab56d8 100644
--- a/arch/arm/boot/dts/am33xx.dtsi
+++ b/arch/arm/boot/dts/am33xx.dtsi
@@ -35,6 +35,10 @@
 		phy1 = &usb1_phy;
 		ethernet0 = &cpsw_emac0;
 		ethernet1 = &cpsw_emac1;
+		gpio0 = &gpio0;
+		gpio1 = &gpio1;
+		gpio2 = &gpio2;
+		gpio3 = &gpio3;
 	};
 
 	cpus {
diff --git a/arch/arm/boot/dts/am4372.dtsi b/arch/arm/boot/dts/am4372.dtsi
index 12fcde4d4d2e..0f5a915ba94b 100644
--- a/arch/arm/boot/dts/am4372.dtsi
+++ b/arch/arm/boot/dts/am4372.dtsi
@@ -31,6 +31,12 @@
 		ethernet0 = &cpsw_emac0;
 		ethernet1 = &cpsw_emac1;
 		spi0 = &qspi;
+		gpio0 = &gpio0;
+		gpio1 = &gpio1;
+		gpio2 = &gpio2;
+		gpio3 = &gpio3;
+		gpio4 = &gpio4;
+		gpio5 = &gpio5;
 	};
 
 	cpus {
diff --git a/arch/arm/boot/dts/dm814x.dtsi b/arch/arm/boot/dts/dm814x.dtsi
index d4537dc61497..d5a49ad31d50 100644
--- a/arch/arm/boot/dts/dm814x.dtsi
+++ b/arch/arm/boot/dts/dm814x.dtsi
@@ -25,6 +25,8 @@
 		usb1 = &usb1;
 		phy0 = &usb0_phy;
 		phy1 = &usb1_phy;
+		gpio0 = &gpio1;
+		gpio1 = &gpio2;
 	};
 
 	cpus {
diff --git a/arch/arm/boot/dts/dm816x.dtsi b/arch/arm/boot/dts/dm816x.dtsi
index 44e39c743b53..500d9091701e 100644
--- a/arch/arm/boot/dts/dm816x.dtsi
+++ b/arch/arm/boot/dts/dm816x.dtsi
@@ -21,6 +21,8 @@
 		serial2 = &uart3;
 		ethernet0 = &eth0;
 		ethernet1 = &eth1;
+		gpio0 = &gpio1;
+		gpio1 = &gpio2;
 	};
 
 	cpus {
diff --git a/arch/arm/boot/dts/dra7.dtsi b/arch/arm/boot/dts/dra7.dtsi
index e0074014385a..4d6e2309a742 100644
--- a/arch/arm/boot/dts/dra7.dtsi
+++ b/arch/arm/boot/dts/dra7.dtsi
@@ -42,6 +42,14 @@
 		d_can0 = &dcan1;
 		d_can1 = &dcan2;
 		spi0 = &qspi;
+		gpio0 = &gpio1;
+		gpio1 = &gpio2;
+		gpio2 = &gpio3;
+		gpio3 = &gpio4;
+		gpio4 = &gpio5;
+		gpio5 = &gpio6;
+		gpio6 = &gpio7;
+		gpio7 = &gpio8;
 	};
 
 	timer {
diff --git a/arch/arm/boot/dts/omap2420.dtsi b/arch/arm/boot/dts/omap2420.dtsi
index fb712b9aa874..933e4415d3d2 100644
--- a/arch/arm/boot/dts/omap2420.dtsi
+++ b/arch/arm/boot/dts/omap2420.dtsi
@@ -13,6 +13,13 @@
 / {
 	compatible = "ti,omap2420", "ti,omap2";
 
+	aliases {
+		gpio0 = &gpio1;
+		gpio1 = &gpio2;
+		gpio2 = &gpio3;
+		gpio3 = &gpio4;
+	};
+
 	ocp {
 		l4: l4 at 48000000 {
 			compatible = "ti,omap2-l4", "simple-bus";
diff --git a/arch/arm/boot/dts/omap2430.dtsi b/arch/arm/boot/dts/omap2430.dtsi
index 455aaea407dd..8c0e5555a550 100644
--- a/arch/arm/boot/dts/omap2430.dtsi
+++ b/arch/arm/boot/dts/omap2430.dtsi
@@ -13,6 +13,14 @@
 / {
 	compatible = "ti,omap2430", "ti,omap2";
 
+	aliases {
+		gpio0 = &gpio1;
+		gpio1 = &gpio2;
+		gpio2 = &gpio3;
+		gpio3 = &gpio4;
+		gpio4 = &gpio5;
+	};
+
 	ocp {
 		l4_wkup: l4_wkup at 49000000 {
 			compatible = "ti,omap2-l4-wkup", "simple-bus";
diff --git a/arch/arm/boot/dts/omap3.dtsi b/arch/arm/boot/dts/omap3.dtsi
index 9fbda38528dc..2676c34c5830 100644
--- a/arch/arm/boot/dts/omap3.dtsi
+++ b/arch/arm/boot/dts/omap3.dtsi
@@ -25,6 +25,12 @@
 		serial0 = &uart1;
 		serial1 = &uart2;
 		serial2 = &uart3;
+		gpio0 = &gpio1;
+		gpio1 = &gpio2;
+		gpio2 = &gpio3;
+		gpio3 = &gpio4;
+		gpio4 = &gpio5;
+		gpio5 = &gpio6;
 	};
 
 	cpus {
diff --git a/arch/arm/boot/dts/omap4.dtsi b/arch/arm/boot/dts/omap4.dtsi
index 3fdc51cd0fad..367a2fb04829 100644
--- a/arch/arm/boot/dts/omap4.dtsi
+++ b/arch/arm/boot/dts/omap4.dtsi
@@ -25,6 +25,12 @@
 		serial1 = &uart2;
 		serial2 = &uart3;
 		serial3 = &uart4;
+		gpio0 = &gpio1;
+		gpio1 = &gpio2;
+		gpio2 = &gpio3;
+		gpio3 = &gpio4;
+		gpio4 = &gpio5;
+		gpio5 = &gpio6;
 	};
 
 	cpus {
diff --git a/arch/arm/boot/dts/omap5.dtsi b/arch/arm/boot/dts/omap5.dtsi
index 84c10195e79b..017edd442390 100644
--- a/arch/arm/boot/dts/omap5.dtsi
+++ b/arch/arm/boot/dts/omap5.dtsi
@@ -32,6 +32,14 @@
 		serial3 = &uart4;
 		serial4 = &uart5;
 		serial5 = &uart6;
+		gpio0 = &gpio1;
+		gpio1 = &gpio2;
+		gpio2 = &gpio3;
+		gpio3 = &gpio4;
+		gpio4 = &gpio5;
+		gpio5 = &gpio6;
+		gpio6 = &gpio7;
+		gpio7 = &gpio8;
 	};
 
 	cpus {
-- 
2.8.1

^ permalink raw reply related	[flat|nested] 12+ messages in thread

* Re: [PATCH 1/2 v2] gpio: omap: make gpio numbering deterministical by using of aliases
  2016-06-14 18:57   ` Uwe Kleine-König
@ 2016-06-21 11:28     ` Tony Lindgren
  -1 siblings, 0 replies; 12+ messages in thread
From: Tony Lindgren @ 2016-06-21 11:28 UTC (permalink / raw)
  To: Uwe Kleine-König
  Cc: Alexandre Courbot, Grygorii Strashko, Kevin Hilman,
	Linus Walleij, linux-gpio, kernel, Santosh Shilimkar, linux-omap,
	linux-arm-kernel

* Uwe Kleine-König <u.kleine-koenig@pengutronix.de> [160614 12:03]:
> Traditionally the n-th gpio device probed by the omap gpio driver got
> the gpio number range [n*32 .. n*32+31].
> When order of the devices probed by the driver changes (which can happen
> already now when some devices have a pinctrl and so the first probe
> attempt returns -ENODEV) the numbering changes.
> 
> To ensure a deterministical numbering use of_alias_get_id to determine
> the base for a given device. If no respective alias exists fall back to
> the traditional numbering.
> 
> For the unusual case where only a part of the gpio devices have a
> matching alias some of them might fail to probe. But if none of them has
> an alias or all, there is no conflict which should be good enough to
> maintain backward compatibility.

I think doing this is a good idea to prevent nasty suprises when
upgrading a kernel on some device:

Acked-by: Tony Lindgren <tony@atomide.com>

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [PATCH 1/2 v2] gpio: omap: make gpio numbering deterministical by using of aliases
@ 2016-06-21 11:28     ` Tony Lindgren
  0 siblings, 0 replies; 12+ messages in thread
From: Tony Lindgren @ 2016-06-21 11:28 UTC (permalink / raw)
  To: linux-arm-kernel

* Uwe Kleine-K?nig <u.kleine-koenig@pengutronix.de> [160614 12:03]:
> Traditionally the n-th gpio device probed by the omap gpio driver got
> the gpio number range [n*32 .. n*32+31].
> When order of the devices probed by the driver changes (which can happen
> already now when some devices have a pinctrl and so the first probe
> attempt returns -ENODEV) the numbering changes.
> 
> To ensure a deterministical numbering use of_alias_get_id to determine
> the base for a given device. If no respective alias exists fall back to
> the traditional numbering.
> 
> For the unusual case where only a part of the gpio devices have a
> matching alias some of them might fail to probe. But if none of them has
> an alias or all, there is no conflict which should be good enough to
> maintain backward compatibility.

I think doing this is a good idea to prevent nasty suprises when
upgrading a kernel on some device:

Acked-by: Tony Lindgren <tony@atomide.com>

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH 1/2 v2] gpio: omap: make gpio numbering deterministical by using of aliases
  2016-06-14 18:57   ` Uwe Kleine-König
@ 2016-06-21 17:01     ` Grygorii Strashko
  -1 siblings, 0 replies; 12+ messages in thread
From: Grygorii Strashko @ 2016-06-21 17:01 UTC (permalink / raw)
  To: Uwe Kleine-König, Santosh Shilimkar, Kevin Hilman,
	Linus Walleij, Alexandre Courbot
  Cc: linux-gpio, linux-omap, kernel, linux-arm-kernel

On 06/14/2016 09:57 PM, Uwe Kleine-König wrote:
> Traditionally the n-th gpio device probed by the omap gpio driver got
> the gpio number range [n*32 .. n*32+31].
> When order of the devices probed by the driver changes (which can happen
> already now when some devices have a pinctrl and so the first probe
> attempt returns -ENODEV) the numbering changes.
>
> To ensure a deterministical numbering use of_alias_get_id to determine
> the base for a given device. If no respective alias exists fall back to
> the traditional numbering.
>
> For the unusual case where only a part of the gpio devices have a
> matching alias some of them might fail to probe. But if none of them has
> an alias or all, there is no conflict which should be good enough to
> maintain backward compatibility.
>
> Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
> ---
>   drivers/gpio/gpio-omap.c | 19 ++++++++++++++++++-
>   1 file changed, 18 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/gpio/gpio-omap.c b/drivers/gpio/gpio-omap.c
> index b98ede78c9d8..4d91792e7266 100644
> --- a/drivers/gpio/gpio-omap.c
> +++ b/drivers/gpio/gpio-omap.c
> @@ -1053,9 +1053,26 @@ static int omap_gpio_chip_init(struct gpio_bank *bank, struct irq_chip *irqc)
>   			bank->chip.parent = &omap_mpuio_device.dev;
>   		bank->chip.base = OMAP_MPUIO(0);
>   	} else {
> +		int gpio_alias_id __maybe_unused;
> +
>   		bank->chip.label = "gpio";
> -		bank->chip.base = gpio;
> +
> +#if defined(CONFIG_OF_GPIO)
> +		/*
> +		 * Traditionally the base is given out in first-come-first-serve
> +		 * order.  This might shuffle the numbering of gpios if the
> +		 * probe order changes.  So make the base deterministical if the
> +		 * device tree specifies alias ids.
> +		 */
> +		gpio_alias_id = of_alias_get_id(bank->chip.of_node, "gpio");
> +		if (gpio_alias_id >= 0)
> +			bank->chip.base = bank->width * gpio_alias_id;
> +		else
> +#endif
> +			bank->chip.base = gpio;
>   	}
> +
> +
>   	bank->chip.ngpio = bank->width;
>
>   	ret = gpiochip_add_data(&bank->chip, bank);
>

Reviewed-by: Grygorii Strashko <grygorii.strashko@ti.com>

-- 
regards,
-grygorii

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [PATCH 1/2 v2] gpio: omap: make gpio numbering deterministical by using of aliases
@ 2016-06-21 17:01     ` Grygorii Strashko
  0 siblings, 0 replies; 12+ messages in thread
From: Grygorii Strashko @ 2016-06-21 17:01 UTC (permalink / raw)
  To: linux-arm-kernel

On 06/14/2016 09:57 PM, Uwe Kleine-K?nig wrote:
> Traditionally the n-th gpio device probed by the omap gpio driver got
> the gpio number range [n*32 .. n*32+31].
> When order of the devices probed by the driver changes (which can happen
> already now when some devices have a pinctrl and so the first probe
> attempt returns -ENODEV) the numbering changes.
>
> To ensure a deterministical numbering use of_alias_get_id to determine
> the base for a given device. If no respective alias exists fall back to
> the traditional numbering.
>
> For the unusual case where only a part of the gpio devices have a
> matching alias some of them might fail to probe. But if none of them has
> an alias or all, there is no conflict which should be good enough to
> maintain backward compatibility.
>
> Signed-off-by: Uwe Kleine-K?nig <u.kleine-koenig@pengutronix.de>
> ---
>   drivers/gpio/gpio-omap.c | 19 ++++++++++++++++++-
>   1 file changed, 18 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/gpio/gpio-omap.c b/drivers/gpio/gpio-omap.c
> index b98ede78c9d8..4d91792e7266 100644
> --- a/drivers/gpio/gpio-omap.c
> +++ b/drivers/gpio/gpio-omap.c
> @@ -1053,9 +1053,26 @@ static int omap_gpio_chip_init(struct gpio_bank *bank, struct irq_chip *irqc)
>   			bank->chip.parent = &omap_mpuio_device.dev;
>   		bank->chip.base = OMAP_MPUIO(0);
>   	} else {
> +		int gpio_alias_id __maybe_unused;
> +
>   		bank->chip.label = "gpio";
> -		bank->chip.base = gpio;
> +
> +#if defined(CONFIG_OF_GPIO)
> +		/*
> +		 * Traditionally the base is given out in first-come-first-serve
> +		 * order.  This might shuffle the numbering of gpios if the
> +		 * probe order changes.  So make the base deterministical if the
> +		 * device tree specifies alias ids.
> +		 */
> +		gpio_alias_id = of_alias_get_id(bank->chip.of_node, "gpio");
> +		if (gpio_alias_id >= 0)
> +			bank->chip.base = bank->width * gpio_alias_id;
> +		else
> +#endif
> +			bank->chip.base = gpio;
>   	}
> +
> +
>   	bank->chip.ngpio = bank->width;
>
>   	ret = gpiochip_add_data(&bank->chip, bank);
>

Reviewed-by: Grygorii Strashko <grygorii.strashko@ti.com>

-- 
regards,
-grygorii

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH 1/2 v2] gpio: omap: make gpio numbering deterministical by using of aliases
  2016-06-14 18:57   ` Uwe Kleine-König
@ 2016-06-23  8:54     ` Linus Walleij
  -1 siblings, 0 replies; 12+ messages in thread
From: Linus Walleij @ 2016-06-23  8:54 UTC (permalink / raw)
  To: Uwe Kleine-König, devicetree, Rob Herring, Mark Rutland
  Cc: Grygorii Strashko, Santosh Shilimkar, Kevin Hilman,
	Alexandre Courbot, Linux-OMAP, linux-gpio, linux-arm-kernel,
	Sascha Hauer

Looping in DT people.

Please send subsequent patches also to devicetree@vger.kernel.org

On Tue, Jun 14, 2016 at 8:57 PM, Uwe Kleine-König
<u.kleine-koenig@pengutronix.de> wrote:

> Traditionally the n-th gpio device probed by the omap gpio driver got
> the gpio number range [n*32 .. n*32+31].
> When order of the devices probed by the driver changes (which can happen
> already now when some devices have a pinctrl and so the first probe
> attempt returns -ENODEV) the numbering changes.
>
> To ensure a deterministical numbering use of_alias_get_id to determine
> the base for a given device. If no respective alias exists fall back to
> the traditional numbering.
>
> For the unusual case where only a part of the gpio devices have a
> matching alias some of them might fail to probe. But if none of them has
> an alias or all, there is no conflict which should be good enough to
> maintain backward compatibility.
>
> Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
> ---
>  drivers/gpio/gpio-omap.c | 19 ++++++++++++++++++-
>  1 file changed, 18 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/gpio/gpio-omap.c b/drivers/gpio/gpio-omap.c
> index b98ede78c9d8..4d91792e7266 100644
> --- a/drivers/gpio/gpio-omap.c
> +++ b/drivers/gpio/gpio-omap.c
> @@ -1053,9 +1053,26 @@ static int omap_gpio_chip_init(struct gpio_bank *bank, struct irq_chip *irqc)
>                         bank->chip.parent = &omap_mpuio_device.dev;
>                 bank->chip.base = OMAP_MPUIO(0);
>         } else {
> +               int gpio_alias_id __maybe_unused;
> +
>                 bank->chip.label = "gpio";
> -               bank->chip.base = gpio;
> +
> +#if defined(CONFIG_OF_GPIO)
> +               /*
> +                * Traditionally the base is given out in first-come-first-serve
> +                * order.  This might shuffle the numbering of gpios if the
> +                * probe order changes.  So make the base deterministical if the
> +                * device tree specifies alias ids.
> +                */
> +               gpio_alias_id = of_alias_get_id(bank->chip.of_node, "gpio");
> +               if (gpio_alias_id >= 0)
> +                       bank->chip.base = bank->width * gpio_alias_id;
> +               else
> +#endif
> +                       bank->chip.base = gpio;
>         }
> +
> +

I need:

- A hunk of the patch to hit
  Documentation/devicetree/bindings/gpio/gpio.txt
  and describe the alias usage there

-  an ACK from a DT bindings maintainer for this.

Yours,
Linus Walleij
--
To unsubscribe from this list: send the line "unsubscribe linux-gpio" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [PATCH 1/2 v2] gpio: omap: make gpio numbering deterministical by using of aliases
@ 2016-06-23  8:54     ` Linus Walleij
  0 siblings, 0 replies; 12+ messages in thread
From: Linus Walleij @ 2016-06-23  8:54 UTC (permalink / raw)
  To: linux-arm-kernel

Looping in DT people.

Please send subsequent patches also to devicetree at vger.kernel.org

On Tue, Jun 14, 2016 at 8:57 PM, Uwe Kleine-K?nig
<u.kleine-koenig@pengutronix.de> wrote:

> Traditionally the n-th gpio device probed by the omap gpio driver got
> the gpio number range [n*32 .. n*32+31].
> When order of the devices probed by the driver changes (which can happen
> already now when some devices have a pinctrl and so the first probe
> attempt returns -ENODEV) the numbering changes.
>
> To ensure a deterministical numbering use of_alias_get_id to determine
> the base for a given device. If no respective alias exists fall back to
> the traditional numbering.
>
> For the unusual case where only a part of the gpio devices have a
> matching alias some of them might fail to probe. But if none of them has
> an alias or all, there is no conflict which should be good enough to
> maintain backward compatibility.
>
> Signed-off-by: Uwe Kleine-K?nig <u.kleine-koenig@pengutronix.de>
> ---
>  drivers/gpio/gpio-omap.c | 19 ++++++++++++++++++-
>  1 file changed, 18 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/gpio/gpio-omap.c b/drivers/gpio/gpio-omap.c
> index b98ede78c9d8..4d91792e7266 100644
> --- a/drivers/gpio/gpio-omap.c
> +++ b/drivers/gpio/gpio-omap.c
> @@ -1053,9 +1053,26 @@ static int omap_gpio_chip_init(struct gpio_bank *bank, struct irq_chip *irqc)
>                         bank->chip.parent = &omap_mpuio_device.dev;
>                 bank->chip.base = OMAP_MPUIO(0);
>         } else {
> +               int gpio_alias_id __maybe_unused;
> +
>                 bank->chip.label = "gpio";
> -               bank->chip.base = gpio;
> +
> +#if defined(CONFIG_OF_GPIO)
> +               /*
> +                * Traditionally the base is given out in first-come-first-serve
> +                * order.  This might shuffle the numbering of gpios if the
> +                * probe order changes.  So make the base deterministical if the
> +                * device tree specifies alias ids.
> +                */
> +               gpio_alias_id = of_alias_get_id(bank->chip.of_node, "gpio");
> +               if (gpio_alias_id >= 0)
> +                       bank->chip.base = bank->width * gpio_alias_id;
> +               else
> +#endif
> +                       bank->chip.base = gpio;
>         }
> +
> +

I need:

- A hunk of the patch to hit
  Documentation/devicetree/bindings/gpio/gpio.txt
  and describe the alias usage there

-  an ACK from a DT bindings maintainer for this.

Yours,
Linus Walleij

^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2016-06-23  8:54 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-06-14 18:57 [PATCH 0/2 v2] gpio-omap: ensure a stable gpio numbering Uwe Kleine-König
2016-06-14 18:57 ` Uwe Kleine-König
2016-06-14 18:57 ` [PATCH 1/2 v2] gpio: omap: make gpio numbering deterministical by using of aliases Uwe Kleine-König
2016-06-14 18:57   ` Uwe Kleine-König
2016-06-21 11:28   ` Tony Lindgren
2016-06-21 11:28     ` Tony Lindgren
2016-06-21 17:01   ` Grygorii Strashko
2016-06-21 17:01     ` Grygorii Strashko
2016-06-23  8:54   ` Linus Walleij
2016-06-23  8:54     ` Linus Walleij
2016-06-14 18:57 ` [PATCH 2/2 v2] ARM: dts: add aliases for ti,omap[234]-gpio devices Uwe Kleine-König
2016-06-14 18:57   ` Uwe Kleine-König

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.