blob: 1836fe5ae60c97a74f26311f0462035bb0c9e028 [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
Dimitris Papastamos60346db2017-12-13 10:54:37 +000010#include <cassert.h>
11#include <platform_def.h>
Antonio Nino Diaz033b4bb2018-10-25 16:52:26 +010012#include <stdbool.h>
Dimitris Papastamos525c37a2017-11-13 09:49:45 +000013#include <stdint.h>
Antonio Nino Diaz033b4bb2018-10-25 16:52:26 +010014#include <utils_def.h>
Dimitris Papastamos60346db2017-12-13 10:54:37 +000015
16/* All group 0 counters */
Antonio Nino Diaz033b4bb2018-10-25 16:52:26 +010017#define AMU_GROUP0_COUNTERS_MASK U(0xf)
Dimitris Papastamose08005a2017-10-12 13:02:29 +010018
Dimitris Papastamos60346db2017-12-13 10:54:37 +000019#ifdef PLAT_AMU_GROUP1_COUNTERS_MASK
20#define AMU_GROUP1_COUNTERS_MASK PLAT_AMU_GROUP1_COUNTERS_MASK
21#else
Antonio Nino Diaz033b4bb2018-10-25 16:52:26 +010022#define AMU_GROUP1_COUNTERS_MASK U(0)
Dimitris Papastamos60346db2017-12-13 10:54:37 +000023#endif
24
25#ifdef PLAT_AMU_GROUP1_NR_COUNTERS
26#define AMU_GROUP1_NR_COUNTERS PLAT_AMU_GROUP1_NR_COUNTERS
27#else
Antonio Nino Diaz033b4bb2018-10-25 16:52:26 +010028#define AMU_GROUP1_NR_COUNTERS U(0)
Dimitris Papastamos60346db2017-12-13 10:54:37 +000029#endif
30
31CASSERT(AMU_GROUP1_COUNTERS_MASK <= 0xffff, invalid_amu_group1_counters_mask);
32CASSERT(AMU_GROUP1_NR_COUNTERS <= 16, invalid_amu_group1_nr_counters);
33
Antonio Nino Diaz033b4bb2018-10-25 16:52:26 +010034bool amu_supported(void);
35void amu_enable(bool el2_unused);
Dimitris Papastamose08005a2017-10-12 13:02:29 +010036
Dimitris Papastamos525c37a2017-11-13 09:49:45 +000037/* Group 0 configuration helpers */
38uint64_t amu_group0_cnt_read(int idx);
39void amu_group0_cnt_write(int idx, uint64_t val);
40
41/* Group 1 configuration helpers */
42uint64_t amu_group1_cnt_read(int idx);
43void amu_group1_cnt_write(int idx, uint64_t val);
44void amu_group1_set_evtype(int idx, unsigned int val);
45
Antonio Nino Diaz033b4bb2018-10-25 16:52:26 +010046#endif /* AMU_H */