xref: /rk3399_ARM-atf/include/lib/extensions/amu.h (revision ed8f06ddda52bc0333f79e9ff798419e67771ae5)
1 /*
2  * Copyright (c) 2017-2021, 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 <context.h>
14 
15 #include <platform_def.h>
16 
17 #if ENABLE_FEAT_AMU
18 #if __aarch64__
19 void amu_enable(cpu_context_t *ctx);
20 void amu_init_el3(void);
21 void amu_init_el2_unused(void);
22 #else
23 void amu_enable(bool el2_unused);
24 #endif
25 #else
26 #if __aarch64__
27 void amu_enable(cpu_context_t *ctx)
28 {
29 }
30 void amu_init_el3(void)
31 {
32 }
33 void amu_init_el2_unused(void)
34 {
35 }
36 #else
37 static inline void amu_enable(bool el2_unused)
38 {
39 }
40 #endif
41 #endif
42 
43 #if ENABLE_AMU_AUXILIARY_COUNTERS
44 /*
45  * AMU data for a single core.
46  */
47 struct amu_core {
48 	uint16_t enable; /* Mask of auxiliary counters to enable */
49 };
50 
51 /*
52  * Topological platform data specific to the AMU.
53  */
54 struct amu_topology {
55 	struct amu_core cores[PLATFORM_CORE_COUNT]; /* Per-core data */
56 };
57 
58 #if !ENABLE_AMU_FCONF
59 /*
60  * Retrieve the platform's AMU topology. A `NULL` return value is treated as a
61  * non-fatal error, in which case no auxiliary counters will be enabled.
62  */
63 const struct amu_topology *plat_amu_topology(void);
64 #endif /* ENABLE_AMU_FCONF */
65 #endif /* ENABLE_AMU_AUXILIARY_COUNTERS */
66 
67 #endif /* AMU_H */
68