summaryrefslogtreecommitdiff
path: root/drivers
diff options
context:
space:
mode:
authorStefano Babic <[email protected]>2010-04-13 12:07:00 +0200
committertrix <[email protected]>2010-04-24 12:58:00 -0500
commit83366790317042bf61c3260c7a61fd8a8fbf5db9 (patch)
tree28f7a162da89cd6187d280f0cfa651aa45013a5a /drivers
parent989359b3182cdd998b58c8cca92717263c8d513d (diff)
MX31: add accessor function to get a gpio
The patch adds an accessor function to get the value of a gpio. Signed-off-by: Stefano Babic <[email protected]>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/gpio/mx31_gpio.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/drivers/gpio/mx31_gpio.c b/drivers/gpio/mx31_gpio.c
index 737aafa8228..b07f0381561 100644
--- a/drivers/gpio/mx31_gpio.c
+++ b/drivers/gpio/mx31_gpio.c
@@ -71,3 +71,18 @@ void mx31_gpio_set(unsigned int gpio, unsigned int value)
l &= ~(1 << gpio);
__REG(gpio_ports[port] + GPIO_DR) = l;
}
+
+int mx31_gpio_get(unsigned int gpio)
+{
+ unsigned int port = gpio >> 5;
+ u32 l;
+
+ if (port >= ARRAY_SIZE(gpio_ports))
+ return -1;
+
+ gpio &= 0x1f;
+
+ l = (__REG(gpio_ports[port] + GPIO_DR) >> gpio) & 0x01;
+
+ return l;
+}