![David Brownell](/assets/img/avatar_default.png)
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>
46 lines
939 B
C
46 lines
939 B
C
#ifndef __ASM_AVR32_ARCH_GPIO_H
|
|
#define __ASM_AVR32_ARCH_GPIO_H
|
|
|
|
#include <linux/compiler.h>
|
|
#include <asm/irq.h>
|
|
|
|
|
|
/* Some GPIO chips can manage IRQs; some can't. The exact numbers can
|
|
* be changed if needed, but for the moment they're not configurable.
|
|
*/
|
|
#define ARCH_NR_GPIOS (NR_GPIO_IRQS + 2 * 32)
|
|
|
|
|
|
/* Arch-neutral GPIO API, supporting both "native" and external GPIOs. */
|
|
#include <asm-generic/gpio.h>
|
|
|
|
static inline int gpio_get_value(unsigned int gpio)
|
|
{
|
|
return __gpio_get_value(gpio);
|
|
}
|
|
|
|
static inline void gpio_set_value(unsigned int gpio, int value)
|
|
{
|
|
__gpio_set_value(gpio, value);
|
|
}
|
|
|
|
static inline int gpio_cansleep(unsigned int gpio)
|
|
{
|
|
return __gpio_cansleep(gpio);
|
|
}
|
|
|
|
|
|
static inline int gpio_to_irq(unsigned int gpio)
|
|
{
|
|
if (gpio < NR_GPIO_IRQS)
|
|
return gpio + GPIO_IRQ_BASE;
|
|
return -EINVAL;
|
|
}
|
|
|
|
static inline int irq_to_gpio(unsigned int irq)
|
|
{
|
|
return irq - GPIO_IRQ_BASE;
|
|
}
|
|
|
|
#endif /* __ASM_AVR32_ARCH_GPIO_H */
|