1 /*
2 * Arm SCP/MCP Software
3 * Copyright (c) 2021-2022, Arm Limited and Contributors. All rights reserved.
4 *
5 * SPDX-License-Identifier: BSD-3-Clause
6 */
7
8 #include <morello_scp_scmi.h>
9
10 #include <internal/scmi.h>
11
12 #include <mod_scmi.h>
13 #include <mod_transport.h>
14
15 #include <fwk_element.h>
16 #include <fwk_id.h>
17 #include <fwk_macros.h>
18 #include <fwk_module.h>
19 #include <fwk_module_idx.h>
20
21 static const struct fwk_element
22 service_table[SCP_MORELLO_SCMI_SERVICE_IDX_COUNT + 1] = {
23 [SCP_MORELLO_SCMI_SERVICE_IDX_PSCI] = {
24 .name = "PSCI",
25 .data = &((struct mod_scmi_service_config) {
26 .transport_id = FWK_ID_ELEMENT_INIT(
27 FWK_MODULE_IDX_TRANSPORT,
28 SCP_MORELLO_SCMI_SERVICE_IDX_PSCI),
29 .transport_api_id = FWK_ID_API_INIT(
30 FWK_MODULE_IDX_TRANSPORT,
31 MOD_TRANSPORT_API_IDX_SCMI_TO_TRANSPORT),
32 .transport_notification_init_id = FWK_ID_NOTIFICATION_INIT(
33 FWK_MODULE_IDX_TRANSPORT,
34 MOD_TRANSPORT_NOTIFICATION_IDX_INITIALIZED),
35 .scmi_agent_id = SCP_SCMI_AGENT_ID_PSCI,
36 .scmi_p2a_id = FWK_ID_NONE_INIT,
37 }),
38 },
39 [SCP_MORELLO_SCMI_SERVICE_IDX_OSPM] = {
40 .name = "OSPM",
41 .data = &((struct mod_scmi_service_config) {
42 .transport_id = FWK_ID_ELEMENT_INIT(
43 FWK_MODULE_IDX_TRANSPORT,
44 SCP_MORELLO_SCMI_SERVICE_IDX_OSPM),
45 .transport_api_id = FWK_ID_API_INIT(
46 FWK_MODULE_IDX_TRANSPORT,
47 MOD_TRANSPORT_API_IDX_SCMI_TO_TRANSPORT),
48 .transport_notification_init_id = FWK_ID_NOTIFICATION_INIT(
49 FWK_MODULE_IDX_TRANSPORT,
50 MOD_TRANSPORT_NOTIFICATION_IDX_INITIALIZED),
51 .scmi_agent_id = SCP_SCMI_AGENT_ID_OSPM,
52 .scmi_p2a_id = FWK_ID_NONE_INIT,
53 }),
54 },
55 [SCP_MORELLO_SCMI_SERVICE_IDX_MCP] = {
56 .name = "MCP",
57 .data = &((struct mod_scmi_service_config) {
58 .transport_id = FWK_ID_ELEMENT_INIT(
59 FWK_MODULE_IDX_TRANSPORT,
60 SCP_MORELLO_SCMI_SERVICE_IDX_MCP),
61 .transport_api_id = FWK_ID_API_INIT(
62 FWK_MODULE_IDX_TRANSPORT,
63 MOD_TRANSPORT_API_IDX_SCMI_TO_TRANSPORT),
64 .transport_notification_init_id = FWK_ID_NONE_INIT,
65 .scmi_agent_id = SCP_SCMI_AGENT_ID_MCP,
66 .scmi_p2a_id = FWK_ID_NONE_INIT,
67 }),
68 },
69 [SCP_MORELLO_SCMI_SERVICE_IDX_COUNT] = { 0 }
70 };
71
get_service_table(fwk_id_t module_id)72 static const struct fwk_element *get_service_table(fwk_id_t module_id)
73 {
74 return service_table;
75 }
76
77 static struct mod_scmi_agent agent_table[] = {
78 [SCP_SCMI_AGENT_ID_OSPM] = {
79 .type = SCMI_AGENT_TYPE_OSPM,
80 .name = "OSPM",
81 },
82 [SCP_SCMI_AGENT_ID_PSCI] = {
83 .type = SCMI_AGENT_TYPE_PSCI,
84 .name = "PSCI",
85 },
86 [SCP_SCMI_AGENT_ID_MCP] = {
87 .type = SCMI_AGENT_TYPE_MANAGEMENT,
88 .name = "MANAGEMENT",
89 },
90 };
91
92 const struct fwk_module_config config_scmi = {
93 .elements = FWK_MODULE_DYNAMIC_ELEMENTS(get_service_table),
94 .data = &((struct mod_scmi_config){
95 .protocol_count_max = 8,
96 .agent_count = FWK_ARRAY_SIZE(agent_table) - 1,
97 .agent_table = agent_table,
98 .vendor_identifier = "arm",
99 .sub_vendor_identifier = "arm",
100 }),
101 };
102