]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
gpio: dwapb_gpio: Enable get_function support
authorLey Foon Tan <ley.foon.tan@intel.com>
Thu, 16 Aug 2018 05:46:30 +0000 (13:46 +0800)
committerMarek Vasut <marex@denx.de>
Sat, 15 Sep 2018 01:17:01 +0000 (03:17 +0200)
Enabled get_function support for dwapb where the function will
return the state of GPIO port.

Signed-off-by: Chin Liang See <chin.liang.see@intel.com>
Signed-off-by: Ley Foon Tan <ley.foon.tan@intel.com>
drivers/gpio/dwapb_gpio.c

index a118f58b226a010a2a7c9b49a3eab2036697cb2a..e7e9b1e3873cd7dcf6ded272fdb8322493434ed9 100644 (file)
@@ -78,11 +78,25 @@ static int dwapb_gpio_set_value(struct udevice *dev, unsigned pin, int val)
        return 0;
 }
 
+static int dwapb_gpio_get_function(struct udevice *dev, unsigned offset)
+{
+       struct gpio_dwapb_platdata *plat = dev_get_platdata(dev);
+       u32 gpio;
+
+       gpio = readl(plat->base + GPIO_SWPORT_DDR(plat->bank));
+
+       if (gpio & BIT(offset))
+               return GPIOF_OUTPUT;
+       else
+               return GPIOF_INPUT;
+}
+
 static const struct dm_gpio_ops gpio_dwapb_ops = {
        .direction_input        = dwapb_gpio_direction_input,
        .direction_output       = dwapb_gpio_direction_output,
        .get_value              = dwapb_gpio_get_value,
        .set_value              = dwapb_gpio_set_value,
+       .get_function           = dwapb_gpio_get_function,
 };
 
 static int gpio_dwapb_probe(struct udevice *dev)