From 3ea21ed969ee9566f76956868e75db633fdc0e11 Mon Sep 17 00:00:00 2001 From: David Brownell Date: Mon, 12 Feb 2007 00:53:12 -0800 Subject: [PATCH] --- yaml --- r: 47955 b: refs/heads/master c: 3c729f1ecd23b86a2d6b211d646f57f9da8dfeb1 h: refs/heads/master i: 47953: 83394eb4edadac4336f44fd4bf3720b325744454 47951: 4eaf522a6983458f91e834d501645c142c5b4a25 v: v3 --- [refs] | 2 +- trunk/include/asm-arm/arch-omap/gpio.h | 66 ++++++++++++++++++++++++++ 2 files changed, 67 insertions(+), 1 deletion(-) diff --git a/[refs] b/[refs] index 0a6003b6fa25..45e238cf2f17 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: 4c20386c8d0719b42503efe65abe47ad3fb3d711 +refs/heads/master: 3c729f1ecd23b86a2d6b211d646f57f9da8dfeb1 diff --git a/trunk/include/asm-arm/arch-omap/gpio.h b/trunk/include/asm-arm/arch-omap/gpio.h index f486b72070ea..3762a6ae6a7f 100644 --- a/trunk/include/asm-arm/arch-omap/gpio.h +++ b/trunk/include/asm-arm/arch-omap/gpio.h @@ -76,4 +76,70 @@ extern void omap_set_gpio_direction(int gpio, int is_input); extern void omap_set_gpio_dataout(int gpio, int enable); extern int omap_get_gpio_datain(int gpio); +/*-------------------------------------------------------------------------*/ + +/* wrappers for "new style" GPIO calls. the old OMAP-specfic ones should + * eventually be removed (along with this errno.h inclusion), and maybe + * gpios should put MPUIOs last too. + */ + +#include + +static inline int gpio_request(unsigned gpio, const char *label) +{ + return omap_request_gpio(gpio); +} + +static inline void gpio_free(unsigned gpio) +{ + omap_free_gpio(gpio); +} + +static inline int __gpio_set_direction(unsigned gpio, int is_input) +{ + if (cpu_class_is_omap2()) { + if (gpio > OMAP_MAX_GPIO_LINES) + return -EINVAL; + } else { + if (gpio > (OMAP_MAX_GPIO_LINES + 16 /* MPUIO */)) + return -EINVAL; + } + omap_set_gpio_direction(gpio, is_input); + return 0; +} + +static inline int gpio_direction_input(unsigned gpio) +{ + return __gpio_set_direction(gpio, 1); +} + +static inline int gpio_direction_output(unsigned gpio) +{ + return __gpio_set_direction(gpio, 0); +} + +static inline int gpio_get_value(unsigned gpio) +{ + return omap_get_gpio_datain(gpio); +} + +static inline void gpio_set_value(unsigned gpio, int value) +{ + omap_set_gpio_dataout(gpio, value); +} + +#include /* cansleep wrappers */ + +static inline int gpio_to_irq(unsigned gpio) +{ + return OMAP_GPIO_IRQ(gpio); +} + +static inline int irq_to_gpio(unsigned irq) +{ + if (cpu_class_is_omap1() && (irq < (IH_MPUIO_BASE + 16))) + return (irq - IH_MPUIO_BASE) + OMAP_MAX_GPIO_LINES; + return irq - IH_GPIO_BASE; +} + #endif