summaryrefslogtreecommitdiffstats
path: root/target/linux/bcm27xx/patches-6.6/950-1082-pinctrl-rp1-Use-persist_gpio_outputs.patch
blob: 6a1b1ab7e38b3ad694741aeaa8f915940866252a (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
From f87840e805569bf6b072c389968a65b1ae1676ef Mon Sep 17 00:00:00 2001
From: Phil Elwell <phil@raspberrypi.com>
Date: Tue, 7 May 2024 13:33:48 +0100
Subject: [PATCH 1082/1085] pinctrl: rp1: Use persist_gpio_outputs

Following 8ff05989b44e1a8f7d2bbe67320990ebc2fbb5e5, adopt the same
parameter name but with the opposite default.

Signed-off-by: Phil Elwell <phil@raspberrypi.com>
---
 drivers/pinctrl/pinctrl-rp1.c | 17 +++++++++--------
 1 file changed, 9 insertions(+), 8 deletions(-)

--- a/drivers/pinctrl/pinctrl-rp1.c
+++ b/drivers/pinctrl/pinctrl-rp1.c
@@ -573,9 +573,9 @@ static const char * const irq_type_names
 	[IRQ_TYPE_LEVEL_LOW] = "level-low",
 };
 
-static bool strict_gpiod;
-module_param(strict_gpiod, bool, 0644);
-MODULE_PARM_DESC(strict_gpiod, "unless true, outputs remain outputs when freed");
+static bool persist_gpio_outputs = true;
+module_param(persist_gpio_outputs, bool, 0644);
+MODULE_PARM_DESC(persist_gpio_outputs, "Enable GPIO_OUT persistence when pin is freed");
 
 static int rp1_pinconf_set(struct pinctrl_dev *pctldev,
 			   unsigned int offset, unsigned long *configs,
@@ -1205,11 +1205,12 @@ static int rp1_pmx_free(struct pinctrl_d
 	struct rp1_pin_info *pin = rp1_get_pin_pctl(pctldev, offset);
 	u32 fsel = rp1_get_fsel(pin);
 
-	/* Return non-GPIOs to GPIO_IN, unless strict_gpiod is set */
-	if (strict_gpiod || fsel != RP1_FSEL_GPIO) {
-		rp1_set_dir(pin, RP1_DIR_INPUT);
-		rp1_set_fsel(pin, RP1_FSEL_GPIO);
-	}
+	/* Return all pins to GPIO_IN, unless persist_gpio_outputs is set */
+	if (persist_gpio_outputs && fsel == RP1_FSEL_GPIO)
+		return 0;
+
+	rp1_set_dir(pin, RP1_DIR_INPUT);
+	rp1_set_fsel(pin, RP1_FSEL_GPIO);
 
 	return 0;
 }