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 | |
Antonio Nino Diaz | 033b4bb | 2018-10-25 16:52:26 +0100 | [diff] [blame] | 10 | #include <stdbool.h> |
Dimitris Papastamos | 525c37a | 2017-11-13 09:49:45 +0000 | [diff] [blame] | 11 | #include <stdint.h> |
Antonio Nino Diaz | e0f9063 | 2018-12-14 00:18:21 +0000 | [diff] [blame] | 12 | |
| 13 | #include <platform_def.h> |
| 14 | |
| 15 | #include <lib/cassert.h> |
| 16 | #include <lib/utils_def.h> |
Dimitris Papastamos | 60346db | 2017-12-13 10:54:37 +0000 | [diff] [blame] | 17 | |
| 18 | /* All group 0 counters */ |
Antonio Nino Diaz | 033b4bb | 2018-10-25 16:52:26 +0100 | [diff] [blame] | 19 | #define AMU_GROUP0_COUNTERS_MASK U(0xf) |
Dimitris Papastamos | e08005a | 2017-10-12 13:02:29 +0100 | [diff] [blame] | 20 | |
Dimitris Papastamos | 60346db | 2017-12-13 10:54:37 +0000 | [diff] [blame] | 21 | #ifdef PLAT_AMU_GROUP1_COUNTERS_MASK |
| 22 | #define AMU_GROUP1_COUNTERS_MASK PLAT_AMU_GROUP1_COUNTERS_MASK |
| 23 | #else |
Antonio Nino Diaz | 033b4bb | 2018-10-25 16:52:26 +0100 | [diff] [blame] | 24 | #define AMU_GROUP1_COUNTERS_MASK U(0) |
Dimitris Papastamos | 60346db | 2017-12-13 10:54:37 +0000 | [diff] [blame] | 25 | #endif |
| 26 | |
| 27 | #ifdef PLAT_AMU_GROUP1_NR_COUNTERS |
| 28 | #define AMU_GROUP1_NR_COUNTERS PLAT_AMU_GROUP1_NR_COUNTERS |
| 29 | #else |
Antonio Nino Diaz | 033b4bb | 2018-10-25 16:52:26 +0100 | [diff] [blame] | 30 | #define AMU_GROUP1_NR_COUNTERS U(0) |
Dimitris Papastamos | 60346db | 2017-12-13 10:54:37 +0000 | [diff] [blame] | 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 | |
Antonio Nino Diaz | 033b4bb | 2018-10-25 16:52:26 +0100 | [diff] [blame] | 36 | bool amu_supported(void); |
| 37 | void amu_enable(bool el2_unused); |
Dimitris Papastamos | e08005a | 2017-10-12 13:02:29 +0100 | [diff] [blame] | 38 | |
Dimitris Papastamos | 525c37a | 2017-11-13 09:49:45 +0000 | [diff] [blame] | 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 | |
Antonio Nino Diaz | 033b4bb | 2018-10-25 16:52:26 +0100 | [diff] [blame] | 48 | #endif /* AMU_H */ |