]> git.karo-electronics.de Git - karo-tx-uboot.git/commitdiff
mxc: Make gpio_get_value() use PSR
authorBenoît Thébaudeau <benoit.thebaudeau@advansee.com>
Mon, 20 Aug 2012 10:55:41 +0000 (10:55 +0000)
committerAlbert ARIBAUD <albert.u.boot@aribaud.net>
Sat, 1 Sep 2012 12:58:28 +0000 (14:58 +0200)
gpio_get_value() should use PSR like Linux, not DR, because DR does not always
reflect the pin state, while PSR does. This is especially useful to detect a
short circuit on a GPIO pin configured as output, or to read the level of a pin
controlled by a non-GPIO IOMUX function.

Signed-off-by: Benoît Thébaudeau <benoit.thebaudeau@advansee.com>
Cc: Stefano Babic <sbabic@denx.de>
Acked-by: Stefano Babic <sbabic@denx.de>
drivers/gpio/mxc_gpio.c

index 661553552e6875d40cad956a82bcef9ac7057b57..e9bf27841cdbabdf7719050b5929bf7f35e027f2 100644 (file)
@@ -116,7 +116,7 @@ int gpio_get_value(unsigned gpio)
 
        regs = (struct gpio_regs *)gpio_ports[port];
 
-       val = (readl(&regs->gpio_dr) >> gpio) & 0x01;
+       val = (readl(&regs->gpio_psr) >> gpio) & 0x01;
 
        return val;
 }