1 # SPDX-License-Identifier: GPL-2.0-or-later
3 # Copyright (C) ST-Ericsson SA 2011
4 # Author : michel.jaouen@stericsson.com
8 set cp [arm mrc 15 0 1 0 0]
9 set cp [expr {$cp & ~1}]
10 arm mcr 15 0 1 0 0 $cp
14 set cp [arm mrc 15 0 1 0 0]
15 set cp [expr {$cp | 1}]
16 arm mcr 15 0 1 0 0 $cp
19 proc ocd_gdb_restart {target_id} {
22 targets $_TARGETNAME_1
36 targets $_TARGETNAME_1
39 set stck1 [reg sp_svc]
40 targets $_TARGETNAME_2
43 set stck2 [reg sp_svc]
47 proc u8500_tapenable {chip val} {
48 echo "JTAG tap enable $chip"
54 irscan $_CHIPNAME.jrc 0x3a
55 drscan $_CHIPNAME.jrc 4 0
56 set pwrsts [drscan $_CHIPNAME.jrc 16 0]
57 echo "pwrsts ="$pwrsts
58 set a9 [expr "0x$pwrsts & 0xc"]
59 set ape [expr "0x$pwrsts & 0x3"]
60 if {[string equal "0" $ape]} {
68 echo "A9 in retention"
79 proc poll_pwrsts { } {
83 irscan $_CHIPNAME.jrc 0x3a
84 drscan $_CHIPNAME.jrc 4 0
85 set pwrsts [drscan $_CHIPNAME.jrc 16 0]
86 set pwrsts [expr "0x$pwrsts & 0xc"]
87 while {[string equal "4" $pwrsts] && $i<20} {
88 irscan $_CHIPNAME.jrc 0x3a
89 drscan $_CHIPNAME.jrc 4 0;
90 set pwrsts [drscan $_CHIPNAME.jrc 16 0]
91 set pwrsts [expr "0x$pwrsts & 0xc"]
92 if {![string equal "4" $pwrsts]} {
105 if {[poll_pwrsts]==1} {
108 echo "halt failed : target in retention"
113 proc u8500_dapenable {chip} {
116 proc u8500_tapdisable {chip val} {
117 echo "JTAG tap disable $chip"
121 proc enable_apetap {} {
126 irscan $_CHIPNAME.jrc 0x3e
127 drscan $_CHIPNAME.jrc 8 0xcf
128 jtag tapenable $_CHIPNAME.dap
129 irscan $_CHIPNAME.jrc 0x6
130 drscan $_CHIPNAME.jrc 32 0
131 irscan $_CHIPNAME.jrc 0x6
132 drscan $_CHIPNAME.jrc 32 0
133 set status [$_TARGETNAME_1 curstate]
134 if {[string equal "unknown" $status]} {
135 $_TARGETNAME_1 arp_examine
136 cache_config l2x 0xa0412000 8
139 set status [$_TARGETNAME_2 curstate]
140 if {[string equal "unknown" $status]} {
141 $_TARGETNAME_2 arp_examine
149 if { [info exists CHIPNAME] } {
151 set _CHIPNAME $CHIPNAME
157 if { [info exists ENDIAN] } {
160 # this defaults to a bigendian
166 # Subsidiary TAP: APE with scan chains for ARM Debug, EmbeddedICE-RT,
167 if { [info exists CPUTAPID] } {
168 set _CPUTAPID $CPUTAPID
170 set _CPUTAPID 0x4ba00477
172 jtag newtap $_CHIPNAME cpu -irlen 4 -ircapture 0xe -irmask 0xf -expected-id $_CPUTAPID -disable
173 jtag configure $_CHIPNAME.cpu -event tap-enable \
174 "u8500_dapenable $_CHIPNAME.cpu"
175 jtag configure $_CHIPNAME.cpu -event tap-disable \
176 "u8500_tapdisable $_CHIPNAME.cpu 0xc0"
179 #CLTAPC TAP JRC equivalent
180 if { [info exists CLTAPC_ID] } {
181 set _CLTAPC_ID $CLTAPC_ID
183 set _CLTAPC_ID 0x22286041
185 jtag newtap $_CHIPNAME jrc -irlen 6 -ircapture 0x6 -irmask 0xf -expected-id $_CLTAPC_ID -ignore-version
188 if { ![info exists TARGETNAME_1] } {
190 set _TARGETNAME_1 $_CHIPNAME.cpu1
193 set _TARGETNAME_1 $TARGETNAME_1
196 if { [info exists DAP_DBG1] } {
197 set _DAP_DBG1 $DAP_DBG1
199 set _DAP_DBG1 0x801A8000
201 if { [info exists DAP_DBG2] } {
202 set _DAP_DBG2 $DAP_DBG2
204 set _DAP_DBG2 0x801AA000
207 dap create $_CHIPNAME.dap -chain-position $_CHIPNAME.cpu
209 target create $_TARGETNAME_1 cortex_a -dap $_CHIPNAME.dap -dbgbase $_DAP_DBG1 -coreid 0 -rtos linux
212 if { ![info exists TARGETNAME_2] } {
214 set _TARGETNAME_2 $_CHIPNAME.cpu2
217 set _TARGETNAME_2 $TARGETNAME_2
220 target create $_TARGETNAME_2 cortex_a -dap $_CHIPNAME.dap -dbgbase $_DAP_DBG2 -coreid 1 -rtos linux
223 if {![info exists SMP]} {
232 target smp $_CHIPNAME.cpu2 $_CHIPNAME.cpu1
240 irscan $_CHIPNAME.jrc 0x3a
241 drscan $_CHIPNAME.jrc 4 4
242 set secsts1 [drscan $_CHIPNAME.jrc 16 0]
243 echo "secsts1 ="$secsts1
244 set secsts1 [expr "0x$secsts1 & 0x4"]
245 if {![string equal "4" $secsts1]} {
246 echo "APE target secured"
248 echo "APE target not secured"
255 irscan $_CHIPNAME.jrc 0x3a
256 drscan $_CHIPNAME.jrc 4 4
257 set secsts1 [drscan $_CHIPNAME.jrc 16 0]
258 echo "secsts1 ="$secsts1
259 set secsts1 [expr "0x$secsts1 & 0x4"]
260 if {[string equal "4" $secsts1]} {
261 if {[poll_pwrsts]==1} {
264 echo "target in retention"
267 echo "target secured"
278 set status [$_TARGETNAME_1 curstate]
279 if {[string equal "halted" $status]} {
281 targets $_TARGETNAME_1
283 set status [$_TARGETNAME_2 curstate]
284 if {[string equal "halted" $status]} {
286 targets $_TARGETNAME_2
292 irscan $_CHIPNAME.jrc 0x3a
293 drscan $_CHIPNAME.jrc 4 4
294 set secsts1 [drscan $_CHIPNAME.jrc 16 0]
295 echo "secsts1 ="$secsts1
296 set secsts1 [expr "0x$secsts1 & 0x4"]
297 while {![string equal "4" $secsts1]} {
298 irscan u8500.jrc 0x3a
300 set secsts1 [drscan $_CHIPNAME.jrc 16 0]
301 echo "secsts1 ="$secsts1
302 set secsts1 [expr "0x$secsts1 & 0x4"]
307 targets $_TARGETNAME_1
311 if {![info exists MAXSPEED]} {
316 set _MAXSPEED $MAXSPEED
319 adapter speed $_MAXSPEED
322 gdb_breakpoint_override hard
323 set mem inaccessible-by-default-off
326 reset_config trst_and_srst combined