/* * Copyright 2018 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. *
*/
staticint vega20_get_current_rpm(struct pp_hwmgr *hwmgr, uint32_t *current_rpm)
{ int ret = 0;
PP_ASSERT_WITH_CODE((ret = smum_send_msg_to_smc(hwmgr,
PPSMC_MSG_GetCurrentRpm,
current_rpm)) == 0, "Attempt to get current RPM from SMC Failed!", return ret);
/** * vega20_thermal_get_temperature - Reads the remote temperature from the SIslands thermal controller. * * @hwmgr: The address of the hardware manager.
*/ int vega20_thermal_get_temperature(struct pp_hwmgr *hwmgr)
{ struct amdgpu_device *adev = hwmgr->adev; int temp = 0;
/** * vega20_thermal_set_temperature_range - Set the requested temperature range for high and low alert signals * * @hwmgr: The address of the hardware manager. * @range: Temperature range to be programmed for high and low alert signals * Exception: PP_Result_BadInput if the input data is not valid.
*/ staticint vega20_thermal_set_temperature_range(struct pp_hwmgr *hwmgr, struct PP_TemperatureRange *range)
{ struct phm_ppt_v3_information *pptable_information =
(struct phm_ppt_v3_information *)hwmgr->pptable; struct amdgpu_device *adev = hwmgr->adev; int low = VEGA20_THERMAL_MINIMUM_ALERT_TEMP; int high = VEGA20_THERMAL_MAXIMUM_ALERT_TEMP;
uint32_t val;
/* compare them in unit celsius degree */ if (low < range->min / PP_TEMPERATURE_UNITS_PER_CENTIGRADES)
low = range->min / PP_TEMPERATURE_UNITS_PER_CENTIGRADES; if (high > pptable_information->us_software_shutdown_temp)
high = pptable_information->us_software_shutdown_temp;
if (low > high) return -EINVAL;
val = RREG32_SOC15(THM, 0, mmTHM_THERMAL_INT_CTRL);
val = CGS_REG_SET_FIELD(val, THM_THERMAL_INT_CTRL, MAX_IH_CREDIT, 5);
val = CGS_REG_SET_FIELD(val, THM_THERMAL_INT_CTRL, THERM_IH_HW_ENA, 1);
val = CGS_REG_SET_FIELD(val, THM_THERMAL_INT_CTRL, DIG_THERM_INTH, high);
val = CGS_REG_SET_FIELD(val, THM_THERMAL_INT_CTRL, DIG_THERM_INTL, low);
val &= ~THM_THERMAL_INT_CTRL__THERM_TRIGGER_MASK_MASK;
val &= ~THM_THERMAL_INT_CTRL__THERM_INTH_MASK_MASK;
val &= ~THM_THERMAL_INT_CTRL__THERM_INTL_MASK_MASK;
/** * vega20_thermal_enable_alert - Enable thermal alerts on the RV770 thermal controller. * * @hwmgr: The address of the hardware manager.
*/ staticint vega20_thermal_enable_alert(struct pp_hwmgr *hwmgr)
{ struct amdgpu_device *adev = hwmgr->adev;
uint32_t val = 0;
val |= (1 << THM_THERMAL_INT_ENA__THERM_INTH_CLR__SHIFT);
val |= (1 << THM_THERMAL_INT_ENA__THERM_INTL_CLR__SHIFT);
val |= (1 << THM_THERMAL_INT_ENA__THERM_TRIGGER_CLR__SHIFT);
WREG32_SOC15(THM, 0, mmTHM_THERMAL_INT_ENA, val);
return 0;
}
/** * vega20_thermal_disable_alert - Disable thermal alerts on the RV770 thermal controller. * @hwmgr: The address of the hardware manager.
*/ int vega20_thermal_disable_alert(struct pp_hwmgr *hwmgr)
{ struct amdgpu_device *adev = hwmgr->adev;
WREG32_SOC15(THM, 0, mmTHM_THERMAL_INT_ENA, 0);
return 0;
}
/** * vega20_thermal_stop_thermal_controller - Uninitialize the thermal controller. * Currently just disables alerts. * @hwmgr: The address of the hardware manager.
*/ int vega20_thermal_stop_thermal_controller(struct pp_hwmgr *hwmgr)
{ int result = vega20_thermal_disable_alert(hwmgr);
return result;
}
/** * vega20_thermal_setup_fan_table - Set up the fan table to control the fan using the SMC. * @hwmgr: the address of the powerplay hardware manager.
*/ staticint vega20_thermal_setup_fan_table(struct pp_hwmgr *hwmgr)
{ int ret; struct vega20_hwmgr *data = (struct vega20_hwmgr *)(hwmgr->backend);
PPTable_t *table = &(data->smc_state_table.pp_table);
ret = smum_send_msg_to_smc_with_parameter(hwmgr,
PPSMC_MSG_SetFanTemperatureTarget,
(uint32_t)table->FanTargetTemperature,
NULL);
return ret;
}
int vega20_start_thermal_controller(struct pp_hwmgr *hwmgr, struct PP_TemperatureRange *range)
{ int ret = 0;
if (range == NULL) return -EINVAL;
ret = vega20_thermal_set_temperature_range(hwmgr, range); if (ret) return ret;
ret = vega20_thermal_enable_alert(hwmgr); if (ret) return ret;
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.