Skip to content

Commit 6c36711

Browse files
notropopcornmix
authored andcommitted
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>
1 parent 8161cdb commit 6c36711

2 files changed

Lines changed: 5 additions & 5 deletions

File tree

‎arch/arm/mach-bcm2708/bcm2708_gpio.c‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ static int bcm2708_set_function(struct gpio_chip *gc, unsigned offset,
7272
unsigned gpio_field_offset = (offset - 10 * gpio_bank) * 3;
7373

7474
//printk(KERN_ERR DRIVER_NAME ": bcm2708_gpio_set_function %p (%d,%d)\n", gc, offset, function);
75-
if (offset >= ARCH_NR_GPIOS)
75+
if (offset >= BCM2708_NR_GPIOS)
7676
return -EINVAL;
7777

7878
spin_lock_irqsave(&lock, flags);
@@ -110,7 +110,7 @@ static int bcm2708_gpio_get(struct gpio_chip *gc, unsigned offset)
110110
unsigned gpio_field_offset = (offset - 32 * gpio_bank);
111111
unsigned lev;
112112

113-
if (offset >= ARCH_NR_GPIOS)
113+
if (offset >= BCM2708_NR_GPIOS)
114114
return 0;
115115
lev = readl(gpio->base + GPIOLEV(gpio_bank));
116116
//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)
123123
unsigned gpio_bank = offset / 32;
124124
unsigned gpio_field_offset = (offset - 32 * gpio_bank);
125125
//printk(KERN_ERR DRIVER_NAME ": bcm2708_gpio_set %p (%d=%d)\n", gc, offset, value);
126-
if (offset >= ARCH_NR_GPIOS)
126+
if (offset >= BCM2708_NR_GPIOS)
127127
return;
128128
if (value)
129129
writel(1 << gpio_field_offset, gpio->base + GPIOSET(gpio_bank));
@@ -302,7 +302,7 @@ static int bcm2708_gpio_probe(struct platform_device *dev)
302302

303303
ucb->gc.label = "bcm2708_gpio";
304304
ucb->gc.base = 0;
305-
ucb->gc.ngpio = ARCH_NR_GPIOS;
305+
ucb->gc.ngpio = BCM2708_NR_GPIOS;
306306
ucb->gc.owner = THIS_MODULE;
307307

308308
ucb->gc.direction_input = bcm2708_gpio_dir_in;

‎arch/arm/mach-bcm2708/include/mach/gpio.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
#ifndef __ASM_ARCH_GPIO_H
1010
#define __ASM_ARCH_GPIO_H
1111

12-
#define ARCH_NR_GPIOS 54 // number of gpio lines
12+
#define BCM2708_NR_GPIOS 54 // number of gpio lines
1313

1414
#define gpio_to_irq(x) ((x) + GPIO_IRQ_START)
1515
#define irq_to_gpio(x) ((x) - GPIO_IRQ_START)

0 commit comments

Comments
 (0)