Haavard Skinnemoen | 6a4e522 | 2007-02-05 16:57:13 +0100 | [diff] [blame] | 1 | #ifndef __ASM_AVR32_ARCH_GPIO_H |
| 2 | #define __ASM_AVR32_ARCH_GPIO_H |
| 3 | |
| 4 | #include <linux/compiler.h> |
| 5 | #include <asm/irq.h> |
| 6 | |
| 7 | |
David Brownell | b98348b | 2008-02-04 22:28:28 -0800 | [diff] [blame] | 8 | /* Some GPIO chips can manage IRQs; some can't. The exact numbers can |
| 9 | * be changed if needed, but for the moment they're not configurable. |
| 10 | */ |
| 11 | #define ARCH_NR_GPIOS (NR_GPIO_IRQS + 2 * 32) |
Haavard Skinnemoen | 6a4e522 | 2007-02-05 16:57:13 +0100 | [diff] [blame] | 12 | |
Haavard Skinnemoen | 6a4e522 | 2007-02-05 16:57:13 +0100 | [diff] [blame] | 13 | |
David Brownell | b98348b | 2008-02-04 22:28:28 -0800 | [diff] [blame] | 14 | /* Arch-neutral GPIO API, supporting both "native" and external GPIOs. */ |
| 15 | #include <asm-generic/gpio.h> |
| 16 | |
| 17 | static inline int gpio_get_value(unsigned int gpio) |
| 18 | { |
| 19 | return __gpio_get_value(gpio); |
| 20 | } |
| 21 | |
| 22 | static inline void gpio_set_value(unsigned int gpio, int value) |
| 23 | { |
| 24 | __gpio_set_value(gpio, value); |
| 25 | } |
| 26 | |
| 27 | static inline int gpio_cansleep(unsigned int gpio) |
| 28 | { |
| 29 | return __gpio_cansleep(gpio); |
| 30 | } |
| 31 | |
David Brownell | 2ae795b | 2007-05-24 13:52:08 -0700 | [diff] [blame] | 32 | |
Haavard Skinnemoen | 6a4e522 | 2007-02-05 16:57:13 +0100 | [diff] [blame] | 33 | static inline int gpio_to_irq(unsigned int gpio) |
| 34 | { |
David Brownell | b98348b | 2008-02-04 22:28:28 -0800 | [diff] [blame] | 35 | if (gpio < NR_GPIO_IRQS) |
| 36 | return gpio + GPIO_IRQ_BASE; |
| 37 | return -EINVAL; |
Haavard Skinnemoen | 6a4e522 | 2007-02-05 16:57:13 +0100 | [diff] [blame] | 38 | } |
| 39 | |
| 40 | static inline int irq_to_gpio(unsigned int irq) |
| 41 | { |
| 42 | return irq - GPIO_IRQ_BASE; |
| 43 | } |
| 44 | |
| 45 | #endif /* __ASM_AVR32_ARCH_GPIO_H */ |