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;
"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);
#define GPIO_FUNC_USB_CLK_EN BIT(0)
#define AR71XX_GPIO_COUNT 16
+#define AR91XX_GPIO_COUNT 22
extern void __iomem *ar71xx_gpio_base;
#include <asm/mach-ar71xx/ar71xx.h>
+extern unsigned long ar71xx_gpio_count;
extern void __ar71xx_gpio_set_value(unsigned gpio, int value);
extern int __ar71xx_gpio_get_value(unsigned gpio);
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);
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);