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