blob: 6462c97485df46f92f54460bd800ff2b29bb2435 [file] [log] [blame]
Jeenu Viswambharan2da918c2018-07-31 16:13:33 +01001/*
Boyan Karatotev6468d4a2023-02-16 15:12:45 +00002 * Copyright (c) 2018-2023, Arm Limited and Contributors. All rights reserved.
Jeenu Viswambharan2da918c2018-07-31 16:13:33 +01003 *
4 * SPDX-License-Identifier: BSD-3-Clause
5 */
6
Antonio Nino Diaze0f90632018-12-14 00:18:21 +00007#include <stdbool.h>
8
Jeenu Viswambharan2da918c2018-07-31 16:13:33 +01009#include <arch.h>
Alexei Fedorov19933552020-05-26 13:16:41 +010010#include <arch_features.h>
Jeenu Viswambharan2da918c2018-07-31 16:13:33 +010011#include <arch_helpers.h>
Antonio Nino Diaze0f90632018-12-14 00:18:21 +000012#include <lib/extensions/mpam.h>
Jeenu Viswambharan2da918c2018-07-31 16:13:33 +010013
Boyan Karatotev6468d4a2023-02-16 15:12:45 +000014void mpam_init_el3(void)
Jeenu Viswambharan2da918c2018-07-31 16:13:33 +010015{
Jeenu Viswambharan2da918c2018-07-31 16:13:33 +010016 /*
17 * Enable MPAM, and disable trapping to EL3 when lower ELs access their
18 * own MPAM registers.
19 */
20 write_mpam3_el3(MPAM3_EL3_MPAMEN_BIT);
21
Boyan Karatotev6468d4a2023-02-16 15:12:45 +000022}
23
24/*
25 * If EL2 is implemented but unused, disable trapping to EL2 when lower ELs
26 * access their own MPAM registers.
27 */
28void mpam_init_el2_unused(void)
29{
30 write_mpam2_el2(0ULL);
Jeenu Viswambharan2da918c2018-07-31 16:13:33 +010031
Boyan Karatotev6468d4a2023-02-16 15:12:45 +000032 if ((read_mpamidr_el1() & MPAMIDR_HAS_HCR_BIT) != 0U) {
33 write_mpamhcr_el2(0ULL);
Jeenu Viswambharan2da918c2018-07-31 16:13:33 +010034 }
Boyan Karatotev6468d4a2023-02-16 15:12:45 +000035
Jeenu Viswambharan2da918c2018-07-31 16:13:33 +010036}