1 /*
2  * Arm SCP/MCP Software
3  * Copyright (c) 2020-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 "platform_core.h"
10 #include "platform_scmi.h"
11 #include "scp_platform_mhu.h"
12 #include "scp_software_mmap.h"
13 
14 #include <mod_transport.h>
15 
16 #include <fwk_element.h>
17 #include <fwk_id.h>
18 #include <fwk_module.h>
19 #include <fwk_module_idx.h>
20 
21 #include <stdint.h>
22 
23 static const struct fwk_element transport_element_table[] = {
24     /* SCP_PLATFORM_SCMI_SERVICE_IDX_PSCI */
25     { .name = "PSCI",
26       .data = &((struct mod_transport_channel_config){
27           .channel_type = MOD_TRANSPORT_CHANNEL_TYPE_COMPLETER,
28           .policies =
29               MOD_TRANSPORT_POLICY_INIT_MAILBOX | MOD_TRANSPORT_POLICY_SECURE,
30           .out_band_mailbox_address = (uintptr_t)SCP_SCMI_PAYLOAD_S_A2P_BASE,
31           .out_band_mailbox_size = SCP_SCMI_PAYLOAD_SIZE,
32           .driver_id = FWK_ID_SUB_ELEMENT_INIT(
33               FWK_MODULE_IDX_MHU2,
34               SCP_PLATFORM_MHU_DEVICE_IDX_SCP_AP_S_CLUS0,
35               0),
36           .driver_api_id = FWK_ID_API_INIT(FWK_MODULE_IDX_MHU2, 0),
37       }) },
38     [SCP_PLATFORM_SCMI_SERVICE_IDX_COUNT] = { 0 },
39 };
40 
transport_get_element_table(fwk_id_t module_id)41 static const struct fwk_element *transport_get_element_table(fwk_id_t module_id)
42 {
43     unsigned int idx;
44     struct mod_transport_channel_config *config;
45 
46     for (idx = 0; idx < SCP_PLATFORM_SCMI_SERVICE_IDX_COUNT; idx++) {
47         config =
48             (struct mod_transport_channel_config *)(transport_element_table[idx]
49                                                         .data);
50         config->pd_source_id = FWK_ID_ELEMENT(
51             FWK_MODULE_IDX_POWER_DOMAIN,
52             platform_core_get_core_count() + platform_core_get_cluster_count() +
53                 PD_STATIC_DEV_IDX_SYSTOP);
54     }
55 
56     return transport_element_table;
57 }
58 
59 const struct fwk_module_config config_transport = {
60     .elements = FWK_MODULE_DYNAMIC_ELEMENTS(transport_get_element_table),
61 };
62