5be625a9aea09ac1bf69387508d0a492b366428a
[openwrt.git] / target / linux / brcm63xx / patches-3.18 / 379-gpio-gpio-bcm63xx-use-alias-id-for-base-calculation.patch
1 From 6759a62f28bb1995afe6562c0adfbbb6e8540933 Mon Sep 17 00:00:00 2001
2 From: Jonas Gorski <jogo@openwrt.org>
3 Date: Sun, 22 Feb 2015 12:57:58 +0100
4 Subject: [PATCH 6/6] gpio: gpio-bcm63xx: use alias id for base calculation
5
6 Signed-off-by: Jonas Gorski <jogo@openwrt.org>
7 ---
8  drivers/gpio/gpio-bcm63xx.c |    6 ++++++
9  1 file changed, 6 insertions(+)
10
11 --- a/drivers/gpio/gpio-bcm63xx.c
12 +++ b/drivers/gpio/gpio-bcm63xx.c
13 @@ -32,6 +32,8 @@
14  #include <linux/of.h>
15  #include <linux/of_gpio.h>
16  
17 +#define BCM63XX_GPIOS_PER_BANK 32
18 +
19  static int bcm63xx_gpio_probe(struct platform_device *pdev)
20  {
21         struct device *dev = &pdev->dev;
22 @@ -73,8 +75,12 @@ static int bcm63xx_gpio_probe(struct pla
23         platform_set_drvdata(pdev, bgc);
24  
25         if (dev->of_node) {
26 +               int id = of_alias_get_id(dev->of_node, "gpio");
27                 u32 ngpios;
28  
29 +               if (id >= 0)
30 +                       bgc->gc.base = id * BCM63XX_GPIOS_PER_BANK;
31 +
32                 if (!of_property_read_u32(dev->of_node, "ngpios", &ngpios))
33                         bgc->gc.ngpio = ngpios;
34