1 # SPDX-License-Identifier: GPL-2.0-or-later
3 source [find target/icepick.cfg]
5 if { [info exists CHIPNAME] } {
6 set _CHIPNAME $CHIPNAME
11 # set the taps to be enabled by default. this can be overridden
12 # by setting DEFAULT_TAPS in a separate configuration file
13 # or directly on the command line.
14 if { [info exists DEFAULT_TAPS] } {
15 set _DEFAULT_TAPS "$DEFAULT_TAPS"
17 set _DEFAULT_TAPS "$_CHIPNAME.tap"
23 if { [info exists DAP_TAPID] } {
24 set _DAP_TAPID $DAP_TAPID
26 set _DAP_TAPID 0x4b6b902f
28 jtag newtap $_CHIPNAME tap -irlen 4 -ircapture 0x1 -irmask 0xf -expected-id $_DAP_TAPID -disable
29 jtag configure $_CHIPNAME.tap -event tap-enable "icepick_d_tapenable $_CHIPNAME.jrc 12 0"
30 dap create $_CHIPNAME.dap -chain-position $_CHIPNAME.tap
35 if { [info exists M3_DAP_TAPID] } {
36 set _M3_DAP_TAPID $M3_DAP_TAPID
38 set _M3_DAP_TAPID 0x4b6b902f
40 jtag newtap $_CHIPNAME m3_tap -irlen 4 -ircapture 0x1 -irmask 0xf -expected-id $_M3_DAP_TAPID -disable
41 jtag configure $_CHIPNAME.m3_tap -event tap-enable "icepick_d_tapenable $_CHIPNAME.jrc 11 0"
42 dap create $_CHIPNAME.m3_dap -chain-position $_CHIPNAME.m3_tap
45 # ICEpick-D (JTAG route controller)
47 if { [info exists JRC_TAPID] } {
48 set _JRC_TAPID $JRC_TAPID
50 set _JRC_TAPID 0x0b94402f
52 jtag newtap $_CHIPNAME jrc -irlen 6 -ircapture 0x1 -irmask 0x3f -expected-id $_JRC_TAPID -ignore-version
53 jtag configure $_CHIPNAME.jrc -event setup {
55 enable_default_taps $_DEFAULT_TAPS
57 # some TCK tycles are required to activate the DEBUG power domain
58 jtag configure $_CHIPNAME.jrc -event post-reset "runtest 100"
61 # helper function that enables all taps passed as argument
63 proc enable_default_taps { taps } {
72 set _TARGETNAME_2 $_CHIPNAME.m3
73 target create $_TARGETNAME_2 cortex_m -dap $_CHIPNAME.m3_dap
78 set _TARGETNAME $_CHIPNAME.cpu
79 target create $_TARGETNAME cortex_a -dap $_CHIPNAME.dap -dbgbase 0x80001000
81 # SRAM: 64K at 0x4030.0000; use the first 16K
82 $_TARGETNAME configure -work-area-phys 0x40300000 -work-area-size 0x4000
85 # when putting the target into 'reset halt', we need to disable the watchdog as
86 # it would otherwise trigger while we're in JTAG
87 # FIXME: unify with target/am437x.cfg
88 source [find mem_helper.tcl]
89 set WDT1_BASE_ADDR 0x44e35000
90 set WDT1_W_PEND_WSPR [expr {$WDT1_BASE_ADDR + 0x0034}]
91 set WDT1_WSPR [expr {$WDT1_BASE_ADDR + 0x0048}]
92 proc disable_watchdog { } {
94 global WDT1_W_PEND_WSPR
97 set curstate [$_TARGETNAME curstate]
99 if { [string compare $curstate halted] == 0 } {
100 set WDT_DISABLE_SEQ1 0xaaaa
101 set WDT_DISABLE_SEQ2 0x5555
103 mww phys $WDT1_WSPR $WDT_DISABLE_SEQ1
105 # Empty body to make sure this executes as fast as possible.
106 # We don't want any delays here otherwise romcode might start
107 # executing and end up changing state of certain IPs.
108 while { [expr {[mrw $WDT1_W_PEND_WSPR] & 0x10}] } { }
110 mww phys $WDT1_WSPR $WDT_DISABLE_SEQ2
111 while { [expr {[mrw $WDT1_W_PEND_WSPR] & 0x10}] } { }
114 $_TARGETNAME configure -event reset-end { disable_watchdog }