2 * Copyright 2015 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.
23 #include <asm/div64.h>
24 #include "tonga_thermal.h"
25 #include "tonga_hwmgr.h"
26 #include "tonga_smumgr.h"
27 #include "tonga_ppsmc.h"
28 #include "smu/smu_7_1_2_d.h"
29 #include "smu/smu_7_1_2_sh_mask.h"
32 * Get Fan Speed Control Parameters.
33 * @param hwmgr the address of the powerplay hardware manager.
34 * @param pSpeed is the address of the structure where the result is to be placed.
35 * @exception Always succeeds except if we cannot zero out the output structure.
37 int tonga_fan_ctrl_get_fan_speed_info(struct pp_hwmgr
*hwmgr
, struct phm_fan_speed_info
*fan_speed_info
)
40 if (hwmgr
->thermal_controller
.fanInfo
.bNoFan
)
43 fan_speed_info
->supports_percent_read
= true;
44 fan_speed_info
->supports_percent_write
= true;
45 fan_speed_info
->min_percent
= 0;
46 fan_speed_info
->max_percent
= 100;
48 if (0 != hwmgr
->thermal_controller
.fanInfo
.ucTachometerPulsesPerRevolution
) {
49 fan_speed_info
->supports_rpm_read
= true;
50 fan_speed_info
->supports_rpm_write
= true;
51 fan_speed_info
->min_rpm
= hwmgr
->thermal_controller
.fanInfo
.ulMinRPM
;
52 fan_speed_info
->max_rpm
= hwmgr
->thermal_controller
.fanInfo
.ulMaxRPM
;
54 fan_speed_info
->min_rpm
= 0;
55 fan_speed_info
->max_rpm
= 0;
62 * Get Fan Speed in percent.
63 * @param hwmgr the address of the powerplay hardware manager.
64 * @param pSpeed is the address of the structure where the result is to be placed.
65 * @exception Fails is the 100% setting appears to be 0.
67 int tonga_fan_ctrl_get_fan_speed_percent(struct pp_hwmgr
*hwmgr
, uint32_t *speed
)
73 if (hwmgr
->thermal_controller
.fanInfo
.bNoFan
)
76 duty100
= PHM_READ_VFPF_INDIRECT_FIELD(hwmgr
->device
, CGS_IND_REG__SMC
, CG_FDO_CTRL1
, FMAX_DUTY100
);
77 duty
= PHM_READ_VFPF_INDIRECT_FIELD(hwmgr
->device
, CGS_IND_REG__SMC
, CG_THERMAL_STATUS
, FDO_PWM_DUTY
);
83 tmp64
= (uint64_t)duty
* 100;
84 do_div(tmp64
, duty100
);
85 *speed
= (uint32_t)tmp64
;
94 * Get Fan Speed in RPM.
95 * @param hwmgr the address of the powerplay hardware manager.
96 * @param speed is the address of the structure where the result is to be placed.
97 * @exception Returns not supported if no fan is found or if pulses per revolution are not set
99 int tonga_fan_ctrl_get_fan_speed_rpm(struct pp_hwmgr
*hwmgr
, uint32_t *speed
)
105 * Set Fan Speed Control to static mode, so that the user can decide what speed to use.
106 * @param hwmgr the address of the powerplay hardware manager.
107 * mode the fan control mode, 0 default, 1 by percent, 5, by RPM
108 * @exception Should always succeed.
110 int tonga_fan_ctrl_set_static_mode(struct pp_hwmgr
*hwmgr
, uint32_t mode
)
113 if (hwmgr
->fan_ctrl_is_in_default_mode
) {
114 hwmgr
->fan_ctrl_default_mode
= PHM_READ_VFPF_INDIRECT_FIELD(hwmgr
->device
, CGS_IND_REG__SMC
, CG_FDO_CTRL2
, FDO_PWM_MODE
);
115 hwmgr
->tmin
= PHM_READ_VFPF_INDIRECT_FIELD(hwmgr
->device
, CGS_IND_REG__SMC
, CG_FDO_CTRL2
, TMIN
);
116 hwmgr
->fan_ctrl_is_in_default_mode
= false;
119 PHM_WRITE_VFPF_INDIRECT_FIELD(hwmgr
->device
, CGS_IND_REG__SMC
, CG_FDO_CTRL2
, TMIN
, 0);
120 PHM_WRITE_VFPF_INDIRECT_FIELD(hwmgr
->device
, CGS_IND_REG__SMC
, CG_FDO_CTRL2
, FDO_PWM_MODE
, mode
);
126 * Reset Fan Speed Control to default mode.
127 * @param hwmgr the address of the powerplay hardware manager.
128 * @exception Should always succeed.
130 int tonga_fan_ctrl_set_default_mode(struct pp_hwmgr
*hwmgr
)
132 if (!hwmgr
->fan_ctrl_is_in_default_mode
) {
133 PHM_WRITE_VFPF_INDIRECT_FIELD(hwmgr
->device
, CGS_IND_REG__SMC
, CG_FDO_CTRL2
, FDO_PWM_MODE
, hwmgr
->fan_ctrl_default_mode
);
134 PHM_WRITE_VFPF_INDIRECT_FIELD(hwmgr
->device
, CGS_IND_REG__SMC
, CG_FDO_CTRL2
, TMIN
, hwmgr
->tmin
);
135 hwmgr
->fan_ctrl_is_in_default_mode
= true;
141 int tonga_fan_ctrl_start_smc_fan_control(struct pp_hwmgr
*hwmgr
)
145 if (phm_cap_enabled(hwmgr
->platform_descriptor
.platformCaps
, PHM_PlatformCaps_ODFuzzyFanControlSupport
)) {
146 cgs_write_register(hwmgr
->device
, mmSMC_MSG_ARG_0
, FAN_CONTROL_FUZZY
);
147 result
= (smum_send_msg_to_smc(hwmgr
->smumgr
, PPSMC_StartFanControl
) == 0) ? 0 : -EINVAL
;
149 if (phm_cap_enabled(hwmgr->platform_descriptor.platformCaps, PHM_PlatformCaps_FanSpeedInTableIsRPM))
150 hwmgr->set_max_fan_rpm_output(hwmgr, hwmgr->thermal_controller.advanceFanControlParameters.usMaxFanRPM);
152 hwmgr->set_max_fan_pwm_output(hwmgr, hwmgr->thermal_controller.advanceFanControlParameters.usMaxFanPWM);
155 cgs_write_register(hwmgr
->device
, mmSMC_MSG_ARG_0
, FAN_CONTROL_TABLE
);
156 result
= (smum_send_msg_to_smc(hwmgr
->smumgr
, PPSMC_StartFanControl
) == 0) ? 0 : -EINVAL
;
158 /* TO DO FOR SOME DEVICE ID 0X692b, send this msg return invalid command.
159 if (result == 0 && hwmgr->thermal_controller.advanceFanControlParameters.ucTargetTemperature != 0)
160 result = (0 == smum_send_msg_to_smc_with_parameter(hwmgr->smumgr, PPSMC_MSG_SetFanTemperatureTarget, \
161 hwmgr->thermal_controller.advanceFanControlParameters.ucTargetTemperature) ? 0 : -EINVAL);
167 int tonga_fan_ctrl_stop_smc_fan_control(struct pp_hwmgr
*hwmgr
)
169 return (smum_send_msg_to_smc(hwmgr
->smumgr
, PPSMC_StopFanControl
) == 0) ? 0 : -EINVAL
;
173 * Set Fan Speed in percent.
174 * @param hwmgr the address of the powerplay hardware manager.
175 * @param speed is the percentage value (0% - 100%) to be set.
176 * @exception Fails is the 100% setting appears to be 0.
178 int tonga_fan_ctrl_set_fan_speed_percent(struct pp_hwmgr
*hwmgr
, uint32_t speed
)
184 if (hwmgr
->thermal_controller
.fanInfo
.bNoFan
)
190 if (phm_cap_enabled(hwmgr
->platform_descriptor
.platformCaps
, PHM_PlatformCaps_MicrocodeFanControl
))
191 tonga_fan_ctrl_stop_smc_fan_control(hwmgr
);
193 duty100
= PHM_READ_VFPF_INDIRECT_FIELD(hwmgr
->device
, CGS_IND_REG__SMC
, CG_FDO_CTRL1
, FMAX_DUTY100
);
198 tmp64
= (uint64_t)speed
* 100;
199 do_div(tmp64
, duty100
);
200 duty
= (uint32_t)tmp64
;
202 PHM_WRITE_VFPF_INDIRECT_FIELD(hwmgr
->device
, CGS_IND_REG__SMC
, CG_FDO_CTRL0
, FDO_STATIC_DUTY
, duty
);
204 return tonga_fan_ctrl_set_static_mode(hwmgr
, FDO_PWM_MODE_STATIC
);
208 * Reset Fan Speed to default.
209 * @param hwmgr the address of the powerplay hardware manager.
210 * @exception Always succeeds.
212 int tonga_fan_ctrl_reset_fan_speed_to_default(struct pp_hwmgr
*hwmgr
)
216 if (hwmgr
->thermal_controller
.fanInfo
.bNoFan
)
219 if (phm_cap_enabled(hwmgr
->platform_descriptor
.platformCaps
, PHM_PlatformCaps_MicrocodeFanControl
)) {
220 result
= tonga_fan_ctrl_set_static_mode(hwmgr
, FDO_PWM_MODE_STATIC
);
222 result
= tonga_fan_ctrl_start_smc_fan_control(hwmgr
);
224 result
= tonga_fan_ctrl_set_default_mode(hwmgr
);
230 * Set Fan Speed in RPM.
231 * @param hwmgr the address of the powerplay hardware manager.
232 * @param speed is the percentage value (min - max) to be set.
233 * @exception Fails is the speed not lie between min and max.
235 int tonga_fan_ctrl_set_fan_speed_rpm(struct pp_hwmgr
*hwmgr
, uint32_t speed
)
241 * Reads the remote temperature from the SIslands thermal controller.
243 * @param hwmgr The address of the hardware manager.
245 int tonga_thermal_get_temperature(struct pp_hwmgr
*hwmgr
)
249 temp
= PHM_READ_VFPF_INDIRECT_FIELD(hwmgr
->device
, CGS_IND_REG__SMC
, CG_MULT_THERMAL_STATUS
, CTF_TEMP
);
251 /* Bit 9 means the reading is lower than the lowest usable value. */
252 if (0 != (0x200 & temp
))
253 temp
= TONGA_THERMAL_MAXIMUM_TEMP_READING
;
255 temp
= (temp
& 0x1ff);
257 temp
= temp
* PP_TEMPERATURE_UNITS_PER_CENTIGRADES
;
263 * Set the requested temperature range for high and low alert signals
265 * @param hwmgr The address of the hardware manager.
266 * @param range Temperature range to be programmed for high and low alert signals
267 * @exception PP_Result_BadInput if the input data is not valid.
269 static int tonga_thermal_set_temperature_range(struct pp_hwmgr
*hwmgr
, uint32_t low_temp
, uint32_t high_temp
)
271 uint32_t low
= TONGA_THERMAL_MINIMUM_ALERT_TEMP
* PP_TEMPERATURE_UNITS_PER_CENTIGRADES
;
272 uint32_t high
= TONGA_THERMAL_MAXIMUM_ALERT_TEMP
* PP_TEMPERATURE_UNITS_PER_CENTIGRADES
;
276 if (high
> high_temp
)
282 PHM_WRITE_VFPF_INDIRECT_FIELD(hwmgr
->device
, CGS_IND_REG__SMC
, CG_THERMAL_INT
, DIG_THERM_INTH
, (high
/ PP_TEMPERATURE_UNITS_PER_CENTIGRADES
));
283 PHM_WRITE_VFPF_INDIRECT_FIELD(hwmgr
->device
, CGS_IND_REG__SMC
, CG_THERMAL_INT
, DIG_THERM_INTL
, (low
/ PP_TEMPERATURE_UNITS_PER_CENTIGRADES
));
284 PHM_WRITE_VFPF_INDIRECT_FIELD(hwmgr
->device
, CGS_IND_REG__SMC
, CG_THERMAL_CTRL
, DIG_THERM_DPM
, (high
/ PP_TEMPERATURE_UNITS_PER_CENTIGRADES
));
290 * Programs thermal controller one-time setting registers
292 * @param hwmgr The address of the hardware manager.
294 static int tonga_thermal_initialize(struct pp_hwmgr
*hwmgr
)
296 if (0 != hwmgr
->thermal_controller
.fanInfo
.ucTachometerPulsesPerRevolution
)
297 PHM_WRITE_VFPF_INDIRECT_FIELD(hwmgr
->device
, CGS_IND_REG__SMC
,
298 CG_TACH_CTRL
, EDGE_PER_REV
,
299 hwmgr
->thermal_controller
.fanInfo
.ucTachometerPulsesPerRevolution
- 1);
301 PHM_WRITE_VFPF_INDIRECT_FIELD(hwmgr
->device
, CGS_IND_REG__SMC
, CG_FDO_CTRL2
, TACH_PWM_RESP_RATE
, 0x28);
307 * Enable thermal alerts on the RV770 thermal controller.
309 * @param hwmgr The address of the hardware manager.
311 static int tonga_thermal_enable_alert(struct pp_hwmgr
*hwmgr
)
315 alert
= PHM_READ_VFPF_INDIRECT_FIELD(hwmgr
->device
, CGS_IND_REG__SMC
, CG_THERMAL_INT
, THERM_INT_MASK
);
316 alert
&= ~(TONGA_THERMAL_HIGH_ALERT_MASK
| TONGA_THERMAL_LOW_ALERT_MASK
);
317 PHM_WRITE_VFPF_INDIRECT_FIELD(hwmgr
->device
, CGS_IND_REG__SMC
, CG_THERMAL_INT
, THERM_INT_MASK
, alert
);
319 /* send message to SMU to enable internal thermal interrupts */
320 return (smum_send_msg_to_smc(hwmgr
->smumgr
, PPSMC_MSG_Thermal_Cntl_Enable
) == 0) ? 0 : -1;
324 * Disable thermal alerts on the RV770 thermal controller.
325 * @param hwmgr The address of the hardware manager.
327 static int tonga_thermal_disable_alert(struct pp_hwmgr
*hwmgr
)
331 alert
= PHM_READ_VFPF_INDIRECT_FIELD(hwmgr
->device
, CGS_IND_REG__SMC
, CG_THERMAL_INT
, THERM_INT_MASK
);
332 alert
|= (TONGA_THERMAL_HIGH_ALERT_MASK
| TONGA_THERMAL_LOW_ALERT_MASK
);
333 PHM_WRITE_VFPF_INDIRECT_FIELD(hwmgr
->device
, CGS_IND_REG__SMC
, CG_THERMAL_INT
, THERM_INT_MASK
, alert
);
335 /* send message to SMU to disable internal thermal interrupts */
336 return (smum_send_msg_to_smc(hwmgr
->smumgr
, PPSMC_MSG_Thermal_Cntl_Disable
) == 0) ? 0 : -1;
340 * Uninitialize the thermal controller.
341 * Currently just disables alerts.
342 * @param hwmgr The address of the hardware manager.
344 int tonga_thermal_stop_thermal_controller(struct pp_hwmgr
*hwmgr
)
346 int result
= tonga_thermal_disable_alert(hwmgr
);
348 if (hwmgr
->thermal_controller
.fanInfo
.bNoFan
)
349 tonga_fan_ctrl_set_default_mode(hwmgr
);
355 * Set up the fan table to control the fan using the SMC.
356 * @param hwmgr the address of the powerplay hardware manager.
357 * @param pInput the pointer to input data
358 * @param pOutput the pointer to output data
359 * @param pStorage the pointer to temporary storage
360 * @param Result the last failure code
361 * @return result from set temperature range routine
363 int tf_tonga_thermal_setup_fan_table(struct pp_hwmgr
*hwmgr
, void *input
, void *output
, void *storage
, int result
)
365 struct tonga_hwmgr
*data
= (struct tonga_hwmgr
*)(hwmgr
->backend
);
366 SMU72_Discrete_FanTable fan_table
= { FDO_MODE_HARDWARE
};
368 uint32_t t_diff1
, t_diff2
, pwm_diff1
, pwm_diff2
;
369 uint16_t fdo_min
, slope1
, slope2
;
370 uint32_t reference_clock
;
374 if (!phm_cap_enabled(hwmgr
->platform_descriptor
.platformCaps
, PHM_PlatformCaps_MicrocodeFanControl
))
377 if (0 == data
->fan_table_start
) {
378 phm_cap_unset(hwmgr
->platform_descriptor
.platformCaps
, PHM_PlatformCaps_MicrocodeFanControl
);
382 duty100
= PHM_READ_VFPF_INDIRECT_FIELD(hwmgr
->device
, CGS_IND_REG__SMC
, CG_FDO_CTRL1
, FMAX_DUTY100
);
385 phm_cap_unset(hwmgr
->platform_descriptor
.platformCaps
, PHM_PlatformCaps_MicrocodeFanControl
);
389 tmp64
= hwmgr
->thermal_controller
.advanceFanControlParameters
.usPWMMin
* duty100
;
390 do_div(tmp64
, 10000);
391 fdo_min
= (uint16_t)tmp64
;
393 t_diff1
= hwmgr
->thermal_controller
.advanceFanControlParameters
.usTMed
- hwmgr
->thermal_controller
.advanceFanControlParameters
.usTMin
;
394 t_diff2
= hwmgr
->thermal_controller
.advanceFanControlParameters
.usTHigh
- hwmgr
->thermal_controller
.advanceFanControlParameters
.usTMed
;
396 pwm_diff1
= hwmgr
->thermal_controller
.advanceFanControlParameters
.usPWMMed
- hwmgr
->thermal_controller
.advanceFanControlParameters
.usPWMMin
;
397 pwm_diff2
= hwmgr
->thermal_controller
.advanceFanControlParameters
.usPWMHigh
- hwmgr
->thermal_controller
.advanceFanControlParameters
.usPWMMed
;
399 slope1
= (uint16_t)((50 + ((16 * duty100
* pwm_diff1
) / t_diff1
)) / 100);
400 slope2
= (uint16_t)((50 + ((16 * duty100
* pwm_diff2
) / t_diff2
)) / 100);
402 fan_table
.TempMin
= cpu_to_be16((50 + hwmgr
->thermal_controller
.advanceFanControlParameters
.usTMin
) / 100);
403 fan_table
.TempMed
= cpu_to_be16((50 + hwmgr
->thermal_controller
.advanceFanControlParameters
.usTMed
) / 100);
404 fan_table
.TempMax
= cpu_to_be16((50 + hwmgr
->thermal_controller
.advanceFanControlParameters
.usTMax
) / 100);
406 fan_table
.Slope1
= cpu_to_be16(slope1
);
407 fan_table
.Slope2
= cpu_to_be16(slope2
);
409 fan_table
.FdoMin
= cpu_to_be16(fdo_min
);
411 fan_table
.HystDown
= cpu_to_be16(hwmgr
->thermal_controller
.advanceFanControlParameters
.ucTHyst
);
413 fan_table
.HystUp
= cpu_to_be16(1);
415 fan_table
.HystSlope
= cpu_to_be16(1);
417 fan_table
.TempRespLim
= cpu_to_be16(5);
419 reference_clock
= tonga_get_xclk(hwmgr
);
421 fan_table
.RefreshPeriod
= cpu_to_be32((hwmgr
->thermal_controller
.advanceFanControlParameters
.ulCycleDelay
* reference_clock
) / 1600);
423 fan_table
.FdoMax
= cpu_to_be16((uint16_t)duty100
);
425 fan_table
.TempSrc
= (uint8_t)PHM_READ_VFPF_INDIRECT_FIELD(hwmgr
->device
, CGS_IND_REG__SMC
, CG_MULT_THERMAL_CTRL
, TEMP_SEL
);
427 fan_table
.FanControl_GL_Flag
= 1;
429 res
= tonga_copy_bytes_to_smc(hwmgr
->smumgr
, data
->fan_table_start
, (uint8_t *)&fan_table
, (uint32_t)sizeof(fan_table
), data
->sram_end
);
430 /* TO DO FOR SOME DEVICE ID 0X692b, send this msg return invalid command.
431 if (res == 0 && hwmgr->thermal_controller.advanceFanControlParameters.ucMinimumPWMLimit != 0)
432 res = (0 == smum_send_msg_to_smc_with_parameter(hwmgr->smumgr, PPSMC_MSG_SetFanMinPwm, \
433 hwmgr->thermal_controller.advanceFanControlParameters.ucMinimumPWMLimit) ? 0 : -1);
435 if (res == 0 && hwmgr->thermal_controller.advanceFanControlParameters.ulMinFanSCLKAcousticLimit != 0)
436 res = (0 == smum_send_msg_to_smc_with_parameter(hwmgr->smumgr, PPSMC_MSG_SetFanSclkTarget, \
437 hwmgr->thermal_controller.advanceFanControlParameters.ulMinFanSCLKAcousticLimit) ? 0 : -1);
440 phm_cap_unset(hwmgr->platform_descriptor.platformCaps, PHM_PlatformCaps_MicrocodeFanControl);
446 * Start the fan control on the SMC.
447 * @param hwmgr the address of the powerplay hardware manager.
448 * @param pInput the pointer to input data
449 * @param pOutput the pointer to output data
450 * @param pStorage the pointer to temporary storage
451 * @param Result the last failure code
452 * @return result from set temperature range routine
454 int tf_tonga_thermal_start_smc_fan_control(struct pp_hwmgr
*hwmgr
, void *input
, void *output
, void *storage
, int result
)
456 /* If the fantable setup has failed we could have disabled PHM_PlatformCaps_MicrocodeFanControl even after this function was included in the table.
457 * Make sure that we still think controlling the fan is OK.
459 if (phm_cap_enabled(hwmgr
->platform_descriptor
.platformCaps
, PHM_PlatformCaps_MicrocodeFanControl
)) {
460 tonga_fan_ctrl_start_smc_fan_control(hwmgr
);
461 tonga_fan_ctrl_set_static_mode(hwmgr
, FDO_PWM_MODE_STATIC
);
468 * Set temperature range for high and low alerts
469 * @param hwmgr the address of the powerplay hardware manager.
470 * @param pInput the pointer to input data
471 * @param pOutput the pointer to output data
472 * @param pStorage the pointer to temporary storage
473 * @param Result the last failure code
474 * @return result from set temperature range routine
476 int tf_tonga_thermal_set_temperature_range(struct pp_hwmgr
*hwmgr
, void *input
, void *output
, void *storage
, int result
)
478 struct PP_TemperatureRange
*range
= (struct PP_TemperatureRange
*)input
;
483 return tonga_thermal_set_temperature_range(hwmgr
, range
->min
, range
->max
);
487 * Programs one-time setting registers
488 * @param hwmgr the address of the powerplay hardware manager.
489 * @param pInput the pointer to input data
490 * @param pOutput the pointer to output data
491 * @param pStorage the pointer to temporary storage
492 * @param Result the last failure code
493 * @return result from initialize thermal controller routine
495 int tf_tonga_thermal_initialize(struct pp_hwmgr
*hwmgr
, void *input
, void *output
, void *storage
, int result
)
497 return tonga_thermal_initialize(hwmgr
);
501 * Enable high and low alerts
502 * @param hwmgr the address of the powerplay hardware manager.
503 * @param pInput the pointer to input data
504 * @param pOutput the pointer to output data
505 * @param pStorage the pointer to temporary storage
506 * @param Result the last failure code
507 * @return result from enable alert routine
509 int tf_tonga_thermal_enable_alert(struct pp_hwmgr
*hwmgr
, void *input
, void *output
, void *storage
, int result
)
511 return tonga_thermal_enable_alert(hwmgr
);
515 * Disable high and low alerts
516 * @param hwmgr the address of the powerplay hardware manager.
517 * @param pInput the pointer to input data
518 * @param pOutput the pointer to output data
519 * @param pStorage the pointer to temporary storage
520 * @param Result the last failure code
521 * @return result from disable alert routine
523 static int tf_tonga_thermal_disable_alert(struct pp_hwmgr
*hwmgr
, void *input
, void *output
, void *storage
, int result
)
525 return tonga_thermal_disable_alert(hwmgr
);
528 static struct phm_master_table_item tonga_thermal_start_thermal_controller_master_list
[] = {
529 { NULL
, tf_tonga_thermal_initialize
},
530 { NULL
, tf_tonga_thermal_set_temperature_range
},
531 { NULL
, tf_tonga_thermal_enable_alert
},
532 /* We should restrict performance levels to low before we halt the SMC.
533 * On the other hand we are still in boot state when we do this so it would be pointless.
534 * If this assumption changes we have to revisit this table.
536 { NULL
, tf_tonga_thermal_setup_fan_table
},
537 { NULL
, tf_tonga_thermal_start_smc_fan_control
},
541 static struct phm_master_table_header tonga_thermal_start_thermal_controller_master
= {
543 PHM_MasterTableFlag_None
,
544 tonga_thermal_start_thermal_controller_master_list
547 static struct phm_master_table_item tonga_thermal_set_temperature_range_master_list
[] = {
548 { NULL
, tf_tonga_thermal_disable_alert
},
549 { NULL
, tf_tonga_thermal_set_temperature_range
},
550 { NULL
, tf_tonga_thermal_enable_alert
},
554 struct phm_master_table_header tonga_thermal_set_temperature_range_master
= {
556 PHM_MasterTableFlag_None
,
557 tonga_thermal_set_temperature_range_master_list
560 int tonga_thermal_ctrl_uninitialize_thermal_controller(struct pp_hwmgr
*hwmgr
)
562 if (!hwmgr
->thermal_controller
.fanInfo
.bNoFan
)
563 tonga_fan_ctrl_set_default_mode(hwmgr
);
568 * Initializes the thermal controller related functions in the Hardware Manager structure.
569 * @param hwmgr The address of the hardware manager.
570 * @exception Any error code from the low-level communication.
572 int pp_tonga_thermal_initialize(struct pp_hwmgr
*hwmgr
)
576 result
= phm_construct_table(hwmgr
, &tonga_thermal_set_temperature_range_master
, &(hwmgr
->set_temperature_range
));
579 result
= phm_construct_table(hwmgr
,
580 &tonga_thermal_start_thermal_controller_master
,
581 &(hwmgr
->start_thermal_controller
));
583 phm_destroy_table(hwmgr
, &(hwmgr
->set_temperature_range
));
587 hwmgr
->fan_ctrl_is_in_default_mode
= true;