From 3bec165e2590ae72bb67ba4913b92e18b1275600 Mon Sep 17 00:00:00 2001 From: Marc Schink Date: Thu, 31 Jul 2025 07:48:46 +0000 Subject: [PATCH] adapter: Add 'user0' GPIO signal Add a user-specific signal 'user0' which can be used for custom functionality. For now, only a single user-specific signal is supported. Additional signals 'userX' or a more generic handling can be added in the future. Also, the signal state can only be configured during the adapter initialization and termination. Commands to change the signal state at run-time may be added in the future. Change-Id: I3f31242f6a693e11565542c3bd4521a245b4ff95 Signed-off-by: Marc Schink Reviewed-on: https://review.openocd.org/c/openocd/+/9088 Reviewed-by: Antonio Borneo Tested-by: jenkins --- doc/openocd.texi | 3 ++- src/jtag/adapter.c | 1 + src/jtag/adapter.h | 1 + 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/doc/openocd.texi b/doc/openocd.texi index 8ebb468d4..1e9f80dce 100644 --- a/doc/openocd.texi +++ b/doc/openocd.texi @@ -2440,7 +2440,7 @@ dict get [adapter list] ftdi @deffn {Config Command} {adapter gpio [ @ @option{tdo} | @option{tdi} | @option{tms} | @option{tck} | @option{trst} | @ @option{swdio} | @option{swdio_dir} | @option{swclk} | @option{srst} | @ - @option{led} @ + @option{led} | @option{user0} @ [ @ gpio_number | @option{-chip} chip_number | @ @option{-active-high} | @option{-active-low} | @ @@ -2460,6 +2460,7 @@ JTAG transport signals @item @option{swdio_dir}: optional swdio buffer control signal @item @option{srst}: system reset signal @item @option{led}: optional activity led +@item @option{user0}: optional, user-specific signal @end itemize diff --git a/src/jtag/adapter.c b/src/jtag/adapter.c index 07560f0db..87c65719c 100644 --- a/src/jtag/adapter.c +++ b/src/jtag/adapter.c @@ -65,6 +65,7 @@ static const struct gpio_map { [ADAPTER_GPIO_IDX_TRST] = { "trst", ADAPTER_GPIO_DIRECTION_OUTPUT, false, true, true }, [ADAPTER_GPIO_IDX_SRST] = { "srst", ADAPTER_GPIO_DIRECTION_OUTPUT, false, true, true }, [ADAPTER_GPIO_IDX_LED] = { "led", ADAPTER_GPIO_DIRECTION_OUTPUT, true, true, true }, + [ADAPTER_GPIO_IDX_USER0] = { "user0", ADAPTER_GPIO_DIRECTION_BIDIRECTIONAL, true, true, true }, }; static int adapter_config_khz(unsigned int khz); diff --git a/src/jtag/adapter.h b/src/jtag/adapter.h index ed58fe5aa..d76ea5e32 100644 --- a/src/jtag/adapter.h +++ b/src/jtag/adapter.h @@ -60,6 +60,7 @@ enum adapter_gpio_config_index { ADAPTER_GPIO_IDX_SWCLK, ADAPTER_GPIO_IDX_SRST, ADAPTER_GPIO_IDX_LED, + ADAPTER_GPIO_IDX_USER0, ADAPTER_GPIO_IDX_NUM, /* must be the last item */ };