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