blob: 99ecfccbbfbd37a6032690be8e54d5d2dfb089f8 [file] [log] [blame]
Dimitris Papastamose08005a2017-10-12 13:02:29 +01001/*
Antonio Nino Diaz4b32e622018-08-16 16:52:57 +01002 * Copyright (c) 2017-2018, ARM Limited and Contributors. All rights reserved.
Dimitris Papastamose08005a2017-10-12 13:02:29 +01003 *
4 * SPDX-License-Identifier: BSD-3-Clause
5 */
6
Antonio Nino Diaz033b4bb2018-10-25 16:52:26 +01007#ifndef AMU_H
8#define AMU_H
Dimitris Papastamose08005a2017-10-12 13:02:29 +01009
Antonio Nino Diaz033b4bb2018-10-25 16:52:26 +010010#include <stdbool.h>
Dimitris Papastamos525c37a2017-11-13 09:49:45 +000011#include <stdint.h>
Antonio Nino Diaze0f90632018-12-14 00:18:21 +000012
13#include <platform_def.h>
14
15#include <lib/cassert.h>
16#include <lib/utils_def.h>
Dimitris Papastamos60346db2017-12-13 10:54:37 +000017
18/* All group 0 counters */
Antonio Nino Diaz033b4bb2018-10-25 16:52:26 +010019#define AMU_GROUP0_COUNTERS_MASK U(0xf)
Dimitris Papastamose08005a2017-10-12 13:02:29 +010020
Dimitris Papastamos60346db2017-12-13 10:54:37 +000021#ifdef PLAT_AMU_GROUP1_COUNTERS_MASK
22#define AMU_GROUP1_COUNTERS_MASK PLAT_AMU_GROUP1_COUNTERS_MASK
23#else
Antonio Nino Diaz033b4bb2018-10-25 16:52:26 +010024#define AMU_GROUP1_COUNTERS_MASK U(0)
Dimitris Papastamos60346db2017-12-13 10:54:37 +000025#endif
26
27#ifdef PLAT_AMU_GROUP1_NR_COUNTERS
28#define AMU_GROUP1_NR_COUNTERS PLAT_AMU_GROUP1_NR_COUNTERS
29#else
Antonio Nino Diaz033b4bb2018-10-25 16:52:26 +010030#define AMU_GROUP1_NR_COUNTERS U(0)
Dimitris Papastamos60346db2017-12-13 10:54:37 +000031#endif
32
33CASSERT(AMU_GROUP1_COUNTERS_MASK <= 0xffff, invalid_amu_group1_counters_mask);
34CASSERT(AMU_GROUP1_NR_COUNTERS <= 16, invalid_amu_group1_nr_counters);
35
Antonio Nino Diaz033b4bb2018-10-25 16:52:26 +010036bool amu_supported(void);
37void amu_enable(bool el2_unused);
Dimitris Papastamose08005a2017-10-12 13:02:29 +010038
Dimitris Papastamos525c37a2017-11-13 09:49:45 +000039/* Group 0 configuration helpers */
40uint64_t amu_group0_cnt_read(int idx);
41void amu_group0_cnt_write(int idx, uint64_t val);
42
43/* Group 1 configuration helpers */
44uint64_t amu_group1_cnt_read(int idx);
45void amu_group1_cnt_write(int idx, uint64_t val);
46void amu_group1_set_evtype(int idx, unsigned int val);
47
Antonio Nino Diaz033b4bb2018-10-25 16:52:26 +010048#endif /* AMU_H */