kv_dpm.h 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200
  1. /*
  2. * Copyright 2013 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 __KV_DPM_H__
  24. #define __KV_DPM_H__
  25. #define SMU__NUM_SCLK_DPM_STATE 8
  26. #define SMU__NUM_MCLK_DPM_LEVELS 4
  27. #define SMU__NUM_LCLK_DPM_LEVELS 8
  28. #define SMU__NUM_PCIE_DPM_LEVELS 0 /* ??? */
  29. #include "smu7_fusion.h"
  30. #include "trinity_dpm.h"
  31. #include "ppsmc.h"
  32. #define KV_NUM_NBPSTATES 4
  33. enum kv_pt_config_reg_type {
  34. KV_CONFIGREG_MMR = 0,
  35. KV_CONFIGREG_SMC_IND,
  36. KV_CONFIGREG_DIDT_IND,
  37. KV_CONFIGREG_CACHE,
  38. KV_CONFIGREG_MAX
  39. };
  40. struct kv_pt_config_reg {
  41. u32 offset;
  42. u32 mask;
  43. u32 shift;
  44. u32 value;
  45. enum kv_pt_config_reg_type type;
  46. };
  47. struct kv_lcac_config_values {
  48. u32 block_id;
  49. u32 signal_id;
  50. u32 t;
  51. };
  52. struct kv_lcac_config_reg {
  53. u32 cntl;
  54. u32 block_mask;
  55. u32 block_shift;
  56. u32 signal_mask;
  57. u32 signal_shift;
  58. u32 t_mask;
  59. u32 t_shift;
  60. u32 enable_mask;
  61. u32 enable_shift;
  62. };
  63. struct kv_pl {
  64. u32 sclk;
  65. u8 vddc_index;
  66. u8 ds_divider_index;
  67. u8 ss_divider_index;
  68. u8 allow_gnb_slow;
  69. u8 force_nbp_state;
  70. u8 display_wm;
  71. u8 vce_wm;
  72. };
  73. struct kv_ps {
  74. struct kv_pl levels[SUMO_MAX_HARDWARE_POWERLEVELS];
  75. u32 num_levels;
  76. bool need_dfs_bypass;
  77. u8 dpm0_pg_nb_ps_lo;
  78. u8 dpm0_pg_nb_ps_hi;
  79. u8 dpmx_nb_ps_lo;
  80. u8 dpmx_nb_ps_hi;
  81. };
  82. struct kv_sys_info {
  83. u32 bootup_uma_clk;
  84. u32 bootup_sclk;
  85. u32 dentist_vco_freq;
  86. u32 nb_dpm_enable;
  87. u32 nbp_memory_clock[KV_NUM_NBPSTATES];
  88. u32 nbp_n_clock[KV_NUM_NBPSTATES];
  89. u16 bootup_nb_voltage_index;
  90. u8 htc_tmp_lmt;
  91. u8 htc_hyst_lmt;
  92. struct sumo_sclk_voltage_mapping_table sclk_voltage_mapping_table;
  93. struct sumo_vid_mapping_table vid_mapping_table;
  94. u32 uma_channel_number;
  95. };
  96. struct kv_power_info {
  97. u32 at[SUMO_MAX_HARDWARE_POWERLEVELS];
  98. u32 voltage_drop_t;
  99. struct kv_sys_info sys_info;
  100. struct kv_pl boot_pl;
  101. bool enable_nb_ps_policy;
  102. bool disable_nb_ps3_in_battery;
  103. bool video_start;
  104. bool battery_state;
  105. u32 lowest_valid;
  106. u32 highest_valid;
  107. u16 high_voltage_t;
  108. bool cac_enabled;
  109. bool bapm_enable;
  110. /* smc offsets */
  111. u32 sram_end;
  112. u32 dpm_table_start;
  113. u32 soft_regs_start;
  114. /* dpm SMU tables */
  115. u8 graphics_dpm_level_count;
  116. u8 uvd_level_count;
  117. u8 vce_level_count;
  118. u8 acp_level_count;
  119. u8 samu_level_count;
  120. u16 fps_high_t;
  121. SMU7_Fusion_GraphicsLevel graphics_level[SMU__NUM_SCLK_DPM_STATE];
  122. SMU7_Fusion_ACPILevel acpi_level;
  123. SMU7_Fusion_UvdLevel uvd_level[SMU7_MAX_LEVELS_UVD];
  124. SMU7_Fusion_ExtClkLevel vce_level[SMU7_MAX_LEVELS_VCE];
  125. SMU7_Fusion_ExtClkLevel acp_level[SMU7_MAX_LEVELS_ACP];
  126. SMU7_Fusion_ExtClkLevel samu_level[SMU7_MAX_LEVELS_SAMU];
  127. u8 uvd_boot_level;
  128. u8 vce_boot_level;
  129. u8 acp_boot_level;
  130. u8 samu_boot_level;
  131. u8 uvd_interval;
  132. u8 vce_interval;
  133. u8 acp_interval;
  134. u8 samu_interval;
  135. u8 graphics_boot_level;
  136. u8 graphics_interval;
  137. u8 graphics_therm_throttle_enable;
  138. u8 graphics_voltage_change_enable;
  139. u8 graphics_clk_slow_enable;
  140. u8 graphics_clk_slow_divider;
  141. u8 fps_low_t;
  142. u32 low_sclk_interrupt_t;
  143. bool uvd_power_gated;
  144. bool vce_power_gated;
  145. bool acp_power_gated;
  146. bool samu_power_gated;
  147. bool nb_dpm_enabled;
  148. /* flags */
  149. bool enable_didt;
  150. bool enable_dpm;
  151. bool enable_auto_thermal_throttling;
  152. bool enable_nb_dpm;
  153. /* caps */
  154. bool caps_cac;
  155. bool caps_power_containment;
  156. bool caps_sq_ramping;
  157. bool caps_db_ramping;
  158. bool caps_td_ramping;
  159. bool caps_tcp_ramping;
  160. bool caps_sclk_throttle_low_notification;
  161. bool caps_fps;
  162. bool caps_uvd_dpm;
  163. bool caps_uvd_pg;
  164. bool caps_vce_pg;
  165. bool caps_samu_pg;
  166. bool caps_acp_pg;
  167. bool caps_stable_p_state;
  168. bool caps_enable_dfs_bypass;
  169. bool caps_sclk_ds;
  170. struct radeon_ps current_rps;
  171. struct kv_ps current_ps;
  172. struct radeon_ps requested_rps;
  173. struct kv_ps requested_ps;
  174. };
  175. /* kv_smc.c */
  176. int kv_notify_message_to_smu(struct radeon_device *rdev, u32 id);
  177. int kv_dpm_get_enable_mask(struct radeon_device *rdev, u32 *enable_mask);
  178. int kv_send_msg_to_smc_with_parameter(struct radeon_device *rdev,
  179. PPSMC_Msg msg, u32 parameter);
  180. int kv_read_smc_sram_dword(struct radeon_device *rdev, u32 smc_address,
  181. u32 *value, u32 limit);
  182. int kv_smc_dpm_enable(struct radeon_device *rdev, bool enable);
  183. int kv_smc_bapm_enable(struct radeon_device *rdev, bool enable);
  184. int kv_copy_bytes_to_smc(struct radeon_device *rdev,
  185. u32 smc_start_address,
  186. const u8 *src, u32 byte_count, u32 limit);
  187. #endif