1 /* 2 * Copyright (c) 2017-2018, ARM Limited and Contributors. All rights reserved. 3 * 4 * SPDX-License-Identifier: BSD-3-Clause 5 */ 6 7 #ifndef AMU_H 8 #define AMU_H 9 10 #include <stdbool.h> 11 #include <stdint.h> 12 13 #include <platform_def.h> 14 15 #include <lib/cassert.h> 16 #include <lib/utils_def.h> 17 18 /* All group 0 counters */ 19 #define AMU_GROUP0_COUNTERS_MASK U(0xf) 20 21 #ifdef PLAT_AMU_GROUP1_COUNTERS_MASK 22 #define AMU_GROUP1_COUNTERS_MASK PLAT_AMU_GROUP1_COUNTERS_MASK 23 #else 24 #define AMU_GROUP1_COUNTERS_MASK U(0) 25 #endif 26 27 #ifdef PLAT_AMU_GROUP1_NR_COUNTERS 28 #define AMU_GROUP1_NR_COUNTERS PLAT_AMU_GROUP1_NR_COUNTERS 29 #else 30 #define AMU_GROUP1_NR_COUNTERS U(0) 31 #endif 32 33 CASSERT(AMU_GROUP1_COUNTERS_MASK <= 0xffff, invalid_amu_group1_counters_mask); 34 CASSERT(AMU_GROUP1_NR_COUNTERS <= 16, invalid_amu_group1_nr_counters); 35 36 bool amu_supported(void); 37 void amu_enable(bool el2_unused); 38 39 /* Group 0 configuration helpers */ 40 uint64_t amu_group0_cnt_read(int idx); 41 void amu_group0_cnt_write(int idx, uint64_t val); 42 43 /* Group 1 configuration helpers */ 44 uint64_t amu_group1_cnt_read(int idx); 45 void amu_group1_cnt_write(int idx, uint64_t val); 46 void amu_group1_set_evtype(int idx, unsigned int val); 47 48 #endif /* AMU_H */ 49