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 --- a/drivers/pinctrl/pinctrl-xway.c
11 +++ b/drivers/pinctrl/pinctrl-xway.c
12 @@ -564,10 +564,9 @@ static struct pinctrl_desc xway_pctrl_de
13 .confops = &xway_pinconf_ops,
16 -static inline int xway_mux_apply(struct pinctrl_dev *pctrldev,
17 +static int mux_apply(struct ltq_pinmux_info *info,
20 - struct ltq_pinmux_info *info = pinctrl_dev_get_drvdata(pctrldev);
22 u32 alt1_reg = GPIO_ALT1(pin);
24 @@ -587,6 +586,14 @@ static inline int xway_mux_apply(struct
28 +static inline int xway_mux_apply(struct pinctrl_dev *pctrldev,
31 + struct ltq_pinmux_info *info = pinctrl_dev_get_drvdata(pctrldev);
33 + return mux_apply(info, pin, mux);
36 static const struct ltq_cfg_param xway_cfg_params[] = {
37 {"lantiq,pull", LTQ_PINCONF_PARAM_PULL},
38 {"lantiq,open-drain", LTQ_PINCONF_PARAM_OPEN_DRAIN},
39 @@ -631,6 +638,10 @@ static int xway_gpio_dir_out(struct gpio
41 struct ltq_pinmux_info *info = dev_get_drvdata(chip->dev);
43 + if (PORT(pin) == PORT3)
44 + gpio_setbit(info->membase[0], GPIO3_OD, PORT_PIN(pin));
46 + gpio_setbit(info->membase[0], GPIO_OD(pin), PORT_PIN(pin));
47 gpio_setbit(info->membase[0], GPIO_DIR(pin), PORT_PIN(pin));
48 xway_gpio_set(chip, pin, val);
50 @@ -651,6 +662,18 @@ static void xway_gpio_free(struct gpio_c
51 pinctrl_free_gpio(gpio);
54 +static int xway_gpio_to_irq(struct gpio_chip *chip, unsigned offset)
56 + struct ltq_pinmux_info *info = dev_get_drvdata(chip->dev);
59 + for (i = 0; i < info->num_exin; i++)
60 + if (info->exin[i] == offset)
61 + return ltq_eiu_get_irq(i);
66 static struct gpio_chip xway_chip = {
68 .direction_input = xway_gpio_dir_in,
69 @@ -659,6 +682,7 @@ static struct gpio_chip xway_chip = {
71 .request = xway_gpio_req,
72 .free = xway_gpio_free,
73 + .to_irq = xway_gpio_to_irq,