1 /*
2  * Copyright (c) 2020-2021, ARM Limited and Contributors. All rights reserved.
3  *
4  * SPDX-License-Identifier: BSD-3-Clause
5  */
6 
7 #include <assert.h>
8 
9 #include <libfdt.h>
10 #include <tc_plat.h>
11 
12 #include <common/bl_common.h>
13 #include <common/debug.h>
14 #include <drivers/arm/css/css_mhu_doorbell.h>
15 #include <drivers/arm/css/scmi.h>
16 #include <lib/fconf/fconf.h>
17 #include <lib/fconf/fconf_dyn_cfg_getter.h>
18 #include <plat/arm/common/plat_arm.h>
19 #include <plat/common/platform.h>
20 
21 static scmi_channel_plat_info_t tc_scmi_plat_info[] = {
22 	{
23 		.scmi_mbx_mem = CSS_SCMI_PAYLOAD_BASE,
24 		.db_reg_addr = PLAT_CSS_MHU_BASE + SENDER_REG_SET(0),
25 		.db_preserve_mask = 0xfffffffe,
26 		.db_modify_mask = 0x1,
27 		.ring_doorbell = &mhuv2_ring_doorbell,
28 	}
29 };
30 
bl31_platform_setup(void)31 void bl31_platform_setup(void)
32 {
33 	tc_bl31_common_platform_setup();
34 }
35 
plat_css_get_scmi_info(int channel_id)36 scmi_channel_plat_info_t *plat_css_get_scmi_info(int channel_id)
37 {
38 
39 	return &tc_scmi_plat_info[channel_id];
40 
41 }
42 
bl31_early_platform_setup2(u_register_t arg0,u_register_t arg1,u_register_t arg2,u_register_t arg3)43 void bl31_early_platform_setup2(u_register_t arg0, u_register_t arg1,
44 				u_register_t arg2, u_register_t arg3)
45 {
46 	arm_bl31_early_platform_setup((void *)arg0, arg1, arg2, (void *)arg3);
47 
48 	/* Fill the properties struct with the info from the config dtb */
49 	fconf_populate("FW_CONFIG", arg1);
50 }
51 
tc_bl31_common_platform_setup(void)52 void tc_bl31_common_platform_setup(void)
53 {
54 	arm_bl31_platform_setup();
55 }
56 
plat_arm_psci_override_pm_ops(plat_psci_ops_t * ops)57 const plat_psci_ops_t *plat_arm_psci_override_pm_ops(plat_psci_ops_t *ops)
58 {
59 	return css_scmi_override_pm_ops(ops);
60 }
61 
bl31_plat_arch_setup(void)62 void __init bl31_plat_arch_setup(void)
63 {
64 	arm_bl31_plat_arch_setup();
65 
66 	/* HW_CONFIG was also loaded by BL2 */
67 	const struct dyn_cfg_dtb_info_t *hw_config_info;
68 
69 	hw_config_info = FCONF_GET_PROPERTY(dyn_cfg, dtb, HW_CONFIG_ID);
70 	assert(hw_config_info != NULL);
71 
72 	fconf_populate("HW_CONFIG", hw_config_info->config_addr);
73 }
74