1 /*
2  * Copyright (c) 2019-2021 Arm Limited. All rights reserved.
3  *
4  * Licensed under the Apache License Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *     http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing software
11  * distributed under the License is distributed on an "AS IS" BASIS
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 /**
18  * \file device_definition.c
19  * \brief This file defines exports the structures based on the peripheral
20  * definitions from device_cfg.h.
21  * This file is meant to be used as a helper for baremetal
22  * applications and/or as an example of how to configure the generic
23  * driver structures.
24  */
25 
26 #include "device_definition.h"
27 #include "platform_base_address.h"
28 #include "tfm_plat_defs.h"
29 
30 /* UART CMSDK driver structures */
31 #ifdef UART0_CMSDK_S
32 static const struct uart_cmsdk_dev_cfg_t UART0_CMSDK_DEV_CFG_S = {
33     .base = UART0_BASE_S,
34     .default_baudrate = DEFAULT_UART_BAUDRATE
35 };
36 static struct uart_cmsdk_dev_data_t UART0_CMSDK_DEV_DATA_S = {
37     .state = 0,
38     .system_clk = 0,
39     .baudrate = 0
40 };
41 struct uart_cmsdk_dev_t ARM_UART0_DEV_S = {
42     &(UART0_CMSDK_DEV_CFG_S),
43     &(UART0_CMSDK_DEV_DATA_S)
44 };
45 #endif
46 #ifdef UART0_CMSDK_NS
47 static const struct uart_cmsdk_dev_cfg_t UART0_CMSDK_DEV_CFG_NS = {
48     .base = UART0_BASE_NS,
49     .default_baudrate = DEFAULT_UART_BAUDRATE
50 };
51 static struct uart_cmsdk_dev_data_t UART0_CMSDK_DEV_DATA_NS = {
52     .state = 0,
53     .system_clk = 0,
54     .baudrate = 0
55 };
56 struct uart_cmsdk_dev_t ARM_UART0_DEV_NS = {
57     &(UART0_CMSDK_DEV_CFG_NS),
58     &(UART0_CMSDK_DEV_DATA_NS)
59 };
60 #endif
61 
62 #ifdef UART1_CMSDK_S
63 static const struct uart_cmsdk_dev_cfg_t UART1_CMSDK_DEV_CFG_S = {
64     .base = UART1_BASE_S,
65     .default_baudrate = DEFAULT_UART_BAUDRATE
66 };
67 static struct uart_cmsdk_dev_data_t UART1_CMSDK_DEV_DATA_S = {
68     .state = 0,
69     .system_clk = 0,
70     .baudrate = 0
71 };
72 struct uart_cmsdk_dev_t ARM_UART1_DEV_S = {
73     &(UART1_CMSDK_DEV_CFG_S),
74     &(UART1_CMSDK_DEV_DATA_S)
75 };
76 #endif
77 #ifdef UART1_CMSDK_NS
78 static const struct uart_cmsdk_dev_cfg_t UART1_CMSDK_DEV_CFG_NS = {
79     .base = UART1_BASE_NS,
80     .default_baudrate = DEFAULT_UART_BAUDRATE
81 };
82 static struct uart_cmsdk_dev_data_t UART1_CMSDK_DEV_DATA_NS = {
83     .state = 0,
84     .system_clk = 0,
85     .baudrate = 0
86 };
87 struct uart_cmsdk_dev_t ARM_UART1_DEV_NS = {
88     &(UART1_CMSDK_DEV_CFG_NS),
89     &(UART1_CMSDK_DEV_DATA_NS)
90 };
91 #endif
92 
93 #ifdef UART2_CMSDK_S
94 static const struct uart_cmsdk_dev_cfg_t UART2_CMSDK_DEV_CFG_S = {
95     .base = UART2_BASE_S,
96     .default_baudrate = DEFAULT_UART_BAUDRATE
97 };
98 static struct uart_cmsdk_dev_data_t UART2_CMSDK_DEV_DATA_S = {
99     .state = 0,
100     .system_clk = 0,
101     .baudrate = 0
102 };
103 struct uart_cmsdk_dev_t ARM_UART2_DEV_S = {
104     &(UART2_CMSDK_DEV_CFG_S),
105     &(UART2_CMSDK_DEV_DATA_S)
106 };
107 #endif
108 #ifdef UART2_CMSDK_NS
109 static const struct uart_cmsdk_dev_cfg_t UART2_CMSDK_DEV_CFG_NS = {
110     .base = UART2_BASE_NS,
111     .default_baudrate = DEFAULT_UART_BAUDRATE
112 };
113 static struct uart_cmsdk_dev_data_t UART2_CMSDK_DEV_DATA_NS = {
114     .state = 0,
115     .system_clk = 0,
116     .baudrate = 0
117 };
118 struct uart_cmsdk_dev_t ARM_UART2_DEV_NS = {
119     &(UART2_CMSDK_DEV_CFG_NS),
120     &(UART2_CMSDK_DEV_DATA_NS)
121 };
122 #endif
123 
124 #ifdef UART3_CMSDK_S
125 static const struct uart_cmsdk_dev_cfg_t UART3_CMSDK_DEV_CFG_S = {
126     .base = UART3_BASE_S,
127     .default_baudrate = DEFAULT_UART_BAUDRATE
128 };
129 static struct uart_cmsdk_dev_data_t UART3_CMSDK_DEV_DATA_S = {
130     .state = 0,
131     .system_clk = 0,
132     .baudrate = 0
133 };
134 struct uart_cmsdk_dev_t ARM_UART3_DEV_S = {
135     &(UART3_CMSDK_DEV_CFG_S),
136     &(UART3_CMSDK_DEV_DATA_S)
137 };
138 #endif
139 #ifdef UART3_CMSDK_NS
140 static const struct uart_cmsdk_dev_cfg_t UART3_CMSDK_DEV_CFG_NS = {
141     .base = UART3_BASE_NS,
142     .default_baudrate = DEFAULT_UART_BAUDRATE
143 };
144 static struct uart_cmsdk_dev_data_t UART3_CMSDK_DEV_DATA_NS = {
145     .state = 0,
146     .system_clk = 0,
147     .baudrate = 0
148 };
149 struct uart_cmsdk_dev_t ARM_UART3_DEV_NS = {
150     &(UART3_CMSDK_DEV_CFG_NS),
151     &(UART3_CMSDK_DEV_DATA_NS)
152 };
153 #endif
154 
155 #ifdef UART4_CMSDK_S
156 static const struct uart_cmsdk_dev_cfg_t UART4_CMSDK_DEV_CFG_S = {
157     .base = UART4_BASE_S,
158     .default_baudrate = DEFAULT_UART_BAUDRATE
159 };
160 static struct uart_cmsdk_dev_data_t UART4_CMSDK_DEV_DATA_S = {
161     .state = 0,
162     .system_clk = 0,
163     .baudrate = 0
164 };
165 struct uart_cmsdk_dev_t ARM_UART4_DEV_S = {
166     &(UART4_CMSDK_DEV_CFG_S),
167     &(UART4_CMSDK_DEV_DATA_S)
168 };
169 #endif
170 #ifdef UART4_CMSDK_NS
171 static const struct uart_cmsdk_dev_cfg_t UART4_CMSDK_DEV_CFG_NS = {
172     .base = UART4_BASE_NS,
173     .default_baudrate = DEFAULT_UART_BAUDRATE
174 };
175 static struct uart_cmsdk_dev_data_t UART4_CMSDK_DEV_DATA_NS = {
176     .state = 0,
177     .system_clk = 0,
178     .baudrate = 0
179 };
180 struct uart_cmsdk_dev_t ARM_UART4_DEV_NS = {
181     &(UART4_CMSDK_DEV_CFG_NS),
182     &(UART4_CMSDK_DEV_DATA_NS)
183 };
184 #endif
185 
186 #ifdef UART5_CMSDK_S
187 static const struct uart_cmsdk_dev_cfg_t UART5_CMSDK_DEV_CFG_S = {
188     .base = UART5_BASE_S,
189     .default_baudrate = DEFAULT_UART_BAUDRATE
190 };
191 static struct uart_cmsdk_dev_data_t UART5_CMSDK_DEV_DATA_S = {
192     .state = 0,
193     .system_clk = 0,
194     .baudrate = 0
195 };
196 struct uart_cmsdk_dev_t ARM_UART5_DEV_S = {
197     &(UART5_CMSDK_DEV_CFG_S),
198     &(UART5_CMSDK_DEV_DATA_S)
199 };
200 #endif
201 #ifdef UART5_CMSDK_NS
202 static const struct uart_cmsdk_dev_cfg_t UART5_CMSDK_DEV_CFG_NS = {
203     .base = UART5_BASE_NS,
204     .default_baudrate = DEFAULT_UART_BAUDRATE
205 };
206 static struct uart_cmsdk_dev_data_t UART5_CMSDK_DEV_DATA_NS = {
207     .state = 0,
208     .system_clk = 0,
209     .baudrate = 0
210 };
211 struct uart_cmsdk_dev_t ARM_UART5_DEV_NS = {
212     &(UART5_CMSDK_DEV_CFG_NS),
213     &(UART5_CMSDK_DEV_DATA_NS)
214 };
215 #endif
216 
217 /* ARM PPC SIE 200 driver structures */
218 #ifdef AHB_PPC0_S
219 static struct ppc_sse200_dev_cfg_t AHB_PPC0_DEV_CFG_S = {
220     .spctrl_base  = CMSDK_SPCTRL_BASE_S,
221     .nspctrl_base = CMSDK_NSPCTRL_BASE_NS
222 };
223 static struct ppc_sse200_dev_data_t AHB_PPC0_DEV_DATA_S = {
224     .p_ns_ppc  = 0,
225     .p_sp_ppc  = 0,
226     .p_nsp_ppc = 0,
227     .int_bit_mask = 0,
228     .state = 0
229 };
230 struct ppc_sse200_dev_t AHB_PPC0_DEV_S = {
231     &AHB_PPC0_DEV_CFG_S,
232     &AHB_PPC0_DEV_DATA_S
233 };
234 #endif
235 
236 #ifdef AHB_PPCEXP0_S
237 static struct ppc_sse200_dev_cfg_t AHB_PPCEXP0_DEV_CFG_S = {
238     .spctrl_base  = CMSDK_SPCTRL_BASE_S,
239     .nspctrl_base = CMSDK_NSPCTRL_BASE_NS
240 };
241 static struct ppc_sse200_dev_data_t AHB_PPCEXP0_DEV_DATA_S = {
242     .p_ns_ppc  = 0,
243     .p_sp_ppc  = 0,
244     .p_nsp_ppc = 0,
245     .int_bit_mask = 0,
246     .state = 0
247 };
248 struct ppc_sse200_dev_t AHB_PPCEXP0_DEV_S = {
249     &AHB_PPCEXP0_DEV_CFG_S,
250     &AHB_PPCEXP0_DEV_DATA_S
251 };
252 #endif
253 
254 #ifdef APB_PPC0_S
255 static struct ppc_sse200_dev_cfg_t APB_PPC0_DEV_CFG_S = {
256     .spctrl_base  = CMSDK_SPCTRL_BASE_S,
257     .nspctrl_base = CMSDK_NSPCTRL_BASE_NS
258 };
259 static struct ppc_sse200_dev_data_t APB_PPC0_DEV_DATA_S = {
260     .p_ns_ppc  = 0,
261     .p_sp_ppc  = 0,
262     .p_nsp_ppc = 0,
263     .int_bit_mask = 0,
264     .state = 0
265 };
266 struct ppc_sse200_dev_t APB_PPC0_DEV_S = {
267     &APB_PPC0_DEV_CFG_S,
268     &APB_PPC0_DEV_DATA_S
269 };
270 #endif
271 
272 #ifdef APB_PPC1_S
273 static struct ppc_sse200_dev_cfg_t APB_PPC1_DEV_CFG_S = {
274     .spctrl_base  = CMSDK_SPCTRL_BASE_S,
275     .nspctrl_base = CMSDK_NSPCTRL_BASE_NS
276 };
277 static struct ppc_sse200_dev_data_t APB_PPC1_DEV_DATA_S = {
278     .p_ns_ppc  = 0,
279     .p_sp_ppc  = 0,
280     .p_nsp_ppc = 0,
281     .int_bit_mask = 0,
282     .state = 0
283 };
284 struct ppc_sse200_dev_t APB_PPC1_DEV_S = {
285     &APB_PPC1_DEV_CFG_S,
286     &APB_PPC1_DEV_DATA_S
287 };
288 #endif
289 
290 #ifdef APB_PPCEXP0_S
291 static struct ppc_sse200_dev_cfg_t APB_PPCEXP0_DEV_CFG_S = {
292     .spctrl_base  = CMSDK_SPCTRL_BASE_S,
293     .nspctrl_base = CMSDK_NSPCTRL_BASE_NS
294 };
295 static struct ppc_sse200_dev_data_t APB_PPCEXP0_DEV_DATA_S = {
296     .p_ns_ppc  = 0,
297     .p_sp_ppc  = 0,
298     .p_nsp_ppc = 0,
299     .int_bit_mask = 0,
300     .state = 0
301 };
302 struct ppc_sse200_dev_t APB_PPCEXP0_DEV_S = {
303     &APB_PPCEXP0_DEV_CFG_S,
304     &APB_PPCEXP0_DEV_DATA_S
305 };
306 #endif
307 
308 #ifdef APB_PPCEXP1_S
309 static struct ppc_sse200_dev_cfg_t APB_PPCEXP1_DEV_CFG = {
310     .spctrl_base  = CMSDK_SPCTRL_BASE_S,
311     .nspctrl_base = CMSDK_NSPCTRL_BASE_NS
312 };
313 static struct ppc_sse200_dev_data_t APB_PPCEXP1_DEV_DATA_S = {
314     .p_ns_ppc  = 0,
315     .p_sp_ppc  = 0,
316     .p_nsp_ppc = 0,
317     .int_bit_mask = 0,
318     .state = 0
319 };
320 struct ppc_sse200_dev_t APB_PPCEXP1_DEV_S = {
321     &APB_PPCEXP1_DEV_CFG,
322     &APB_PPCEXP1_DEV_DATA_S
323 };
324 #endif
325 
326 #ifdef APB_PPCEXP2_S
327 static struct ppc_sse200_dev_cfg_t APB_PPCEXP2_DEV_CFG = {
328     .spctrl_base  = CMSDK_SPCTRL_BASE_S,
329     .nspctrl_base = CMSDK_NSPCTRL_BASE_NS
330 };
331 static struct ppc_sse200_dev_data_t APB_PPCEXP2_DEV_DATA_S = {
332     .p_ns_ppc  = 0,
333     .p_sp_ppc  = 0,
334     .p_nsp_ppc = 0,
335     .int_bit_mask = 0,
336     .state = 0
337 };
338 struct ppc_sse200_dev_t APB_PPCEXP2_DEV_S = {
339     &APB_PPCEXP2_DEV_CFG,
340     &APB_PPCEXP2_DEV_DATA_S
341 };
342 #endif
343 
344 /* CMSDK Timer driver structures */
345 #ifdef CMSDK_TIMER0_S
346 static const struct timer_cmsdk_dev_cfg_t CMSDK_TIMER0_DEV_CFG_S
347 #ifdef TEST_NS_SLIH_IRQ
348     TFM_LINK_SET_RO_IN_PARTITION_SECTION("TFM_SP_SLIH_TEST", "APP-ROT")
349 #endif
350   = {
351         .base = CMSDK_TIMER0_BASE_S
352     };
353 static struct timer_cmsdk_dev_data_t CMSDK_TIMER0_DEV_DATA_S
354 #ifdef TEST_NS_SLIH_IRQ
355     TFM_LINK_SET_RW_IN_PARTITION_SECTION("TFM_SP_SLIH_TEST", "APP-ROT")
356 #endif
357   = {
358         .is_initialized = 0
359     };
360 struct timer_cmsdk_dev_t CMSDK_TIMER0_DEV_S
361 #ifdef TEST_NS_SLIH_IRQ
362     TFM_LINK_SET_RW_IN_PARTITION_SECTION("TFM_SP_SLIH_TEST", "APP-ROT")
363 #endif
364   = {
365         &(CMSDK_TIMER0_DEV_CFG_S),
366         &(CMSDK_TIMER0_DEV_DATA_S)
367     };
368 #endif
369 #ifdef CMSDK_TIMER0_NS
370 static const struct timer_cmsdk_dev_cfg_t CMSDK_TIMER0_DEV_CFG_NS = {
371     .base = CMSDK_TIMER0_BASE_NS
372 };
373 static struct timer_cmsdk_dev_data_t CMSDK_TIMER0_DEV_DATA_NS = {
374     .is_initialized = 0
375 };
376 struct timer_cmsdk_dev_t CMSDK_TIMER0_DEV_NS = {
377     &(CMSDK_TIMER0_DEV_CFG_NS),
378     &(CMSDK_TIMER0_DEV_DATA_NS)
379 };
380 #endif
381 
382 #ifdef CMSDK_TIMER1_S
383 static const struct timer_cmsdk_dev_cfg_t CMSDK_TIMER1_DEV_CFG_S = {
384     .base = CMSDK_TIMER1_BASE_S
385 };
386 static struct timer_cmsdk_dev_data_t CMSDK_TIMER1_DEV_DATA_S = {
387     .is_initialized = 0
388 };
389 struct timer_cmsdk_dev_t CMSDK_TIMER1_DEV_S = {
390     &(CMSDK_TIMER1_DEV_CFG_S),
391     &(CMSDK_TIMER1_DEV_DATA_S)
392 };
393 #endif
394 #ifdef CMSDK_TIMER1_NS
395 static const struct timer_cmsdk_dev_cfg_t CMSDK_TIMER1_DEV_CFG_NS = {
396     .base = CMSDK_TIMER1_BASE_NS
397 };
398 static struct timer_cmsdk_dev_data_t CMSDK_TIMER1_DEV_DATA_NS = {
399     .is_initialized = 0
400 };
401 struct timer_cmsdk_dev_t CMSDK_TIMER1_DEV_NS = {
402     &(CMSDK_TIMER1_DEV_CFG_NS),
403     &(CMSDK_TIMER1_DEV_DATA_NS)
404 };
405 #endif
406 
407 /* ARM MPC SSE 200 driver structures */
408 #ifdef MPC_ISRAM0_S
409 static const struct mpc_sie200_dev_cfg_t MPC_ISRAM0_DEV_CFG_S = {
410     .base = MPC_ISRAM0_BASE_S
411 };
412 static struct mpc_sie200_dev_data_t MPC_ISRAM0_DEV_DATA_S = {
413     .range_list = 0,
414     .nbr_of_ranges = 0,
415     .state = 0,
416     .reserved = 0
417 };
418 struct mpc_sie200_dev_t MPC_ISRAM0_DEV_S = {
419     &(MPC_ISRAM0_DEV_CFG_S),
420     &(MPC_ISRAM0_DEV_DATA_S)
421 };
422 #endif
423 
424 #ifdef MPC_ISRAM1_S
425 static const struct mpc_sie200_dev_cfg_t MPC_ISRAM1_DEV_CFG_S = {
426     .base = MPC_ISRAM1_BASE_S
427 };
428 static struct mpc_sie200_dev_data_t MPC_ISRAM1_DEV_DATA_S = {
429     .range_list = 0,
430     .nbr_of_ranges = 0,
431     .state = 0,
432     .reserved = 0
433 };
434 struct mpc_sie200_dev_t MPC_ISRAM1_DEV_S = {
435     &(MPC_ISRAM1_DEV_CFG_S),
436     &(MPC_ISRAM1_DEV_DATA_S)
437 };
438 #endif
439 
440 #ifdef MPC_ISRAM2_S
441 static const struct mpc_sie200_dev_cfg_t MPC_ISRAM2_DEV_CFG_S = {
442     .base = MPC_ISRAM2_BASE_S
443 };
444 static struct mpc_sie200_dev_data_t MPC_ISRAM2_DEV_DATA_S = {
445     .range_list = 0,
446     .nbr_of_ranges = 0,
447     .state = 0,
448     .reserved = 0
449 };
450 struct mpc_sie200_dev_t MPC_ISRAM2_DEV_S = {
451     &(MPC_ISRAM2_DEV_CFG_S),
452     &(MPC_ISRAM2_DEV_DATA_S)
453 };
454 #endif
455 
456 #ifdef MPC_ISRAM3_S
457 static const struct mpc_sie200_dev_cfg_t MPC_ISRAM3_DEV_CFG_S = {
458     .base = MPC_ISRAM3_BASE_S
459 };
460 static struct mpc_sie200_dev_data_t MPC_ISRAM3_DEV_DATA_S = {
461     .range_list = 0,
462     .nbr_of_ranges = 0,
463     .state = 0,
464     .reserved = 0
465 };
466 struct mpc_sie200_dev_t MPC_ISRAM3_DEV_S = {
467     &(MPC_ISRAM3_DEV_CFG_S),
468     &(MPC_ISRAM3_DEV_DATA_S)
469 };
470 #endif
471 
472 #ifdef MPC_BRAM_S
473 static const struct mpc_sie200_dev_cfg_t MPC_BRAM_DEV_CFG_S = {
474     .base = MPC_BRAM_BASE_S
475 };
476 static struct mpc_sie200_dev_data_t MPC_BRAM_DEV_DATA_S = {
477     .range_list = 0,
478     .nbr_of_ranges = 0,
479     .state = 0,
480     .reserved = 0
481 };
482 struct mpc_sie200_dev_t MPC_BRAM_DEV_S = {
483     &(MPC_BRAM_DEV_CFG_S),
484     &(MPC_BRAM_DEV_DATA_S)
485 };
486 #endif
487 
488 #ifdef MPC_QSPI_S
489 static const struct mpc_sie200_dev_cfg_t MPC_QSPI_DEV_CFG_S = {
490     .base = MPC_QSPI_BASE_S
491 };
492 static struct mpc_sie200_dev_data_t MPC_QSPI_DEV_DATA_S = {
493     .range_list = 0,
494     .nbr_of_ranges = 0,
495     .state = 0,
496     .reserved = 0
497 };
498 struct mpc_sie200_dev_t MPC_QSPI_DEV_S = {
499     &(MPC_QSPI_DEV_CFG_S),
500     &(MPC_QSPI_DEV_DATA_S)
501 };
502 #endif
503 
504 #ifdef MPC_DDR4_S
505 static const struct mpc_sie200_dev_cfg_t MPC_DDR4_DEV_CFG_S = {
506     .base = MPC_DDR4_BASE_S
507 };
508 static struct mpc_sie200_dev_data_t MPC_DDR4_DEV_DATA_S = {
509     .range_list = 0,
510     .nbr_of_ranges = 0,
511     .state = 0,
512     .reserved = 0
513 };
514 struct mpc_sie200_dev_t MPC_DDR4_DEV_S = {
515     &(MPC_DDR4_DEV_CFG_S),
516     &(MPC_DDR4_DEV_DATA_S)
517 };
518 #endif
519 
520 #ifdef MPS3_IO_S
521 static struct arm_mps3_io_dev_cfg_t MPS3_IO_DEV_CFG_S = {
522     .base = MPS3_IO_FPGAIO_BASE_S
523 };
524 struct arm_mps3_io_dev_t MPS3_IO_DEV_S = {
525     .cfg = &(MPS3_IO_DEV_CFG_S)
526 };
527 #endif
528 
529 #ifdef MPS3_IO_NS
530 static struct arm_mps3_io_dev_cfg_t MPS3_IO_DEV_CFG_NS = {
531     .base = MPS3_IO_FPGAIO_BASE_NS
532 };
533 struct arm_mps3_io_dev_t MPS3_IO_DEV_NS = {
534     .cfg = &(MPS3_IO_DEV_CFG_NS)
535 };
536 #endif
537