From: Joel A Fernandes Date: Mon, 15 Aug 2011 21:42:06 -0500 Subject: [U-Boot] [PATCH 6/7] OMAP3: Add function to get state of a GPIO output In-Reply-To: <1313462527-3876-1-git-send-email-agnel.joel@gmail.com> References: <1313462527-3876-1-git-send-email-agnel.joel@gmail.com> Message-ID: <1313462527-3876-6-git-send-email-agnel.joel@gmail.com> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de Read directly from OMAP24XX_GPIO_DATAOUT to get the output state of the GPIO pin Signed-off-by: Joel A Fernandes Signed-off-by: Jason Kridner --- arch/arm/cpu/armv7/omap3/gpio.c | 20 ++++++++++++++++++++ arch/arm/include/asm/arch-omap3/gpio.h | 2 ++ 2 files changed, 22 insertions(+), 0 deletions(-) diff --git a/arch/arm/cpu/armv7/omap3/gpio.c b/arch/arm/cpu/armv7/omap3/gpio.c index aeb6066..c8bb551 100644 --- a/arch/arm/cpu/armv7/omap3/gpio.c +++ b/arch/arm/cpu/armv7/omap3/gpio.c @@ -160,6 +160,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 += OMAP24XX_GPIO_DATAOUT; + break; + default: + return -EINVAL; + } + return (__raw_readl(reg) + & (1 << get_gpio_index(gpio))) != 0; +} + static void _reset_gpio(struct gpio_bank *bank, int gpio) { _set_gpio_direction(bank, get_gpio_index(gpio), 1); diff --git a/arch/arm/include/asm/arch-omap3/gpio.h b/arch/arm/include/asm/arch-omap3/gpio.h index 30f633c..81615bc 100644 --- a/arch/arm/include/asm/arch-omap3/gpio.h +++ b/arch/arm/include/asm/arch-omap3/gpio.h @@ -82,5 +82,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_ */ -- 1.7.1