lantiq: add v3.9 support
[openwrt.git] / target / linux / lantiq / patches-3.9 / 0022-PINCTRL-add-gpio_irq-support.patch
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
5
6 ---
7  drivers/pinctrl/pinctrl-xway.c |   28 ++++++++++++++++++++++++++--
8  1 file changed, 26 insertions(+), 2 deletions(-)
9
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,
16  };
17  
18 -static inline int xway_mux_apply(struct pinctrl_dev *pctrldev,
19 +static int mux_apply(struct ltq_pinmux_info *info,
20                                 int pin, int mux)
21  {
22 -       struct ltq_pinmux_info *info = pinctrl_dev_get_drvdata(pctrldev);
23         int port = PORT(pin);
24         u32 alt1_reg = GPIO_ALT1(pin);
25  
26 @@ -587,6 +586,14 @@ static inline int xway_mux_apply(struct pinctrl_dev *pctrldev,
27         return 0;
28  }
29  
30 +static inline int xway_mux_apply(struct pinctrl_dev *pctrldev,
31 +                               int pin, int mux)
32 +{
33 +       struct ltq_pinmux_info *info = pinctrl_dev_get_drvdata(pctrldev);
34 +
35 +       return mux_apply(info, pin, mux);
36 +}
37 +
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)
42  {
43         struct ltq_pinmux_info *info = dev_get_drvdata(chip->dev);
44  
45 +       if (PORT(pin) == PORT3)
46 +               gpio_setbit(info->membase[0], GPIO3_OD, PORT_PIN(pin));
47 +       else
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);
51  
52 @@ -651,6 +662,18 @@ static void xway_gpio_free(struct gpio_chip *chip, unsigned offset)
53         pinctrl_free_gpio(gpio);
54  }
55  
56 +static int xway_gpio_to_irq(struct gpio_chip *chip, unsigned offset)
57 +{
58 +       struct ltq_pinmux_info *info = dev_get_drvdata(chip->dev);
59 +       int i;
60 +
61 +       for (i = 0; i < info->num_exin; i++)
62 +               if (info->exin[i] == offset)
63 +                       return ltq_eiu_get_irq(i);
64 +
65 +       return -1;
66 +}
67 +
68  static struct gpio_chip xway_chip = {
69         .label = "gpio-xway",
70         .direction_input = xway_gpio_dir_in,
71 @@ -659,6 +682,7 @@ static struct gpio_chip xway_chip = {
72         .set = xway_gpio_set,
73         .request = xway_gpio_req,
74         .free = xway_gpio_free,
75 +       .to_irq = xway_gpio_to_irq,
76         .base = -1,
77  };
78  
79 -- 
80 1.7.10.4
81