2 # Copyright (C) 2011 by Karl Kurbjun
3 # Copyright (C) 2009 by David Brownell
6 # Utilities for TI ICEpick-C ... used in DaVinci, OMAP3, and more.
7 # Details about the ICEPickC are available in the AM/DM37x document SPRUGN4M
13 # define ICEPick instructions
19 return $constant($key)
22 # Instruction to connect to the icepick module
23 proc icepick_c_connect {jrc} {
25 # Send CONNECT instruction in IR state
26 irscan $jrc [CONST IR_CONNECT] -endstate IRPAUSE
28 # Send write and connect key
29 drscan $jrc 8 0x89 -endstate DRPAUSE
32 # Instruction to disconnect to the icepick module
33 proc icepick_c_disconnect {jrc} {
35 # Send CONNECT instruction in IR state
36 irscan $jrc [CONST IR_CONNECT] -endstate IRPAUSE
38 # Send write and connect key
39 drscan $jrc 8 0x86 -endstate DRPAUSE
44 # this function is for sending router commands
46 # jrc: TAP name for the ICEpick
47 # rw: read/write (0 for read, 1 for write)
48 # block: icepick or DAP
49 # register: which register to read/write
50 # payload: value to read/write
51 # this function is for sending router commands
53 proc icepick_c_router {jrc rw block register payload} {
56 [expr ( ($rw & 0x1) << 31) | ( ($block & 0x7) << 28) | \
57 ( ($register & 0xF) << 24) | ( $payload & 0xFFFFFF ) ]
59 # echo "\tNew router value:\t0x[format %x $new_dr_value]"
62 irscan $jrc [CONST IR_ROUTER] -endstate IRPAUSE
64 # ROUTER instructions are 32 bits wide
65 set old_dr_value [drscan $jrc 32 $new_dr_value -endstate DRPAUSE]
68 # Configure the icepick control register
69 proc icepick_c_setup {jrc} {
71 # send a router write, block is 0, register is 1, value is 0x2100
72 icepick_c_router $jrc 1 0x0 0x1 0x001000
75 # jrc == TAP name for the ICEpick
76 # port == a port number, 0..15
77 proc icepick_c_tapenable {jrc port} {
79 # First CONNECT to the ICEPick
80 # echo "Connecting to ICEPick"
81 icepick_c_connect $jrc
83 # echo "Configuring the ICEpick"
86 # NOTE: it's important not to enter RUN/IDLE state until
87 # done sending these instructions and data to the ICEpick.
88 # And never to enter RESET, which will disable the TAPs.
90 # first enable power and clock for TAP
91 icepick_c_router $jrc 1 0x2 $port 0x100048
93 # TRM states that the register should be read back here, skipped for now
95 # enable debug "default" mode
96 icepick_c_router $jrc 1 0x2 $port 0x102048
98 # TRM states that debug enable and debug mode should be read back and
99 # confirmed - skipped for now
101 # Finally select the tap
102 icepick_c_router $jrc 1 0x2 $port 0x102148
104 # Enter the bypass state
105 irscan $jrc [CONST IR_BYPASS] -endstate RUN/IDLE
109 # This function uses the ICEPick to send a warm system reset
110 proc icepick_c_wreset {jrc} {
112 # send a router write, block is 0, register is 1, value is 0x2100
113 icepick_c_router $jrc 1 0x0 0x1 0x002101