kernel: move console loglevel to generic
[oweals/openwrt.git] / target / linux / sunxi / patches-4.9 / 0033-pinctrl-sunxi-Support-generic-binding.patch
1 From cefbf1a1b29531a970bc2908a50a75d6474fcc38 Mon Sep 17 00:00:00 2001
2 From: Maxime Ripard <maxime.ripard@free-electrons.com>
3 Date: Thu, 20 Oct 2016 15:49:03 +0200
4 Subject: pinctrl: sunxi: Support generic binding
5
6 Our bindings are mostly irrelevant now that we have generic pinctrl
7 bindings that cover exactly the same uses cases.
8
9 Add support for the new ones, and obviously keep our old binding support in
10 order to keep the ABI stable.
11
12 Acked-by: Chen-Yu Tsai <wens@csie.org>
13 Signed-off-by: Maxime Ripard <maxime.ripard@free-electrons.com>
14 Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
15 ---
16  drivers/pinctrl/sunxi/pinctrl-sunxi.c | 48 +++++++++++++++++++++++++++++++++--
17  1 file changed, 46 insertions(+), 2 deletions(-)
18
19 --- a/drivers/pinctrl/sunxi/pinctrl-sunxi.c
20 +++ b/drivers/pinctrl/sunxi/pinctrl-sunxi.c
21 @@ -149,18 +149,33 @@ static int sunxi_pctrl_get_group_pins(st
22  
23  static bool sunxi_pctrl_has_bias_prop(struct device_node *node)
24  {
25 -       return of_find_property(node, "allwinner,pull", NULL);
26 +       return of_find_property(node, "bias-pull-up", NULL) ||
27 +               of_find_property(node, "bias-pull-down", NULL) ||
28 +               of_find_property(node, "bias-disable", NULL) ||
29 +               of_find_property(node, "allwinner,pull", NULL);
30  }
31  
32  static bool sunxi_pctrl_has_drive_prop(struct device_node *node)
33  {
34 -       return of_find_property(node, "allwinner,drive", NULL);
35 +       return of_find_property(node, "drive-strength", NULL) ||
36 +               of_find_property(node, "allwinner,drive", NULL);
37  }
38  
39  static int sunxi_pctrl_parse_bias_prop(struct device_node *node)
40  {
41         u32 val;
42  
43 +       /* Try the new style binding */
44 +       if (of_find_property(node, "bias-pull-up", NULL))
45 +               return PIN_CONFIG_BIAS_PULL_UP;
46 +
47 +       if (of_find_property(node, "bias-pull-down", NULL))
48 +               return PIN_CONFIG_BIAS_PULL_DOWN;
49 +
50 +       if (of_find_property(node, "bias-disable", NULL))
51 +               return PIN_CONFIG_BIAS_DISABLE;
52 +
53 +       /* And fall back to the old binding */
54         if (of_property_read_u32(node, "allwinner,pull", &val))
55                 return -EINVAL;
56  
57 @@ -180,6 +195,21 @@ static int sunxi_pctrl_parse_drive_prop(
58  {
59         u32 val;
60  
61 +       /* Try the new style binding */
62 +       if (!of_property_read_u32(node, "drive-strength", &val)) {
63 +               /* We can't go below 10mA ... */
64 +               if (val < 10)
65 +                       return -EINVAL;
66 +
67 +               /* ... and only up to 40 mA ... */
68 +               if (val > 40)
69 +                       val = 40;
70 +
71 +               /* by steps of 10 mA */
72 +               return rounddown(val, 10);
73 +       }
74 +
75 +       /* And then fall back to the old binding */
76         if (of_property_read_u32(node, "allwinner,drive", &val))
77                 return -EINVAL;
78  
79 @@ -191,6 +221,12 @@ static const char *sunxi_pctrl_parse_fun
80         const char *function;
81         int ret;
82  
83 +       /* Try the generic binding */
84 +       ret = of_property_read_string(node, "function", &function);
85 +       if (!ret)
86 +               return function;
87 +
88 +       /* And fall back to our legacy one */
89         ret = of_property_read_string(node, "allwinner,function", &function);
90         if (!ret)
91                 return function;
92 @@ -203,6 +239,14 @@ static const char *sunxi_pctrl_find_pins
93  {
94         int count;
95  
96 +       /* Try the generic binding */
97 +       count = of_property_count_strings(node, "pins");
98 +       if (count > 0) {
99 +               *npins = count;
100 +               return "pins";
101 +       }
102 +
103 +       /* And fall back to our legacy one */
104         count = of_property_count_strings(node, "allwinner,pins");
105         if (count > 0) {
106                 *npins = count;