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 ++++--- include/asm-avr32/gpio.h | 6 ++++++ include/asm-avr32/irq.h | 8 ++++++-- 5 files changed, 57 insertions(+), 5 deletions(-) create mode 100644 include/asm-avr32/arch-at32ap/gpio.h create mode 100644 include/asm-avr32/arch-at32ap/irq.h create mode 100644 include/asm-avr32/gpio.h (limited to 'include/asm-avr32') diff --git a/include/asm-avr32/arch-at32ap/gpio.h b/include/asm-avr32/arch-at32ap/gpio.h new file mode 100644 index 000000000000..fcb756bdaa8e --- /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 000000000000..f8f7f4571e44 --- /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 83c690571322..2ba611e0e134 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); diff --git a/include/asm-avr32/gpio.h b/include/asm-avr32/gpio.h new file mode 100644 index 000000000000..19e8ccc77db3 --- /dev/null +++ b/include/asm-avr32/gpio.h @@ -0,0 +1,6 @@ +#ifndef __ASM_AVR32_GPIO_H +#define __ASM_AVR32_GPIO_H + +#include + +#endif /* __ASM_AVR32_GPIO_H */ diff --git a/include/asm-avr32/irq.h b/include/asm-avr32/irq.h index f7e725707dd7..83e6549d7783 100644 --- a/include/asm-avr32/irq.h +++ b/include/asm-avr32/irq.h @@ -2,8 +2,12 @@ #define __ASM_AVR32_IRQ_H #define NR_INTERNAL_IRQS 64 -#define NR_EXTERNAL_IRQS 64 -#define NR_IRQS (NR_INTERNAL_IRQS + NR_EXTERNAL_IRQS) + +#include + +#ifndef NR_IRQS +#define NR_IRQS (NR_INTERNAL_IRQS) +#endif #define irq_canonicalize(i) (i) -- cgit v1.2.3