diff options
author | Javier Arteaga <javier@emutex.com> | 2018-03-06 13:42:13 +0000 |
---|---|---|
committer | Linus Walleij <linus.walleij@linaro.org> | 2018-03-23 04:07:22 +0100 |
commit | 67e6d3e83c18188bdc1467663c49787f8d4fdc0d (patch) | |
tree | e5f6a498296ea128d72f171ec6c371fdc05f2613 /drivers/pinctrl/intel/pinctrl-intel.c | |
parent | 86822c2f3a7c343cadcbebae1d5f7d75de1b3cfe (diff) | |
download | linux-stable-67e6d3e83c18188bdc1467663c49787f8d4fdc0d.tar.gz linux-stable-67e6d3e83c18188bdc1467663c49787f8d4fdc0d.tar.bz2 linux-stable-67e6d3e83c18188bdc1467663c49787f8d4fdc0d.zip |
pinctrl: intel: Implement intel_gpio_get_direction callback
Allows querying GPIO direction from the pad config register.
If the pad is not in GPIO mode, return an error.
Signed-off-by: Javier Arteaga <javier@emutex.com>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Acked-by: Mika Westerberg <mika.westerberg@linux.intel.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Diffstat (limited to 'drivers/pinctrl/intel/pinctrl-intel.c')
-rw-r--r-- | drivers/pinctrl/intel/pinctrl-intel.c | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/drivers/pinctrl/intel/pinctrl-intel.c b/drivers/pinctrl/intel/pinctrl-intel.c index 96e73e30204e..1e24a6b8a64e 100644 --- a/drivers/pinctrl/intel/pinctrl-intel.c +++ b/drivers/pinctrl/intel/pinctrl-intel.c @@ -788,6 +788,24 @@ static void intel_gpio_set(struct gpio_chip *chip, unsigned offset, int value) raw_spin_unlock_irqrestore(&pctrl->lock, flags); } +static int intel_gpio_get_direction(struct gpio_chip *chip, unsigned int offset) +{ + struct intel_pinctrl *pctrl = gpiochip_get_data(chip); + void __iomem *reg; + u32 padcfg0; + + reg = intel_get_padcfg(pctrl, offset, PADCFG0); + if (!reg) + return -EINVAL; + + padcfg0 = readl(reg); + + if (padcfg0 & PADCFG0_PMODE_MASK) + return -EINVAL; + + return !!(padcfg0 & PADCFG0_GPIOTXDIS); +} + static int intel_gpio_direction_input(struct gpio_chip *chip, unsigned offset) { return pinctrl_gpio_direction_input(chip->base + offset); @@ -804,6 +822,7 @@ static const struct gpio_chip intel_gpio_chip = { .owner = THIS_MODULE, .request = gpiochip_generic_request, .free = gpiochip_generic_free, + .get_direction = intel_gpio_get_direction, .direction_input = intel_gpio_direction_input, .direction_output = intel_gpio_direction_output, .get = intel_gpio_get, |