ampere_qs_mq.cfg 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333
  1. # SPDX-License-Identifier: GPL-2.0-or-later
  2. #
  3. # OpenOCD Target Configuration for Ampere Altra ("Quicksilver") and
  4. # Ampere Altra Max ("Mystique") processors
  5. #
  6. # Copyright (c) 2019-2022, Ampere Computing LLC
  7. # Command Line Argument Description
  8. #
  9. # SPLITSMP
  10. # Only used for dual socket systems. Do not use for a single socket setup.
  11. # Option pertains to the ARMv8 target core naming in a dual socket setup.
  12. # If specified, name all ARMv8 cores per socket as individual SMP sessions.
  13. # If not specified, name ARMv8 cores from both sockets as one SMP session.
  14. # This option is used in conjunction with the SMP_STR board file option.
  15. # Syntax: -c "set SPLITSMP {}"
  16. #
  17. # PHYS_IDX
  18. # Enable OpenOCD ARMv8 core target physical indexing.
  19. # If not specified, defaults to OpenOCD ARMv8 core target logical indexing.
  20. # Syntax: -c "set PHYS_IDX {}"
  21. #
  22. # CHIPNAME
  23. # Specifies the name of the chip.
  24. # Will typically be either qs, qs0, qs1, mq, mq0 or mq1.
  25. # If not specified, defaults to qs.
  26. # Syntax: -c "set CHIPNAME {qs}"
  27. #
  28. # SYSNAME
  29. # Specifies the name of the system.
  30. # Will typically be either qs or mq.
  31. # If not specified, defaults to qs.
  32. # Syntax: -c "set SYSNAME {qs}"
  33. #
  34. # Life-Cycle State (LCS)
  35. # If not specified, defaults to "Secure LCS".
  36. # LCS=0, "Secure LCS"
  37. # LCS=1, "Chip Manufacturing LCS"
  38. # Syntax: -c "set LCS {0}"
  39. # Syntax: -c "set LCS {1}"
  40. #
  41. # CORELIST
  42. # Specify available physical cores by number.
  43. # Example syntax to connect to physical cores 16 and 17.
  44. # Syntax: -c "set CORELIST {16 17}"
  45. #
  46. # COREMASK_LO
  47. # Specify available physical cores 0-63 by mask.
  48. # Example syntax to connect to physical cores 16 and 17.
  49. # Syntax: -c "set COREMASK_LO {0x0000000000030000}"
  50. #
  51. # COREMASK_HI
  52. # Specify available physical cores 64 and above by mask.
  53. # Example syntax to connect to physical cores 94 and 95.
  54. # Syntax: -c "set COREMASK_HI {0x00000000C0000000}"
  55. #
  56. # ARMV8_TAPID
  57. # Can override the ARMV8 TAPID default value if necessary.
  58. # Experimental Use. Most users will not use this option.
  59. # Syntax: -c "set ARMV8_TAPID {0x3BA06477}"
  60. #
  61. # SMPMPRO_TAPID
  62. # Can override the SMPMPRO TAPID default value if necessary.
  63. # Experimental Use. Most users will not use this option.
  64. # Syntax: -c "set SMPMPRO_TAPID {0x4BA00477}"
  65. #
  66. #
  67. # Board File Argument Description
  68. # These optional arguments are defined in the board file and
  69. # referenced by the target file. See the corresponding board
  70. # files for examples of their use.
  71. #
  72. # SMP_STR
  73. # This option is used primarily for a dual socket system and it is not
  74. # recommended for a single socket setup. This option configures whether
  75. # the SMP ARMv8 core grouping is maintained at the board or target cfg level.
  76. # Specify the option if the SMP core grouping is defined at the board level.
  77. # Do not specify if the SMP core grouping is defined at the chip level.
  78. # If not specified, defaults to SMP core grouping defined per socket.
  79. # If specified, "SMP_STR=target smp", the SMP core grouping is maintained
  80. # at the board cfg level.
  81. # Used in conjunction with the SPLITSMP option to group two chips into
  82. # a single SMP configuration or maintain as two separate SMP sessions.
  83. #
  84. # CORE_INDEX_OFFSET
  85. # Specifies the starting logical core index value.
  86. # Used for dual-socket systems.
  87. # For socket #0, set to 0.
  88. # For socket #1, set the starting logical core based from
  89. # the last logical core on socket #0.
  90. # If not specified, defaults to 0.
  91. #
  92. #
  93. # Configure defaults for target.
  94. # Can be overridden in board configuration file.
  95. #
  96. if { [info exists SMP_STR] } {
  97. # SMP configured at the dual socket board level
  98. set _SMP_STR $SMP_STR
  99. } else {
  100. # SMP configured at the single socket target level
  101. set _SMP_STR "target smp"
  102. }
  103. if { [info exists CHIPNAME] } {
  104. set _CHIPNAME $CHIPNAME
  105. } else {
  106. set _CHIPNAME qs
  107. }
  108. if { [info exists SYSNAME] } {
  109. set _SYSNAME $SYSNAME
  110. } else {
  111. set _SYSNAME qs
  112. }
  113. if { [info exists CORE_INDEX_OFFSET] } {
  114. set _CORE_INDEX_OFFSET $CORE_INDEX_OFFSET
  115. } else {
  116. set _CORE_INDEX_OFFSET 0
  117. }
  118. if { [info exists ENDIAN] } {
  119. set _ENDIAN $ENDIAN
  120. } else {
  121. set _ENDIAN little
  122. }
  123. if { [info exists ARMV8_TAPID] } {
  124. set _ARMV8_TAPID $ARMV8_TAPID
  125. } else {
  126. if { [info exists MQ_ENABLE] } {
  127. # Configure for Mystique
  128. set _ARMV8_TAPID 0x3BA06477
  129. set _MAX_CORE 128
  130. } else {
  131. # Configure for Quicksilver
  132. set _ARMV8_TAPID 0x2BA06477
  133. set _MAX_CORE 80
  134. }
  135. }
  136. if { [info exists SMPMPRO_TAPID] } {
  137. set _SMPMPRO_TAPID $SMPMPRO_TAPID
  138. } else {
  139. set _SMPMPRO_TAPID 0x4BA00477
  140. }
  141. if { [info exists CORELIST] } {
  142. set _CORELIST $CORELIST
  143. } else {
  144. if { [info exists COREMASK_LO] } {
  145. set _COREMASK_LO $COREMASK_LO
  146. } else {
  147. set _COREMASK_LO 0x0
  148. }
  149. if { [info exists COREMASK_HI] } {
  150. set _COREMASK_HI $COREMASK_HI
  151. } else {
  152. set _COREMASK_HI 0x0
  153. }
  154. set _CORELIST {}
  155. set _MASK 0x1
  156. for {set i 0} {$i < 64} {incr i} {
  157. if { [expr {$_COREMASK_LO & $_MASK}] != 0x0 } {
  158. set _CORELIST "$_CORELIST $i"
  159. }
  160. set _MASK [expr {$_MASK << 0x1}]
  161. }
  162. set _MASK 0x1
  163. for {} {$i < $_MAX_CORE} {incr i} {
  164. if { [expr {$_COREMASK_HI & $_MASK}] != 0x0 } {
  165. set _CORELIST "$_CORELIST $i"
  166. }
  167. set _MASK [expr {$_MASK << 0x1}]
  168. }
  169. }
  170. #
  171. # Definition of target names
  172. #
  173. set _TARGETNAME_PMPRO pmpro
  174. set _TARGETNAME_SMPRO smpro
  175. set _TARGETNAME_ARMV8 armv8
  176. #
  177. # Configure JTAG TAPs - TAP chain declaration order is important
  178. #
  179. jtag newtap $_CHIPNAME pmpro.tap -irlen 4 -ircapture 0x1 -irmask 0x3 -expected-id $_SMPMPRO_TAPID
  180. set _TAPNAME_PMPRO $_CHIPNAME.$_TARGETNAME_PMPRO.tap
  181. jtag newtap $_CHIPNAME smpro.tap -irlen 4 -ircapture 0x1 -irmask 0x3 -expected-id $_SMPMPRO_TAPID
  182. set _TAPNAME_SMPRO $_CHIPNAME.$_TARGETNAME_SMPRO.tap
  183. jtag newtap $_CHIPNAME armv8.tap -irlen 4 -ircapture 0x1 -irmask 0x3 -expected-id $_ARMV8_TAPID
  184. set _TAPNAME_ARMV8 $_CHIPNAME.$_TARGETNAME_ARMV8.tap
  185. set _DAPNAME_PMPRO $_CHIPNAME.$_TARGETNAME_PMPRO.dap
  186. set _DAPNAME_SMPRO $_CHIPNAME.$_TARGETNAME_SMPRO.dap
  187. set _DAPNAME_ARMV8 $_CHIPNAME.$_TARGETNAME_ARMV8.dap
  188. set _AP_PMPRO_AHB 0
  189. set _AP_SMPRO_AHB 0
  190. set _AP_ARMV8_APB 0x00010000
  191. set _AP_ARMV8_AXI 0x00020000
  192. #
  193. # Configure JTAG DAPs
  194. #
  195. dap create $_DAPNAME_PMPRO -chain-position $_TAPNAME_PMPRO -adiv5
  196. dap create $_DAPNAME_SMPRO -chain-position $_TAPNAME_SMPRO -adiv5
  197. dap create $_DAPNAME_ARMV8 -chain-position $_TAPNAME_ARMV8 -adiv6
  198. if { [info exists LCS] && [expr {"$LCS"!="0"}] } {
  199. #
  200. # Create the DAP AHB-AP MEM-AP target for the PMPRO CPU
  201. #
  202. target create $_CHIPNAME.$_TARGETNAME_PMPRO.ahb mem_ap -endian $_ENDIAN -dap $_DAPNAME_PMPRO -ap-num $_AP_PMPRO_AHB
  203. #
  204. # Configure target PMPRO CPU
  205. #
  206. target create $_CHIPNAME.$_TARGETNAME_PMPRO cortex_m -endian $_ENDIAN -dap $_DAPNAME_PMPRO -ap-num $_AP_PMPRO_AHB
  207. #
  208. # Create the DAP AHB-AP MEM-AP target for the SMPRO CPU
  209. #
  210. target create $_CHIPNAME.$_TARGETNAME_SMPRO.ahb mem_ap -endian $_ENDIAN -dap $_DAPNAME_SMPRO -ap-num $_AP_SMPRO_AHB
  211. #
  212. # Configure target SMPRO CPU
  213. #
  214. target create $_CHIPNAME.$_TARGETNAME_SMPRO cortex_m -endian $_ENDIAN -dap $_DAPNAME_SMPRO -ap-num $_AP_SMPRO_AHB
  215. }
  216. # Create the DAP APB-AP MEM-AP target for the ARMV8 cores
  217. target create $_CHIPNAME.$_TARGETNAME_ARMV8.apb mem_ap -endian $_ENDIAN -dap $_DAPNAME_ARMV8 -ap-num $_AP_ARMV8_APB
  218. # Create the DAP AXI-AP MEM-AP target for the ARMV8 cores
  219. target create $_CHIPNAME.$_TARGETNAME_ARMV8.axi mem_ap -endian $_ENDIAN -dap $_DAPNAME_ARMV8 -ap-num $_AP_ARMV8_AXI
  220. # Set CSW register value default correctly for AXI accessible device memory:
  221. # Select the correct Access Port Number
  222. $_DAPNAME_ARMV8 apsel $_AP_ARMV8_AXI
  223. # First set the CSW to OpenOCD's internal default
  224. $_DAPNAME_ARMV8 apcsw default
  225. # Set Domain[1:0]=b'11 (CSW[14:13]=b'11)
  226. # Set Cache[3:0]=b'0000 (CSW[27:24]=b'0000)
  227. # Porter Cfg registers require secure access, AxPROT[1] (CSW[29]) must be b'0'.
  228. # Set AxPROT[2:0]=b'000 (CSW[30:28]=b'000) for an Unpriveleged, Secure, Data access.
  229. $_DAPNAME_ARMV8 apcsw 0x00006000 0x7F006000
  230. #
  231. # Configure target CPUs
  232. #
  233. set logical_index $_CORE_INDEX_OFFSET
  234. foreach physical_index $_CORELIST {
  235. if { [info exists PHYS_IDX] } {
  236. set logical_index [expr {$physical_index + $_CORE_INDEX_OFFSET}]
  237. }
  238. # Format a string to reference which CPU target to use
  239. if { [info exists SPLITSMP] } {
  240. eval "set _TARGETNAME $_CHIPNAME.${_TARGETNAME_ARMV8}_$logical_index"
  241. } else {
  242. eval "set _TARGETNAME $_SYSNAME.${_TARGETNAME_ARMV8}_$logical_index"
  243. }
  244. # Create and configure Cross Trigger Interface (CTI) - required for halt and resume
  245. set _CTINAME $_TARGETNAME.cti
  246. set _offset [expr {(0x00100000 * $physical_index) + (0x00200000 * ($physical_index>>1))}]
  247. cti create $_CTINAME -dap $_DAPNAME_ARMV8 -ap-num $_AP_ARMV8_APB -baseaddr [expr {0xA0220000 + $_offset}]
  248. # Create the target
  249. target create $_TARGETNAME aarch64 -endian $_ENDIAN \
  250. -dap $_DAPNAME_ARMV8 -ap-num $_AP_ARMV8_APB -dbgbase [expr {0xA0210000 + $_offset}] \
  251. -rtos hwthread -cti $_CTINAME -coreid $logical_index
  252. # Build string used to enable SMP mode for the ARMv8 CPU cores
  253. set _SMP_STR "$_SMP_STR $_TARGETNAME"
  254. # Clear CTI output/input enables that are not configured by OpenOCD for aarch64
  255. $_TARGETNAME configure -event reset-init [subst {
  256. $_CTINAME write INEN0 0x00000000
  257. $_CTINAME write INEN1 0x00000000
  258. $_CTINAME write INEN2 0x00000000
  259. $_CTINAME write INEN3 0x00000000
  260. $_CTINAME write INEN4 0x00000000
  261. $_CTINAME write INEN5 0x00000000
  262. $_CTINAME write INEN6 0x00000000
  263. $_CTINAME write INEN7 0x00000000
  264. $_CTINAME write INEN8 0x00000000
  265. $_CTINAME write OUTEN0 0x00000000
  266. $_CTINAME write OUTEN1 0x00000000
  267. $_CTINAME write OUTEN2 0x00000000
  268. $_CTINAME write OUTEN3 0x00000000
  269. $_CTINAME write OUTEN4 0x00000000
  270. $_CTINAME write OUTEN5 0x00000000
  271. $_CTINAME write OUTEN6 0x00000000
  272. $_CTINAME write OUTEN7 0x00000000
  273. $_CTINAME write OUTEN8 0x00000000
  274. }]
  275. incr logical_index
  276. }
  277. if { [info exists SMP_STR] } {
  278. # Return updated SMP configuration string back to board level
  279. set SMP_STR $_SMP_STR
  280. } else {
  281. # For single socket per SMP configuration, evaluate the string
  282. eval $_SMP_STR
  283. }
  284. if { [info exists CORE_INDEX_OFFSET] } {
  285. # For multi-socket, return total number of cores back to board level
  286. set CORE_INDEX_OFFSET $logical_index
  287. }