[PATCH 1/3] drm/amd/pp: Add sysfs entry to get voltage control type

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Change-Id: Ie54af5a8056dba16aa9849190441377c5958b385
Signed-off-by: Rex Zhu <Rex.Zhu at amd.com>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c         | 27 ++++++++++++++++++++++++++
 drivers/gpu/drm/amd/include/kgd_pp_interface.h |  8 ++++++++
 2 files changed, 35 insertions(+)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c
index 01a996c..c2bf384 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c
@@ -247,6 +247,23 @@ static ssize_t amdgpu_get_pp_num_states(struct device *dev,
 	return buf_len;
 }
 
+static ssize_t amdgpu_get_voltage_control_type(struct device *dev,
+		struct device_attribute *attr,
+		char *buf)
+{
+	struct drm_device *ddev = dev_get_drvdata(dev);
+	struct amdgpu_device *adev = ddev->dev_private;
+	enum PP_VOLTAGE_CONTROL_TYPE data = PP_INVALID_VOLTAGE_TYPE;
+	int buf_len;
+
+	if (adev->powerplay.pp_funcs->get_pp_voltage_control_type)
+		adev->powerplay.pp_funcs->get_pp_voltage_control_type(adev, &data);
+
+	buf_len = snprintf(buf, PAGE_SIZE, "%d\n", data);
+
+	return buf_len;
+}
+
 static ssize_t amdgpu_get_pp_cur_state(struct device *dev,
 		struct device_attribute *attr,
 		char *buf)
@@ -772,6 +789,7 @@ static DEVICE_ATTR(pp_gfx_power_profile, S_IRUGO | S_IWUSR,
 static DEVICE_ATTR(pp_compute_power_profile, S_IRUGO | S_IWUSR,
 		amdgpu_get_pp_compute_power_profile,
 		amdgpu_set_pp_compute_power_profile);
+static DEVICE_ATTR(pp_get_voltage_control_type, S_IRUGO, amdgpu_get_voltage_control_type, NULL);
 
 static ssize_t amdgpu_hwmon_show_temp(struct device *dev,
 				      struct device_attribute *attr,
@@ -1404,6 +1422,13 @@ int amdgpu_pm_sysfs_init(struct amdgpu_device *adev)
 				"pp_compute_power_profile\n");
 		return ret;
 	}
+	ret = device_create_file(adev->dev,
+			&dev_attr_pp_get_voltage_control_type);
+	if (ret) {
+		DRM_ERROR("failed to create device file	"
+				"pp_get_voltage_control_type\n");
+		return ret;
+	}
 
 	ret = amdgpu_debugfs_pm_init(adev);
 	if (ret) {
@@ -1440,6 +1465,8 @@ void amdgpu_pm_sysfs_fini(struct amdgpu_device *adev)
 			&dev_attr_pp_gfx_power_profile);
 	device_remove_file(adev->dev,
 			&dev_attr_pp_compute_power_profile);
+	device_remove_file(adev->dev,
+			&dev_attr_pp_get_voltage_control_type);
 }
 
 void amdgpu_pm_compute_clocks(struct amdgpu_device *adev)
diff --git a/drivers/gpu/drm/amd/include/kgd_pp_interface.h b/drivers/gpu/drm/amd/include/kgd_pp_interface.h
index ed27626..251ccb4 100644
--- a/drivers/gpu/drm/amd/include/kgd_pp_interface.h
+++ b/drivers/gpu/drm/amd/include/kgd_pp_interface.h
@@ -197,6 +197,13 @@ struct pp_gpu_power {
 		((group) << PP_GROUP_SHIFT | (block) << PP_BLOCK_SHIFT | \
 		(support) << PP_STATE_SUPPORT_SHIFT | (state) << PP_STATE_SHIFT)
 
+enum PP_VOLTAGE_CONTROL_TYPE {
+	PP_EXTENDED_VOLTAGE,
+	PP_EXTENDED_VARIABLE_VOLTAGE,
+	PP_ADAPTIVE_VOLGATE_FREQUENCY_SCALING,
+	PP_INVALID_VOLTAGE_TYPE = 0xFF,
+};
+
 struct seq_file;
 enum amd_pp_clock_type;
 struct amd_pp_simple_clock_info;
@@ -289,6 +296,7 @@ struct amd_pm_funcs {
 				struct pp_display_clock_request *clock);
 	int (*get_display_mode_validation_clocks)(void *handle,
 		struct amd_pp_simple_clock_info *clocks);
+	int (*get_pp_voltage_control_type)(void *handle, enum PP_VOLTAGE_CONTROL_TYPE *type);
 };
 
 #endif
-- 
1.9.1



[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux