aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/gpu/drm/nouveau/nouveau_hwmon.c34
1 files changed, 33 insertions, 1 deletions
diff --git a/drivers/gpu/drm/nouveau/nouveau_hwmon.c b/drivers/gpu/drm/nouveau/nouveau_hwmon.c
index bb0718579c2c..2304189addcb 100644
--- a/drivers/gpu/drm/nouveau/nouveau_hwmon.c
+++ b/drivers/gpu/drm/nouveau/nouveau_hwmon.c
@@ -192,6 +192,27 @@ static SENSOR_DEVICE_ATTR(pwm1_max, S_IRUGO | S_IWUSR,
192 nouveau_hwmon_get_pwm1_max, 192 nouveau_hwmon_get_pwm1_max,
193 nouveau_hwmon_set_pwm1_max, 0); 193 nouveau_hwmon_set_pwm1_max, 0);
194 194
195static struct attribute *pwm_fan_sensor_attrs[] = {
196 &sensor_dev_attr_pwm1_min.dev_attr.attr,
197 &sensor_dev_attr_pwm1_max.dev_attr.attr,
198 NULL
199};
200static const struct attribute_group pwm_fan_sensor_group = {
201 .attrs = pwm_fan_sensor_attrs,
202};
203
204static struct attribute *temp1_auto_point_sensor_attrs[] = {
205 &sensor_dev_attr_temp1_auto_point1_pwm.dev_attr.attr,
206 &sensor_dev_attr_temp1_auto_point1_temp.dev_attr.attr,
207 &sensor_dev_attr_temp1_auto_point1_temp_hyst.dev_attr.attr,
208 NULL
209};
210static const struct attribute_group temp1_auto_point_sensor_group = {
211 .attrs = temp1_auto_point_sensor_attrs,
212};
213
214#define N_ATTR_GROUPS 3
215
195static const u32 nouveau_config_chip[] = { 216static const u32 nouveau_config_chip[] = {
196 HWMON_C_UPDATE_INTERVAL, 217 HWMON_C_UPDATE_INTERVAL,
197 0 218 0
@@ -687,17 +708,28 @@ nouveau_hwmon_init(struct drm_device *dev)
687#if defined(CONFIG_HWMON) || (defined(MODULE) && defined(CONFIG_HWMON_MODULE)) 708#if defined(CONFIG_HWMON) || (defined(MODULE) && defined(CONFIG_HWMON_MODULE))
688 struct nouveau_drm *drm = nouveau_drm(dev); 709 struct nouveau_drm *drm = nouveau_drm(dev);
689 struct nvkm_therm *therm = nvxx_therm(&drm->client.device); 710 struct nvkm_therm *therm = nvxx_therm(&drm->client.device);
711 const struct attribute_group *special_groups[N_ATTR_GROUPS];
690 struct nouveau_hwmon *hwmon; 712 struct nouveau_hwmon *hwmon;
691 struct device *hwmon_dev; 713 struct device *hwmon_dev;
692 int ret = 0; 714 int ret = 0;
715 int i = 0;
693 716
694 hwmon = drm->hwmon = kzalloc(sizeof(*hwmon), GFP_KERNEL); 717 hwmon = drm->hwmon = kzalloc(sizeof(*hwmon), GFP_KERNEL);
695 if (!hwmon) 718 if (!hwmon)
696 return -ENOMEM; 719 return -ENOMEM;
697 hwmon->dev = dev; 720 hwmon->dev = dev;
698 721
722 if (therm && therm->attr_get && therm->attr_set) {
723 if (nvkm_therm_temp_get(therm) >= 0)
724 special_groups[i++] = &temp1_auto_point_sensor_group;
725 if (therm->fan_get && therm->fan_get(therm) >= 0)
726 special_groups[i++] = &pwm_fan_sensor_group;
727 }
728
729 special_groups[i] = 0;
699 hwmon_dev = hwmon_device_register_with_info(dev->dev, "nouveau", dev, 730 hwmon_dev = hwmon_device_register_with_info(dev->dev, "nouveau", dev,
700 &nouveau_chip_info, NULL); 731 &nouveau_chip_info,
732 special_groups);
701 if (IS_ERR(hwmon_dev)) { 733 if (IS_ERR(hwmon_dev)) {
702 ret = PTR_ERR(hwmon_dev); 734 ret = PTR_ERR(hwmon_dev);
703 NV_ERROR(drm, "Unable to register hwmon device: %d\n", ret); 735 NV_ERROR(drm, "Unable to register hwmon device: %d\n", ret);