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 "fiji_thermal.h"
25 #include "fiji_hwmgr.h"
26 #include "fiji_smumgr.h"
27 #include "fiji_ppsmc.h"
28 #include "smu/smu_7_1_3_d.h"
29 #include "smu/smu_7_1_3_sh_mask.h"
31 int fiji_fan_ctrl_get_fan_speed_info(struct pp_hwmgr *hwmgr,
32 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 fiji_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 fiji_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 fiji_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 fiji_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 fiji_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 fiji_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 fiji_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 fiji_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 * 100;
225 do_div(tmp64, 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 fiji_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 fiji_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 = fiji_fan_ctrl_set_static_mode(hwmgr, FDO_PWM_MODE_STATIC);
250 result = fiji_fan_ctrl_start_smc_fan_control(hwmgr);
252 result = fiji_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 fiji_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 crystal_clock_freq = tonga_get_xclk(hwmgr);
277 tach_period = 60 * crystal_clock_freq * 10000 / (8 * speed);
279 PHM_WRITE_VFPF_INDIRECT_FIELD(hwmgr->device, CGS_IND_REG__SMC,
280 CG_TACH_STATUS, TACH_PERIOD, tach_period);
282 return fiji_fan_ctrl_set_static_mode(hwmgr, FDO_PWM_MODE_STATIC);
286 * Reads the remote temperature from the SIslands thermal controller.
288 * @param hwmgr The address of the hardware manager.
290 int fiji_thermal_get_temperature(struct pp_hwmgr *hwmgr)
294 temp = PHM_READ_VFPF_INDIRECT_FIELD(hwmgr->device, CGS_IND_REG__SMC,
295 CG_MULT_THERMAL_STATUS, CTF_TEMP);
297 /* Bit 9 means the reading is lower than the lowest usable value. */
299 temp = FIJI_THERMAL_MAXIMUM_TEMP_READING;
303 temp *= PP_TEMPERATURE_UNITS_PER_CENTIGRADES;
309 * Set the requested temperature range for high and low alert signals
311 * @param hwmgr The address of the hardware manager.
312 * @param range Temperature range to be programmed for high and low alert signals
313 * @exception PP_Result_BadInput if the input data is not valid.
315 static int fiji_thermal_set_temperature_range(struct pp_hwmgr *hwmgr,
316 uint32_t low_temp, uint32_t high_temp)
318 uint32_t low = FIJI_THERMAL_MINIMUM_ALERT_TEMP *
319 PP_TEMPERATURE_UNITS_PER_CENTIGRADES;
320 uint32_t high = FIJI_THERMAL_MAXIMUM_ALERT_TEMP *
321 PP_TEMPERATURE_UNITS_PER_CENTIGRADES;
325 if (high > high_temp)
331 PHM_WRITE_VFPF_INDIRECT_FIELD(hwmgr->device, CGS_IND_REG__SMC,
332 CG_THERMAL_INT, DIG_THERM_INTH,
333 (high / PP_TEMPERATURE_UNITS_PER_CENTIGRADES));
334 PHM_WRITE_VFPF_INDIRECT_FIELD(hwmgr->device, CGS_IND_REG__SMC,
335 CG_THERMAL_INT, DIG_THERM_INTL,
336 (low / PP_TEMPERATURE_UNITS_PER_CENTIGRADES));
337 PHM_WRITE_VFPF_INDIRECT_FIELD(hwmgr->device, CGS_IND_REG__SMC,
338 CG_THERMAL_CTRL, DIG_THERM_DPM,
339 (high / PP_TEMPERATURE_UNITS_PER_CENTIGRADES));
345 * Programs thermal controller one-time setting registers
347 * @param hwmgr The address of the hardware manager.
349 static int fiji_thermal_initialize(struct pp_hwmgr *hwmgr)
351 if (hwmgr->thermal_controller.fanInfo.ucTachometerPulsesPerRevolution)
352 PHM_WRITE_VFPF_INDIRECT_FIELD(hwmgr->device, CGS_IND_REG__SMC,
353 CG_TACH_CTRL, EDGE_PER_REV,
354 hwmgr->thermal_controller.fanInfo.
355 ucTachometerPulsesPerRevolution - 1);
357 PHM_WRITE_VFPF_INDIRECT_FIELD(hwmgr->device, CGS_IND_REG__SMC,
358 CG_FDO_CTRL2, TACH_PWM_RESP_RATE, 0x28);
364 * Enable thermal alerts on the RV770 thermal controller.
366 * @param hwmgr The address of the hardware manager.
368 static int fiji_thermal_enable_alert(struct pp_hwmgr *hwmgr)
372 alert = PHM_READ_VFPF_INDIRECT_FIELD(hwmgr->device, CGS_IND_REG__SMC,
373 CG_THERMAL_INT, THERM_INT_MASK);
374 alert &= ~(FIJI_THERMAL_HIGH_ALERT_MASK | FIJI_THERMAL_LOW_ALERT_MASK);
375 PHM_WRITE_VFPF_INDIRECT_FIELD(hwmgr->device, CGS_IND_REG__SMC,
376 CG_THERMAL_INT, THERM_INT_MASK, alert);
378 /* send message to SMU to enable internal thermal interrupts */
379 return smum_send_msg_to_smc(hwmgr->smumgr, PPSMC_MSG_Thermal_Cntl_Enable);
383 * Disable thermal alerts on the RV770 thermal controller.
384 * @param hwmgr The address of the hardware manager.
386 static int fiji_thermal_disable_alert(struct pp_hwmgr *hwmgr)
390 alert = PHM_READ_VFPF_INDIRECT_FIELD(hwmgr->device, CGS_IND_REG__SMC,
391 CG_THERMAL_INT, THERM_INT_MASK);
392 alert |= (FIJI_THERMAL_HIGH_ALERT_MASK | FIJI_THERMAL_LOW_ALERT_MASK);
393 PHM_WRITE_VFPF_INDIRECT_FIELD(hwmgr->device, CGS_IND_REG__SMC,
394 CG_THERMAL_INT, THERM_INT_MASK, alert);
396 /* send message to SMU to disable internal thermal interrupts */
397 return smum_send_msg_to_smc(hwmgr->smumgr, PPSMC_MSG_Thermal_Cntl_Disable);
401 * Uninitialize the thermal controller.
402 * Currently just disables alerts.
403 * @param hwmgr The address of the hardware manager.
405 int fiji_thermal_stop_thermal_controller(struct pp_hwmgr *hwmgr)
407 int result = fiji_thermal_disable_alert(hwmgr);
409 if (hwmgr->thermal_controller.fanInfo.bNoFan)
410 fiji_fan_ctrl_set_default_mode(hwmgr);
416 * Set up the fan table to control the fan using the SMC.
417 * @param hwmgr the address of the powerplay hardware manager.
418 * @param pInput the pointer to input data
419 * @param pOutput the pointer to output data
420 * @param pStorage the pointer to temporary storage
421 * @param Result the last failure code
422 * @return result from set temperature range routine
424 int tf_fiji_thermal_setup_fan_table(struct pp_hwmgr *hwmgr,
425 void *input, void *output, void *storage, int result)
427 struct fiji_hwmgr *data = (struct fiji_hwmgr *)(hwmgr->backend);
428 SMU73_Discrete_FanTable fan_table = { FDO_MODE_HARDWARE };
430 uint32_t t_diff1, t_diff2, pwm_diff1, pwm_diff2;
431 uint16_t fdo_min, slope1, slope2;
432 uint32_t reference_clock;
436 if (data->fan_table_start == 0) {
437 phm_cap_unset(hwmgr->platform_descriptor.platformCaps,
438 PHM_PlatformCaps_MicrocodeFanControl);
442 duty100 = PHM_READ_VFPF_INDIRECT_FIELD(hwmgr->device, CGS_IND_REG__SMC,
443 CG_FDO_CTRL1, FMAX_DUTY100);
446 phm_cap_unset(hwmgr->platform_descriptor.platformCaps,
447 PHM_PlatformCaps_MicrocodeFanControl);
451 tmp64 = hwmgr->thermal_controller.advanceFanControlParameters.
453 do_div(tmp64, 10000);
454 fdo_min = (uint16_t)tmp64;
456 t_diff1 = hwmgr->thermal_controller.advanceFanControlParameters.usTMed -
457 hwmgr->thermal_controller.advanceFanControlParameters.usTMin;
458 t_diff2 = hwmgr->thermal_controller.advanceFanControlParameters.usTHigh -
459 hwmgr->thermal_controller.advanceFanControlParameters.usTMed;
461 pwm_diff1 = hwmgr->thermal_controller.advanceFanControlParameters.usPWMMed -
462 hwmgr->thermal_controller.advanceFanControlParameters.usPWMMin;
463 pwm_diff2 = hwmgr->thermal_controller.advanceFanControlParameters.usPWMHigh -
464 hwmgr->thermal_controller.advanceFanControlParameters.usPWMMed;
466 slope1 = (uint16_t)((50 + ((16 * duty100 * pwm_diff1) / t_diff1)) / 100);
467 slope2 = (uint16_t)((50 + ((16 * duty100 * pwm_diff2) / t_diff2)) / 100);
469 fan_table.TempMin = cpu_to_be16((50 + hwmgr->
470 thermal_controller.advanceFanControlParameters.usTMin) / 100);
471 fan_table.TempMed = cpu_to_be16((50 + hwmgr->
472 thermal_controller.advanceFanControlParameters.usTMed) / 100);
473 fan_table.TempMax = cpu_to_be16((50 + hwmgr->
474 thermal_controller.advanceFanControlParameters.usTMax) / 100);
476 fan_table.Slope1 = cpu_to_be16(slope1);
477 fan_table.Slope2 = cpu_to_be16(slope2);
479 fan_table.FdoMin = cpu_to_be16(fdo_min);
481 fan_table.HystDown = cpu_to_be16(hwmgr->
482 thermal_controller.advanceFanControlParameters.ucTHyst);
484 fan_table.HystUp = cpu_to_be16(1);
486 fan_table.HystSlope = cpu_to_be16(1);
488 fan_table.TempRespLim = cpu_to_be16(5);
490 reference_clock = tonga_get_xclk(hwmgr);
492 fan_table.RefreshPeriod = cpu_to_be32((hwmgr->
493 thermal_controller.advanceFanControlParameters.ulCycleDelay *
494 reference_clock) / 1600);
496 fan_table.FdoMax = cpu_to_be16((uint16_t)duty100);
498 fan_table.TempSrc = (uint8_t)PHM_READ_VFPF_INDIRECT_FIELD(
499 hwmgr->device, CGS_IND_REG__SMC,
500 CG_MULT_THERMAL_CTRL, TEMP_SEL);
502 res = fiji_copy_bytes_to_smc(hwmgr->smumgr, data->fan_table_start,
503 (uint8_t *)&fan_table, (uint32_t)sizeof(fan_table),
506 if (!res && hwmgr->thermal_controller.
507 advanceFanControlParameters.ucMinimumPWMLimit)
508 res = smum_send_msg_to_smc_with_parameter(hwmgr->smumgr,
509 PPSMC_MSG_SetFanMinPwm,
510 hwmgr->thermal_controller.
511 advanceFanControlParameters.ucMinimumPWMLimit);
513 if (!res && hwmgr->thermal_controller.
514 advanceFanControlParameters.ulMinFanSCLKAcousticLimit)
515 res = smum_send_msg_to_smc_with_parameter(hwmgr->smumgr,
516 PPSMC_MSG_SetFanSclkTarget,
517 hwmgr->thermal_controller.
518 advanceFanControlParameters.ulMinFanSCLKAcousticLimit);
521 phm_cap_unset(hwmgr->platform_descriptor.platformCaps,
522 PHM_PlatformCaps_MicrocodeFanControl);
528 * Start the fan control on the SMC.
529 * @param hwmgr the address of the powerplay hardware manager.
530 * @param pInput the pointer to input data
531 * @param pOutput the pointer to output data
532 * @param pStorage the pointer to temporary storage
533 * @param Result the last failure code
534 * @return result from set temperature range routine
536 int tf_fiji_thermal_start_smc_fan_control(struct pp_hwmgr *hwmgr,
537 void *input, void *output, void *storage, int result)
539 /* If the fantable setup has failed we could have disabled
540 * PHM_PlatformCaps_MicrocodeFanControl even after
541 * this function was included in the table.
542 * Make sure that we still think controlling the fan is OK.
544 if (phm_cap_enabled(hwmgr->platform_descriptor.platformCaps,
545 PHM_PlatformCaps_MicrocodeFanControl)) {
546 fiji_fan_ctrl_start_smc_fan_control(hwmgr);
547 fiji_fan_ctrl_set_static_mode(hwmgr, FDO_PWM_MODE_STATIC);
554 * Set temperature range for high and low alerts
555 * @param hwmgr the address of the powerplay hardware manager.
556 * @param pInput the pointer to input data
557 * @param pOutput the pointer to output data
558 * @param pStorage the pointer to temporary storage
559 * @param Result the last failure code
560 * @return result from set temperature range routine
562 int tf_fiji_thermal_set_temperature_range(struct pp_hwmgr *hwmgr,
563 void *input, void *output, void *storage, int result)
565 struct PP_TemperatureRange *range = (struct PP_TemperatureRange *)input;
570 return fiji_thermal_set_temperature_range(hwmgr, range->min, range->max);
574 * Programs one-time setting registers
575 * @param hwmgr the address of the powerplay hardware manager.
576 * @param pInput the pointer to input data
577 * @param pOutput the pointer to output data
578 * @param pStorage the pointer to temporary storage
579 * @param Result the last failure code
580 * @return result from initialize thermal controller routine
582 int tf_fiji_thermal_initialize(struct pp_hwmgr *hwmgr,
583 void *input, void *output, void *storage, int result)
585 return fiji_thermal_initialize(hwmgr);
589 * Enable high and low alerts
590 * @param hwmgr the address of the powerplay hardware manager.
591 * @param pInput the pointer to input data
592 * @param pOutput the pointer to output data
593 * @param pStorage the pointer to temporary storage
594 * @param Result the last failure code
595 * @return result from enable alert routine
597 int tf_fiji_thermal_enable_alert(struct pp_hwmgr *hwmgr,
598 void *input, void *output, void *storage, int result)
600 return fiji_thermal_enable_alert(hwmgr);
604 * Disable high and low alerts
605 * @param hwmgr the address of the powerplay hardware manager.
606 * @param pInput the pointer to input data
607 * @param pOutput the pointer to output data
608 * @param pStorage the pointer to temporary storage
609 * @param Result the last failure code
610 * @return result from disable alert routine
612 static int tf_fiji_thermal_disable_alert(struct pp_hwmgr *hwmgr,
613 void *input, void *output, void *storage, int result)
615 return fiji_thermal_disable_alert(hwmgr);
618 static struct phm_master_table_item
619 fiji_thermal_start_thermal_controller_master_list[] = {
620 {NULL, tf_fiji_thermal_initialize},
621 {NULL, tf_fiji_thermal_set_temperature_range},
622 {NULL, tf_fiji_thermal_enable_alert},
623 /* We should restrict performance levels to low before we halt the SMC.
624 * On the other hand we are still in boot state when we do this
625 * so it would be pointless.
626 * If this assumption changes we have to revisit this table.
628 {NULL, tf_fiji_thermal_setup_fan_table},
629 {NULL, tf_fiji_thermal_start_smc_fan_control},
633 static struct phm_master_table_header
634 fiji_thermal_start_thermal_controller_master = {
636 PHM_MasterTableFlag_None,
637 fiji_thermal_start_thermal_controller_master_list
640 static struct phm_master_table_item
641 fiji_thermal_set_temperature_range_master_list[] = {
642 {NULL, tf_fiji_thermal_disable_alert},
643 {NULL, tf_fiji_thermal_set_temperature_range},
644 {NULL, tf_fiji_thermal_enable_alert},
648 struct phm_master_table_header
649 fiji_thermal_set_temperature_range_master = {
651 PHM_MasterTableFlag_None,
652 fiji_thermal_set_temperature_range_master_list
655 int fiji_thermal_ctrl_uninitialize_thermal_controller(struct pp_hwmgr *hwmgr)
657 if (!hwmgr->thermal_controller.fanInfo.bNoFan)
658 fiji_fan_ctrl_set_default_mode(hwmgr);
663 * Initializes the thermal controller related functions in the Hardware Manager structure.
664 * @param hwmgr The address of the hardware manager.
665 * @exception Any error code from the low-level communication.
667 int pp_fiji_thermal_initialize(struct pp_hwmgr *hwmgr)
671 result = phm_construct_table(hwmgr,
672 &fiji_thermal_set_temperature_range_master,
673 &(hwmgr->set_temperature_range));
676 result = phm_construct_table(hwmgr,
677 &fiji_thermal_start_thermal_controller_master,
678 &(hwmgr->start_thermal_controller));
680 phm_destroy_table(hwmgr, &(hwmgr->set_temperature_range));
684 hwmgr->fan_ctrl_is_in_default_mode = true;