1 From a3d6a8b1bd041e8428b8cd1edeed8fe9259e54b1 Mon Sep 17 00:00:00 2001
2 From: notro <notro@tronnes.org>
3 Date: Sun, 20 Apr 2014 18:55:24 +0200
4 Subject: [PATCH 193/196] bcm2708_gpio: make room for additional GPIO chips
6 ARCH_NR_GPIOS is set to 54, and all is used by the onboard gpio controller.
7 This makes no room for additional gpio controllers to be added.
9 ARCH_NR_GPIOS limits how many gpios that can be used on a platform.
11 static struct gpio_desc gpio_desc[ARCH_NR_GPIOS];
13 Lift this restraint by using the default value for ARCH_NR_GPIOS, which is 256,
14 and make a new macro for the on-chip number of gpios.
16 Signed-off-by: Noralf Tronnes <notro@tronnes.org>
18 arch/arm/mach-bcm2708/bcm2708_gpio.c | 8 ++++----
19 arch/arm/mach-bcm2708/include/mach/gpio.h | 2 +-
20 2 files changed, 5 insertions(+), 5 deletions(-)
22 diff --git a/arch/arm/mach-bcm2708/bcm2708_gpio.c b/arch/arm/mach-bcm2708/bcm2708_gpio.c
23 index bab8a49..120929ff 100644
24 --- a/arch/arm/mach-bcm2708/bcm2708_gpio.c
25 +++ b/arch/arm/mach-bcm2708/bcm2708_gpio.c
26 @@ -72,7 +72,7 @@ static int bcm2708_set_function(struct gpio_chip *gc, unsigned offset,
27 unsigned gpio_field_offset = (offset - 10 * gpio_bank) * 3;
29 //printk(KERN_ERR DRIVER_NAME ": bcm2708_gpio_set_function %p (%d,%d)\n", gc, offset, function);
30 - if (offset >= ARCH_NR_GPIOS)
31 + if (offset >= BCM2708_NR_GPIOS)
34 spin_lock_irqsave(&lock, flags);
35 @@ -110,7 +110,7 @@ static int bcm2708_gpio_get(struct gpio_chip *gc, unsigned offset)
36 unsigned gpio_field_offset = (offset - 32 * gpio_bank);
39 - if (offset >= ARCH_NR_GPIOS)
40 + if (offset >= BCM2708_NR_GPIOS)
42 lev = readl(gpio->base + GPIOLEV(gpio_bank));
43 //printk(KERN_ERR DRIVER_NAME ": bcm2708_gpio_get %p (%d)=%d\n", gc, offset, 0x1 & (lev>>gpio_field_offset));
44 @@ -123,7 +123,7 @@ static void bcm2708_gpio_set(struct gpio_chip *gc, unsigned offset, int value)
45 unsigned gpio_bank = offset / 32;
46 unsigned gpio_field_offset = (offset - 32 * gpio_bank);
47 //printk(KERN_ERR DRIVER_NAME ": bcm2708_gpio_set %p (%d=%d)\n", gc, offset, value);
48 - if (offset >= ARCH_NR_GPIOS)
49 + if (offset >= BCM2708_NR_GPIOS)
52 writel(1 << gpio_field_offset, gpio->base + GPIOSET(gpio_bank));
53 @@ -302,7 +302,7 @@ static int bcm2708_gpio_probe(struct platform_device *dev)
55 ucb->gc.label = "bcm2708_gpio";
57 - ucb->gc.ngpio = ARCH_NR_GPIOS;
58 + ucb->gc.ngpio = BCM2708_NR_GPIOS;
59 ucb->gc.owner = THIS_MODULE;
61 ucb->gc.direction_input = bcm2708_gpio_dir_in;
62 diff --git a/arch/arm/mach-bcm2708/include/mach/gpio.h b/arch/arm/mach-bcm2708/include/mach/gpio.h
63 index f600bc7..d8b3a90 100644
64 --- a/arch/arm/mach-bcm2708/include/mach/gpio.h
65 +++ b/arch/arm/mach-bcm2708/include/mach/gpio.h
67 #ifndef __ASM_ARCH_GPIO_H
68 #define __ASM_ARCH_GPIO_H
70 -#define ARCH_NR_GPIOS 54 // number of gpio lines
71 +#define BCM2708_NR_GPIOS 54 // number of gpio lines
73 #define gpio_to_irq(x) ((x) + GPIO_IRQ_START)
74 #define irq_to_gpio(x) ((x) - GPIO_IRQ_START)