aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c
diff options
context:
space:
mode:
authorGrazvydas Ignotas <notasas@gmail.com>2016-10-29 16:28:59 -0400
committerAlex Deucher <alexander.deucher@amd.com>2016-11-11 10:20:56 -0500
commit81c1514bf8db9aee71bc6e610a62d64a865e06a4 (patch)
tree18b04c6517c9bc96cc5d76de500d52953d83e5fd /drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c
parent72a16a9d59ee0de87d9899959978b8e8f6da8438 (diff)
drm/amd/amdgpu: expose fan rpm though hwmon
Only for cards that are supported by powerplay. Signed-off-by: Grazvydas Ignotas <notasas@gmail.com> Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
Diffstat (limited to 'drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c')
-rw-r--r--drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c
index 274f3309aec9..723ae682bf25 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c
@@ -737,6 +737,21 @@ static ssize_t amdgpu_hwmon_get_pwm1(struct device *dev,
737 return sprintf(buf, "%i\n", speed); 737 return sprintf(buf, "%i\n", speed);
738} 738}
739 739
740static ssize_t amdgpu_hwmon_get_fan1_input(struct device *dev,
741 struct device_attribute *attr,
742 char *buf)
743{
744 struct amdgpu_device *adev = dev_get_drvdata(dev);
745 int err;
746 u32 speed;
747
748 err = amdgpu_dpm_get_fan_speed_rpm(adev, &speed);
749 if (err)
750 return err;
751
752 return sprintf(buf, "%i\n", speed);
753}
754
740static SENSOR_DEVICE_ATTR(temp1_input, S_IRUGO, amdgpu_hwmon_show_temp, NULL, 0); 755static SENSOR_DEVICE_ATTR(temp1_input, S_IRUGO, amdgpu_hwmon_show_temp, NULL, 0);
741static SENSOR_DEVICE_ATTR(temp1_crit, S_IRUGO, amdgpu_hwmon_show_temp_thresh, NULL, 0); 756static SENSOR_DEVICE_ATTR(temp1_crit, S_IRUGO, amdgpu_hwmon_show_temp_thresh, NULL, 0);
742static SENSOR_DEVICE_ATTR(temp1_crit_hyst, S_IRUGO, amdgpu_hwmon_show_temp_thresh, NULL, 1); 757static SENSOR_DEVICE_ATTR(temp1_crit_hyst, S_IRUGO, amdgpu_hwmon_show_temp_thresh, NULL, 1);
@@ -744,6 +759,7 @@ static SENSOR_DEVICE_ATTR(pwm1, S_IRUGO | S_IWUSR, amdgpu_hwmon_get_pwm1, amdgpu
744static SENSOR_DEVICE_ATTR(pwm1_enable, S_IRUGO | S_IWUSR, amdgpu_hwmon_get_pwm1_enable, amdgpu_hwmon_set_pwm1_enable, 0); 759static SENSOR_DEVICE_ATTR(pwm1_enable, S_IRUGO | S_IWUSR, amdgpu_hwmon_get_pwm1_enable, amdgpu_hwmon_set_pwm1_enable, 0);
745static SENSOR_DEVICE_ATTR(pwm1_min, S_IRUGO, amdgpu_hwmon_get_pwm1_min, NULL, 0); 760static SENSOR_DEVICE_ATTR(pwm1_min, S_IRUGO, amdgpu_hwmon_get_pwm1_min, NULL, 0);
746static SENSOR_DEVICE_ATTR(pwm1_max, S_IRUGO, amdgpu_hwmon_get_pwm1_max, NULL, 0); 761static SENSOR_DEVICE_ATTR(pwm1_max, S_IRUGO, amdgpu_hwmon_get_pwm1_max, NULL, 0);
762static SENSOR_DEVICE_ATTR(fan1_input, S_IRUGO, amdgpu_hwmon_get_fan1_input, NULL, 0);
747 763
748static struct attribute *hwmon_attributes[] = { 764static struct attribute *hwmon_attributes[] = {
749 &sensor_dev_attr_temp1_input.dev_attr.attr, 765 &sensor_dev_attr_temp1_input.dev_attr.attr,
@@ -753,6 +769,7 @@ static struct attribute *hwmon_attributes[] = {
753 &sensor_dev_attr_pwm1_enable.dev_attr.attr, 769 &sensor_dev_attr_pwm1_enable.dev_attr.attr,
754 &sensor_dev_attr_pwm1_min.dev_attr.attr, 770 &sensor_dev_attr_pwm1_min.dev_attr.attr,
755 &sensor_dev_attr_pwm1_max.dev_attr.attr, 771 &sensor_dev_attr_pwm1_max.dev_attr.attr,
772 &sensor_dev_attr_fan1_input.dev_attr.attr,
756 NULL 773 NULL
757}; 774};
758 775
@@ -804,6 +821,10 @@ static umode_t hwmon_attributes_visible(struct kobject *kobj,
804 attr == &sensor_dev_attr_pwm1_min.dev_attr.attr)) 821 attr == &sensor_dev_attr_pwm1_min.dev_attr.attr))
805 return 0; 822 return 0;
806 823
824 /* requires powerplay */
825 if (attr == &sensor_dev_attr_fan1_input.dev_attr.attr)
826 return 0;
827
807 return effective_mode; 828 return effective_mode;
808} 829}
809 830