2 * Copyright 2016 Advanced Micro Devices, Inc.
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:
11 * The above copyright notice and this permission notice shall be included in
12 * all copies or substantial portions of the Software.
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.
24 #include <asm/div64.h>
25 #include "polaris10_thermal.h"
26 #include "polaris10_hwmgr.h"
27 #include "polaris10_smumgr.h"
28 #include "polaris10_ppsmc.h"
29 #include "smu/smu_7_1_3_d.h"
30 #include "smu/smu_7_1_3_sh_mask.h"
32 int polaris10_fan_ctrl_get_fan_speed_info(struct pp_hwmgr
*hwmgr
,
33 struct phm_fan_speed_info
*fan_speed_info
)
35 if (hwmgr
->thermal_controller
.fanInfo
.bNoFan
)
38 fan_speed_info
->supports_percent_read
= true;
39 fan_speed_info
->supports_percent_write
= true;
40 fan_speed_info
->min_percent
= 0;
41 fan_speed_info
->max_percent
= 100;
43 if (phm_cap_enabled(hwmgr
->platform_descriptor
.platformCaps
,
44 PHM_PlatformCaps_FanSpeedInTableIsRPM
) &&
45 hwmgr
->thermal_controller
.fanInfo
.ucTachometerPulsesPerRevolution
) {
46 fan_speed_info
->supports_rpm_read
= true;
47 fan_speed_info
->supports_rpm_write
= true;
48 fan_speed_info
->min_rpm
= hwmgr
->thermal_controller
.fanInfo
.ulMinRPM
;
49 fan_speed_info
->max_rpm
= hwmgr
->thermal_controller
.fanInfo
.ulMaxRPM
;
51 fan_speed_info
->min_rpm
= 0;
52 fan_speed_info
->max_rpm
= 0;
58 int polaris10_fan_ctrl_get_fan_speed_percent(struct pp_hwmgr
*hwmgr
,
65 if (hwmgr
->thermal_controller
.fanInfo
.bNoFan
)
68 duty100
= PHM_READ_VFPF_INDIRECT_FIELD(hwmgr
->device
, CGS_IND_REG__SMC
,
69 CG_FDO_CTRL1
, FMAX_DUTY100
);
70 duty
= PHM_READ_VFPF_INDIRECT_FIELD(hwmgr
->device
, CGS_IND_REG__SMC
,
71 CG_THERMAL_STATUS
, FDO_PWM_DUTY
);
77 tmp64
= (uint64_t)duty
* 100;
78 do_div(tmp64
, duty100
);
79 *speed
= (uint32_t)tmp64
;
87 int polaris10_fan_ctrl_get_fan_speed_rpm(struct pp_hwmgr
*hwmgr
, uint32_t *speed
)
90 uint32_t crystal_clock_freq
;
92 if (hwmgr
->thermal_controller
.fanInfo
.bNoFan
||
93 (hwmgr
->thermal_controller
.fanInfo
.
94 ucTachometerPulsesPerRevolution
== 0))
97 tach_period
= PHM_READ_VFPF_INDIRECT_FIELD(hwmgr
->device
, CGS_IND_REG__SMC
,
98 CG_TACH_STATUS
, TACH_PERIOD
);
100 if (tach_period
== 0)
103 crystal_clock_freq
= tonga_get_xclk(hwmgr
);
105 *speed
= 60 * crystal_clock_freq
* 10000 / tach_period
;
111 * Set Fan Speed Control to static mode, so that the user can decide what speed to use.
112 * @param hwmgr the address of the powerplay hardware manager.
113 * mode the fan control mode, 0 default, 1 by percent, 5, by RPM
114 * @exception Should always succeed.
116 int polaris10_fan_ctrl_set_static_mode(struct pp_hwmgr
*hwmgr
, uint32_t mode
)
119 if (hwmgr
->fan_ctrl_is_in_default_mode
) {
120 hwmgr
->fan_ctrl_default_mode
=
121 PHM_READ_VFPF_INDIRECT_FIELD(hwmgr
->device
, CGS_IND_REG__SMC
,
122 CG_FDO_CTRL2
, FDO_PWM_MODE
);
124 PHM_READ_VFPF_INDIRECT_FIELD(hwmgr
->device
, CGS_IND_REG__SMC
,
126 hwmgr
->fan_ctrl_is_in_default_mode
= false;
129 PHM_WRITE_VFPF_INDIRECT_FIELD(hwmgr
->device
, CGS_IND_REG__SMC
,
130 CG_FDO_CTRL2
, TMIN
, 0);
131 PHM_WRITE_VFPF_INDIRECT_FIELD(hwmgr
->device
, CGS_IND_REG__SMC
,
132 CG_FDO_CTRL2
, FDO_PWM_MODE
, mode
);
138 * Reset Fan Speed Control to default mode.
139 * @param hwmgr the address of the powerplay hardware manager.
140 * @exception Should always succeed.
142 int polaris10_fan_ctrl_set_default_mode(struct pp_hwmgr
*hwmgr
)
144 if (!hwmgr
->fan_ctrl_is_in_default_mode
) {
145 PHM_WRITE_VFPF_INDIRECT_FIELD(hwmgr
->device
, CGS_IND_REG__SMC
,
146 CG_FDO_CTRL2
, FDO_PWM_MODE
, hwmgr
->fan_ctrl_default_mode
);
147 PHM_WRITE_VFPF_INDIRECT_FIELD(hwmgr
->device
, CGS_IND_REG__SMC
,
148 CG_FDO_CTRL2
, TMIN
, hwmgr
->tmin
);
149 hwmgr
->fan_ctrl_is_in_default_mode
= true;
155 int polaris10_fan_ctrl_start_smc_fan_control(struct pp_hwmgr
*hwmgr
)
159 if (phm_cap_enabled(hwmgr
->platform_descriptor
.platformCaps
,
160 PHM_PlatformCaps_ODFuzzyFanControlSupport
)) {
161 cgs_write_register(hwmgr
->device
, mmSMC_MSG_ARG_0
, FAN_CONTROL_FUZZY
);
162 result
= smum_send_msg_to_smc(hwmgr
->smumgr
, PPSMC_StartFanControl
);
164 if (phm_cap_enabled(hwmgr
->platform_descriptor
.platformCaps
,
165 PHM_PlatformCaps_FanSpeedInTableIsRPM
))
166 hwmgr
->hwmgr_func
->set_max_fan_rpm_output(hwmgr
,
167 hwmgr
->thermal_controller
.
168 advanceFanControlParameters
.usMaxFanRPM
);
170 hwmgr
->hwmgr_func
->set_max_fan_pwm_output(hwmgr
,
171 hwmgr
->thermal_controller
.
172 advanceFanControlParameters
.usMaxFanPWM
);
175 cgs_write_register(hwmgr
->device
, mmSMC_MSG_ARG_0
, FAN_CONTROL_TABLE
);
176 result
= smum_send_msg_to_smc(hwmgr
->smumgr
, PPSMC_StartFanControl
);
179 if (!result
&& hwmgr
->thermal_controller
.
180 advanceFanControlParameters
.ucTargetTemperature
)
181 result
= smum_send_msg_to_smc_with_parameter(hwmgr
->smumgr
,
182 PPSMC_MSG_SetFanTemperatureTarget
,
183 hwmgr
->thermal_controller
.
184 advanceFanControlParameters
.ucTargetTemperature
);
190 int polaris10_fan_ctrl_stop_smc_fan_control(struct pp_hwmgr
*hwmgr
)
192 return smum_send_msg_to_smc(hwmgr
->smumgr
, PPSMC_StopFanControl
);
196 * Set Fan Speed in percent.
197 * @param hwmgr the address of the powerplay hardware manager.
198 * @param speed is the percentage value (0% - 100%) to be set.
199 * @exception Fails is the 100% setting appears to be 0.
201 int polaris10_fan_ctrl_set_fan_speed_percent(struct pp_hwmgr
*hwmgr
,
208 if (hwmgr
->thermal_controller
.fanInfo
.bNoFan
)
214 if (phm_cap_enabled(hwmgr
->platform_descriptor
.platformCaps
,
215 PHM_PlatformCaps_MicrocodeFanControl
))
216 polaris10_fan_ctrl_stop_smc_fan_control(hwmgr
);
218 duty100
= PHM_READ_VFPF_INDIRECT_FIELD(hwmgr
->device
, CGS_IND_REG__SMC
,
219 CG_FDO_CTRL1
, FMAX_DUTY100
);
224 tmp64
= (uint64_t)speed
* duty100
;
226 duty
= (uint32_t)tmp64
;
228 PHM_WRITE_VFPF_INDIRECT_FIELD(hwmgr
->device
, CGS_IND_REG__SMC
,
229 CG_FDO_CTRL0
, FDO_STATIC_DUTY
, duty
);
231 return polaris10_fan_ctrl_set_static_mode(hwmgr
, FDO_PWM_MODE_STATIC
);
235 * Reset Fan Speed to default.
236 * @param hwmgr the address of the powerplay hardware manager.
237 * @exception Always succeeds.
239 int polaris10_fan_ctrl_reset_fan_speed_to_default(struct pp_hwmgr
*hwmgr
)
243 if (hwmgr
->thermal_controller
.fanInfo
.bNoFan
)
246 if (phm_cap_enabled(hwmgr
->platform_descriptor
.platformCaps
,
247 PHM_PlatformCaps_MicrocodeFanControl
)) {
248 result
= polaris10_fan_ctrl_set_static_mode(hwmgr
, FDO_PWM_MODE_STATIC
);
250 result
= polaris10_fan_ctrl_start_smc_fan_control(hwmgr
);
252 result
= polaris10_fan_ctrl_set_default_mode(hwmgr
);
258 * Set Fan Speed in RPM.
259 * @param hwmgr the address of the powerplay hardware manager.
260 * @param speed is the percentage value (min - max) to be set.
261 * @exception Fails is the speed not lie between min and max.
263 int polaris10_fan_ctrl_set_fan_speed_rpm(struct pp_hwmgr
*hwmgr
, uint32_t speed
)
265 uint32_t tach_period
;
266 uint32_t crystal_clock_freq
;
268 if (hwmgr
->thermal_controller
.fanInfo
.bNoFan
||
269 (hwmgr
->thermal_controller
.fanInfo
.
270 ucTachometerPulsesPerRevolution
== 0) ||
271 (speed
< hwmgr
->thermal_controller
.fanInfo
.ulMinRPM
) ||
272 (speed
> hwmgr
->thermal_controller
.fanInfo
.ulMaxRPM
))
275 if (phm_cap_enabled(hwmgr
->platform_descriptor
.platformCaps
,
276 PHM_PlatformCaps_MicrocodeFanControl
))
277 polaris10_fan_ctrl_stop_smc_fan_control(hwmgr
);
279 crystal_clock_freq
= tonga_get_xclk(hwmgr
);
281 tach_period
= 60 * crystal_clock_freq
* 10000 / (8 * speed
);
283 PHM_WRITE_VFPF_INDIRECT_FIELD(hwmgr
->device
, CGS_IND_REG__SMC
,
284 CG_TACH_STATUS
, TACH_PERIOD
, tach_period
);
286 return polaris10_fan_ctrl_set_static_mode(hwmgr
, FDO_PWM_MODE_STATIC
);
290 * Reads the remote temperature from the SIslands thermal controller.
292 * @param hwmgr The address of the hardware manager.
294 int polaris10_thermal_get_temperature(struct pp_hwmgr
*hwmgr
)
298 temp
= PHM_READ_VFPF_INDIRECT_FIELD(hwmgr
->device
, CGS_IND_REG__SMC
,
299 CG_MULT_THERMAL_STATUS
, CTF_TEMP
);
301 /* Bit 9 means the reading is lower than the lowest usable value. */
303 temp
= POLARIS10_THERMAL_MAXIMUM_TEMP_READING
;
307 temp
*= PP_TEMPERATURE_UNITS_PER_CENTIGRADES
;
313 * Set the requested temperature range for high and low alert signals
315 * @param hwmgr The address of the hardware manager.
316 * @param range Temperature range to be programmed for high and low alert signals
317 * @exception PP_Result_BadInput if the input data is not valid.
319 static int polaris10_thermal_set_temperature_range(struct pp_hwmgr
*hwmgr
,
320 uint32_t low_temp
, uint32_t high_temp
)
322 uint32_t low
= POLARIS10_THERMAL_MINIMUM_ALERT_TEMP
*
323 PP_TEMPERATURE_UNITS_PER_CENTIGRADES
;
324 uint32_t high
= POLARIS10_THERMAL_MAXIMUM_ALERT_TEMP
*
325 PP_TEMPERATURE_UNITS_PER_CENTIGRADES
;
329 if (high
> high_temp
)
335 PHM_WRITE_VFPF_INDIRECT_FIELD(hwmgr
->device
, CGS_IND_REG__SMC
,
336 CG_THERMAL_INT
, DIG_THERM_INTH
,
337 (high
/ PP_TEMPERATURE_UNITS_PER_CENTIGRADES
));
338 PHM_WRITE_VFPF_INDIRECT_FIELD(hwmgr
->device
, CGS_IND_REG__SMC
,
339 CG_THERMAL_INT
, DIG_THERM_INTL
,
340 (low
/ PP_TEMPERATURE_UNITS_PER_CENTIGRADES
));
341 PHM_WRITE_VFPF_INDIRECT_FIELD(hwmgr
->device
, CGS_IND_REG__SMC
,
342 CG_THERMAL_CTRL
, DIG_THERM_DPM
,
343 (high
/ PP_TEMPERATURE_UNITS_PER_CENTIGRADES
));
349 * Programs thermal controller one-time setting registers
351 * @param hwmgr The address of the hardware manager.
353 static int polaris10_thermal_initialize(struct pp_hwmgr
*hwmgr
)
355 if (hwmgr
->thermal_controller
.fanInfo
.ucTachometerPulsesPerRevolution
)
356 PHM_WRITE_VFPF_INDIRECT_FIELD(hwmgr
->device
, CGS_IND_REG__SMC
,
357 CG_TACH_CTRL
, EDGE_PER_REV
,
358 hwmgr
->thermal_controller
.fanInfo
.
359 ucTachometerPulsesPerRevolution
- 1);
361 PHM_WRITE_VFPF_INDIRECT_FIELD(hwmgr
->device
, CGS_IND_REG__SMC
,
362 CG_FDO_CTRL2
, TACH_PWM_RESP_RATE
, 0x28);
368 * Enable thermal alerts on the RV770 thermal controller.
370 * @param hwmgr The address of the hardware manager.
372 static int polaris10_thermal_enable_alert(struct pp_hwmgr
*hwmgr
)
376 alert
= PHM_READ_VFPF_INDIRECT_FIELD(hwmgr
->device
, CGS_IND_REG__SMC
,
377 CG_THERMAL_INT
, THERM_INT_MASK
);
378 alert
&= ~(POLARIS10_THERMAL_HIGH_ALERT_MASK
| POLARIS10_THERMAL_LOW_ALERT_MASK
);
379 PHM_WRITE_VFPF_INDIRECT_FIELD(hwmgr
->device
, CGS_IND_REG__SMC
,
380 CG_THERMAL_INT
, THERM_INT_MASK
, alert
);
382 /* send message to SMU to enable internal thermal interrupts */
383 return smum_send_msg_to_smc(hwmgr
->smumgr
, PPSMC_MSG_Thermal_Cntl_Enable
);
387 * Disable thermal alerts on the RV770 thermal controller.
388 * @param hwmgr The address of the hardware manager.
390 static int polaris10_thermal_disable_alert(struct pp_hwmgr
*hwmgr
)
394 alert
= PHM_READ_VFPF_INDIRECT_FIELD(hwmgr
->device
, CGS_IND_REG__SMC
,
395 CG_THERMAL_INT
, THERM_INT_MASK
);
396 alert
|= (POLARIS10_THERMAL_HIGH_ALERT_MASK
| POLARIS10_THERMAL_LOW_ALERT_MASK
);
397 PHM_WRITE_VFPF_INDIRECT_FIELD(hwmgr
->device
, CGS_IND_REG__SMC
,
398 CG_THERMAL_INT
, THERM_INT_MASK
, alert
);
400 /* send message to SMU to disable internal thermal interrupts */
401 return smum_send_msg_to_smc(hwmgr
->smumgr
, PPSMC_MSG_Thermal_Cntl_Disable
);
405 * Uninitialize the thermal controller.
406 * Currently just disables alerts.
407 * @param hwmgr The address of the hardware manager.
409 int polaris10_thermal_stop_thermal_controller(struct pp_hwmgr
*hwmgr
)
411 int result
= polaris10_thermal_disable_alert(hwmgr
);
413 if (!hwmgr
->thermal_controller
.fanInfo
.bNoFan
)
414 polaris10_fan_ctrl_set_default_mode(hwmgr
);
420 * Set up the fan table to control the fan using the SMC.
421 * @param hwmgr the address of the powerplay hardware manager.
422 * @param pInput the pointer to input data
423 * @param pOutput the pointer to output data
424 * @param pStorage the pointer to temporary storage
425 * @param Result the last failure code
426 * @return result from set temperature range routine
428 int tf_polaris10_thermal_setup_fan_table(struct pp_hwmgr
*hwmgr
,
429 void *input
, void *output
, void *storage
, int result
)
431 struct polaris10_hwmgr
*data
= (struct polaris10_hwmgr
*)(hwmgr
->backend
);
432 SMU74_Discrete_FanTable fan_table
= { FDO_MODE_HARDWARE
};
434 uint32_t t_diff1
, t_diff2
, pwm_diff1
, pwm_diff2
;
435 uint16_t fdo_min
, slope1
, slope2
;
436 uint32_t reference_clock
;
440 if (data
->fan_table_start
== 0) {
441 phm_cap_unset(hwmgr
->platform_descriptor
.platformCaps
,
442 PHM_PlatformCaps_MicrocodeFanControl
);
446 duty100
= PHM_READ_VFPF_INDIRECT_FIELD(hwmgr
->device
, CGS_IND_REG__SMC
,
447 CG_FDO_CTRL1
, FMAX_DUTY100
);
450 phm_cap_unset(hwmgr
->platform_descriptor
.platformCaps
,
451 PHM_PlatformCaps_MicrocodeFanControl
);
455 tmp64
= hwmgr
->thermal_controller
.advanceFanControlParameters
.
457 do_div(tmp64
, 10000);
458 fdo_min
= (uint16_t)tmp64
;
460 t_diff1
= hwmgr
->thermal_controller
.advanceFanControlParameters
.usTMed
-
461 hwmgr
->thermal_controller
.advanceFanControlParameters
.usTMin
;
462 t_diff2
= hwmgr
->thermal_controller
.advanceFanControlParameters
.usTHigh
-
463 hwmgr
->thermal_controller
.advanceFanControlParameters
.usTMed
;
465 pwm_diff1
= hwmgr
->thermal_controller
.advanceFanControlParameters
.usPWMMed
-
466 hwmgr
->thermal_controller
.advanceFanControlParameters
.usPWMMin
;
467 pwm_diff2
= hwmgr
->thermal_controller
.advanceFanControlParameters
.usPWMHigh
-
468 hwmgr
->thermal_controller
.advanceFanControlParameters
.usPWMMed
;
470 slope1
= (uint16_t)((50 + ((16 * duty100
* pwm_diff1
) / t_diff1
)) / 100);
471 slope2
= (uint16_t)((50 + ((16 * duty100
* pwm_diff2
) / t_diff2
)) / 100);
473 fan_table
.TempMin
= cpu_to_be16((50 + hwmgr
->
474 thermal_controller
.advanceFanControlParameters
.usTMin
) / 100);
475 fan_table
.TempMed
= cpu_to_be16((50 + hwmgr
->
476 thermal_controller
.advanceFanControlParameters
.usTMed
) / 100);
477 fan_table
.TempMax
= cpu_to_be16((50 + hwmgr
->
478 thermal_controller
.advanceFanControlParameters
.usTMax
) / 100);
480 fan_table
.Slope1
= cpu_to_be16(slope1
);
481 fan_table
.Slope2
= cpu_to_be16(slope2
);
483 fan_table
.FdoMin
= cpu_to_be16(fdo_min
);
485 fan_table
.HystDown
= cpu_to_be16(hwmgr
->
486 thermal_controller
.advanceFanControlParameters
.ucTHyst
);
488 fan_table
.HystUp
= cpu_to_be16(1);
490 fan_table
.HystSlope
= cpu_to_be16(1);
492 fan_table
.TempRespLim
= cpu_to_be16(5);
494 reference_clock
= tonga_get_xclk(hwmgr
);
496 fan_table
.RefreshPeriod
= cpu_to_be32((hwmgr
->
497 thermal_controller
.advanceFanControlParameters
.ulCycleDelay
*
498 reference_clock
) / 1600);
500 fan_table
.FdoMax
= cpu_to_be16((uint16_t)duty100
);
502 fan_table
.TempSrc
= (uint8_t)PHM_READ_VFPF_INDIRECT_FIELD(
503 hwmgr
->device
, CGS_IND_REG__SMC
,
504 CG_MULT_THERMAL_CTRL
, TEMP_SEL
);
506 res
= polaris10_copy_bytes_to_smc(hwmgr
->smumgr
, data
->fan_table_start
,
507 (uint8_t *)&fan_table
, (uint32_t)sizeof(fan_table
),
510 if (!res
&& hwmgr
->thermal_controller
.
511 advanceFanControlParameters
.ucMinimumPWMLimit
)
512 res
= smum_send_msg_to_smc_with_parameter(hwmgr
->smumgr
,
513 PPSMC_MSG_SetFanMinPwm
,
514 hwmgr
->thermal_controller
.
515 advanceFanControlParameters
.ucMinimumPWMLimit
);
517 if (!res
&& hwmgr
->thermal_controller
.
518 advanceFanControlParameters
.ulMinFanSCLKAcousticLimit
)
519 res
= smum_send_msg_to_smc_with_parameter(hwmgr
->smumgr
,
520 PPSMC_MSG_SetFanSclkTarget
,
521 hwmgr
->thermal_controller
.
522 advanceFanControlParameters
.ulMinFanSCLKAcousticLimit
);
525 phm_cap_unset(hwmgr
->platform_descriptor
.platformCaps
,
526 PHM_PlatformCaps_MicrocodeFanControl
);
532 * Start the fan control on the SMC.
533 * @param hwmgr the address of the powerplay hardware manager.
534 * @param pInput the pointer to input data
535 * @param pOutput the pointer to output data
536 * @param pStorage the pointer to temporary storage
537 * @param Result the last failure code
538 * @return result from set temperature range routine
540 int tf_polaris10_thermal_start_smc_fan_control(struct pp_hwmgr
*hwmgr
,
541 void *input
, void *output
, void *storage
, int result
)
543 /* If the fantable setup has failed we could have disabled
544 * PHM_PlatformCaps_MicrocodeFanControl even after
545 * this function was included in the table.
546 * Make sure that we still think controlling the fan is OK.
548 if (phm_cap_enabled(hwmgr
->platform_descriptor
.platformCaps
,
549 PHM_PlatformCaps_MicrocodeFanControl
)) {
550 polaris10_fan_ctrl_start_smc_fan_control(hwmgr
);
551 polaris10_fan_ctrl_set_static_mode(hwmgr
, FDO_PWM_MODE_STATIC
);
558 * Set temperature range for high and low alerts
559 * @param hwmgr the address of the powerplay hardware manager.
560 * @param pInput the pointer to input data
561 * @param pOutput the pointer to output data
562 * @param pStorage the pointer to temporary storage
563 * @param Result the last failure code
564 * @return result from set temperature range routine
566 int tf_polaris10_thermal_set_temperature_range(struct pp_hwmgr
*hwmgr
,
567 void *input
, void *output
, void *storage
, int result
)
569 struct PP_TemperatureRange
*range
= (struct PP_TemperatureRange
*)input
;
574 return polaris10_thermal_set_temperature_range(hwmgr
, range
->min
, range
->max
);
578 * Programs one-time setting registers
579 * @param hwmgr the address of the powerplay hardware manager.
580 * @param pInput the pointer to input data
581 * @param pOutput the pointer to output data
582 * @param pStorage the pointer to temporary storage
583 * @param Result the last failure code
584 * @return result from initialize thermal controller routine
586 int tf_polaris10_thermal_initialize(struct pp_hwmgr
*hwmgr
,
587 void *input
, void *output
, void *storage
, int result
)
589 return polaris10_thermal_initialize(hwmgr
);
593 * Enable high and low alerts
594 * @param hwmgr the address of the powerplay hardware manager.
595 * @param pInput the pointer to input data
596 * @param pOutput the pointer to output data
597 * @param pStorage the pointer to temporary storage
598 * @param Result the last failure code
599 * @return result from enable alert routine
601 int tf_polaris10_thermal_enable_alert(struct pp_hwmgr
*hwmgr
,
602 void *input
, void *output
, void *storage
, int result
)
604 return polaris10_thermal_enable_alert(hwmgr
);
608 * Disable high and low alerts
609 * @param hwmgr the address of the powerplay hardware manager.
610 * @param pInput the pointer to input data
611 * @param pOutput the pointer to output data
612 * @param pStorage the pointer to temporary storage
613 * @param Result the last failure code
614 * @return result from disable alert routine
616 static int tf_polaris10_thermal_disable_alert(struct pp_hwmgr
*hwmgr
,
617 void *input
, void *output
, void *storage
, int result
)
619 return polaris10_thermal_disable_alert(hwmgr
);
622 static int tf_polaris10_thermal_avfs_enable(struct pp_hwmgr
*hwmgr
,
623 void *input
, void *output
, void *storage
, int result
)
626 struct pp_smumgr
*smumgr
= (struct pp_smumgr
*)(hwmgr
->smumgr
);
627 struct polaris10_smumgr
*smu_data
= (struct polaris10_smumgr
*)(smumgr
->backend
);
629 if (smu_data
->avfs
.avfs_btc_status
!= AVFS_BTC_ENABLEAVFS
)
632 ret
= (smum_send_msg_to_smc(smumgr
, PPSMC_MSG_EnableAvfs
) == 0) ?
636 /* If this param is not changed, this function could fire unnecessarily */
637 smu_data
->avfs
.avfs_btc_status
= AVFS_BTC_COMPLETED_PREVIOUSLY
;
642 static const struct phm_master_table_item
643 polaris10_thermal_start_thermal_controller_master_list
[] = {
644 {NULL
, tf_polaris10_thermal_initialize
},
645 {NULL
, tf_polaris10_thermal_set_temperature_range
},
646 {NULL
, tf_polaris10_thermal_enable_alert
},
647 {NULL
, tf_polaris10_thermal_avfs_enable
},
648 /* We should restrict performance levels to low before we halt the SMC.
649 * On the other hand we are still in boot state when we do this
650 * so it would be pointless.
651 * If this assumption changes we have to revisit this table.
653 {NULL
, tf_polaris10_thermal_setup_fan_table
},
654 {NULL
, tf_polaris10_thermal_start_smc_fan_control
},
658 static const struct phm_master_table_header
659 polaris10_thermal_start_thermal_controller_master
= {
661 PHM_MasterTableFlag_None
,
662 polaris10_thermal_start_thermal_controller_master_list
665 static const struct phm_master_table_item
666 polaris10_thermal_set_temperature_range_master_list
[] = {
667 {NULL
, tf_polaris10_thermal_disable_alert
},
668 {NULL
, tf_polaris10_thermal_set_temperature_range
},
669 {NULL
, tf_polaris10_thermal_enable_alert
},
673 static const struct phm_master_table_header
674 polaris10_thermal_set_temperature_range_master
= {
676 PHM_MasterTableFlag_None
,
677 polaris10_thermal_set_temperature_range_master_list
680 int polaris10_thermal_ctrl_uninitialize_thermal_controller(struct pp_hwmgr
*hwmgr
)
682 if (!hwmgr
->thermal_controller
.fanInfo
.bNoFan
)
683 polaris10_fan_ctrl_set_default_mode(hwmgr
);
688 * Initializes the thermal controller related functions in the Hardware Manager structure.
689 * @param hwmgr The address of the hardware manager.
690 * @exception Any error code from the low-level communication.
692 int pp_polaris10_thermal_initialize(struct pp_hwmgr
*hwmgr
)
696 result
= phm_construct_table(hwmgr
,
697 &polaris10_thermal_set_temperature_range_master
,
698 &(hwmgr
->set_temperature_range
));
701 result
= phm_construct_table(hwmgr
,
702 &polaris10_thermal_start_thermal_controller_master
,
703 &(hwmgr
->start_thermal_controller
));
705 phm_destroy_table(hwmgr
, &(hwmgr
->set_temperature_range
));
709 hwmgr
->fan_ctrl_is_in_default_mode
= true;