334d25568f2a2a0b0708babe08e82446bf82d773
[fw/openocd] / tcl / target / renesas_rcar_gen3.cfg
1 # Renesas R-Car Generation 3 SOCs
2 # - There are a combination of Cortex-A57s, Cortex-A53s, and Cortex-R7 for each Gen3 SOC
3 # - Each SOC can boot through any of the, up to 3, core types that it has
4 #   e.g. H3 can boot through Cortex-A57, Cortex-A53, or Cortex-R7
5
6 # Supported Gen3 SOCs and their cores:
7 #  H3: Cortex-A57 x 4, Cortex-A53 x 4, Cortex-R7 x 2 (Lock-Step)
8 # M3W: Cortex-A57 x 2, Cortex-A53 x 4, Cortex-R7 x 2 (Lock-Step)
9 # M3N: Cortex-A57 x 2,                 Cortex-R7 x 2 (Lock-Step)
10 # V3U:                 Cortex-A76 x 8, Cortex-R52 x2 (Lock-Step)
11 # V3H:                 Cortex-A53 x 4, Cortex-R7 x 2 (Lock-Step)
12 # V3M:                 Cortex-A53 x 2, Cortex-R7 x 2 (Lock-Step)
13 #  E3:                 Cortex-A53 x 1, Cortex-R7 x 2 (Lock-Step)
14 #  D3:                 Cortex-A53 x 1
15
16 # Usage:
17 # There are 2 configuration options:
18 # SOC:       Selects the supported SOC. (Default 'H3')
19 # BOOT_CORE: Selects the booting core. 'CA57', 'CA53', or 'CR7'
20 #            Defaults to 'CA57' if the SOC has one, else defaults to 'CA53'
21
22 if { [info exists SOC] } {
23         set _soc $SOC
24 } else {
25         set _soc H3
26 }
27
28 set _num_ca53 0
29 set _num_ca57 0
30 set _num_ca76 0
31 set _num_cr52 0
32 set _num_cr7 0
33
34 # Set configuration for each SOC and the default 'BOOT_CORE'
35 switch $_soc {
36         H3 {
37                 set _CHIPNAME r8a77950
38                 set _num_ca57 4
39                 set _num_ca53 4
40                 set _num_cr7 1
41                 set _boot_core CA57
42         }
43         M3W {
44                 set _CHIPNAME r8a77960
45                 set _num_ca57 2
46                 set _num_ca53 4
47                 set _num_cr7 1
48                 set _boot_core CA57
49         }
50         M3N {
51                 set _CHIPNAME r8a77965
52                 set _num_ca57 2
53                 set _num_ca53 4
54                 set _num_cr7 1
55                 set _boot_core CA57
56         }
57         V3M {
58                 set _CHIPNAME r8a77970
59                 set _num_ca57 0
60                 set _num_ca53 2
61                 set _num_cr7 1
62                 set _boot_core CA53
63         }
64         V3H {
65                 set _CHIPNAME r8a77980
66                 set _num_ca57 0
67                 set _num_ca53 4
68                 set _num_cr7 1
69                 set _boot_core CA53
70         }
71         E3 {
72                 set _CHIPNAME r8a77990
73                 set _num_ca57 0
74                 set _num_ca53 1
75                 set _num_cr7 1
76                 set _boot_core CA53
77         }
78         D3 {
79                 set _CHIPNAME r8a77995
80                 set _num_ca57 0
81                 set _num_ca53 1
82                 set _num_cr7 0
83                 set _boot_core CA53
84         }
85         V3U {
86                 set _CHIPNAME r8a779a0
87                 set _num_ca76 8
88                 set _num_cr52 1
89                 set _boot_core CA76
90         }
91         default {
92                 error "'$_soc' is invalid!"
93         }
94 }
95
96 # If configured, override the default 'CHIPNAME'
97 if { [info exists CHIPNAME] } {
98         set _CHIPNAME $CHIPNAME
99 }
100
101 # If configured, override the default 'BOOT_CORE'
102 if { [info exists BOOT_CORE] } {
103         set _boot_core $BOOT_CORE
104 }
105
106 if { [info exists DAP_TAPID] } {
107         set _DAP_TAPID $DAP_TAPID
108 } else {
109         set _DAP_TAPID 0x5ba00477
110 }
111
112 echo "\t$_soc - $_num_ca76 CA76(s), $_num_ca57 CA57(s), $_num_ca53 CA53(s), $_num_cr52 CR52(s), $_num_cr7 CR7(s)"
113 echo "\tBoot Core - $_boot_core\n"
114
115 set _DAPNAME $_CHIPNAME.dap
116
117 # TAP and DAP
118 jtag newtap $_CHIPNAME cpu -irlen 4 -ircapture 0x01 -irmask 0x0f -expected-id $_DAP_TAPID
119 dap create $_DAPNAME -chain-position $_CHIPNAME.cpu
120
121 set CA76_DBGBASE {0x81410000 0x81510000 0x81610000 0x81710000 0x81c10000 0x81d10000 0x81e10000 0x81f10000}
122 set CA76_CTIBASE {0x81420000 0x81520000 0x81620000 0x81720000 0x81c20000 0x81d20000 0x81e20000 0x81f20000}
123 set CA57_DBGBASE {0x80410000 0x80510000 0x80610000 0x80710000}
124 set CA57_CTIBASE {0x80420000 0x80520000 0x80620000 0x80720000}
125 set CA53_DBGBASE {0x80C10000 0x80D10000 0x80E10000 0x80F10000}
126 set CA53_CTIBASE {0x80C20000 0x80D20000 0x80E20000 0x80F20000}
127 set CR52_DBGBASE 0x80c10000
128 set CR52_CTIBASE 0x80c20000
129 set  CR7_DBGBASE 0x80910000
130 set  CR7_CTIBASE 0x80918000
131
132 set _targets ""
133 set smp_targets ""
134
135 proc setup_a5x {core_name dbgbase ctibase num boot} {
136         global _CHIPNAME
137         global _DAPNAME
138         global smp_targets
139         global _targets
140         for { set _core 0 } { $_core < $num } { incr _core } {
141                 set _TARGETNAME $_CHIPNAME.$core_name.$_core
142                 set _CTINAME $_TARGETNAME.cti
143                 cti create $_CTINAME -dap $_DAPNAME -ap-num 1 \
144                         -baseaddr [lindex $ctibase $_core]
145                 set _command "target create $_TARGETNAME aarch64 -dap $_DAPNAME \
146                         -ap-num 1 -dbgbase [lindex $dbgbase $_core] -cti $_CTINAME"
147                 if { $_core == 0  && $boot == 1 } {
148                         set _targets "$_TARGETNAME"
149                 } else {
150                         set _command "$_command -defer-examine"
151                 }
152                 set smp_targets "$smp_targets $_TARGETNAME"
153                 eval $_command
154         }
155 }
156
157 proc setup_cr7 {core_name dbgbase ctibase num boot} {
158         global _CHIPNAME
159         global _DAPNAME
160         for { set _core 0 } { $_core < $num } { incr _core } {
161                 set _TARGETNAME $_CHIPNAME.$core_name
162                 set _CTINAME $_TARGETNAME.cti
163                 cti create $_CTINAME -dap $_DAPNAME -ap-num 1 -baseaddr $ctibase
164                 set _command "target create $_TARGETNAME cortex_r4 -dap $_DAPNAME \
165                         -ap-num 1 -dbgbase $dbgbase"
166                 if { $boot == 1 } {
167                         set _targets "$_TARGETNAME"
168                 } else {
169                         set _command "$_command -defer-examine"
170                 }
171                 eval $_command
172         }
173 }
174
175 # Organize target list based on the boot core
176 if { [string equal $_boot_core CA76] } {
177         setup_a5x a76 $CA76_DBGBASE $CA76_CTIBASE $_num_ca76 1
178         setup_cr7 r52 $CR52_DBGBASE $CR52_CTIBASE $_num_cr52 0
179 } elseif { [string equal $_boot_core CA57] } {
180         setup_a5x a57 $CA57_DBGBASE $CA57_CTIBASE $_num_ca57 1
181         setup_a5x a53 $CA53_DBGBASE $CA53_CTIBASE $_num_ca53 0
182         setup_cr7 r7  $CR7_DBGBASE  $CR7_CTIBASE  $_num_cr7  0
183 } elseif { [string equal $_boot_core CA53] } {
184         setup_a5x a53 $CA53_DBGBASE $CA53_CTIBASE $_num_ca53 1
185         setup_a5x a57 $CA57_DBGBASE $CA57_CTIBASE $_num_ca57 0
186         setup_cr7 r7  $CR7_DBGBASE  $CR7_CTIBASE  $_num_cr7  0
187 } elseif { [string equal $_boot_core CR52] } {
188         setup_cr7 r52 $CR52_DBGBASE $CR52_CTIBASE $_num_cr52 1
189         setup_a5x a76 $CA76_DBGBASE $CA76_CTIBASE $_num_ca76 0
190 } else {
191         setup_cr7 r7  $CR7_DBGBASE  $CR7_CTIBASE  $_num_cr7  1
192         setup_a5x a57 $CA57_DBGBASE $CA57_CTIBASE $_num_ca57 0
193         setup_a5x a53 $CA53_DBGBASE $CA53_CTIBASE $_num_ca53 0
194 }
195
196 source [find target/renesas_rcar_reset_common.cfg]
197
198 eval "target smp $smp_targets"
199 targets $_targets