162306a36Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */
262306a36Sopenharmony_ci/*
362306a36Sopenharmony_ci * Contains register definitions for the Freescale Embedded Performance
462306a36Sopenharmony_ci * Monitor.
562306a36Sopenharmony_ci */
662306a36Sopenharmony_ci#ifdef __KERNEL__
762306a36Sopenharmony_ci#ifndef __ASM_POWERPC_REG_FSL_EMB_H__
862306a36Sopenharmony_ci#define __ASM_POWERPC_REG_FSL_EMB_H__
962306a36Sopenharmony_ci
1062306a36Sopenharmony_ci#include <linux/stringify.h>
1162306a36Sopenharmony_ci
1262306a36Sopenharmony_ci#ifndef __ASSEMBLY__
1362306a36Sopenharmony_ci/* Performance Monitor Registers */
1462306a36Sopenharmony_ci#define mfpmr(rn)	({unsigned int rval; \
1562306a36Sopenharmony_ci			asm volatile(".machine push; " \
1662306a36Sopenharmony_ci				     ".machine e300; " \
1762306a36Sopenharmony_ci				     "mfpmr %0," __stringify(rn) ";" \
1862306a36Sopenharmony_ci				     ".machine pop; " \
1962306a36Sopenharmony_ci				     : "=r" (rval)); rval;})
2062306a36Sopenharmony_ci#define mtpmr(rn, v)	asm volatile(".machine push; " \
2162306a36Sopenharmony_ci				     ".machine e300; " \
2262306a36Sopenharmony_ci				     "mtpmr " __stringify(rn) ",%0; " \
2362306a36Sopenharmony_ci				     ".machine pop; " \
2462306a36Sopenharmony_ci				     : : "r" (v))
2562306a36Sopenharmony_ci#endif /* __ASSEMBLY__ */
2662306a36Sopenharmony_ci
2762306a36Sopenharmony_ci/* Freescale Book E Performance Monitor APU Registers */
2862306a36Sopenharmony_ci#define PMRN_PMC0	0x010	/* Performance Monitor Counter 0 */
2962306a36Sopenharmony_ci#define PMRN_PMC1	0x011	/* Performance Monitor Counter 1 */
3062306a36Sopenharmony_ci#define PMRN_PMC2	0x012	/* Performance Monitor Counter 2 */
3162306a36Sopenharmony_ci#define PMRN_PMC3	0x013	/* Performance Monitor Counter 3 */
3262306a36Sopenharmony_ci#define PMRN_PMC4	0x014	/* Performance Monitor Counter 4 */
3362306a36Sopenharmony_ci#define PMRN_PMC5	0x015	/* Performance Monitor Counter 5 */
3462306a36Sopenharmony_ci#define PMRN_PMLCA0	0x090	/* PM Local Control A0 */
3562306a36Sopenharmony_ci#define PMRN_PMLCA1	0x091	/* PM Local Control A1 */
3662306a36Sopenharmony_ci#define PMRN_PMLCA2	0x092	/* PM Local Control A2 */
3762306a36Sopenharmony_ci#define PMRN_PMLCA3	0x093	/* PM Local Control A3 */
3862306a36Sopenharmony_ci#define PMRN_PMLCA4	0x094	/* PM Local Control A4 */
3962306a36Sopenharmony_ci#define PMRN_PMLCA5	0x095	/* PM Local Control A5 */
4062306a36Sopenharmony_ci
4162306a36Sopenharmony_ci#define PMLCA_FC	0x80000000	/* Freeze Counter */
4262306a36Sopenharmony_ci#define PMLCA_FCS	0x40000000	/* Freeze in Supervisor */
4362306a36Sopenharmony_ci#define PMLCA_FCU	0x20000000	/* Freeze in User */
4462306a36Sopenharmony_ci#define PMLCA_FCM1	0x10000000	/* Freeze when PMM==1 */
4562306a36Sopenharmony_ci#define PMLCA_FCM0	0x08000000	/* Freeze when PMM==0 */
4662306a36Sopenharmony_ci#define PMLCA_CE	0x04000000	/* Condition Enable */
4762306a36Sopenharmony_ci#define PMLCA_FGCS1	0x00000002	/* Freeze in guest state */
4862306a36Sopenharmony_ci#define PMLCA_FGCS0	0x00000001	/* Freeze in hypervisor state */
4962306a36Sopenharmony_ci
5062306a36Sopenharmony_ci#define PMLCA_EVENT_MASK 0x01ff0000	/* Event field */
5162306a36Sopenharmony_ci#define PMLCA_EVENT_SHIFT	16
5262306a36Sopenharmony_ci
5362306a36Sopenharmony_ci#define PMRN_PMLCB0	0x110	/* PM Local Control B0 */
5462306a36Sopenharmony_ci#define PMRN_PMLCB1	0x111	/* PM Local Control B1 */
5562306a36Sopenharmony_ci#define PMRN_PMLCB2	0x112	/* PM Local Control B2 */
5662306a36Sopenharmony_ci#define PMRN_PMLCB3	0x113	/* PM Local Control B3 */
5762306a36Sopenharmony_ci#define PMRN_PMLCB4	0x114	/* PM Local Control B4 */
5862306a36Sopenharmony_ci#define PMRN_PMLCB5	0x115	/* PM Local Control B5 */
5962306a36Sopenharmony_ci
6062306a36Sopenharmony_ci#define PMLCB_THRESHMUL_MASK	0x0700	/* Threshold Multiple Field */
6162306a36Sopenharmony_ci#define PMLCB_THRESHMUL_SHIFT	8
6262306a36Sopenharmony_ci
6362306a36Sopenharmony_ci#define PMLCB_THRESHOLD_MASK	0x003f	/* Threshold Field */
6462306a36Sopenharmony_ci#define PMLCB_THRESHOLD_SHIFT	0
6562306a36Sopenharmony_ci
6662306a36Sopenharmony_ci#define PMRN_PMGC0	0x190	/* PM Global Control 0 */
6762306a36Sopenharmony_ci
6862306a36Sopenharmony_ci#define PMGC0_FAC	0x80000000	/* Freeze all Counters */
6962306a36Sopenharmony_ci#define PMGC0_PMIE	0x40000000	/* Interrupt Enable */
7062306a36Sopenharmony_ci#define PMGC0_FCECE	0x20000000	/* Freeze countes on
7162306a36Sopenharmony_ci					   Enabled Condition or
7262306a36Sopenharmony_ci					   Event */
7362306a36Sopenharmony_ci
7462306a36Sopenharmony_ci#define PMRN_UPMC0	0x000	/* User Performance Monitor Counter 0 */
7562306a36Sopenharmony_ci#define PMRN_UPMC1	0x001	/* User Performance Monitor Counter 1 */
7662306a36Sopenharmony_ci#define PMRN_UPMC2	0x002	/* User Performance Monitor Counter 2 */
7762306a36Sopenharmony_ci#define PMRN_UPMC3	0x003	/* User Performance Monitor Counter 3 */
7862306a36Sopenharmony_ci#define PMRN_UPMC4	0x004	/* User Performance Monitor Counter 4 */
7962306a36Sopenharmony_ci#define PMRN_UPMC5	0x005	/* User Performance Monitor Counter 5 */
8062306a36Sopenharmony_ci#define PMRN_UPMLCA0	0x080	/* User PM Local Control A0 */
8162306a36Sopenharmony_ci#define PMRN_UPMLCA1	0x081	/* User PM Local Control A1 */
8262306a36Sopenharmony_ci#define PMRN_UPMLCA2	0x082	/* User PM Local Control A2 */
8362306a36Sopenharmony_ci#define PMRN_UPMLCA3	0x083	/* User PM Local Control A3 */
8462306a36Sopenharmony_ci#define PMRN_UPMLCA4	0x084	/* User PM Local Control A4 */
8562306a36Sopenharmony_ci#define PMRN_UPMLCA5	0x085	/* User PM Local Control A5 */
8662306a36Sopenharmony_ci#define PMRN_UPMLCB0	0x100	/* User PM Local Control B0 */
8762306a36Sopenharmony_ci#define PMRN_UPMLCB1	0x101	/* User PM Local Control B1 */
8862306a36Sopenharmony_ci#define PMRN_UPMLCB2	0x102	/* User PM Local Control B2 */
8962306a36Sopenharmony_ci#define PMRN_UPMLCB3	0x103	/* User PM Local Control B3 */
9062306a36Sopenharmony_ci#define PMRN_UPMLCB4	0x104	/* User PM Local Control B4 */
9162306a36Sopenharmony_ci#define PMRN_UPMLCB5	0x105	/* User PM Local Control B5 */
9262306a36Sopenharmony_ci#define PMRN_UPMGC0	0x180	/* User PM Global Control 0 */
9362306a36Sopenharmony_ci
9462306a36Sopenharmony_ci
9562306a36Sopenharmony_ci#endif /* __ASM_POWERPC_REG_FSL_EMB_H__ */
9662306a36Sopenharmony_ci#endif /* __KERNEL__ */
97