jtag_dev_t: Make dev, idcode and desc less generic.

No codechange intended.
This commit is contained in:
Uwe Bonnes 2020-10-09 12:10:05 +02:00
parent 87b546777a
commit 7ccf0d3e03
5 changed files with 19 additions and 19 deletions

View File

@ -340,7 +340,7 @@ uint32_t dap_read_reg(ADIv5_DP_t *dp, uint8_t reg)
uint8_t buf[8];
uint8_t dap_index = 0;
if (dp->dev)
dap_index = dp->dev->dev;
dap_index = dp->dev->jd_dev;
buf[0] = ID_DAP_TRANSFER;
buf[1] = dap_index;
buf[2] = 0x01; // Request size
@ -359,7 +359,7 @@ void dap_write_reg(ADIv5_DP_t *dp, uint8_t reg, uint32_t data)
buf[0] = ID_DAP_TRANSFER;
uint8_t dap_index = 0;
if (dp->dev)
dap_index = dp->dev->dev;
dap_index = dp->dev->jd_dev;
buf[1] = dap_index;
buf[2] = 0x01; // Request size
buf[3] = reg & ~DAP_TRANSFER_RnW;;
@ -391,7 +391,7 @@ unsigned int dap_read_block(ADIv5_AP_t *ap, void *dest, uint32_t src,
unsigned int sz = len >> align;
uint8_t dap_index = 0;
if (ap->dp->dev)
dap_index = ap->dp->dev->dev;
dap_index = ap->dp->dev->jd_dev;
buf[0] = ID_DAP_TRANSFER_BLOCK;
buf[1] = dap_index;
buf[2] = sz & 0xff;
@ -427,7 +427,7 @@ unsigned int dap_write_block(ADIv5_AP_t *ap, uint32_t dest, const void *src,
unsigned int sz = len >> align;
uint8_t dap_index = 0;
if (ap->dp->dev)
dap_index = ap->dp->dev->dev;
dap_index = ap->dp->dev->jd_dev;
buf[0] = ID_DAP_TRANSFER_BLOCK;
buf[1] = dap_index;
buf[2] = sz & 0xff;
@ -528,7 +528,7 @@ static uint8_t *mem_access_setup(ADIv5_AP_t *ap, uint8_t *p,
}
uint8_t dap_index = 0;
if (ap->dp->dev)
dap_index = ap->dp->dev->dev;
dap_index = ap->dp->dev->jd_dev;
*p++ = ID_DAP_TRANSFER;
*p++ = dap_index;
*p++ = 3; /* Nr transfers */
@ -564,7 +564,7 @@ uint32_t dap_ap_read(ADIv5_AP_t *ap, uint16_t addr)
buf[0] = ID_DAP_TRANSFER;
uint8_t dap_index = 0;
if (ap->dp->dev)
dap_index = ap->dp->dev->dev;
dap_index = ap->dp->dev->jd_dev;
*p++ = ID_DAP_TRANSFER;
*p++ = dap_index;
*p++ = 2; /* Nr transfers */
@ -585,7 +585,7 @@ void dap_ap_write(ADIv5_AP_t *ap, uint16_t addr, uint32_t value)
uint8_t buf[63], *p = buf;
uint8_t dap_index = 0;
if (ap->dp->dev)
dap_index = ap->dp->dev->dev;
dap_index = ap->dp->dev->jd_dev;
*p++ = ID_DAP_TRANSFER;
*p++ = dap_index;
*p++ = 2; /* Nr transfers */

View File

@ -1041,10 +1041,10 @@ int jtag_scan_stlinkv2(bmp_info_t *info, const uint8_t *irlens)
jtag_dev_count = stlink_read_idcodes(info, idcodes);
/* Check for known devices and handle accordingly */
for(int i = 0; i < jtag_dev_count; i++)
jtag_devs[i].idcode = idcodes[i];
jtag_devs[i].jd_idcode = idcodes[i];
for(int i = 0; i < jtag_dev_count; i++)
for(int j = 0; dev_descr[j].idcode; j++)
if((jtag_devs[i].idcode & dev_descr[j].idmask) ==
if((jtag_devs[i].jd_idcode & dev_descr[j].idmask) ==
dev_descr[j].idcode) {
if(dev_descr[j].handler)
dev_descr[j].handler(&jtag_devs[i]);

View File

@ -51,7 +51,7 @@ void adiv5_jtag_dp_handler(jtag_dev_t *dev)
dp->dev = dev;
if ((PC_HOSTED == 0 ) || (!platform_jtag_dp_init(dp))) {
dp->idcode = dev->idcode;
dp->idcode = dev->jd_idcode;
dp->dp_read = fw_adiv5_jtagdp_read;
dp->error = adiv5_jtagdp_error;
dp->low_access = fw_adiv5_jtagdp_low_access;

View File

@ -94,7 +94,7 @@ int jtag_scan(const uint8_t *irlens)
}
jtag_devs[jtag_dev_count].ir_len = *irlens;
jtag_devs[jtag_dev_count].ir_prescan = j;
jtag_devs[jtag_dev_count].dev = jtag_dev_count;
jtag_devs[jtag_dev_count].jd_dev = jtag_dev_count;
j += *irlens;
irlens++;
jtag_dev_count++;
@ -117,7 +117,7 @@ int jtag_scan(const uint8_t *irlens)
if(jtag_devs[jtag_dev_count].ir_len == 1) break;
jtag_devs[++jtag_dev_count].ir_len = 1;
jtag_devs[jtag_dev_count].ir_prescan = j;
jtag_devs[jtag_dev_count].dev = jtag_dev_count;
jtag_devs[jtag_dev_count].jd_dev = jtag_dev_count;
} else jtag_devs[jtag_dev_count].ir_len++;
j++;
}
@ -169,9 +169,9 @@ int jtag_scan(const uint8_t *irlens)
jtagtap_shift_dr();
for(i = 0; i < jtag_dev_count; i++) {
if(!jtag_proc.jtagtap_next(0, 1)) continue;
jtag_devs[i].idcode = 1;
jtag_devs[i].jd_idcode = 1;
for(j = 2; j; j <<= 1)
if(jtag_proc.jtagtap_next(0, 1)) jtag_devs[i].idcode |= j;
if(jtag_proc.jtagtap_next(0, 1)) jtag_devs[i].jd_idcode |= j;
}
DEBUG_INFO("Return to Run-Test/Idle\n");
@ -181,11 +181,11 @@ int jtag_scan(const uint8_t *irlens)
/* Check for known devices and handle accordingly */
for(i = 0; i < jtag_dev_count; i++)
for(j = 0; dev_descr[j].idcode; j++)
if((jtag_devs[i].idcode & dev_descr[j].idmask) ==
if((jtag_devs[i].jd_idcode & dev_descr[j].idmask) ==
dev_descr[j].idcode) {
jtag_devs[i].current_ir = -1;
/* Save description in table */
jtag_devs[i].descr = dev_descr[j].descr;
jtag_devs[i].jd_descr = dev_descr[j].descr;
/* Call handler to initialise/probe device further */
if(dev_descr[j].handler)
dev_descr[j].handler(&jtag_devs[i]);

View File

@ -27,7 +27,7 @@
typedef struct jtag_dev_s {
union {
uint8_t dev;
uint8_t jd_dev;
uint8_t dr_prescan;
};
uint8_t dr_postscan;
@ -35,8 +35,8 @@ typedef struct jtag_dev_s {
uint8_t ir_len;
uint8_t ir_prescan;
uint8_t ir_postscan;
uint32_t idcode;
const char *descr;
uint32_t jd_idcode;
const char *jd_descr;
uint32_t current_ir;
} jtag_dev_t;