Dimitris Papastamos | e08005a | 2017-10-12 13:02:29 +0100 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2017, 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 | |
Dimitris Papastamos | 60346db | 2017-12-13 10:54:37 +0000 | [diff] [blame] | 10 | #include <cassert.h> |
| 11 | #include <platform_def.h> |
Dimitris Papastamos | 525c37a | 2017-11-13 09:49:45 +0000 | [diff] [blame] | 12 | #include <stdint.h> |
Joel Hutton | 0dcdd8d | 2017-12-21 15:21:20 +0000 | [diff] [blame] | 13 | #include <sys/cdefs.h> /* for CASSERT() */ |
Dimitris Papastamos | 60346db | 2017-12-13 10:54:37 +0000 | [diff] [blame] | 14 | |
| 15 | /* All group 0 counters */ |
Dimitris Papastamos | e08005a | 2017-10-12 13:02:29 +0100 | [diff] [blame] | 16 | #define AMU_GROUP0_COUNTERS_MASK 0xf |
| 17 | |
Dimitris Papastamos | 60346db | 2017-12-13 10:54:37 +0000 | [diff] [blame] | 18 | #ifdef PLAT_AMU_GROUP1_COUNTERS_MASK |
| 19 | #define AMU_GROUP1_COUNTERS_MASK PLAT_AMU_GROUP1_COUNTERS_MASK |
| 20 | #else |
| 21 | #define AMU_GROUP1_COUNTERS_MASK 0 |
| 22 | #endif |
| 23 | |
| 24 | #ifdef PLAT_AMU_GROUP1_NR_COUNTERS |
| 25 | #define AMU_GROUP1_NR_COUNTERS PLAT_AMU_GROUP1_NR_COUNTERS |
| 26 | #else |
| 27 | #define AMU_GROUP1_NR_COUNTERS 0 |
| 28 | #endif |
| 29 | |
| 30 | CASSERT(AMU_GROUP1_COUNTERS_MASK <= 0xffff, invalid_amu_group1_counters_mask); |
| 31 | CASSERT(AMU_GROUP1_NR_COUNTERS <= 16, invalid_amu_group1_nr_counters); |
| 32 | |
Dimitris Papastamos | 525c37a | 2017-11-13 09:49:45 +0000 | [diff] [blame] | 33 | int amu_supported(void); |
Dimitris Papastamos | e08005a | 2017-10-12 13:02:29 +0100 | [diff] [blame] | 34 | void amu_enable(int el2_unused); |
| 35 | |
Dimitris Papastamos | 525c37a | 2017-11-13 09:49:45 +0000 | [diff] [blame] | 36 | /* Group 0 configuration helpers */ |
| 37 | uint64_t amu_group0_cnt_read(int idx); |
| 38 | void amu_group0_cnt_write(int idx, uint64_t val); |
| 39 | |
| 40 | /* Group 1 configuration helpers */ |
| 41 | uint64_t amu_group1_cnt_read(int idx); |
| 42 | void amu_group1_cnt_write(int idx, uint64_t val); |
| 43 | void amu_group1_set_evtype(int idx, unsigned int val); |
| 44 | |
Dimitris Papastamos | e08005a | 2017-10-12 13:02:29 +0100 | [diff] [blame] | 45 | #endif /* __AMU_H__ */ |