cpuidle.h 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. #ifndef _ASM_POWERPC_CPUIDLE_H
  2. #define _ASM_POWERPC_CPUIDLE_H
  3. #ifdef CONFIG_PPC_POWERNV
  4. /* Used in powernv idle state management */
  5. #define PNV_THREAD_RUNNING 0
  6. #define PNV_THREAD_NAP 1
  7. #define PNV_THREAD_SLEEP 2
  8. #define PNV_THREAD_WINKLE 3
  9. #define PNV_CORE_IDLE_LOCK_BIT 0x100
  10. #define PNV_CORE_IDLE_THREAD_BITS 0x0FF
  11. /*
  12. * ============================ NOTE =================================
  13. * The older firmware populates only the RL field in the psscr_val and
  14. * sets the psscr_mask to 0xf. On such a firmware, the kernel sets the
  15. * remaining PSSCR fields to default values as follows:
  16. *
  17. * - ESL and EC bits are to 1. So wakeup from any stop state will be
  18. * at vector 0x100.
  19. *
  20. * - MTL and PSLL are set to the maximum allowed value as per the ISA,
  21. * i.e. 15.
  22. *
  23. * - The Transition Rate, TR is set to the Maximum value 3.
  24. */
  25. #define PSSCR_HV_DEFAULT_VAL (PSSCR_ESL | PSSCR_EC | \
  26. PSSCR_PSLL_MASK | PSSCR_TR_MASK | \
  27. PSSCR_MTL_MASK)
  28. #define PSSCR_HV_DEFAULT_MASK (PSSCR_ESL | PSSCR_EC | \
  29. PSSCR_PSLL_MASK | PSSCR_TR_MASK | \
  30. PSSCR_MTL_MASK | PSSCR_RL_MASK)
  31. #define PSSCR_EC_SHIFT 20
  32. #define PSSCR_ESL_SHIFT 21
  33. #define GET_PSSCR_EC(x) (((x) & PSSCR_EC) >> PSSCR_EC_SHIFT)
  34. #define GET_PSSCR_ESL(x) (((x) & PSSCR_ESL) >> PSSCR_ESL_SHIFT)
  35. #define GET_PSSCR_RL(x) ((x) & PSSCR_RL_MASK)
  36. #define ERR_EC_ESL_MISMATCH -1
  37. #define ERR_DEEP_STATE_ESL_MISMATCH -2
  38. #ifndef __ASSEMBLY__
  39. extern u32 pnv_fastsleep_workaround_at_entry[];
  40. extern u32 pnv_fastsleep_workaround_at_exit[];
  41. extern u64 pnv_first_deep_stop_state;
  42. int validate_psscr_val_mask(u64 *psscr_val, u64 *psscr_mask, u32 flags);
  43. static inline void report_invalid_psscr_val(u64 psscr_val, int err)
  44. {
  45. switch (err) {
  46. case ERR_EC_ESL_MISMATCH:
  47. pr_warn("Invalid psscr 0x%016llx : ESL,EC bits unequal",
  48. psscr_val);
  49. break;
  50. case ERR_DEEP_STATE_ESL_MISMATCH:
  51. pr_warn("Invalid psscr 0x%016llx : ESL cleared for deep stop-state",
  52. psscr_val);
  53. }
  54. }
  55. #endif
  56. #endif
  57. /* Idle state entry routines */
  58. #ifdef CONFIG_PPC_P7_NAP
  59. #define IDLE_STATE_ENTER_SEQ(IDLE_INST) \
  60. /* Magic NAP/SLEEP/WINKLE mode enter sequence */ \
  61. std r0,0(r1); \
  62. ptesync; \
  63. ld r0,0(r1); \
  64. 236: cmpd cr0,r0,r0; \
  65. bne 236b; \
  66. IDLE_INST; \
  67. #define IDLE_STATE_ENTER_SEQ_NORET(IDLE_INST) \
  68. IDLE_STATE_ENTER_SEQ(IDLE_INST) \
  69. b .
  70. #endif /* CONFIG_PPC_P7_NAP */
  71. #endif