aboutsummaryrefslogtreecommitdiffstats
path: root/target/linux/brcm2708/patches-3.10/0193-bcm2708_gpio-make-room-for-additional-GPIO-chips.patch
blob: a27068264d4208b2a7d9234fffcc776bb3afb55e (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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
From a3d6a8b1bd041e8428b8cd1edeed8fe9259e54b1 Mon Sep 17 00:00:00 2001
From: notro <notro@tronnes.org>
Date: Sun, 20 Apr 2014 18:55:24 +0200
Subject: [PATCH 193/196] bcm2708_gpio: make room for additional GPIO chips

ARCH_NR_GPIOS is set to 54, and all is used by the onboard gpio controller.
This makes no room for additional gpio controllers to be added.

ARCH_NR_GPIOS limits how many gpios that can be used on a platform.
From gpiolib.c:
static struct gpio_desc gpio_desc[ARCH_NR_GPIOS];

Lift this restraint by using the default value for ARCH_NR_GPIOS, which is 256,
and make a new macro for the on-chip number of gpios.

Signed-off-by: Noralf Tronnes <notro@tronnes.org>
---
 arch/arm/mach-bcm2708/bcm2708_gpio.c      | 8 ++++----
 arch/arm/mach-bcm2708/include/mach/gpio.h | 2 +-
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/arch/arm/mach-bcm2708/bcm2708_gpio.c b/arch/arm/mach-bcm2708/bcm2708_gpio.c
index bab8a49..120929ff 100644
--- a/arch/arm/mach-bcm2708/bcm2708_gpio.c
+++ b/arch/arm/mach-bcm2708/bcm2708_gpio.c
@@ -72,7 +72,7 @@ static int bcm2708_set_function(struct gpio_chip *gc, unsigned offset,
 	unsigned gpio_field_offset = (offset - 10 * gpio_bank) * 3;
 
 //printk(KERN_ERR DRIVER_NAME ": bcm2708_gpio_set_function %p (%d,%d)\n", gc, offset, function);
-	if (offset >= ARCH_NR_GPIOS)
+	if (offset >= BCM2708_NR_GPIOS)
 		return -EINVAL;
 
 	spin_lock_irqsave(&lock, flags);
@@ -110,7 +110,7 @@ static int bcm2708_gpio_get(struct gpio_chip *gc, unsigned offset)
 	unsigned gpio_field_offset = (offset - 32 * gpio_bank);
 	unsigned lev;
 
-	if (offset >= ARCH_NR_GPIOS)
+	if (offset >= BCM2708_NR_GPIOS)
 		return 0;
 	lev = readl(gpio->base + GPIOLEV(gpio_bank));
 //printk(KERN_ERR DRIVER_NAME ": bcm2708_gpio_get %p (%d)=%d\n", gc, offset, 0x1 & (lev>>gpio_field_offset));
@@ -123,7 +123,7 @@ static void bcm2708_gpio_set(struct gpio_chip *gc, unsigned offset, int value)
 	unsigned gpio_bank = offset / 32;
 	unsigned gpio_field_offset = (offset - 32 * gpio_bank);
 //printk(KERN_ERR DRIVER_NAME ": bcm2708_gpio_set %p (%d=%d)\n", gc, offset, value);
-	if (offset >= ARCH_NR_GPIOS)
+	if (offset >= BCM2708_NR_GPIOS)
 		return;
 	if (value)
 		writel(1 << gpio_field_offset, gpio->base + GPIOSET(gpio_bank));
@@ -302,7 +302,7 @@ static int bcm2708_gpio_probe(struct platform_device *dev)
 
 	ucb->gc.label = "bcm2708_gpio";
 	ucb->gc.base = 0;
-	ucb->gc.ngpio = ARCH_NR_GPIOS;
+	ucb->gc.ngpio = BCM2708_NR_GPIOS;
 	ucb->gc.owner = THIS_MODULE;
 
 	ucb->gc.direction_input = bcm2708_gpio_dir_in;
diff --git a/arch/arm/mach-bcm2708/include/mach/gpio.h b/arch/arm/mach-bcm2708/include/mach/gpio.h
index f600bc7..d8b3a90 100644
--- a/arch/arm/mach-bcm2708/include/mach/gpio.h
+++ b/arch/arm/mach-bcm2708/include/mach/gpio.h
@@ -9,7 +9,7 @@
 #ifndef __ASM_ARCH_GPIO_H
 #define __ASM_ARCH_GPIO_H
 
-#define ARCH_NR_GPIOS 54 // number of gpio lines
+#define BCM2708_NR_GPIOS 54 // number of gpio lines
 
 #define gpio_to_irq(x)	((x) + GPIO_IRQ_START)
 #define irq_to_gpio(x)	((x) - GPIO_IRQ_START)
-- 
1.9.1