Commit 9a7fd013 authored by Alex Deucher's avatar Alex Deucher

drm/amdgpu/swsmu: add smu11 helper to get manual fan speed (v2)

Will be used to fetch the fan speeds when manual fan mode is
set.

v2: squash in a Coverity fix from Colin Ian King
Reviewed-by: default avatarEvan Quan <evan.quan@amd.com>
Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
parent 8d6e65ad
...@@ -203,6 +203,9 @@ smu_v11_0_set_fan_control_mode(struct smu_context *smu, ...@@ -203,6 +203,9 @@ smu_v11_0_set_fan_control_mode(struct smu_context *smu,
int smu_v11_0_set_fan_speed_rpm(struct smu_context *smu, int smu_v11_0_set_fan_speed_rpm(struct smu_context *smu,
uint32_t speed); uint32_t speed);
int smu_v11_0_get_fan_speed_rpm(struct smu_context *smu,
uint32_t *speed);
int smu_v11_0_set_xgmi_pstate(struct smu_context *smu, int smu_v11_0_set_xgmi_pstate(struct smu_context *smu,
uint32_t pstate); uint32_t pstate);
......
...@@ -1153,6 +1153,27 @@ int smu_v11_0_set_fan_speed_rpm(struct smu_context *smu, ...@@ -1153,6 +1153,27 @@ int smu_v11_0_set_fan_speed_rpm(struct smu_context *smu,
return ret; return ret;
} }
int smu_v11_0_get_fan_speed_rpm(struct smu_context *smu,
uint32_t *speed)
{
struct amdgpu_device *adev = smu->adev;
uint32_t tach_period, crystal_clock_freq;
uint64_t tmp64;
tach_period = REG_GET_FIELD(RREG32_SOC15(THM, 0, mmCG_TACH_CTRL),
CG_TACH_CTRL, TARGET_PERIOD);
if (!tach_period)
return -EINVAL;
crystal_clock_freq = amdgpu_asic_get_xclk(adev);
tmp64 = (uint64_t)crystal_clock_freq * 60 * 10000;
do_div(tmp64, (tach_period * 8));
*speed = (uint32_t)tmp64;
return 0;
}
int smu_v11_0_set_xgmi_pstate(struct smu_context *smu, int smu_v11_0_set_xgmi_pstate(struct smu_context *smu,
uint32_t pstate) uint32_t pstate)
{ {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment