aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm/nouveau/nouveau_pm.c
diff options
context:
space:
mode:
authorMartin Peres <martin.peres@labri.fr>2012-09-04 07:52:00 -0400
committerBen Skeggs <bskeggs@redhat.com>2012-10-02 23:13:15 -0400
commit2f951a5db5b55f65eb02d9a90aa7cecafde9f8b8 (patch)
tree9aeaca54de7a14598a3b2be04cb13ab891863dfd /drivers/gpu/drm/nouveau/nouveau_pm.c
parentc9cbf135065c0a674d43451127a10e48a53f9054 (diff)
drm/nouveau/therm: add support for fan-control modes
For now, only 2 control modes are available: - NONE: The fan is never touched (default) - MANUAL: The fan is set to the user-defined fan speed (pwm1) This patch introduces a distinction between ptherm internal fan management and external fan management. The latter is bound to respect the fan mode while the first can still select the speed it wants unless the NONE mode is selected. This is important for automatic fan management. Signed-off-by: Martin Peres <martin.peres@labri.fr> Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
Diffstat (limited to 'drivers/gpu/drm/nouveau/nouveau_pm.c')
-rw-r--r--drivers/gpu/drm/nouveau/nouveau_pm.c40
1 files changed, 40 insertions, 0 deletions
diff --git a/drivers/gpu/drm/nouveau/nouveau_pm.c b/drivers/gpu/drm/nouveau/nouveau_pm.c
index 0dca191ee173..b9d5335df742 100644
--- a/drivers/gpu/drm/nouveau/nouveau_pm.c
+++ b/drivers/gpu/drm/nouveau/nouveau_pm.c
@@ -503,6 +503,45 @@ nouveau_hwmon_show_fan0_input(struct device *d, struct device_attribute *attr,
503static SENSOR_DEVICE_ATTR(fan0_input, S_IRUGO, nouveau_hwmon_show_fan0_input, 503static SENSOR_DEVICE_ATTR(fan0_input, S_IRUGO, nouveau_hwmon_show_fan0_input,
504 NULL, 0); 504 NULL, 0);
505 505
506 static ssize_t
507nouveau_hwmon_get_pwm1_enable(struct device *d,
508 struct device_attribute *a, char *buf)
509{
510 struct drm_device *dev = dev_get_drvdata(d);
511 struct nouveau_drm *drm = nouveau_drm(dev);
512 struct nouveau_therm *therm = nouveau_therm(drm->device);
513 int ret;
514
515 ret = therm->attr_get(therm, NOUVEAU_THERM_ATTR_FAN_MODE);
516 if (ret < 0)
517 return ret;
518
519 return sprintf(buf, "%i\n", ret);
520}
521
522static ssize_t
523nouveau_hwmon_set_pwm1_enable(struct device *d, struct device_attribute *a,
524 const char *buf, size_t count)
525{
526 struct drm_device *dev = dev_get_drvdata(d);
527 struct nouveau_drm *drm = nouveau_drm(dev);
528 struct nouveau_therm *therm = nouveau_therm(drm->device);
529 long value;
530 int ret;
531
532 if (strict_strtol(buf, 10, &value) == -EINVAL)
533 return -EINVAL;
534
535 ret = therm->attr_set(therm, NOUVEAU_THERM_ATTR_FAN_MODE, value);
536 if (ret)
537 return ret;
538 else
539 return count;
540}
541static SENSOR_DEVICE_ATTR(pwm1_enable, S_IRUGO | S_IWUSR,
542 nouveau_hwmon_get_pwm1_enable,
543 nouveau_hwmon_set_pwm1_enable, 0);
544
506static ssize_t 545static ssize_t
507nouveau_hwmon_get_pwm1(struct device *d, struct device_attribute *a, char *buf) 546nouveau_hwmon_get_pwm1(struct device *d, struct device_attribute *a, char *buf)
508{ 547{
@@ -638,6 +677,7 @@ static struct attribute *hwmon_fan_rpm_attributes[] = {
638 NULL 677 NULL
639}; 678};
640static struct attribute *hwmon_pwm_fan_attributes[] = { 679static struct attribute *hwmon_pwm_fan_attributes[] = {
680 &sensor_dev_attr_pwm1_enable.dev_attr.attr,
641 &sensor_dev_attr_pwm1.dev_attr.attr, 681 &sensor_dev_attr_pwm1.dev_attr.attr,
642 &sensor_dev_attr_pwm1_min.dev_attr.attr, 682 &sensor_dev_attr_pwm1_min.dev_attr.attr,
643 &sensor_dev_attr_pwm1_max.dev_attr.attr, 683 &sensor_dev_attr_pwm1_max.dev_attr.attr,