diff options
author | Alexander Shiyan <shc_work@mail.ru> | 2014-04-07 18:17:39 +0400 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2014-04-08 08:11:23 +0200 |
commit | e9ab71561b2bf166b175ab4af0784e7258bf1de4 (patch) | |
tree | 5fb1e4c284da20b0a59b52bb0748e92c4da7681b /drivers/gpio | |
parent | 6ca980c096ae623b143c62680e4017c436bbf2e6 (diff) | |
download | barebox-e9ab71561b2bf166b175ab4af0784e7258bf1de4.tar.gz barebox-e9ab71561b2bf166b175ab4af0784e7258bf1de4.tar.xz |
GPIO: i.MX: Implement get_direction()
Signed-off-by: Alexander Shiyan <shc_work@mail.ru>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'drivers/gpio')
-rw-r--r-- | drivers/gpio/gpio-imx.c | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/drivers/gpio/gpio-imx.c b/drivers/gpio/gpio-imx.c index a71492a3c3..d32638cf0b 100644 --- a/drivers/gpio/gpio-imx.c +++ b/drivers/gpio/gpio-imx.c @@ -113,11 +113,21 @@ static int imx_gpio_get_value(struct gpio_chip *chip, unsigned gpio) return val & (1 << gpio) ? 1 : 0; } +static int imx_get_direction(struct gpio_chip *chip, unsigned offset) +{ + struct imx_gpio_chip *imxgpio = container_of(chip, struct imx_gpio_chip, chip); + void __iomem *base = imxgpio->base; + u32 val = readl(base + imxgpio->regs->gdir); + + return (val & (1 << offset)) ? GPIOF_DIR_OUT : GPIOF_DIR_IN; +} + static struct gpio_ops imx_gpio_ops = { .direction_input = imx_gpio_direction_input, .direction_output = imx_gpio_direction_output, .get = imx_gpio_get_value, .set = imx_gpio_set_value, + .get_direction = imx_get_direction, }; static int imx_gpio_probe(struct device_d *dev) |