summaryrefslogtreecommitdiffstats
path: root/drivers/gpio
diff options
context:
space:
mode:
authorSebastian Hesselbarth <sebastian.hesselbarth@gmail.com>2013-11-09 14:24:09 +0100
committerSascha Hauer <s.hauer@pengutronix.de>2013-11-11 09:05:35 +0100
commitd7fc449a2ea8686f73403922f045b6d39baab27f (patch)
tree083d5eaf0082e6f255ac038aaa97923913d52015 /drivers/gpio
parentfcc25285a2b98afd4e6c2324093b4f52f59a26d3 (diff)
downloadbarebox-d7fc449a2ea8686f73403922f045b6d39baab27f.tar.gz
barebox-d7fc449a2ea8686f73403922f045b6d39baab27f.tar.xz
gpio: dw: add get_direction callback
This adds a callback function to read the current state of a GPIOs in/out direction. Signed-off-by: Sebastian Hesselbarth <sebastian.hesselbarth@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'drivers/gpio')
-rw-r--r--drivers/gpio/gpio-dw.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/drivers/gpio/gpio-dw.c b/drivers/gpio/gpio-dw.c
index 791488a19d..65770422ae 100644
--- a/drivers/gpio/gpio-dw.c
+++ b/drivers/gpio/gpio-dw.c
@@ -90,9 +90,18 @@ static int dw_gpio_direction_output(struct gpio_chip *gc,
return 0;
}
+static int dw_gpio_get_direction(struct gpio_chip *gc, unsigned offset)
+{
+ struct dw_gpio_instance *chip = to_dw_gpio(gc);
+
+ return (readl(chip->regs + DW_GPIO_DDR) & (1 << offset)) ?
+ GPIO_DIR_OUT : GPIO_DIR_IN;
+}
+
static struct gpio_ops imx_gpio_ops = {
.direction_input = dw_gpio_direction_input,
.direction_output = dw_gpio_direction_output,
+ .get_direction = dw_gpio_get_direction,
.get = dw_gpio_get,
.set = dw_gpio_set,
};