tcl/target: add SPDX tag
[fw/openocd] / tcl / target / hilscher_netx500.cfg
1 # SPDX-License-Identifier: GPL-2.0-or-later
2
3 #Hilscher netX 500 CPU
4
5 if { [info exists CHIPNAME] } {
6    set _CHIPNAME $CHIPNAME
7 } else {
8    set _CHIPNAME netx500
9 }
10
11 if { [info exists ENDIAN] } {
12    set _ENDIAN $ENDIAN
13 } else {
14    set _ENDIAN little
15 }
16
17 if { [info exists CPUTAPID] } {
18    set _CPUTAPID $CPUTAPID
19 } else {
20    set _CPUTAPID 0x07926021
21 }
22
23 # jtag scan chain
24 jtag newtap $_CHIPNAME cpu -irlen 4 -ircapture 0x1 -irmask 0xf -expected-id $_CPUTAPID
25
26 # that TAP is associated with a target
27 set _TARGETNAME $_CHIPNAME.cpu
28 target create $_TARGETNAME arm926ejs -endian $_ENDIAN -chain-position $_TARGETNAME
29
30 proc mread32 {addr} {
31   return [read_memory $addr 32 1]
32 }
33
34 # This function must be called on netX100/500 right after halt
35 # If it is called later the needed register cannot be written anymore
36 proc sdram_fix { } {
37
38   set accesskey [mread32 0x00100070]
39   mww 0x00100070 $accesskey
40   mww 0x0010002c 0x00000001
41
42   if {[expr {[mread32 0x0010002c] & 0x07}] == 0x07} {
43          puts "SDRAM Fix was not executed. Probably your CPU halted too late and the register is already locked!"
44   } else {
45          puts "SDRAM Fix succeeded!"
46   }
47 }