xref: /rk3399_ARM-atf/lib/extensions/brbe/brbe.c (revision cf9346cb83804feb083b56a668eb0a462983e038)
1 /*
2  * Copyright (c) 2022, Arm Limited. All rights reserved.
3  *
4  * SPDX-License-Identifier: BSD-3-Clause
5  */
6 
7 #include <arch.h>
8 #include <arch_features.h>
9 #include <arch_helpers.h>
10 
11 void brbe_enable(void)
12 {
13 	uint64_t val;
14 
15 	if (is_feat_brbe_present()) {
16 		/*
17 		 * MDCR_EL3.SBRBE = 0b01
18 		 *
19 		 * Allows BRBE usage in non-secure world and prohibited in
20 		 * secure world.
21 		 */
22 		val = read_mdcr_el3();
23 		val &= ~(MDCR_SBRBE_MASK << MDCR_SBRBE_SHIFT);
24 		val |= (0x1UL << MDCR_SBRBE_SHIFT);
25 		write_mdcr_el3(val);
26 	}
27 }
28