aboutsummaryrefslogtreecommitdiffstats
path: root/include/asm-avr32/arch-at32ap
diff options
context:
space:
mode:
authorDavid Brownell <dbrownell@users.sourceforge.net>2008-02-05 01:28:28 -0500
committerLinus Torvalds <torvalds@woody.linux-foundation.org>2008-02-05 12:44:13 -0500
commitb98348bdd08dc4ec11828aa98a78edde15c53cfa (patch)
treea0b4618bf8ec436581f29080c32ddb07e7489bd0 /include/asm-avr32/arch-at32ap
parentb72540c30c9c8c2c3f17cae29962cfb50fbe166a (diff)
gpiolib: avr32 at32ap platform support
Teach AVR32 to use the "GPIO Library" when exposing its GPIOs, so that signals on external chips (like GPIO expanders) can easily be used. This mostly reorganizes some existing logic, with two minor changes in behavior: - The PSR registers are used instead of the previous "gpio_mask" values, matching AT91 behavior and removing some duplication between that role and that of "pinmux_mask". - NR_IRQs grew to acommodate a bank of external GPIOs. Eventually this number should probably become a board-specific config option. There's a debugfs dump of status for the built-in GPIOs, showing which pins have deglitching, pullups, or open drain drive enabled, as well as the ID string used when requesting each IRQ. Signed-off-by: David Brownell <dbrownell@users.sourceforge.net> Acked-by: Haavard Skinnemoen <hskinnemoen@atmel.com> Cc: Jean Delvare <khali@linux-fr.org> Cc: Eric Miao <eric.miao@marvell.com> Cc: Sam Ravnborg <sam@ravnborg.org> Cc: Philipp Zabel <philipp.zabel@gmail.com> Cc: Russell King <rmk@arm.linux.org.uk> Cc: Ben Gardner <bgardner@wabtec.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'include/asm-avr32/arch-at32ap')
-rw-r--r--include/asm-avr32/arch-at32ap/at32ap700x.h2
-rw-r--r--include/asm-avr32/arch-at32ap/gpio.h34
-rw-r--r--include/asm-avr32/arch-at32ap/irq.h4
3 files changed, 27 insertions, 13 deletions
diff --git a/include/asm-avr32/arch-at32ap/at32ap700x.h b/include/asm-avr32/arch-at32ap/at32ap700x.h
index 99684d6f3967..31e48b0e7324 100644
--- a/include/asm-avr32/arch-at32ap/at32ap700x.h
+++ b/include/asm-avr32/arch-at32ap/at32ap700x.h
@@ -13,8 +13,6 @@
13#define GPIO_PERIPH_A 0 13#define GPIO_PERIPH_A 0
14#define GPIO_PERIPH_B 1 14#define GPIO_PERIPH_B 1
15 15
16#define NR_GPIO_CONTROLLERS 4
17
18/* 16/*
19 * Pin numbers identifying specific GPIO pins on the chip. They can 17 * Pin numbers identifying specific GPIO pins on the chip. They can
20 * also be converted to IRQ numbers by passing them through 18 * also be converted to IRQ numbers by passing them through
diff --git a/include/asm-avr32/arch-at32ap/gpio.h b/include/asm-avr32/arch-at32ap/gpio.h
index af7f9535bab3..0180f584ef03 100644
--- a/include/asm-avr32/arch-at32ap/gpio.h
+++ b/include/asm-avr32/arch-at32ap/gpio.h
@@ -5,20 +5,36 @@
5#include <asm/irq.h> 5#include <asm/irq.h>
6 6
7 7
8/* Arch-neutral GPIO API */ 8/* Some GPIO chips can manage IRQs; some can't. The exact numbers can
9int __must_check gpio_request(unsigned int gpio, const char *label); 9 * be changed if needed, but for the moment they're not configurable.
10void gpio_free(unsigned int gpio); 10 */
11#define ARCH_NR_GPIOS (NR_GPIO_IRQS + 2 * 32)
11 12
12int gpio_direction_input(unsigned int gpio);
13int gpio_direction_output(unsigned int gpio, int value);
14int gpio_get_value(unsigned int gpio);
15void gpio_set_value(unsigned int gpio, int value);
16 13
17#include <asm-generic/gpio.h> /* cansleep wrappers */ 14/* Arch-neutral GPIO API, supporting both "native" and external GPIOs. */
15#include <asm-generic/gpio.h>
16
17static inline int gpio_get_value(unsigned int gpio)
18{
19 return __gpio_get_value(gpio);
20}
21
22static inline void gpio_set_value(unsigned int gpio, int value)
23{
24 __gpio_set_value(gpio, value);
25}
26
27static inline int gpio_cansleep(unsigned int gpio)
28{
29 return __gpio_cansleep(gpio);
30}
31
18 32
19static inline int gpio_to_irq(unsigned int gpio) 33static inline int gpio_to_irq(unsigned int gpio)
20{ 34{
21 return gpio + GPIO_IRQ_BASE; 35 if (gpio < NR_GPIO_IRQS)
36 return gpio + GPIO_IRQ_BASE;
37 return -EINVAL;
22} 38}
23 39
24static inline int irq_to_gpio(unsigned int irq) 40static inline int irq_to_gpio(unsigned int irq)
diff --git a/include/asm-avr32/arch-at32ap/irq.h b/include/asm-avr32/arch-at32ap/irq.h
index 5adffab9a577..608e350368c7 100644
--- a/include/asm-avr32/arch-at32ap/irq.h
+++ b/include/asm-avr32/arch-at32ap/irq.h
@@ -3,11 +3,11 @@
3 3
4#define EIM_IRQ_BASE NR_INTERNAL_IRQS 4#define EIM_IRQ_BASE NR_INTERNAL_IRQS
5#define NR_EIM_IRQS 32 5#define NR_EIM_IRQS 32
6
7#define AT32_EXTINT(n) (EIM_IRQ_BASE + (n)) 6#define AT32_EXTINT(n) (EIM_IRQ_BASE + (n))
8 7
9#define GPIO_IRQ_BASE (EIM_IRQ_BASE + NR_EIM_IRQS) 8#define GPIO_IRQ_BASE (EIM_IRQ_BASE + NR_EIM_IRQS)
10#define NR_GPIO_IRQS (5 * 32) 9#define NR_GPIO_CTLR (5 /*internal*/ + 1 /*external*/)
10#define NR_GPIO_IRQS (NR_GPIO_CTLR * 32)
11 11
12#define NR_IRQS (GPIO_IRQ_BASE + NR_GPIO_IRQS) 12#define NR_IRQS (GPIO_IRQ_BASE + NR_GPIO_IRQS)
13 13