rv_hwmgr.h 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304
  1. /*
  2. * Copyright 2017 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. #ifndef RAVEN_HWMGR_H
  24. #define RAVEN_HWMGR_H
  25. #include "hwmgr.h"
  26. #include "rv_inc.h"
  27. #include "smu10_driver_if.h"
  28. #include "rv_ppsmc.h"
  29. #define RAVEN_MAX_HARDWARE_POWERLEVELS 8
  30. #define PHMRAVEN_DYNCLK_NUMBER_OF_TREND_COEFFICIENTS 15
  31. #define DPMFlags_SCLK_Enabled 0x00000001
  32. #define DPMFlags_UVD_Enabled 0x00000002
  33. #define DPMFlags_VCE_Enabled 0x00000004
  34. #define DPMFlags_ACP_Enabled 0x00000008
  35. #define DPMFlags_ForceHighestValid 0x40000000
  36. /* Do not change the following, it is also defined in SMU8.h */
  37. #define SMU_EnabledFeatureScoreboard_AcpDpmOn 0x00000001
  38. #define SMU_EnabledFeatureScoreboard_SclkDpmOn 0x00200000
  39. #define SMU_EnabledFeatureScoreboard_UvdDpmOn 0x01000000
  40. #define SMU_EnabledFeatureScoreboard_VceDpmOn 0x02000000
  41. #define SMU_PHYID_SHIFT 8
  42. #define RAVEN_PCIE_POWERGATING_TARGET_GFX 0
  43. #define RAVEN_PCIE_POWERGATING_TARGET_DDI 1
  44. #define RAVEN_PCIE_POWERGATING_TARGET_PLLCASCADE 2
  45. #define RAVEN_PCIE_POWERGATING_TARGET_PHY 3
  46. enum VQ_TYPE {
  47. CLOCK_TYPE_DCLK = 0L,
  48. CLOCK_TYPE_ECLK,
  49. CLOCK_TYPE_SCLK,
  50. CLOCK_TYPE_CCLK,
  51. VQ_GFX_CU
  52. };
  53. #define SUSTAINABLE_SCLK_MASK 0x00ffffff
  54. #define SUSTAINABLE_SCLK_SHIFT 0
  55. #define SUSTAINABLE_CU_MASK 0xff000000
  56. #define SUSTAINABLE_CU_SHIFT 24
  57. struct rv_dpm_entry {
  58. uint32_t soft_min_clk;
  59. uint32_t hard_min_clk;
  60. uint32_t soft_max_clk;
  61. uint32_t hard_max_clk;
  62. };
  63. struct rv_power_level {
  64. uint32_t engine_clock;
  65. uint8_t vddc_index;
  66. uint8_t ds_divider_index;
  67. uint8_t ss_divider_index;
  68. uint8_t allow_gnb_slow;
  69. uint8_t force_nbp_state;
  70. uint8_t display_wm;
  71. uint8_t vce_wm;
  72. uint8_t num_simd_to_powerdown;
  73. uint8_t hysteresis_up;
  74. uint8_t rsv[3];
  75. };
  76. /*used for the nbpsFlags field in rv_power state*/
  77. #define RAVEN_POWERSTATE_FLAGS_NBPS_FORCEHIGH (1<<0)
  78. #define RAVEN_POWERSTATE_FLAGS_NBPS_LOCKTOHIGH (1<<1)
  79. #define RAVEN_POWERSTATE_FLAGS_NBPS_LOCKTOLOW (1<<2)
  80. #define RAVEN_POWERSTATE_FLAGS_BAPM_DISABLE (1<<0)
  81. struct rv_uvd_clocks {
  82. uint32_t vclk;
  83. uint32_t dclk;
  84. uint32_t vclk_low_divider;
  85. uint32_t vclk_high_divider;
  86. uint32_t dclk_low_divider;
  87. uint32_t dclk_high_divider;
  88. };
  89. struct pp_disable_nbpslo_flags {
  90. union {
  91. struct {
  92. uint32_t entry : 1;
  93. uint32_t display : 1;
  94. uint32_t driver: 1;
  95. uint32_t vce : 1;
  96. uint32_t uvd : 1;
  97. uint32_t acp : 1;
  98. uint32_t reserved: 26;
  99. } bits;
  100. uint32_t u32All;
  101. };
  102. };
  103. enum rv_pstate_previous_action {
  104. DO_NOTHING = 1,
  105. FORCE_HIGH,
  106. CANCEL_FORCE_HIGH
  107. };
  108. struct rv_power_state {
  109. unsigned int magic;
  110. uint32_t level;
  111. struct rv_uvd_clocks uvd_clocks;
  112. uint32_t evclk;
  113. uint32_t ecclk;
  114. uint32_t samclk;
  115. uint32_t acpclk;
  116. bool need_dfs_bypass;
  117. uint32_t nbps_flags;
  118. uint32_t bapm_flags;
  119. uint8_t dpm0_pg_nbps_low;
  120. uint8_t dpm0_pg_nbps_high;
  121. uint8_t dpm_x_nbps_low;
  122. uint8_t dpm_x_nbps_high;
  123. enum rv_pstate_previous_action action;
  124. struct rv_power_level levels[RAVEN_MAX_HARDWARE_POWERLEVELS];
  125. struct pp_disable_nbpslo_flags nbpslo_flags;
  126. };
  127. #define RAVEN_NUM_NBPSTATES 4
  128. #define RAVEN_NUM_NBPMEMORYCLOCK 2
  129. struct rv_display_phy_info_entry {
  130. uint8_t phy_present;
  131. uint8_t active_lane_mapping;
  132. uint8_t display_config_type;
  133. uint8_t active_num_of_lanes;
  134. };
  135. #define RAVEN_MAX_DISPLAYPHY_IDS 10
  136. struct rv_display_phy_info {
  137. bool display_phy_access_initialized;
  138. struct rv_display_phy_info_entry entries[RAVEN_MAX_DISPLAYPHY_IDS];
  139. };
  140. #define MAX_DISPLAY_CLOCK_LEVEL 8
  141. struct rv_system_info{
  142. uint8_t htc_tmp_lmt;
  143. uint8_t htc_hyst_lmt;
  144. };
  145. #define MAX_REGULAR_DPM_NUMBER 8
  146. struct rv_mclk_latency_entries {
  147. uint32_t frequency;
  148. uint32_t latency;
  149. };
  150. struct rv_mclk_latency_table {
  151. uint32_t count;
  152. struct rv_mclk_latency_entries entries[MAX_REGULAR_DPM_NUMBER];
  153. };
  154. struct rv_clock_voltage_dependency_record {
  155. uint32_t clk;
  156. uint32_t vol;
  157. };
  158. struct rv_voltage_dependency_table {
  159. uint32_t count;
  160. struct rv_clock_voltage_dependency_record entries[1];
  161. };
  162. struct rv_clock_voltage_information {
  163. struct rv_voltage_dependency_table *vdd_dep_on_dcefclk;
  164. struct rv_voltage_dependency_table *vdd_dep_on_socclk;
  165. struct rv_voltage_dependency_table *vdd_dep_on_fclk;
  166. struct rv_voltage_dependency_table *vdd_dep_on_mclk;
  167. struct rv_voltage_dependency_table *vdd_dep_on_dispclk;
  168. struct rv_voltage_dependency_table *vdd_dep_on_dppclk;
  169. struct rv_voltage_dependency_table *vdd_dep_on_phyclk;
  170. };
  171. struct rv_hwmgr {
  172. uint32_t disable_driver_thermal_policy;
  173. uint32_t thermal_auto_throttling_treshold;
  174. struct rv_system_info sys_info;
  175. struct rv_mclk_latency_table mclk_latency_table;
  176. uint32_t ddi_power_gating_disabled;
  177. struct rv_display_phy_info_entry display_phy_info;
  178. uint32_t dce_slow_sclk_threshold;
  179. bool disp_clk_bypass;
  180. bool disp_clk_bypass_pending;
  181. uint32_t bapm_enabled;
  182. bool video_start;
  183. bool battery_state;
  184. uint32_t is_nb_dpm_enabled;
  185. uint32_t is_voltage_island_enabled;
  186. uint32_t disable_smu_acp_s3_handshake;
  187. uint32_t disable_notify_smu_vpu_recovery;
  188. bool in_vpu_recovery;
  189. bool pg_acp_init;
  190. uint8_t disp_config;
  191. /* PowerTune */
  192. uint32_t power_containment_features;
  193. bool cac_enabled;
  194. bool disable_uvd_power_tune_feature;
  195. bool enable_bapm_feature;
  196. bool enable_tdc_limit_feature;
  197. /* SMC SRAM Address of firmware header tables */
  198. uint32_t sram_end;
  199. uint32_t dpm_table_start;
  200. uint32_t soft_regs_start;
  201. /* start of SMU7_Fusion_DpmTable */
  202. uint8_t uvd_level_count;
  203. uint8_t vce_level_count;
  204. uint8_t acp_level_count;
  205. uint8_t samu_level_count;
  206. uint32_t fps_high_threshold;
  207. uint32_t fps_low_threshold;
  208. uint32_t dpm_flags;
  209. struct rv_dpm_entry sclk_dpm;
  210. struct rv_dpm_entry uvd_dpm;
  211. struct rv_dpm_entry vce_dpm;
  212. struct rv_dpm_entry acp_dpm;
  213. bool acp_power_up_no_dsp;
  214. uint32_t max_sclk_level;
  215. uint32_t num_of_clk_entries;
  216. /* CPU Power State */
  217. uint32_t separation_time;
  218. bool cc6_disable;
  219. bool pstate_disable;
  220. bool cc6_setting_changed;
  221. uint32_t ulTotalActiveCUs;
  222. bool isp_tileA_power_gated;
  223. bool isp_tileB_power_gated;
  224. uint32_t isp_actual_hard_min_freq;
  225. uint32_t soc_actual_hard_min_freq;
  226. uint32_t dcf_actual_hard_min_freq;
  227. uint32_t f_actual_hard_min_freq;
  228. uint32_t fabric_actual_soft_min_freq;
  229. uint32_t vclk_soft_min;
  230. uint32_t dclk_soft_min;
  231. uint32_t gfx_actual_soft_min_freq;
  232. bool vcn_power_gated;
  233. bool vcn_dpg_mode;
  234. bool gfx_off_controled_by_driver;
  235. Watermarks_t water_marks_table;
  236. struct rv_clock_voltage_information clock_vol_info;
  237. DpmClocks_t clock_table;
  238. uint32_t active_process_mask;
  239. bool need_min_deep_sleep_dcefclk; /* disabled by default */
  240. };
  241. struct pp_hwmgr;
  242. int rv_init_function_pointers(struct pp_hwmgr *hwmgr);
  243. #endif