brcm63xx: use consistent gpio chip labeling for OF/non-OF
authorJonas Gorski <jogo@openwrt.org>
Mon, 16 Mar 2015 13:37:38 +0000 (13:37 +0000)
committerJonas Gorski <jogo@openwrt.org>
Mon, 16 Mar 2015 13:37:38 +0000 (13:37 +0000)
Ensure gpio chips are always labeled the same; this allows simplifying
any arch setup gpio lookups.

Signed-off-by: Jonas Gorski <jogo@openwrt.org>
SVN-Revision: 44846

target/linux/brcm63xx/patches-3.14/374-gpio-add-a-simple-GPIO-driver-for-bcm63xx.patch
target/linux/brcm63xx/patches-3.14/378-MIPS-BCM63XX-calculate-labels-for-DT-registered-cont.patch [deleted file]
target/linux/brcm63xx/patches-3.14/378-MIPS-BCM63XX-do-not-register-gpio-controller-if-pres.patch [new file with mode: 0644]
target/linux/brcm63xx/patches-3.14/568-board_DGND3700v1_3800B.patch
target/linux/brcm63xx/patches-3.18/374-gpio-add-a-simple-GPIO-driver-for-bcm63xx.patch
target/linux/brcm63xx/patches-3.18/378-MIPS-BCM63XX-calculate-labels-for-DT-registered-cont.patch [deleted file]
target/linux/brcm63xx/patches-3.18/378-MIPS-BCM63XX-do-not-register-gpio-controller-if-pres.patch [new file with mode: 0644]
target/linux/brcm63xx/patches-3.18/568-board_DGND3700v1_3800B.patch

index 2a07e735ca5772b6f7eea04561b8c3d9806dafcd..6f74d027f95300e0aa4575539e1856e7d9aef9dd 100644 (file)
@@ -8,8 +8,8 @@ Signed-off-by: Jonas Gorski <jogo@openwrt.org>
 ---
  drivers/gpio/Kconfig        |    8 +++
  drivers/gpio/Makefile       |    1 +
- drivers/gpio/gpio-bcm63xx.c |  117 +++++++++++++++++++++++++++++++++++++++++++
- 3 files changed, 126 insertions(+)
+ drivers/gpio/gpio-bcm63xx.c |  122 +++++++++++++++++++++++++++++++++++++++++++
+ 3 files changed, 131 insertions(+)
  create mode 100644 drivers/gpio/gpio-bcm63xx.c
 
 --- a/drivers/gpio/Kconfig
@@ -41,7 +41,7 @@ Signed-off-by: Jonas Gorski <jogo@openwrt.org>
  obj-$(CONFIG_GPIO_CS5535)     += gpio-cs5535.o
 --- /dev/null
 +++ b/drivers/gpio/gpio-bcm63xx.c
-@@ -0,0 +1,117 @@
+@@ -0,0 +1,122 @@
 +/*
 + * Driver for BCM63XX memory-mapped GPIO controllers, based on
 + * Generic driver for memory-mapped GPIO controllers.
@@ -117,8 +117,13 @@ Signed-off-by: Jonas Gorski <jogo@openwrt.org>
 +      platform_set_drvdata(pdev, bgc);
 +
 +      if (dev->of_node) {
++              int id = of_alias_get_id(dev->of_node, "gpio");
 +              u32 ngpios;
 +
++              if (id >= 0)
++                      bgc->gc.label = devm_kasprintf(dev, GFP_KERNEL,
++                                                     "bcm63xx-gpio.%d", id);
++
 +              if (!of_property_read_u32(dev->of_node, "ngpios", &ngpios))
 +                      bgc->gc.ngpio = ngpios;
 +
diff --git a/target/linux/brcm63xx/patches-3.14/378-MIPS-BCM63XX-calculate-labels-for-DT-registered-cont.patch b/target/linux/brcm63xx/patches-3.14/378-MIPS-BCM63XX-calculate-labels-for-DT-registered-cont.patch
deleted file mode 100644 (file)
index 40f9e6d..0000000
+++ /dev/null
@@ -1,44 +0,0 @@
-From e55892aac9d5508a000647ca66f0e678e02be3bb Mon Sep 17 00:00:00 2001
-From: Jonas Gorski <jogo@openwrt.org>
-Date: Sat, 21 Feb 2015 17:26:50 +0100
-Subject: [PATCH 5/6] MIPS: BCM63XX: calculate labels for DT registered
- controllers
-
-
-Signed-off-by: Jonas Gorski <jogo@openwrt.org>
----
- arch/mips/bcm63xx/gpio.c |   16 +++++++++++++---
- 1 file changed, 13 insertions(+), 3 deletions(-)
-
---- a/arch/mips/bcm63xx/gpio.c
-+++ b/arch/mips/bcm63xx/gpio.c
-@@ -20,6 +20,8 @@
- #include <bcm63xx_gpio.h>
- #include <bcm63xx_regs.h>
-+#include "boards/board_common.h"
-+
- /* for registering lookups; make them large enough to hold OF names */
- static char *gpio_chip_labels[] = {
-       "xxxxxxxx.gpio-controller",
-@@ -49,9 +51,17 @@ static void __init bcm63xx_gpio_init_one
-       pdata.base = id * 32;
-       pdata.ngpio = ngpio;
--      sprintf(gpio_chip_labels[id], "bcm63xx-gpio.%d", id);
--      platform_device_register_resndata(NULL, "bcm63xx-gpio", id, res, 2,
--                                        &pdata, sizeof(pdata));
-+      if (board_of_device_present("gpio0")) {
-+              unsigned long base = res[0].start;
-+
-+              if (base < 0xf0000000U)
-+                      base = CPHYSADDR(base);
-+              sprintf(gpio_chip_labels[id], "%lx.gpio-controller", base);
-+      } else {
-+              sprintf(gpio_chip_labels[id], "bcm63xx-gpio.%d", id);
-+              platform_device_register_resndata(NULL, "bcm63xx-gpio", id, res,
-+                                                2, &pdata, sizeof(pdata));
-+      }
- }
- int __init bcm63xx_gpio_init(void)
diff --git a/target/linux/brcm63xx/patches-3.14/378-MIPS-BCM63XX-do-not-register-gpio-controller-if-pres.patch b/target/linux/brcm63xx/patches-3.14/378-MIPS-BCM63XX-do-not-register-gpio-controller-if-pres.patch
new file mode 100644 (file)
index 0000000..2faf0de
--- /dev/null
@@ -0,0 +1,34 @@
+From e55892aac9d5508a000647ca66f0e678e02be3bb Mon Sep 17 00:00:00 2001
+From: Jonas Gorski <jogo@openwrt.org>
+Date: Sat, 21 Feb 2015 17:26:50 +0100
+Subject: [PATCH 5/6] MIPS: BCM63XX: do not register gpio-controller if
+present in dtb
+
+Signed-off-by: Jonas Gorski <jogo@openwrt.org>
+---
+ arch/mips/bcm63xx/gpio.c |   7 +++++--
+ 1 file changed, 5 insertions(+), 2 deletions(-)
+
+--- a/arch/mips/bcm63xx/gpio.c
++++ b/arch/mips/bcm63xx/gpio.c
+@@ -20,6 +20,8 @@
+ #include <bcm63xx_gpio.h>
+ #include <bcm63xx_regs.h>
++#include "boards/board_common.h"
++
+ /* for registering lookups; make them large enough to hold OF names */
+ static char *gpio_chip_labels[] = {
+       "xxxxxxxx.gpio-controller",
+@@ -50,8 +52,9 @@ static void __init bcm63xx_gpio_init_one
+       pdata.ngpio = ngpio;
+       sprintf(gpio_chip_labels[id], "bcm63xx-gpio.%d", id);
+-      platform_device_register_resndata(NULL, "bcm63xx-gpio", id, res, 2,
+-                                        &pdata, sizeof(pdata));
++      if (!board_of_device_present("gpio0"))
++              platform_device_register_resndata(NULL, "bcm63xx-gpio", id, res,
++                                                2, &pdata, sizeof(pdata));
+ }
+ int __init bcm63xx_gpio_init(void)
index b4013bbd4a258e9c8441d8bc6103a49d841834eb..3a203c2409240890e74a8054a487c9b37c6b65e2 100644 (file)
@@ -1,6 +1,6 @@
 --- a/arch/mips/bcm63xx/boards/board_bcm963xx.c
 +++ b/arch/mips/bcm63xx/boards/board_bcm963xx.c
-@@ -2132,6 +2132,48 @@
+@@ -2132,6 +2132,48 @@ static struct board_info __initdata boar
        .has_ehci0 = 1,
  };
  
@@ -49,7 +49,7 @@
  static struct sprom_fixup __initdata vr3025u_fixups[] = {
        { .offset = 97, .value = 0xfeb3 },
        { .offset = 98, .value = 0x1618 },
-@@ -2723,6 +2765,7 @@
+@@ -2723,6 +2765,7 @@ static const struct board_info __initcon
  #ifdef CONFIG_BCM63XX_CPU_6368
        &board_96368mvwg,
        &board_96368mvngr,
@@ -57,7 +57,7 @@
        &board_P870HW51A_V2,
        &board_VR3025u,
        &board_VR3025un,
-@@ -2813,6 +2856,7 @@
+@@ -2813,6 +2856,7 @@ static struct of_device_id const bcm963x
        { .compatible = "comtrend,vr-3025u", .data = &board_VR3025u, },
        { .compatible = "comtrend,vr-3025un", .data = &board_VR3025un, },
        { .compatible = "comtrend,wap-5813n", .data = &board_WAP5813n, },
index 53fcb8a3f5cc8c7ed347f0a24cce18eb53c9f2c4..3e53c80606e0e35171146321f06ea347d0964be6 100644 (file)
@@ -8,8 +8,8 @@ Signed-off-by: Jonas Gorski <jogo@openwrt.org>
 ---
  drivers/gpio/Kconfig        |    8 +++
  drivers/gpio/Makefile       |    1 +
- drivers/gpio/gpio-bcm63xx.c |  117 +++++++++++++++++++++++++++++++++++++++++++
- 3 files changed, 126 insertions(+)
+ drivers/gpio/gpio-bcm63xx.c |  122 +++++++++++++++++++++++++++++++++++++++++++
+ 3 files changed, 131 insertions(+)
  create mode 100644 drivers/gpio/gpio-bcm63xx.c
 
 --- a/drivers/gpio/Kconfig
@@ -41,7 +41,7 @@ Signed-off-by: Jonas Gorski <jogo@openwrt.org>
  obj-$(CONFIG_GPIO_CS5535)     += gpio-cs5535.o
 --- /dev/null
 +++ b/drivers/gpio/gpio-bcm63xx.c
-@@ -0,0 +1,117 @@
+@@ -0,0 +1,122 @@
 +/*
 + * Driver for BCM63XX memory-mapped GPIO controllers, based on
 + * Generic driver for memory-mapped GPIO controllers.
@@ -117,8 +117,13 @@ Signed-off-by: Jonas Gorski <jogo@openwrt.org>
 +      platform_set_drvdata(pdev, bgc);
 +
 +      if (dev->of_node) {
++              int id = of_alias_get_id(dev->of_node, "gpio");
 +              u32 ngpios;
 +
++              if (id >= 0)
++                      bgc->gc.label = devm_kasprintf(dev, GFP_KERNEL,
++                                                     "bcm63xx-gpio.%d", id);
++
 +              if (!of_property_read_u32(dev->of_node, "ngpios", &ngpios))
 +                      bgc->gc.ngpio = ngpios;
 +
diff --git a/target/linux/brcm63xx/patches-3.18/378-MIPS-BCM63XX-calculate-labels-for-DT-registered-cont.patch b/target/linux/brcm63xx/patches-3.18/378-MIPS-BCM63XX-calculate-labels-for-DT-registered-cont.patch
deleted file mode 100644 (file)
index 40f9e6d..0000000
+++ /dev/null
@@ -1,44 +0,0 @@
-From e55892aac9d5508a000647ca66f0e678e02be3bb Mon Sep 17 00:00:00 2001
-From: Jonas Gorski <jogo@openwrt.org>
-Date: Sat, 21 Feb 2015 17:26:50 +0100
-Subject: [PATCH 5/6] MIPS: BCM63XX: calculate labels for DT registered
- controllers
-
-
-Signed-off-by: Jonas Gorski <jogo@openwrt.org>
----
- arch/mips/bcm63xx/gpio.c |   16 +++++++++++++---
- 1 file changed, 13 insertions(+), 3 deletions(-)
-
---- a/arch/mips/bcm63xx/gpio.c
-+++ b/arch/mips/bcm63xx/gpio.c
-@@ -20,6 +20,8 @@
- #include <bcm63xx_gpio.h>
- #include <bcm63xx_regs.h>
-+#include "boards/board_common.h"
-+
- /* for registering lookups; make them large enough to hold OF names */
- static char *gpio_chip_labels[] = {
-       "xxxxxxxx.gpio-controller",
-@@ -49,9 +51,17 @@ static void __init bcm63xx_gpio_init_one
-       pdata.base = id * 32;
-       pdata.ngpio = ngpio;
--      sprintf(gpio_chip_labels[id], "bcm63xx-gpio.%d", id);
--      platform_device_register_resndata(NULL, "bcm63xx-gpio", id, res, 2,
--                                        &pdata, sizeof(pdata));
-+      if (board_of_device_present("gpio0")) {
-+              unsigned long base = res[0].start;
-+
-+              if (base < 0xf0000000U)
-+                      base = CPHYSADDR(base);
-+              sprintf(gpio_chip_labels[id], "%lx.gpio-controller", base);
-+      } else {
-+              sprintf(gpio_chip_labels[id], "bcm63xx-gpio.%d", id);
-+              platform_device_register_resndata(NULL, "bcm63xx-gpio", id, res,
-+                                                2, &pdata, sizeof(pdata));
-+      }
- }
- int __init bcm63xx_gpio_init(void)
diff --git a/target/linux/brcm63xx/patches-3.18/378-MIPS-BCM63XX-do-not-register-gpio-controller-if-pres.patch b/target/linux/brcm63xx/patches-3.18/378-MIPS-BCM63XX-do-not-register-gpio-controller-if-pres.patch
new file mode 100644 (file)
index 0000000..2faf0de
--- /dev/null
@@ -0,0 +1,34 @@
+From e55892aac9d5508a000647ca66f0e678e02be3bb Mon Sep 17 00:00:00 2001
+From: Jonas Gorski <jogo@openwrt.org>
+Date: Sat, 21 Feb 2015 17:26:50 +0100
+Subject: [PATCH 5/6] MIPS: BCM63XX: do not register gpio-controller if
+present in dtb
+
+Signed-off-by: Jonas Gorski <jogo@openwrt.org>
+---
+ arch/mips/bcm63xx/gpio.c |   7 +++++--
+ 1 file changed, 5 insertions(+), 2 deletions(-)
+
+--- a/arch/mips/bcm63xx/gpio.c
++++ b/arch/mips/bcm63xx/gpio.c
+@@ -20,6 +20,8 @@
+ #include <bcm63xx_gpio.h>
+ #include <bcm63xx_regs.h>
++#include "boards/board_common.h"
++
+ /* for registering lookups; make them large enough to hold OF names */
+ static char *gpio_chip_labels[] = {
+       "xxxxxxxx.gpio-controller",
+@@ -50,8 +52,9 @@ static void __init bcm63xx_gpio_init_one
+       pdata.ngpio = ngpio;
+       sprintf(gpio_chip_labels[id], "bcm63xx-gpio.%d", id);
+-      platform_device_register_resndata(NULL, "bcm63xx-gpio", id, res, 2,
+-                                        &pdata, sizeof(pdata));
++      if (!board_of_device_present("gpio0"))
++              platform_device_register_resndata(NULL, "bcm63xx-gpio", id, res,
++                                                2, &pdata, sizeof(pdata));
+ }
+ int __init bcm63xx_gpio_init(void)
index b4013bbd4a258e9c8441d8bc6103a49d841834eb..3a203c2409240890e74a8054a487c9b37c6b65e2 100644 (file)
@@ -1,6 +1,6 @@
 --- a/arch/mips/bcm63xx/boards/board_bcm963xx.c
 +++ b/arch/mips/bcm63xx/boards/board_bcm963xx.c
-@@ -2132,6 +2132,48 @@
+@@ -2132,6 +2132,48 @@ static struct board_info __initdata boar
        .has_ehci0 = 1,
  };
  
@@ -49,7 +49,7 @@
  static struct sprom_fixup __initdata vr3025u_fixups[] = {
        { .offset = 97, .value = 0xfeb3 },
        { .offset = 98, .value = 0x1618 },
-@@ -2723,6 +2765,7 @@
+@@ -2723,6 +2765,7 @@ static const struct board_info __initcon
  #ifdef CONFIG_BCM63XX_CPU_6368
        &board_96368mvwg,
        &board_96368mvngr,
@@ -57,7 +57,7 @@
        &board_P870HW51A_V2,
        &board_VR3025u,
        &board_VR3025un,
-@@ -2813,6 +2856,7 @@
+@@ -2813,6 +2856,7 @@ static struct of_device_id const bcm963x
        { .compatible = "comtrend,vr-3025u", .data = &board_VR3025u, },
        { .compatible = "comtrend,vr-3025un", .data = &board_VR3025un, },
        { .compatible = "comtrend,wap-5813n", .data = &board_WAP5813n, },