1 /*
2  * Copyright (c) 2019-2023 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 "host_device_definition.h"
27 #include "platform_base_address.h"
28 #include "host_base_address.h"
29 
30 /* Arm UART PL011 driver structures */
31 #ifdef UART0_PL011_S
32 static const struct uart_pl011_dev_cfg_t UART0_PL011_DEV_CFG_S = {
33     .base = HOST_UART0_BASE_S,
34     .def_baudrate = DEFAULT_UART_BAUDRATE,
35     .def_wlen = UART_PL011_WLEN_8,
36     .def_parity = UART_PL011_PARITY_DISABLED,
37     .def_stopbit = UART_PL011_STOPBIT_1};
38 static struct uart_pl011_dev_data_t UART0_PL011_DEV_DATA_S = {
39     .state = 0,
40     .uart_clk = 0,
41     .baudrate = 0};
42 struct uart_pl011_dev_t UART0_PL011_DEV_S = {&(UART0_PL011_DEV_CFG_S),
43                                              &(UART0_PL011_DEV_DATA_S)};
44 #endif
45 #ifdef UART0_PL011_NS
46 static const struct uart_pl011_dev_cfg_t UART0_PL011_DEV_CFG_NS = {
47     .base = HOST_UART0_BASE_NS,
48     .def_baudrate = DEFAULT_UART_BAUDRATE,
49     .def_wlen = UART_PL011_WLEN_8,
50     .def_parity = UART_PL011_PARITY_DISABLED,
51     .def_stopbit = UART_PL011_STOPBIT_1};
52 static struct uart_pl011_dev_data_t UART0_PL011_DEV_DATA_NS = {
53     .state = 0,
54     .uart_clk = 0,
55     .baudrate = 0};
56 struct uart_pl011_dev_t UART0_PL011_DEV_NS = {&(UART0_PL011_DEV_CFG_NS),
57                                               &(UART0_PL011_DEV_DATA_NS)};
58 #endif
59 
60 #if (defined (SPI_STRATAFLASHJ3_S) && defined (CFI_S))
61 static const struct cfi_dev_cfg_t CFI_DEV_CFG_S = {
62     /* Define the flash base/size to be the same as the host access area, as the
63      * flash may not be mapped contiguously or predictably within that area.
64      */
65     .base = HOST_ACCESS_BASE_S,
66 };
67 struct cfi_dev_t CFI_DEV_S = {
68     .cfg = &CFI_DEV_CFG_S,
69 };
70 #endif
71 
72 #if (defined(SPI_STRATAFLASHJ3_S) && defined(CFI_S))
73 struct cfi_strataflashj3_dev_t SPI_STRATAFLASHJ3_DEV = {
74     .controller = &CFI_DEV_S,
75     .total_sector_cnt = 0,
76     .page_size = 0,
77     .sector_size = 0,
78     .program_unit = 0,
79     .is_initialized = false
80 };
81 #endif
82 
83 /* Message Handling Units (MHU) */
84 #ifdef MHU_AP_MONITOR_TO_RSE
85 struct mhu_v2_x_dev_t MHU_AP_MONITOR_TO_RSE_DEV = {
86     MHU0_RECEIVER_BASE_S,
87     MHU_V2_X_RECEIVER_FRAME};
88 #endif
89 
90 #ifdef MHU_RSE_TO_AP_MONITOR
91 struct mhu_v2_x_dev_t MHU_RSE_TO_AP_MONITOR_DEV = {
92     MHU0_SENDER_BASE_S,
93     MHU_V2_X_SENDER_FRAME};
94 #endif
95 
96 #ifdef MHU_SCP_TO_RSE
97 struct mhu_v2_x_dev_t MHU_SCP_TO_RSE_DEV = {
98     MHU2_RECEIVER_BASE_S,
99     MHU_V2_X_RECEIVER_FRAME};
100 #endif
101 
102 #ifdef MHU_RSE_TO_SCP
103 struct mhu_v2_x_dev_t MHU_RSE_TO_SCP_DEV = {
104     MHU2_SENDER_BASE_S,
105     MHU_V2_X_SENDER_FRAME};
106 #endif
107