From 6a4e5227a33f60f918b30cf2001fb0bb259d9396 Mon Sep 17 00:00:00 2001 From: Haavard Skinnemoen Date: Mon, 5 Feb 2007 16:57:13 +0100 Subject: [AVR32] GPIO API implementation Arch-neutral GPIO calls for AVR32. GPIO IRQ support written by David Brownell. Signed-off-by: Haavard Skinnemoen --- include/asm-avr32/arch-at32ap/gpio.h | 27 +++++++++++++++++++++++++++ include/asm-avr32/arch-at32ap/irq.h | 14 ++++++++++++++ include/asm-avr32/arch-at32ap/portmux.h | 7 ++++--- 3 files changed, 45 insertions(+), 3 deletions(-) create mode 100644 include/asm-avr32/arch-at32ap/gpio.h create mode 100644 include/asm-avr32/arch-at32ap/irq.h (limited to 'include/asm-avr32/arch-at32ap') diff --git a/include/asm-avr32/arch-at32ap/gpio.h b/include/asm-avr32/arch-at32ap/gpio.h new file mode 100644 index 00000000000..fcb756bdaa8 --- /dev/null +++ b/include/asm-avr32/arch-at32ap/gpio.h @@ -0,0 +1,27 @@ +#ifndef __ASM_AVR32_ARCH_GPIO_H +#define __ASM_AVR32_ARCH_GPIO_H + +#include +#include + + +/* Arch-neutral GPIO API */ +int __must_check gpio_request(unsigned int gpio, const char *label); +void gpio_free(unsigned int gpio); + +int gpio_direction_input(unsigned int gpio); +int gpio_direction_output(unsigned int gpio); +int gpio_get_value(unsigned int gpio); +void gpio_set_value(unsigned int gpio, int value); + +static inline int gpio_to_irq(unsigned int gpio) +{ + return gpio + GPIO_IRQ_BASE; +} + +static inline int irq_to_gpio(unsigned int irq) +{ + return irq - GPIO_IRQ_BASE; +} + +#endif /* __ASM_AVR32_ARCH_GPIO_H */ diff --git a/include/asm-avr32/arch-at32ap/irq.h b/include/asm-avr32/arch-at32ap/irq.h new file mode 100644 index 00000000000..f8f7f4571e4 --- /dev/null +++ b/include/asm-avr32/arch-at32ap/irq.h @@ -0,0 +1,14 @@ +#ifndef __ASM_AVR32_ARCH_IRQ_H +#define __ASM_AVR32_ARCH_IRQ_H + +#define EIM_IRQ_BASE NR_INTERNAL_IRQS +#define NR_EIM_IRQS 32 + +#define AT32_EXTINT(n) (EIM_IRQ_BASE + (n)) + +#define GPIO_IRQ_BASE (EIM_IRQ_BASE + NR_EIM_IRQS) +#define NR_GPIO_IRQS (4 * 32) + +#define NR_IRQS (GPIO_IRQ_BASE + NR_GPIO_IRQS) + +#endif /* __ASM_AVR32_ARCH_IRQ_H */ diff --git a/include/asm-avr32/arch-at32ap/portmux.h b/include/asm-avr32/arch-at32ap/portmux.h index 83c69057132..2ba611e0e13 100644 --- a/include/asm-avr32/arch-at32ap/portmux.h +++ b/include/asm-avr32/arch-at32ap/portmux.h @@ -15,9 +15,10 @@ * * The following flags determine the initial state of the pin. */ -#define AT32_GPIOF_PULLUP 0x00000001 /* Enable pull-up */ -#define AT32_GPIOF_OUTPUT 0x00000002 /* Enable output driver */ -#define AT32_GPIOF_HIGH 0x00000004 /* Set output high */ +#define AT32_GPIOF_PULLUP 0x00000001 /* (not-OUT) Enable pull-up */ +#define AT32_GPIOF_OUTPUT 0x00000002 /* (OUT) Enable output driver */ +#define AT32_GPIOF_HIGH 0x00000004 /* (OUT) Set output high */ +#define AT32_GPIOF_DEGLITCH 0x00000008 /* (IN) Filter glitches */ void at32_select_periph(unsigned int pin, unsigned int periph, unsigned long flags); -- cgit v1.2.3