eventinit.c 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196
  1. /*
  2. * Copyright 2015 Advanced Micro Devices, Inc.
  3. *
  4. * Permission is hereby granted, free of charge, to any person obtaining a
  5. * copy of this software and associated documentation files (the "Software"),
  6. * to deal in the Software without restriction, including without limitation
  7. * the rights to use, copy, modify, merge, publish, distribute, sublicense,
  8. * and/or sell copies of the Software, and to permit persons to whom the
  9. * Software is furnished to do so, subject to the following conditions:
  10. *
  11. * The above copyright notice and this permission notice shall be included in
  12. * all copies or substantial portions of the Software.
  13. *
  14. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  15. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  16. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
  17. * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
  18. * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
  19. * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
  20. * OTHER DEALINGS IN THE SOFTWARE.
  21. *
  22. */
  23. #include "eventmgr.h"
  24. #include "eventinit.h"
  25. #include "ppinterrupt.h"
  26. #include "hardwaremanager.h"
  27. void pem_init_feature_info(struct pp_eventmgr *eventmgr)
  28. {
  29. /* PowerPlay info */
  30. eventmgr->ui_state_info[PP_PowerSource_AC].default_ui_lable =
  31. PP_StateUILabel_Performance;
  32. eventmgr->ui_state_info[PP_PowerSource_AC].current_ui_label =
  33. PP_StateUILabel_Performance;
  34. eventmgr->ui_state_info[PP_PowerSource_DC].default_ui_lable =
  35. PP_StateUILabel_Battery;
  36. eventmgr->ui_state_info[PP_PowerSource_DC].current_ui_label =
  37. PP_StateUILabel_Battery;
  38. if (phm_cap_enabled(eventmgr->platform_descriptor->platformCaps, PHM_PlatformCaps_PowerPlaySupport)) {
  39. eventmgr->features[PP_Feature_PowerPlay].supported = true;
  40. eventmgr->features[PP_Feature_PowerPlay].version = PEM_CURRENT_POWERPLAY_FEATURE_VERSION;
  41. eventmgr->features[PP_Feature_PowerPlay].enabled_default = true;
  42. eventmgr->features[PP_Feature_PowerPlay].enabled = true;
  43. } else {
  44. eventmgr->features[PP_Feature_PowerPlay].supported = false;
  45. eventmgr->features[PP_Feature_PowerPlay].enabled = false;
  46. eventmgr->features[PP_Feature_PowerPlay].enabled_default = false;
  47. }
  48. eventmgr->features[PP_Feature_Force3DClock].supported = true;
  49. eventmgr->features[PP_Feature_Force3DClock].enabled = false;
  50. eventmgr->features[PP_Feature_Force3DClock].enabled_default = false;
  51. eventmgr->features[PP_Feature_Force3DClock].version = 1;
  52. /* over drive*/
  53. eventmgr->features[PP_Feature_User2DPerformance].version = 4;
  54. eventmgr->features[PP_Feature_User3DPerformance].version = 4;
  55. eventmgr->features[PP_Feature_OverdriveTest].version = 4;
  56. eventmgr->features[PP_Feature_OverDrive].version = 4;
  57. eventmgr->features[PP_Feature_OverDrive].enabled = false;
  58. eventmgr->features[PP_Feature_OverDrive].enabled_default = false;
  59. eventmgr->features[PP_Feature_User2DPerformance].supported = false;
  60. eventmgr->features[PP_Feature_User2DPerformance].enabled = false;
  61. eventmgr->features[PP_Feature_User2DPerformance].enabled_default = false;
  62. eventmgr->features[PP_Feature_User3DPerformance].supported = false;
  63. eventmgr->features[PP_Feature_User3DPerformance].enabled = false;
  64. eventmgr->features[PP_Feature_User3DPerformance].enabled_default = false;
  65. eventmgr->features[PP_Feature_OverdriveTest].supported = false;
  66. eventmgr->features[PP_Feature_OverdriveTest].enabled = false;
  67. eventmgr->features[PP_Feature_OverdriveTest].enabled_default = false;
  68. eventmgr->features[PP_Feature_OverDrive].supported = false;
  69. eventmgr->features[PP_Feature_PowerBudgetWaiver].enabled_default = false;
  70. eventmgr->features[PP_Feature_PowerBudgetWaiver].version = 1;
  71. eventmgr->features[PP_Feature_PowerBudgetWaiver].supported = false;
  72. eventmgr->features[PP_Feature_PowerBudgetWaiver].enabled = false;
  73. /* Multi UVD States support */
  74. eventmgr->features[PP_Feature_MultiUVDState].supported = false;
  75. eventmgr->features[PP_Feature_MultiUVDState].enabled = false;
  76. eventmgr->features[PP_Feature_MultiUVDState].enabled_default = false;
  77. /* Dynamic UVD States support */
  78. eventmgr->features[PP_Feature_DynamicUVDState].supported = false;
  79. eventmgr->features[PP_Feature_DynamicUVDState].enabled = false;
  80. eventmgr->features[PP_Feature_DynamicUVDState].enabled_default = false;
  81. /* VCE DPM support */
  82. eventmgr->features[PP_Feature_VCEDPM].supported = false;
  83. eventmgr->features[PP_Feature_VCEDPM].enabled = false;
  84. eventmgr->features[PP_Feature_VCEDPM].enabled_default = false;
  85. /* ACP PowerGating support */
  86. eventmgr->features[PP_Feature_ACP_POWERGATING].supported = false;
  87. eventmgr->features[PP_Feature_ACP_POWERGATING].enabled = false;
  88. eventmgr->features[PP_Feature_ACP_POWERGATING].enabled_default = false;
  89. /* PPM support */
  90. eventmgr->features[PP_Feature_PPM].version = 1;
  91. eventmgr->features[PP_Feature_PPM].supported = false;
  92. eventmgr->features[PP_Feature_PPM].enabled = false;
  93. /* FFC support (enables fan and temp settings, Gemini needs temp settings) */
  94. if (phm_cap_enabled(eventmgr->platform_descriptor->platformCaps, PHM_PlatformCaps_ODFuzzyFanControlSupport) ||
  95. phm_cap_enabled(eventmgr->platform_descriptor->platformCaps, PHM_PlatformCaps_GeminiRegulatorFanControlSupport)) {
  96. eventmgr->features[PP_Feature_FFC].version = 1;
  97. eventmgr->features[PP_Feature_FFC].supported = true;
  98. eventmgr->features[PP_Feature_FFC].enabled = true;
  99. eventmgr->features[PP_Feature_FFC].enabled_default = true;
  100. } else {
  101. eventmgr->features[PP_Feature_FFC].supported = false;
  102. eventmgr->features[PP_Feature_FFC].enabled = false;
  103. eventmgr->features[PP_Feature_FFC].enabled_default = false;
  104. }
  105. eventmgr->features[PP_Feature_VariBright].supported = false;
  106. eventmgr->features[PP_Feature_VariBright].enabled = false;
  107. eventmgr->features[PP_Feature_VariBright].enabled_default = false;
  108. eventmgr->features[PP_Feature_BACO].supported = false;
  109. eventmgr->features[PP_Feature_BACO].supported = false;
  110. eventmgr->features[PP_Feature_BACO].enabled_default = false;
  111. /* PowerDown feature support */
  112. eventmgr->features[PP_Feature_PowerDown].supported = false;
  113. eventmgr->features[PP_Feature_PowerDown].enabled = false;
  114. eventmgr->features[PP_Feature_PowerDown].enabled_default = false;
  115. eventmgr->features[PP_Feature_FPS].version = 1;
  116. eventmgr->features[PP_Feature_FPS].supported = false;
  117. eventmgr->features[PP_Feature_FPS].enabled_default = false;
  118. eventmgr->features[PP_Feature_FPS].enabled = false;
  119. eventmgr->features[PP_Feature_ViPG].version = 1;
  120. eventmgr->features[PP_Feature_ViPG].supported = false;
  121. eventmgr->features[PP_Feature_ViPG].enabled_default = false;
  122. eventmgr->features[PP_Feature_ViPG].enabled = false;
  123. }
  124. static int thermal_interrupt_callback(void *private_data,
  125. unsigned src_id, const uint32_t *iv_entry)
  126. {
  127. /* TO DO hanle PEM_Event_ThermalNotification (struct pp_eventmgr *)private_data*/
  128. pr_info("current thermal is out of range \n");
  129. return 0;
  130. }
  131. int pem_register_interrupts(struct pp_eventmgr *eventmgr)
  132. {
  133. int result = 0;
  134. struct pp_interrupt_registration_info info;
  135. info.call_back = thermal_interrupt_callback;
  136. info.context = eventmgr;
  137. result = phm_register_thermal_interrupt(eventmgr->hwmgr, &info);
  138. /* TODO:
  139. * 2. Register CTF event interrupt
  140. * 3. Register for vbios events interrupt
  141. * 4. Register External Throttle Interrupt
  142. * 5. Register Smc To Host Interrupt
  143. * */
  144. return result;
  145. }
  146. int pem_unregister_interrupts(struct pp_eventmgr *eventmgr)
  147. {
  148. return 0;
  149. }
  150. void pem_uninit_featureInfo(struct pp_eventmgr *eventmgr)
  151. {
  152. eventmgr->features[PP_Feature_MultiUVDState].supported = false;
  153. eventmgr->features[PP_Feature_VariBright].supported = false;
  154. eventmgr->features[PP_Feature_PowerBudgetWaiver].supported = false;
  155. eventmgr->features[PP_Feature_OverDrive].supported = false;
  156. eventmgr->features[PP_Feature_OverdriveTest].supported = false;
  157. eventmgr->features[PP_Feature_User3DPerformance].supported = false;
  158. eventmgr->features[PP_Feature_User2DPerformance].supported = false;
  159. eventmgr->features[PP_Feature_PowerPlay].supported = false;
  160. eventmgr->features[PP_Feature_Force3DClock].supported = false;
  161. }