blob: 33e460140818dce373a149e9cb11fcbf6a8a19bd [file] [log] [blame]
Usama Ariff5c58af2020-04-17 16:13:39 +01001/*
laurenw-arm9b266552023-05-03 12:48:55 -05002 * Copyright (c) 2020-2023, Arm Limited and Contributors. All rights reserved.
Usama Ariff5c58af2020-04-17 16:13:39 +01003 *
4 * SPDX-License-Identifier: BSD-3-Clause
5 */
6
7#include <assert.h>
8
9#include <libfdt.h>
Usama Arif6ec0c652021-04-09 17:07:41 +010010#include <tc_plat.h>
Usama Ariff5c58af2020-04-17 16:13:39 +010011
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>
Usama Arif34a87d72021-08-17 17:57:10 +010016#include <lib/fconf/fconf.h>
17#include <lib/fconf/fconf_dyn_cfg_getter.h>
Usama Ariff5c58af2020-04-17 16:13:39 +010018#include <plat/arm/common/plat_arm.h>
19#include <plat/common/platform.h>
20
Usama Arif6ec0c652021-04-09 17:07:41 +010021static scmi_channel_plat_info_t tc_scmi_plat_info[] = {
Usama Ariff5c58af2020-04-17 16:13:39 +010022 {
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
31void bl31_platform_setup(void)
32{
Usama Arif6ec0c652021-04-09 17:07:41 +010033 tc_bl31_common_platform_setup();
Usama Ariff5c58af2020-04-17 16:13:39 +010034}
35
Tony K Nadackalf0f2c902022-12-07 20:44:05 +000036scmi_channel_plat_info_t *plat_css_get_scmi_info(unsigned int channel_id)
Usama Ariff5c58af2020-04-17 16:13:39 +010037{
38
Usama Arif6ec0c652021-04-09 17:07:41 +010039 return &tc_scmi_plat_info[channel_id];
Usama Ariff5c58af2020-04-17 16:13:39 +010040
41}
42
43void 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);
Usama Arif34a87d72021-08-17 17:57:10 +010047
48 /* Fill the properties struct with the info from the config dtb */
49 fconf_populate("FW_CONFIG", arg1);
Usama Ariff5c58af2020-04-17 16:13:39 +010050}
51
laurenw-arm6fbe11c2023-05-04 14:55:37 -050052#ifdef PLATFORM_TESTS
Sandrine Bailleux4eefbf12023-05-05 15:44:26 +020053static __dead2 void tc_run_platform_tests(void)
54{
Sandrine Bailleux303ef332023-05-05 15:59:00 +020055 int tests_failed;
56
57 printf("\nStarting platform tests...\n");
58
Tamas Ban657b90e2023-04-21 09:31:48 +020059#ifdef PLATFORM_TEST_NV_COUNTERS
Sandrine Bailleux303ef332023-05-05 15:59:00 +020060 tests_failed = nv_counter_test();
Tamas Ban657b90e2023-04-21 09:31:48 +020061#elif PLATFORM_TEST_TFM_TESTSUITE
Sandrine Bailleux303ef332023-05-05 15:59:00 +020062 tests_failed = run_platform_tests();
laurenw-arm1b076112023-02-07 13:40:05 -060063#endif
Sandrine Bailleux303ef332023-05-05 15:59:00 +020064
65 printf("Platform tests %s.\n",
66 (tests_failed != 0) ? "failed" : "succeeded");
67
Sandrine Bailleux57cc12c2023-05-05 13:59:07 +020068 /* Suspend booting, no matter the tests outcome. */
Sandrine Bailleux303ef332023-05-05 15:59:00 +020069 printf("Suspend booting...\n");
Mate Toth-Pal25dd2172022-10-21 14:24:49 +020070 plat_error_handler(-1);
Sandrine Bailleux4eefbf12023-05-05 15:44:26 +020071}
72#endif
73
74void tc_bl31_common_platform_setup(void)
75{
76 arm_bl31_platform_setup();
77
78#ifdef PLATFORM_TESTS
79 tc_run_platform_tests();
laurenw-arm9b266552023-05-03 12:48:55 -050080#endif
Usama Ariff5c58af2020-04-17 16:13:39 +010081}
82
83const plat_psci_ops_t *plat_arm_psci_override_pm_ops(plat_psci_ops_t *ops)
84{
85 return css_scmi_override_pm_ops(ops);
86}
Usama Arif34a87d72021-08-17 17:57:10 +010087
88void __init bl31_plat_arch_setup(void)
89{
90 arm_bl31_plat_arch_setup();
91
92 /* HW_CONFIG was also loaded by BL2 */
93 const struct dyn_cfg_dtb_info_t *hw_config_info;
94
95 hw_config_info = FCONF_GET_PROPERTY(dyn_cfg, dtb, HW_CONFIG_ID);
96 assert(hw_config_info != NULL);
97
98 fconf_populate("HW_CONFIG", hw_config_info->config_addr);
99}