From acd690d524f5c7528f8c96e27cdd23474e8e31c9 Mon Sep 17 00:00:00 2001 From: Emmanuel Vadot Date: Mon, 19 Jun 2017 06:30:04 +0000 Subject: [PATCH] allwinner: Configure pins for DTS >= Linux 4.11 Starting with DTS from Linux 4.11, the pins list, function, drive and pull are no longer prefixed with "allwinner,". Allow the pinctrl driver to handle both case. --- sys/arm/allwinner/a10_gpio.c | 40 +++++++++++++++++++++++++----------- 1 file changed, 28 insertions(+), 12 deletions(-) diff --git a/sys/arm/allwinner/a10_gpio.c b/sys/arm/allwinner/a10_gpio.c index b3c5ac5cccc..b1862707da6 100644 --- a/sys/arm/allwinner/a10_gpio.c +++ b/sys/arm/allwinner/a10_gpio.c @@ -565,24 +565,38 @@ aw_fdt_configure_pins(device_t dev, phandle_t cfgxref) ret = 0; /* Getting all prop for configuring pins */ - pins_nb = ofw_bus_string_list_to_array(node, "allwinner,pins", &pinlist); - if (pins_nb <= 0) - return (ENOENT); - if (OF_getprop_alloc(node, "allwinner,function", + pins_nb = ofw_bus_string_list_to_array(node, "pins", &pinlist); + if (pins_nb <= 0) { + pins_nb = ofw_bus_string_list_to_array(node, "allwinner,pins", + &pinlist); + if (pins_nb <= 0) + return (ENOENT); + } + if (OF_getprop_alloc(node, "function", sizeof(*pin_function), (void **)&pin_function) == -1) { - ret = ENOENT; - goto out; + if (OF_getprop_alloc(node, "allwinner,function", + sizeof(*pin_function), + (void **)&pin_function) == -1) { + ret = ENOENT; + goto out; + } } - if (OF_getencprop(node, "allwinner,drive", + if (OF_getencprop(node, "drive", &pin_drive, sizeof(pin_drive)) == -1) { - ret = ENOENT; - goto out; + if (OF_getencprop(node, "allwinner,drive", + &pin_drive, sizeof(pin_drive)) == -1) { + ret = ENOENT; + goto out; + } } - if (OF_getencprop(node, "allwinner,pull", + if (OF_getencprop(node, "pull", &pin_pull, sizeof(pin_pull)) == -1) { - ret = ENOENT; - goto out; + if (OF_getencprop(node, "allwinner,pull", + &pin_pull, sizeof(pin_pull)) == -1) { + ret = ENOENT; + goto out; + } } /* Configure each pin to the correct function, drive and pull */ @@ -697,6 +711,8 @@ a10_gpio_attach(device_t dev) /* * Register as a pinctrl device */ + fdt_pinctrl_register(dev, "pins"); + fdt_pinctrl_configure_tree(dev); fdt_pinctrl_register(dev, "allwinner,pins"); fdt_pinctrl_configure_tree(dev); -- 2.45.0