lantiq: fix PHY state handling issue
[openwrt.git] / target / linux / lantiq / patches-4.4 / 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 @@ -682,6 +689,18 @@ static int xway_gpio_dir_out(struct gpio
43         return 0;
44  }
45  
46 +static int xway_gpio_to_irq(struct gpio_chip *chip, unsigned offset)
47 +{
48 +       struct ltq_pinmux_info *info = dev_get_drvdata(chip->dev);
49 +       int i;
50 +
51 +       for (i = 0; i < info->num_exin; i++)
52 +               if (info->exin[i] == offset)
53 +                       return ltq_eiu_get_irq(i);
54 +
55 +       return -1;
56 +}
57 +
58  static struct gpio_chip xway_chip = {
59         .label = "gpio-xway",
60         .direction_input = xway_gpio_dir_in,
61 @@ -690,6 +709,7 @@ static struct gpio_chip xway_chip = {
62         .set = xway_gpio_set,
63         .request = gpiochip_generic_request,
64         .free = gpiochip_generic_free,
65 +       .to_irq = xway_gpio_to_irq,
66         .base = -1,
67  };
68