1 /*
2  * Arm SCP/MCP Software
3  * Copyright (c) 2022, Arm Limited and Contributors. All rights reserved.
4  *
5  * SPDX-License-Identifier: BSD-3-Clause
6  */
7 #include <lcp_mhu3.h>
8 #include <lcp_mmap.h>
9 
10 #include <mod_mhu3.h>
11 
12 #include <fwk_element.h>
13 #include <fwk_id.h>
14 #include <fwk_module.h>
15 
16 #include <fmw_cmsis.h>
17 
18 #include <stddef.h>
19 
20 enum mhu3_device2lcp_irq {
21     MHU3_SCP2LCP_IRQ_COMBINED = 40,
22     MHU3_AP2LCP_IRQ_PBX_COMBINED = 48,
23     MHU3_AP2LCP_IRQ_STD_CH_TRANSFER = 52,
24     MHU3_AP2LCP_IRQ_FAST_CH_TRANSFER_0 = 56,
25     MHU3_AP2LCP_IRQ_FAST_CH_TRANSFER_1 = 57,
26     MHU3_AP2LCP_IRQ_FAST_CH_TRANSFER_2 = 58,
27 };
28 
29 #define LCP_AP_NUM_CHANNELS  1
30 #define LCP_SCP_NUM_CHANNELS 1
31 
32 struct mod_mhu3_channel_config ap_lcp_channel_config[LCP_AP_NUM_CHANNELS] = {
33     /* PBX CH 0, FLAG 0, MBX CH 0, FLAG 0 */
34     MOD_MHU3_INIT_DBCH(0, 0, 0, 0),
35 };
36 
37 struct mod_mhu3_channel_config scp_lcp_channel_config[LCP_SCP_NUM_CHANNELS] = {
38     /* PBX CH 0, FLAG 0, MBX CH 0, FLAG 0 */
39     MOD_MHU3_INIT_DBCH(0, 0, 0, 0),
40 };
41 
42 static const struct fwk_element element_table[MHU3_DEVICE_IDX_COUNT+1] = {
43     [MHU3_DEVICE_IDX_SCP_LCP] = {
44         .name = "",
45         .sub_element_count = LCP_SCP_NUM_CHANNELS,
46         .data = &(struct mod_mhu3_device_config) {
47             .irq = (unsigned int) MHU3_SCP2LCP_IRQ_COMBINED,
48             .in = LCP0_SCP_MHU_MBX_BASE,
49             .out = LCP0_SCP_MHU_PBX_BASE,
50             .channels = &scp_lcp_channel_config[0],
51         },
52     },
53     [MHU3_DEVICE_IDX_COUNT] = { 0 },
54 };
55 
get_element_table(fwk_id_t module_id)56 static const struct fwk_element *get_element_table(fwk_id_t module_id)
57 {
58     return element_table;
59 }
60 
61 struct fwk_module_config config_mhu3 = {
62     .elements = FWK_MODULE_DYNAMIC_ELEMENTS(get_element_table),
63 };
64