]> git.kernelconcepts.de Git - karo-tx-uboot.git/commitdiff
MX31: add accessor function to get a gpio
authorStefano Babic <sbabic@denx.de>
Tue, 13 Apr 2010 10:07:00 +0000 (12:07 +0200)
committertrix <trix@windriver.com>
Fri, 30 Apr 2010 10:23:25 +0000 (05:23 -0500)
The patch adds an accessor function to get the value of a gpio.

Signed-off-by: Stefano Babic <sbabic@denx.de>
arch/arm/include/asm/arch-mx31/mx31.h
drivers/gpio/mx31_gpio.c

index 3cc4b350b6d48b7f15873d67040be2d92ff2ee0f..f702d260f1157ec9e40f4484f0b99645312f51c5 100644 (file)
@@ -37,12 +37,17 @@ enum mx31_gpio_direction {
 extern int mx31_gpio_direction(unsigned int gpio,
                               enum mx31_gpio_direction direction);
 extern void mx31_gpio_set(unsigned int gpio, unsigned int value);
+extern int mx31_gpio_get(unsigned int gpio);
 #else
 static inline int mx31_gpio_direction(unsigned int gpio,
                                      enum mx31_gpio_direction direction)
 {
        return 1;
 }
+static inline int mx31_gpio_get(unsigned int gpio)
+{
+       return 1;
+}
 static inline void mx31_gpio_set(unsigned int gpio, unsigned int value)
 {
 }
index 737aafa82281880f1e21283d7cd963106cc7acc7..b07f0381561cab545a1863ca96489fc87a88f480 100644 (file)
@@ -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;
+}