Usama Arif | bec5afd | 2020-04-17 16:13:39 +0100 | [diff] [blame] | 1 | /* |
laurenw-arm | 2ce1e35 | 2023-02-07 13:40:05 -0600 | [diff] [blame] | 2 | * Copyright (c) 2020-2023, ARM Limited and Contributors. All rights reserved. |
Usama Arif | bec5afd | 2020-04-17 16:13:39 +0100 | [diff] [blame] | 3 | * |
| 4 | * SPDX-License-Identifier: BSD-3-Clause |
| 5 | */ |
| 6 | |
| 7 | #include <assert.h> |
| 8 | |
| 9 | #include <libfdt.h> |
Usama Arif | f151362 | 2021-04-09 17:07:41 +0100 | [diff] [blame] | 10 | #include <tc_plat.h> |
Usama Arif | bec5afd | 2020-04-17 16:13:39 +0100 | [diff] [blame] | 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> |
Usama Arif | a49bd49 | 2021-08-17 17:57:10 +0100 | [diff] [blame] | 16 | #include <lib/fconf/fconf.h> |
| 17 | #include <lib/fconf/fconf_dyn_cfg_getter.h> |
Usama Arif | bec5afd | 2020-04-17 16:13:39 +0100 | [diff] [blame] | 18 | #include <plat/arm/common/plat_arm.h> |
| 19 | #include <plat/common/platform.h> |
| 20 | |
Usama Arif | f151362 | 2021-04-09 17:07:41 +0100 | [diff] [blame] | 21 | static scmi_channel_plat_info_t tc_scmi_plat_info[] = { |
Usama Arif | bec5afd | 2020-04-17 16:13:39 +0100 | [diff] [blame] | 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 | |
| 31 | void bl31_platform_setup(void) |
| 32 | { |
Usama Arif | f151362 | 2021-04-09 17:07:41 +0100 | [diff] [blame] | 33 | tc_bl31_common_platform_setup(); |
Usama Arif | bec5afd | 2020-04-17 16:13:39 +0100 | [diff] [blame] | 34 | } |
| 35 | |
Tony K Nadackal | 1b116a8 | 2022-12-07 20:44:05 +0000 | [diff] [blame] | 36 | scmi_channel_plat_info_t *plat_css_get_scmi_info(unsigned int channel_id) |
Usama Arif | bec5afd | 2020-04-17 16:13:39 +0100 | [diff] [blame] | 37 | { |
| 38 | |
Usama Arif | f151362 | 2021-04-09 17:07:41 +0100 | [diff] [blame] | 39 | return &tc_scmi_plat_info[channel_id]; |
Usama Arif | bec5afd | 2020-04-17 16:13:39 +0100 | [diff] [blame] | 40 | |
| 41 | } |
| 42 | |
| 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); |
Usama Arif | a49bd49 | 2021-08-17 17:57:10 +0100 | [diff] [blame] | 47 | |
| 48 | /* Fill the properties struct with the info from the config dtb */ |
| 49 | fconf_populate("FW_CONFIG", arg1); |
Usama Arif | bec5afd | 2020-04-17 16:13:39 +0100 | [diff] [blame] | 50 | } |
| 51 | |
Usama Arif | f151362 | 2021-04-09 17:07:41 +0100 | [diff] [blame] | 52 | void tc_bl31_common_platform_setup(void) |
Usama Arif | bec5afd | 2020-04-17 16:13:39 +0100 | [diff] [blame] | 53 | { |
| 54 | arm_bl31_platform_setup(); |
Mate Toth-Pal | 14ba4af | 2022-10-21 14:24:49 +0200 | [diff] [blame] | 55 | |
Tamas Ban | 15b79da | 2023-04-21 09:31:48 +0200 | [diff] [blame^] | 56 | #ifdef PLATFORM_TEST_NV_COUNTERS |
laurenw-arm | 2ce1e35 | 2023-02-07 13:40:05 -0600 | [diff] [blame] | 57 | nv_counter_test(); |
Tamas Ban | 15b79da | 2023-04-21 09:31:48 +0200 | [diff] [blame^] | 58 | #elif PLATFORM_TEST_TFM_TESTSUITE |
| 59 | run_platform_tests(); |
laurenw-arm | 2ce1e35 | 2023-02-07 13:40:05 -0600 | [diff] [blame] | 60 | #endif |
Mate Toth-Pal | 14ba4af | 2022-10-21 14:24:49 +0200 | [diff] [blame] | 61 | /* Suspend booting */ |
| 62 | plat_error_handler(-1); |
Usama Arif | bec5afd | 2020-04-17 16:13:39 +0100 | [diff] [blame] | 63 | } |
| 64 | |
| 65 | const plat_psci_ops_t *plat_arm_psci_override_pm_ops(plat_psci_ops_t *ops) |
| 66 | { |
| 67 | return css_scmi_override_pm_ops(ops); |
| 68 | } |
Usama Arif | a49bd49 | 2021-08-17 17:57:10 +0100 | [diff] [blame] | 69 | |
| 70 | void __init bl31_plat_arch_setup(void) |
| 71 | { |
| 72 | arm_bl31_plat_arch_setup(); |
| 73 | |
| 74 | /* HW_CONFIG was also loaded by BL2 */ |
| 75 | const struct dyn_cfg_dtb_info_t *hw_config_info; |
| 76 | |
| 77 | hw_config_info = FCONF_GET_PROPERTY(dyn_cfg, dtb, HW_CONFIG_ID); |
| 78 | assert(hw_config_info != NULL); |
| 79 | |
| 80 | fconf_populate("HW_CONFIG", hw_config_info->config_addr); |
| 81 | } |