tcl/target: add SPDX tag
[fw/openocd] / tcl / target / renesas_rcar_gen2.cfg
1 # SPDX-License-Identifier: GPL-2.0-or-later
2
3 # Renesas R-Car Generation 2 SOCs
4 # - There are a combination of Cortex-A15s and Cortex-A7s for each Gen2 SOC
5 # - Each SOC can boot through any of the, up to 2, core types that it has
6 #   e.g. H2 can boot through Cortex-A15 or Cortex-A7
7
8 # Supported Gen2 SOCs and their cores:
9 # H2:  Cortex-A15 x 4, Cortex-A7 x 4
10 # M2:  Cortex-A15 x 2
11 # V2H: Cortex-A15 x 2
12 # M2N: Cortex-A15 x 2
13 # E2:                  Cortex-A7 x 2
14
15 # Usage:
16 # There are 2 configuration options:
17 # SOC:       Selects the supported SOC. (Default 'H2')
18 # BOOT_CORE: Selects the booting core. 'CA15', or 'CA7'
19 #            Defaults to 'CA15' if the SOC has one, else defaults to 'CA7'
20
21 if { [info exists SOC] } {
22         set _soc $SOC
23 } else {
24         set _soc H2
25 }
26
27 # Set configuration for each SOC and the default 'BOOT_CORE'
28 switch $_soc {
29         H2 {
30                 set _CHIPNAME r8a7790
31                 set _num_ca15 4
32                 set _num_ca7 4
33                 set _boot_core CA15
34         }
35         M2 {
36                 set _CHIPNAME r8a7791
37                 set _num_ca15 2
38                 set _num_ca7 0
39                 set _boot_core CA15
40         }
41         V2H {
42                 set _CHIPNAME r8a7792
43                 set _num_ca15 2
44                 set _num_ca7 0
45                 set _boot_core CA15
46         }
47         M2N {
48                 set _CHIPNAME r8a7793
49                 set _num_ca15 2
50                 set _num_ca7 0
51                 set _boot_core CA15
52         }
53         E2 {
54                 set _CHIPNAME r8a7794
55                 set _num_ca15 0
56                 set _num_ca7 2
57                 set _boot_core CA7
58         }
59         default {
60                 error "'$_soc' is invalid!"
61         }
62 }
63
64 # If configured, override the default 'CHIPNAME'
65 if { [info exists CHIPNAME] } {
66         set _CHIPNAME $CHIPNAME
67 }
68
69 # If configured, override the default 'BOOT_CORE'
70 if { [info exists BOOT_CORE] } {
71         set _boot_core $BOOT_CORE
72 }
73
74 if { [info exists DAP_TAPID] } {
75         set _DAP_TAPID $DAP_TAPID
76 } else {
77         set _DAP_TAPID 0x4ba00477
78 }
79
80 echo "\t$_soc - $_num_ca15 CA15(s), $_num_ca7 CA7(s)"
81 echo "\tBoot Core - $_boot_core\n"
82
83 set _DAPNAME $_CHIPNAME.dap
84
85 # TAP and DAP
86 jtag newtap $_CHIPNAME cpu -irlen 4 -ircapture 0x01 -irmask 0x0f -expected-id $_DAP_TAPID
87 dap create $_DAPNAME -chain-position $_CHIPNAME.cpu
88
89 set CA15_DBGBASE {0x800B0000 0x800B2000 0x800B4000 0x800B6000}
90 set CA7_DBGBASE  {0x800F0000 0x800F2000 0x800F4000 0x800F6000}
91
92 set _targets ""
93 set smp_targets ""
94
95 proc setup_ca {core_name dbgbase num boot} {
96         global _CHIPNAME
97         global _DAPNAME
98         global smp_targets
99         global _targets
100         for { set _core 0 } { $_core < $num } { incr _core } {
101                 set _TARGETNAME $_CHIPNAME.$core_name.$_core
102                 set _CTINAME $_TARGETNAME.cti
103                 set _command "target create $_TARGETNAME cortex_a -dap $_DAPNAME \
104                         -coreid $_core -dbgbase [lindex $dbgbase $_core]"
105                 if { $_core == 0  && $boot == 1 } {
106                         set _targets "$_TARGETNAME"
107                 } else {
108                         set _command "$_command -defer-examine"
109                 }
110                 set smp_targets "$smp_targets $_TARGETNAME"
111                 eval $_command
112         }
113 }
114
115 # Organize target list based on the boot core
116 if { [string equal $_boot_core CA15] } {
117         setup_ca a15 $CA15_DBGBASE $_num_ca15 1
118         setup_ca a7  $CA7_DBGBASE  $_num_ca7 0
119 } elseif { [string equal $_boot_core CA7] } {
120         setup_ca a7  $CA7_DBGBASE  $_num_ca7 1
121         setup_ca a15 $CA15_DBGBASE $_num_ca15 0
122 } else {
123         setup_ca a15 $CA15_DBGBASE $_num_ca15 0
124         setup_ca a7  $CA7_DBGBASE  $_num_ca7 0
125 }
126
127 source [find target/renesas_rcar_reset_common.cfg]
128
129 eval "target smp $smp_targets"
130 targets $_targets