From 569919d8e284c36d4ee981df5fcaa2e188f006a0 Mon Sep 17 00:00:00 2001 From: Joel A Fernandes Date: Sun, 4 Sep 2011 11:10:03 -0500 Subject: [PATCH] OMAP: Add function to get state of a GPIO output Read directly from OMAP_GPIO_DATAOUT to get the output state of the GPIO pin Signed-off-by: Joel A Fernandes Signed-off-by: Jason Kridner Signed-off-by: Sandeep Paulraj --- arch/arm/cpu/armv7/omap-common/gpio.c | 20 ++++++++++++++++++++ arch/arm/include/asm/omap_gpio.h | 2 ++ 2 files changed, 22 insertions(+) diff --git a/arch/arm/cpu/armv7/omap-common/gpio.c b/arch/arm/cpu/armv7/omap-common/gpio.c index 2fcaf5a..4749524 100644 --- a/arch/arm/cpu/armv7/omap-common/gpio.c +++ b/arch/arm/cpu/armv7/omap-common/gpio.c @@ -151,6 +151,26 @@ int omap_get_gpio_datain(int gpio) & (1 << get_gpio_index(gpio))) != 0; } +int omap_get_gpio_dataout(int gpio) +{ + struct gpio_bank *bank; + void *reg; + + if (check_gpio(gpio) < 0) + return -EINVAL; + bank = get_gpio_bank(gpio); + reg = bank->base; + switch (bank->method) { + case METHOD_GPIO_24XX: + reg += OMAP_GPIO_DATAOUT; + break; + default: + return -EINVAL; + } + return (__raw_readl(reg) + & (1 << get_gpio_index(gpio))) != 0; +} + static void _reset_gpio(const struct gpio_bank *bank, int gpio) { _set_gpio_direction(bank, get_gpio_index(gpio), 1); diff --git a/arch/arm/include/asm/omap_gpio.h b/arch/arm/include/asm/omap_gpio.h index 3089e1c..8741572 100644 --- a/arch/arm/include/asm/omap_gpio.h +++ b/arch/arm/include/asm/omap_gpio.h @@ -61,5 +61,7 @@ void omap_set_gpio_direction(int gpio, int is_input); void omap_set_gpio_dataout(int gpio, int enable); /* Get the value of a gpio input */ int omap_get_gpio_datain(int gpio); +/* Get the value of a gpio output */ +int omap_get_gpio_dataout(int gpio); #endif /* _GPIO_H_ */ -- 2.7.4