/* * Copyright 2016 Advanced Micro Devices, Inc. * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR * OTHER DEALINGS IN THE SOFTWARE. *
*/
/** * smu7_fan_ctrl_set_static_mode - Set Fan Speed Control to static mode, so that the user can decide what speed to use. * @hwmgr: the address of the powerplay hardware manager. * @mode: the fan control mode, 0 default, 1 by percent, 5, by RPM * Exception: Should always succeed.
*/ int smu7_fan_ctrl_set_static_mode(struct pp_hwmgr *hwmgr, uint32_t mode)
{ if (hwmgr->fan_ctrl_is_in_default_mode) {
hwmgr->fan_ctrl_default_mode =
PHM_READ_VFPF_INDIRECT_FIELD(hwmgr->device, CGS_IND_REG__SMC,
CG_FDO_CTRL2, FDO_PWM_MODE);
hwmgr->tmin =
PHM_READ_VFPF_INDIRECT_FIELD(hwmgr->device, CGS_IND_REG__SMC,
CG_FDO_CTRL2, TMIN);
hwmgr->fan_ctrl_is_in_default_mode = false;
}
/** * smu7_fan_ctrl_set_default_mode - Reset Fan Speed Control to default mode. * @hwmgr: the address of the powerplay hardware manager. * Exception: Should always succeed.
*/ int smu7_fan_ctrl_set_default_mode(struct pp_hwmgr *hwmgr)
{ if (!hwmgr->fan_ctrl_is_in_default_mode) {
PHM_WRITE_VFPF_INDIRECT_FIELD(hwmgr->device, CGS_IND_REG__SMC,
CG_FDO_CTRL2, FDO_PWM_MODE, hwmgr->fan_ctrl_default_mode);
PHM_WRITE_VFPF_INDIRECT_FIELD(hwmgr->device, CGS_IND_REG__SMC,
CG_FDO_CTRL2, TMIN, hwmgr->tmin);
hwmgr->fan_ctrl_is_in_default_mode = true;
}
return 0;
}
int smu7_fan_ctrl_start_smc_fan_control(struct pp_hwmgr *hwmgr)
{ int result;
if (PP_CAP(PHM_PlatformCaps_ODFuzzyFanControlSupport)) {
result = smum_send_msg_to_smc_with_parameter(hwmgr, PPSMC_StartFanControl,
FAN_CONTROL_FUZZY, NULL);
if (PP_CAP(PHM_PlatformCaps_FanSpeedInTableIsRPM))
hwmgr->hwmgr_func->set_max_fan_rpm_output(hwmgr,
hwmgr->thermal_controller.
advanceFanControlParameters.usMaxFanRPM); else
hwmgr->hwmgr_func->set_max_fan_pwm_output(hwmgr,
hwmgr->thermal_controller.
advanceFanControlParameters.usMaxFanPWM);
} else {
result = smum_send_msg_to_smc_with_parameter(hwmgr, PPSMC_StartFanControl,
FAN_CONTROL_TABLE, NULL);
}
if (!result && hwmgr->thermal_controller.
advanceFanControlParameters.ucTargetTemperature)
result = smum_send_msg_to_smc_with_parameter(hwmgr,
PPSMC_MSG_SetFanTemperatureTarget,
hwmgr->thermal_controller.
advanceFanControlParameters.ucTargetTemperature,
NULL);
/** * smu7_fan_ctrl_set_fan_speed_pwm - Set Fan Speed in PWM. * @hwmgr: the address of the powerplay hardware manager. * @speed: is the pwm value (0 - 255) to be set.
*/ int smu7_fan_ctrl_set_fan_speed_pwm(struct pp_hwmgr *hwmgr,
uint32_t speed)
{
uint32_t duty100;
uint32_t duty;
uint64_t tmp64;
if (hwmgr->thermal_controller.fanInfo.bNoFan) return 0;
speed = min_t(uint32_t, speed, 255);
if (PP_CAP(PHM_PlatformCaps_MicrocodeFanControl))
smu7_fan_ctrl_stop_smc_fan_control(hwmgr);
/** * smu7_fan_ctrl_reset_fan_speed_to_default - Reset Fan Speed to default. * @hwmgr: the address of the powerplay hardware manager. * Exception: Always succeeds.
*/ int smu7_fan_ctrl_reset_fan_speed_to_default(struct pp_hwmgr *hwmgr)
{ int result;
if (hwmgr->thermal_controller.fanInfo.bNoFan) return 0;
if (PP_CAP(PHM_PlatformCaps_MicrocodeFanControl)) {
result = smu7_fan_ctrl_set_static_mode(hwmgr, FDO_PWM_MODE_STATIC); if (!result)
result = smu7_fan_ctrl_start_smc_fan_control(hwmgr);
} else
result = smu7_fan_ctrl_set_default_mode(hwmgr);
return result;
}
/** * smu7_fan_ctrl_set_fan_speed_rpm - Set Fan Speed in RPM. * @hwmgr: the address of the powerplay hardware manager. * @speed: is the percentage value (min - max) to be set. * Exception: Fails is the speed not lie between min and max.
*/ int smu7_fan_ctrl_set_fan_speed_rpm(struct pp_hwmgr *hwmgr, uint32_t speed)
{
uint32_t tach_period;
uint32_t crystal_clock_freq;
/** * smu7_thermal_get_temperature - Reads the remote temperature from the SIslands thermal controller. * * @hwmgr: The address of the hardware manager.
*/ int smu7_thermal_get_temperature(struct pp_hwmgr *hwmgr)
{ int temp;
/* Bit 9 means the reading is lower than the lowest usable value. */ if (temp & 0x200)
temp = SMU7_THERMAL_MAXIMUM_TEMP_READING; else
temp = temp & 0x1ff;
temp *= PP_TEMPERATURE_UNITS_PER_CENTIGRADES;
return temp;
}
/** * smu7_thermal_set_temperature_range - Set the requested temperature range for high and low alert signals * * @hwmgr: The address of the hardware manager. * @low_temp: Temperature to be programmed for high alert signals * @high_temp: Temperature to be programmed for low alert signals * Exception: PP_Result_BadInput if the input data is not valid.
*/ staticint smu7_thermal_set_temperature_range(struct pp_hwmgr *hwmgr, int low_temp, int high_temp)
{ int low = SMU7_THERMAL_MINIMUM_ALERT_TEMP *
PP_TEMPERATURE_UNITS_PER_CENTIGRADES; int high = SMU7_THERMAL_MAXIMUM_ALERT_TEMP *
PP_TEMPERATURE_UNITS_PER_CENTIGRADES;
if (low < low_temp)
low = low_temp; if (high > high_temp)
high = high_temp;
/* send message to SMU to enable internal thermal interrupts */
smum_send_msg_to_smc(hwmgr, PPSMC_MSG_Thermal_Cntl_Enable, NULL);
}
/** * smu7_thermal_disable_alert - Disable thermal alerts on the RV770 thermal controller. * @hwmgr: The address of the hardware manager.
*/ int smu7_thermal_disable_alert(struct pp_hwmgr *hwmgr)
{
uint32_t alert;
/* send message to SMU to disable internal thermal interrupts */ return smum_send_msg_to_smc(hwmgr, PPSMC_MSG_Thermal_Cntl_Disable, NULL);
}
/** * smu7_thermal_stop_thermal_controller - Uninitialize the thermal controller. * Currently just disables alerts. * @hwmgr: The address of the hardware manager.
*/ int smu7_thermal_stop_thermal_controller(struct pp_hwmgr *hwmgr)
{ int result = smu7_thermal_disable_alert(hwmgr);
if (!hwmgr->thermal_controller.fanInfo.bNoFan)
smu7_fan_ctrl_set_default_mode(hwmgr);
return result;
}
/** * smu7_thermal_start_smc_fan_control - Start the fan control on the SMC. * @hwmgr: the address of the powerplay hardware manager. * Return: result from set temperature range routine
*/ staticint smu7_thermal_start_smc_fan_control(struct pp_hwmgr *hwmgr)
{ /* If the fantable setup has failed we could have disabled * PHM_PlatformCaps_MicrocodeFanControl even after * this function was included in the table. * Make sure that we still think controlling the fan is OK.
*/ if (PP_CAP(PHM_PlatformCaps_MicrocodeFanControl)) {
smu7_fan_ctrl_start_smc_fan_control(hwmgr);
smu7_fan_ctrl_set_static_mode(hwmgr, FDO_PWM_MODE_STATIC);
}
return 0;
}
int smu7_start_thermal_controller(struct pp_hwmgr *hwmgr, struct PP_TemperatureRange *range)
{ int ret = 0;
if (range == NULL) return -EINVAL;
smu7_thermal_initialize(hwmgr);
ret = smu7_thermal_set_temperature_range(hwmgr, range->min, range->max); if (ret) return -EINVAL;
smu7_thermal_enable_alert(hwmgr);
ret = smum_thermal_avfs_enable(hwmgr); if (ret) return -EINVAL;
/* We should restrict performance levels to low before we halt the SMC. * On the other hand we are still in boot state when we do this * so it would be pointless. * If this assumption changes we have to revisit this table.
*/
smum_thermal_setup_fan_table(hwmgr);
smu7_thermal_start_smc_fan_control(hwmgr); return 0;
}
int smu7_thermal_ctrl_uninitialize_thermal_controller(struct pp_hwmgr *hwmgr)
{ if (!hwmgr->thermal_controller.fanInfo.bNoFan)
smu7_fan_ctrl_set_default_mode(hwmgr); return 0;
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.