internal.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. #ifndef __MEMORY_LOWPOWER_INTERNAL_H
  2. #define __MEMORY_LOWPOWER_INTERNAL_H
  3. /* Memory Lowpower State & Action */
  4. enum power_state {
  5. MLP_INIT, /* Memory-lowpower is initialized */
  6. MLP_SCREENON,
  7. MLP_SCREENOFF,
  8. MLP_SCREENIDLE,
  9. MLP_ENABLE,
  10. MLP_ENABLE_DCS,
  11. MLP_ENABLE_PASR,
  12. };
  13. #define TEST_MEMORY_LOWPOWER_STATE(uname, lname) \
  14. static inline int Mlps##uname(unsigned long *state) \
  15. { return test_bit(MLP_##lname, state); }
  16. #define SET_MEMORY_LOWPOWER_STATE(uname, lname) \
  17. static inline void SetMlps##uname(unsigned long *state) \
  18. { set_bit(MLP_##lname, state); }
  19. #define CLEAR_MEMORY_LOWPOWER_STATE(uname, lname) \
  20. static inline void ClearMlps##uname(unsigned long *state) \
  21. { clear_bit(MLP_##lname, state); }
  22. #define MEMORY_LOWPOWER_STATE(uname, lname) (TEST_MEMORY_LOWPOWER_STATE(uname, lname) \
  23. SET_MEMORY_LOWPOWER_STATE(uname, lname) CLEAR_MEMORY_LOWPOWER_STATE(uname, lname))
  24. MEMORY_LOWPOWER_STATE(Init, INIT)
  25. MEMORY_LOWPOWER_STATE(ScreenOn, SCREENON) /*MEMORY_LOWPOWER_STATE(ScreenOff, SCREENOFF)*/
  26. MEMORY_LOWPOWER_STATE(ScreenIdle, SCREENIDLE)
  27. MEMORY_LOWPOWER_STATE(Enable, ENABLE)
  28. MEMORY_LOWPOWER_STATE(EnableDCS, ENABLE_DCS)
  29. MEMORY_LOWPOWER_STATE(EnablePASR, ENABLE_PASR)
  30. #define IS_ACTION_SCREENON(action) (action == MLP_SCREENON)
  31. #define IS_ACTION_SCREENOFF(action) (action == MLP_SCREENOFF)
  32. #define IS_ACTION_SCREENIDLE(action) (action == MLP_SCREENIDLE)
  33. /* Memory Lowpower Features & their operations */
  34. enum power_level {
  35. MLP_LEVEL_DCS,
  36. MLP_LEVEL_PASR,
  37. NR_MLP_LEVEL,
  38. };
  39. typedef void (*get_range_t) (int, unsigned long *, unsigned long *);
  40. /* Feature specific operations */
  41. struct memory_lowpower_operation {
  42. struct list_head link;
  43. enum power_level level;
  44. /*
  45. * Taking actions before entering this feature -
  46. * callee needs to issue func to get the range "times" times
  47. */
  48. int (*config)(int times, get_range_t func);
  49. /* Entering this feature */
  50. int (*enable)(void);
  51. /* Leaving this feature */
  52. int (*disable)(void);
  53. /* Taking actions after leaving this feature */
  54. int (*restore)(void);
  55. };
  56. /*
  57. * Examples for feature specific operations,
  58. *
  59. * DCS:
  60. * config - data collection, trigger LPDMA (4->2)
  61. * enable - Notify PowerMCU to turn off high channels
  62. * disable - Notify PowerMCU to turn on high channels
  63. * restore - trigger LPDMA (2->4)
  64. *
  65. * PASR:
  66. * config - Identify banks/ranks, trigger APMCU flow
  67. * enable - No operations (in the enable flow of DCS in PowerMCU/SPM)
  68. * disable - No operations (in the disable flow of DCS in PowerMCU/SPM)
  69. * restore - Trigger APMCU flow for reset
  70. *
  71. * (Not absolutely)
  72. * Operations are called in low to high level order for configure/enable.
  73. * Operations are called in reverse order for disable/restore.
  74. */
  75. extern void register_memory_lowpower_operation(struct memory_lowpower_operation *handler);
  76. extern void unregister_memory_lowpower_operation(struct memory_lowpower_operation *handler);
  77. /* memory-lowpower APIs */
  78. extern int get_memory_lowpower_cma(void);
  79. extern int put_memory_lowpower_cma(void);
  80. extern int get_memory_lowpower_cma_aligned(int count, unsigned int align, struct page **pages);
  81. extern int put_memory_lowpower_cma_aligned(int count, struct page *pages);
  82. extern int memory_lowpower_task_init(void);
  83. extern phys_addr_t memory_lowpower_cma_base(void);
  84. extern unsigned long memory_lowpower_cma_size(void);
  85. extern void set_memory_lowpower_aligned(int aligned);
  86. #endif /* __MEMORY_LOWPOWER_INTERNAL_H */