summaryrefslogtreecommitdiff
path: root/target/linux/brcm63xx/patches-3.18/379-gpio-gpio-bcm63xx-use-alias-id-for-base-calculation.patch
blob: 5be625a9aea09ac1bf69387508d0a492b366428a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
From 6759a62f28bb1995afe6562c0adfbbb6e8540933 Mon Sep 17 00:00:00 2001
From: Jonas Gorski <jogo@openwrt.org>
Date: Sun, 22 Feb 2015 12:57:58 +0100
Subject: [PATCH 6/6] gpio: gpio-bcm63xx: use alias id for base calculation

Signed-off-by: Jonas Gorski <jogo@openwrt.org>
---
 drivers/gpio/gpio-bcm63xx.c |    6 ++++++
 1 file changed, 6 insertions(+)

--- a/drivers/gpio/gpio-bcm63xx.c
+++ b/drivers/gpio/gpio-bcm63xx.c
@@ -32,6 +32,8 @@
 #include <linux/of.h>
 #include <linux/of_gpio.h>
 
+#define BCM63XX_GPIOS_PER_BANK	32
+
 static int bcm63xx_gpio_probe(struct platform_device *pdev)
 {
 	struct device *dev = &pdev->dev;
@@ -73,8 +75,12 @@ static int bcm63xx_gpio_probe(struct pla
 	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.base = id * BCM63XX_GPIOS_PER_BANK;
+
 		if (!of_property_read_u32(dev->of_node, "ngpios", &ngpios))
 			bgc->gc.ngpio = ngpios;