1 From ea78e25b769740a801e259f4f6cb93fa92faa244 Mon Sep 17 00:00:00 2001
2 From: John Crispin <blogic@openwrt.org>
3 Date: Sat, 29 Jun 2013 19:32:08 +0200
4 Subject: [PATCH 22/22] PINCTRL: add gpio_irq support
7 drivers/pinctrl/pinctrl-xway.c | 28 ++++++++++++++++++++++++++--
8 1 file changed, 26 insertions(+), 2 deletions(-)
10 diff --git a/drivers/pinctrl/pinctrl-xway.c b/drivers/pinctrl/pinctrl-xway.c
11 index 068224e..8719d35 100644
12 --- a/drivers/pinctrl/pinctrl-xway.c
13 +++ b/drivers/pinctrl/pinctrl-xway.c
14 @@ -564,10 +564,9 @@ static struct pinctrl_desc xway_pctrl_desc = {
15 .confops = &xway_pinconf_ops,
18 -static inline int xway_mux_apply(struct pinctrl_dev *pctrldev,
19 +static int mux_apply(struct ltq_pinmux_info *info,
22 - struct ltq_pinmux_info *info = pinctrl_dev_get_drvdata(pctrldev);
24 u32 alt1_reg = GPIO_ALT1(pin);
26 @@ -587,6 +586,14 @@ static inline int xway_mux_apply(struct pinctrl_dev *pctrldev,
30 +static inline int xway_mux_apply(struct pinctrl_dev *pctrldev,
33 + struct ltq_pinmux_info *info = pinctrl_dev_get_drvdata(pctrldev);
35 + return mux_apply(info, pin, mux);
38 static const struct ltq_cfg_param xway_cfg_params[] = {
39 {"lantiq,pull", LTQ_PINCONF_PARAM_PULL},
40 {"lantiq,open-drain", LTQ_PINCONF_PARAM_OPEN_DRAIN},
41 @@ -631,6 +638,10 @@ static int xway_gpio_dir_out(struct gpio_chip *chip, unsigned int pin, int val)
43 struct ltq_pinmux_info *info = dev_get_drvdata(chip->dev);
45 + if (PORT(pin) == PORT3)
46 + gpio_setbit(info->membase[0], GPIO3_OD, PORT_PIN(pin));
48 + gpio_setbit(info->membase[0], GPIO_OD(pin), PORT_PIN(pin));
49 gpio_setbit(info->membase[0], GPIO_DIR(pin), PORT_PIN(pin));
50 xway_gpio_set(chip, pin, val);
52 @@ -651,6 +662,18 @@ static void xway_gpio_free(struct gpio_chip *chip, unsigned offset)
53 pinctrl_free_gpio(gpio);
56 +static int xway_gpio_to_irq(struct gpio_chip *chip, unsigned offset)
58 + struct ltq_pinmux_info *info = dev_get_drvdata(chip->dev);
61 + for (i = 0; i < info->num_exin; i++)
62 + if (info->exin[i] == offset)
63 + return ltq_eiu_get_irq(i);
68 static struct gpio_chip xway_chip = {
70 .direction_input = xway_gpio_dir_in,
71 @@ -659,6 +682,7 @@ static struct gpio_chip xway_chip = {
73 .request = xway_gpio_req,
74 .free = xway_gpio_free,
75 + .to_irq = xway_gpio_to_irq,