From b80c50f7cfaf56f2d6587caa7dbdba87cce83293 Mon Sep 17 00:00:00 2001 From: juhosg Date: Thu, 4 Dec 2008 12:17:14 +0000 Subject: [PATCH] [ar71xx] make all AR913x GPIO lines usable git-svn-id: svn://svn.openwrt.org/openwrt/trunk@13509 3c298f89-4303-0410-b956-a3cf2f4a3e73 --- .../ar71xx/files/arch/mips/ar71xx/gpio.c | 19 +++++++++++++++++++ .../include/asm-mips/mach-ar71xx/ar71xx.h | 1 + .../files/include/asm-mips/mach-ar71xx/gpio.h | 5 +++-- 3 files changed, 23 insertions(+), 2 deletions(-) diff --git a/target/linux/ar71xx/files/arch/mips/ar71xx/gpio.c b/target/linux/ar71xx/files/arch/mips/ar71xx/gpio.c index 03bf38b7c..a3d00aeed 100644 --- a/target/linux/ar71xx/files/arch/mips/ar71xx/gpio.c +++ b/target/linux/ar71xx/files/arch/mips/ar71xx/gpio.c @@ -22,6 +22,9 @@ static DEFINE_SPINLOCK(ar71xx_gpio_lock); +unsigned long ar71xx_gpio_count; +EXPORT_SYMBOL(ar71xx_gpio_count); + void __ar71xx_gpio_set_value(unsigned gpio, int value) { unsigned long flags; @@ -129,6 +132,22 @@ void __init ar71xx_gpio_init(void) "AR71xx GPIO controller")) panic("cannot allocate AR71xx GPIO registers page"); + switch (ar71xx_soc) { + case AR71XX_SOC_AR7130: + case AR71XX_SOC_AR7141: + case AR71XX_SOC_AR7161: + ar71xx_gpio_chip.ngpio = AR71XX_GPIO_COUNT; + break; + + case AR71XX_SOC_AR9130: + case AR71XX_SOC_AR9132: + ar71xx_gpio_chip.ngpio = AR91XX_GPIO_COUNT; + break; + + default: + BUG(); + } + err = gpiochip_add(&ar71xx_gpio_chip); if (err) panic("cannot add AR71xx GPIO chip, error=%d", err); diff --git a/target/linux/ar71xx/files/include/asm-mips/mach-ar71xx/ar71xx.h b/target/linux/ar71xx/files/include/asm-mips/mach-ar71xx/ar71xx.h index 78cf1ca24..5e551a14f 100644 --- a/target/linux/ar71xx/files/include/asm-mips/mach-ar71xx/ar71xx.h +++ b/target/linux/ar71xx/files/include/asm-mips/mach-ar71xx/ar71xx.h @@ -206,6 +206,7 @@ extern void ar71xx_add_device_usb(void) __init; #define GPIO_FUNC_USB_CLK_EN BIT(0) #define AR71XX_GPIO_COUNT 16 +#define AR91XX_GPIO_COUNT 22 extern void __iomem *ar71xx_gpio_base; diff --git a/target/linux/ar71xx/files/include/asm-mips/mach-ar71xx/gpio.h b/target/linux/ar71xx/files/include/asm-mips/mach-ar71xx/gpio.h index 347727001..6354d68cf 100644 --- a/target/linux/ar71xx/files/include/asm-mips/mach-ar71xx/gpio.h +++ b/target/linux/ar71xx/files/include/asm-mips/mach-ar71xx/gpio.h @@ -18,6 +18,7 @@ #include +extern unsigned long ar71xx_gpio_count; extern void __ar71xx_gpio_set_value(unsigned gpio, int value); extern int __ar71xx_gpio_get_value(unsigned gpio); @@ -33,7 +34,7 @@ static inline int irq_to_gpio(unsigned irq) static inline int gpio_get_value(unsigned gpio) { - if (gpio < AR71XX_GPIO_COUNT) + if (gpio < ar71xx_gpio_count) return __ar71xx_gpio_get_value(gpio); return __gpio_get_value(gpio); @@ -41,7 +42,7 @@ static inline int gpio_get_value(unsigned gpio) static inline void gpio_set_value(unsigned gpio, int value) { - if (gpio < AR71XX_GPIO_COUNT) + if (gpio < ar71xx_gpio_count) __ar71xx_gpio_set_value(gpio, value); else __gpio_set_value(gpio, value);