ti_k3.cfg 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256
  1. # SPDX-License-Identifier: GPL-2.0-or-later
  2. # Copyright (C) 2019-2021 Texas Instruments Incorporated - http://www.ti.com/
  3. #
  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. # * AM642: https://www.ti.com/lit/pdf/spruim2
  12. # Has 2 ARMV8 Cores and 4 R5 Cores, M4F and an M3
  13. #
  14. if { [info exists SOC] } {
  15. set _soc $SOC
  16. } else {
  17. set _soc am654
  18. }
  19. # set V8_SMP_DEBUG to non 0 value in board if you'd like to use SMP debug
  20. if { [info exists V8_SMP_DEBUG] } {
  21. set _v8_smp_debug $V8_SMP_DEBUG
  22. } else {
  23. set _v8_smp_debug 0
  24. }
  25. # Common Definitions
  26. # CM3 the very first processor - all current SoCs have it.
  27. set CM3_CTIBASE {0x3C016000}
  28. # M3 power-ap unlock offsets
  29. set _m3_ap_unlock_offsets {0xf0 0x44}
  30. # All the ARMV8s are the next processors.
  31. # CL0,CORE0 CL0,CORE1 CL1,CORE0 CL1,CORE1
  32. set ARMV8_DBGBASE {0x90410000 0x90510000 0x90810000 0x90910000}
  33. set ARMV8_CTIBASE {0x90420000 0x90520000 0x90820000 0x90920000}
  34. # And we add up the R5s
  35. # (0)MCU 0 (1)MCU 1 (2)MAIN_0_0 (3)MAIN_0_1 (4)MAIN_1_0 (5)MAIN_1_1
  36. set R5_DBGBASE {0x9d010000 0x9d012000 0x9d410000 0x9d412000 0x9d510000 0x9d512000}
  37. set R5_CTIBASE {0x9d018000 0x9d019000 0x9d418000 0x9d419000 0x9d518000 0x9d519000}
  38. # Finally an M4F
  39. set CM4_CTIBASE {0x20001000}
  40. # M4 may be present on some very few SoCs
  41. set _mcu_m4_cores 0
  42. # M4 power-ap unlock offsets
  43. set _m4_ap_unlock_offsets {0xf0 0x60}
  44. # Set configuration overrides for each SOC
  45. switch $_soc {
  46. am654 {
  47. set _CHIPNAME am654
  48. set _K3_DAP_TAPID 0x0bb5a02f
  49. # AM654 has 2 clusters of 2 A53 cores each.
  50. set _armv8_cpu_name a53
  51. set _armv8_cores 4
  52. # AM654 has 1 cluster of 2 R5s cores.
  53. set _r5_cores 2
  54. set _mcu_r5_cores 2
  55. set _mcu_base_core_id 0
  56. set _main0_r5_cores 0
  57. set _main0_base_core_id 0
  58. set _main1_r5_cores 0
  59. set _main1_base_core_id 0
  60. # M3 power-ap unlock offsets
  61. set _m3_ap_unlock_offsets {0xf0 0x50}
  62. }
  63. am642 {
  64. set _CHIPNAME am642
  65. set _K3_DAP_TAPID 0x0bb3802f
  66. # AM642 has 1 clusters of 2 A53 cores each.
  67. set _armv8_cpu_name a53
  68. set _armv8_cores 2
  69. set ARMV8_DBGBASE {0x90010000 0x90110000}
  70. set ARMV8_CTIBASE {0x90020000 0x90120000}
  71. # AM642 has 2 cluster of 2 R5s cores.
  72. set _r5_cores 4
  73. set _mcu_r5_cores 0
  74. set _mcu_base_core_id 0
  75. set _main0_r5_cores 2
  76. set _main0_base_core_id 0
  77. set _main1_r5_cores 2
  78. set _main1_base_core_id 2
  79. set R5_DBGBASE {0x9d410000 0x9d412000 0x9d510000 0x9d512000}
  80. set R5_CTIBASE {0x9d418000 0x9d419000 0x9d518000 0x9d519000}
  81. # M4 processor
  82. set _mcu_m4_cores 1
  83. }
  84. j721e {
  85. set _CHIPNAME j721e
  86. set _K3_DAP_TAPID 0x0bb6402f
  87. # J721E has 1 cluster of 2 A72 cores.
  88. set _armv8_cpu_name a72
  89. set _armv8_cores 2
  90. # J721E has 3 clusters of 2 R5 cores each.
  91. set _r5_cores 6
  92. set _mcu_r5_cores 2
  93. set _mcu_base_core_id 0
  94. set _main0_r5_cores 2
  95. set _main0_base_core_id 2
  96. set _main1_r5_cores 2
  97. set _main1_base_core_id 4
  98. }
  99. j7200 {
  100. set _CHIPNAME j7200
  101. set _K3_DAP_TAPID 0x0bb6d02f
  102. # J7200 has 1 cluster of 2 A72 cores.
  103. set _armv8_cpu_name a72
  104. set _armv8_cores 2
  105. # J7200 has 2 clusters of 2 R5 cores each.
  106. set _r5_cores 4
  107. set _mcu_r5_cores 2
  108. set _mcu_base_core_id 0
  109. set _main0_r5_cores 2
  110. set _main0_base_core_id 2
  111. set _main1_r5_cores 0
  112. set _main1_base_core_id 0
  113. set R5_DBGBASE {0x9d010000 0x9d012000 0x9d110000 0x9d112000}
  114. set R5_CTIBASE {0x9d018000 0x9d019000 0x9d118000 0x9d119000}
  115. # M3 CTI base
  116. set CM3_CTIBASE {0x20001000}
  117. }
  118. default {
  119. echo "'$_soc' is invalid!"
  120. }
  121. }
  122. jtag newtap $_CHIPNAME cpu -irlen 4 -expected-id $_K3_DAP_TAPID -ignore-version
  123. dap create $_CHIPNAME.dap -chain-position $_CHIPNAME.cpu
  124. set _TARGETNAME $_CHIPNAME.cpu
  125. set _CTINAME $_CHIPNAME.cti
  126. # M3 is always present
  127. cti create $_CTINAME.m3 -dap $_CHIPNAME.dap -ap-num 7 -baseaddr [lindex $CM3_CTIBASE 0]
  128. target create $_TARGETNAME.m3 cortex_m -dap $_CHIPNAME.dap -ap-num 7 -defer-examine
  129. $_TARGETNAME.m3 configure -event reset-assert { }
  130. proc m3_up { args } {
  131. # To access M3, we need to enable the JTAG access for the same.
  132. # Ensure Power-AP unlocked
  133. $::_CHIPNAME.dap apreg 3 [lindex $::_m3_ap_unlock_offsets 0] 0x00190000
  134. $::_CHIPNAME.dap apreg 3 [lindex $::_m3_ap_unlock_offsets 1] 0x00102098
  135. $::_TARGETNAME.m3 arp_examine
  136. }
  137. set _v8_smp_targets ""
  138. for { set _core 0 } { $_core < $_armv8_cores } { incr _core } {
  139. cti create $_CTINAME.$_armv8_cpu_name.$_core -dap $_CHIPNAME.dap -ap-num 1 \
  140. -baseaddr [lindex $ARMV8_CTIBASE $_core]
  141. target create $_TARGETNAME.$_armv8_cpu_name.$_core aarch64 -dap $_CHIPNAME.dap \
  142. -dbgbase [lindex $ARMV8_DBGBASE $_core] -cti $_CTINAME.$_armv8_cpu_name.$_core -defer-examine
  143. set _v8_smp_targets "$_v8_smp_targets $_TARGETNAME.$_armv8_cpu_name.$_core"
  144. }
  145. # Setup ARMV8 proc commands based on CPU to prevent people confusing SoCs
  146. set _armv8_up_cmd "$_armv8_cpu_name"_up
  147. # Available if V8_SMP_DEBUG is set to non-zero value
  148. set _armv8_smp_cmd "$_armv8_cpu_name"_smp
  149. if { $_v8_smp_debug == 0 } {
  150. proc $_armv8_up_cmd { args } {
  151. foreach { _core } [set args] {
  152. $::_TARGETNAME.$::_armv8_cpu_name.$_core arp_examine
  153. $::_TARGETNAME.$::_armv8_cpu_name.$_core aarch64 dbginit
  154. }
  155. }
  156. } else {
  157. proc $_armv8_smp_cmd { args } {
  158. for { set _core 0 } { $_core < $::_armv8_cores } { incr _core } {
  159. $::_TARGETNAME.$::_armv8_cpu_name.$_core arp_examine
  160. $::_TARGETNAME.$::_armv8_cpu_name.$_core aarch64 dbginit
  161. $::_TARGETNAME.$::_armv8_cpu_name.$_core aarch64 smp on
  162. }
  163. # Set Default target are core 0
  164. targets $::_TARGETNAME.$::_armv8_cpu_name.0
  165. }
  166. # Declare SMP
  167. target smp $:::_v8_smp_targets
  168. }
  169. for { set _core 0 } { $_core < $_r5_cores } { incr _core } {
  170. cti create $_CTINAME.r5.$_core -dap $_CHIPNAME.dap -ap-num 1 \
  171. -baseaddr [lindex $R5_CTIBASE $_core]
  172. # inactive core examination will fail - wait till startup of additional core
  173. target create $_TARGETNAME.r5.$_core cortex_r4 -dap $_CHIPNAME.dap \
  174. -dbgbase [lindex $R5_DBGBASE $_core] -ap-num 1 -defer-examine
  175. }
  176. if { $_mcu_r5_cores != 0 } {
  177. proc mcu_r5_up { args } {
  178. foreach { _core } [set args] {
  179. set _core [expr {$_core + $::_mcu_base_core_id}]
  180. $::_TARGETNAME.r5.$_core arp_examine
  181. $::_TARGETNAME.r5.$_core cortex_r4 dbginit
  182. }
  183. }
  184. }
  185. if { $_main0_r5_cores != 0 } {
  186. proc main0_r5_up { args } {
  187. foreach { _core } [set args] {
  188. set _core [expr {$_core + $::_main0_base_core_id}]
  189. $::_TARGETNAME.r5.$_core arp_examine
  190. $::_TARGETNAME.r5.$_core cortex_r4 dbginit
  191. }
  192. }
  193. }
  194. if { $_main1_r5_cores != 0 } {
  195. proc main1_r5_up { args } {
  196. foreach { _core } [set args] {
  197. set _core [expr {$_core + $::_main1_base_core_id}]
  198. $::_TARGETNAME.r5.$_core arp_examine
  199. $::_TARGETNAME.r5.$_core cortex_r4 dbginit
  200. }
  201. }
  202. }
  203. if { $_mcu_m4_cores != 0 } {
  204. cti create $_CTINAME.m4 -dap $_CHIPNAME.dap -ap-num 8 -baseaddr [lindex $CM4_CTIBASE 0]
  205. target create $_TARGETNAME.m4 cortex_m -dap $_CHIPNAME.dap -ap-num 8 -defer-examine
  206. $_TARGETNAME.m4 configure -event reset-assert { }
  207. proc m4_up { args } {
  208. # To access M4, we need to enable the JTAG access for the same.
  209. # Ensure Power-AP unlocked
  210. $::_CHIPNAME.dap apreg 3 [lindex $::_m4_ap_unlock_offsets 0] 0x00190000
  211. $::_CHIPNAME.dap apreg 3 [lindex $::_m4_ap_unlock_offsets 1] 0x00102098
  212. $::_TARGETNAME.m4 arp_examine
  213. }
  214. }