Commit 3ac4ffdd authored by Likun Gao's avatar Likun Gao Committed by Alex Deucher

drm/amd/powerplay: add fan input interface for hwmon

Add fan1_input and fan1_target interface to get fan speed info for hwmon.
Signed-off-by: default avatarLikun Gao <Likun.Gao@amd.com>
Reviewed-by: default avatarKevin Wang <kevin1.wang@amd.com>
Reviewed-by: default avatarHuang Rui <ray.huang@amd.com>
Reviewed-by: default avatarAlex Deucher <alexander.deucher@amd.com>
Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
parent 637c1c66
...@@ -1503,7 +1503,11 @@ static ssize_t amdgpu_hwmon_get_fan1_input(struct device *dev, ...@@ -1503,7 +1503,11 @@ static ssize_t amdgpu_hwmon_get_fan1_input(struct device *dev,
(adev->ddev->switch_power_state != DRM_SWITCH_POWER_ON)) (adev->ddev->switch_power_state != DRM_SWITCH_POWER_ON))
return -EINVAL; return -EINVAL;
if (adev->powerplay.pp_funcs->get_fan_speed_rpm) { if (is_support_sw_smu(adev)) {
err = smu_get_current_rpm(&adev->smu, &speed);
if (err)
return err;
} else if (adev->powerplay.pp_funcs->get_fan_speed_rpm) {
err = amdgpu_dpm_get_fan_speed_rpm(adev, &speed); err = amdgpu_dpm_get_fan_speed_rpm(adev, &speed);
if (err) if (err)
return err; return err;
...@@ -1559,7 +1563,11 @@ static ssize_t amdgpu_hwmon_get_fan1_target(struct device *dev, ...@@ -1559,7 +1563,11 @@ static ssize_t amdgpu_hwmon_get_fan1_target(struct device *dev,
(adev->ddev->switch_power_state != DRM_SWITCH_POWER_ON)) (adev->ddev->switch_power_state != DRM_SWITCH_POWER_ON))
return -EINVAL; return -EINVAL;
if (adev->powerplay.pp_funcs->get_fan_speed_rpm) { if (is_support_sw_smu(adev)) {
err = smu_get_current_rpm(&adev->smu, &rpm);
if (err)
return err;
} else if (adev->powerplay.pp_funcs->get_fan_speed_rpm) {
err = amdgpu_dpm_get_fan_speed_rpm(adev, &rpm); err = amdgpu_dpm_get_fan_speed_rpm(adev, &rpm);
if (err) if (err)
return err; return err;
......
...@@ -530,6 +530,7 @@ struct smu_funcs ...@@ -530,6 +530,7 @@ struct smu_funcs
int (*dpm_set_vce_enable)(struct smu_context *smu, bool enable); int (*dpm_set_vce_enable)(struct smu_context *smu, bool enable);
uint32_t (*get_sclk)(struct smu_context *smu, bool low); uint32_t (*get_sclk)(struct smu_context *smu, bool low);
uint32_t (*get_mclk)(struct smu_context *smu, bool low); uint32_t (*get_mclk)(struct smu_context *smu, bool low);
int (*get_current_rpm)(struct smu_context *smu, uint32_t *speed);
}; };
#define smu_init_microcode(smu) \ #define smu_init_microcode(smu) \
...@@ -580,6 +581,8 @@ struct smu_funcs ...@@ -580,6 +581,8 @@ struct smu_funcs
((smu)->funcs->set_od8_default_settings ? (smu)->funcs->set_od8_default_settings((smu)) : 0) ((smu)->funcs->set_od8_default_settings ? (smu)->funcs->set_od8_default_settings((smu)) : 0)
#define smu_update_od8_settings(smu, index, value) \ #define smu_update_od8_settings(smu, index, value) \
((smu)->funcs->update_od8_settings ? (smu)->funcs->update_od8_settings((smu), (index), (value)) : 0) ((smu)->funcs->update_od8_settings ? (smu)->funcs->update_od8_settings((smu), (index), (value)) : 0)
#define smu_get_current_rpm(smu, speed) \
((smu)->funcs->get_current_rpm ? (smu)->funcs->get_current_rpm((smu), (speed)) : 0)
#define smu_send_smc_msg(smu, msg) \ #define smu_send_smc_msg(smu, msg) \
((smu)->funcs->send_smc_msg? (smu)->funcs->send_smc_msg((smu), (msg)) : 0) ((smu)->funcs->send_smc_msg? (smu)->funcs->send_smc_msg((smu), (msg)) : 0)
#define smu_send_smc_msg_with_param(smu, msg, param) \ #define smu_send_smc_msg_with_param(smu, msg, param) \
......
...@@ -1712,6 +1712,23 @@ static int smu_v11_0_dpm_set_vce_enable(struct smu_context *smu, bool enable) ...@@ -1712,6 +1712,23 @@ static int smu_v11_0_dpm_set_vce_enable(struct smu_context *smu, bool enable)
return smu_feature_set_enabled(smu, FEATURE_DPM_UVD_BIT, enable); return smu_feature_set_enabled(smu, FEATURE_DPM_UVD_BIT, enable);
} }
static int smu_v11_0_get_current_rpm(struct smu_context *smu,
uint32_t *current_rpm)
{
int ret;
ret = smu_send_smc_msg(smu, SMU_MSG_GetCurrentRpm);
if (ret) {
pr_err("Attempt to get current RPM from SMC Failed!\n");
return ret;
}
smu_read_smc_arg(smu, current_rpm);
return 0;
}
static const struct smu_funcs smu_v11_0_funcs = { static const struct smu_funcs smu_v11_0_funcs = {
.init_microcode = smu_v11_0_init_microcode, .init_microcode = smu_v11_0_init_microcode,
.load_microcode = smu_v11_0_load_microcode, .load_microcode = smu_v11_0_load_microcode,
...@@ -1761,7 +1778,7 @@ static const struct smu_funcs smu_v11_0_funcs = { ...@@ -1761,7 +1778,7 @@ static const struct smu_funcs smu_v11_0_funcs = {
.update_od8_settings = smu_v11_0_update_od8_settings, .update_od8_settings = smu_v11_0_update_od8_settings,
.dpm_set_uvd_enable = smu_v11_0_dpm_set_uvd_enable, .dpm_set_uvd_enable = smu_v11_0_dpm_set_uvd_enable,
.dpm_set_vce_enable = smu_v11_0_dpm_set_vce_enable, .dpm_set_vce_enable = smu_v11_0_dpm_set_vce_enable,
.get_current_rpm = smu_v11_0_get_current_rpm,
}; };
void smu_v11_0_set_smu_funcs(struct smu_context *smu) void smu_v11_0_set_smu_funcs(struct smu_context *smu)
......
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