dvfs.h 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. /*
  2. * Copyright (c) 2019 Actions Semiconductor Co., Ltd
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. */
  6. /**
  7. * @file dynamic voltage and frequency scaling interface
  8. */
  9. #ifndef _DVFS_H_
  10. #define _DVFS_H_
  11. #ifndef _ASMLANGUAGE
  12. /*
  13. * dvfs levels
  14. */
  15. #define DVFS_LEVEL_LOW (10)
  16. #define DVFS_LEVEL_S2 (20)
  17. #define DVFS_LEVEL_NORMAL (30)
  18. #define DVFS_LEVEL_PERFORMANCE (40)
  19. #define DVFS_LEVEL_MID_PERFORMANCE (50)
  20. #define DVFS_LEVEL_HIGH_PERFORMANCE (60)
  21. #define DVFS_EVENT_PRE_CHANGE (1)
  22. #define DVFS_EVENT_POST_CHANGE (2)
  23. struct dvfs_freqs {
  24. uint8_t state; /* DVFS_EVENT_PRE_CHANGE / DVFS_EVENT_POST_CHANGE */
  25. uint8_t old_level;
  26. uint8_t new_level;
  27. };
  28. struct dvfs_level {
  29. uint8_t level_id;
  30. uint8_t enable_cnt;
  31. uint16_t cpu_freq;
  32. uint16_t dsp_freq;
  33. uint16_t gpu_freq;
  34. uint16_t de_freq;
  35. uint16_t jpeg_freq;
  36. uint16_t vdd_volt;
  37. };
  38. #ifdef CONFIG_ACTS_DVFS_DYNAMIC_LEVEL
  39. #ifdef CONFIG_DVFS_SECTION_CTX_IN_SRAM
  40. #define __dvfs_notifier_data __in_section_unique(sleep.noinit)
  41. #define __dvfs_notifier_func __in_section_unique(sleepfunc)
  42. #else
  43. #define __dvfs_notifier_data
  44. #define __dvfs_notifier_func __ramfunc
  45. #endif
  46. struct dvfs_notifier {
  47. sys_dnode_t node;
  48. void (*dvfs_notify_func_t)(void *user_data, struct dvfs_freqs *dvfs_freq);
  49. void *user_data;
  50. };
  51. int dvfs_set_freq_table(struct dvfs_level *dvfs_level_tbl, int level_cnt);
  52. int dvfs_get_current_level(void);
  53. int dvfs_set_level(int level_id, const char *user_info);
  54. int dvfs_unset_level(int level_id, const char *user_info);
  55. struct dvfs_level *dvfs_get_info_by_level_id(int level_id);
  56. int dvfs_register_notifier(struct dvfs_notifier *notifier);
  57. int dvfs_unregister_notifier(struct dvfs_notifier *notifier);
  58. int dvfs_force_set_level(int level_id, const char *user_info);
  59. int dvfs_force_unset_level(int level_id, const char *user_info);
  60. int dvfs_lock(void);
  61. int dvfs_unlock(void);
  62. #else
  63. #define dvfs_set_freq_table(dvfs_level_tbl, level_cnt) ({ 0; })
  64. #define dvfs_get_current_level() ({ 0; })
  65. #define dvfs_set_level(level_id, user_info) ({ 0; })
  66. #define dvfs_unset_level(level_id, user_info) ({ 0; })
  67. #define dvfs_get_info_by_level_id(level_id) ({ 0; })
  68. #define dvfs_register_notifier(notifier) ({ 0; })
  69. #define dvfs_unregister_notifier(notifier) ({ 0; })
  70. #define dvfs_force_set_level(level_id, user_info)({ 0; })
  71. #define dvfs_force_unset_level(level_id, user_info)({ 0; })
  72. #define dvfs_lock(void)({ 0; })
  73. #define dvfs_unlock(void)({ 0; })
  74. #endif /* CONFIG_ACTS_DVFS_DYNAMIC_LEVEL */
  75. #endif /* _ASMLANGUAGE */
  76. #endif /* _DVFS_H_ */