]> git.kernelconcepts.de Git - karo-tx-uboot.git/commitdiff
gpio: am33xx: add missing gpio_get_value() function
authorLothar Waßmann <LW@KARO-electronics.de>
Mon, 25 Aug 2014 12:25:18 +0000 (14:25 +0200)
committerLothar Waßmann <LW@KARO-electronics.de>
Mon, 25 Aug 2014 12:25:18 +0000 (14:25 +0200)
drivers/gpio/am33xx_gpio.c

index f34fdc6bd845ff8e2154f962e4004eb017cff08f..de0bc475ca8cbc65f36ebed21f3f4e9719d4a0d6 100644 (file)
@@ -87,7 +87,7 @@ int gpio_set_value(unsigned gpio, int val)
        return 0;
 }
 
-int gpio_direction_input(unsigned gpio)
+int gpio_get_value(unsigned gpio)
 {
        int bank = gpio / 32;
        int mask = 1 << (gpio % 32);
@@ -97,7 +97,19 @@ int gpio_direction_input(unsigned gpio)
                        gpio / 32, gpio % 32);
                return -EINVAL;
        }
+       return (readl(&gpio_base[bank]->datain) & mask) != 0;
+}
+
+int gpio_direction_input(unsigned gpio)
+{
+       int bank = gpio / 32;
+       int mask = 1 << (gpio % 32);
 
+       if (bank >= ARRAY_SIZE(gpio_base)) {
+               printf("ERROR: Invalid GPIO: %u (GPIO%u_%u)\n", gpio,
+                       gpio / 32, gpio % 32);
+               return -EINVAL;
+       }
        writel(readl(&gpio_base[bank]->oe) | mask, &gpio_base[bank]->oe);
        return 0;
 }