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
6 Our bindings are mostly irrelevant now that we have generic pinctrl
7 bindings that cover exactly the same uses cases.
9 Add support for the new ones, and obviously keep our old binding support in
10 order to keep the ABI stable.
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>
16 drivers/pinctrl/sunxi/pinctrl-sunxi.c | 48 +++++++++++++++++++++++++++++++++--
17 1 file changed, 46 insertions(+), 2 deletions(-)
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
23 static bool sunxi_pctrl_has_bias_prop(struct device_node *node)
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);
32 static bool sunxi_pctrl_has_drive_prop(struct device_node *node)
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);
39 static int sunxi_pctrl_parse_bias_prop(struct device_node *node)
43 + /* Try the new style binding */
44 + if (of_find_property(node, "bias-pull-up", NULL))
45 + return PIN_CONFIG_BIAS_PULL_UP;
47 + if (of_find_property(node, "bias-pull-down", NULL))
48 + return PIN_CONFIG_BIAS_PULL_DOWN;
50 + if (of_find_property(node, "bias-disable", NULL))
51 + return PIN_CONFIG_BIAS_DISABLE;
53 + /* And fall back to the old binding */
54 if (of_property_read_u32(node, "allwinner,pull", &val))
57 @@ -180,6 +195,21 @@ static int sunxi_pctrl_parse_drive_prop(
61 + /* Try the new style binding */
62 + if (!of_property_read_u32(node, "drive-strength", &val)) {
63 + /* We can't go below 10mA ... */
67 + /* ... and only up to 40 mA ... */
71 + /* by steps of 10 mA */
72 + return rounddown(val, 10);
75 + /* And then fall back to the old binding */
76 if (of_property_read_u32(node, "allwinner,drive", &val))
79 @@ -191,6 +221,12 @@ static const char *sunxi_pctrl_parse_fun
83 + /* Try the generic binding */
84 + ret = of_property_read_string(node, "function", &function);
88 + /* And fall back to our legacy one */
89 ret = of_property_read_string(node, "allwinner,function", &function);
92 @@ -203,6 +239,14 @@ static const char *sunxi_pctrl_find_pins
96 + /* Try the generic binding */
97 + count = of_property_count_strings(node, "pins");
103 + /* And fall back to our legacy one */
104 count = of_property_count_strings(node, "allwinner,pins");