aboutsummaryrefslogtreecommitdiffstats
path: root/target/linux/bcm27xx/patches-4.19/950-0698-regulator-gpio-Allow-nonexclusive-GPIO-access.patch
diff options
context:
space:
mode:
authorAdrian Schmutzler <freifunk@adrianschmutzler.de>2020-02-08 21:58:55 +0100
committerAdrian Schmutzler <freifunk@adrianschmutzler.de>2020-02-14 14:10:51 +0100
commit7d7aa2fd924c27829ec25f825481554dd81bce97 (patch)
tree658b87b89331670266163e522ea5fb52535633cb /target/linux/bcm27xx/patches-4.19/950-0698-regulator-gpio-Allow-nonexclusive-GPIO-access.patch
parente7bfda2c243e66a75ff966ba04c28b1590b5d24c (diff)
downloadupstream-7d7aa2fd924c27829ec25f825481554dd81bce97.tar.gz
upstream-7d7aa2fd924c27829ec25f825481554dd81bce97.tar.bz2
upstream-7d7aa2fd924c27829ec25f825481554dd81bce97.zip
brcm2708: rename target to bcm27xx
This change makes the names of Broadcom targets consistent by using the common notation based on SoC/CPU ID (which is used internally anyway), bcmXXXX instead of brcmXXXX. This is even used for target TITLE in make menuconfig already, only the short target name used brcm so far. Despite, since subtargets range from bcm2708 to bcm2711, it seems appropriate to use bcm27xx instead of bcm2708 (again, as already done for BOARDNAME). This also renames the packages brcm2708-userland and brcm2708-gpu-fw. Signed-off-by: Adrian Schmutzler <freifunk@adrianschmutzler.de> Acked-by: Álvaro Fernández Rojas <noltari@gmail.com>
Diffstat (limited to 'target/linux/bcm27xx/patches-4.19/950-0698-regulator-gpio-Allow-nonexclusive-GPIO-access.patch')
-rw-r--r--target/linux/bcm27xx/patches-4.19/950-0698-regulator-gpio-Allow-nonexclusive-GPIO-access.patch79
1 files changed, 79 insertions, 0 deletions
diff --git a/target/linux/bcm27xx/patches-4.19/950-0698-regulator-gpio-Allow-nonexclusive-GPIO-access.patch b/target/linux/bcm27xx/patches-4.19/950-0698-regulator-gpio-Allow-nonexclusive-GPIO-access.patch
new file mode 100644
index 0000000000..a940736c3e
--- /dev/null
+++ b/target/linux/bcm27xx/patches-4.19/950-0698-regulator-gpio-Allow-nonexclusive-GPIO-access.patch
@@ -0,0 +1,79 @@
+From f6d983b7bc9ae79d0eb4dea7bc30a1ad5ff428a7 Mon Sep 17 00:00:00 2001
+From: Linus Walleij <linus.walleij@linaro.org>
+Date: Fri, 12 Oct 2018 14:54:12 +0200
+Subject: [PATCH] regulator/gpio: Allow nonexclusive GPIO access
+
+commit b0ce7b29bfcd090ddba476f45a75ec0a797b048a upstream.
+
+[ This is a partial cherry-pick, omitting the regulator
+change which isn't required ]
+
+This allows nonexclusive (simultaneous) access to a single
+GPIO line for the fixed regulator enable line. This happens
+when several regulators use the same GPIO for enabling and
+disabling a regulator, and all need a handle on their GPIO
+descriptor.
+
+This solution with a special flag is not entirely elegant
+and should ideally be replaced by something more careful as
+this makes it possible for several consumers to
+enable/disable the same GPIO line to the left and right
+without any consistency. The current use inside the regulator
+core should however be fine as it takes special care to
+handle this.
+
+For the state of the GPIO backend, this is still the
+lesser evil compared to going back to global GPIO
+numbers.
+
+Cc: Marek Szyprowski <m.szyprowski@samsung.com>
+Cc: Jon Hunter <jonathanh@nvidia.com>
+Fixes: efdfeb079cc3 ("regulator: fixed: Convert to use GPIO descriptor only")
+Reported-by: Marek Szyprowski <m.szyprowski@samsung.com>
+Tested-by: Jon Hunter <jonathanh@nvidia.com>
+Tested-by: Marek Szyprowski <m.szyprowski@samsung.com>
+Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
+Signed-off-by: Mark Brown <broonie@kernel.org>
+---
+ drivers/gpio/gpiolib.c | 19 +++++++++++++++++--
+ include/linux/gpio/consumer.h | 1 +
+ 2 files changed, 18 insertions(+), 2 deletions(-)
+
+--- a/drivers/gpio/gpiolib.c
++++ b/drivers/gpio/gpiolib.c
+@@ -3988,8 +3988,23 @@ struct gpio_desc *__must_check gpiod_get
+ * the device name as label
+ */
+ status = gpiod_request(desc, con_id ? con_id : devname);
+- if (status < 0)
+- return ERR_PTR(status);
++ if (status < 0) {
++ if (status == -EBUSY && flags & GPIOD_FLAGS_BIT_NONEXCLUSIVE) {
++ /*
++ * This happens when there are several consumers for
++ * the same GPIO line: we just return here without
++ * further initialization. It is a bit if a hack.
++ * This is necessary to support fixed regulators.
++ *
++ * FIXME: Make this more sane and safe.
++ */
++ dev_info(dev, "nonexclusive access to GPIO for %s\n",
++ con_id ? con_id : devname);
++ return desc;
++ } else {
++ return ERR_PTR(status);
++ }
++ }
+
+ status = gpiod_configure_flags(desc, con_id, lookupflags, flags);
+ if (status < 0) {
+--- a/include/linux/gpio/consumer.h
++++ b/include/linux/gpio/consumer.h
+@@ -30,6 +30,7 @@ struct gpio_descs {
+ #define GPIOD_FLAGS_BIT_DIR_OUT BIT(1)
+ #define GPIOD_FLAGS_BIT_DIR_VAL BIT(2)
+ #define GPIOD_FLAGS_BIT_OPEN_DRAIN BIT(3)
++#define GPIOD_FLAGS_BIT_NONEXCLUSIVE BIT(4)
+
+ /**
+ * Optional flags that can be passed to one of gpiod_* to configure direction