summaryrefslogtreecommitdiff
path: root/drivers/gpio/sandbox.c
diff options
context:
space:
mode:
authorHeinrich Schuchardt <xypron.glpk@gmx.de>2020-09-14 12:50:55 +0200
committerTom Rini <trini@konsulko.com>2020-10-14 11:16:34 -0400
commit7cd96a47281145aca4f9c8960a0a2e185b8bd70c (patch)
treeddbbed43a10c1a25a9c813cf6cc347e545b50524 /drivers/gpio/sandbox.c
parent39916bb45f9e233d6df8ee478c539b100116a34a (diff)
downloadu-boot-7cd96a47281145aca4f9c8960a0a2e185b8bd70c.tar.gz
drivers: gpio: keep output value for input on sandbox
For testing purposes keep the output value when switching to input. This allows us to manipulate the input value via the gpio command. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Reviewed-by: Philippe Reynes <philippe.reynes@softathome.com>
Diffstat (limited to 'drivers/gpio/sandbox.c')
-rw-r--r--drivers/gpio/sandbox.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/drivers/gpio/sandbox.c b/drivers/gpio/sandbox.c
index c2f80472b8..eb2600de31 100644
--- a/drivers/gpio/sandbox.c
+++ b/drivers/gpio/sandbox.c
@@ -185,7 +185,15 @@ static int sb_gpio_set_dir_flags(struct udevice *dev, unsigned int offset,
dir_flags = get_gpio_dir_flags(dev, offset);
- *dir_flags = flags;
+ /*
+ * For testing purposes keep the output value when switching to input.
+ * This allows us to manipulate the input value via the gpio command.
+ */
+ if (flags & GPIOD_IS_IN)
+ *dir_flags = (flags & ~GPIOD_IS_OUT_ACTIVE) |
+ (*dir_flags & GPIOD_IS_OUT_ACTIVE);
+ else
+ *dir_flags = flags;
return 0;
}