Jammy Zhou | 3bace35 | 2015-07-21 21:18:15 +0800 | [diff] [blame] | 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 _HWMGR_H_ |
| 24 | #define _HWMGR_H_ |
| 25 | |
Rex Zhu | 28a18ba | 2015-09-23 15:14:38 +0800 | [diff] [blame] | 26 | #include <linux/seq_file.h> |
Jammy Zhou | 3bace35 | 2015-07-21 21:18:15 +0800 | [diff] [blame] | 27 | #include "amd_powerplay.h" |
| 28 | #include "pp_instance.h" |
| 29 | #include "hardwaremanager.h" |
| 30 | #include "pp_power_source.h" |
yanyang1 | c82baa2 | 2015-08-18 15:28:32 +0800 | [diff] [blame] | 31 | #include "hwmgr_ppt.h" |
Rex Zhu | 17c00a2 | 2015-12-03 14:16:01 +0800 | [diff] [blame] | 32 | #include "ppatomctrl.h" |
| 33 | #include "hwmgr_ppt.h" |
Rex Zhu | 48d7b75 | 2016-08-31 17:27:11 +0800 | [diff] [blame] | 34 | #include "power_state.h" |
Jammy Zhou | 3bace35 | 2015-07-21 21:18:15 +0800 | [diff] [blame] | 35 | |
| 36 | struct pp_instance; |
| 37 | struct pp_hwmgr; |
Rex Zhu | c28eae2 | 2015-10-16 11:46:51 +0800 | [diff] [blame] | 38 | struct phm_fan_speed_info; |
Rex Zhu | 17c00a2 | 2015-12-03 14:16:01 +0800 | [diff] [blame] | 39 | struct pp_atomctrl_voltage_table; |
| 40 | |
Rex Zhu | 41698ab | 2016-08-11 17:56:56 +0800 | [diff] [blame] | 41 | #define VOLTAGE_SCALE 4 |
| 42 | |
| 43 | uint8_t convert_to_vid(uint16_t vddc); |
| 44 | |
Rex Zhu | 17c00a2 | 2015-12-03 14:16:01 +0800 | [diff] [blame] | 45 | enum DISPLAY_GAP { |
| 46 | DISPLAY_GAP_VBLANK_OR_WM = 0, /* Wait for vblank or MCHG watermark. */ |
| 47 | DISPLAY_GAP_VBLANK = 1, /* Wait for vblank. */ |
| 48 | DISPLAY_GAP_WATERMARK = 2, /* Wait for MCHG watermark. (Note that HW may deassert WM in VBI depending on DC_STUTTER_CNTL.) */ |
| 49 | DISPLAY_GAP_IGNORE = 3 /* Do not wait. */ |
| 50 | }; |
| 51 | typedef enum DISPLAY_GAP DISPLAY_GAP; |
| 52 | |
Rex Zhu | 17c00a2 | 2015-12-03 14:16:01 +0800 | [diff] [blame] | 53 | struct vi_dpm_level { |
| 54 | bool enabled; |
| 55 | uint32_t value; |
| 56 | uint32_t param1; |
| 57 | }; |
| 58 | |
| 59 | struct vi_dpm_table { |
| 60 | uint32_t count; |
| 61 | struct vi_dpm_level dpm_level[1]; |
| 62 | }; |
Jammy Zhou | 3bace35 | 2015-07-21 21:18:15 +0800 | [diff] [blame] | 63 | |
| 64 | enum PP_Result { |
| 65 | PP_Result_TableImmediateExit = 0x13, |
| 66 | }; |
| 67 | |
| 68 | #define PCIE_PERF_REQ_REMOVE_REGISTRY 0 |
| 69 | #define PCIE_PERF_REQ_FORCE_LOWPOWER 1 |
| 70 | #define PCIE_PERF_REQ_GEN1 2 |
| 71 | #define PCIE_PERF_REQ_GEN2 3 |
| 72 | #define PCIE_PERF_REQ_GEN3 4 |
| 73 | |
Rex Zhu | 6429fb6 | 2016-08-16 18:13:57 +0800 | [diff] [blame] | 74 | enum PP_FEATURE_MASK { |
| 75 | PP_SCLK_DPM_MASK = 0x1, |
| 76 | PP_MCLK_DPM_MASK = 0x2, |
| 77 | PP_PCIE_DPM_MASK = 0x4, |
| 78 | PP_SCLK_DEEP_SLEEP_MASK = 0x8, |
| 79 | PP_POWER_CONTAINMENT_MASK = 0x10, |
| 80 | PP_UVD_HANDSHAKE_MASK = 0x20, |
| 81 | PP_SMC_VOLTAGE_CONTROL_MASK = 0x40, |
| 82 | PP_VBI_TIME_SUPPORT_MASK = 0x80, |
| 83 | PP_ULV_MASK = 0x100, |
Rex Zhu | 53b963b | 2016-10-27 17:48:49 +0800 | [diff] [blame] | 84 | PP_ENABLE_GFX_CG_THRU_SMU = 0x200, |
| 85 | PP_CLOCK_STRETCH_MASK = 0x400, |
Rex Zhu | cf54d6d | 2016-11-02 13:18:54 +0800 | [diff] [blame] | 86 | PP_OD_FUZZY_FAN_CONTROL_MASK = 0x800 |
Rex Zhu | 6429fb6 | 2016-08-16 18:13:57 +0800 | [diff] [blame] | 87 | }; |
| 88 | |
Jammy Zhou | 3bace35 | 2015-07-21 21:18:15 +0800 | [diff] [blame] | 89 | enum PHM_BackEnd_Magic { |
| 90 | PHM_Dummy_Magic = 0xAA5555AA, |
| 91 | PHM_RV770_Magic = 0xDCBAABCD, |
| 92 | PHM_Kong_Magic = 0x239478DF, |
| 93 | PHM_NIslands_Magic = 0x736C494E, |
| 94 | PHM_Sumo_Magic = 0x8339FA11, |
| 95 | PHM_SIslands_Magic = 0x369431AC, |
| 96 | PHM_Trinity_Magic = 0x96751873, |
| 97 | PHM_CIslands_Magic = 0x38AC78B0, |
| 98 | PHM_Kv_Magic = 0xDCBBABC0, |
| 99 | PHM_VIslands_Magic = 0x20130307, |
| 100 | PHM_Cz_Magic = 0x67DCBA25 |
| 101 | }; |
| 102 | |
Jammy Zhou | 3bace35 | 2015-07-21 21:18:15 +0800 | [diff] [blame] | 103 | |
| 104 | #define PHM_PCIE_POWERGATING_TARGET_GFX 0 |
| 105 | #define PHM_PCIE_POWERGATING_TARGET_DDI 1 |
| 106 | #define PHM_PCIE_POWERGATING_TARGET_PLLCASCADE 2 |
| 107 | #define PHM_PCIE_POWERGATING_TARGET_PHY 3 |
| 108 | |
| 109 | typedef int (*phm_table_function)(struct pp_hwmgr *hwmgr, void *input, |
| 110 | void *output, void *storage, int result); |
| 111 | |
| 112 | typedef bool (*phm_check_function)(struct pp_hwmgr *hwmgr); |
| 113 | |
Rex Zhu | 28a18ba | 2015-09-23 15:14:38 +0800 | [diff] [blame] | 114 | struct phm_set_power_state_input { |
| 115 | const struct pp_hw_power_state *pcurrent_state; |
| 116 | const struct pp_hw_power_state *pnew_state; |
| 117 | }; |
| 118 | |
Jammy Zhou | 3bace35 | 2015-07-21 21:18:15 +0800 | [diff] [blame] | 119 | struct phm_acp_arbiter { |
| 120 | uint32_t acpclk; |
| 121 | }; |
| 122 | |
| 123 | struct phm_uvd_arbiter { |
| 124 | uint32_t vclk; |
| 125 | uint32_t dclk; |
| 126 | uint32_t vclk_ceiling; |
| 127 | uint32_t dclk_ceiling; |
| 128 | }; |
| 129 | |
| 130 | struct phm_vce_arbiter { |
| 131 | uint32_t evclk; |
| 132 | uint32_t ecclk; |
| 133 | }; |
| 134 | |
| 135 | struct phm_gfx_arbiter { |
| 136 | uint32_t sclk; |
| 137 | uint32_t mclk; |
| 138 | uint32_t sclk_over_drive; |
| 139 | uint32_t mclk_over_drive; |
| 140 | uint32_t sclk_threshold; |
| 141 | uint32_t num_cus; |
| 142 | }; |
| 143 | |
| 144 | /* Entries in the master tables */ |
| 145 | struct phm_master_table_item { |
| 146 | phm_check_function isFunctionNeededInRuntimeTable; |
| 147 | phm_table_function tableFunction; |
| 148 | }; |
| 149 | |
| 150 | enum phm_master_table_flag { |
| 151 | PHM_MasterTableFlag_None = 0, |
| 152 | PHM_MasterTableFlag_ExitOnError = 1, |
| 153 | }; |
| 154 | |
| 155 | /* The header of the master tables */ |
| 156 | struct phm_master_table_header { |
| 157 | uint32_t storage_size; |
| 158 | uint32_t flags; |
Nils Wallménius | e90b622 | 2016-04-10 16:30:03 +0200 | [diff] [blame] | 159 | const struct phm_master_table_item *master_list; |
Jammy Zhou | 3bace35 | 2015-07-21 21:18:15 +0800 | [diff] [blame] | 160 | }; |
| 161 | |
| 162 | struct phm_runtime_table_header { |
| 163 | uint32_t storage_size; |
| 164 | bool exit_error; |
| 165 | phm_table_function *function_list; |
| 166 | }; |
| 167 | |
| 168 | struct phm_clock_array { |
| 169 | uint32_t count; |
| 170 | uint32_t values[1]; |
| 171 | }; |
| 172 | |
| 173 | struct phm_clock_voltage_dependency_record { |
| 174 | uint32_t clk; |
| 175 | uint32_t v; |
| 176 | }; |
| 177 | |
| 178 | struct phm_vceclock_voltage_dependency_record { |
| 179 | uint32_t ecclk; |
| 180 | uint32_t evclk; |
| 181 | uint32_t v; |
| 182 | }; |
| 183 | |
| 184 | struct phm_uvdclock_voltage_dependency_record { |
| 185 | uint32_t vclk; |
| 186 | uint32_t dclk; |
| 187 | uint32_t v; |
| 188 | }; |
| 189 | |
| 190 | struct phm_samuclock_voltage_dependency_record { |
| 191 | uint32_t samclk; |
| 192 | uint32_t v; |
| 193 | }; |
| 194 | |
| 195 | struct phm_acpclock_voltage_dependency_record { |
| 196 | uint32_t acpclk; |
| 197 | uint32_t v; |
| 198 | }; |
| 199 | |
| 200 | struct phm_clock_voltage_dependency_table { |
| 201 | uint32_t count; /* Number of entries. */ |
| 202 | struct phm_clock_voltage_dependency_record entries[1]; /* Dynamically allocate count entries. */ |
| 203 | }; |
| 204 | |
| 205 | struct phm_phase_shedding_limits_record { |
| 206 | uint32_t Voltage; |
| 207 | uint32_t Sclk; |
| 208 | uint32_t Mclk; |
| 209 | }; |
| 210 | |
| 211 | |
| 212 | extern int phm_dispatch_table(struct pp_hwmgr *hwmgr, |
| 213 | struct phm_runtime_table_header *rt_table, |
| 214 | void *input, void *output); |
| 215 | |
| 216 | extern int phm_construct_table(struct pp_hwmgr *hwmgr, |
Nils Wallménius | e90b622 | 2016-04-10 16:30:03 +0200 | [diff] [blame] | 217 | const struct phm_master_table_header *master_table, |
Jammy Zhou | 3bace35 | 2015-07-21 21:18:15 +0800 | [diff] [blame] | 218 | struct phm_runtime_table_header *rt_table); |
| 219 | |
| 220 | extern int phm_destroy_table(struct pp_hwmgr *hwmgr, |
| 221 | struct phm_runtime_table_header *rt_table); |
| 222 | |
| 223 | |
| 224 | struct phm_uvd_clock_voltage_dependency_record { |
| 225 | uint32_t vclk; |
| 226 | uint32_t dclk; |
| 227 | uint32_t v; |
| 228 | }; |
| 229 | |
| 230 | struct phm_uvd_clock_voltage_dependency_table { |
| 231 | uint8_t count; |
| 232 | struct phm_uvd_clock_voltage_dependency_record entries[1]; |
| 233 | }; |
| 234 | |
| 235 | struct phm_acp_clock_voltage_dependency_record { |
| 236 | uint32_t acpclk; |
| 237 | uint32_t v; |
| 238 | }; |
| 239 | |
| 240 | struct phm_acp_clock_voltage_dependency_table { |
| 241 | uint32_t count; |
| 242 | struct phm_acp_clock_voltage_dependency_record entries[1]; |
| 243 | }; |
| 244 | |
| 245 | struct phm_vce_clock_voltage_dependency_record { |
| 246 | uint32_t ecclk; |
| 247 | uint32_t evclk; |
| 248 | uint32_t v; |
| 249 | }; |
| 250 | |
| 251 | struct phm_phase_shedding_limits_table { |
| 252 | uint32_t count; |
| 253 | struct phm_phase_shedding_limits_record entries[1]; |
| 254 | }; |
| 255 | |
| 256 | struct phm_vceclock_voltage_dependency_table { |
| 257 | uint8_t count; /* Number of entries. */ |
| 258 | struct phm_vceclock_voltage_dependency_record entries[1]; /* Dynamically allocate count entries. */ |
| 259 | }; |
| 260 | |
| 261 | struct phm_uvdclock_voltage_dependency_table { |
| 262 | uint8_t count; /* Number of entries. */ |
| 263 | struct phm_uvdclock_voltage_dependency_record entries[1]; /* Dynamically allocate count entries. */ |
| 264 | }; |
| 265 | |
| 266 | struct phm_samuclock_voltage_dependency_table { |
| 267 | uint8_t count; /* Number of entries. */ |
| 268 | struct phm_samuclock_voltage_dependency_record entries[1]; /* Dynamically allocate count entries. */ |
| 269 | }; |
| 270 | |
| 271 | struct phm_acpclock_voltage_dependency_table { |
| 272 | uint32_t count; /* Number of entries. */ |
| 273 | struct phm_acpclock_voltage_dependency_record entries[1]; /* Dynamically allocate count entries. */ |
| 274 | }; |
| 275 | |
| 276 | struct phm_vce_clock_voltage_dependency_table { |
| 277 | uint8_t count; |
| 278 | struct phm_vce_clock_voltage_dependency_record entries[1]; |
| 279 | }; |
| 280 | |
| 281 | struct pp_hwmgr_func { |
| 282 | int (*backend_init)(struct pp_hwmgr *hw_mgr); |
| 283 | int (*backend_fini)(struct pp_hwmgr *hw_mgr); |
| 284 | int (*asic_setup)(struct pp_hwmgr *hw_mgr); |
| 285 | int (*get_power_state_size)(struct pp_hwmgr *hw_mgr); |
Rex Zhu | 28a18ba | 2015-09-23 15:14:38 +0800 | [diff] [blame] | 286 | |
| 287 | int (*apply_state_adjust_rules)(struct pp_hwmgr *hwmgr, |
| 288 | struct pp_power_state *prequest_ps, |
| 289 | const struct pp_power_state *pcurrent_ps); |
| 290 | |
| 291 | int (*force_dpm_level)(struct pp_hwmgr *hw_mgr, |
| 292 | enum amd_dpm_forced_level level); |
| 293 | |
| 294 | int (*dynamic_state_management_enable)( |
| 295 | struct pp_hwmgr *hw_mgr); |
Eric Huang | 8059752 | 2016-05-31 17:31:12 -0400 | [diff] [blame] | 296 | int (*dynamic_state_management_disable)( |
| 297 | struct pp_hwmgr *hw_mgr); |
Rex Zhu | 28a18ba | 2015-09-23 15:14:38 +0800 | [diff] [blame] | 298 | |
| 299 | int (*patch_boot_state)(struct pp_hwmgr *hwmgr, |
| 300 | struct pp_hw_power_state *hw_ps); |
| 301 | |
| 302 | int (*get_pp_table_entry)(struct pp_hwmgr *hwmgr, |
| 303 | unsigned long, struct pp_power_state *); |
Jammy Zhou | 3bace35 | 2015-07-21 21:18:15 +0800 | [diff] [blame] | 304 | int (*get_num_of_pp_table_entries)(struct pp_hwmgr *hwmgr); |
Rex Zhu | 28a18ba | 2015-09-23 15:14:38 +0800 | [diff] [blame] | 305 | int (*powerdown_uvd)(struct pp_hwmgr *hwmgr); |
| 306 | int (*powergate_vce)(struct pp_hwmgr *hwmgr, bool bgate); |
| 307 | int (*powergate_uvd)(struct pp_hwmgr *hwmgr, bool bgate); |
| 308 | int (*get_mclk)(struct pp_hwmgr *hwmgr, bool low); |
| 309 | int (*get_sclk)(struct pp_hwmgr *hwmgr, bool low); |
| 310 | int (*power_state_set)(struct pp_hwmgr *hwmgr, |
| 311 | const void *state); |
Rex Zhu | 28a18ba | 2015-09-23 15:14:38 +0800 | [diff] [blame] | 312 | int (*enable_clock_power_gating)(struct pp_hwmgr *hwmgr); |
Rex Zhu | e8c7de5 | 2015-10-16 14:51:09 +0800 | [diff] [blame] | 313 | int (*notify_smc_display_config_after_ps_adjustment)(struct pp_hwmgr *hwmgr); |
| 314 | int (*display_config_changed)(struct pp_hwmgr *hwmgr); |
Rex Zhu | b113201 | 2015-09-30 13:28:49 +0800 | [diff] [blame] | 315 | int (*disable_clock_power_gating)(struct pp_hwmgr *hwmgr); |
| 316 | int (*update_clock_gatings)(struct pp_hwmgr *hwmgr, |
| 317 | const uint32_t *msg_id); |
Rex Zhu | c28eae2 | 2015-10-16 11:46:51 +0800 | [diff] [blame] | 318 | int (*set_max_fan_rpm_output)(struct pp_hwmgr *hwmgr, uint16_t us_max_fan_pwm); |
| 319 | int (*set_max_fan_pwm_output)(struct pp_hwmgr *hwmgr, uint16_t us_max_fan_pwm); |
| 320 | int (*get_temperature)(struct pp_hwmgr *hwmgr); |
| 321 | int (*stop_thermal_controller)(struct pp_hwmgr *hwmgr); |
| 322 | int (*get_fan_speed_info)(struct pp_hwmgr *hwmgr, struct phm_fan_speed_info *fan_speed_info); |
| 323 | int (*set_fan_control_mode)(struct pp_hwmgr *hwmgr, uint32_t mode); |
| 324 | int (*get_fan_control_mode)(struct pp_hwmgr *hwmgr); |
| 325 | int (*set_fan_speed_percent)(struct pp_hwmgr *hwmgr, uint32_t percent); |
| 326 | int (*get_fan_speed_percent)(struct pp_hwmgr *hwmgr, uint32_t *speed); |
| 327 | int (*set_fan_speed_rpm)(struct pp_hwmgr *hwmgr, uint32_t percent); |
| 328 | int (*get_fan_speed_rpm)(struct pp_hwmgr *hwmgr, uint32_t *speed); |
| 329 | int (*reset_fan_speed_to_default)(struct pp_hwmgr *hwmgr); |
| 330 | int (*uninitialize_thermal_controller)(struct pp_hwmgr *hwmgr); |
| 331 | int (*register_internal_thermal_interrupt)(struct pp_hwmgr *hwmgr, |
| 332 | const void *thermal_interrupt_info); |
Rex Zhu | 09b4c87 | 2015-11-04 11:07:34 +0800 | [diff] [blame] | 333 | bool (*check_smc_update_required_for_display_configuration)(struct pp_hwmgr *hwmgr); |
| 334 | int (*check_states_equal)(struct pp_hwmgr *hwmgr, |
| 335 | const struct pp_hw_power_state *pstate1, |
| 336 | const struct pp_hw_power_state *pstate2, |
| 337 | bool *equal); |
Rex Zhu | 73c9f22 | 2015-11-19 13:46:01 +0800 | [diff] [blame] | 338 | int (*set_cpu_power_state)(struct pp_hwmgr *hwmgr); |
| 339 | int (*store_cc6_data)(struct pp_hwmgr *hwmgr, uint32_t separation_time, |
| 340 | bool cc6_disable, bool pstate_disable, |
| 341 | bool pstate_switch_disable); |
Vitaly Prosyak | c4dd206 | 2015-11-30 16:39:53 -0500 | [diff] [blame] | 342 | int (*get_dal_power_level)(struct pp_hwmgr *hwmgr, |
Rex Zhu | e273b04 | 2015-12-07 18:44:23 +0800 | [diff] [blame] | 343 | struct amd_pp_simple_clock_info *info); |
| 344 | int (*get_performance_level)(struct pp_hwmgr *, const struct pp_hw_power_state *, |
| 345 | PHM_PerformanceLevelDesignation, uint32_t, PHM_PerformanceLevel *); |
| 346 | int (*get_current_shallow_sleep_clocks)(struct pp_hwmgr *hwmgr, |
| 347 | const struct pp_hw_power_state *state, struct pp_clock_info *clock_info); |
| 348 | int (*get_clock_by_type)(struct pp_hwmgr *hwmgr, enum amd_pp_clock_type type, struct amd_pp_clocks *clocks); |
| 349 | int (*get_max_high_clocks)(struct pp_hwmgr *hwmgr, struct amd_pp_simple_clock_info *clocks); |
Rex Zhu | e1d32e6 | 2015-12-29 11:22:34 +0800 | [diff] [blame] | 350 | int (*power_off_asic)(struct pp_hwmgr *hwmgr); |
Eric Huang | 5632708 | 2016-04-12 14:57:23 -0400 | [diff] [blame] | 351 | int (*force_clock_level)(struct pp_hwmgr *hwmgr, enum pp_clock_type type, uint32_t mask); |
Eric Huang | f3898ea | 2015-12-11 16:24:34 -0500 | [diff] [blame] | 352 | int (*print_clock_levels)(struct pp_hwmgr *hwmgr, enum pp_clock_type type, char *buf); |
Eric Huang | 65f85e7 | 2016-02-11 15:54:45 -0500 | [diff] [blame] | 353 | int (*enable_per_cu_power_gating)(struct pp_hwmgr *hwmgr, bool enable); |
Eric Huang | 428bafa | 2016-05-12 14:51:21 -0400 | [diff] [blame] | 354 | int (*get_sclk_od)(struct pp_hwmgr *hwmgr); |
| 355 | int (*set_sclk_od)(struct pp_hwmgr *hwmgr, uint32_t value); |
Eric Huang | f2bdc05 | 2016-05-24 15:11:17 -0400 | [diff] [blame] | 356 | int (*get_mclk_od)(struct pp_hwmgr *hwmgr); |
| 357 | int (*set_mclk_od)(struct pp_hwmgr *hwmgr, uint32_t value); |
Tom St Denis | a6e3695 | 2016-09-15 10:07:34 -0400 | [diff] [blame] | 358 | int (*read_sensor)(struct pp_hwmgr *hwmgr, int idx, int32_t *value); |
Huang Rui | 167112b | 2016-12-14 16:26:54 +0800 | [diff] [blame] | 359 | int (*request_firmware)(struct pp_hwmgr *hwmgr); |
| 360 | int (*release_firmware)(struct pp_hwmgr *hwmgr); |
Eric Huang | 34bb273 | 2016-09-12 16:17:44 -0400 | [diff] [blame^] | 361 | int (*set_power_profile_state)(struct pp_hwmgr *hwmgr, |
| 362 | struct amd_pp_profile *request); |
Jammy Zhou | 3bace35 | 2015-07-21 21:18:15 +0800 | [diff] [blame] | 363 | }; |
| 364 | |
| 365 | struct pp_table_func { |
| 366 | int (*pptable_init)(struct pp_hwmgr *hw_mgr); |
| 367 | int (*pptable_fini)(struct pp_hwmgr *hw_mgr); |
| 368 | int (*pptable_get_number_of_vce_state_table_entries)(struct pp_hwmgr *hw_mgr); |
| 369 | int (*pptable_get_vce_state_table_entry)( |
| 370 | struct pp_hwmgr *hwmgr, |
| 371 | unsigned long i, |
Rex Zhu | 0d8de7c | 2016-10-12 15:13:29 +0800 | [diff] [blame] | 372 | struct amd_vce_state *vce_state, |
Jammy Zhou | 3bace35 | 2015-07-21 21:18:15 +0800 | [diff] [blame] | 373 | void **clock_info, |
| 374 | unsigned long *flag); |
| 375 | }; |
| 376 | |
| 377 | union phm_cac_leakage_record { |
| 378 | struct { |
| 379 | uint16_t Vddc; /* in CI, we use it for StdVoltageHiSidd */ |
| 380 | uint32_t Leakage; /* in CI, we use it for StdVoltageLoSidd */ |
| 381 | }; |
| 382 | struct { |
| 383 | uint16_t Vddc1; |
| 384 | uint16_t Vddc2; |
| 385 | uint16_t Vddc3; |
| 386 | }; |
| 387 | }; |
| 388 | |
| 389 | struct phm_cac_leakage_table { |
| 390 | uint32_t count; |
| 391 | union phm_cac_leakage_record entries[1]; |
| 392 | }; |
| 393 | |
| 394 | struct phm_samu_clock_voltage_dependency_record { |
| 395 | uint32_t samclk; |
| 396 | uint32_t v; |
| 397 | }; |
| 398 | |
| 399 | |
| 400 | struct phm_samu_clock_voltage_dependency_table { |
| 401 | uint8_t count; |
| 402 | struct phm_samu_clock_voltage_dependency_record entries[1]; |
| 403 | }; |
| 404 | |
| 405 | struct phm_cac_tdp_table { |
| 406 | uint16_t usTDP; |
| 407 | uint16_t usConfigurableTDP; |
| 408 | uint16_t usTDC; |
| 409 | uint16_t usBatteryPowerLimit; |
| 410 | uint16_t usSmallPowerLimit; |
| 411 | uint16_t usLowCACLeakage; |
| 412 | uint16_t usHighCACLeakage; |
| 413 | uint16_t usMaximumPowerDeliveryLimit; |
| 414 | uint16_t usOperatingTempMinLimit; |
| 415 | uint16_t usOperatingTempMaxLimit; |
| 416 | uint16_t usOperatingTempStep; |
| 417 | uint16_t usOperatingTempHyst; |
| 418 | uint16_t usDefaultTargetOperatingTemp; |
| 419 | uint16_t usTargetOperatingTemp; |
| 420 | uint16_t usPowerTuneDataSetID; |
| 421 | uint16_t usSoftwareShutdownTemp; |
| 422 | uint16_t usClockStretchAmount; |
| 423 | uint16_t usTemperatureLimitHotspot; |
| 424 | uint16_t usTemperatureLimitLiquid1; |
| 425 | uint16_t usTemperatureLimitLiquid2; |
| 426 | uint16_t usTemperatureLimitVrVddc; |
| 427 | uint16_t usTemperatureLimitVrMvdd; |
| 428 | uint16_t usTemperatureLimitPlx; |
| 429 | uint8_t ucLiquid1_I2C_address; |
| 430 | uint8_t ucLiquid2_I2C_address; |
| 431 | uint8_t ucLiquid_I2C_Line; |
| 432 | uint8_t ucVr_I2C_address; |
| 433 | uint8_t ucVr_I2C_Line; |
| 434 | uint8_t ucPlx_I2C_address; |
| 435 | uint8_t ucPlx_I2C_Line; |
Rex Zhu | 83a7af6 | 2016-06-23 11:05:00 +0800 | [diff] [blame] | 436 | uint32_t usBoostPowerLimit; |
| 437 | uint8_t ucCKS_LDO_REFSEL; |
Jammy Zhou | 3bace35 | 2015-07-21 21:18:15 +0800 | [diff] [blame] | 438 | }; |
| 439 | |
| 440 | struct phm_ppm_table { |
| 441 | uint8_t ppm_design; |
| 442 | uint16_t cpu_core_number; |
| 443 | uint32_t platform_tdp; |
| 444 | uint32_t small_ac_platform_tdp; |
| 445 | uint32_t platform_tdc; |
| 446 | uint32_t small_ac_platform_tdc; |
| 447 | uint32_t apu_tdp; |
| 448 | uint32_t dgpu_tdp; |
| 449 | uint32_t dgpu_ulv_power; |
| 450 | uint32_t tj_max; |
| 451 | }; |
| 452 | |
| 453 | struct phm_vq_budgeting_record { |
| 454 | uint32_t ulCUs; |
| 455 | uint32_t ulSustainableSOCPowerLimitLow; |
| 456 | uint32_t ulSustainableSOCPowerLimitHigh; |
| 457 | uint32_t ulMinSclkLow; |
| 458 | uint32_t ulMinSclkHigh; |
| 459 | uint8_t ucDispConfig; |
| 460 | uint32_t ulDClk; |
| 461 | uint32_t ulEClk; |
| 462 | uint32_t ulSustainableSclk; |
| 463 | uint32_t ulSustainableCUs; |
| 464 | }; |
| 465 | |
| 466 | struct phm_vq_budgeting_table { |
| 467 | uint8_t numEntries; |
| 468 | struct phm_vq_budgeting_record entries[1]; |
| 469 | }; |
| 470 | |
| 471 | struct phm_clock_and_voltage_limits { |
| 472 | uint32_t sclk; |
| 473 | uint32_t mclk; |
| 474 | uint16_t vddc; |
| 475 | uint16_t vddci; |
| 476 | uint16_t vddgfx; |
| 477 | }; |
| 478 | |
yanyang1 | c82baa2 | 2015-08-18 15:28:32 +0800 | [diff] [blame] | 479 | /* Structure to hold PPTable information */ |
Jammy Zhou | 3bace35 | 2015-07-21 21:18:15 +0800 | [diff] [blame] | 480 | |
yanyang1 | c82baa2 | 2015-08-18 15:28:32 +0800 | [diff] [blame] | 481 | struct phm_ppt_v1_information { |
| 482 | struct phm_ppt_v1_clock_voltage_dependency_table *vdd_dep_on_sclk; |
| 483 | struct phm_ppt_v1_clock_voltage_dependency_table *vdd_dep_on_mclk; |
| 484 | struct phm_clock_array *valid_sclk_values; |
| 485 | struct phm_clock_array *valid_mclk_values; |
| 486 | struct phm_clock_and_voltage_limits max_clock_voltage_on_dc; |
| 487 | struct phm_clock_and_voltage_limits max_clock_voltage_on_ac; |
| 488 | struct phm_clock_voltage_dependency_table *vddc_dep_on_dal_pwrl; |
| 489 | struct phm_ppm_table *ppm_parameter_table; |
| 490 | struct phm_cac_tdp_table *cac_dtp_table; |
| 491 | struct phm_ppt_v1_mm_clock_voltage_dependency_table *mm_dep_table; |
| 492 | struct phm_ppt_v1_voltage_lookup_table *vddc_lookup_table; |
| 493 | struct phm_ppt_v1_voltage_lookup_table *vddgfx_lookup_table; |
| 494 | struct phm_ppt_v1_pcie_table *pcie_table; |
| 495 | uint16_t us_ulv_voltage_offset; |
| 496 | }; |
Jammy Zhou | 3bace35 | 2015-07-21 21:18:15 +0800 | [diff] [blame] | 497 | |
| 498 | struct phm_dynamic_state_info { |
| 499 | struct phm_clock_voltage_dependency_table *vddc_dependency_on_sclk; |
| 500 | struct phm_clock_voltage_dependency_table *vddci_dependency_on_mclk; |
| 501 | struct phm_clock_voltage_dependency_table *vddc_dependency_on_mclk; |
| 502 | struct phm_clock_voltage_dependency_table *mvdd_dependency_on_mclk; |
| 503 | struct phm_clock_voltage_dependency_table *vddc_dep_on_dal_pwrl; |
| 504 | struct phm_clock_array *valid_sclk_values; |
| 505 | struct phm_clock_array *valid_mclk_values; |
| 506 | struct phm_clock_and_voltage_limits max_clock_voltage_on_dc; |
| 507 | struct phm_clock_and_voltage_limits max_clock_voltage_on_ac; |
| 508 | uint32_t mclk_sclk_ratio; |
| 509 | uint32_t sclk_mclk_delta; |
| 510 | uint32_t vddc_vddci_delta; |
| 511 | uint32_t min_vddc_for_pcie_gen2; |
| 512 | struct phm_cac_leakage_table *cac_leakage_table; |
| 513 | struct phm_phase_shedding_limits_table *vddc_phase_shed_limits_table; |
| 514 | |
| 515 | struct phm_vce_clock_voltage_dependency_table |
Alex Deucher | 9c0bad9 | 2015-11-13 23:51:40 -0500 | [diff] [blame] | 516 | *vce_clock_voltage_dependency_table; |
Jammy Zhou | 3bace35 | 2015-07-21 21:18:15 +0800 | [diff] [blame] | 517 | struct phm_uvd_clock_voltage_dependency_table |
Alex Deucher | 9c0bad9 | 2015-11-13 23:51:40 -0500 | [diff] [blame] | 518 | *uvd_clock_voltage_dependency_table; |
Jammy Zhou | 3bace35 | 2015-07-21 21:18:15 +0800 | [diff] [blame] | 519 | struct phm_acp_clock_voltage_dependency_table |
| 520 | *acp_clock_voltage_dependency_table; |
| 521 | struct phm_samu_clock_voltage_dependency_table |
| 522 | *samu_clock_voltage_dependency_table; |
| 523 | |
| 524 | struct phm_ppm_table *ppm_parameter_table; |
| 525 | struct phm_cac_tdp_table *cac_dtp_table; |
| 526 | struct phm_clock_voltage_dependency_table *vdd_gfx_dependency_on_sclk; |
Christian König | edf600d | 2016-05-03 15:54:54 +0200 | [diff] [blame] | 527 | struct phm_vq_budgeting_table *vq_budgeting_table; |
Jammy Zhou | 3bace35 | 2015-07-21 21:18:15 +0800 | [diff] [blame] | 528 | }; |
| 529 | |
yanyang1 | c82baa2 | 2015-08-18 15:28:32 +0800 | [diff] [blame] | 530 | struct pp_fan_info { |
| 531 | bool bNoFan; |
| 532 | uint8_t ucTachometerPulsesPerRevolution; |
| 533 | uint32_t ulMinRPM; |
| 534 | uint32_t ulMaxRPM; |
| 535 | }; |
| 536 | |
| 537 | struct pp_advance_fan_control_parameters { |
| 538 | uint16_t usTMin; /* The temperature, in 0.01 centigrades, below which we just run at a minimal PWM. */ |
| 539 | uint16_t usTMed; /* The middle temperature where we change slopes. */ |
| 540 | uint16_t usTHigh; /* The high temperature for setting the second slope. */ |
| 541 | uint16_t usPWMMin; /* The minimum PWM value in percent (0.01% increments). */ |
| 542 | uint16_t usPWMMed; /* The PWM value (in percent) at TMed. */ |
| 543 | uint16_t usPWMHigh; /* The PWM value at THigh. */ |
| 544 | uint8_t ucTHyst; /* Temperature hysteresis. Integer. */ |
| 545 | uint32_t ulCycleDelay; /* The time between two invocations of the fan control routine in microseconds. */ |
| 546 | uint16_t usTMax; /* The max temperature */ |
| 547 | uint8_t ucFanControlMode; |
| 548 | uint16_t usFanPWMMinLimit; |
| 549 | uint16_t usFanPWMMaxLimit; |
| 550 | uint16_t usFanPWMStep; |
| 551 | uint16_t usDefaultMaxFanPWM; |
| 552 | uint16_t usFanOutputSensitivity; |
| 553 | uint16_t usDefaultFanOutputSensitivity; |
| 554 | uint16_t usMaxFanPWM; /* The max Fan PWM value for Fuzzy Fan Control feature */ |
| 555 | uint16_t usFanRPMMinLimit; /* Minimum limit range in percentage, need to calculate based on minRPM/MaxRpm */ |
| 556 | uint16_t usFanRPMMaxLimit; /* Maximum limit range in percentage, usually set to 100% by default */ |
| 557 | uint16_t usFanRPMStep; /* Step increments/decerements, in percent */ |
| 558 | uint16_t usDefaultMaxFanRPM; /* The max Fan RPM value for Fuzzy Fan Control feature, default from PPTable */ |
| 559 | uint16_t usMaxFanRPM; /* The max Fan RPM value for Fuzzy Fan Control feature, user defined */ |
| 560 | uint16_t usFanCurrentLow; /* Low current */ |
| 561 | uint16_t usFanCurrentHigh; /* High current */ |
| 562 | uint16_t usFanRPMLow; /* Low RPM */ |
| 563 | uint16_t usFanRPMHigh; /* High RPM */ |
| 564 | uint32_t ulMinFanSCLKAcousticLimit; /* Minimum Fan Controller SCLK Frequency Acoustic Limit. */ |
| 565 | uint8_t ucTargetTemperature; /* Advanced fan controller target temperature. */ |
| 566 | uint8_t ucMinimumPWMLimit; /* The minimum PWM that the advanced fan controller can set. This should be set to the highest PWM that will run the fan at its lowest RPM. */ |
| 567 | uint16_t usFanGainEdge; /* The following is added for Fiji */ |
| 568 | uint16_t usFanGainHotspot; |
| 569 | uint16_t usFanGainLiquid; |
| 570 | uint16_t usFanGainVrVddc; |
| 571 | uint16_t usFanGainVrMvdd; |
| 572 | uint16_t usFanGainPlx; |
| 573 | uint16_t usFanGainHbm; |
| 574 | }; |
| 575 | |
| 576 | struct pp_thermal_controller_info { |
| 577 | uint8_t ucType; |
| 578 | uint8_t ucI2cLine; |
| 579 | uint8_t ucI2cAddress; |
| 580 | struct pp_fan_info fanInfo; |
| 581 | struct pp_advance_fan_control_parameters advanceFanControlParameters; |
| 582 | }; |
| 583 | |
| 584 | struct phm_microcode_version_info { |
| 585 | uint32_t SMC; |
| 586 | uint32_t DMCU; |
| 587 | uint32_t MC; |
| 588 | uint32_t NB; |
| 589 | }; |
| 590 | |
Rex Zhu | b1c8e1e | 2016-08-24 11:28:41 +0800 | [diff] [blame] | 591 | enum PP_TABLE_VERSION { |
| 592 | PP_TABLE_V0 = 0, |
| 593 | PP_TABLE_V1, |
| 594 | PP_TABLE_V2, |
| 595 | PP_TABLE_MAX |
| 596 | }; |
| 597 | |
yanyang1 | c82baa2 | 2015-08-18 15:28:32 +0800 | [diff] [blame] | 598 | /** |
| 599 | * The main hardware manager structure. |
| 600 | */ |
Jammy Zhou | 3bace35 | 2015-07-21 21:18:15 +0800 | [diff] [blame] | 601 | struct pp_hwmgr { |
| 602 | uint32_t chip_family; |
| 603 | uint32_t chip_id; |
Jammy Zhou | 3bace35 | 2015-07-21 21:18:15 +0800 | [diff] [blame] | 604 | |
Rex Zhu | b1c8e1e | 2016-08-24 11:28:41 +0800 | [diff] [blame] | 605 | uint32_t pp_table_version; |
Jammy Zhou | 3bace35 | 2015-07-21 21:18:15 +0800 | [diff] [blame] | 606 | void *device; |
| 607 | struct pp_smumgr *smumgr; |
| 608 | const void *soft_pp_table; |
Eric Huang | 1551019 | 2016-04-15 15:02:54 -0400 | [diff] [blame] | 609 | uint32_t soft_pp_table_size; |
Eric Huang | 4dcf9e6 | 2016-06-01 17:08:07 -0400 | [diff] [blame] | 610 | void *hardcode_pp_table; |
Alex Deucher | 9c0bad9 | 2015-11-13 23:51:40 -0500 | [diff] [blame] | 611 | bool need_pp_table_upload; |
Rex Zhu | 48d7b75 | 2016-08-31 17:27:11 +0800 | [diff] [blame] | 612 | |
Rex Zhu | 0d8de7c | 2016-10-12 15:13:29 +0800 | [diff] [blame] | 613 | struct amd_vce_state vce_states[AMD_MAX_VCE_LEVELS]; |
Rex Zhu | 48d7b75 | 2016-08-31 17:27:11 +0800 | [diff] [blame] | 614 | uint32_t num_vce_state_tables; |
| 615 | |
Jammy Zhou | 3bace35 | 2015-07-21 21:18:15 +0800 | [diff] [blame] | 616 | enum amd_dpm_forced_level dpm_level; |
Rex Zhu | 570272d | 2017-01-06 13:32:49 +0800 | [diff] [blame] | 617 | enum amd_dpm_forced_level saved_dpm_level; |
Rex Zhu | 28a18ba | 2015-09-23 15:14:38 +0800 | [diff] [blame] | 618 | bool block_hw_access; |
Jammy Zhou | 3bace35 | 2015-07-21 21:18:15 +0800 | [diff] [blame] | 619 | struct phm_gfx_arbiter gfx_arbiter; |
| 620 | struct phm_acp_arbiter acp_arbiter; |
| 621 | struct phm_uvd_arbiter uvd_arbiter; |
| 622 | struct phm_vce_arbiter vce_arbiter; |
| 623 | uint32_t usec_timeout; |
| 624 | void *pptable; |
| 625 | struct phm_platform_descriptor platform_descriptor; |
| 626 | void *backend; |
Rex Zhu | e1d32e6 | 2015-12-29 11:22:34 +0800 | [diff] [blame] | 627 | enum PP_DAL_POWERLEVEL dal_power_level; |
Jammy Zhou | 3bace35 | 2015-07-21 21:18:15 +0800 | [diff] [blame] | 628 | struct phm_dynamic_state_info dyn_state; |
| 629 | struct phm_runtime_table_header setup_asic; |
Rex Zhu | e1d32e6 | 2015-12-29 11:22:34 +0800 | [diff] [blame] | 630 | struct phm_runtime_table_header power_down_asic; |
Jammy Zhou | 3bace35 | 2015-07-21 21:18:15 +0800 | [diff] [blame] | 631 | struct phm_runtime_table_header disable_dynamic_state_management; |
| 632 | struct phm_runtime_table_header enable_dynamic_state_management; |
Rex Zhu | 28a18ba | 2015-09-23 15:14:38 +0800 | [diff] [blame] | 633 | struct phm_runtime_table_header set_power_state; |
| 634 | struct phm_runtime_table_header enable_clock_power_gatings; |
Rex Zhu | e8c7de5 | 2015-10-16 14:51:09 +0800 | [diff] [blame] | 635 | struct phm_runtime_table_header display_configuration_changed; |
Rex Zhu | c28eae2 | 2015-10-16 11:46:51 +0800 | [diff] [blame] | 636 | struct phm_runtime_table_header start_thermal_controller; |
| 637 | struct phm_runtime_table_header set_temperature_range; |
Jammy Zhou | 3bace35 | 2015-07-21 21:18:15 +0800 | [diff] [blame] | 638 | const struct pp_hwmgr_func *hwmgr_func; |
| 639 | const struct pp_table_func *pptable_func; |
| 640 | struct pp_power_state *ps; |
Rex Zhu | 73c9f22 | 2015-11-19 13:46:01 +0800 | [diff] [blame] | 641 | enum pp_power_source power_source; |
Jammy Zhou | 3bace35 | 2015-07-21 21:18:15 +0800 | [diff] [blame] | 642 | uint32_t num_ps; |
yanyang1 | c82baa2 | 2015-08-18 15:28:32 +0800 | [diff] [blame] | 643 | struct pp_thermal_controller_info thermal_controller; |
Rex Zhu | c28eae2 | 2015-10-16 11:46:51 +0800 | [diff] [blame] | 644 | bool fan_ctrl_is_in_default_mode; |
| 645 | uint32_t fan_ctrl_default_mode; |
| 646 | uint32_t tmin; |
yanyang1 | c82baa2 | 2015-08-18 15:28:32 +0800 | [diff] [blame] | 647 | struct phm_microcode_version_info microcode_version_info; |
Jammy Zhou | 3bace35 | 2015-07-21 21:18:15 +0800 | [diff] [blame] | 648 | uint32_t ps_size; |
| 649 | struct pp_power_state *current_ps; |
| 650 | struct pp_power_state *request_ps; |
| 651 | struct pp_power_state *boot_ps; |
| 652 | struct pp_power_state *uvd_ps; |
Eric Yang | 14f6341 | 2015-12-01 13:23:07 -0500 | [diff] [blame] | 653 | struct amd_pp_display_configuration display_config; |
Rex Zhu | 6429fb6 | 2016-08-16 18:13:57 +0800 | [diff] [blame] | 654 | uint32_t feature_mask; |
Eric Huang | 34bb273 | 2016-09-12 16:17:44 -0400 | [diff] [blame^] | 655 | |
| 656 | /* power profile */ |
| 657 | struct amd_pp_profile gfx_power_profile; |
| 658 | struct amd_pp_profile compute_power_profile; |
| 659 | struct amd_pp_profile default_gfx_power_profile; |
| 660 | struct amd_pp_profile default_compute_power_profile; |
| 661 | enum amd_pp_profile_type current_power_profile; |
Jammy Zhou | 3bace35 | 2015-07-21 21:18:15 +0800 | [diff] [blame] | 662 | }; |
| 663 | |
Rex Zhu | 1c86380 | 2016-12-28 19:43:23 +0800 | [diff] [blame] | 664 | extern int hwmgr_early_init(struct pp_instance *handle); |
| 665 | extern int hwmgr_hw_init(struct pp_instance *handle); |
| 666 | extern int hwmgr_hw_fini(struct pp_instance *handle); |
Jammy Zhou | 3bace35 | 2015-07-21 21:18:15 +0800 | [diff] [blame] | 667 | extern int phm_wait_on_register(struct pp_hwmgr *hwmgr, uint32_t index, |
| 668 | uint32_t value, uint32_t mask); |
| 669 | |
Jammy Zhou | 3bace35 | 2015-07-21 21:18:15 +0800 | [diff] [blame] | 670 | extern void phm_wait_on_indirect_register(struct pp_hwmgr *hwmgr, |
| 671 | uint32_t indirect_port, |
| 672 | uint32_t index, |
| 673 | uint32_t value, |
| 674 | uint32_t mask); |
| 675 | |
Rex Zhu | 08bd8b9f | 2016-07-29 16:30:04 +0800 | [diff] [blame] | 676 | |
Jammy Zhou | 3bace35 | 2015-07-21 21:18:15 +0800 | [diff] [blame] | 677 | |
Rex Zhu | 17c00a2 | 2015-12-03 14:16:01 +0800 | [diff] [blame] | 678 | extern bool phm_cf_want_uvd_power_gating(struct pp_hwmgr *hwmgr); |
| 679 | extern bool phm_cf_want_vce_power_gating(struct pp_hwmgr *hwmgr); |
| 680 | extern bool phm_cf_want_microcode_fan_ctrl(struct pp_hwmgr *hwmgr); |
| 681 | |
| 682 | extern int phm_trim_voltage_table(struct pp_atomctrl_voltage_table *vol_table); |
| 683 | extern int phm_get_svi2_mvdd_voltage_table(struct pp_atomctrl_voltage_table *vol_table, phm_ppt_v1_clock_voltage_dependency_table *dep_table); |
| 684 | extern int phm_get_svi2_vddci_voltage_table(struct pp_atomctrl_voltage_table *vol_table, phm_ppt_v1_clock_voltage_dependency_table *dep_table); |
| 685 | extern int phm_get_svi2_vdd_voltage_table(struct pp_atomctrl_voltage_table *vol_table, phm_ppt_v1_voltage_lookup_table *lookup_table); |
| 686 | extern void phm_trim_voltage_table_to_fit_state_table(uint32_t max_vol_steps, struct pp_atomctrl_voltage_table *vol_table); |
| 687 | extern int phm_reset_single_dpm_table(void *table, uint32_t count, int max); |
| 688 | extern void phm_setup_pcie_table_entry(void *table, uint32_t index, uint32_t pcie_gen, uint32_t pcie_lanes); |
| 689 | extern int32_t phm_get_dpm_level_enable_mask_value(void *table); |
Rex Zhu | 8bea252 | 2016-09-12 15:17:37 +0800 | [diff] [blame] | 690 | extern uint8_t phm_get_voltage_id(struct pp_atomctrl_voltage_table *voltage_table, |
| 691 | uint32_t voltage); |
Rex Zhu | 17c00a2 | 2015-12-03 14:16:01 +0800 | [diff] [blame] | 692 | extern uint8_t phm_get_voltage_index(struct phm_ppt_v1_voltage_lookup_table *lookup_table, uint16_t voltage); |
| 693 | extern uint16_t phm_find_closest_vddci(struct pp_atomctrl_voltage_table *vddci_table, uint16_t vddci); |
| 694 | extern int phm_find_boot_level(void *table, uint32_t value, uint32_t *boot_level); |
| 695 | extern int phm_get_sclk_for_voltage_evv(struct pp_hwmgr *hwmgr, phm_ppt_v1_voltage_lookup_table *lookup_table, |
| 696 | uint16_t virtual_voltage_id, int32_t *sclk); |
| 697 | extern int phm_initializa_dynamic_state_adjustment_rule_settings(struct pp_hwmgr *hwmgr); |
Rex Zhu | 17c00a2 | 2015-12-03 14:16:01 +0800 | [diff] [blame] | 698 | extern uint32_t phm_get_lowest_enabled_level(struct pp_hwmgr *hwmgr, uint32_t mask); |
Rex Zhu | 8b41e7a | 2016-05-10 15:37:00 +0800 | [diff] [blame] | 699 | extern void phm_apply_dal_min_voltage_request(struct pp_hwmgr *hwmgr); |
Rex Zhu | 28a18ba | 2015-09-23 15:14:38 +0800 | [diff] [blame] | 700 | |
Rex Zhu | a5b580e | 2016-12-29 15:30:38 +0800 | [diff] [blame] | 701 | extern int smu7_init_function_pointers(struct pp_hwmgr *hwmgr); |
Rex Zhu | 026c881 | 2016-08-16 21:38:19 +0800 | [diff] [blame] | 702 | extern int phm_get_voltage_evv_on_sclk(struct pp_hwmgr *hwmgr, uint8_t voltage_type, |
| 703 | uint32_t sclk, uint16_t id, uint16_t *voltage); |
| 704 | |
Rex Zhu | 28a18ba | 2015-09-23 15:14:38 +0800 | [diff] [blame] | 705 | #define PHM_ENTIRE_REGISTER_MASK 0xFFFFFFFFU |
| 706 | |
Jammy Zhou | 3bace35 | 2015-07-21 21:18:15 +0800 | [diff] [blame] | 707 | #define PHM_FIELD_SHIFT(reg, field) reg##__##field##__SHIFT |
| 708 | #define PHM_FIELD_MASK(reg, field) reg##__##field##_MASK |
| 709 | |
| 710 | #define PHM_SET_FIELD(origval, reg, field, fieldval) \ |
| 711 | (((origval) & ~PHM_FIELD_MASK(reg, field)) | \ |
| 712 | (PHM_FIELD_MASK(reg, field) & ((fieldval) << PHM_FIELD_SHIFT(reg, field)))) |
| 713 | |
| 714 | #define PHM_GET_FIELD(value, reg, field) \ |
| 715 | (((value) & PHM_FIELD_MASK(reg, field)) >> \ |
| 716 | PHM_FIELD_SHIFT(reg, field)) |
| 717 | |
| 718 | |
Jammy Zhou | 3bace35 | 2015-07-21 21:18:15 +0800 | [diff] [blame] | 719 | /* Operations on named fields. */ |
| 720 | |
| 721 | #define PHM_READ_FIELD(device, reg, field) \ |
| 722 | PHM_GET_FIELD(cgs_read_register(device, mm##reg), reg, field) |
| 723 | |
| 724 | #define PHM_READ_INDIRECT_FIELD(device, port, reg, field) \ |
| 725 | PHM_GET_FIELD(cgs_read_ind_register(device, port, ix##reg), \ |
| 726 | reg, field) |
| 727 | |
| 728 | #define PHM_READ_VFPF_INDIRECT_FIELD(device, port, reg, field) \ |
| 729 | PHM_GET_FIELD(cgs_read_ind_register(device, port, ix##reg), \ |
| 730 | reg, field) |
| 731 | |
| 732 | #define PHM_WRITE_FIELD(device, reg, field, fieldval) \ |
| 733 | cgs_write_register(device, mm##reg, PHM_SET_FIELD( \ |
| 734 | cgs_read_register(device, mm##reg), reg, field, fieldval)) |
| 735 | |
| 736 | #define PHM_WRITE_INDIRECT_FIELD(device, port, reg, field, fieldval) \ |
| 737 | cgs_write_ind_register(device, port, ix##reg, \ |
| 738 | PHM_SET_FIELD(cgs_read_ind_register(device, port, ix##reg), \ |
| 739 | reg, field, fieldval)) |
| 740 | |
| 741 | #define PHM_WRITE_VFPF_INDIRECT_FIELD(device, port, reg, field, fieldval) \ |
| 742 | cgs_write_ind_register(device, port, ix##reg, \ |
| 743 | PHM_SET_FIELD(cgs_read_ind_register(device, port, ix##reg), \ |
| 744 | reg, field, fieldval)) |
| 745 | |
Rex Zhu | 08bd8b9f | 2016-07-29 16:30:04 +0800 | [diff] [blame] | 746 | #define PHM_WAIT_INDIRECT_REGISTER_GIVEN_INDEX(hwmgr, port, index, value, mask) \ |
| 747 | phm_wait_on_indirect_register(hwmgr, mm##port##_INDEX, index, value, mask) |
| 748 | |
| 749 | |
| 750 | #define PHM_WAIT_INDIRECT_REGISTER(hwmgr, port, reg, value, mask) \ |
| 751 | PHM_WAIT_INDIRECT_REGISTER_GIVEN_INDEX(hwmgr, port, ix##reg, value, mask) |
Jammy Zhou | 3bace35 | 2015-07-21 21:18:15 +0800 | [diff] [blame] | 752 | |
| 753 | #define PHM_WAIT_INDIRECT_FIELD(hwmgr, port, reg, field, fieldval) \ |
| 754 | PHM_WAIT_INDIRECT_REGISTER(hwmgr, port, reg, (fieldval) \ |
| 755 | << PHM_FIELD_SHIFT(reg, field), PHM_FIELD_MASK(reg, field)) |
| 756 | |
Jammy Zhou | 3bace35 | 2015-07-21 21:18:15 +0800 | [diff] [blame] | 757 | |
| 758 | #endif /* _HWMGR_H_ */ |