brcm63xx: probe gpio controllers through DT
[openwrt/svn-archive/archive.git] / target / linux / brcm63xx / patches-3.14 / 378-MIPS-BCM63XX-calculate-labels-for-DT-registered-cont.patch
1 From e55892aac9d5508a000647ca66f0e678e02be3bb Mon Sep 17 00:00:00 2001
2 From: Jonas Gorski <jogo@openwrt.org>
3 Date: Sat, 21 Feb 2015 17:26:50 +0100
4 Subject: [PATCH 5/6] MIPS: BCM63XX: calculate labels for DT registered
5 controllers
6
7
8 Signed-off-by: Jonas Gorski <jogo@openwrt.org>
9 ---
10 arch/mips/bcm63xx/gpio.c | 16 +++++++++++++---
11 1 file changed, 13 insertions(+), 3 deletions(-)
12
13 diff --git a/arch/mips/bcm63xx/gpio.c b/arch/mips/bcm63xx/gpio.c
14 index 70cd05b..cf0b819 100644
15 --- a/arch/mips/bcm63xx/gpio.c
16 +++ b/arch/mips/bcm63xx/gpio.c
17 @@ -20,6 +20,8 @@
18 #include <bcm63xx_gpio.h>
19 #include <bcm63xx_regs.h>
20
21 +#include "boards/board_common.h"
22 +
23 /* for registering lookups; make them large enough to hold OF names */
24 static char *gpio_chip_labels[] = {
25 "xxxxxxxx.gpio-controller",
26 @@ -49,9 +51,17 @@ static void __init bcm63xx_gpio_init_one(int id, int dir, int data, int ngpio)
27 pdata.base = id * 32;
28 pdata.ngpio = ngpio;
29
30 - sprintf(gpio_chip_labels[id], "bcm63xx-gpio.%d", id);
31 - platform_device_register_resndata(NULL, "bcm63xx-gpio", id, res, 2,
32 - &pdata, sizeof(pdata));
33 + if (board_of_device_present("gpio0")) {
34 + unsigned long base = res[0].start;
35 +
36 + if (base < 0xf0000000U)
37 + base = CPHYSADDR(base);
38 + sprintf(gpio_chip_labels[id], "%lx.gpio-controller", base);
39 + } else {
40 + sprintf(gpio_chip_labels[id], "bcm63xx-gpio.%d", id);
41 + platform_device_register_resndata(NULL, "bcm63xx-gpio", id, res,
42 + 2, &pdata, sizeof(pdata));
43 + }
44 }
45
46 int __init bcm63xx_gpio_init(void)
47 --
48 1.7.10.4
49