summaryrefslogtreecommitdiffstats
path: root/target/linux/bcm27xx/patches-6.6/950-1007-pinctrl-rp1-Allow-legacy-brcm-pins-on-all-banks.patch
blob: 36175ec1dc62897c50e575629df32be6a61aef15 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
From d81e2fafab376d3975c46c5f477945384a38524d Mon Sep 17 00:00:00 2001
From: Phil Elwell <phil@raspberrypi.com>
Date: Thu, 4 Apr 2024 10:50:32 +0100
Subject: [PATCH 1007/1085] 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 <phil@raspberrypi.com>
---
 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,