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 "config_power_domain.h"
9 #include "n1sdp_core.h"
10 #include "n1sdp_scp_mhu.h"
11 #include "n1sdp_scp_mmap.h"
12 #include "n1sdp_scp_scmi.h"
13 #include "n1sdp_scp_software_mmap.h"
14
15 #include <mod_transport.h>
16
17 #include <fwk_element.h>
18 #include <fwk_id.h>
19 #include <fwk_module.h>
20 #include <fwk_module_idx.h>
21
22 static const struct fwk_element transport_element_table[] = {
23 /* SCP_N1SDP_SCMI_SERVICE_IDX_PSCI */
24 { .name = "PSCI",
25 .data = &((struct mod_transport_channel_config){
26 .channel_type = MOD_TRANSPORT_CHANNEL_TYPE_COMPLETER,
27 .policies =
28 MOD_TRANSPORT_POLICY_INIT_MAILBOX | MOD_TRANSPORT_POLICY_SECURE,
29 .out_band_mailbox_address = SCP_AP_SHARED_SECURE_RAM,
30 .out_band_mailbox_size = SCP_SCMI_PAYLOAD_SIZE,
31 .driver_id = FWK_ID_SUB_ELEMENT_INIT(
32 FWK_MODULE_IDX_MHU,
33 N1SDP_MHU_DEVICE_IDX_S_CLUS0,
34 0),
35 .driver_api_id = FWK_ID_API_INIT(FWK_MODULE_IDX_MHU, 0),
36 }) },
37 /* SCP_N1SDP_SCMI_SERVICE_IDX_OSPM */
38 { .name = "OSPM",
39 .data = &((struct mod_transport_channel_config){
40 .channel_type = MOD_TRANSPORT_CHANNEL_TYPE_COMPLETER,
41 .policies = MOD_TRANSPORT_POLICY_INIT_MAILBOX,
42 .out_band_mailbox_address = SCP_AP_SHARED_NONSECURE_RAM,
43 .out_band_mailbox_size = SCP_SCMI_PAYLOAD_SIZE,
44 .driver_id = FWK_ID_SUB_ELEMENT_INIT(
45 FWK_MODULE_IDX_MHU,
46 N1SDP_MHU_DEVICE_IDX_NS_CLUS0,
47 0),
48 .driver_api_id = FWK_ID_API_INIT(FWK_MODULE_IDX_MHU, 0),
49 }) },
50 /* SCP_N1SDP_SCMI_SERVICE_IDX_MCP */
51 { .name = "MCP",
52 .data = &((struct mod_transport_channel_config){
53 .channel_type = MOD_TRANSPORT_CHANNEL_TYPE_COMPLETER,
54 .policies = MOD_TRANSPORT_POLICY_SECURE,
55 .out_band_mailbox_address = SCP_MCP_SHARED_SECURE_RAM,
56 .out_band_mailbox_size = SCP_SCMI_PAYLOAD_SIZE,
57 .driver_id = FWK_ID_SUB_ELEMENT_INIT(
58 FWK_MODULE_IDX_MHU,
59 N1SDP_MHU_DEVICE_IDX_S_MCP,
60 0),
61 .driver_api_id = FWK_ID_API_INIT(FWK_MODULE_IDX_MHU, 0),
62 }) },
63 [SCP_N1SDP_SCMI_SERVICE_IDX_COUNT] = { 0 },
64 };
65
transport_get_element_table(fwk_id_t module_id)66 static const struct fwk_element *transport_get_element_table(fwk_id_t module_id)
67 {
68 unsigned int idx;
69 struct mod_transport_channel_config *config;
70
71 for (idx = 0; idx < SCP_N1SDP_SCMI_SERVICE_IDX_COUNT; idx++) {
72 config =
73 (struct mod_transport_channel_config *)(transport_element_table[idx]
74 .data);
75 if (n1sdp_is_multichip_enabled() && (n1sdp_get_chipid() == 0x0)) {
76 config->pd_source_id = FWK_ID_ELEMENT(
77 FWK_MODULE_IDX_POWER_DOMAIN, PD_MULTI_CHIP_IDX_SYSTOP0);
78 } else {
79 config->pd_source_id = FWK_ID_ELEMENT(
80 FWK_MODULE_IDX_POWER_DOMAIN, PD_SINGLE_CHIP_IDX_SYSTOP0);
81 }
82 }
83
84 return transport_element_table;
85 }
86
87 const struct fwk_module_config config_transport = {
88 .elements = FWK_MODULE_DYNAMIC_ELEMENTS(transport_get_element_table),
89 };
90