15 #include <linux/kernel.h>
17 #include <linux/module.h>
18 #include <linux/types.h>
28 static void __iomem *ath79_gpio_base;
29 static unsigned long ath79_gpio_count;
32 static void __ath79_gpio_set_value(
unsigned gpio,
int value)
42 static int __ath79_gpio_get_value(
unsigned gpio)
47 static int ath79_gpio_get_value(
struct gpio_chip *
chip,
unsigned offset)
49 return __ath79_gpio_get_value(offset);
52 static void ath79_gpio_set_value(
struct gpio_chip *
chip,
53 unsigned offset,
int value)
55 __ath79_gpio_set_value(offset, value);
58 static int ath79_gpio_direction_input(
struct gpio_chip *
chip,
61 void __iomem *base = ath79_gpio_base;
69 spin_unlock_irqrestore(&ath79_gpio_lock, flags);
74 static int ath79_gpio_direction_output(
struct gpio_chip *chip,
75 unsigned offset,
int value)
77 void __iomem *base = ath79_gpio_base;
90 spin_unlock_irqrestore(&ath79_gpio_lock, flags);
95 static int ar934x_gpio_direction_input(
struct gpio_chip *chip,
unsigned offset)
97 void __iomem *base = ath79_gpio_base;
105 spin_unlock_irqrestore(&ath79_gpio_lock, flags);
110 static int ar934x_gpio_direction_output(
struct gpio_chip *chip,
unsigned offset,
113 void __iomem *base = ath79_gpio_base;
126 spin_unlock_irqrestore(&ath79_gpio_lock, flags);
131 static struct gpio_chip ath79_gpio_chip = {
133 .get = ath79_gpio_get_value,
134 .set = ath79_gpio_set_value,
135 .direction_input = ath79_gpio_direction_input,
136 .direction_output = ath79_gpio_direction_output,
142 void __iomem *base = ath79_gpio_base;
152 spin_unlock_irqrestore(&ath79_gpio_lock, flags);
157 void __iomem *base = ath79_gpio_base;
167 spin_unlock_irqrestore(&ath79_gpio_lock, flags);
172 void __iomem *base = ath79_gpio_base;
182 spin_unlock_irqrestore(&ath79_gpio_lock, flags);
191 else if (soc_is_ar7240())
193 else if (soc_is_ar7241() || soc_is_ar7242())
195 else if (soc_is_ar913x())
197 else if (soc_is_ar933x())
199 else if (soc_is_ar934x())
205 ath79_gpio_chip.ngpio = ath79_gpio_count;
206 if (soc_is_ar934x()) {
207 ath79_gpio_chip.direction_input = ar934x_gpio_direction_input;
208 ath79_gpio_chip.direction_output = ar934x_gpio_direction_output;
213 panic(
"cannot add AR71xx GPIO chip, error=%d", err);
218 if (gpio < ath79_gpio_count)
219 return __ath79_gpio_get_value(gpio);
227 if (gpio < ath79_gpio_count)
228 __ath79_gpio_set_value(gpio, value);