• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 #ifndef _SELFTESTS_POWERPC_PMU_EBB_LMR_H
2 #define _SELFTESTS_POWERPC_PMU_EBB_LMR_H
3 
4 #include "reg.h"
5 
6 #ifndef PPC_FEATURE2_ARCH_3_00
7 #define PPC_FEATURE2_ARCH_3_00 0x00800000
8 #endif
9 
10 #define lmr_is_supported() have_hwcap2(PPC_FEATURE2_ARCH_3_00)
11 
ebb_lmr_reset(void)12 static inline void ebb_lmr_reset(void)
13 {
14 	unsigned long bescr = mfspr(SPRN_BESCR);
15 	bescr &= ~(BESCR_LMEO);
16 	bescr |= BESCR_LME;
17 	mtspr(SPRN_BESCR, bescr);
18 }
19 
20 #define LDMX(t, a, b)\
21 	(0x7c00026a |				\
22 	 (((t) & 0x1f) << 21) |			\
23 	 (((a) & 0x1f) << 16) |			\
24 	 (((b) & 0x1f) << 11))
25 
ldmx(unsigned long address)26 static inline unsigned long ldmx(unsigned long address)
27 {
28 	unsigned long ret;
29 
30 	asm volatile ("mr 9, %1\r\n"
31 		      ".long " __stringify(LDMX(9, 0, 9)) "\r\n"
32 		      "mr %0, 9\r\n":"=r"(ret)
33 		      :"r"(address)
34 		      :"r9");
35 
36 	return ret;
37 }
38 
39 #endif
40