summaryrefslogtreecommitdiffstats
path: root/drivers/pinctrl/pinctrl-oxnas.c
diff options
context:
space:
mode:
authorNeil Armstrong <narmstrong@baylibre.com>2016-05-24 12:03:24 +0200
committerLinus Walleij <linus.walleij@linaro.org>2016-05-30 09:41:48 +0200
commit2f94ced704c488d0bf6b6efe4969a21089dae72d (patch)
tree6d231bb6174a8f099b7d54ad17bbaccddac1e9e1 /drivers/pinctrl/pinctrl-oxnas.c
parentpinctrl: max77620: add pincontrol driver for MAX77620/MAX20024 (diff)
downloadlinux-2f94ced704c488d0bf6b6efe4969a21089dae72d.tar.xz
linux-2f94ced704c488d0bf6b6efe4969a21089dae72d.zip
pinctrl: oxnas: Add GPIO get_direction
Implement a get_direction callback for the OXNAS GPIO driver in order to have pin output polarity in debugfs and new userspace ABI. Signed-off-by: Neil Armstrong <narmstrong@baylibre.com> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Diffstat (limited to 'drivers/pinctrl/pinctrl-oxnas.c')
-rw-r--r--drivers/pinctrl/pinctrl-oxnas.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/drivers/pinctrl/pinctrl-oxnas.c b/drivers/pinctrl/pinctrl-oxnas.c
index 5fd113c06864..2c6abef91d20 100644
--- a/drivers/pinctrl/pinctrl-oxnas.c
+++ b/drivers/pinctrl/pinctrl-oxnas.c
@@ -49,6 +49,7 @@
/* GPIO Registers */
#define INPUT_VALUE 0x00
+#define OUTPUT_EN 0x04
#define IRQ_PENDING 0x0c
#define OUTPUT_SET 0x14
#define OUTPUT_CLEAR 0x18
@@ -431,6 +432,15 @@ static int oxnas_gpio_request_enable(struct pinctrl_dev *pctldev,
return 0;
}
+static int oxnas_gpio_get_direction(struct gpio_chip *chip,
+ unsigned int offset)
+{
+ struct oxnas_gpio_bank *bank = gpiochip_get_data(chip);
+ u32 mask = BIT(offset);
+
+ return !(readl_relaxed(bank->reg_base + OUTPUT_EN) & mask);
+}
+
static int oxnas_gpio_direction_input(struct gpio_chip *chip,
unsigned int offset)
{
@@ -664,6 +674,7 @@ static void oxnas_gpio_irq_handler(struct irq_desc *desc)
.label = "GPIO" #_bank, \
.request = gpiochip_generic_request, \
.free = gpiochip_generic_free, \
+ .get_direction = oxnas_gpio_get_direction, \
.direction_input = oxnas_gpio_direction_input, \
.direction_output = oxnas_gpio_direction_output, \
.get = oxnas_gpio_get, \