diff --git a/src/platforms/hosted/dap_swd.c b/src/platforms/hosted/dap_swd.c index ad390c22277..8da65855256 100644 --- a/src/platforms/hosted/dap_swd.c +++ b/src/platforms/hosted/dap_swd.c @@ -55,7 +55,6 @@ static void dap_swd_seq_out_parity(uint32_t tms_states, size_t clock_cycles); static bool dap_swd_configure(dap_swd_turnaround_cycles_e turnaround, dap_swd_fault_cfg_e fault_cfg); static bool dap_write_reg_no_check(uint16_t addr, uint32_t data); static uint32_t dap_read_reg_no_check(uint16_t addr); -static uint32_t dap_swd_clear_error(adiv5_debug_port_s *target_dp, bool protocol_recovery); bool dap_swd_init(adiv5_debug_port_s *target_dp) { @@ -85,7 +84,6 @@ bool dap_swd_init(adiv5_debug_port_s *target_dp) /* Set up the accelerated SWD functions for basic target operations */ target_dp->read_no_check = dap_read_reg_no_check; target_dp->dp_read = dap_dp_read_reg; - target_dp->error = dap_swd_clear_error; target_dp->low_access = dap_dp_low_access; target_dp->abort = dap_dp_abort; return true; @@ -176,22 +174,6 @@ static bool dap_swd_seq_in_parity(uint32_t *const result, const size_t clock_cyc return !parity; } -static void dap_line_reset(void) -{ - const uint8_t data[8] = { - 0xffU, - 0xffU, - 0xffU, - 0xffU, - 0xffU, - 0xffU, - 0xffU, - 0x0fU, - }; - if (!perform_dap_swj_sequence(64, data)) - DEBUG_ERROR("line reset failed\n"); -} - static bool dap_write_reg_no_check(const uint16_t addr, const uint32_t data) { DEBUG_PROBE("dap_write_reg_no_check %04x <- %08" PRIx32 "\n", addr, data); @@ -233,40 +215,3 @@ uint32_t dap_read_reg_no_check(const uint16_t addr) adiv5_debug_port_s dummy_dp = {0}; return dap_read_reg(&dummy_dp, addr); } - -static uint32_t dap_swd_clear_error(adiv5_debug_port_s *const target_dp, const bool protocol_recovery) -{ - DEBUG_PROBE("dap_swd_clear_error (protocol recovery? %s)\n", protocol_recovery ? "true" : "false"); - /* Only do the comms reset dance on DPv2+ w/ fault or to perform protocol recovery. */ - if ((target_dp->version >= 2 && target_dp->fault) || protocol_recovery) { - /* - * Note that on DPv2+ devices, during a protocol error condition - * the target becomes deselected during line reset. Once reset, - * we must then re-select the target to bring the device back - * into the expected state. - */ - dap_line_reset(); - if (target_dp->version >= 2) - dap_write_reg_no_check(ADIV5_DP_TARGETSEL, target_dp->targetsel); - dap_read_reg_no_check(ADIV5_DP_DPIDR); - /* Exception here is unexpected, so do not catch */ - } - const uint32_t err = dap_read_reg_no_check(ADIV5_DP_CTRLSTAT) & - (ADIV5_DP_CTRLSTAT_STICKYORUN | ADIV5_DP_CTRLSTAT_STICKYCMP | ADIV5_DP_CTRLSTAT_STICKYERR | - ADIV5_DP_CTRLSTAT_WDATAERR); - uint32_t clr = 0; - - if (err & ADIV5_DP_CTRLSTAT_STICKYORUN) - clr |= ADIV5_DP_ABORT_ORUNERRCLR; - if (err & ADIV5_DP_CTRLSTAT_STICKYCMP) - clr |= ADIV5_DP_ABORT_STKCMPCLR; - if (err & ADIV5_DP_CTRLSTAT_STICKYERR) - clr |= ADIV5_DP_ABORT_STKERRCLR; - if (err & ADIV5_DP_CTRLSTAT_WDATAERR) - clr |= ADIV5_DP_ABORT_WDERRCLR; - - if (clr) - dap_write_reg(target_dp, ADIV5_DP_ABORT, clr); - target_dp->fault = 0; - return err; -}