target: ls1088a: Add service processor
[fw/openocd] / tcl / target / ls1088a.cfg
1 # SPDX-License-Identifier: GPL-2.0-or-later
2 # NXP LS1088A
3
4 if { [info exists CHIPNAME] } {
5         set _CHIPNAME $CHIPNAME
6 } else {
7         set _CHIPNAME ls1088a
8 }
9
10 if { [info exists DAP_TAPID] } {
11         set _DAP_TAPID $DAP_TAPID
12 } else {
13         set _DAP_TAPID 0x5ba00477
14 }
15
16 jtag newtap $_CHIPNAME dap -irlen 4 -expected-id $_DAP_TAPID
17 dap create $_CHIPNAME.dap -chain-position $_CHIPNAME.dap
18
19 target create $_CHIPNAME.axi mem_ap -dap $_CHIPNAME.dap -ap-num 1
20
21 set _CPU_BASE 0x81000000
22 set _CPU_STRIDE 0x100000
23 set _CPU_DBGOFF 0x10000
24 set _CPU_CTIOFF 0x20000
25
26 set _TARGETS {}
27 for {set i 0} {$i < 8} {incr i} {
28         set _BASE [expr {$_CPU_BASE + $_CPU_STRIDE * $i}]
29         cti create $_CHIPNAME.cti$i -dap $_CHIPNAME.dap -ap-num 0 \
30                 -baseaddr [expr {$_BASE + $_CPU_CTIOFF}]
31         target create $_CHIPNAME.cpu$i aarch64 -dap $_CHIPNAME.dap \
32                 -cti $_CHIPNAME.cti$i -dbgbase [expr {$_BASE + $_CPU_DBGOFF}] \
33                 {*}[expr {$i ? "-coreid $i" : "-rtos hwthread" }]
34         lappend _TARGETS $_CHIPNAME.cpu$i
35 }
36
37 target smp {*}$_TARGETS
38
39 # Service processor
40 target create $_CHIPNAME.sp cortex_a -dap $_CHIPNAME.dap -ap-num 0 -dbgbase 0x80138000
41
42 # Normally you will not need to call this, but if you are using the hard-coded
43 # Reset Configuration Word (RCW) you will need to call this manually. The CPU's
44 # reset vector is 0, and the boot ROM at that location contains ARMv7-A 32-bit
45 # instructions. This will cause the CPU to almost immediately execute an
46 # illegal instruction.
47 #
48 # This code is idempotent; releasing a released CPU has no effect, although it
49 # will halt/resume the service processor.
50 add_help_text release_cpu "Release a cpu which is held off"
51 proc release_cpu {cpu} {
52         set RST_BRRL 0x1e60060
53
54         set old [target current]
55         targets $::_CHIPNAME.sp
56         set not_halted [string compare halted [$::_CHIPNAME.sp curstate]]
57         if {$not_halted} {
58                 halt
59         }
60
61         # Release the cpu; it will start executing something bogus
62         mem2array regs 32 $RST_BRRL 1
63         mww $RST_BRRL [expr {$regs(0) | 1 << $cpu}]
64
65         if {$not_halted} {
66                 resume
67         }
68         targets $old
69 }
70
71 targets $_CHIPNAME.cpu0
72
73 # Seems to work OK in testing
74 adapter speed 10000