target: add configuration for NXP MC-IMX8M-EVK
[openocd.git] / tcl / target / icepick.cfg
blob0f160bb1073c2342391c3ba5cd9c373b8ad83730
2 # Copyright (C)   2011        by Karl Kurbjun
3 # Copyright (C)   2009        by David Brownell
6 # Utilities for TI ICEpick-C/D used in most TI SoCs
7 # Details about the ICEPick are available in the the TRM for each SoC
8 # and http://processors.wiki.ti.com/index.php/ICEPICK
10 # create "constants"
11 proc CONST { key } {
13         array set constant {
14                 # define ICEPick instructions
15                 IR_BYPASS   0x00
16                 IR_ROUTER   0x02
17                 IR_CONNECT  0x07
18                 IF_BYPASS   0x3F
19         }
20         return $constant($key)
23 # Instruction to connect to the icepick module
24 proc icepick_c_connect {jrc} {
26         # Send CONNECT instruction in IR state
27         irscan $jrc [CONST IR_CONNECT] -endstate IRPAUSE
29         # Send write and connect key
30         drscan $jrc 8 0x89 -endstate DRPAUSE
33 # Instruction to disconnect to the icepick module
34 proc icepick_c_disconnect {jrc} {
36         # Send CONNECT instruction in IR state
37         irscan $jrc [CONST IR_CONNECT] -endstate IRPAUSE
39         # Send write and connect key
40         drscan $jrc 8 0x86 -endstate DRPAUSE
44 # icepick_c_router:
45 #  this function is for sending router commands
46 # arguments are:
47 #  jrc:        TAP name for the ICEpick
48 #  rw:         read/write (0 for read, 1 for write)
49 #  block:      icepick or DAP
50 #  register:   which register to read/write
51 #  payload:    value to read/write
52 # this function is for sending router commands
54 proc icepick_c_router {jrc rw block register payload} {
56         set new_dr_value \
57                 [expr ( ($rw & 0x1) << 31)        | ( ($block & 0x7) << 28) | \
58                         ( ($register & 0xF) << 24)  | ( $payload & 0xFFFFFF ) ]
60 #       echo "\tNew router value:\t0x[format %x $new_dr_value]"
62         # select router
63         irscan $jrc [CONST IR_ROUTER] -endstate IRPAUSE
65         # ROUTER instructions are 32 bits wide
66         set old_dr_value 0x[drscan $jrc 32 $new_dr_value -endstate DRPAUSE]
67 #       echo "\tOld router value:\t0x[format %x $old_dr_value]"
70 # Configure the icepick control register
71 proc icepick_c_setup {jrc} {
73         # send a router write, block is 0, register is 1, value is 0x2100
74         icepick_c_router $jrc 1 0x0 0x1 0x001000
77 # jrc   == TAP name for the ICEpick
78 # port  == a port number, 0..15
79 proc icepick_c_tapenable {jrc port} {
81         # First CONNECT to the ICEPick
82 #       echo "Connecting to ICEPick"
83         icepick_c_connect $jrc
85 #       echo "Configuring the ICEpick"
86         icepick_c_setup $jrc
88         # NOTE: it's important not to enter RUN/IDLE state until
89         # done sending these instructions and data to the ICEpick.
90         # And never to enter RESET, which will disable the TAPs.
92         # first enable power and clock for TAP
93         icepick_c_router $jrc 1 0x2 $port 0x100048
95         # TRM states that the register should be read back here, skipped for now
97         # enable debug "default" mode
98         icepick_c_router $jrc 1 0x2 $port 0x102048
100         # TRM states that debug enable and debug mode should be read back and
101         # confirmed - skipped for now
103         # Finally select the tap
104         icepick_c_router $jrc 1 0x2 $port 0x102148
106         # Enter the bypass state
107         irscan $jrc [CONST IR_BYPASS] -endstate RUN/IDLE
108         runtest 10
111 # jrc   == TAP name for the ICEpick
112 # coreid== core id number 0..15 (not same as port number!)
113 proc icepick_d_set_core_control {jrc coreid value } {
114         icepick_c_router $jrc 1 0x6 $coreid $value
117 # jrc   == TAP name for the ICEpick
118 # port  == a port number, 0..15
119 # Follow the sequence described in
120 # http://processors.wiki.ti.com/images/f/f6/Router_Scan_Sequence-ICEpick-D.pdf
121 proc icepick_d_tapenable {jrc port coreid { value 0x2008 } } {
122         # First CONNECT to the ICEPick
123         icepick_c_connect $jrc
124         icepick_c_setup $jrc
126         # Select the port
127         icepick_c_router $jrc 1 0x2 $port 0x2108
129         # Set icepick core control for $coreid
130         icepick_d_set_core_control $jrc $coreid $value
132         # Enter the bypass state
133         irscan $jrc [CONST IF_BYPASS] -endstate RUN/IDLE
134         runtest 10
137 # This function uses the ICEPick to send a warm system reset
138 proc icepick_c_wreset {jrc} {
140         # send a router write, block is 0, register is 1, value is 0x2100
141         icepick_c_router $jrc 1 0x0 0x1 0x002101