blob: 838e4b9320ddc060735c54c484ff9c4d9e297789 [file] [log] [blame]
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +02001/*
Boyan Karatotev4e282422024-10-25 14:34:13 +01002 * Copyright (c) 2017-2024, Arm Limited. All rights reserved.
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +02003 *
4 * SPDX-License-Identifier: BSD-3-Clause
5 */
6
johpow01b7d752a2020-10-08 17:29:11 -05007#ifndef AMU_H
8#define AMU_H
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +02009
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +020010#include <stdint.h>
11
johpow01b7d752a2020-10-08 17:29:11 -050012#include <cassert.h>
13#include <platform_def.h>
johpow0122a40a62021-03-04 10:35:20 -060014#include <utils_def.h>
johpow01b7d752a2020-10-08 17:29:11 -050015
16#define AMU_GROUP0_COUNTERS_MASK U(0xf)
17#define AMU_GROUP0_NR_COUNTERS U(4)
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +020018
19#ifdef PLAT_AMU_GROUP1_COUNTERS_MASK
20#define AMU_GROUP1_COUNTERS_MASK PLAT_AMU_GROUP1_COUNTERS_MASK
21#else
johpow01b7d752a2020-10-08 17:29:11 -050022#define AMU_GROUP1_COUNTERS_MASK U(0)
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +020023#endif
24
johpow01b7d752a2020-10-08 17:29:11 -050025/* Calculate number of group 1 counters */
26#if (AMU_GROUP1_COUNTERS_MASK & (1 << 15))
27#define AMU_GROUP1_NR_COUNTERS 16U
28#elif (AMU_GROUP1_COUNTERS_MASK & (1 << 14))
29#define AMU_GROUP1_NR_COUNTERS 15U
30#elif (AMU_GROUP1_COUNTERS_MASK & (1 << 13))
31#define AMU_GROUP1_NR_COUNTERS 14U
32#elif (AMU_GROUP1_COUNTERS_MASK & (1 << 12))
33#define AMU_GROUP1_NR_COUNTERS 13U
34#elif (AMU_GROUP1_COUNTERS_MASK & (1 << 11))
35#define AMU_GROUP1_NR_COUNTERS 12U
36#elif (AMU_GROUP1_COUNTERS_MASK & (1 << 10))
37#define AMU_GROUP1_NR_COUNTERS 11U
38#elif (AMU_GROUP1_COUNTERS_MASK & (1 << 9))
39#define AMU_GROUP1_NR_COUNTERS 10U
40#elif (AMU_GROUP1_COUNTERS_MASK & (1 << 8))
41#define AMU_GROUP1_NR_COUNTERS 9U
42#elif (AMU_GROUP1_COUNTERS_MASK & (1 << 7))
43#define AMU_GROUP1_NR_COUNTERS 8U
44#elif (AMU_GROUP1_COUNTERS_MASK & (1 << 6))
45#define AMU_GROUP1_NR_COUNTERS 7U
46#elif (AMU_GROUP1_COUNTERS_MASK & (1 << 5))
47#define AMU_GROUP1_NR_COUNTERS 6U
48#elif (AMU_GROUP1_COUNTERS_MASK & (1 << 4))
49#define AMU_GROUP1_NR_COUNTERS 5U
50#elif (AMU_GROUP1_COUNTERS_MASK & (1 << 3))
51#define AMU_GROUP1_NR_COUNTERS 4U
52#elif (AMU_GROUP1_COUNTERS_MASK & (1 << 2))
53#define AMU_GROUP1_NR_COUNTERS 3U
54#elif (AMU_GROUP1_COUNTERS_MASK & (1 << 1))
55#define AMU_GROUP1_NR_COUNTERS 2U
56#elif (AMU_GROUP1_COUNTERS_MASK & (1 << 0))
57#define AMU_GROUP1_NR_COUNTERS 1U
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +020058#else
johpow01b7d752a2020-10-08 17:29:11 -050059#define AMU_GROUP1_NR_COUNTERS 0U
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +020060#endif
61
johpow01b7d752a2020-10-08 17:29:11 -050062CASSERT(AMU_GROUP1_COUNTERS_MASK <= 0xffff, invalid_amu_group1_counters_mask);
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +020063
johpow01b7d752a2020-10-08 17:29:11 -050064uint64_t amu_group0_cnt_read(unsigned int idx);
65#if __aarch64__
66uint64_t amu_group0_voffset_read(unsigned int idx);
67void amu_group0_voffset_write(unsigned int idx, uint64_t val);
68#endif
69
70#if AMU_GROUP1_NR_COUNTERS
71uint64_t amu_group1_cnt_read(unsigned int idx);
Juan Pablo Condec3cf2da2024-04-01 13:57:19 -050072uint64_t amu_group1_num_counters(void);
73uint64_t amu_group1_evtype_read(unsigned int idx);
74void amu_group1_evtype_write(unsigned int idx, uint64_t val);
johpow01b7d752a2020-10-08 17:29:11 -050075#if __aarch64__
Juan Pablo Condec3cf2da2024-04-01 13:57:19 -050076uint64_t amu_group1_is_counter_implemented(unsigned int idx);
johpow01b7d752a2020-10-08 17:29:11 -050077uint64_t amu_group1_voffset_read(unsigned int idx);
78void amu_group1_voffset_write(unsigned int idx, uint64_t val);
79#endif
80#endif
81
82#endif /* AMU_H */