summaryrefslogtreecommitdiff
path: root/drivers/pinctrl/pinctrl-xway.c
diff options
context:
space:
mode:
authorJohn Crispin <blogic@openwrt.org>2015-12-04 11:05:44 +0100
committerLinus Walleij <linus.walleij@linaro.org>2015-12-11 00:05:19 +0100
commit3e640743fee6e6a82ead1f163737755b2a965712 (patch)
tree14b2fa69fadf2ccb5ac2fb9cb064023add7dfefe /drivers/pinctrl/pinctrl-xway.c
parentb4818afeacbd81821f89a89951471cffcb6a65e0 (diff)
pinctrl: lantiq: Implement gpio_chip.to_irq
Some drivers require a way to translate GPIO pins to their IRQ numbers. This patch adds the .to_irq() gpiolib callback to the pinctrl-xway driver, which returns an IRQ mapping for a given GPIO pin. Signed-off-by: John Crispin <blogic@openwrt.org> Signed-off-by: Martin Schiller <mschiller@tdt.de> [Switched ->dev to ->parent] Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Diffstat (limited to 'drivers/pinctrl/pinctrl-xway.c')
-rw-r--r--drivers/pinctrl/pinctrl-xway.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/drivers/pinctrl/pinctrl-xway.c b/drivers/pinctrl/pinctrl-xway.c
index b4380fb72001..e56222eac96c 100644
--- a/drivers/pinctrl/pinctrl-xway.c
+++ b/drivers/pinctrl/pinctrl-xway.c
@@ -682,6 +682,22 @@ static int xway_gpio_dir_out(struct gpio_chip *chip, unsigned int pin, int val)
return 0;
}
+/*
+ * gpiolib gpiod_to_irq callback function.
+ * Returns the mapped IRQ (external interrupt) number for a given GPIO pin.
+ */
+static int xway_gpio_to_irq(struct gpio_chip *chip, unsigned offset)
+{
+ struct ltq_pinmux_info *info = dev_get_drvdata(chip->parent);
+ int i;
+
+ for (i = 0; i < info->num_exin; i++)
+ if (info->exin[i] == offset)
+ return ltq_eiu_get_irq(i);
+
+ return -1;
+}
+
static struct gpio_chip xway_chip = {
.label = "gpio-xway",
.direction_input = xway_gpio_dir_in,
@@ -690,6 +706,7 @@ static struct gpio_chip xway_chip = {
.set = xway_gpio_set,
.request = gpiochip_generic_request,
.free = gpiochip_generic_free,
+ .to_irq = xway_gpio_to_irq,
.base = -1,
};