1 /*
2 * Copyright (c) 2020 - 2024 Renesas Electronics Corporation and/or its affiliates
3 *
4 * SPDX-License-Identifier: BSD-3-Clause
5 */
6 #ifndef BSP_MCU_FAMILY_CFG_H_
7 #define BSP_MCU_FAMILY_CFG_H_
8 #include "bsp_mcu_device_pn_cfg.h"
9 #include "bsp_mcu_device_cfg.h"
10 #include "bsp_override.h"
11 #include "bsp_mcu_info.h"
12 #include "bsp_clock_cfg.h"
13 #define BSP_MCU_GROUP_RA8T1 (1)
14 #define BSP_LOCO_HZ         (DT_PROP_OR(DT_NODELABEL(loco), clock_frequency, 0))
15 #define BSP_MOCO_HZ         (DT_PROP_OR(DT_NODELABEL(moco), clock_frequency, 0))
16 #define BSP_SUB_CLOCK_HZ    (0)
17 #if BSP_CFG_HOCO_FREQUENCY == 0
18 #define BSP_HOCO_HZ (16000000)
19 #elif BSP_CFG_HOCO_FREQUENCY == 1
20 #define BSP_HOCO_HZ (18000000)
21 #elif BSP_CFG_HOCO_FREQUENCY == 2
22 #define BSP_HOCO_HZ (20000000)
23 #elif BSP_CFG_HOCO_FREQUENCY == 4
24 #define BSP_HOCO_HZ (32000000)
25 #elif BSP_CFG_HOCO_FREQUENCY == 7
26 #define BSP_HOCO_HZ (48000000)
27 #else
28 #error "Invalid HOCO frequency chosen (BSP_CFG_HOCO_FREQUENCY) in bsp_clock_cfg.h"
29 #endif
30 
31 #define BSP_CFG_FLL_ENABLE (0)
32 
33 #define BSP_CFG_CLOCK_SETTLING_DELAY_ENABLE (1)
34 #define BSP_CFG_SLEEP_MODE_DELAY_ENABLE     (1)
35 #define BSP_CFG_MSTP_CHANGE_DELAY_ENABLE    (1)
36 #define BSP_CFG_RTOS_IDLE_SLEEP             (0)
37 #define BSP_CFG_CLOCK_SETTLING_DELAY_US     (150)
38 
39 #if defined(BSP_PACKAGE_LQFP) && (BSP_PACKAGE_PINS == 100)
40 #define BSP_MAX_CLOCK_CHANGE_THRESHOLD (180000000U)
41 #elif defined(BSP_PACKAGE_LQFP)
42 #define BSP_MAX_CLOCK_CHANGE_THRESHOLD (200000000U)
43 #else
44 #define BSP_MAX_CLOCK_CHANGE_THRESHOLD (240000000U)
45 #endif
46 
47 #define BSP_CORTEX_VECTOR_TABLE_ENTRIES (16U)
48 #define BSP_VECTOR_TABLE_MAX_ENTRIES    (112U)
49 #define BSP_CFG_INLINE_IRQ_FUNCTIONS    (1)
50 
51 #if defined(_RA_TZ_SECURE)
52 #define BSP_TZ_SECURE_BUILD    (1)
53 #define BSP_TZ_NONSECURE_BUILD (0)
54 #elif defined(_RA_TZ_NONSECURE)
55 #define BSP_TZ_SECURE_BUILD    (0)
56 #define BSP_TZ_NONSECURE_BUILD (1)
57 #else
58 #define BSP_TZ_SECURE_BUILD    (0)
59 #define BSP_TZ_NONSECURE_BUILD (0)
60 #endif
61 
62 /* TrustZone Settings */
63 #define BSP_TZ_CFG_INIT_SECURE_ONLY   (BSP_CFG_CLOCKS_SECURE || (!BSP_CFG_CLOCKS_OVERRIDE))
64 #define BSP_TZ_CFG_SKIP_INIT          (BSP_TZ_NONSECURE_BUILD && BSP_TZ_CFG_INIT_SECURE_ONLY)
65 #define BSP_TZ_CFG_EXCEPTION_RESPONSE (0)
66 
67 /* CMSIS TrustZone Settings */
68 #define SCB_CSR_AIRCR_INIT         (1)
69 #define SCB_AIRCR_BFHFNMINS_VAL    (0)
70 #define SCB_AIRCR_SYSRESETREQS_VAL (1)
71 #define SCB_AIRCR_PRIS_VAL         (0)
72 #define TZ_FPU_NS_USAGE            (1)
73 #ifndef SCB_NSACR_CP10_11_VAL
74 #define SCB_NSACR_CP10_11_VAL (3U)
75 #endif
76 
77 #ifndef FPU_FPCCR_TS_VAL
78 #define FPU_FPCCR_TS_VAL (1U)
79 #endif
80 #define FPU_FPCCR_CLRONRETS_VAL (1)
81 
82 #ifndef FPU_FPCCR_CLRONRET_VAL
83 #define FPU_FPCCR_CLRONRET_VAL (1)
84 #endif
85 
86 /* Type 1 Peripheral Security Attribution */
87 
88 /* Peripheral Security Attribution Register (PSAR) Settings */
89 #ifndef BSP_TZ_CFG_PSARB
90 #define BSP_TZ_CFG_PSARB                                                                           \
91 	((((RA_NOT_DEFINED > 0) ? 0U : 1U) << 4) /* I3C */ |                                       \
92 	 (((RA_NOT_DEFINED > 0) ? 0U : 1U) << 8) /* IIC1 */ |                                      \
93 	 (((RA_NOT_DEFINED > 0) ? 0U : 1U) << 9) /* IIC0 */ |                                      \
94 	 (((RA_NOT_DEFINED > 0) ? 0U : 1U) << 11) /* USBFS */ |                                    \
95 	 (((RA_NOT_DEFINED > 0) ? 0U : 1U) << 12) /* USBHS */ | (1 << 15) /* ETHERC/EDMAC */ |     \
96 	 (1 << 16) /* OSPI */ | (((RA_NOT_DEFINED > 0) ? 0U : 1U) << 18) /* SPI1 */ |              \
97 	 (((RA_NOT_DEFINED > 0) ? 0U : 1U) << 19) /* SPI0 */ |                                     \
98 	 (((RA_NOT_DEFINED > 0) ? 0U : 1U) << 22) /* SCI9 */ |                                     \
99 	 (((RA_NOT_DEFINED > 0) ? 0U : 1U) << 27) /* SCI4 */ |                                     \
100 	 (((RA_NOT_DEFINED > 0) ? 0U : 1U) << 28) /* SCI3 */ |                                     \
101 	 (((RA_NOT_DEFINED > 0) ? 0U : 1U) << 29) /* SCI2 */ |                                     \
102 	 (((RA_NOT_DEFINED > 0) ? 0U : 1U) << 30) /* SCI1 */ |                                     \
103 	 (((RA_NOT_DEFINED > 0) ? 0U : 1U) << 31) /* SCI0 */)
104 #endif
105 #ifndef BSP_TZ_CFG_PSARC
106 #define BSP_TZ_CFG_PSARC                                                                           \
107 	((((RA_NOT_DEFINED > 0) ? 0U : 1U) << 0) /* CAC */ |                                       \
108 	 (((RA_NOT_DEFINED > 0) ? 0U : 1U) << 1) /* CRC */ |                                       \
109 	 (((RA_NOT_DEFINED > 0) ? 0U : 1U) << 7) /* SSIE1 */ |                                     \
110 	 (((RA_NOT_DEFINED > 0) ? 0U : 1U) << 8) /* SSIE0 */ |                                     \
111 	 (((RA_NOT_DEFINED > 0) ? 0U : 1U) << 11) /* SDHI1 */ |                                    \
112 	 (((RA_NOT_DEFINED > 0) ? 0U : 1U) << 12) /* SDHI0 */ |                                    \
113 	 (((RA_NOT_DEFINED > 0) ? 0U : 1U) << 13) /* DOC */ |                                      \
114 	 (((RA_NOT_DEFINED > 0) ? 0U : 1U) << 16) /* CEU */ |                                      \
115 	 (((RA_NOT_DEFINED > 0) ? 0U : 1U) << 26) /* CANFD1 */ |                                   \
116 	 (((RA_NOT_DEFINED > 0) ? 0U : 1U) << 27) /* CANFD0 */ |                                   \
117 	 (((RA_NOT_DEFINED > 0) ? 0U : 1U) << 31) /* RSIP7 */)
118 #endif
119 #ifndef BSP_TZ_CFG_PSARD
120 #define BSP_TZ_CFG_PSARD                                                                           \
121 	((((RA_NOT_DEFINED > 0) ? 0U : 1U) << 4) /* AGT1 */ |                                      \
122 	 (((RA_NOT_DEFINED > 0) ? 0U : 1U) << 5) /* AGT0 */ |                                      \
123 	 (((RA_NOT_DEFINED > 0) ? 0U : 1U) << 11) /* POEG3 */ |                                    \
124 	 (((RA_NOT_DEFINED > 0) ? 0U : 1U) << 12) /* POEG2 */ |                                    \
125 	 (((RA_NOT_DEFINED > 0) ? 0U : 1U) << 13) /* POEG1 */ |                                    \
126 	 (((RA_NOT_DEFINED > 0) ? 0U : 1U) << 14) /* POEG0 */ |                                    \
127 	 (((RA_NOT_DEFINED > 0) ? 0U : 1U) << 15) /* ADC121 */ |                                   \
128 	 (((RA_NOT_DEFINED > 0) ? 0U : 1U) << 16) /* ADC120 */ |                                   \
129 	 (((RA_NOT_DEFINED > 0) ? 0U : 1U) << 20) /* DAC120 */ |                                   \
130 	 (((RA_NOT_DEFINED > 0) ? 0U : 1U) << 22) /* TSN */ |                                      \
131 	 (((RA_NOT_DEFINED > 0) ? 0U : 1U) << 27) /* ACMPHS1 */ |                                  \
132 	 (((RA_NOT_DEFINED > 0) ? 0U : 1U) << 28) /* ACMPHS0 */)
133 #endif
134 #ifndef BSP_TZ_CFG_PSARE
135 #define BSP_TZ_CFG_PSARE                                                                           \
136 	((((RA_NOT_DEFINED > 0) ? 0U : 1U) << 1) /* WDT */ |                                       \
137 	 (((RA_NOT_DEFINED > 0) ? 0U : 1U) << 2) /* IWDT */ |                                      \
138 	 (((RA_NOT_DEFINED > 0) ? 0U : 1U) << 3) /* RTC */ |                                       \
139 	 (((RA_NOT_DEFINED > 0) ? 0U : 1U) << 8) /* ULPT1 */ |                                     \
140 	 (((RA_NOT_DEFINED > 0) ? 0U : 1U) << 9) /* ULPT0 */ |                                     \
141 	 (((RA_NOT_DEFINED > 0) ? 0U : 1U) << 18) /* GPT13 */ |                                    \
142 	 (((RA_NOT_DEFINED > 0) ? 0U : 1U) << 19) /* GPT12 */ |                                    \
143 	 (((RA_NOT_DEFINED > 0) ? 0U : 1U) << 20) /* GPT11 */ |                                    \
144 	 (((RA_NOT_DEFINED > 0) ? 0U : 1U) << 21) /* GPT10 */ |                                    \
145 	 (((RA_NOT_DEFINED > 0) ? 0U : 1U) << 22) /* GPT9 */ |                                     \
146 	 (((RA_NOT_DEFINED > 0) ? 0U : 1U) << 23) /* GPT8 */ |                                     \
147 	 (((RA_NOT_DEFINED > 0) ? 0U : 1U) << 24) /* GPT7 */ |                                     \
148 	 (((RA_NOT_DEFINED > 0) ? 0U : 1U) << 25) /* GPT6 */ |                                     \
149 	 (((RA_NOT_DEFINED > 0) ? 0U : 1U) << 26) /* GPT5 */ |                                     \
150 	 (((RA_NOT_DEFINED > 0) ? 0U : 1U) << 27) /* GPT4 */ |                                     \
151 	 (((RA_NOT_DEFINED > 0) ? 0U : 1U) << 28) /* GPT3 */ |                                     \
152 	 (((RA_NOT_DEFINED > 0) ? 0U : 1U) << 29) /* GPT2 */ |                                     \
153 	 (((RA_NOT_DEFINED > 0) ? 0U : 1U) << 30) /* GPT1 */ |                                     \
154 	 (((RA_NOT_DEFINED > 0) ? 0U : 1U) << 31) /* GPT0 */)
155 #endif
156 #ifndef BSP_TZ_CFG_MSSAR
157 #define BSP_TZ_CFG_MSSAR                                                                           \
158 	((((RA_NOT_DEFINED > 0) ? 0U : 1U) << 22) /* DTC_DMAC */ |                                 \
159 	 (((RA_NOT_DEFINED > 0) ? 0U : 1U) << 31) /* ELC */)
160 #endif
161 
162 /* Type 2 Peripheral Security Attribution */
163 
164 /* Security attribution for RSTSRn registers. */
165 #ifndef BSP_TZ_CFG_RSTSAR
166 #define BSP_TZ_CFG_RSTSAR (0x0000000FU)
167 #endif
168 
169 /* Security attribution for registers of LVD channels. */
170 #ifndef BSP_TZ_CFG_LVDSAR
171 /* The LVD driver needs to access both channels. This means that the security attribution for both
172  * channels must be the same.
173  */
174 #if (RA_NOT_DEFINED > 0) || (RA_NOT_DEFINED > 0)
175 #define BSP_TZ_CFG_LVDSAR (0U)
176 #else
177 #define BSP_TZ_CFG_LVDSAR (3U)
178 #endif
179 #endif
180 
181 /* Security attribution for LPM registers.
182  * - OPCCR based on clock security.
183  * - Set remaining registers based on LPM security.
184  */
185 #ifndef BSP_TZ_CFG_LPMSAR
186 #define BSP_TZ_CFG_LPMSAR                                                                          \
187 	((RA_NOT_DEFINED > 0) ? BSP_CFG_CLOCKS_SECURE == 0                                         \
188 			      : (0x002E0106U | (BSP_CFG_CLOCKS_SECURE == 0)))
189 #endif
190 /* Deep Standby Interrupt Factor Security Attribution Register. */
191 #ifndef BSP_TZ_CFG_DPFSAR
192 #define BSP_TZ_CFG_DPFSAR ((1 > 0) ? 0U : 0xAF1FFFFFU)
193 #endif
194 /* RAM Standby Control Security Attribution Register. */
195 #ifndef BSP_TZ_CFG_RSCSAR
196 #define BSP_TZ_CFG_RSCSAR ((1 > 0) ? 0U : 0x00037FFFU)
197 #endif
198 
199 /* Security attribution for CGC registers. */
200 #ifndef BSP_TZ_CFG_CGFSAR
201 #if BSP_CFG_CLOCKS_SECURE
202 /* Protect all CGC registers from Non-secure write access. */
203 #define BSP_TZ_CFG_CGFSAR (0U)
204 #else
205 /* Allow Secure and Non-secure write access. */
206 #define BSP_TZ_CFG_CGFSAR (0x047F3BFDU)
207 #endif
208 #endif
209 
210 /* Security attribution for Battery Backup registers. */
211 #ifndef BSP_TZ_CFG_BBFSAR
212 #define BSP_TZ_CFG_BBFSAR (0x0000001FU)
213 #endif
214 
215 /* Security attribution for registers for IRQ channels. */
216 #ifndef BSP_TZ_CFG_ICUSARA
217 #define BSP_TZ_CFG_ICUSARA                                                                         \
218 	((((RA_NOT_DEFINED > 0) ? 0U : 1U) << 0U) /* External IRQ0 */ |                            \
219 	 (((RA_NOT_DEFINED > 0) ? 0U : 1U) << 1U) /* External IRQ1 */ |                            \
220 	 (((RA_NOT_DEFINED > 0) ? 0U : 1U) << 2U) /* External IRQ2 */ |                            \
221 	 (((RA_NOT_DEFINED > 0) ? 0U : 1U) << 3U) /* External IRQ3 */ |                            \
222 	 (((RA_NOT_DEFINED > 0) ? 0U : 1U) << 4U) /* External IRQ4 */ |                            \
223 	 (((RA_NOT_DEFINED > 0) ? 0U : 1U) << 5U) /* External IRQ5 */ |                            \
224 	 (((RA_NOT_DEFINED > 0) ? 0U : 1U) << 6U) /* External IRQ6 */ |                            \
225 	 (((RA_NOT_DEFINED > 0) ? 0U : 1U) << 7U) /* External IRQ7 */ |                            \
226 	 (((RA_NOT_DEFINED > 0) ? 0U : 1U) << 8U) /* External IRQ8 */ |                            \
227 	 (((RA_NOT_DEFINED > 0) ? 0U : 1U) << 9U) /* External IRQ9 */ |                            \
228 	 (((RA_NOT_DEFINED > 0) ? 0U : 1U) << 10U) /* External IRQ10 */ |                          \
229 	 (((RA_NOT_DEFINED > 0) ? 0U : 1U) << 11U) /* External IRQ11 */ |                          \
230 	 (((RA_NOT_DEFINED > 0) ? 0U : 1U) << 12U) /* External IRQ12 */ |                          \
231 	 (((RA_NOT_DEFINED > 0) ? 0U : 1U) << 13U) /* External IRQ13 */ |                          \
232 	 (((RA_NOT_DEFINED > 0) ? 0U : 1U) << 14U) /* External IRQ14 */ |                          \
233 	 (((RA_NOT_DEFINED > 0) ? 0U : 1U) << 15U) /* External IRQ15 */)
234 #endif
235 
236 /* Security attribution for NMI registers. */
237 #ifndef BSP_TZ_CFG_ICUSARB
238 #define BSP_TZ_CFG_ICUSARB (0 | 0xFFFFFFFEU) /* Should match AIRCR.BFHFNMINS. */
239 #endif
240 
241 /* Security attribution for registers for DMAC channels */
242 #ifndef BSP_TZ_CFG_DMACCHSAR
243 #define BSP_TZ_CFG_DMACCHSAR                                                                       \
244 	((((RA_NOT_DEFINED > 0) ? 0U : 1U) << 0U) /* DMAC Channel 0 */ |                           \
245 	 (((RA_NOT_DEFINED > 0) ? 0U : 1U) << 1U) /* DMAC Channel 1 */ |                           \
246 	 (((RA_NOT_DEFINED > 0) ? 0U : 1U) << 2U) /* DMAC Channel 2 */ |                           \
247 	 (((RA_NOT_DEFINED > 0) ? 0U : 1U) << 3U) /* DMAC Channel 3 */ |                           \
248 	 (((RA_NOT_DEFINED > 0) ? 0U : 1U) << 4U) /* DMAC Channel 4 */ |                           \
249 	 (((RA_NOT_DEFINED > 0) ? 0U : 1U) << 5U) /* DMAC Channel 5 */ |                           \
250 	 (((RA_NOT_DEFINED > 0) ? 0U : 1U) << 6U) /* DMAC Channel 6 */ |                           \
251 	 (((RA_NOT_DEFINED > 0) ? 0U : 1U) << 7U) /* DMAC Channel 7 */)
252 #endif
253 
254 /* Security attribution registers for WUPEN0. */
255 #ifndef BSP_TZ_CFG_ICUSARE
256 #define BSP_TZ_CFG_ICUSARE ((1 > 0) ? 0U : 0xFF1D0000U)
257 #endif
258 
259 /* Security attribution registers for WUPEN1. */
260 #ifndef BSP_TZ_CFG_ICUSARF
261 #define BSP_TZ_CFG_ICUSARF ((1 > 0) ? 0U : 0x00007F08U)
262 #endif
263 
264 /* Trusted Event Route Control Register for IELSR, DMAC.DELSR and ELC.ELSR. Note that currently
265  * Trusted Event Route Control is not supported.
266  */
267 #ifndef BSP_TZ_CFG_TEVTRCR
268 #define BSP_TZ_CFG_TEVTRCR (0)
269 #endif
270 
271 /* Security attribution register for ELCR, ELSEGR0, ELSEGR1 Security Attribution. */
272 #ifndef BSP_TZ_CFG_ELCSARA
273 #define BSP_TZ_CFG_ELCSARA (0x00000007U)
274 #endif
275 
276 /* Set DTCSTSAR if the Secure program uses the DTC. */
277 #if RA_NOT_DEFINED == RA_NOT_DEFINED
278 #define BSP_TZ_CFG_DTC_USED (0U)
279 #else
280 #define BSP_TZ_CFG_DTC_USED (1U)
281 #endif
282 
283 /* Security attribution of FLWT and FCKMHZ registers. */
284 #ifndef BSP_TZ_CFG_FSAR
285 /* If the CGC registers are only accessible in Secure mode, than there is no
286  * reason for nonsecure applications to access FLWT and FCKMHZ.
287  */
288 #define BSP_TZ_CFG_FSAR                                                                            \
289 	(((BSP_CFG_CLOCKS_SECURE == 0) ? (1U << 0) : 0U) | /* FLWTSA */                            \
290 	 ((RA_NOT_DEFINED) > 0 ? 0U : (1U << 1)) |         /* FCACHESA */                          \
291 	 ((BSP_CFG_CLOCKS_SECURE == 0) ? (1U << 8) : 0U) | /* FCKMHZSA */                          \
292 	 ((RA_NOT_DEFINED) > 0 ? 0U : (1U << 9U)) |        /* FACICMISA */                         \
293 	 ((RA_NOT_DEFINED) > 0 ? 0U : (1U << 10U)) /* FACICMRSA */)
294 #endif
295 
296 /* Security attribution for SRAM registers. */
297 #ifndef BSP_TZ_CFG_SRAMSAR
298 /* If the CGC registers are only accessible in Secure mode, than there is no reason for Non Secure
299  * applications to access SRAM0WTEN and therefore there is no reason to access PRCR2.
300  */
301 #define BSP_TZ_CFG_SRAMSAR                                                                         \
302 	(((1U) << 0U) | /* SRAMSA0 */                                                              \
303 	 ((1U) << 1U) | /* SRAMSA1 */                                                              \
304 	 ((1U) << 7U) | /* STBRAMSA */                                                             \
305 	 ((BSP_CFG_CLOCKS_SECURE == 0) ? (1U << 8U) : 0U) /* SRAMWTSA */)
306 #endif
307 
308 /* Security attribution for the DMAC Bus Master MPU settings. */
309 #ifndef BSP_TZ_CFG_MMPUSARA
310 /* The DMAC Bus Master MPU settings should align with the DMAC channel settings. */
311 #define BSP_TZ_CFG_MMPUSARA (BSP_TZ_CFG_DMACCHSAR)
312 #endif
313 
314 /* Security Attribution Register A for BUS Control registers. */
315 #ifndef BSP_TZ_CFG_BUSSARA
316 #define BSP_TZ_CFG_BUSSARA (1U)
317 #endif
318 /* Security Attribution Register B for BUS Control registers. */
319 #ifndef BSP_TZ_CFG_BUSSARB
320 #define BSP_TZ_CFG_BUSSARB (1U)
321 #endif
322 /* Security Attribution Register C for BUS Control registers. */
323 #ifndef BSP_TZ_CFG_BUSSARC
324 #define BSP_TZ_CFG_BUSSARC (1U)
325 #endif
326 
327 /* Enable Uninitialized Non-Secure Application Fallback. */
328 #ifndef BSP_TZ_CFG_NON_SECURE_APPLICATION_FALLBACK
329 #define BSP_TZ_CFG_NON_SECURE_APPLICATION_FALLBACK (1U)
330 #endif
331 
332 #define OFS_SEQ1             0xA001A001 | (1 << 1) | (3 << 2)
333 #define OFS_SEQ2             (15 << 4) | (3 << 8) | (3 << 10)
334 #define OFS_SEQ3             (1 << 12) | (1 << 14) | (1 << 17)
335 #define OFS_SEQ4             (3 << 18) | (15 << 20) | (3 << 24) | (3 << 26)
336 #define OFS_SEQ5             (1 << 28) | (1 << 30)
337 #define BSP_CFG_ROM_REG_OFS0 (OFS_SEQ1 | OFS_SEQ2 | OFS_SEQ3 | OFS_SEQ4 | OFS_SEQ5)
338 
339 #define BSP_CFG_ROM_REG_OFS2 ((1 << 0) | 0xFFFFFFFEU)
340 
341 /* Option Function Select Register 1 Security Attribution */
342 #ifndef BSP_CFG_ROM_REG_OFS1_SEL
343 #if defined(_RA_TZ_SECURE) || defined(_RA_TZ_NONSECURE)
344 #define BSP_CFG_ROM_REG_OFS1_SEL                                                                   \
345 	(0x00000000U | ((0U << 0U)) | ((0U << 3U)) | ((0U << 5U)) |                                \
346 	 ((BSP_CFG_CLOCKS_SECURE == 0) ? 0xF00U : 0U) | ((0U << 24U)) | ((0U << 25U)))
347 #else
348 #define BSP_CFG_ROM_REG_OFS1_SEL (0x00000000U)
349 #endif
350 #endif
351 #define BSP_CFG_ROM_REG_OFS1_INITECCEN (0 << 25)
352 #define BSP_CFG_ROM_REG_OFS1                                                                       \
353 	(0xFCFFFED0 | (1 << 3) | (7) | (1 << 5) | (1 << 8) | (1 << 24) |                           \
354 	 (BSP_CFG_ROM_REG_OFS1_INITECCEN))
355 
356 /* Used to create IELS values for the interrupt initialization table g_interrupt_event_link_select.
357  */
358 #define BSP_PRV_IELS_ENUM(vector) CONCAT(ELC_, vector)
359 
360 /* Dual Mode Select Register */
361 #ifndef BSP_CFG_ROM_REG_DUALSEL
362 #if CONFIG_DUAL_BANK_MODE
363 #define BSP_CFG_ROM_REG_DUALSEL (0xFFFFFFF8U | (0x0U))
364 #else
365 #define BSP_CFG_ROM_REG_DUALSEL (0xFFFFFFF8U | (0x7U))
366 #endif
367 #endif
368 
369 /* Block Protection Register 0 */
370 #ifndef BSP_CFG_ROM_REG_BPS0
371 #define BSP_CFG_ROM_REG_BPS0 (~(0U))
372 #endif
373 /* Block Protection Register 1 */
374 #ifndef BSP_CFG_ROM_REG_BPS1
375 #define BSP_CFG_ROM_REG_BPS1 (~(0U))
376 #endif
377 /* Block Protection Register 2 */
378 #ifndef BSP_CFG_ROM_REG_BPS2
379 #define BSP_CFG_ROM_REG_BPS2 (~(0U))
380 #endif
381 /* Block Protection Register 3 */
382 #ifndef BSP_CFG_ROM_REG_BPS3
383 #define BSP_CFG_ROM_REG_BPS3 (~(0U))
384 #endif
385 /* Permanent Block Protection Register 0 */
386 #ifndef BSP_CFG_ROM_REG_PBPS0
387 #define BSP_CFG_ROM_REG_PBPS0 (~(0U))
388 #endif
389 /* Permanent Block Protection Register 1 */
390 #ifndef BSP_CFG_ROM_REG_PBPS1
391 #define BSP_CFG_ROM_REG_PBPS1 (~(0U))
392 #endif
393 /* Permanent Block Protection Register 2 */
394 #ifndef BSP_CFG_ROM_REG_PBPS2
395 #define BSP_CFG_ROM_REG_PBPS2 (~(0U))
396 #endif
397 /* Permanent Block Protection Register 3 */
398 #ifndef BSP_CFG_ROM_REG_PBPS3
399 #define BSP_CFG_ROM_REG_PBPS3 (~(0U))
400 #endif
401 /* Security Attribution for Block Protection Register 0 (If any blocks are marked as protected in
402  * the secure application, then mark them as secure)
403  */
404 #ifndef BSP_CFG_ROM_REG_BPS_SEL0
405 #define BSP_CFG_ROM_REG_BPS_SEL0 (BSP_CFG_ROM_REG_BPS0 & BSP_CFG_ROM_REG_PBPS0)
406 #endif
407 /* Security Attribution for Block Protection Register 1 (If any blocks are marked as protected in
408  * the secure application, then mark them as secure)
409  */
410 #ifndef BSP_CFG_ROM_REG_BPS_SEL1
411 #define BSP_CFG_ROM_REG_BPS_SEL1 (BSP_CFG_ROM_REG_BPS1 & BSP_CFG_ROM_REG_PBPS1)
412 #endif
413 /* Security Attribution for Block Protection Register 2 (If any blocks are marked as protected in
414  * the secure application, then mark them as secure)
415  */
416 #ifndef BSP_CFG_ROM_REG_BPS_SEL2
417 #define BSP_CFG_ROM_REG_BPS_SEL2 (BSP_CFG_ROM_REG_BPS2 & BSP_CFG_ROM_REG_PBPS2)
418 #endif
419 /* Security Attribution for Block Protection Register 3 (If any blocks are marked as protected in
420  * the secure application, then mark them as secure)
421  */
422 #ifndef BSP_CFG_ROM_REG_BPS_SEL3
423 #define BSP_CFG_ROM_REG_BPS_SEL3 (BSP_CFG_ROM_REG_BPS3 & BSP_CFG_ROM_REG_PBPS3)
424 #endif
425 /* Security Attribution for Bank Select Register */
426 #ifndef BSP_CFG_ROM_REG_BANKSEL_SEL
427 #define BSP_CFG_ROM_REG_BANKSEL_SEL (0xFFFFFFFFU)
428 #endif
429 #ifndef BSP_CLOCK_CFG_MAIN_OSC_WAIT
430 #define BSP_CLOCK_CFG_MAIN_OSC_WAIT (9)
431 #endif
432 
433 /* FSBL Control Register 0 */
434 #ifndef BSP_CFG_ROM_REG_FSBLCTRL0
435 #define BSP_CFG_ROM_REG_FSBLCTRL0                                                                  \
436 	((7 << R_OFS_DATAFLASH_FSBLCTRL0_FSBLEN_Pos) |                                             \
437 	 (7 << R_OFS_DATAFLASH_FSBLCTRL0_FSBLSKIPSW_Pos) |                                         \
438 	 (7 << R_OFS_DATAFLASH_FSBLCTRL0_FSBLSKIPDS_Pos) |                                         \
439 	 (7 << R_OFS_DATAFLASH_FSBLCTRL0_FSBLCLK_Pos) | 0xFFFFF000)
440 #endif
441 
442 /* FSBL Control Register 1 */
443 #ifndef BSP_CFG_ROM_REG_FSBLCTRL1
444 #define BSP_CFG_ROM_REG_FSBLCTRL1 ((3 << R_OFS_DATAFLASH_FSBLCTRL1_FSBLEXMD_Pos) | 0xFFFFFFFC)
445 #endif
446 
447 /* FSBL Control Register 2 */
448 #ifndef BSP_CFG_ROM_REG_FSBLCTRL2
449 #define BSP_CFG_ROM_REG_FSBLCTRL2                                                                  \
450 	((15 << R_OFS_DATAFLASH_FSBLCTRL2_PORTPN_Pos) |                                            \
451 	 (0x1F << R_OFS_DATAFLASH_FSBLCTRL2_PORTGN_Pos) | 0xFFFFFE00)
452 #endif
453 
454 /* Start Address of Code Certificate Register 0 */
455 #ifndef BSP_CFG_ROM_REG_SACC0
456 #define BSP_CFG_ROM_REG_SACC0 (0xFFFFFFFF)
457 #endif
458 
459 /* Start Address of Code Certificate Register 1 */
460 #ifndef BSP_CFG_ROM_REG_SACC1
461 #define BSP_CFG_ROM_REG_SACC1 (0xFFFFFFFF)
462 #endif
463 
464 /* Start Address of Measurement Report Register */
465 #ifndef BSP_CFG_ROM_REG_SAMR
466 #define BSP_CFG_ROM_REG_SAMR (0xFFFFFFFF)
467 #endif
468 
469 /* Hash of OEM_ROOT_PK Register */
470 #ifndef BSP_CFG_ROM_REG_HOEMRTPK
471 #define BSP_CFG_ROM_REG_HOEMRTPK (RA_NOT_DEFINED)
472 #endif
473 
474 /* Configuration Data 0 Lock Bit Register 0 */
475 #ifndef BSP_CFG_ROM_REG_CFGD0LOCK0
476 #define BSP_CFG_ROM_REG_CFGD0LOCK0 (RA_NOT_DEFINED)
477 #endif
478 
479 /* Configuration Data 0 Lock Bit Register 1 */
480 #ifndef BSP_CFG_ROM_REG_CFGD0LOCK1
481 #define BSP_CFG_ROM_REG_CFGD0LOCK1 (RA_NOT_DEFINED)
482 #endif
483 
484 /* Configuration Data 1 Lock Bit Register 0 */
485 #ifndef BSP_CFG_ROM_REG_CFGD1LOCK0
486 #define BSP_CFG_ROM_REG_CFGD1LOCK0 (RA_NOT_DEFINED)
487 #endif
488 
489 /* Configuration Data 1 Lock Bit Register 1 */
490 #ifndef BSP_CFG_ROM_REG_CFGD1LOCK1
491 #define BSP_CFG_ROM_REG_CFGD1LOCK1 (RA_NOT_DEFINED)
492 #endif
493 
494 /* Configuration Data 2 Lock Bit Register */
495 #ifndef BSP_CFG_ROM_REG_CFGD2LOCK
496 #define BSP_CFG_ROM_REG_CFGD2LOCK (RA_NOT_DEFINED)
497 #endif
498 
499 /* Anti-Rollback Counter Lock Setting Register */
500 #ifndef BSP_CFG_ROM_REG_ARCLS
501 #define BSP_CFG_ROM_REG_ARCLS                                                                      \
502 	((RA_NOT_DEFINED << R_OFS_DATAFLASH_ARCLS_ARCS_LK_Pos) |                                   \
503 	 (RA_NOT_DEFINED << R_OFS_DATAFLASH_ARCLS_ARCNS_LK_Pos) |                                  \
504 	 (RA_NOT_DEFINED << R_OFS_DATAFLASH_ARCLS_ARCBL_LK_Pos) | 0xFFC0)
505 #endif
506 
507 /* Anti-Rollback Counter Configuration Setting for Non-secure Application Register */
508 #ifndef BSP_CFG_ROM_REG_ARCCS
509 #define BSP_CFG_ROM_REG_ARCCS (RA_NOT_DEFINED | 0xFFFC)
510 #endif
511 
512 /* Anti-Rollback Counter for Secure Application 0 Register */
513 #ifndef BSP_CFG_ROM_REG_ARC_SEC0
514 #define BSP_CFG_ROM_REG_ARC_SEC0 (0U)
515 #endif
516 
517 /* Anti-Rollback Counter for Secure Application 1 Register */
518 #ifndef BSP_CFG_ROM_REG_ARC_SEC1
519 #define BSP_CFG_ROM_REG_ARC_SEC1 (0U)
520 #endif
521 
522 /* Anti-Rollback Counter for Non-secure Application 0 Register */
523 #ifndef BSP_CFG_ROM_REG_ARC_NSEC0
524 #define BSP_CFG_ROM_REG_ARC_NSEC0 (0U)
525 #endif
526 
527 /* Anti-Rollback Counter for Non-secure Application 1 Register */
528 #ifndef BSP_CFG_ROM_REG_ARC_NSEC1
529 #define BSP_CFG_ROM_REG_ARC_NSEC1 (0U)
530 #endif
531 
532 /* Anti-Rollback Counter for Non-secure Application 2 Register */
533 #ifndef BSP_CFG_ROM_REG_ARC_NSEC2
534 #define BSP_CFG_ROM_REG_ARC_NSEC2 (0U)
535 #endif
536 
537 /* Anti-Rollback Counter for Non-secure Application 3 Register */
538 #ifndef BSP_CFG_ROM_REG_ARC_NSEC3
539 #define BSP_CFG_ROM_REG_ARC_NSEC3 (0U)
540 #endif
541 
542 /* Anti-Rollback Counter for Non-secure Application 4 Register */
543 #ifndef BSP_CFG_ROM_REG_ARC_NSEC4
544 #define BSP_CFG_ROM_REG_ARC_NSEC4 (0U)
545 #endif
546 
547 /* Anti-Rollback Counter for Non-secure Application 5 Register */
548 #ifndef BSP_CFG_ROM_REG_ARC_NSEC5
549 #define BSP_CFG_ROM_REG_ARC_NSEC5 (0U)
550 #endif
551 
552 /* Anti-Rollback Counter for Non-secure Application 6 Register */
553 #ifndef BSP_CFG_ROM_REG_ARC_NSEC6
554 #define BSP_CFG_ROM_REG_ARC_NSEC6 (0U)
555 #endif
556 
557 /* Anti-Rollback Counter for Non-secure Application 7 Register */
558 #ifndef BSP_CFG_ROM_REG_ARC_NSEC7
559 #define BSP_CFG_ROM_REG_ARC_NSEC7 (0U)
560 #endif
561 
562 /* Anti-Rollback Counter for OEMBL 0 Register */
563 #ifndef BSP_CFG_ROM_REG_ARC_OEMBL0
564 #define BSP_CFG_ROM_REG_ARC_OEMBL0 (0U)
565 #endif
566 
567 /* Anti-Rollback Counter for OEMBL 1 Register */
568 #ifndef BSP_CFG_ROM_REG_ARC_OEMBL1
569 #define BSP_CFG_ROM_REG_ARC_OEMBL1 (0U)
570 #endif
571 
572 #ifndef BSP_CFG_DCACHE_ENABLED
573 #define BSP_CFG_DCACHE_ENABLED (CONFIG_DCACHE)
574 #endif
575 
576 /* SDRAM controller configuration */
577 #if DT_NODE_HAS_STATUS_OKAY(DT_INST(0, renesas_ra_sdram))
578 #define BSP_CFG_SDRAM_TRAS                                                                         \
579 	DT_PROP_BY_IDX(DT_CHILD(DT_INST(0, renesas_ra_sdram), bank_0), renesas_ra_sdram_timing, 0)
580 #define BSP_CFG_SDRAM_TRCD                                                                         \
581 	DT_PROP_BY_IDX(DT_CHILD(DT_INST(0, renesas_ra_sdram), bank_0), renesas_ra_sdram_timing, 1)
582 #define BSP_CFG_SDRAM_TRP                                                                          \
583 	DT_PROP_BY_IDX(DT_CHILD(DT_INST(0, renesas_ra_sdram), bank_0), renesas_ra_sdram_timing, 2)
584 #define BSP_CFG_SDRAM_TWR                                                                          \
585 	DT_PROP_BY_IDX(DT_CHILD(DT_INST(0, renesas_ra_sdram), bank_0), renesas_ra_sdram_timing, 3)
586 #define BSP_CFG_SDRAM_TCL                                                                          \
587 	DT_PROP_BY_IDX(DT_CHILD(DT_INST(0, renesas_ra_sdram), bank_0), renesas_ra_sdram_timing, 4)
588 #define BSP_CFG_SDRAM_TRFC                                                                         \
589 	DT_PROP_BY_IDX(DT_CHILD(DT_INST(0, renesas_ra_sdram), bank_0), renesas_ra_sdram_timing, 5)
590 #define BSP_CFG_SDRAM_TREFW                                                                        \
591 	DT_PROP_BY_IDX(DT_CHILD(DT_INST(0, renesas_ra_sdram), bank_0), renesas_ra_sdram_timing, 6)
592 #define BSP_CFG_SDRAM_INIT_ARFI            DT_PROP(DT_INST(0, renesas_ra_sdram), auto_refresh_interval)
593 #define BSP_CFG_SDRAM_INIT_ARFC            DT_PROP(DT_INST(0, renesas_ra_sdram), auto_refresh_count)
594 #define BSP_CFG_SDRAM_INIT_PRC             DT_PROP(DT_INST(0, renesas_ra_sdram), precharge_cycle_count)
595 #define BSP_CFG_SDRAM_MULTIPLEX_ADDR_SHIFT DT_ENUM_IDX(DT_INST(0, renesas_ra_sdram), multiplex_addr_shift)
596 #define BSP_CFG_SDRAM_ENDIAN_MODE          DT_ENUM_IDX(DT_INST(0, renesas_ra_sdram), edian_mode)
597 #define BSP_CFG_SDRAM_ACCESS_MODE          DT_PROP(DT_INST(0, renesas_ra_sdram), continuous_access)
598 #define BSP_CFG_SDRAM_BUS_WIDTH            DT_ENUM_IDX(DT_INST(0, renesas_ra_sdram), bus_width)
599 #else
600 #define BSP_CFG_SDRAM_TRAS 					(0)
601 #define BSP_CFG_SDRAM_TRCD 					(0)
602 #define BSP_CFG_SDRAM_TRP 					(0)
603 #define BSP_CFG_SDRAM_TWR 					(0)
604 #define BSP_CFG_SDRAM_TCL 					(0)
605 #define BSP_CFG_SDRAM_TRFC 					(0)
606 #define BSP_CFG_SDRAM_TREFW 				(0)
607 #define BSP_CFG_SDRAM_INIT_ARFI 			(0)
608 #define BSP_CFG_SDRAM_INIT_ARFC 			(0)
609 #define BSP_CFG_SDRAM_INIT_PRC 				(0)
610 #define BSP_CFG_SDRAM_MULTIPLEX_ADDR_SHIFT 	(0)
611 #define BSP_CFG_SDRAM_ENDIAN_MODE 			(0)
612 #define BSP_CFG_SDRAM_ACCESS_MODE 			(0)
613 #define BSP_CFG_SDRAM_BUS_WIDTH 			(0)
614 #endif	/* DT_NODE_HAS_STATUS_OKAY(DT_INST(0, renesas_ra_sdram)) */
615 
616 #endif /* BSP_MCU_FAMILY_CFG_H_ */
617