From d81e2fafab376d3975c46c5f477945384a38524d Mon Sep 17 00:00:00 2001 From: Phil Elwell Date: Thu, 4 Apr 2024 10:50:32 +0100 Subject: [PATCH 3/5] pinctrl: rp1: Allow legacy brcm,pins on all banks Support the use of the brcm,pins property for GPIOs in banks 1 and 2, but only for inputs and outputs - no other legacy mapping. Signed-off-by: Phil Elwell --- drivers/pinctrl/pinctrl-rp1.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) --- a/drivers/pinctrl/pinctrl-rp1.c +++ b/drivers/pinctrl/pinctrl-rp1.c @@ -981,7 +981,16 @@ static int rp1_pctl_legacy_map_func(stru return -EINVAL; } - func = legacy_fsel_map[pin][fnum]; + if (pin < ARRAY_SIZE(legacy_fsel_map)) { + func = legacy_fsel_map[pin][fnum]; + } else if (fnum < 2) { + func = func_gpio; + } else { + dev_err(pc->dev, "%pOF: invalid brcm,pins value %d\n", + np, pin); + return -EINVAL; + } + if (func == func_invalid) { dev_err(pc->dev, "%pOF: brcm,function %d not supported on pin %d\n", np, fnum, pin); @@ -1104,13 +1113,6 @@ static int rp1_pctl_dt_node_to_map(struc err = of_property_read_u32_index(np, "brcm,pins", i, &pin); if (err) goto out; - if (pin >= ARRAY_SIZE(legacy_fsel_map)) { - dev_err(pc->dev, "%pOF: invalid brcm,pins value %d\n", - np, pin); - err = -EINVAL; - goto out; - } - if (num_funcs) { err = of_property_read_u32_index(np, "brcm,function", (num_funcs > 1) ? i : 0,