mt_cpufreq_hybrid.h 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  1. #ifndef _MT_CPUFREQ_HYBRID_
  2. #define _MT_CPUFREQ_HYBRID_
  3. #include <linux/kernel.h>
  4. /**************************************
  5. * [Hybrid DVFS] Config
  6. **************************************/
  7. #if defined(CONFIG_ARCH_MT6755)
  8. #define CONFIG_HYBRID_CPU_DVFS
  9. /*#define __TRIAL_RUN__*/
  10. #elif defined(CONFIG_ARCH_MT6797)
  11. /*#define CONFIG_HYBRID_CPU_DVFS*/
  12. /*#define __TRIAL_RUN__*/
  13. #endif
  14. /**************************************
  15. * [Hybrid DVFS] Parameter
  16. **************************************/
  17. #if defined(CONFIG_ARCH_MT6797)
  18. enum cpu_cluster {
  19. CPU_CLUSTER_LL,
  20. CPU_CLUSTER_L,
  21. CPU_CLUSTER_B,
  22. CPU_CLUSTER_CCI, /* virtual */
  23. NUM_CPU_CLUSTER
  24. };
  25. #define NUM_PHY_CLUSTER (NUM_CPU_CLUSTER - 1)
  26. #define NUM_CPU_OPP 16
  27. #else /* CONFIG_ARCH_MT6755 */
  28. enum cpu_cluster {
  29. CPU_CLUSTER_LL,
  30. CPU_CLUSTER_L,
  31. NUM_CPU_CLUSTER
  32. };
  33. #define NUM_PHY_CLUSTER NUM_CPU_CLUSTER
  34. #define NUM_CPU_OPP 8
  35. #endif
  36. /**************************************
  37. * [Hybrid DVFS] Definition
  38. **************************************/
  39. #define OPP_AT_SUSPEND UINT_MAX
  40. #define VOLT_AT_SUSPEND UINT_MAX
  41. #define CEILING_AT_SUSPEND UINT_MAX
  42. #define FLOOR_AT_SUSPEND UINT_MAX
  43. enum sema_user {
  44. SEMA_FHCTL_DRV,
  45. SEMA_I2C_DRV,
  46. NUM_SEMA_USER
  47. };
  48. enum pause_src {
  49. PAUSE_INIT,
  50. PAUSE_I2CDRV,
  51. PAUSE_IDLE,
  52. PAUSE_SUSPEND,
  53. NUM_PAUSE_SRC
  54. };
  55. struct init_sta {
  56. unsigned int opp[NUM_CPU_CLUSTER]; /* SW index */
  57. unsigned int freq[NUM_CPU_CLUSTER]; /* KHz */
  58. unsigned int volt[NUM_CPU_CLUSTER]; /* PMIC value */
  59. unsigned int ceiling[NUM_CPU_CLUSTER]; /* SW index */
  60. unsigned int floor[NUM_CPU_CLUSTER]; /* SW index */
  61. bool is_on[NUM_CPU_CLUSTER]; /* on/off */
  62. };
  63. /**************************************
  64. * [Hybrid DVFS] Macro / Inline
  65. **************************************/
  66. static inline unsigned int opp_limit_to_ceiling(int limit)
  67. {
  68. unsigned int ceiling;
  69. if (limit >= 0)
  70. ceiling = (limit < NUM_CPU_OPP ? limit : NUM_CPU_OPP - 1);
  71. else /* no limit */
  72. ceiling = 0;
  73. return ceiling;
  74. }
  75. static inline unsigned int opp_limit_to_floor(int limit)
  76. {
  77. unsigned int floor;
  78. if (limit >= 0)
  79. floor = (limit < NUM_CPU_OPP ? limit : NUM_CPU_OPP - 1);
  80. else /* no limit */
  81. floor = NUM_CPU_OPP - 1;
  82. return floor;
  83. }
  84. /**************************************
  85. * [Hybrid DVFS] API
  86. **************************************/
  87. #ifdef CONFIG_HYBRID_CPU_DVFS
  88. extern int cpuhvfs_module_init(void);
  89. extern int cpuhvfs_kick_dvfsp_to_run(struct init_sta *sta);
  90. extern void cpuhvfs_notify_cluster_on(unsigned int cluster);
  91. extern void cpuhvfs_notify_cluster_off(unsigned int cluster);
  92. extern int cpuhvfs_set_target_opp(unsigned int cluster, unsigned int index, unsigned int *ret_volt);
  93. extern unsigned int cpuhvfs_get_curr_volt(unsigned int cluster);
  94. extern int cpuhvfs_get_dvfsp_semaphore(enum sema_user user);
  95. extern void cpuhvfs_release_dvfsp_semaphore(enum sema_user user);
  96. extern int cpuhvfs_pause_dvfsp_running(enum pause_src src);
  97. extern void cpuhvfs_unpause_dvfsp_to_run(enum pause_src src);
  98. extern int cpuhvfs_stop_dvfsp_running(void);
  99. extern int cpuhvfs_restart_dvfsp_running(struct init_sta *sta);
  100. extern int cpuhvfs_dvfsp_suspend(void);
  101. extern void cpuhvfs_dvfsp_resume(unsigned int on_cluster, struct init_sta *sta);
  102. extern void cpuhvfs_dump_dvfsp_info(void);
  103. #else
  104. static inline int cpuhvfs_module_init(void) { return -ENODEV; }
  105. static inline int cpuhvfs_kick_dvfsp_to_run(struct init_sta *sta) { return -ENODEV; }
  106. static inline void cpuhvfs_notify_cluster_on(unsigned int cluster) {}
  107. static inline void cpuhvfs_notify_cluster_off(unsigned int cluster) { BUG(); }
  108. static inline int cpuhvfs_set_target_opp(unsigned int cluster, unsigned int index,
  109. unsigned int *ret_volt) { return -ENODEV; }
  110. static inline unsigned int cpuhvfs_get_curr_volt(unsigned int cluster) { return UINT_MAX; }
  111. static inline int cpuhvfs_get_dvfsp_semaphore(enum sema_user user) { return 0; }
  112. static inline void cpuhvfs_release_dvfsp_semaphore(enum sema_user user) {}
  113. static inline int cpuhvfs_pause_dvfsp_running(enum pause_src src) { return 0; }
  114. static inline void cpuhvfs_unpause_dvfsp_to_run(enum pause_src src) {}
  115. static inline int cpuhvfs_stop_dvfsp_running(void) { return 0; }
  116. static inline int cpuhvfs_restart_dvfsp_running(struct init_sta *sta) { return -ENODEV; }
  117. static inline int cpuhvfs_dvfsp_suspend(void) { return 0; }
  118. static inline void cpuhvfs_dvfsp_resume(unsigned int on_cluster, struct init_sta *sta) {}
  119. static inline void cpuhvfs_dump_dvfsp_info(void) {}
  120. #endif
  121. #endif /* _MT_CPUFREQ_HYBRID_ */