1 # SPDX-License-Identifier: GPL-2.0-or-later
2 # Copyright (C) 2019-2021 Texas Instruments Incorporated - http://www.ti.com/
4 # Texas Instruments K3 devices:
5 # * AM654x: https://www.ti.com/lit/pdf/spruid7
6 # Has 4 ARMV8 Cores and 2 R5 Cores and an M3
7 # * J721E: https://www.ti.com/lit/pdf/spruil1
8 # Has 2 ARMV8 Cores and 6 R5 Cores and an M3
9 # * J7200: https://www.ti.com/lit/pdf/spruiu1
10 # Has 2 ARMV8 Cores and 4 R5 Cores and an M3
11 # * J721S2: https://www.ti.com/lit/pdf/spruj28
12 # Has 2 ARMV8 Cores and 6 R5 Cores and an M4F
13 # * AM642: https://www.ti.com/lit/pdf/spruim2
14 # Has 2 ARMV8 Cores and 4 R5 Cores, M4F and an M3
15 # * AM625: https://www.ti.com/lit/pdf/spruiv7a
16 # Has 4 ARMV8 Cores and 1 R5 Core and an M4F
17 # * AM62a7: https://www.ti.com/lit/pdf/spruj16a
18 # Has 4 ARMV8 Cores and 2 R5 Cores
21 source [find target/swj-dp.tcl]
23 if { [info exists SOC] } {
29 # set V8_SMP_DEBUG to non 0 value in board if you'd like to use SMP debug
30 if { [info exists V8_SMP_DEBUG] } {
31 set _v8_smp_debug $V8_SMP_DEBUG
38 # System Controller is the very first processor - all current SoCs have it.
39 set CM3_CTIBASE {0x3C016000}
41 # sysctrl power-ap unlock offsets
42 set _sysctrl_ap_unlock_offsets {0xf0 0x44}
44 # All the ARMV8s are the next processors.
45 # CL0,CORE0 CL0,CORE1 CL1,CORE0 CL1,CORE1
46 set ARMV8_DBGBASE {0x90410000 0x90510000 0x90810000 0x90910000}
47 set ARMV8_CTIBASE {0x90420000 0x90520000 0x90820000 0x90920000}
49 # And we add up the R5s
50 # (0)MCU 0 (1)MCU 1 (2)MAIN_0_0 (3)MAIN_0_1 (4)MAIN_1_0 (5)MAIN_1_1
51 set R5_DBGBASE {0x9d010000 0x9d012000 0x9d410000 0x9d412000 0x9d510000 0x9d512000}
52 set R5_CTIBASE {0x9d018000 0x9d019000 0x9d418000 0x9d419000 0x9d518000 0x9d519000}
53 set R5_NAMES {mcu_r5.0 mcu_r5.1 main0_r5.0 main0_r5.1 main1_r5.0 main1_r5.1}
55 # Finally an General Purpose(GP) MCU
56 set CM4_CTIBASE {0x20001000}
58 # General Purpose MCU (M4) may be present on some very few SoCs
60 # General Purpose MCU power-ap unlock offsets
61 set _gp_mcu_ap_unlock_offsets {0xf0 0x60}
63 # Set configuration overrides for each SOC
66 set _K3_DAP_TAPID 0x0bb5a02f
68 # AM654 has 2 clusters of 2 A53 cores each.
69 set _armv8_cpu_name a53
72 # AM654 has 1 cluster of 2 R5s cores.
74 set R5_NAMES {mcu_r5.0 mcu_r5.1}
76 # Sysctrl power-ap unlock offsets
77 set _sysctrl_ap_unlock_offsets {0xf0 0x50}
80 set _K3_DAP_TAPID 0x0bb3802f
82 # AM642 has 1 clusters of 2 A53 cores each.
83 set _armv8_cpu_name a53
85 set ARMV8_DBGBASE {0x90010000 0x90110000}
86 set ARMV8_CTIBASE {0x90020000 0x90120000}
88 # AM642 has 2 cluster of 2 R5s cores.
90 set R5_NAMES {main0_r5.0 main0_r5.1 main1_r5.0 main1_r5.1}
91 set R5_DBGBASE {0x9d410000 0x9d412000 0x9d510000 0x9d512000}
92 set R5_CTIBASE {0x9d418000 0x9d419000 0x9d518000 0x9d519000}
98 set _K3_DAP_TAPID 0x0bb7e02f
100 # AM625 has 1 clusters of 4 A53 cores.
101 set _armv8_cpu_name a53
103 set ARMV8_DBGBASE {0x90010000 0x90110000 0x90210000 0x90310000}
104 set ARMV8_CTIBASE {0x90020000 0x90120000 0x90220000 0x90320000}
106 # AM625 has 1 cluster of 1 R5s core.
108 set R5_NAMES {main0_r5.0}
109 set R5_DBGBASE {0x9d410000}
110 set R5_CTIBASE {0x9d418000}
113 set CM3_CTIBASE {0x20001000}
114 # Sysctrl power-ap unlock offsets
115 set _sysctrl_ap_unlock_offsets {0xf0 0x78}
119 set _gp_mcu_ap_unlock_offsets {0xf0 0x7c}
121 # Setup DMEM access descriptions
122 # DAPBUS (Debugger) description
123 set _dmem_base_address 0x740002000
124 set _dmem_ap_address_offset 0x100
126 # Emulated AP description
127 set _dmem_emu_base_address 0x760000000
128 set _dmem_emu_base_address_map_to 0x1d500000
129 set _dmem_emu_ap_list 1
132 set _K3_DAP_TAPID 0x0bb8d02f
134 # AM62a7 has 1 clusters of 4 A53 cores.
135 set _armv8_cpu_name a53
137 set ARMV8_DBGBASE {0x90010000 0x90110000 0x90210000 0x90310000}
138 set ARMV8_CTIBASE {0x90020000 0x90120000 0x90220000 0x90320000}
140 # AM62a7 has 2 cluster of 1 R5s core.
142 set R5_NAMES {main0_r5.0 mcu0_r5.0}
143 set R5_DBGBASE {0x9d410000 0x9d810000}
144 set R5_CTIBASE {0x9d418000 0x9d818000}
147 set CM3_CTIBASE {0x20001000}
148 # Sysctrl power-ap unlock offsets
149 set _sysctrl_ap_unlock_offsets {0xf0 0x78}
152 set _K3_DAP_TAPID 0x0bb6402f
153 # J721E has 1 cluster of 2 A72 cores.
154 set _armv8_cpu_name a72
157 # J721E has 3 clusters of 2 R5 cores each.
160 # Setup DMEM access descriptions
161 # DAPBUS (Debugger) description
162 set _dmem_base_address 0x4c40002000
163 set _dmem_ap_address_offset 0x100
165 # Emulated AP description
166 set _dmem_emu_base_address 0x4c60000000
167 set _dmem_emu_base_address_map_to 0x1d600000
168 set _dmem_emu_ap_list 1
171 set _K3_DAP_TAPID 0x0bb6d02f
173 # J7200 has 1 cluster of 2 A72 cores.
174 set _armv8_cpu_name a72
177 # J7200 has 2 clusters of 2 R5 cores each.
179 set R5_DBGBASE {0x9d010000 0x9d012000 0x9d110000 0x9d112000}
180 set R5_CTIBASE {0x9d018000 0x9d019000 0x9d118000 0x9d119000}
183 set CM3_CTIBASE {0x20001000}
186 set _K3_DAP_TAPID 0x0bb7502f
188 # J721s2 has 1 cluster of 2 A72 cores.
189 set _armv8_cpu_name a72
192 # J721s2 has 3 clusters of 2 R5 cores each.
196 set CM3_CTIBASE {0x20001000}
197 # Sysctrl power-ap unlock offsets
198 set _sysctrl_ap_unlock_offsets {0xf0 0x78}
202 set _gp_mcu_ap_unlock_offsets {0xf0 0x7c}
205 echo "'$_soc' is invalid!"
211 swj_newdap $_CHIPNAME cpu -irlen 4 -expected-id $_K3_DAP_TAPID -ignore-version
213 dap create $_CHIPNAME.dap -chain-position $_CHIPNAME.cpu
215 set _TARGETNAME $_CHIPNAME.cpu
217 set _CTINAME $_CHIPNAME.cti
219 # sysctrl is always present
220 cti create $_CTINAME.sysctrl -dap $_CHIPNAME.dap -ap-num 7 -baseaddr [lindex $CM3_CTIBASE 0]
221 target create $_TARGETNAME.sysctrl cortex_m -dap $_CHIPNAME.dap -ap-num 7 -defer-examine
222 $_TARGETNAME.sysctrl configure -event reset-assert { }
225 # To access sysctrl, we need to enable the JTAG access for the same.
226 # Ensure Power-AP unlocked
227 $::_CHIPNAME.dap apreg 3 [lindex $::_sysctrl_ap_unlock_offsets 0] 0x00190000
228 $::_CHIPNAME.dap apreg 3 [lindex $::_sysctrl_ap_unlock_offsets 1] 0x00102098
230 $::_TARGETNAME.sysctrl arp_examine
233 $_TARGETNAME.sysctrl configure -event gdb-attach {
235 # gdb-attach default rule
239 proc _cpu_no_smp_up {} {
240 set _current_target [target current]
241 set _current_type [$_current_target cget -type]
243 $_current_target arp_examine
244 $_current_target $_current_type dbginit
247 proc _armv8_smp_up {} {
248 for { set _core 0 } { $_core < $::_armv8_cores } { incr _core } {
249 $::_TARGETNAME.$::_armv8_cpu_name.$_core arp_examine
250 $::_TARGETNAME.$::_armv8_cpu_name.$_core aarch64 dbginit
251 $::_TARGETNAME.$::_armv8_cpu_name.$_core aarch64 smp on
253 # Set Default target as core 0
254 targets $::_TARGETNAME.$::_armv8_cpu_name.0
257 set _v8_smp_targets ""
259 for { set _core 0 } { $_core < $_armv8_cores } { incr _core } {
261 cti create $_CTINAME.$_armv8_cpu_name.$_core -dap $_CHIPNAME.dap -ap-num 1 \
262 -baseaddr [lindex $ARMV8_CTIBASE $_core]
264 target create $_TARGETNAME.$_armv8_cpu_name.$_core aarch64 -dap $_CHIPNAME.dap \
265 -dbgbase [lindex $ARMV8_DBGBASE $_core] -cti $_CTINAME.$_armv8_cpu_name.$_core -defer-examine
267 set _v8_smp_targets "$_v8_smp_targets $_TARGETNAME.$_armv8_cpu_name.$_core"
269 if { $_v8_smp_debug == 0 } {
270 $_TARGETNAME.$_armv8_cpu_name.$_core configure -event gdb-attach {
272 # gdb-attach default rule
276 $_TARGETNAME.$_armv8_cpu_name.$_core configure -event gdb-attach {
278 # gdb-attach default rule
284 # Setup ARMV8 proc commands based on CPU to prevent people confusing SoCs
285 set _armv8_up_cmd "$_armv8_cpu_name"_up
286 # Available if V8_SMP_DEBUG is set to non-zero value
287 set _armv8_smp_cmd "$_armv8_cpu_name"_smp
289 if { $_v8_smp_debug == 0 } {
290 proc $_armv8_up_cmd { args } {
291 foreach _core $args {
297 proc $_armv8_smp_cmd { args } {
301 target smp $:::_v8_smp_targets
304 for { set _core 0 } { $_core < $_r5_cores } { incr _core } {
305 set _r5_name [lindex $R5_NAMES $_core]
306 cti create $_CTINAME.$_r5_name -dap $_CHIPNAME.dap -ap-num 1 \
307 -baseaddr [lindex $R5_CTIBASE $_core]
309 # inactive core examination will fail - wait till startup of additional core
310 target create $_TARGETNAME.$_r5_name cortex_r4 -dap $_CHIPNAME.dap \
311 -dbgbase [lindex $R5_DBGBASE $_core] -ap-num 1 -defer-examine
313 $_TARGETNAME.$_r5_name configure -event gdb-attach {
315 # gdb-attach default rule
320 proc r5_up { args } {
321 foreach _core $args {
327 if { $_gp_mcu_cores != 0 } {
328 cti create $_CTINAME.gp_mcu -dap $_CHIPNAME.dap -ap-num 8 -baseaddr [lindex $CM4_CTIBASE 0]
329 target create $_TARGETNAME.gp_mcu cortex_m -dap $_CHIPNAME.dap -ap-num 8 -defer-examine
330 $_TARGETNAME.gp_mcu configure -event reset-assert { }
333 # To access GP MCU, we need to enable the JTAG access for the same.
334 # Ensure Power-AP unlocked
335 $::_CHIPNAME.dap apreg 3 [lindex $::_gp_mcu_ap_unlock_offsets 0] 0x00190000
336 $::_CHIPNAME.dap apreg 3 [lindex $::_gp_mcu_ap_unlock_offsets 1] 0x00102098
338 $::_TARGETNAME.gp_mcu arp_examine
341 $_TARGETNAME.gp_mcu configure -event gdb-attach {
343 # gdb-attach default rule
348 # In case of DMEM access, configure the dmem adapter with offsets from above.
349 if { 0 == [string compare [adapter name] dmem ] } {
350 if { [info exists _dmem_base_address] } {
351 # DAPBUS (Debugger) description
352 dmem base_address $_dmem_base_address
353 dmem ap_address_offset $_dmem_ap_address_offset
354 dmem max_aps $_dmem_max_aps
356 # The following are the details of APs to be emulated for direct address access.
357 # Debug Config (Debugger) description
358 dmem emu_base_address_range $_dmem_emu_base_address $_dmem_emu_base_address_map_to
359 dmem emu_ap_list $_dmem_emu_ap_list
360 # We are going local bus, so speed is really dummy here.
363 puts "ERROR: ${SOC} data is missing to support dmem access!"