tcl/target: add SPDX tag
[fw/openocd] / tcl / target / am335x.cfg
1 # SPDX-License-Identifier: GPL-2.0-or-later
2
3 source [find target/icepick.cfg]
4
5 if { [info exists CHIPNAME] } {
6         set _CHIPNAME $CHIPNAME
7 } else {
8         set _CHIPNAME am335x
9 }
10
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"
16 } else {
17         set _DEFAULT_TAPS "$_CHIPNAME.tap"
18 }
19
20 #
21 # Main DAP
22 #
23 if { [info exists DAP_TAPID] } {
24         set _DAP_TAPID $DAP_TAPID
25 } else {
26         set _DAP_TAPID 0x4b6b902f
27 }
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
31
32 #
33 # M3 DAP
34 #
35 if { [info exists M3_DAP_TAPID] } {
36         set _M3_DAP_TAPID $M3_DAP_TAPID
37 } else {
38         set _M3_DAP_TAPID 0x4b6b902f
39 }
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
43
44 #
45 # ICEpick-D (JTAG route controller)
46 #
47 if { [info exists JRC_TAPID] } {
48         set _JRC_TAPID $JRC_TAPID
49 } else {
50         set _JRC_TAPID 0x0b94402f
51 }
52 jtag newtap $_CHIPNAME jrc -irlen 6 -ircapture 0x1 -irmask 0x3f -expected-id $_JRC_TAPID -ignore-version
53 jtag configure $_CHIPNAME.jrc -event setup {
54         global _DEFAULT_TAPS
55         enable_default_taps $_DEFAULT_TAPS
56 }
57 # some TCK tycles are required to activate the DEBUG power domain
58 jtag configure $_CHIPNAME.jrc -event post-reset "runtest 100"
59
60 #
61 # helper function that enables all taps passed as argument
62 #
63 proc enable_default_taps { taps } {
64         foreach tap $taps {
65                 jtag tapenable $tap
66         }
67 }
68
69 #
70 # Cortex-M3 target
71 #
72 set _TARGETNAME_2 $_CHIPNAME.m3
73 target create $_TARGETNAME_2 cortex_m -dap $_CHIPNAME.m3_dap
74
75 #
76 # Cortex-A8 target
77 #
78 set _TARGETNAME $_CHIPNAME.cpu
79 target create $_TARGETNAME cortex_a -dap $_CHIPNAME.dap -dbgbase 0x80001000
80
81 # SRAM: 64K at 0x4030.0000; use the first 16K
82 $_TARGETNAME configure -work-area-phys 0x40300000 -work-area-size 0x4000
83
84
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 { } {
93         global WDT1_WSPR
94         global WDT1_W_PEND_WSPR
95         global _TARGETNAME
96
97         set curstate [$_TARGETNAME curstate]
98
99         if { [string compare $curstate halted] == 0 } {
100                 set WDT_DISABLE_SEQ1    0xaaaa
101                 set WDT_DISABLE_SEQ2    0x5555
102
103                 mww phys $WDT1_WSPR $WDT_DISABLE_SEQ1
104
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}] } { }
109
110                 mww phys $WDT1_WSPR $WDT_DISABLE_SEQ2
111                 while { [expr {[mrw $WDT1_W_PEND_WSPR] & 0x10}] } { }
112         }
113 }
114 $_TARGETNAME configure -event reset-end { disable_watchdog }