ebb_lmr.h 786 B

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