lantiq: update to 3.14
[openwrt.git] / target / linux / lantiq / patches-3.14 / 0009-pinctrl-lantiq-fix-up-pinmux.patch
1 From 29452de974f2cdc87876dbdc18a16405ef80c05f 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 09/31] 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 diff --git a/drivers/pinctrl/pinctrl-xway.c b/drivers/pinctrl/pinctrl-xway.c
14 index e66f4ca..b5f43c8 100644
15 --- a/drivers/pinctrl/pinctrl-xway.c
16 +++ b/drivers/pinctrl/pinctrl-xway.c
17 @@ -609,10 +609,9 @@ static struct pinctrl_desc xway_pctrl_desc = {
18         .confops        = &xway_pinconf_ops,
19  };
20  
21 -static inline int xway_mux_apply(struct pinctrl_dev *pctrldev,
22 +static int mux_apply(struct ltq_pinmux_info *info,
23                                 int pin, int mux)
24  {
25 -       struct ltq_pinmux_info *info = pinctrl_dev_get_drvdata(pctrldev);
26         int port = PORT(pin);
27         u32 alt1_reg = GPIO_ALT1(pin);
28  
29 @@ -632,6 +631,14 @@ static inline int xway_mux_apply(struct pinctrl_dev *pctrldev,
30         return 0;
31  }
32  
33 +static inline int xway_mux_apply(struct pinctrl_dev *pctrldev,
34 +                               int pin, int mux)
35 +{
36 +       struct ltq_pinmux_info *info = pinctrl_dev_get_drvdata(pctrldev);
37 +
38 +       return mux_apply(info, pin, mux);
39 +}
40 +
41  static const struct ltq_cfg_param xway_cfg_params[] = {
42         {"lantiq,pull",         LTQ_PINCONF_PARAM_PULL},
43         {"lantiq,open-drain",   LTQ_PINCONF_PARAM_OPEN_DRAIN},
44 @@ -676,6 +683,10 @@ static int xway_gpio_dir_out(struct gpio_chip *chip, unsigned int pin, int val)
45  {
46         struct ltq_pinmux_info *info = dev_get_drvdata(chip->dev);
47  
48 +       if (PORT(pin) == PORT3)
49 +               gpio_setbit(info->membase[0], GPIO3_OD, PORT_PIN(pin));
50 +       else
51 +               gpio_setbit(info->membase[0], GPIO_OD(pin), PORT_PIN(pin));
52         gpio_setbit(info->membase[0], GPIO_DIR(pin), PORT_PIN(pin));
53         xway_gpio_set(chip, pin, val);
54  
55 @@ -696,6 +707,18 @@ static void xway_gpio_free(struct gpio_chip *chip, unsigned offset)
56         pinctrl_free_gpio(gpio);
57  }
58  
59 +static int xway_gpio_to_irq(struct gpio_chip *chip, unsigned offset)
60 +{
61 +       struct ltq_pinmux_info *info = dev_get_drvdata(chip->dev);
62 +       int i;
63 +
64 +       for (i = 0; i < info->num_exin; i++)
65 +               if (info->exin[i] == offset)
66 +                       return ltq_eiu_get_irq(i);
67 +
68 +       return -1;
69 +}
70 +
71  static struct gpio_chip xway_chip = {
72         .label = "gpio-xway",
73         .direction_input = xway_gpio_dir_in,
74 @@ -704,6 +727,7 @@ static struct gpio_chip xway_chip = {
75         .set = xway_gpio_set,
76         .request = xway_gpio_req,
77         .free = xway_gpio_free,
78 +       .to_irq = xway_gpio_to_irq,
79         .base = -1,
80  };
81  
82 -- 
83 1.7.10.4
84