Usama Arif | bec5afd | 2020-04-17 16:13:39 +0100 | [diff] [blame] | 1 | /* |
laurenw-arm | 481ac28 | 2023-05-03 12:48:55 -0500 | [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> |
Madhukar Pappireddy | e108df2 | 2023-03-22 15:40:40 -0500 | [diff] [blame] | 16 | #include <drivers/arm/sbsa.h> |
Usama Arif | a49bd49 | 2021-08-17 17:57:10 +0100 | [diff] [blame] | 17 | #include <lib/fconf/fconf.h> |
| 18 | #include <lib/fconf/fconf_dyn_cfg_getter.h> |
Usama Arif | bec5afd | 2020-04-17 16:13:39 +0100 | [diff] [blame] | 19 | #include <plat/arm/common/plat_arm.h> |
| 20 | #include <plat/common/platform.h> |
| 21 | |
Usama Arif | f151362 | 2021-04-09 17:07:41 +0100 | [diff] [blame] | 22 | static scmi_channel_plat_info_t tc_scmi_plat_info[] = { |
Usama Arif | bec5afd | 2020-04-17 16:13:39 +0100 | [diff] [blame] | 23 | { |
| 24 | .scmi_mbx_mem = CSS_SCMI_PAYLOAD_BASE, |
| 25 | .db_reg_addr = PLAT_CSS_MHU_BASE + SENDER_REG_SET(0), |
| 26 | .db_preserve_mask = 0xfffffffe, |
| 27 | .db_modify_mask = 0x1, |
| 28 | .ring_doorbell = &mhuv2_ring_doorbell, |
| 29 | } |
| 30 | }; |
| 31 | |
| 32 | void bl31_platform_setup(void) |
| 33 | { |
Usama Arif | f151362 | 2021-04-09 17:07:41 +0100 | [diff] [blame] | 34 | tc_bl31_common_platform_setup(); |
Usama Arif | bec5afd | 2020-04-17 16:13:39 +0100 | [diff] [blame] | 35 | } |
| 36 | |
Tony K Nadackal | 1b116a8 | 2022-12-07 20:44:05 +0000 | [diff] [blame] | 37 | 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] | 38 | { |
| 39 | |
Usama Arif | f151362 | 2021-04-09 17:07:41 +0100 | [diff] [blame] | 40 | return &tc_scmi_plat_info[channel_id]; |
Usama Arif | bec5afd | 2020-04-17 16:13:39 +0100 | [diff] [blame] | 41 | |
| 42 | } |
| 43 | |
| 44 | void bl31_early_platform_setup2(u_register_t arg0, u_register_t arg1, |
| 45 | u_register_t arg2, u_register_t arg3) |
| 46 | { |
| 47 | arm_bl31_early_platform_setup((void *)arg0, arg1, arg2, (void *)arg3); |
Usama Arif | a49bd49 | 2021-08-17 17:57:10 +0100 | [diff] [blame] | 48 | |
| 49 | /* Fill the properties struct with the info from the config dtb */ |
| 50 | fconf_populate("FW_CONFIG", arg1); |
Usama Arif | bec5afd | 2020-04-17 16:13:39 +0100 | [diff] [blame] | 51 | } |
| 52 | |
laurenw-arm | 4c4181c | 2023-05-04 14:55:37 -0500 | [diff] [blame] | 53 | #ifdef PLATFORM_TESTS |
Sandrine Bailleux | 27fba52 | 2023-05-05 15:44:26 +0200 | [diff] [blame] | 54 | static __dead2 void tc_run_platform_tests(void) |
Usama Arif | bec5afd | 2020-04-17 16:13:39 +0100 | [diff] [blame] | 55 | { |
Sandrine Bailleux | f0f42fb | 2023-05-05 15:59:00 +0200 | [diff] [blame] | 56 | int tests_failed; |
| 57 | |
| 58 | printf("\nStarting platform tests...\n"); |
Mate Toth-Pal | 14ba4af | 2022-10-21 14:24:49 +0200 | [diff] [blame] | 59 | |
Tamas Ban | 15b79da | 2023-04-21 09:31:48 +0200 | [diff] [blame] | 60 | #ifdef PLATFORM_TEST_NV_COUNTERS |
Sandrine Bailleux | f0f42fb | 2023-05-05 15:59:00 +0200 | [diff] [blame] | 61 | tests_failed = nv_counter_test(); |
laurenw-arm | 116f10c | 2023-06-13 16:43:39 -0500 | [diff] [blame] | 62 | #elif PLATFORM_TEST_ROTPK |
| 63 | tests_failed = rotpk_test(); |
Tamas Ban | 15b79da | 2023-04-21 09:31:48 +0200 | [diff] [blame] | 64 | #elif PLATFORM_TEST_TFM_TESTSUITE |
Sandrine Bailleux | f0f42fb | 2023-05-05 15:59:00 +0200 | [diff] [blame] | 65 | tests_failed = run_platform_tests(); |
laurenw-arm | 2ce1e35 | 2023-02-07 13:40:05 -0600 | [diff] [blame] | 66 | #endif |
Sandrine Bailleux | f0f42fb | 2023-05-05 15:59:00 +0200 | [diff] [blame] | 67 | |
| 68 | printf("Platform tests %s.\n", |
| 69 | (tests_failed != 0) ? "failed" : "succeeded"); |
| 70 | |
Sandrine Bailleux | e1da6c4 | 2023-05-05 13:59:07 +0200 | [diff] [blame] | 71 | /* Suspend booting, no matter the tests outcome. */ |
Sandrine Bailleux | f0f42fb | 2023-05-05 15:59:00 +0200 | [diff] [blame] | 72 | printf("Suspend booting...\n"); |
Mate Toth-Pal | 14ba4af | 2022-10-21 14:24:49 +0200 | [diff] [blame] | 73 | plat_error_handler(-1); |
Sandrine Bailleux | 27fba52 | 2023-05-05 15:44:26 +0200 | [diff] [blame] | 74 | } |
| 75 | #endif |
| 76 | |
| 77 | void tc_bl31_common_platform_setup(void) |
| 78 | { |
| 79 | arm_bl31_platform_setup(); |
| 80 | |
| 81 | #ifdef PLATFORM_TESTS |
| 82 | tc_run_platform_tests(); |
laurenw-arm | 481ac28 | 2023-05-03 12:48:55 -0500 | [diff] [blame] | 83 | #endif |
Usama Arif | bec5afd | 2020-04-17 16:13:39 +0100 | [diff] [blame] | 84 | } |
| 85 | |
| 86 | const plat_psci_ops_t *plat_arm_psci_override_pm_ops(plat_psci_ops_t *ops) |
| 87 | { |
| 88 | return css_scmi_override_pm_ops(ops); |
| 89 | } |
Usama Arif | a49bd49 | 2021-08-17 17:57:10 +0100 | [diff] [blame] | 90 | |
| 91 | void __init bl31_plat_arch_setup(void) |
| 92 | { |
| 93 | arm_bl31_plat_arch_setup(); |
| 94 | |
| 95 | /* HW_CONFIG was also loaded by BL2 */ |
| 96 | const struct dyn_cfg_dtb_info_t *hw_config_info; |
| 97 | |
| 98 | hw_config_info = FCONF_GET_PROPERTY(dyn_cfg, dtb, HW_CONFIG_ID); |
| 99 | assert(hw_config_info != NULL); |
| 100 | |
| 101 | fconf_populate("HW_CONFIG", hw_config_info->config_addr); |
| 102 | } |
Madhukar Pappireddy | e108df2 | 2023-03-22 15:40:40 -0500 | [diff] [blame] | 103 | |
Govindraj Raja | 436ea5e | 2023-05-10 14:50:36 -0500 | [diff] [blame] | 104 | #if defined(SPD_spmd) && (SPMC_AT_EL3 == 0) |
Madhukar Pappireddy | e108df2 | 2023-03-22 15:40:40 -0500 | [diff] [blame] | 105 | void tc_bl31_plat_runtime_setup(void) |
| 106 | { |
| 107 | arm_bl31_plat_runtime_setup(); |
| 108 | |
| 109 | /* Start secure watchdog timer. */ |
| 110 | plat_arm_secure_wdt_start(); |
| 111 | } |
| 112 | |
| 113 | void bl31_plat_runtime_setup(void) |
| 114 | { |
| 115 | tc_bl31_plat_runtime_setup(); |
| 116 | } |
| 117 | |
| 118 | /* |
| 119 | * Platform handler for Group0 secure interrupt. |
| 120 | */ |
| 121 | int plat_spmd_handle_group0_interrupt(uint32_t intid) |
| 122 | { |
| 123 | /* Trusted Watchdog timer is the only source of Group0 interrupt now. */ |
| 124 | if (intid == SBSA_SECURE_WDOG_INTID) { |
Madhukar Pappireddy | e108df2 | 2023-03-22 15:40:40 -0500 | [diff] [blame] | 125 | /* Refresh the timer. */ |
| 126 | plat_arm_secure_wdt_refresh(); |
| 127 | |
Madhukar Pappireddy | e108df2 | 2023-03-22 15:40:40 -0500 | [diff] [blame] | 128 | return 0; |
| 129 | } |
| 130 | |
| 131 | return -1; |
| 132 | } |
Govindraj Raja | 436ea5e | 2023-05-10 14:50:36 -0500 | [diff] [blame] | 133 | #endif /*defined(SPD_spmd) && (SPMC_AT_EL3 == 0)*/ |