Skip to content

Commit 169db46

Browse files
hlord2000jhedberg
authored andcommitted
dp: add option to keep reset deasserted
Adds a property to keep reset deasserted even when the SWD port is disconnected. Signed-off-by: Helmut Lord <[email protected]>
1 parent 871124a commit 169db46

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

drivers/dp/swdp_bitbang.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ struct sw_config {
4848
void *dnoe_reg;
4949
struct gpio_dt_spec noe;
5050
struct gpio_dt_spec reset;
51+
bool keep_reset_deast;
5152
uint32_t port_write_cycles;
5253
void *clk_reg;
5354
};
@@ -668,7 +669,10 @@ static int sw_port_off(const struct device *dev)
668669
}
669670

670671
if (config->reset.port) {
671-
ret = gpio_pin_configure_dt(&config->reset, GPIO_DISCONNECTED);
672+
ret = gpio_pin_configure_dt(&config->reset,
673+
config->keep_reset_deast
674+
? GPIO_OUTPUT_ACTIVE
675+
: GPIO_DISCONNECTED);
672676
if (ret) {
673677
return ret;
674678
}
@@ -729,6 +733,7 @@ static struct swdp_api swdp_bitbang_api = {
729733
.dnoe_reg = SW_GPIOS_GET_REG(n, dnoe_gpios), \
730734
.noe = GPIO_DT_SPEC_INST_GET_OR(n, noe_gpios, {0}), \
731735
.reset = GPIO_DT_SPEC_INST_GET_OR(n, reset_gpios, {0}), \
736+
.keep_reset_deast = DT_INST_PROP(n, keep_reset_deasserted), \
732737
.port_write_cycles = DT_INST_PROP(n, port_write_cycles), \
733738
}; \
734739
\

dts/bindings/misc/zephyr,swdp-gpio.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,14 @@ properties:
9292
description: |
9393
Optional GPIO pin used for RESET output.
9494
95+
keep-reset-deasserted:
96+
type: boolean
97+
description: |
98+
When present, the driver will actively keep the target's RESET line
99+
in its de-asserted (inactive) state even when no SWD communication
100+
is occurring. This prevents the target from being unintentionally
101+
reset. This property requires 'reset-gpios' to be defined.
102+
95103
port-write-cycles:
96104
type: int
97105
required: true

0 commit comments

Comments
 (0)