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 
8 #include <Mockfwk_module.h>
9 
10 #include <internal/mhu3.h>
11 
12 #include <mod_mhu3.h>
13 
14 #include <fwk_element.h>
15 #include <fwk_id.h>
16 #include <fwk_macros.h>
17 
18 enum mhu3_fake_irqs {
19     /* Some fake random device irq numbers */
20     MHU3_FAKE_IRQ_COMBINED = 40,
21     MHU3_FAKE_IRQ_PBX = 45,
22     MHU3_FAKE_DEVICE_1_PBX = 48,
23     MHU3_FAKE_DEVICE_1_MBX = 49,
24     MHU3_FAKE_DEVICE_1_FAST_CH_TRANSFER_0 = 56,
25     MHU3_FAKE_DEVICE_1_FAST_CH_TRANSFER_1 = 57,
26 };
27 
28 /*
29  * This represents index of the channel descriptor within
30  * element table
31  */
32 enum mhu3_fake_device_1_channel_idx {
33     FAKE_DEVICE_1_CHANNEL_DBCH_0_IDX,
34     FAKE_DEVICE_1_CHANNEL_FCH_0_IN_IDX,
35     FAKE_DEVICE_1_CHANNEL_FCH_0_OUT_IDX,
36     FAKE_DEVICE_1_CHANNEL_COUNT,
37 };
38 
39 /* Doorbell channel number */
40 enum dbch_channels {
41     FAKE_DEVICE_1_CHANNEL_DBCH_0,
42 };
43 
44 /*
45  * Fast channel number
46  * separate fast channels with different directions
47  * can have same sequence number
48  */
49 enum fch_channels {
50     FAKE_DEVICE_CHANNEL_FCH_0,
51 };
52 
53 #define FAKE_DEVICE_1_NUM_CH FAKE_DEVICE_1_CHANNEL_COUNT
54 
55 enum mhu3_fake_device_idx {
56     MHU3_DEVICE_IDX_DEVICE_1,
57     MHU3_DEVICE_IDX_COUNT,
58 };
59 
60 struct mod_mhu3_channel_config device_1_channel_config[FAKE_DEVICE_1_NUM_CH] = {
61     /* PBX CH 0, FLAG 0, MBX CH 0, FLAG 0 */
62     MOD_MHU3_INIT_DBCH(0, 0, 0, 0),
63     /* FCH 0, group 0, direction in (can changed for few test cases) */
64     MOD_MHU3_INIT_FCH(0, 0, MOD_MHU3_FCH_DIR_IN),
65     MOD_MHU3_INIT_FCH(0, 0, MOD_MHU3_FCH_DIR_OUT),
66 };
67 
68 /* Provide a fake device info */
69 static const struct fwk_element element_table[MHU3_DEVICE_IDX_COUNT+1] = {
70     [MHU3_DEVICE_IDX_DEVICE_1] = {
71         .name = "",
72         .sub_element_count = FAKE_DEVICE_1_NUM_CH,
73         .data = &(struct mod_mhu3_device_config) {
74             .irq = (unsigned int) MHU3_FAKE_IRQ_COMBINED,
75             .in = (uintptr_t)NULL,
76             .out = (uintptr_t)NULL,
77             .channels = &device_1_channel_config[0],
78         },
79     },
80     [MHU3_DEVICE_IDX_COUNT] = { 0 },
81 };
82 
get_element_table(fwk_id_t module_id)83 static const struct fwk_element *get_element_table(fwk_id_t module_id)
84 {
85     return element_table;
86 }
87 
88 struct fwk_module_config config_fake_mhu3 = {
89     .elements = FWK_MODULE_DYNAMIC_ELEMENTS(get_element_table),
90 };
91