Commit 9df5d008 authored by Evan Quan's avatar Evan Quan Committed by Alex Deucher
Browse files

drm/amd/pm: add fan minimum pwm OD setting support for SMU13



Add SMU13 fan minimum pwm OD setting support.

Signed-off-by: default avatarEvan Quan <evan.quan@amd.com>
Reviewed-by: default avatarAlex Deucher <alexander.deucher@amd.com>
Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
parent eedd5a34
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -88,6 +88,12 @@ fan_target_temperature
.. kernel-doc:: drivers/gpu/drm/amd/pm/amdgpu_pm.c
   :doc: fan_target_temperature

fan_minimum_pwm
---------------

.. kernel-doc:: drivers/gpu/drm/amd/pm/amdgpu_pm.c
   :doc: fan_minimum_pwm

GFXOFF
======

+2 −0
Original line number Diff line number Diff line
@@ -117,6 +117,7 @@ enum pp_clock_type {
	OD_ACOUSTIC_LIMIT,
	OD_ACOUSTIC_TARGET,
	OD_FAN_TARGET_TEMPERATURE,
	OD_FAN_MINIMUM_PWM,
};

enum amd_pp_sensors {
@@ -195,6 +196,7 @@ enum PP_OD_DPM_TABLE_COMMAND {
	PP_OD_EDIT_ACOUSTIC_LIMIT,
	PP_OD_EDIT_ACOUSTIC_TARGET,
	PP_OD_EDIT_FAN_TARGET_TEMPERATURE,
	PP_OD_EDIT_FAN_MINIMUM_PWM,
};

struct pp_states_info {
+64 −0
Original line number Diff line number Diff line
@@ -3745,6 +3745,62 @@ static umode_t fan_target_temperature_visible(struct amdgpu_device *adev)
	return umode;
}

/**
 * DOC: fan_minimum_pwm
 *
 * The amdgpu driver provides a sysfs API for checking and adjusting the
 * minimum fan speed in PWM.
 *
 * Reading back the file shows you the current setting and the permitted
 * ranges if changable.
 *
 * Writing an integer to the file, change the setting accordingly.
 *
 * When you have finished the editing, write "c" (commit) to the file to commit
 * your changes.
 *
 * This setting works under auto fan control mode only. It can co-exist with
 * other settings which can work also under auto mode. It adjusts the PMFW's
 * behavior about the minimum fan speed in PWM the fan should spin. Setting
 * via this interface will switch the fan control to auto mode implicitly.
 */
static ssize_t fan_minimum_pwm_show(struct kobject *kobj,
				    struct kobj_attribute *attr,
				    char *buf)
{
	struct od_kobj *container = container_of(kobj, struct od_kobj, kobj);
	struct amdgpu_device *adev = (struct amdgpu_device *)container->priv;

	return (ssize_t)amdgpu_retrieve_od_settings(adev, OD_FAN_MINIMUM_PWM, buf);
}

static ssize_t fan_minimum_pwm_store(struct kobject *kobj,
				     struct kobj_attribute *attr,
				     const char *buf,
				     size_t count)
{
	struct od_kobj *container = container_of(kobj, struct od_kobj, kobj);
	struct amdgpu_device *adev = (struct amdgpu_device *)container->priv;

	return (ssize_t)amdgpu_distribute_custom_od_settings(adev,
							     PP_OD_EDIT_FAN_MINIMUM_PWM,
							     buf,
							     count);
}

static umode_t fan_minimum_pwm_visible(struct amdgpu_device *adev)
{
	umode_t umode = 0000;

	if (adev->pm.od_feature_mask & OD_OPS_SUPPORT_FAN_MINIMUM_PWM_RETRIEVE)
		umode |= S_IRUSR | S_IRGRP | S_IROTH;

	if (adev->pm.od_feature_mask & OD_OPS_SUPPORT_FAN_MINIMUM_PWM_SET)
		umode |= S_IWUSR;

	return umode;
}

static struct od_feature_set amdgpu_od_set = {
	.containers = {
		[0] = {
@@ -3782,6 +3838,14 @@ static struct od_feature_set amdgpu_od_set = {
						.store = fan_target_temperature_store,
					},
				},
				[4] = {
					.name = "fan_minimum_pwm",
					.ops = {
						.is_visible = fan_minimum_pwm_visible,
						.show = fan_minimum_pwm_show,
						.store = fan_minimum_pwm_store,
					},
				},
			},
		},
	},
+2 −0
Original line number Diff line number Diff line
@@ -322,6 +322,8 @@ struct config_table_setting
#define OD_OPS_SUPPORT_ACOUSTIC_TARGET_THRESHOLD_SET		BIT(5)
#define OD_OPS_SUPPORT_FAN_TARGET_TEMPERATURE_RETRIEVE		BIT(6)
#define OD_OPS_SUPPORT_FAN_TARGET_TEMPERATURE_SET		BIT(7)
#define OD_OPS_SUPPORT_FAN_MINIMUM_PWM_RETRIEVE		BIT(8)
#define OD_OPS_SUPPORT_FAN_MINIMUM_PWM_SET		BIT(9)

struct amdgpu_pm {
	struct mutex		mutex;
+2 −0
Original line number Diff line number Diff line
@@ -2489,6 +2489,8 @@ static enum smu_clk_type smu_convert_to_smuclk(enum pp_clock_type type)
		clk_type = SMU_OD_ACOUSTIC_TARGET; break;
	case OD_FAN_TARGET_TEMPERATURE:
		clk_type = SMU_OD_FAN_TARGET_TEMPERATURE; break;
	case OD_FAN_MINIMUM_PWM:
		clk_type = SMU_OD_FAN_MINIMUM_PWM; break;
	default:
		clk_type = SMU_CLK_COUNT; break;
	}
Loading