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