timex.h 962 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. #ifndef _ASM_POWERPC_TIMEX_H
  2. #define _ASM_POWERPC_TIMEX_H
  3. #ifdef __KERNEL__
  4. /*
  5. * PowerPC architecture timex specifications
  6. */
  7. #include <asm/cputable.h>
  8. #include <asm/reg.h>
  9. #define CLOCK_TICK_RATE 1024000 /* Underlying HZ */
  10. typedef unsigned long cycles_t;
  11. static inline cycles_t get_cycles(void)
  12. {
  13. #ifdef __powerpc64__
  14. return mftb();
  15. #else
  16. cycles_t ret;
  17. /*
  18. * For the "cycle" counter we use the timebase lower half.
  19. * Currently only used on SMP.
  20. */
  21. ret = 0;
  22. __asm__ __volatile__(
  23. #ifdef CONFIG_8xx
  24. "97: mftb %0\n"
  25. #else
  26. "97: mfspr %0, %2\n"
  27. #endif
  28. "99:\n"
  29. ".section __ftr_fixup,\"a\"\n"
  30. ".align 2\n"
  31. "98:\n"
  32. " .long %1\n"
  33. " .long 0\n"
  34. " .long 97b-98b\n"
  35. " .long 99b-98b\n"
  36. " .long 0\n"
  37. " .long 0\n"
  38. ".previous"
  39. #ifdef CONFIG_8xx
  40. : "=r" (ret) : "i" (CPU_FTR_601));
  41. #else
  42. : "=r" (ret) : "i" (CPU_FTR_601), "i" (SPRN_TBRL));
  43. #endif
  44. return ret;
  45. #endif
  46. }
  47. #endif /* __KERNEL__ */
  48. #endif /* _ASM_POWERPC_TIMEX_H */