blob: be37006636c4134e8ab9d8fd674dd0361f75feb0 [file] [log] [blame]
Dimitris Papastamosef69e1e2017-10-17 14:03:14 +01001/*
2 * Copyright (c) 2017, ARM Limited and Contributors. All rights reserved.
3 *
4 * SPDX-License-Identifier: BSD-3-Clause
5 */
6
7#include <amu.h>
8#include <arch.h>
9#include <arch_helpers.h>
Dimitris Papastamos0767d502017-11-13 09:49:45 +000010#include <debug.h>
Dimitris Papastamosef69e1e2017-10-17 14:03:14 +010011
12void amu_enable(int el2_unused)
13{
14 uint64_t features;
15
16 features = read_id_pfr0() >> ID_PFR0_AMU_SHIFT;
Dimitris Papastamos0767d502017-11-13 09:49:45 +000017 if ((features & ID_PFR0_AMU_MASK) != 1) {
18 WARN("Cannot enable AMU - not supported\n");
19 return;
Dimitris Papastamosef69e1e2017-10-17 14:03:14 +010020 }
Dimitris Papastamos0767d502017-11-13 09:49:45 +000021
22 if (el2_unused) {
23 uint64_t v;
24
25 /*
26 * Non-secure access from EL0 or EL1 to the Activity Monitor
27 * registers do not trap to EL2.
28 */
29 v = read_hcptr();
30 v &= ~TAM_BIT;
31 write_hcptr(v);
32 }
33
34 /* Enable group 0 counters */
35 write_amcntenset0(AMU_GROUP0_COUNTERS_MASK);
Dimitris Papastamosef69e1e2017-10-17 14:03:14 +010036}