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 <mod_traffic_cop.h>
9 
10 #include <fwk_id.h>
11 #include <fwk_macros.h>
12 #include <fwk_module.h>
13 #include <fwk_module_idx.h>
14 
15 #include <stddef.h>
16 #include <stdint.h>
17 
18 enum fake_tcop_pct_idx {
19     FAKE_MOD_TCOP_PCT_0,
20     FAKE_MOD_TCOP_PCT_1,
21     FAKE_MOD_TCOP_PCT_COUNT,
22 };
23 
24 enum fake_tcop_core_config_idx {
25     FAKE_MOD_TCOP_CORE_CFG_0,
26     FAKE_MOD_TCOP_CORE_CFG_1,
27     FAKE_MOD_TCOP_CORE_CFG_COUNT,
28 };
29 
30 enum fake_tcop_domain_idx {
31     FAKE_MOD_TCOP_DOM_0,
32     FAKE_MOD_TCOP_DOM_1,
33     FAKE_MOD_TCOP_DOM_COUNT,
34 };
35 
36 enum fake_tcop_element_idx {
37     FAKE_MOD_TCOP_ELEM_0,
38     FAKE_MOD_TCOP_ELEM_1,
39     FAKE_MOD_TCOP_ELEM_COUNT,
40 };
41 
42 static struct mod_tcop_pct_table fake_pct_table[FAKE_MOD_TCOP_PCT_COUNT] = {
43     [FAKE_MOD_TCOP_PCT_0] = {
44         .cores_online = 2,
45         .perf_limit = 1001 * 1000000UL,
46     },
47     [FAKE_MOD_TCOP_PCT_1] = {
48         .cores_online = 1,
49         .perf_limit = 1002 * 1000000UL,
50     },
51 };
52 
53 static const struct mod_tcop_core_config
54     fake_core_config[FAKE_MOD_TCOP_CORE_CFG_COUNT] = {
55     [FAKE_MOD_TCOP_CORE_CFG_0] = {
56         .pd_id = FWK_ID_ELEMENT_INIT(FWK_MODULE_IDX_POWER_DOMAIN, 0),
57         .core_starts_online = true,
58         },
59     [FAKE_MOD_TCOP_CORE_CFG_1] = {
60         .pd_id = FWK_ID_ELEMENT_INIT(FWK_MODULE_IDX_POWER_DOMAIN, 1),
61         .core_starts_online = false,
62         },
63 };
64 
65 static const struct mod_tcop_domain_config
66     fake_domain_conf[FAKE_MOD_TCOP_DOM_COUNT] = {
67     [FAKE_MOD_TCOP_DOM_0] = {
68         .perf_id = FWK_ID_ELEMENT_INIT(FWK_MODULE_IDX_DVFS, 0),
69         .pct = fake_pct_table,
70         .pct_size = FWK_ARRAY_SIZE(fake_pct_table),
71         .core_config = fake_core_config,
72     },
73     [FAKE_MOD_TCOP_DOM_1] = { { 0 } },
74 };
75 
76 static const struct fwk_element element_table[FAKE_MOD_TCOP_ELEM_COUNT] = {
77     [FAKE_MOD_TCOP_ELEM_0] = {
78         .name = "ELEM-0",
79         .sub_element_count = 2,
80         .data = fake_domain_conf,
81     },
82     [FAKE_MOD_TCOP_ELEM_1] = { 0 },
83 };
84 
tcop_get_element_table(fwk_id_t module_id)85 static const struct fwk_element *tcop_get_element_table(fwk_id_t module_id)
86 {
87     return element_table;
88 }
89 const struct fwk_module_config config_traffic_cop = {
90     .elements = FWK_MODULE_DYNAMIC_ELEMENTS(tcop_get_element_table),
91 };
92