pinctrl: single: change function mask default value
authorDario Binacchi <dariobin@libero.it>
Sun, 11 Apr 2021 07:39:45 +0000 (09:39 +0200)
committerLokesh Vutla <lokeshvutla@ti.com>
Mon, 12 Apr 2021 05:47:15 +0000 (11:17 +0530)
The patch is inspired by more recent versions of the Linux driver.
Replacing the default value 0xffffffff of the function mask with 0 is
certainly more conservative in case the "pinctrl-single,function-mask"
DT property is missing.

Signed-off-by: Dario Binacchi <dariobin@libero.it>
Reviewed-by: Simon Glass <sjg@chromium.org>
drivers/pinctrl/pinctrl-single.c

index 5ade108..630a6c0 100644 (file)
@@ -79,6 +79,10 @@ static int single_configure_pins(struct udevice *dev,
        phys_addr_t reg;
        u32 offset, val;
 
+       /* If function mask is null, needn't enable it. */
+       if (!pdata->mask)
+               return 0;
+
        for (n = 0; n < count; n++, pins++) {
                offset = fdt32_to_cpu(pins->reg);
                if (offset < 0 || offset > pdata->offset) {
@@ -207,8 +211,12 @@ static int single_of_to_plat(struct udevice *dev)
        }
        pdata->base = addr;
 
-       pdata->mask = dev_read_u32_default(dev, "pinctrl-single,function-mask",
-                                          0xffffffff);
+       ret = dev_read_u32(dev, "pinctrl-single,function-mask", &pdata->mask);
+       if (ret) {
+               pdata->mask = 0;
+               dev_warn(dev, "missing function register mask\n");
+       }
+
        pdata->bits_per_mux = dev_read_bool(dev, "pinctrl-single,bit-per-mux");
 
        return 0;