kernel: refresh patches
[openwrt.git] / target / linux / lantiq / patches-3.14 / 0012-pinctrl-lantiq-fix-up-pinmux.patch
1 From 25494c55a4007a1409f53ddbafd661636e47ea34 Mon Sep 17 00:00:00 2001
2 From: John Crispin <blogic@openwrt.org>
3 Date: Fri, 9 Aug 2013 20:38:15 +0200
4 Subject: [PATCH 12/36] pinctrl/lantiq: fix up pinmux
5
6 We found out how to set the gphy led pinmuxing.
7
8 Signed-off-by: John Crispin <blogic@openwrt.org>
9 ---
10  drivers/pinctrl/pinctrl-xway.c |   28 ++++++++++++++++++++++++++--
11  1 file changed, 26 insertions(+), 2 deletions(-)
12
13 --- a/drivers/pinctrl/pinctrl-xway.c
14 +++ b/drivers/pinctrl/pinctrl-xway.c
15 @@ -609,10 +609,9 @@ static struct pinctrl_desc xway_pctrl_de
16         .confops        = &xway_pinconf_ops,
17  };
18  
19 -static inline int xway_mux_apply(struct pinctrl_dev *pctrldev,
20 +static int mux_apply(struct ltq_pinmux_info *info,
21                                 int pin, int mux)
22  {
23 -       struct ltq_pinmux_info *info = pinctrl_dev_get_drvdata(pctrldev);
24         int port = PORT(pin);
25         u32 alt1_reg = GPIO_ALT1(pin);
26  
27 @@ -632,6 +631,14 @@ static inline int xway_mux_apply(struct 
28         return 0;
29  }
30  
31 +static inline int xway_mux_apply(struct pinctrl_dev *pctrldev,
32 +                               int pin, int mux)
33 +{
34 +       struct ltq_pinmux_info *info = pinctrl_dev_get_drvdata(pctrldev);
35 +
36 +       return mux_apply(info, pin, mux);
37 +}
38 +
39  static const struct ltq_cfg_param xway_cfg_params[] = {
40         {"lantiq,pull",         LTQ_PINCONF_PARAM_PULL},
41         {"lantiq,open-drain",   LTQ_PINCONF_PARAM_OPEN_DRAIN},
42 @@ -676,6 +683,10 @@ static int xway_gpio_dir_out(struct gpio
43  {
44         struct ltq_pinmux_info *info = dev_get_drvdata(chip->dev);
45  
46 +       if (PORT(pin) == PORT3)
47 +               gpio_setbit(info->membase[0], GPIO3_OD, PORT_PIN(pin));
48 +       else
49 +               gpio_setbit(info->membase[0], GPIO_OD(pin), PORT_PIN(pin));
50         gpio_setbit(info->membase[0], GPIO_DIR(pin), PORT_PIN(pin));
51         xway_gpio_set(chip, pin, val);
52  
53 @@ -696,6 +707,18 @@ static void xway_gpio_free(struct gpio_c
54         pinctrl_free_gpio(gpio);
55  }
56  
57 +static int xway_gpio_to_irq(struct gpio_chip *chip, unsigned offset)
58 +{
59 +       struct ltq_pinmux_info *info = dev_get_drvdata(chip->dev);
60 +       int i;
61 +
62 +       for (i = 0; i < info->num_exin; i++)
63 +               if (info->exin[i] == offset)
64 +                       return ltq_eiu_get_irq(i);
65 +
66 +       return -1;
67 +}
68 +
69  static struct gpio_chip xway_chip = {
70         .label = "gpio-xway",
71         .direction_input = xway_gpio_dir_in,
72 @@ -704,6 +727,7 @@ static struct gpio_chip xway_chip = {
73         .set = xway_gpio_set,
74         .request = xway_gpio_req,
75         .free = xway_gpio_free,
76 +       .to_irq = xway_gpio_to_irq,
77         .base = -1,
78  };
79