brcm63xx: use consistent gpio chip labeling for OF/non-OF
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
This commit is contained in:
parent
e1a8e41287
commit
343ec8d645
6 changed files with 36 additions and 46 deletions
|
@ -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;
|
||||
+
|
||||
|
|
|
@ -1,14 +1,13 @@
|
|||
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
|
||||
|
||||
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 | 16 +++++++++++++---
|
||||
1 file changed, 13 insertions(+), 3 deletions(-)
|
||||
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
|
||||
|
@ -21,24 +20,15 @@ Signed-off-by: Jonas Gorski <jogo@openwrt.org>
|
|||
/* 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;
|
||||
@@ -50,8 +52,9 @@ static void __init bcm63xx_gpio_init_one
|
||||
pdata.ngpio = ngpio;
|
||||
|
||||
- sprintf(gpio_chip_labels[id], "bcm63xx-gpio.%d", id);
|
||||
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);
|
||||
+ 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)
|
|
@ -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, },
|
||||
|
|
|
@ -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;
|
||||
+
|
||||
|
|
|
@ -1,14 +1,13 @@
|
|||
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
|
||||
|
||||
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 | 16 +++++++++++++---
|
||||
1 file changed, 13 insertions(+), 3 deletions(-)
|
||||
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
|
||||
|
@ -21,24 +20,15 @@ Signed-off-by: Jonas Gorski <jogo@openwrt.org>
|
|||
/* 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;
|
||||
@@ -50,8 +52,9 @@ static void __init bcm63xx_gpio_init_one
|
||||
pdata.ngpio = ngpio;
|
||||
|
||||
- sprintf(gpio_chip_labels[id], "bcm63xx-gpio.%d", id);
|
||||
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);
|
||||
+ 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)
|
|
@ -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, },
|
||||
|
|
Loading…
Reference in a new issue