File tree Expand file tree Collapse file tree 4 files changed +21
-6
lines changed Expand file tree Collapse file tree 4 files changed +21
-6
lines changed Original file line number Diff line number Diff line change 167
167
#define JTAG_IDCODE_PARTNO_MASK (0xffffU << JTAG_IDCODE_PARTNO_OFFSET)
168
168
#define JTAG_IDCODE_DESIGNER_OFFSET 1U
169
169
#define JTAG_IDCODE_DESIGNER_MASK (0x7ffU << JTAG_IDCODE_DESIGNER_OFFSET)
170
+ /* Bits 10:7 - JEP-106 Continuation code */
171
+ /* Bits 6:0 - JEP-106 Identity code */
172
+ #define JTAG_IDCODE_DESIGNER_JEP106_CONT_OFFSET 7U
173
+ #define JTAG_IDCODE_DESIGNER_JEP106_CONT_MASK (0xfU << ADIV5_DP_DESIGNER_JEP106_CONT_OFFSET)
174
+ #define JTAG_IDCODE_DESIGNER_JEP106_CODE_MASK (0x7fU)
170
175
171
176
#define JTAG_IDCODE_ARM_DPv0 UINT32_C(0x4ba00477)
172
177
Original file line number Diff line number Diff line change @@ -352,10 +352,8 @@ static bool riscv_hart_init(riscv_hart_s *const hart)
352
352
return true;
353
353
}
354
354
355
- /* If the hart implements mvendorid, this gives us the JEP-106, otherwise use the JTAG IDCode */
356
- target -> designer_code = hart -> vendorid ?
357
- hart -> vendorid :
358
- ((hart -> dbg_module -> dmi_bus -> idcode & JTAG_IDCODE_DESIGNER_MASK ) >> JTAG_IDCODE_DESIGNER_OFFSET );
355
+ /* If the hart implements mvendorid, this gives us the JEP-106, otherwise use the DTM designer code */
356
+ target -> designer_code = hart -> vendorid ? hart -> vendorid : hart -> dbg_module -> dmi_bus -> designer_code ;
359
357
target -> cpuid = hart -> archid ;
360
358
361
359
riscv_hart_discover_triggers (hart );
Original file line number Diff line number Diff line change @@ -90,7 +90,7 @@ typedef struct riscv_dmi riscv_dmi_s;
90
90
struct riscv_dmi {
91
91
uint32_t ref_count ;
92
92
93
- uint32_t idcode ;
93
+ uint16_t designer_code ;
94
94
riscv_debug_version_e version ;
95
95
96
96
uint8_t dev_index ;
Original file line number Diff line number Diff line change 35
35
#include "jtag_scan.h"
36
36
#include "jtagtap.h"
37
37
#include "riscv_debug.h"
38
+ #include "adiv5.h"
38
39
39
40
#define IR_DTMCS 0x10U
40
41
#define IR_DMI 0x11U
@@ -75,12 +76,23 @@ void riscv_jtag_dtm_handler(const uint8_t dev_index)
75
76
}
76
77
77
78
/* Setup and try to discover the DMI bus */
78
- dmi -> idcode = jtag_devs [dev_index ].jd_idcode ;
79
79
dmi -> dev_index = dev_index ;
80
+ /*
81
+ * The code in JTAG_IDCODE_DESIGNER is in the form
82
+ * Bits 10:7 - JEP-106 Continuation code
83
+ * Bits 6:0 - JEP-106 Identity code
84
+ * here we convert it to our internal representation, See JEP-106 code list
85
+ */
86
+ const uint16_t designer =
87
+ (jtag_devs [dev_index ].jd_idcode & JTAG_IDCODE_DESIGNER_MASK ) >> JTAG_IDCODE_DESIGNER_OFFSET ;
88
+ dmi -> designer_code =
89
+ (designer & JTAG_IDCODE_DESIGNER_JEP106_CONT_MASK ) << 1U | (designer & JTAG_IDCODE_DESIGNER_JEP106_CODE_MASK );
90
+
80
91
riscv_jtag_dtm_init (dmi );
81
92
/* If we failed to find any DMs or Harts, free the structure */
82
93
if (!dmi -> ref_count )
83
94
free (dmi );
95
+
84
96
/* Reset the JTAG machinary back to bypass to scan the next device in the chain */
85
97
jtag_dev_write_ir (dev_index , IR_BYPASS );
86
98
}
You can’t perform that action at this time.
0 commit comments