smu7_hwmgr.h 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354
  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. #ifndef _SMU7_HWMGR_H
  24. #define _SMU7_HWMGR_H
  25. #include "hwmgr.h"
  26. #include "ppatomctrl.h"
  27. #define SMU7_MAX_HARDWARE_POWERLEVELS 2
  28. #define SMU7_VOLTAGE_CONTROL_NONE 0x0
  29. #define SMU7_VOLTAGE_CONTROL_BY_GPIO 0x1
  30. #define SMU7_VOLTAGE_CONTROL_BY_SVID2 0x2
  31. #define SMU7_VOLTAGE_CONTROL_MERGED 0x3
  32. #define DPMTABLE_OD_UPDATE_SCLK 0x00000001
  33. #define DPMTABLE_OD_UPDATE_MCLK 0x00000002
  34. #define DPMTABLE_UPDATE_SCLK 0x00000004
  35. #define DPMTABLE_UPDATE_MCLK 0x00000008
  36. enum gpu_pt_config_reg_type {
  37. GPU_CONFIGREG_MMR = 0,
  38. GPU_CONFIGREG_SMC_IND,
  39. GPU_CONFIGREG_DIDT_IND,
  40. GPU_CONFIGREG_GC_CAC_IND,
  41. GPU_CONFIGREG_CACHE,
  42. GPU_CONFIGREG_MAX
  43. };
  44. struct gpu_pt_config_reg {
  45. uint32_t offset;
  46. uint32_t mask;
  47. uint32_t shift;
  48. uint32_t value;
  49. enum gpu_pt_config_reg_type type;
  50. };
  51. struct smu7_performance_level {
  52. uint32_t memory_clock;
  53. uint32_t engine_clock;
  54. uint16_t pcie_gen;
  55. uint16_t pcie_lane;
  56. };
  57. struct smu7_thermal_temperature_setting {
  58. long temperature_low;
  59. long temperature_high;
  60. long temperature_shutdown;
  61. };
  62. struct smu7_uvd_clocks {
  63. uint32_t vclk;
  64. uint32_t dclk;
  65. };
  66. struct smu7_vce_clocks {
  67. uint32_t evclk;
  68. uint32_t ecclk;
  69. };
  70. struct smu7_power_state {
  71. uint32_t magic;
  72. struct smu7_uvd_clocks uvd_clks;
  73. struct smu7_vce_clocks vce_clks;
  74. uint32_t sam_clk;
  75. uint16_t performance_level_count;
  76. bool dc_compatible;
  77. uint32_t sclk_threshold;
  78. struct smu7_performance_level performance_levels[SMU7_MAX_HARDWARE_POWERLEVELS];
  79. };
  80. struct smu7_dpm_level {
  81. bool enabled;
  82. uint32_t value;
  83. uint32_t param1;
  84. };
  85. #define SMU7_MAX_DEEPSLEEP_DIVIDER_ID 5
  86. #define MAX_REGULAR_DPM_NUMBER 8
  87. #define SMU7_MINIMUM_ENGINE_CLOCK 2500
  88. struct smu7_single_dpm_table {
  89. uint32_t count;
  90. struct smu7_dpm_level dpm_levels[MAX_REGULAR_DPM_NUMBER];
  91. };
  92. struct smu7_dpm_table {
  93. struct smu7_single_dpm_table sclk_table;
  94. struct smu7_single_dpm_table mclk_table;
  95. struct smu7_single_dpm_table pcie_speed_table;
  96. struct smu7_single_dpm_table vddc_table;
  97. struct smu7_single_dpm_table vddci_table;
  98. struct smu7_single_dpm_table mvdd_table;
  99. };
  100. struct smu7_clock_registers {
  101. uint32_t vCG_SPLL_FUNC_CNTL;
  102. uint32_t vCG_SPLL_FUNC_CNTL_2;
  103. uint32_t vCG_SPLL_FUNC_CNTL_3;
  104. uint32_t vCG_SPLL_FUNC_CNTL_4;
  105. uint32_t vCG_SPLL_SPREAD_SPECTRUM;
  106. uint32_t vCG_SPLL_SPREAD_SPECTRUM_2;
  107. uint32_t vDLL_CNTL;
  108. uint32_t vMCLK_PWRMGT_CNTL;
  109. uint32_t vMPLL_AD_FUNC_CNTL;
  110. uint32_t vMPLL_DQ_FUNC_CNTL;
  111. uint32_t vMPLL_FUNC_CNTL;
  112. uint32_t vMPLL_FUNC_CNTL_1;
  113. uint32_t vMPLL_FUNC_CNTL_2;
  114. uint32_t vMPLL_SS1;
  115. uint32_t vMPLL_SS2;
  116. };
  117. #define DISABLE_MC_LOADMICROCODE 1
  118. #define DISABLE_MC_CFGPROGRAMMING 2
  119. struct smu7_voltage_smio_registers {
  120. uint32_t vS0_VID_LOWER_SMIO_CNTL;
  121. };
  122. #define SMU7_MAX_LEAKAGE_COUNT 8
  123. struct smu7_leakage_voltage {
  124. uint16_t count;
  125. uint16_t leakage_id[SMU7_MAX_LEAKAGE_COUNT];
  126. uint16_t actual_voltage[SMU7_MAX_LEAKAGE_COUNT];
  127. };
  128. struct smu7_vbios_boot_state {
  129. uint16_t mvdd_bootup_value;
  130. uint16_t vddc_bootup_value;
  131. uint16_t vddci_bootup_value;
  132. uint16_t vddgfx_bootup_value;
  133. uint32_t sclk_bootup_value;
  134. uint32_t mclk_bootup_value;
  135. uint16_t pcie_gen_bootup_value;
  136. uint16_t pcie_lane_bootup_value;
  137. };
  138. struct smu7_display_timing {
  139. uint32_t min_clock_in_sr;
  140. uint32_t num_existing_displays;
  141. };
  142. struct smu7_dpmlevel_enable_mask {
  143. uint32_t uvd_dpm_enable_mask;
  144. uint32_t vce_dpm_enable_mask;
  145. uint32_t acp_dpm_enable_mask;
  146. uint32_t samu_dpm_enable_mask;
  147. uint32_t sclk_dpm_enable_mask;
  148. uint32_t mclk_dpm_enable_mask;
  149. uint32_t pcie_dpm_enable_mask;
  150. };
  151. struct smu7_pcie_perf_range {
  152. uint16_t max;
  153. uint16_t min;
  154. };
  155. struct smu7_hwmgr {
  156. struct smu7_dpm_table dpm_table;
  157. struct smu7_dpm_table golden_dpm_table;
  158. uint32_t voting_rights_clients0;
  159. uint32_t voting_rights_clients1;
  160. uint32_t voting_rights_clients2;
  161. uint32_t voting_rights_clients3;
  162. uint32_t voting_rights_clients4;
  163. uint32_t voting_rights_clients5;
  164. uint32_t voting_rights_clients6;
  165. uint32_t voting_rights_clients7;
  166. uint32_t static_screen_threshold_unit;
  167. uint32_t static_screen_threshold;
  168. uint32_t voltage_control;
  169. uint32_t vdd_gfx_control;
  170. uint32_t vddc_vddgfx_delta;
  171. uint32_t active_auto_throttle_sources;
  172. struct smu7_clock_registers clock_registers;
  173. bool is_memory_gddr5;
  174. uint16_t acpi_vddc;
  175. bool pspp_notify_required;
  176. uint16_t force_pcie_gen;
  177. uint16_t acpi_pcie_gen;
  178. uint32_t pcie_gen_cap;
  179. uint32_t pcie_lane_cap;
  180. uint32_t pcie_spc_cap;
  181. struct smu7_leakage_voltage vddc_leakage;
  182. struct smu7_leakage_voltage vddci_leakage;
  183. struct smu7_leakage_voltage vddcgfx_leakage;
  184. uint32_t mvdd_control;
  185. uint32_t vddc_mask_low;
  186. uint32_t mvdd_mask_low;
  187. uint16_t max_vddc_in_pptable;
  188. uint16_t min_vddc_in_pptable;
  189. uint16_t max_vddci_in_pptable;
  190. uint16_t min_vddci_in_pptable;
  191. bool is_uvd_enabled;
  192. struct smu7_vbios_boot_state vbios_boot_state;
  193. bool pcie_performance_request;
  194. bool battery_state;
  195. bool is_tlu_enabled;
  196. bool disable_handshake;
  197. bool smc_voltage_control_enabled;
  198. bool vbi_time_out_support;
  199. uint32_t soft_regs_start;
  200. /* ---- Stuff originally coming from Evergreen ---- */
  201. uint32_t vddci_control;
  202. struct pp_atomctrl_voltage_table vddc_voltage_table;
  203. struct pp_atomctrl_voltage_table vddci_voltage_table;
  204. struct pp_atomctrl_voltage_table mvdd_voltage_table;
  205. struct pp_atomctrl_voltage_table vddgfx_voltage_table;
  206. uint32_t mgcg_cgtt_local2;
  207. uint32_t mgcg_cgtt_local3;
  208. uint32_t gpio_debug;
  209. uint32_t mc_micro_code_feature;
  210. uint32_t highest_mclk;
  211. uint16_t acpi_vddci;
  212. uint8_t mvdd_high_index;
  213. uint8_t mvdd_low_index;
  214. bool dll_default_on;
  215. bool performance_request_registered;
  216. /* ---- Low Power Features ---- */
  217. bool ulv_supported;
  218. /* ---- CAC Stuff ---- */
  219. uint32_t cac_table_start;
  220. bool cac_configuration_required;
  221. bool driver_calculate_cac_leakage;
  222. bool cac_enabled;
  223. /* ---- DPM2 Parameters ---- */
  224. uint32_t power_containment_features;
  225. bool enable_dte_feature;
  226. bool enable_tdc_limit_feature;
  227. bool enable_pkg_pwr_tracking_feature;
  228. bool disable_uvd_power_tune_feature;
  229. uint32_t dte_tj_offset;
  230. uint32_t fast_watermark_threshold;
  231. /* ---- Phase Shedding ---- */
  232. uint8_t vddc_phase_shed_control;
  233. /* ---- DI/DT ---- */
  234. struct smu7_display_timing display_timing;
  235. /* ---- Thermal Temperature Setting ---- */
  236. struct smu7_thermal_temperature_setting thermal_temp_setting;
  237. struct smu7_dpmlevel_enable_mask dpm_level_enable_mask;
  238. uint32_t need_update_smu7_dpm_table;
  239. uint32_t sclk_dpm_key_disabled;
  240. uint32_t mclk_dpm_key_disabled;
  241. uint32_t pcie_dpm_key_disabled;
  242. uint32_t min_engine_clocks;
  243. struct smu7_pcie_perf_range pcie_gen_performance;
  244. struct smu7_pcie_perf_range pcie_lane_performance;
  245. struct smu7_pcie_perf_range pcie_gen_power_saving;
  246. struct smu7_pcie_perf_range pcie_lane_power_saving;
  247. bool use_pcie_performance_levels;
  248. bool use_pcie_power_saving_levels;
  249. uint32_t mclk_activity_target;
  250. uint32_t mclk_dpm0_activity_target;
  251. uint32_t low_sclk_interrupt_threshold;
  252. uint32_t last_mclk_dpm_enable_mask;
  253. bool uvd_enabled;
  254. /* ---- Power Gating States ---- */
  255. bool uvd_power_gated;
  256. bool vce_power_gated;
  257. bool samu_power_gated;
  258. bool need_long_memory_training;
  259. /* Application power optimization parameters */
  260. bool update_up_hyst;
  261. bool update_down_hyst;
  262. uint32_t down_hyst;
  263. uint32_t up_hyst;
  264. uint32_t disable_dpm_mask;
  265. bool apply_optimized_settings;
  266. uint32_t avfs_vdroop_override_setting;
  267. bool apply_avfs_cks_off_voltage;
  268. uint32_t frame_time_x2;
  269. uint16_t mem_latency_high;
  270. uint16_t mem_latency_low;
  271. };
  272. /* To convert to Q8.8 format for firmware */
  273. #define SMU7_Q88_FORMAT_CONVERSION_UNIT 256
  274. enum SMU7_I2CLineID {
  275. SMU7_I2CLineID_DDC1 = 0x90,
  276. SMU7_I2CLineID_DDC2 = 0x91,
  277. SMU7_I2CLineID_DDC3 = 0x92,
  278. SMU7_I2CLineID_DDC4 = 0x93,
  279. SMU7_I2CLineID_DDC5 = 0x94,
  280. SMU7_I2CLineID_DDC6 = 0x95,
  281. SMU7_I2CLineID_SCLSDA = 0x96,
  282. SMU7_I2CLineID_DDCVGA = 0x97
  283. };
  284. #define SMU7_I2C_DDC1DATA 0
  285. #define SMU7_I2C_DDC1CLK 1
  286. #define SMU7_I2C_DDC2DATA 2
  287. #define SMU7_I2C_DDC2CLK 3
  288. #define SMU7_I2C_DDC3DATA 4
  289. #define SMU7_I2C_DDC3CLK 5
  290. #define SMU7_I2C_SDA 40
  291. #define SMU7_I2C_SCL 41
  292. #define SMU7_I2C_DDC4DATA 65
  293. #define SMU7_I2C_DDC4CLK 66
  294. #define SMU7_I2C_DDC5DATA 0x48
  295. #define SMU7_I2C_DDC5CLK 0x49
  296. #define SMU7_I2C_DDC6DATA 0x4a
  297. #define SMU7_I2C_DDC6CLK 0x4b
  298. #define SMU7_I2C_DDCVGADATA 0x4c
  299. #define SMU7_I2C_DDCVGACLK 0x4d
  300. #define SMU7_UNUSED_GPIO_PIN 0x7F
  301. uint32_t smu7_get_xclk(struct pp_hwmgr *hwmgr);
  302. uint8_t smu7_get_sleep_divider_id_from_clock(uint32_t clock,
  303. uint32_t clock_insr);
  304. #endif