adiv5: Read TARGETID on DPv2 devices.

This commit is contained in:
Uwe Bonnes 2018-09-10 21:21:26 +02:00 committed by Gareth McMullin
parent cde7726b87
commit 489f24584b
2 changed files with 20 additions and 0 deletions

View File

@ -439,6 +439,14 @@ void adiv5_dp_init(ADIv5_DP_t *dp)
ADIV5_DP_CTRLSTAT_CDBGRSTACK);
}
dp->dp_idcode = adiv5_dp_read(dp, ADIV5_DP_IDCODE);
if ((dp->dp_idcode & ADIV5_DP_VERSION_MASK) == ADIV5_DPv2) {
/* Read TargetID. Can be done with device in WFI, sleep or reset!*/
adiv5_dp_write(dp, ADIV5_DP_SELECT, ADIV5_DP_BANK2);
dp->targetid = adiv5_dp_read(dp, ADIV5_DP_CTRLSTAT);
adiv5_dp_write(dp, ADIV5_DP_SELECT, ADIV5_DP_BANK0);
DEBUG("TARGETID %08" PRIx32 "\n", dp->targetid);
}
/* Probe for APs on this DP */
for(int i = 0; i < 256; i++) {
ADIv5_AP_t *ap = adiv5_new_ap(dp, i);

View File

@ -34,6 +34,16 @@
#define ADIV5_DP_SELECT ADIV5_DP_REG(0x8)
#define ADIV5_DP_RDBUFF ADIV5_DP_REG(0xC)
#define ADIV5_DP_BANK0 0
#define ADIV5_DP_BANK1 1
#define ADIV5_DP_BANK2 2
#define ADIV5_DP_BANK3 3
#define ADIV5_DP_BANK4 4
#define ADIV5_DP_VERSION_MASK 0xf000
#define ADIV5_DPv1 0x1000
#define ADIV5_DPv2 0x2000
/* AP Abort Register (ABORT) */
/* Bits 31:5 - Reserved */
#define ADIV5_DP_ABORT_ORUNERRCLR (1 << 4)
@ -112,6 +122,8 @@ typedef struct ADIv5_DP_s {
int refcnt;
uint32_t idcode;
uint32_t dp_idcode; /* Contains DPvX revision*/
uint32_t targetid; /* Contains IDCODE for DPv2 devices.*/
uint32_t (*dp_read)(struct ADIv5_DP_s *dp, uint16_t addr);
uint32_t (*error)(struct ADIv5_DP_s *dp);