1 /*
2 * Renesas SCP/MCP Software
3 * Copyright (c) 2020-2022, Renesas Electronics Corporation. All rights
4 * reserved.
5 *
6 * SPDX-License-Identifier: BSD-3-Clause
7 */
8
9 #include <config_power_domain.h>
10 #include <rcar_core.h>
11 #include <rcar_mfismh.h>
12 #include <rcar_scmi.h>
13 #include <software_mmap.h>
14
15 #include <mod_power_domain.h>
16 #include <mod_rcar_pd_sysc.h>
17 #include <mod_transport.h>
18
19 #include <fwk_element.h>
20 #include <fwk_id.h>
21 #include <fwk_module.h>
22 #include <fwk_module_idx.h>
23
24 #include <stdint.h>
25
26 static const struct fwk_element transport_element_table[] = {
27 /* RCAR_SCMI_SERVICE_IDX_PSCI */
28 { .name = "PSCI",
29 .data = &((struct mod_transport_channel_config){
30 .channel_type = MOD_TRANSPORT_CHANNEL_TYPE_COMPLETER,
31 .policies =
32 MOD_TRANSPORT_POLICY_INIT_MAILBOX | MOD_TRANSPORT_POLICY_SECURE,
33 .out_band_mailbox_address = (uintptr_t)SCMI_PAYLOAD_S_A2P_BASE,
34 .out_band_mailbox_size = SCMI_PAYLOAD_SIZE,
35 .driver_id = FWK_ID_SUB_ELEMENT_INIT(
36 FWK_MODULE_IDX_RCAR_MFISMH,
37 RCAR_MFISMH_DEVICE_IDX_S,
38 0),
39 .driver_api_id = FWK_ID_API_INIT(FWK_MODULE_IDX_RCAR_MFISMH, 0),
40 }) },
41 /* RCAR_SCMI_SERVICE_IDX_OSPM */
42 { .name = "OSPM",
43 .data = &((struct mod_transport_channel_config){
44 .channel_type = MOD_TRANSPORT_CHANNEL_TYPE_COMPLETER,
45 .policies = MOD_TRANSPORT_POLICY_INIT_MAILBOX,
46 .out_band_mailbox_address = (uintptr_t)SCMI_PAYLOAD0_NS_A2P_BASE,
47 .out_band_mailbox_size = SCMI_PAYLOAD_SIZE,
48 .driver_id = FWK_ID_SUB_ELEMENT_INIT(
49 FWK_MODULE_IDX_RCAR_MFISMH,
50 RCAR_MFISMH_DEVICE_IDX_NS_1,
51 0),
52 .driver_api_id = FWK_ID_API_INIT(FWK_MODULE_IDX_RCAR_MFISMH, 0),
53 }) },
54 /* RCAR_SCMI_SERVICE_IDX_VMM */
55 { .name = "VMM",
56 .data = &((struct mod_transport_channel_config){
57 .channel_type = MOD_TRANSPORT_CHANNEL_TYPE_COMPLETER,
58 .policies = MOD_TRANSPORT_POLICY_INIT_MAILBOX,
59 .out_band_mailbox_address = (uintptr_t)SCMI_PAYLOAD0_NS_A2P_VMM,
60 .out_band_mailbox_size = SCMI_PAYLOAD_SIZE,
61 .driver_id = FWK_ID_SUB_ELEMENT_INIT(
62 FWK_MODULE_IDX_RCAR_MFISMH,
63 RCAR_MFISMH_DEVICE_IDX_NS_2,
64 0),
65 .driver_api_id = FWK_ID_API_INIT(FWK_MODULE_IDX_RCAR_MFISMH, 0),
66 }) },
67 /* RCAR_SCMI_SERVICE_IDX_VM1 */
68 { .name = "VM1",
69 .data = &((struct mod_transport_channel_config){
70 .channel_type = MOD_TRANSPORT_CHANNEL_TYPE_COMPLETER,
71 .policies = MOD_TRANSPORT_POLICY_INIT_MAILBOX,
72 .out_band_mailbox_address = (uintptr_t)SCMI_PAYLOAD0_NS_A2P_VM1,
73 .out_band_mailbox_size = SCMI_PAYLOAD_SIZE,
74 .driver_id = FWK_ID_SUB_ELEMENT_INIT(
75 FWK_MODULE_IDX_RCAR_MFISMH,
76 RCAR_MFISMH_DEVICE_IDX_NS_3,
77 0),
78 .driver_api_id = FWK_ID_API_INIT(FWK_MODULE_IDX_RCAR_MFISMH, 0),
79 }) },
80 /* RCAR_SCMI_SERVICE_IDX_VM2 */
81 { .name = "VM2",
82 .data = &((struct mod_transport_channel_config){
83 .channel_type = MOD_TRANSPORT_CHANNEL_TYPE_COMPLETER,
84 .policies = MOD_TRANSPORT_POLICY_INIT_MAILBOX,
85 .out_band_mailbox_address = (uintptr_t)SCMI_PAYLOAD0_NS_A2P_VM2,
86 .out_band_mailbox_size = SCMI_PAYLOAD_SIZE,
87 .driver_id = FWK_ID_SUB_ELEMENT_INIT(
88 FWK_MODULE_IDX_RCAR_MFISMH,
89 RCAR_MFISMH_DEVICE_IDX_NS_4,
90 0),
91 .driver_api_id = FWK_ID_API_INIT(FWK_MODULE_IDX_RCAR_MFISMH, 0),
92 }) },
93 [RCAR_SCMI_SERVICE_IDX_COUNT] = { 0 },
94 };
95
transport_get_element_table(fwk_id_t module_id)96 static const struct fwk_element *transport_get_element_table(fwk_id_t module_id)
97 {
98 unsigned int idx;
99 struct mod_transport_channel_config *config;
100
101 for (idx = 0; idx < RCAR_SCMI_SERVICE_IDX_COUNT; idx++) {
102 config =
103 (struct mod_transport_channel_config *)(transport_element_table[idx]
104 .data);
105 config->pd_source_id = (fwk_id_t)FWK_ID_ELEMENT_INIT(
106 FWK_MODULE_IDX_POWER_DOMAIN,
107 CONFIG_POWER_DOMAIN_CHILD_ALWAYS_ON + rcar_core_get_count() +
108 rcar_cluster_get_count());
109 }
110
111 return transport_element_table;
112 }
113
114 struct fwk_module_config config_transport = {
115 .elements = FWK_MODULE_DYNAMIC_ELEMENTS(transport_get_element_table),
116 };
117