18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-or-later */ 28c2ecf20Sopenharmony_ci/* 38c2ecf20Sopenharmony_ci * Cell Broadband Engine Performance Monitor 48c2ecf20Sopenharmony_ci * 58c2ecf20Sopenharmony_ci * (C) Copyright IBM Corporation 2006 68c2ecf20Sopenharmony_ci * 78c2ecf20Sopenharmony_ci * Author: 88c2ecf20Sopenharmony_ci * David Erb (djerb@us.ibm.com) 98c2ecf20Sopenharmony_ci * Kevin Corry (kevcorry@us.ibm.com) 108c2ecf20Sopenharmony_ci */ 118c2ecf20Sopenharmony_ci 128c2ecf20Sopenharmony_ci#ifndef __ASM_CELL_PMU_H__ 138c2ecf20Sopenharmony_ci#define __ASM_CELL_PMU_H__ 148c2ecf20Sopenharmony_ci 158c2ecf20Sopenharmony_ci/* The Cell PMU has four hardware performance counters, which can be 168c2ecf20Sopenharmony_ci * configured as four 32-bit counters or eight 16-bit counters. 178c2ecf20Sopenharmony_ci */ 188c2ecf20Sopenharmony_ci#define NR_PHYS_CTRS 4 198c2ecf20Sopenharmony_ci#define NR_CTRS (NR_PHYS_CTRS * 2) 208c2ecf20Sopenharmony_ci 218c2ecf20Sopenharmony_ci/* Macros for the pm_control register. */ 228c2ecf20Sopenharmony_ci#define CBE_PM_16BIT_CTR(ctr) (1 << (24 - ((ctr) & (NR_PHYS_CTRS - 1)))) 238c2ecf20Sopenharmony_ci#define CBE_PM_ENABLE_PERF_MON 0x80000000 248c2ecf20Sopenharmony_ci#define CBE_PM_STOP_AT_MAX 0x40000000 258c2ecf20Sopenharmony_ci#define CBE_PM_TRACE_MODE_GET(pm_control) (((pm_control) >> 28) & 0x3) 268c2ecf20Sopenharmony_ci#define CBE_PM_TRACE_MODE_SET(mode) (((mode) & 0x3) << 28) 278c2ecf20Sopenharmony_ci#define CBE_PM_TRACE_BUF_OVFLW(bit) (((bit) & 0x1) << 17) 288c2ecf20Sopenharmony_ci#define CBE_PM_COUNT_MODE_SET(count) (((count) & 0x3) << 18) 298c2ecf20Sopenharmony_ci#define CBE_PM_FREEZE_ALL_CTRS 0x00100000 308c2ecf20Sopenharmony_ci#define CBE_PM_ENABLE_EXT_TRACE 0x00008000 318c2ecf20Sopenharmony_ci#define CBE_PM_SPU_ADDR_TRACE_SET(msk) (((msk) & 0x3) << 9) 328c2ecf20Sopenharmony_ci 338c2ecf20Sopenharmony_ci/* Macros for the trace_address register. */ 348c2ecf20Sopenharmony_ci#define CBE_PM_TRACE_BUF_FULL 0x00000800 358c2ecf20Sopenharmony_ci#define CBE_PM_TRACE_BUF_EMPTY 0x00000400 368c2ecf20Sopenharmony_ci#define CBE_PM_TRACE_BUF_DATA_COUNT(ta) ((ta) & 0x3ff) 378c2ecf20Sopenharmony_ci#define CBE_PM_TRACE_BUF_MAX_COUNT 0x400 388c2ecf20Sopenharmony_ci 398c2ecf20Sopenharmony_ci/* Macros for the pm07_control registers. */ 408c2ecf20Sopenharmony_ci#define CBE_PM_CTR_INPUT_MUX(pm07_control) (((pm07_control) >> 26) & 0x3f) 418c2ecf20Sopenharmony_ci#define CBE_PM_CTR_INPUT_CONTROL 0x02000000 428c2ecf20Sopenharmony_ci#define CBE_PM_CTR_POLARITY 0x01000000 438c2ecf20Sopenharmony_ci#define CBE_PM_CTR_COUNT_CYCLES 0x00800000 448c2ecf20Sopenharmony_ci#define CBE_PM_CTR_ENABLE 0x00400000 458c2ecf20Sopenharmony_ci#define PM07_CTR_INPUT_MUX(x) (((x) & 0x3F) << 26) 468c2ecf20Sopenharmony_ci#define PM07_CTR_INPUT_CONTROL(x) (((x) & 1) << 25) 478c2ecf20Sopenharmony_ci#define PM07_CTR_POLARITY(x) (((x) & 1) << 24) 488c2ecf20Sopenharmony_ci#define PM07_CTR_COUNT_CYCLES(x) (((x) & 1) << 23) 498c2ecf20Sopenharmony_ci#define PM07_CTR_ENABLE(x) (((x) & 1) << 22) 508c2ecf20Sopenharmony_ci 518c2ecf20Sopenharmony_ci/* Macros for the pm_status register. */ 528c2ecf20Sopenharmony_ci#define CBE_PM_CTR_OVERFLOW_INTR(ctr) (1 << (31 - ((ctr) & 7))) 538c2ecf20Sopenharmony_ci 548c2ecf20Sopenharmony_cienum pm_reg_name { 558c2ecf20Sopenharmony_ci group_control, 568c2ecf20Sopenharmony_ci debug_bus_control, 578c2ecf20Sopenharmony_ci trace_address, 588c2ecf20Sopenharmony_ci ext_tr_timer, 598c2ecf20Sopenharmony_ci pm_status, 608c2ecf20Sopenharmony_ci pm_control, 618c2ecf20Sopenharmony_ci pm_interval, 628c2ecf20Sopenharmony_ci pm_start_stop, 638c2ecf20Sopenharmony_ci}; 648c2ecf20Sopenharmony_ci 658c2ecf20Sopenharmony_ci/* Routines for reading/writing the PMU registers. */ 668c2ecf20Sopenharmony_ciextern u32 cbe_read_phys_ctr(u32 cpu, u32 phys_ctr); 678c2ecf20Sopenharmony_ciextern void cbe_write_phys_ctr(u32 cpu, u32 phys_ctr, u32 val); 688c2ecf20Sopenharmony_ciextern u32 cbe_read_ctr(u32 cpu, u32 ctr); 698c2ecf20Sopenharmony_ciextern void cbe_write_ctr(u32 cpu, u32 ctr, u32 val); 708c2ecf20Sopenharmony_ci 718c2ecf20Sopenharmony_ciextern u32 cbe_read_pm07_control(u32 cpu, u32 ctr); 728c2ecf20Sopenharmony_ciextern void cbe_write_pm07_control(u32 cpu, u32 ctr, u32 val); 738c2ecf20Sopenharmony_ciextern u32 cbe_read_pm(u32 cpu, enum pm_reg_name reg); 748c2ecf20Sopenharmony_ciextern void cbe_write_pm(u32 cpu, enum pm_reg_name reg, u32 val); 758c2ecf20Sopenharmony_ci 768c2ecf20Sopenharmony_ciextern u32 cbe_get_ctr_size(u32 cpu, u32 phys_ctr); 778c2ecf20Sopenharmony_ciextern void cbe_set_ctr_size(u32 cpu, u32 phys_ctr, u32 ctr_size); 788c2ecf20Sopenharmony_ci 798c2ecf20Sopenharmony_ciextern void cbe_enable_pm(u32 cpu); 808c2ecf20Sopenharmony_ciextern void cbe_disable_pm(u32 cpu); 818c2ecf20Sopenharmony_ci 828c2ecf20Sopenharmony_ciextern void cbe_read_trace_buffer(u32 cpu, u64 *buf); 838c2ecf20Sopenharmony_ci 848c2ecf20Sopenharmony_ciextern void cbe_enable_pm_interrupts(u32 cpu, u32 thread, u32 mask); 858c2ecf20Sopenharmony_ciextern void cbe_disable_pm_interrupts(u32 cpu); 868c2ecf20Sopenharmony_ciextern u32 cbe_get_and_clear_pm_interrupts(u32 cpu); 878c2ecf20Sopenharmony_ciextern void cbe_sync_irq(int node); 888c2ecf20Sopenharmony_ci 898c2ecf20Sopenharmony_ci#define CBE_COUNT_SUPERVISOR_MODE 0 908c2ecf20Sopenharmony_ci#define CBE_COUNT_HYPERVISOR_MODE 1 918c2ecf20Sopenharmony_ci#define CBE_COUNT_PROBLEM_MODE 2 928c2ecf20Sopenharmony_ci#define CBE_COUNT_ALL_MODES 3 938c2ecf20Sopenharmony_ci 948c2ecf20Sopenharmony_ci#endif /* __ASM_CELL_PMU_H__ */ 95