blob: 56369ae80b7972d5f7523da07bf1e41c1880e6f1 [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
8#include <arch_helpers.h>
9
10void tftf_arch_setup(void)
11{
12 /* Do not try to configure EL2 if TFTF is running at NS-EL1 */
13 if (IS_IN_EL2()) {
Varun Wadekar8900d8c2020-07-10 15:45:39 -070014 /* Enable asynchronous SError aborts to EL2 */
15 enable_serror();
16
Sandrine Bailleuxdddec6b2018-12-18 15:45:01 +010017 /*
18 * Route physical interrupts to EL2 regardless of the value of
19 * the IMO/FMO bits. Without this, interrupts would not be taken
20 * and would remain pending, regardless of the PSTATE.{A, I, F}
21 * interrupt masks.
22 */
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +020023 write_hcr_el2(HCR_TGE_BIT);
Ambroise Vincentfae77722019-03-07 10:17:15 +000024
25 /*
26 * Disable trap of SVE instructions to EL2.
27 * The fields of the CPTR_EL2 register reset to an
28 * architecturally UNKNOWN value.
29 */
30 write_cptr_el2(CPTR_EL2_RES1);
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +020031 isb();
32 }
33}