18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */
28c2ecf20Sopenharmony_ci/*
38c2ecf20Sopenharmony_ci * Definitions for use with the Alpha wrperfmon PAL call.
48c2ecf20Sopenharmony_ci */
58c2ecf20Sopenharmony_ci
68c2ecf20Sopenharmony_ci#ifndef __ALPHA_WRPERFMON_H
78c2ecf20Sopenharmony_ci#define __ALPHA_WRPERFMON_H
88c2ecf20Sopenharmony_ci
98c2ecf20Sopenharmony_ci/* Following commands are implemented on all CPUs */
108c2ecf20Sopenharmony_ci#define PERFMON_CMD_DISABLE 0
118c2ecf20Sopenharmony_ci#define PERFMON_CMD_ENABLE 1
128c2ecf20Sopenharmony_ci#define PERFMON_CMD_DESIRED_EVENTS 2
138c2ecf20Sopenharmony_ci#define PERFMON_CMD_LOGGING_OPTIONS 3
148c2ecf20Sopenharmony_ci/* Following commands on EV5/EV56/PCA56 only */
158c2ecf20Sopenharmony_ci#define PERFMON_CMD_INT_FREQ 4
168c2ecf20Sopenharmony_ci#define PERFMON_CMD_ENABLE_CLEAR 7
178c2ecf20Sopenharmony_ci/* Following commands are on EV5 and better CPUs */
188c2ecf20Sopenharmony_ci#define PERFMON_CMD_READ 5
198c2ecf20Sopenharmony_ci#define PERFMON_CMD_WRITE 6
208c2ecf20Sopenharmony_ci/* Following command are on EV6 and better CPUs */
218c2ecf20Sopenharmony_ci#define PERFMON_CMD_ENABLE_WRITE 7
228c2ecf20Sopenharmony_ci/* Following command are on EV67 and better CPUs */
238c2ecf20Sopenharmony_ci#define PERFMON_CMD_I_STAT 8
248c2ecf20Sopenharmony_ci#define PERFMON_CMD_PMPC 9
258c2ecf20Sopenharmony_ci
268c2ecf20Sopenharmony_ci
278c2ecf20Sopenharmony_ci/* EV5/EV56/PCA56 Counters */
288c2ecf20Sopenharmony_ci#define EV5_PCTR_0 (1UL<<0)
298c2ecf20Sopenharmony_ci#define EV5_PCTR_1 (1UL<<1)
308c2ecf20Sopenharmony_ci#define EV5_PCTR_2 (1UL<<2)
318c2ecf20Sopenharmony_ci
328c2ecf20Sopenharmony_ci#define EV5_PCTR_0_COUNT_SHIFT 48
338c2ecf20Sopenharmony_ci#define EV5_PCTR_1_COUNT_SHIFT 32
348c2ecf20Sopenharmony_ci#define EV5_PCTR_2_COUNT_SHIFT 16
358c2ecf20Sopenharmony_ci
368c2ecf20Sopenharmony_ci#define EV5_PCTR_0_COUNT_MASK 0xffffUL
378c2ecf20Sopenharmony_ci#define EV5_PCTR_1_COUNT_MASK 0xffffUL
388c2ecf20Sopenharmony_ci#define EV5_PCTR_2_COUNT_MASK 0x3fffUL
398c2ecf20Sopenharmony_ci
408c2ecf20Sopenharmony_ci/* EV6 Counters */
418c2ecf20Sopenharmony_ci#define EV6_PCTR_0 (1UL<<0)
428c2ecf20Sopenharmony_ci#define EV6_PCTR_1 (1UL<<1)
438c2ecf20Sopenharmony_ci
448c2ecf20Sopenharmony_ci#define EV6_PCTR_0_COUNT_SHIFT 28
458c2ecf20Sopenharmony_ci#define EV6_PCTR_1_COUNT_SHIFT 6
468c2ecf20Sopenharmony_ci
478c2ecf20Sopenharmony_ci#define EV6_PCTR_0_COUNT_MASK 0xfffffUL
488c2ecf20Sopenharmony_ci#define EV6_PCTR_1_COUNT_MASK 0xfffffUL
498c2ecf20Sopenharmony_ci
508c2ecf20Sopenharmony_ci/* EV67 (and subsequent) counters */
518c2ecf20Sopenharmony_ci#define EV67_PCTR_0 (1UL<<0)
528c2ecf20Sopenharmony_ci#define EV67_PCTR_1 (1UL<<1)
538c2ecf20Sopenharmony_ci
548c2ecf20Sopenharmony_ci#define EV67_PCTR_0_COUNT_SHIFT 28
558c2ecf20Sopenharmony_ci#define EV67_PCTR_1_COUNT_SHIFT 6
568c2ecf20Sopenharmony_ci
578c2ecf20Sopenharmony_ci#define EV67_PCTR_0_COUNT_MASK 0xfffffUL
588c2ecf20Sopenharmony_ci#define EV67_PCTR_1_COUNT_MASK 0xfffffUL
598c2ecf20Sopenharmony_ci
608c2ecf20Sopenharmony_ci
618c2ecf20Sopenharmony_ci/*
628c2ecf20Sopenharmony_ci * The Alpha Architecure Handbook, vers. 4 (1998) appears to have a misprint
638c2ecf20Sopenharmony_ci *  in Table E-23 regarding the bits that set the event PCTR 1 counts.
648c2ecf20Sopenharmony_ci *  Hopefully what we have here is correct.
658c2ecf20Sopenharmony_ci */
668c2ecf20Sopenharmony_ci#define EV6_PCTR_0_EVENT_MASK 0x10UL
678c2ecf20Sopenharmony_ci#define EV6_PCTR_1_EVENT_MASK 0x0fUL
688c2ecf20Sopenharmony_ci
698c2ecf20Sopenharmony_ci/* EV6 Events */
708c2ecf20Sopenharmony_ci#define EV6_PCTR_0_CYCLES (0UL << 4)
718c2ecf20Sopenharmony_ci#define EV6_PCTR_0_INSTRUCTIONS (1UL << 4)
728c2ecf20Sopenharmony_ci
738c2ecf20Sopenharmony_ci#define EV6_PCTR_1_CYCLES 0
748c2ecf20Sopenharmony_ci#define EV6_PCTR_1_BRANCHES 1
758c2ecf20Sopenharmony_ci#define EV6_PCTR_1_BRANCH_MISPREDICTS 2
768c2ecf20Sopenharmony_ci#define EV6_PCTR_1_DTB_SINGLE_MISSES 3
778c2ecf20Sopenharmony_ci#define EV6_PCTR_1_DTB_DOUBLE_MISSES 4
788c2ecf20Sopenharmony_ci#define EV6_PCTR_1_ITB_MISSES 5
798c2ecf20Sopenharmony_ci#define EV6_PCTR_1_UNALIGNED_TRAPS 6
808c2ecf20Sopenharmony_ci#define EV6_PCTR_1_REPLY_TRAPS 7
818c2ecf20Sopenharmony_ci
828c2ecf20Sopenharmony_ci/* From the Alpha Architecture Reference Manual, 4th edn., 2002 */
838c2ecf20Sopenharmony_ci#define EV67_PCTR_MODE_MASK 0x10UL
848c2ecf20Sopenharmony_ci#define EV67_PCTR_EVENT_MASK 0x0CUL
858c2ecf20Sopenharmony_ci
868c2ecf20Sopenharmony_ci#define EV67_PCTR_MODE_PROFILEME (1UL<<4)
878c2ecf20Sopenharmony_ci#define EV67_PCTR_MODE_AGGREGATE (0UL<<4)
888c2ecf20Sopenharmony_ci
898c2ecf20Sopenharmony_ci#define EV67_PCTR_INSTR_CYCLES (0UL<<2)
908c2ecf20Sopenharmony_ci#define EV67_PCTR_CYCLES_UNDEF (1UL<<2)
918c2ecf20Sopenharmony_ci#define EV67_PCTR_INSTR_BCACHEMISS (2UL<<2)
928c2ecf20Sopenharmony_ci#define EV67_PCTR_CYCLES_MBOX (3UL<<2)
938c2ecf20Sopenharmony_ci
948c2ecf20Sopenharmony_ci#endif
95