diff options
author | Tom Rini <trini@konsulko.com> | 2016-05-24 08:20:43 -0400 |
---|---|---|
committer | Tom Rini <trini@konsulko.com> | 2016-05-24 08:20:43 -0400 |
commit | ec8fb48ce98987065493b27422200897cf0909f8 (patch) | |
tree | e56d70ee24a04ee26fe75ac2af46c22705da61ed /drivers/gpio/zynq_gpio.c | |
parent | c98dc5a13399414fb651a80d05fa682236c4444e (diff) | |
parent | ad5b5801264e573bfbf17a20b04c546985c5bfc1 (diff) | |
download | u-boot-imx-ec8fb48ce98987065493b27422200897cf0909f8.zip u-boot-imx-ec8fb48ce98987065493b27422200897cf0909f8.tar.gz u-boot-imx-ec8fb48ce98987065493b27422200897cf0909f8.tar.bz2 |
Merge branch 'master' of git://www.denx.de/git/u-boot-microblaze
Diffstat (limited to 'drivers/gpio/zynq_gpio.c')
-rw-r--r-- | drivers/gpio/zynq_gpio.c | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/drivers/gpio/zynq_gpio.c b/drivers/gpio/zynq_gpio.c index 3a995f6..4ab2356 100644 --- a/drivers/gpio/zynq_gpio.c +++ b/drivers/gpio/zynq_gpio.c @@ -299,11 +299,33 @@ static int zynq_gpio_direction_output(struct udevice *dev, unsigned gpio, return 0; } +static int zynq_gpio_get_function(struct udevice *dev, unsigned offset) +{ + u32 reg; + unsigned int bank_num, bank_pin_num; + struct zynq_gpio_privdata *priv = dev_get_priv(dev); + + if (check_gpio(offset, dev) < 0) + return -1; + + zynq_gpio_get_bank_pin(offset, &bank_num, &bank_pin_num, dev); + + /* set the GPIO pin as output */ + reg = readl(priv->base + ZYNQ_GPIO_DIRM_OFFSET(bank_num)); + reg &= BIT(bank_pin_num); + if (reg) + return GPIOF_OUTPUT; + else + return GPIOF_INPUT; +} + static const struct dm_gpio_ops gpio_zynq_ops = { .direction_input = zynq_gpio_direction_input, .direction_output = zynq_gpio_direction_output, .get_value = zynq_gpio_get_value, .set_value = zynq_gpio_set_value, + .get_function = zynq_gpio_get_function, + }; static const struct udevice_id zynq_gpio_ids[] = { |