tcl/target/renesas_rz_g2: Added RZ/G2LC and RZ/G2UL
[fw/openocd] / tcl / target / renesas_rz_g2.cfg
1 # SPDX-License-Identifier: GPL-2.0-or-later
2
3 # Renesas RZ/G2 SOCs
4 # - There are a combination of Cortex-A57s, Cortex-A53s, Cortex-A55, Cortex-R7
5 # and Cortex-M33 for each SOC
6 # - Each SOC can boot through the Cortex-A5x cores
7
8 # Supported RZ/G2 SOCs and their cores:
9 # RZ/G2H:   Cortex-A57 x4, Cortex-A53 x4, Cortex-R7
10 # RZ/G2M:   Cortex-A57 x2, Cortex-A53 x4, Cortex-R7
11 # RZ/G2N:   Cortex-A57 x2,                Cortex-R7
12 # RZ/G2E:                  Cortex-A53 x2, Cortex-R7
13 # RZ/G2L:                  Cortex-A55 x2, Cortex-M33
14 # RZ/G2LC:                 Cortex-A55 x2, Cortex-M33
15 # RZ/G2UL:                 Cortex-A55 x1, Cortex-M33
16
17 # Usage:
18 # There are 2 configuration options:
19 # SOC:       Selects the supported SOC. (Default 'G2L')
20 # BOOT_CORE: Selects the booting core. 'CA57', 'CA53' or 'CA55'
21
22 transport select jtag
23 reset_config trst_and_srst srst_gates_jtag
24 adapter speed 4000
25 adapter srst delay 500
26
27 if { [info exists SOC] } {
28         set _soc $SOC
29 } else {
30         set _soc G2L
31 }
32
33 set _num_ca57 0
34 set _num_ca55 0
35 set _num_ca53 0
36 set _num_cr7 0
37 set _num_cm33 0
38
39 # Set configuration for each SOC and the default 'BOOT_CORE'
40 switch $_soc {
41         G2H {
42                 set _CHIPNAME r8a774ex
43                 set _num_ca57 4
44                 set _num_ca53 4
45                 set _num_cr7 1
46                 set _boot_core CA57
47                 set _ap_num 1
48         }
49         G2M {
50                 set _CHIPNAME r8a774ax
51                 set _num_ca57 2
52                 set _num_ca53 4
53                 set _num_cr7 1
54                 set _boot_core CA57
55                 set _ap_num 1
56         }
57         G2N {
58                 set _CHIPNAME r8a774bx
59                 set _num_ca57 2
60                 set _num_ca53 0
61                 set _num_cr7 1
62                 set _boot_core CA57
63                 set _ap_num 1
64         }
65         G2E {
66                 set _CHIPNAME r8a774c0
67                 set _num_ca57 0
68                 set _num_ca53 2
69                 set _num_cr7 1
70                 set _boot_core CA53
71                 set _ap_num 1
72         }
73         G2L {
74                 set _CHIPNAME r9a07g044l
75                 set _num_ca55 2
76                 set _num_cm33 1
77                 set _boot_core CA55
78                 set _ap_num 0
79         }
80         G2LC {
81                 set _CHIPNAME r9a07g044c
82                 set _num_ca55 2
83                 set _num_cm33 1
84                 set _boot_core CA55
85                 set _ap_num 0
86         }
87         G2UL {
88                 set _CHIPNAME r9a07g043u
89                 set _num_ca55 1
90                 set _num_cm33 1
91                 set _boot_core CA55
92                 set _ap_num 0
93         }
94         default {
95                 error "'$_soc' is invalid!"
96         }
97 }
98
99 # If configured, override the default 'CHIPNAME'
100 if { [info exists CHIPNAME] } {
101         set _CHIPNAME $CHIPNAME
102 }
103
104 # If configured, override the default 'BOOT_CORE'
105 if { [info exists BOOT_CORE] } {
106         set _boot_core $BOOT_CORE
107 }
108
109 if { [info exists DAP_TAPID] } {
110         set _DAP_TAPID $DAP_TAPID
111 } else {
112         set _DAP_TAPID 0x6ba00477
113 }
114
115 echo "\t$_soc - $_num_ca57 CA57(s), $_num_ca55 CA55(s), $_num_ca53 CA53(s), $_num_cr7 CR7(s), \
116         $_num_cm33 CM33(s)"
117 echo "\tBoot Core - $_boot_core\n"
118
119 set _DAPNAME $_CHIPNAME.dap
120
121
122 # TAP and DAP
123 jtag newtap $_CHIPNAME cpu -irlen 4 -ircapture 0x1 -irmask 0xf -expected-id $_DAP_TAPID \
124         -ignore-version
125 dap create $_DAPNAME -chain-position $_CHIPNAME.cpu
126 echo "$_CHIPNAME.cpu"
127
128 set CA57_DBGBASE {0x80410000 0x80510000 0x80610000 0x80710000}
129 set CA57_CTIBASE {0x80420000 0x80520000 0x80620000 0x80720000}
130 set CA55_DBGBASE {0x10E10000 0x10F10000}
131 set CA55_CTIBASE {0x10E20000 0x10F20000}
132 set CA53_DBGBASE {0x80C10000 0x80D10000 0x80E10000 0x80F10000}
133 set CA53_CTIBASE {0x80C20000 0x80D20000 0x80E20000 0x80F20000}
134 set  CR7_DBGBASE 0x80910000
135 set  CR7_CTIBASE 0x80918000
136 set CM33_DBGBASE 0xE000E000
137 set CM33_CTIBASE 0xE0042000
138
139 set smp_targets ""
140
141 proc setup_a5x {core_name dbgbase ctibase num boot} {
142         for { set _core 0 } { $_core < $num } { incr _core } {
143                 set _TARGETNAME $::_CHIPNAME.$core_name.$_core
144                 set _CTINAME $_TARGETNAME.cti
145                 cti create $_CTINAME -dap $::_DAPNAME -ap-num $::_ap_num \
146                         -baseaddr [lindex $ctibase $_core]
147                 target create $_TARGETNAME aarch64 -dap $::_DAPNAME \
148                         -ap-num $::_ap_num -dbgbase [lindex $dbgbase $_core] -cti $_CTINAME
149                 if { $_core > 0 || $boot == 0 } {
150                         $_TARGETNAME configure -defer-examine
151                 }
152                 set ::smp_targets "$::smp_targets $_TARGETNAME"
153         }
154 }
155
156 proc setup_cr7 {dbgbase ctibase} {
157         set _TARGETNAME $::_CHIPNAME.r7
158         set _CTINAME $_TARGETNAME.cti
159         cti create $_CTINAME -dap $::_DAPNAME -ap-num 1 -baseaddr $ctibase
160         target create $_TARGETNAME cortex_r4 -dap $::_DAPNAME \
161                 -ap-num 1 -dbgbase $dbgbase -defer-examine
162 }
163
164 proc setup_cm33 {dbgbase ctibase} {
165         set _TARGETNAME $::_CHIPNAME.m33
166         set _CTINAME $_TARGETNAME.cti
167         cti create $_CTINAME -dap $::_DAPNAME -ap-num 2 -baseaddr $ctibase
168         target create $_TARGETNAME cortex_m -dap $::_DAPNAME \
169                 -ap-num 2 -dbgbase $dbgbase -defer-examine
170 }
171
172 # Organize target list based on the boot core
173 if { $_boot_core == "CA57" } {
174         setup_a5x a57 $CA57_DBGBASE $CA57_CTIBASE $_num_ca57 1
175         setup_a5x a53 $CA53_DBGBASE $CA53_CTIBASE $_num_ca53 0
176         setup_cr7 $CR7_DBGBASE $CR7_CTIBASE
177 } elseif { $_boot_core == "CA53" } {
178         setup_a5x a53 $CA53_DBGBASE $CA53_CTIBASE $_num_ca53 1
179         setup_a5x a57 $CA57_DBGBASE $CA57_CTIBASE $_num_ca57 0
180         setup_cr7 $CR7_DBGBASE $CR7_CTIBASE
181 } elseif { $_boot_core == "CA55" } {
182         setup_a5x a55 $CA55_DBGBASE $CA55_CTIBASE $_num_ca55 1
183         setup_cm33 $CM33_DBGBASE $CM33_CTIBASE
184 }
185 echo "SMP targets:$smp_targets"
186 eval "target smp $smp_targets"
187
188 if { $_soc == "G2L" || $_soc == "G2LC" || $_soc == "G2UL" } {
189         target create $_CHIPNAME.axi_ap mem_ap -dap $_DAPNAME -ap-num 1
190 }
191
192 proc init_reset {mode} {
193     # Assert both resets: equivalent to a power-on reset
194     adapter assert trst assert srst
195
196     # Deassert TRST to begin TAP communication
197     adapter deassert trst assert srst
198
199     # TAP should now be responsive, validate the scan-chain
200     jtag arp_init
201 }