mirror of https://gitee.com/openkylin/linux.git
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: Likun Gao <Likun.Gao@amd.com> Reviewed-by: Kevin Wang <kevin1.wang@amd.com> Reviewed-by: Huang Rui <ray.huang@amd.com> Reviewed-by: Alex Deucher <alexander.deucher@amd.com> Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
This commit is contained in:
parent
637c1c6644
commit
3ac4ffdd13
|
@ -1503,7 +1503,11 @@ static ssize_t amdgpu_hwmon_get_fan1_input(struct device *dev,
|
|||
(adev->ddev->switch_power_state != DRM_SWITCH_POWER_ON))
|
||||
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);
|
||||
if (err)
|
||||
return err;
|
||||
|
@ -1559,7 +1563,11 @@ static ssize_t amdgpu_hwmon_get_fan1_target(struct device *dev,
|
|||
(adev->ddev->switch_power_state != DRM_SWITCH_POWER_ON))
|
||||
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);
|
||||
if (err)
|
||||
return err;
|
||||
|
|
|
@ -530,6 +530,7 @@ struct smu_funcs
|
|||
int (*dpm_set_vce_enable)(struct smu_context *smu, bool enable);
|
||||
uint32_t (*get_sclk)(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) \
|
||||
|
@ -580,6 +581,8 @@ struct smu_funcs
|
|||
((smu)->funcs->set_od8_default_settings ? (smu)->funcs->set_od8_default_settings((smu)) : 0)
|
||||
#define smu_update_od8_settings(smu, index, value) \
|
||||
((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) \
|
||||
((smu)->funcs->send_smc_msg? (smu)->funcs->send_smc_msg((smu), (msg)) : 0)
|
||||
#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)
|
|||
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 = {
|
||||
.init_microcode = smu_v11_0_init_microcode,
|
||||
.load_microcode = smu_v11_0_load_microcode,
|
||||
|
@ -1761,7 +1778,7 @@ static const struct smu_funcs smu_v11_0_funcs = {
|
|||
.update_od8_settings = smu_v11_0_update_od8_settings,
|
||||
.dpm_set_uvd_enable = smu_v11_0_dpm_set_uvd_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)
|
||||
|
|
Loading…
Reference in New Issue