From 81890b1fe9475340ad461422152e28af36ac225e Mon Sep 17 00:00:00 2001 From: Rafael Silva Date: Fri, 5 Aug 2022 21:27:52 +0100 Subject: [PATCH] target/adi: clarify TARGETSEL mask and offset --- src/target/adiv5.h | 8 ++++++++ src/target/adiv5_swdp.c | 4 +++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/target/adiv5.h b/src/target/adiv5.h index 170d1fb..f9dc2c6 100644 --- a/src/target/adiv5.h +++ b/src/target/adiv5.h @@ -68,6 +68,14 @@ #define ADIV5_DP_TARGETID_TDESIGNER_OFFSET 1U #define ADIV5_DP_TARGETID_TDESIGNER_MASK (0x7ffU << ADIV5_DP_TARGETID_TDESIGNER_OFFSET) +/* DP TARGETSEL */ +#define ADIV5_DP_TARGETSEL_TINSTANCE_OFFSET 28U +#define ADIV5_DP_TARGETSEL_TINSTANCE_MASK (0xfU << ADIV5_DP_TARGETSEL_TINSTANCE_OFFSET) +#define ADIV5_DP_TARGETSEL_TPARTNO_OFFSET 12U +#define ADIV5_DP_TARGETSEL_TPARTNO_MASK (0xffffU << ADIV5_DP_TARGETSEL_TPARTNO_OFFSET) +#define ADIV5_DP_TARGETSEL_TDESIGNER_OFFSET 1U +#define ADIV5_DP_TARGETSEL_TDESIGNER_MASK (0x7ffU << ADIV5_DP_TARGETSEL_TDESIGNER_OFFSET) + /* DP DPIDR/TARGETID/IDCODE DESIGNER */ /* Bits 10:7 - JEP-106 Continuation code */ /* Bits 6:0 - JEP-106 Identity code */ diff --git a/src/target/adiv5_swdp.c b/src/target/adiv5_swdp.c index 58f3038..1c743d0 100644 --- a/src/target/adiv5_swdp.c +++ b/src/target/adiv5_swdp.c @@ -159,7 +159,9 @@ int adiv5_swdp_scan(uint32_t targetid) for (volatile size_t i = 0; i < nr_dps; i++) { if (scan_multidrop) { dp_line_reset(initial_dp); - dp_targetid = (i << 28U) | (initial_dp->target_id & 0x0fffffffU); + dp_targetid = + (i << ADIV5_DP_TARGETSEL_TINSTANCE_OFFSET) | + (initial_dp->target_id & (ADIV5_DP_TARGETSEL_TPARTNO_MASK | ADIV5_DP_TARGETSEL_TDESIGNER_MASK | 1U)); initial_dp->dp_low_write(initial_dp, ADIV5_DP_TARGETSEL, dp_targetid); TRY_CATCH (e, EXCEPTION_ALL) { dp_debug_port_id = initial_dp->dp_read(initial_dp, ADIV5_DP_DPIDR);