]> git.kernelconcepts.de Git - karo-tx-uboot.git/commitdiff
OMAP: Add function to get state of a GPIO output
authorJoel A Fernandes <agnel.joel@gmail.com>
Sun, 4 Sep 2011 16:10:03 +0000 (11:10 -0500)
committerAlbert ARIBAUD <albert.u.boot@aribaud.net>
Mon, 12 Sep 2011 15:40:48 +0000 (17:40 +0200)
Read directly from OMAP_GPIO_DATAOUT to get the output state of the GPIO pin

Signed-off-by: Joel A Fernandes <agnel.joel@gmail.com>
Signed-off-by: Jason Kridner <jkridner@beagleboard.org>
Signed-off-by: Sandeep Paulraj <s-paulraj@ti.com>
arch/arm/cpu/armv7/omap-common/gpio.c
arch/arm/include/asm/omap_gpio.h

index 2fcaf5a9f88c3a2d65c078e6ec07a8389f89b97f..47495244e7be0fa5dd4cb97f1f9a620601d1a3b6 100644 (file)
@@ -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);
index 3089e1c9851eaedd799e95d59608d029fe3705cc..8741572502c544f655dffb177e05a1e32b9c5c1f 100644 (file)
@@ -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_ */