bcm2835gpio: Make buffer an output before the GPIO connected to it
authorSteve Marple <stevemarple@googlemail.com>
Tue, 19 Apr 2022 22:29:55 +0000 (23:29 +0100)
committerAntonio Borneo <borneo.antonio@gmail.com>
Sat, 30 Apr 2022 17:48:42 +0000 (17:48 +0000)
The correct ordering is required to prevent two outputs connected
together.

Change-Id: I634a9ca7e0ccf337d1723011b8aee1f2d81efbcf
Signed-off-by: Steve Marple <stevemarple@googlemail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/6937
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
src/jtag/drivers/bcm2835gpio.c

index fd6c28b964a203f12ff715bb8b8dbfff839dbd66..b7a4d998cddfb1e5b010571a8e6600015e9ee1e1 100644 (file)
@@ -565,6 +565,13 @@ static int bcm2835gpio_init(void)
        }
 
        if (transport_is_swd()) {
+               /* Make buffer an output before the GPIO connected to it */
+               if (swdio_dir_gpio != -1) {
+                       swdio_dir_gpio_mode = MODE_GPIO(swdio_dir_gpio);
+                       GPIO_SET = 1 << swdio_dir_gpio;
+                       OUT_GPIO(swdio_dir_gpio);
+               }
+
                swclk_gpio_mode = MODE_GPIO(swclk_gpio);
                swdio_gpio_mode = MODE_GPIO(swdio_gpio);
 
@@ -580,12 +587,6 @@ static int bcm2835gpio_init(void)
                OUT_GPIO(srst_gpio);
        }
 
-       if (swdio_dir_gpio != -1) {
-               swdio_dir_gpio_mode = MODE_GPIO(swdio_dir_gpio);
-               GPIO_SET = 1 << swdio_dir_gpio;
-               OUT_GPIO(swdio_dir_gpio);
-       }
-
        LOG_DEBUG("saved pinmux settings: tck %d tms %d tdi %d "
                  "tdo %d trst %d srst %d", tck_gpio_mode, tms_gpio_mode,
                  tdi_gpio_mode, tdo_gpio_mode, trst_gpio_mode, srst_gpio_mode);