diff options
author | Ley Foon Tan <ley.foon.tan@intel.com> | 2018-08-16 13:46:30 +0800 |
---|---|---|
committer | Marek Vasut <marex@denx.de> | 2018-09-15 03:17:01 +0200 |
commit | 71f2700b92ab6e419741dc81c27d77cddfaab45f (patch) | |
tree | 10ac416365acc50de7c3e7385e976ddd217cbd8c /drivers/gpio/dwapb_gpio.c | |
parent | ecb10a41c9adf2c499c3d19fff96a08bb9ad2aef (diff) |
gpio: dwapb_gpio: Enable get_function support
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>
Diffstat (limited to 'drivers/gpio/dwapb_gpio.c')
-rw-r--r-- | drivers/gpio/dwapb_gpio.c | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/drivers/gpio/dwapb_gpio.c b/drivers/gpio/dwapb_gpio.c index a118f58b226..e7e9b1e3873 100644 --- a/drivers/gpio/dwapb_gpio.c +++ b/drivers/gpio/dwapb_gpio.c @@ -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) |