summaryrefslogtreecommitdiff
path: root/drivers/gpio/mxc_gpio.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/gpio/mxc_gpio.c')
-rw-r--r--drivers/gpio/mxc_gpio.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/drivers/gpio/mxc_gpio.c b/drivers/gpio/mxc_gpio.c
index 1dec4e35e0a..28176e15b7d 100644
--- a/drivers/gpio/mxc_gpio.c
+++ b/drivers/gpio/mxc_gpio.c
@@ -6,7 +6,6 @@
* Copyright (C) 2011
* Stefano Babic, DENX Software Engineering, <sbabic@denx.de>
*/
-#include <common.h>
#include <errno.h>
#include <dm.h>
#include <malloc.h>
@@ -134,7 +133,10 @@ int gpio_get_value(unsigned gpio)
regs = (struct gpio_regs *)gpio_ports[port];
- val = (readl(&regs->gpio_psr) >> gpio) & 0x01;
+ if ((readl(&regs->gpio_dir) >> gpio) & 0x01)
+ val = (readl(&regs->gpio_dr) >> gpio) & 0x01;
+ else
+ val = (readl(&regs->gpio_psr) >> gpio) & 0x01;
return val;
}
@@ -211,7 +213,10 @@ static void mxc_gpio_bank_set_value(struct gpio_regs *regs, int offset,
static int mxc_gpio_bank_get_value(struct gpio_regs *regs, int offset)
{
- return (readl(&regs->gpio_psr) >> offset) & 0x01;
+ if ((readl(&regs->gpio_dir) >> offset) & 0x01)
+ return (readl(&regs->gpio_dr) >> offset) & 0x01;
+ else
+ return (readl(&regs->gpio_psr) >> offset) & 0x01;
}
/* set GPIO pin 'gpio' as an input */