adiv5: Cleaned up and made use of the DP bank selection macros
This commit is contained in:
parent
0c708ffa48
commit
e59ebb0e1d
|
@ -739,9 +739,10 @@ void adiv5_dp_init(ADIv5_DP_t *dp, const uint32_t idcode)
|
|||
DEBUG_WARN("DPv0 detected based on JTAG IDCode\n");
|
||||
|
||||
if (dp->version >= 2) {
|
||||
adiv5_dp_write(dp, ADIV5_DP_SELECT, 2); /* TARGETID is on bank 2 */
|
||||
/* TARGETID is on bank 2 */
|
||||
adiv5_dp_write(dp, ADIV5_DP_SELECT, ADIV5_DP_BANK2);
|
||||
const uint32_t targetid = adiv5_dp_read(dp, ADIV5_DP_TARGETID);
|
||||
adiv5_dp_write(dp, ADIV5_DP_SELECT, 0);
|
||||
adiv5_dp_write(dp, ADIV5_DP_SELECT, ADIV5_DP_BANK0);
|
||||
|
||||
/* Use TARGETID register to identify target */
|
||||
const uint16_t tdesigner = (targetid & ADIV5_DP_TARGETID_TDESIGNER_MASK) >> ADIV5_DP_TARGETID_TDESIGNER_OFFSET;
|
||||
|
|
|
@ -31,12 +31,6 @@
|
|||
#define ADIV5_DP_REG(x) (x)
|
||||
#define ADIV5_AP_REG(x) (ADIV5_APnDP | (x))
|
||||
|
||||
#define ADIV5_DP_BANK0 0x00U
|
||||
#define ADIV5_DP_BANK1 0x10U
|
||||
#define ADIV5_DP_BANK2 0x20U
|
||||
#define ADIV5_DP_BANK3 0x30U
|
||||
#define ADIV5_DP_BANK4 0x40U
|
||||
|
||||
/* ADIv5 DP Register addresses */
|
||||
#define ADIV5_DP_DPIDR ADIV5_DP_REG(0x0U)
|
||||
#define ADIV5_DP_ABORT ADIV5_DP_REG(0x0U)
|
||||
|
@ -60,6 +54,13 @@
|
|||
#define ADIV5_DP_DPIDR_DESIGNER_OFFSET 1U
|
||||
#define ADIV5_DP_DPIDR_DESIGNER_MASK (0x7ffU << ADIV5_DP_DPIDR_DESIGNER_OFFSET)
|
||||
|
||||
/* DP SELECT register DP bank numbers */
|
||||
#define ADIV5_DP_BANK0 0U
|
||||
#define ADIV5_DP_BANK1 1U
|
||||
#define ADIV5_DP_BANK2 2U
|
||||
#define ADIV5_DP_BANK3 3U
|
||||
#define ADIV5_DP_BANK4 4U
|
||||
|
||||
/* DP TARGETID */
|
||||
#define ADIV5_DP_TARGETID_TREVISION_OFFSET 28U
|
||||
#define ADIV5_DP_TARGETID_TREVISION_MASK (0xfU << ADIV5_DP_TARGETID_TREVISION_OFFSET)
|
||||
|
|
|
@ -140,10 +140,11 @@ uint32_t adiv5_swdp_scan(uint32_t targetid)
|
|||
if (dp_version >= 2) {
|
||||
scan_multidrop = true;
|
||||
|
||||
/* Read TargetID. Can be done with device in WFI, sleep or reset!*/
|
||||
adiv5_dp_write(initial_dp, ADIV5_DP_SELECT, 2); /* TARGETID is on bank 2 */
|
||||
/* Read TargetID. Can be done with device in WFI, sleep or reset! */
|
||||
/* TARGETID is on bank 2 */
|
||||
adiv5_dp_write(initial_dp, ADIV5_DP_SELECT, ADIV5_DP_BANK2);
|
||||
dp_targetid = adiv5_dp_read(initial_dp, ADIV5_DP_TARGETID);
|
||||
adiv5_dp_write(initial_dp, ADIV5_DP_SELECT, 0);
|
||||
adiv5_dp_write(initial_dp, ADIV5_DP_SELECT, ADIV5_DP_BANK0);
|
||||
|
||||
const uint16_t tdesigner =
|
||||
(dp_targetid & ADIV5_DP_TARGETID_TDESIGNER_MASK) >> ADIV5_DP_TARGETID_TDESIGNER_OFFSET;
|
||||
|
|
Loading…
Reference in New Issue