summaryrefslogtreecommitdiffstats
path: root/drivers/pinctrl
diff options
context:
space:
mode:
authorAndrey Smirnov <andrew.smirnov@gmail.com>2017-03-08 14:08:54 -0800
committerSascha Hauer <s.hauer@pengutronix.de>2017-03-09 08:13:38 +0100
commitda1752b37003a0c1c9b25948b05e19f4ab8055a1 (patch)
treea6b1bca0898697df2c52dbaed5fa7270772ec956 /drivers/pinctrl
parent15426d5c46c57020cf62e350fa6de07a46889ec3 (diff)
downloadbarebox-da1752b37003a0c1c9b25948b05e19f4ab8055a1.tar.gz
barebox-da1752b37003a0c1c9b25948b05e19f4ab8055a1.tar.xz
pinctrl: at91: Implement .get_direction hook
Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'drivers/pinctrl')
-rw-r--r--drivers/pinctrl/pinctrl-at91.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/drivers/pinctrl/pinctrl-at91.c b/drivers/pinctrl/pinctrl-at91.c
index 34fb0ae62a..021c1e5a2e 100644
--- a/drivers/pinctrl/pinctrl-at91.c
+++ b/drivers/pinctrl/pinctrl-at91.c
@@ -568,6 +568,21 @@ static int at91_gpio_direction_output(struct gpio_chip *chip, unsigned offset,
return 0;
}
+static int at91_gpio_get_direction(struct gpio_chip *chip, unsigned offset)
+{
+ struct at91_gpio_chip *at91_gpio = to_at91_gpio_chip(chip);
+ void __iomem *pio = at91_gpio->regbase;
+ unsigned mask = 1 << offset;
+ u32 osr;
+
+ if (mask & __raw_readl(pio + PIO_PSR)) {
+ osr = __raw_readl(pio + PIO_OSR);
+ return !(osr & mask);
+ } else {
+ return -EBUSY;
+ }
+}
+
static int at91_gpio_direction_input(struct gpio_chip *chip, unsigned offset)
{
struct at91_gpio_chip *at91_gpio = to_at91_gpio_chip(chip);
@@ -603,6 +618,7 @@ static struct gpio_ops at91_gpio_ops = {
.free = at91_gpio_free,
.direction_input = at91_gpio_direction_input,
.direction_output = at91_gpio_direction_output,
+ .get_direction = at91_gpio_get_direction,
.get = at91_gpio_get,
.set = at91_gpio_set,
};