cz_dpm.h 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237
  1. /*
  2. * Copyright 2014 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 __CZ_DPM_H__
  24. #define __CZ_DPM_H__
  25. #include "smu8_fusion.h"
  26. #define CZ_AT_DFLT 30
  27. #define CZ_NUM_NBPSTATES 4
  28. #define CZ_NUM_NBPMEMORY_CLOCK 2
  29. #define CZ_MAX_HARDWARE_POWERLEVELS 8
  30. #define CZ_MAX_DISPLAY_CLOCK_LEVEL 8
  31. #define CZ_MAX_DISPLAYPHY_IDS 10
  32. #define PPCZ_VOTINGRIGHTSCLIENTS_DFLT0 0x3FFFC102
  33. #define SMC_RAM_END 0x40000
  34. #define DPMFlags_SCLK_Enabled 0x00000001
  35. #define DPMFlags_UVD_Enabled 0x00000002
  36. #define DPMFlags_VCE_Enabled 0x00000004
  37. #define DPMFlags_ACP_Enabled 0x00000008
  38. #define DPMFlags_ForceHighestValid 0x40000000
  39. #define DPMFlags_Debug 0x80000000
  40. /* Do not change the following, it is also defined in SMU8.h */
  41. #define SMU_EnabledFeatureScoreboard_AcpDpmOn 0x00000001
  42. #define SMU_EnabledFeatureScoreboard_SclkDpmOn 0x00200000
  43. #define SMU_EnabledFeatureScoreboard_UvdDpmOn 0x00800000
  44. #define SMU_EnabledFeatureScoreboard_VceDpmOn 0x01000000
  45. /* temporary solution to SetMinDeepSleepSclk
  46. * should indicate by display adaptor
  47. * 10k Hz unit*/
  48. #define CZ_MIN_DEEP_SLEEP_SCLK 800
  49. enum cz_pt_config_reg_type {
  50. CZ_CONFIGREG_MMR = 0,
  51. CZ_CONFIGREG_SMC_IND,
  52. CZ_CONFIGREG_DIDT_IND,
  53. CZ_CONFIGREG_CACHE,
  54. CZ_CONFIGREG_MAX
  55. };
  56. struct cz_pt_config_reg {
  57. uint32_t offset;
  58. uint32_t mask;
  59. uint32_t shift;
  60. uint32_t value;
  61. enum cz_pt_config_reg_type type;
  62. };
  63. struct cz_dpm_entry {
  64. uint32_t soft_min_clk;
  65. uint32_t hard_min_clk;
  66. uint32_t soft_max_clk;
  67. uint32_t hard_max_clk;
  68. };
  69. struct cz_pl {
  70. uint32_t sclk;
  71. uint8_t vddc_index;
  72. uint8_t ds_divider_index;
  73. uint8_t ss_divider_index;
  74. uint8_t allow_gnb_slow;
  75. uint8_t force_nbp_state;
  76. uint8_t display_wm;
  77. uint8_t vce_wm;
  78. };
  79. struct cz_ps {
  80. struct cz_pl levels[CZ_MAX_HARDWARE_POWERLEVELS];
  81. uint32_t num_levels;
  82. bool need_dfs_bypass;
  83. uint8_t dpm0_pg_nb_ps_lo;
  84. uint8_t dpm0_pg_nb_ps_hi;
  85. uint8_t dpmx_nb_ps_lo;
  86. uint8_t dpmx_nb_ps_hi;
  87. bool force_high;
  88. };
  89. struct cz_displayphy_entry {
  90. uint8_t phy_present;
  91. uint8_t active_lane_mapping;
  92. uint8_t display_conf_type;
  93. uint8_t num_active_lanes;
  94. };
  95. struct cz_displayphy_info {
  96. bool phy_access_initialized;
  97. struct cz_displayphy_entry entries[CZ_MAX_DISPLAYPHY_IDS];
  98. };
  99. struct cz_sys_info {
  100. uint32_t bootup_uma_clk;
  101. uint32_t bootup_sclk;
  102. uint32_t dentist_vco_freq;
  103. uint32_t nb_dpm_enable;
  104. uint32_t nbp_memory_clock[CZ_NUM_NBPMEMORY_CLOCK];
  105. uint32_t nbp_n_clock[CZ_NUM_NBPSTATES];
  106. uint8_t nbp_voltage_index[CZ_NUM_NBPSTATES];
  107. uint32_t display_clock[CZ_MAX_DISPLAY_CLOCK_LEVEL];
  108. uint16_t bootup_nb_voltage_index;
  109. uint8_t htc_tmp_lmt;
  110. uint8_t htc_hyst_lmt;
  111. uint32_t uma_channel_number;
  112. };
  113. struct cz_power_info {
  114. uint32_t active_target[CZ_MAX_HARDWARE_POWERLEVELS];
  115. struct cz_sys_info sys_info;
  116. struct cz_pl boot_pl;
  117. bool disable_nb_ps3_in_battery;
  118. bool battery_state;
  119. uint32_t lowest_valid;
  120. uint32_t highest_valid;
  121. uint16_t high_voltage_threshold;
  122. /* smc offsets */
  123. uint32_t sram_end;
  124. uint32_t dpm_table_start;
  125. uint32_t soft_regs_start;
  126. /* dpm SMU tables */
  127. uint8_t uvd_level_count;
  128. uint8_t vce_level_count;
  129. uint8_t acp_level_count;
  130. uint32_t fps_high_threshold;
  131. uint32_t fps_low_threshold;
  132. /* dpm table */
  133. uint32_t dpm_flags;
  134. struct cz_dpm_entry sclk_dpm;
  135. struct cz_dpm_entry uvd_dpm;
  136. struct cz_dpm_entry vce_dpm;
  137. struct cz_dpm_entry acp_dpm;
  138. uint8_t uvd_boot_level;
  139. uint8_t uvd_interval;
  140. uint8_t vce_boot_level;
  141. uint8_t vce_interval;
  142. uint8_t acp_boot_level;
  143. uint8_t acp_interval;
  144. uint8_t graphics_boot_level;
  145. uint8_t graphics_interval;
  146. uint8_t graphics_therm_throttle_enable;
  147. uint8_t graphics_voltage_change_enable;
  148. uint8_t graphics_clk_slow_enable;
  149. uint8_t graphics_clk_slow_divider;
  150. uint32_t low_sclk_interrupt_threshold;
  151. bool uvd_power_gated;
  152. bool vce_power_gated;
  153. bool acp_power_gated;
  154. uint32_t active_process_mask;
  155. uint32_t mgcg_cgtt_local0;
  156. uint32_t mgcg_cgtt_local1;
  157. uint32_t clock_slow_down_step;
  158. uint32_t skip_clock_slow_down;
  159. bool enable_nb_ps_policy;
  160. uint32_t voting_clients;
  161. uint32_t voltage_drop_threshold;
  162. uint32_t gfx_pg_threshold;
  163. uint32_t max_sclk_level;
  164. /* flags */
  165. bool didt_enabled;
  166. bool video_start;
  167. bool cac_enabled;
  168. bool bapm_enabled;
  169. bool nb_dpm_enabled_by_driver;
  170. bool nb_dpm_enabled;
  171. bool auto_thermal_throttling_enabled;
  172. bool dpm_enabled;
  173. bool need_pptable_upload;
  174. /* caps */
  175. bool caps_cac;
  176. bool caps_power_containment;
  177. bool caps_sq_ramping;
  178. bool caps_db_ramping;
  179. bool caps_td_ramping;
  180. bool caps_tcp_ramping;
  181. bool caps_sclk_throttle_low_notification;
  182. bool caps_fps;
  183. bool caps_uvd_dpm;
  184. bool caps_uvd_pg;
  185. bool caps_vce_dpm;
  186. bool caps_vce_pg;
  187. bool caps_acp_dpm;
  188. bool caps_acp_pg;
  189. bool caps_stable_power_state;
  190. bool caps_enable_dfs_bypass;
  191. bool caps_sclk_ds;
  192. bool caps_voltage_island;
  193. /* power state */
  194. struct amdgpu_ps current_rps;
  195. struct cz_ps current_ps;
  196. struct amdgpu_ps requested_rps;
  197. struct cz_ps requested_ps;
  198. bool uvd_power_down;
  199. bool vce_power_down;
  200. bool acp_power_down;
  201. bool uvd_dynamic_pg;
  202. };
  203. /* cz_smc.c */
  204. uint32_t cz_get_argument(struct amdgpu_device *adev);
  205. int cz_send_msg_to_smc(struct amdgpu_device *adev, uint16_t msg);
  206. int cz_send_msg_to_smc_with_parameter(struct amdgpu_device *adev,
  207. uint16_t msg, uint32_t parameter);
  208. int cz_read_smc_sram_dword(struct amdgpu_device *adev,
  209. uint32_t smc_address, uint32_t *value, uint32_t limit);
  210. int cz_smu_upload_pptable(struct amdgpu_device *adev);
  211. int cz_smu_download_pptable(struct amdgpu_device *adev, void **table);
  212. #endif