blob: 051067865613b2a206a75a45c2c8f8912cffc0a4 [file] [log] [blame]
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +02001/*
Ambroise Vincentfae77722019-03-07 10:17:15 +00002 * Copyright (c) 2018-2019, Arm Limited. All rights reserved.
Varun Wadekar8900d8c2020-07-10 15:45:39 -07003 * Copyright (c) 2020, NVIDIA Corporation. All rights reserved.
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +02004 *
5 * SPDX-License-Identifier: BSD-3-Clause
6 */
7
Arunachalam Ganapathy92f18682023-09-02 01:41:28 +01008#include <arch_features.h>
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +02009#include <arch_helpers.h>
10
11void tftf_arch_setup(void)
12{
13 /* Do not try to configure EL2 if TFTF is running at NS-EL1 */
14 if (IS_IN_EL2()) {
Varun Wadekar8900d8c2020-07-10 15:45:39 -070015 /* Enable asynchronous SError aborts to EL2 */
16 enable_serror();
17
Sandrine Bailleuxdddec6b2018-12-18 15:45:01 +010018 /*
19 * Route physical interrupts to EL2 regardless of the value of
20 * the IMO/FMO bits. Without this, interrupts would not be taken
21 * and would remain pending, regardless of the PSTATE.{A, I, F}
22 * interrupt masks.
23 */
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +020024 write_hcr_el2(HCR_TGE_BIT);
Ambroise Vincentfae77722019-03-07 10:17:15 +000025
26 /*
Arunachalam Ganapathy92f18682023-09-02 01:41:28 +010027 * Disable trap of SVE, SME instructions to EL2.
Ambroise Vincentfae77722019-03-07 10:17:15 +000028 * The fields of the CPTR_EL2 register reset to an
29 * architecturally UNKNOWN value.
30 */
Arunachalam Ganapathy92f18682023-09-02 01:41:28 +010031 write_cptr_el2(CPTR_EL2_RESET_VAL);
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +020032 isb();
Arunachalam Ganapathy92f18682023-09-02 01:41:28 +010033
34 /*
35 * Enable access to ZT0 storage when FEAT_SME2 is implemented
36 * and enable FA64 when FEAT_SME_FA64 is implemented
37 */
38 if (is_feat_sme_supported()) {
39 write_smcr_el2(SMCR_EL2_RESET_VAL);
40 isb();
41 }
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +020042 }
43}