]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
drivers: gpio: keep output value for input on sandbox
authorHeinrich Schuchardt <xypron.glpk@gmx.de>
Mon, 14 Sep 2020 10:50:55 +0000 (12:50 +0200)
committerTom Rini <trini@konsulko.com>
Wed, 14 Oct 2020 15:16:34 +0000 (11:16 -0400)
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>
drivers/gpio/sandbox.c

index c2f80472b83a8a900f813e2f66db51bfba3e23a5..eb2600de3111d8cea5f882ff5a3580fe257c4d96 100644 (file)
@@ -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;
 }