diff options
Diffstat (limited to 'drivers/gpu/drm/nouveau/nouveau_hwmon.c')
| -rw-r--r-- | drivers/gpu/drm/nouveau/nouveau_hwmon.c | 110 |
1 files changed, 77 insertions, 33 deletions
diff --git a/drivers/gpu/drm/nouveau/nouveau_hwmon.c b/drivers/gpu/drm/nouveau/nouveau_hwmon.c index 71f764bf4cc6..23b1670c1c2f 100644 --- a/drivers/gpu/drm/nouveau/nouveau_hwmon.c +++ b/drivers/gpu/drm/nouveau/nouveau_hwmon.c | |||
| @@ -43,7 +43,7 @@ nouveau_hwmon_show_temp(struct device *d, struct device_attribute *a, char *buf) | |||
| 43 | { | 43 | { |
| 44 | struct drm_device *dev = dev_get_drvdata(d); | 44 | struct drm_device *dev = dev_get_drvdata(d); |
| 45 | struct nouveau_drm *drm = nouveau_drm(dev); | 45 | struct nouveau_drm *drm = nouveau_drm(dev); |
| 46 | struct nvkm_therm *therm = nvxx_therm(&drm->device); | 46 | struct nvkm_therm *therm = nvxx_therm(&drm->client.device); |
| 47 | int temp = nvkm_therm_temp_get(therm); | 47 | int temp = nvkm_therm_temp_get(therm); |
| 48 | 48 | ||
| 49 | if (temp < 0) | 49 | if (temp < 0) |
| @@ -69,7 +69,7 @@ nouveau_hwmon_temp1_auto_point1_temp(struct device *d, | |||
| 69 | { | 69 | { |
| 70 | struct drm_device *dev = dev_get_drvdata(d); | 70 | struct drm_device *dev = dev_get_drvdata(d); |
| 71 | struct nouveau_drm *drm = nouveau_drm(dev); | 71 | struct nouveau_drm *drm = nouveau_drm(dev); |
| 72 | struct nvkm_therm *therm = nvxx_therm(&drm->device); | 72 | struct nvkm_therm *therm = nvxx_therm(&drm->client.device); |
| 73 | 73 | ||
| 74 | return snprintf(buf, PAGE_SIZE, "%d\n", | 74 | return snprintf(buf, PAGE_SIZE, "%d\n", |
| 75 | therm->attr_get(therm, NVKM_THERM_ATTR_THRS_FAN_BOOST) * 1000); | 75 | therm->attr_get(therm, NVKM_THERM_ATTR_THRS_FAN_BOOST) * 1000); |
| @@ -81,7 +81,7 @@ nouveau_hwmon_set_temp1_auto_point1_temp(struct device *d, | |||
| 81 | { | 81 | { |
| 82 | struct drm_device *dev = dev_get_drvdata(d); | 82 | struct drm_device *dev = dev_get_drvdata(d); |
| 83 | struct nouveau_drm *drm = nouveau_drm(dev); | 83 | struct nouveau_drm *drm = nouveau_drm(dev); |
| 84 | struct nvkm_therm *therm = nvxx_therm(&drm->device); | 84 | struct nvkm_therm *therm = nvxx_therm(&drm->client.device); |
| 85 | long value; | 85 | long value; |
| 86 | 86 | ||
| 87 | if (kstrtol(buf, 10, &value) == -EINVAL) | 87 | if (kstrtol(buf, 10, &value) == -EINVAL) |
| @@ -102,7 +102,7 @@ nouveau_hwmon_temp1_auto_point1_temp_hyst(struct device *d, | |||
| 102 | { | 102 | { |
| 103 | struct drm_device *dev = dev_get_drvdata(d); | 103 | struct drm_device *dev = dev_get_drvdata(d); |
| 104 | struct nouveau_drm *drm = nouveau_drm(dev); | 104 | struct nouveau_drm *drm = nouveau_drm(dev); |
| 105 | struct nvkm_therm *therm = nvxx_therm(&drm->device); | 105 | struct nvkm_therm *therm = nvxx_therm(&drm->client.device); |
| 106 | 106 | ||
| 107 | return snprintf(buf, PAGE_SIZE, "%d\n", | 107 | return snprintf(buf, PAGE_SIZE, "%d\n", |
| 108 | therm->attr_get(therm, NVKM_THERM_ATTR_THRS_FAN_BOOST_HYST) * 1000); | 108 | therm->attr_get(therm, NVKM_THERM_ATTR_THRS_FAN_BOOST_HYST) * 1000); |
| @@ -114,7 +114,7 @@ nouveau_hwmon_set_temp1_auto_point1_temp_hyst(struct device *d, | |||
| 114 | { | 114 | { |
| 115 | struct drm_device *dev = dev_get_drvdata(d); | 115 | struct drm_device *dev = dev_get_drvdata(d); |
| 116 | struct nouveau_drm *drm = nouveau_drm(dev); | 116 | struct nouveau_drm *drm = nouveau_drm(dev); |
| 117 | struct nvkm_therm *therm = nvxx_therm(&drm->device); | 117 | struct nvkm_therm *therm = nvxx_therm(&drm->client.device); |
| 118 | long value; | 118 | long value; |
| 119 | 119 | ||
| 120 | if (kstrtol(buf, 10, &value) == -EINVAL) | 120 | if (kstrtol(buf, 10, &value) == -EINVAL) |
| @@ -134,7 +134,7 @@ nouveau_hwmon_max_temp(struct device *d, struct device_attribute *a, char *buf) | |||
| 134 | { | 134 | { |
| 135 | struct drm_device *dev = dev_get_drvdata(d); | 135 | struct drm_device *dev = dev_get_drvdata(d); |
| 136 | struct nouveau_drm *drm = nouveau_drm(dev); | 136 | struct nouveau_drm *drm = nouveau_drm(dev); |
| 137 | struct nvkm_therm *therm = nvxx_therm(&drm->device); | 137 | struct nvkm_therm *therm = nvxx_therm(&drm->client.device); |
| 138 | 138 | ||
| 139 | return snprintf(buf, PAGE_SIZE, "%d\n", | 139 | return snprintf(buf, PAGE_SIZE, "%d\n", |
| 140 | therm->attr_get(therm, NVKM_THERM_ATTR_THRS_DOWN_CLK) * 1000); | 140 | therm->attr_get(therm, NVKM_THERM_ATTR_THRS_DOWN_CLK) * 1000); |
| @@ -145,7 +145,7 @@ nouveau_hwmon_set_max_temp(struct device *d, struct device_attribute *a, | |||
| 145 | { | 145 | { |
| 146 | struct drm_device *dev = dev_get_drvdata(d); | 146 | struct drm_device *dev = dev_get_drvdata(d); |
| 147 | struct nouveau_drm *drm = nouveau_drm(dev); | 147 | struct nouveau_drm *drm = nouveau_drm(dev); |
| 148 | struct nvkm_therm *therm = nvxx_therm(&drm->device); | 148 | struct nvkm_therm *therm = nvxx_therm(&drm->client.device); |
| 149 | long value; | 149 | long value; |
| 150 | 150 | ||
| 151 | if (kstrtol(buf, 10, &value) == -EINVAL) | 151 | if (kstrtol(buf, 10, &value) == -EINVAL) |
| @@ -165,7 +165,7 @@ nouveau_hwmon_max_temp_hyst(struct device *d, struct device_attribute *a, | |||
| 165 | { | 165 | { |
| 166 | struct drm_device *dev = dev_get_drvdata(d); | 166 | struct drm_device *dev = dev_get_drvdata(d); |
| 167 | struct nouveau_drm *drm = nouveau_drm(dev); | 167 | struct nouveau_drm *drm = nouveau_drm(dev); |
| 168 | struct nvkm_therm *therm = nvxx_therm(&drm->device); | 168 | struct nvkm_therm *therm = nvxx_therm(&drm->client.device); |
| 169 | 169 | ||
| 170 | return snprintf(buf, PAGE_SIZE, "%d\n", | 170 | return snprintf(buf, PAGE_SIZE, "%d\n", |
| 171 | therm->attr_get(therm, NVKM_THERM_ATTR_THRS_DOWN_CLK_HYST) * 1000); | 171 | therm->attr_get(therm, NVKM_THERM_ATTR_THRS_DOWN_CLK_HYST) * 1000); |
| @@ -176,7 +176,7 @@ nouveau_hwmon_set_max_temp_hyst(struct device *d, struct device_attribute *a, | |||
| 176 | { | 176 | { |
| 177 | struct drm_device *dev = dev_get_drvdata(d); | 177 | struct drm_device *dev = dev_get_drvdata(d); |
| 178 | struct nouveau_drm *drm = nouveau_drm(dev); | 178 | struct nouveau_drm *drm = nouveau_drm(dev); |
| 179 | struct nvkm_therm *therm = nvxx_therm(&drm->device); | 179 | struct nvkm_therm *therm = nvxx_therm(&drm->client.device); |
| 180 | long value; | 180 | long value; |
| 181 | 181 | ||
| 182 | if (kstrtol(buf, 10, &value) == -EINVAL) | 182 | if (kstrtol(buf, 10, &value) == -EINVAL) |
| @@ -197,7 +197,7 @@ nouveau_hwmon_critical_temp(struct device *d, struct device_attribute *a, | |||
| 197 | { | 197 | { |
| 198 | struct drm_device *dev = dev_get_drvdata(d); | 198 | struct drm_device *dev = dev_get_drvdata(d); |
| 199 | struct nouveau_drm *drm = nouveau_drm(dev); | 199 | struct nouveau_drm *drm = nouveau_drm(dev); |
| 200 | struct nvkm_therm *therm = nvxx_therm(&drm->device); | 200 | struct nvkm_therm *therm = nvxx_therm(&drm->client.device); |
| 201 | 201 | ||
| 202 | return snprintf(buf, PAGE_SIZE, "%d\n", | 202 | return snprintf(buf, PAGE_SIZE, "%d\n", |
| 203 | therm->attr_get(therm, NVKM_THERM_ATTR_THRS_CRITICAL) * 1000); | 203 | therm->attr_get(therm, NVKM_THERM_ATTR_THRS_CRITICAL) * 1000); |
| @@ -209,7 +209,7 @@ nouveau_hwmon_set_critical_temp(struct device *d, struct device_attribute *a, | |||
| 209 | { | 209 | { |
| 210 | struct drm_device *dev = dev_get_drvdata(d); | 210 | struct drm_device *dev = dev_get_drvdata(d); |
| 211 | struct nouveau_drm *drm = nouveau_drm(dev); | 211 | struct nouveau_drm *drm = nouveau_drm(dev); |
| 212 | struct nvkm_therm *therm = nvxx_therm(&drm->device); | 212 | struct nvkm_therm *therm = nvxx_therm(&drm->client.device); |
| 213 | long value; | 213 | long value; |
| 214 | 214 | ||
| 215 | if (kstrtol(buf, 10, &value) == -EINVAL) | 215 | if (kstrtol(buf, 10, &value) == -EINVAL) |
| @@ -230,7 +230,7 @@ nouveau_hwmon_critical_temp_hyst(struct device *d, struct device_attribute *a, | |||
| 230 | { | 230 | { |
| 231 | struct drm_device *dev = dev_get_drvdata(d); | 231 | struct drm_device *dev = dev_get_drvdata(d); |
| 232 | struct nouveau_drm *drm = nouveau_drm(dev); | 232 | struct nouveau_drm *drm = nouveau_drm(dev); |
| 233 | struct nvkm_therm *therm = nvxx_therm(&drm->device); | 233 | struct nvkm_therm *therm = nvxx_therm(&drm->client.device); |
| 234 | 234 | ||
| 235 | return snprintf(buf, PAGE_SIZE, "%d\n", | 235 | return snprintf(buf, PAGE_SIZE, "%d\n", |
| 236 | therm->attr_get(therm, NVKM_THERM_ATTR_THRS_CRITICAL_HYST) * 1000); | 236 | therm->attr_get(therm, NVKM_THERM_ATTR_THRS_CRITICAL_HYST) * 1000); |
| @@ -243,7 +243,7 @@ nouveau_hwmon_set_critical_temp_hyst(struct device *d, | |||
| 243 | { | 243 | { |
| 244 | struct drm_device *dev = dev_get_drvdata(d); | 244 | struct drm_device *dev = dev_get_drvdata(d); |
| 245 | struct nouveau_drm *drm = nouveau_drm(dev); | 245 | struct nouveau_drm *drm = nouveau_drm(dev); |
| 246 | struct nvkm_therm *therm = nvxx_therm(&drm->device); | 246 | struct nvkm_therm *therm = nvxx_therm(&drm->client.device); |
| 247 | long value; | 247 | long value; |
| 248 | 248 | ||
| 249 | if (kstrtol(buf, 10, &value) == -EINVAL) | 249 | if (kstrtol(buf, 10, &value) == -EINVAL) |
| @@ -263,7 +263,7 @@ nouveau_hwmon_emergency_temp(struct device *d, struct device_attribute *a, | |||
| 263 | { | 263 | { |
| 264 | struct drm_device *dev = dev_get_drvdata(d); | 264 | struct drm_device *dev = dev_get_drvdata(d); |
| 265 | struct nouveau_drm *drm = nouveau_drm(dev); | 265 | struct nouveau_drm *drm = nouveau_drm(dev); |
| 266 | struct nvkm_therm *therm = nvxx_therm(&drm->device); | 266 | struct nvkm_therm *therm = nvxx_therm(&drm->client.device); |
| 267 | 267 | ||
| 268 | return snprintf(buf, PAGE_SIZE, "%d\n", | 268 | return snprintf(buf, PAGE_SIZE, "%d\n", |
| 269 | therm->attr_get(therm, NVKM_THERM_ATTR_THRS_SHUTDOWN) * 1000); | 269 | therm->attr_get(therm, NVKM_THERM_ATTR_THRS_SHUTDOWN) * 1000); |
| @@ -275,7 +275,7 @@ nouveau_hwmon_set_emergency_temp(struct device *d, struct device_attribute *a, | |||
| 275 | { | 275 | { |
| 276 | struct drm_device *dev = dev_get_drvdata(d); | 276 | struct drm_device *dev = dev_get_drvdata(d); |
| 277 | struct nouveau_drm *drm = nouveau_drm(dev); | 277 | struct nouveau_drm *drm = nouveau_drm(dev); |
| 278 | struct nvkm_therm *therm = nvxx_therm(&drm->device); | 278 | struct nvkm_therm *therm = nvxx_therm(&drm->client.device); |
| 279 | long value; | 279 | long value; |
| 280 | 280 | ||
| 281 | if (kstrtol(buf, 10, &value) == -EINVAL) | 281 | if (kstrtol(buf, 10, &value) == -EINVAL) |
| @@ -296,7 +296,7 @@ nouveau_hwmon_emergency_temp_hyst(struct device *d, struct device_attribute *a, | |||
| 296 | { | 296 | { |
| 297 | struct drm_device *dev = dev_get_drvdata(d); | 297 | struct drm_device *dev = dev_get_drvdata(d); |
| 298 | struct nouveau_drm *drm = nouveau_drm(dev); | 298 | struct nouveau_drm *drm = nouveau_drm(dev); |
| 299 | struct nvkm_therm *therm = nvxx_therm(&drm->device); | 299 | struct nvkm_therm *therm = nvxx_therm(&drm->client.device); |
| 300 | 300 | ||
| 301 | return snprintf(buf, PAGE_SIZE, "%d\n", | 301 | return snprintf(buf, PAGE_SIZE, "%d\n", |
| 302 | therm->attr_get(therm, NVKM_THERM_ATTR_THRS_SHUTDOWN_HYST) * 1000); | 302 | therm->attr_get(therm, NVKM_THERM_ATTR_THRS_SHUTDOWN_HYST) * 1000); |
| @@ -309,7 +309,7 @@ nouveau_hwmon_set_emergency_temp_hyst(struct device *d, | |||
| 309 | { | 309 | { |
| 310 | struct drm_device *dev = dev_get_drvdata(d); | 310 | struct drm_device *dev = dev_get_drvdata(d); |
| 311 | struct nouveau_drm *drm = nouveau_drm(dev); | 311 | struct nouveau_drm *drm = nouveau_drm(dev); |
| 312 | struct nvkm_therm *therm = nvxx_therm(&drm->device); | 312 | struct nvkm_therm *therm = nvxx_therm(&drm->client.device); |
| 313 | long value; | 313 | long value; |
| 314 | 314 | ||
| 315 | if (kstrtol(buf, 10, &value) == -EINVAL) | 315 | if (kstrtol(buf, 10, &value) == -EINVAL) |
| @@ -349,7 +349,7 @@ nouveau_hwmon_show_fan1_input(struct device *d, struct device_attribute *attr, | |||
| 349 | { | 349 | { |
| 350 | struct drm_device *dev = dev_get_drvdata(d); | 350 | struct drm_device *dev = dev_get_drvdata(d); |
| 351 | struct nouveau_drm *drm = nouveau_drm(dev); | 351 | struct nouveau_drm *drm = nouveau_drm(dev); |
| 352 | struct nvkm_therm *therm = nvxx_therm(&drm->device); | 352 | struct nvkm_therm *therm = nvxx_therm(&drm->client.device); |
| 353 | 353 | ||
| 354 | return snprintf(buf, PAGE_SIZE, "%d\n", nvkm_therm_fan_sense(therm)); | 354 | return snprintf(buf, PAGE_SIZE, "%d\n", nvkm_therm_fan_sense(therm)); |
| 355 | } | 355 | } |
| @@ -362,7 +362,7 @@ nouveau_hwmon_get_pwm1_enable(struct device *d, | |||
| 362 | { | 362 | { |
| 363 | struct drm_device *dev = dev_get_drvdata(d); | 363 | struct drm_device *dev = dev_get_drvdata(d); |
| 364 | struct nouveau_drm *drm = nouveau_drm(dev); | 364 | struct nouveau_drm *drm = nouveau_drm(dev); |
| 365 | struct nvkm_therm *therm = nvxx_therm(&drm->device); | 365 | struct nvkm_therm *therm = nvxx_therm(&drm->client.device); |
| 366 | int ret; | 366 | int ret; |
| 367 | 367 | ||
| 368 | ret = therm->attr_get(therm, NVKM_THERM_ATTR_FAN_MODE); | 368 | ret = therm->attr_get(therm, NVKM_THERM_ATTR_FAN_MODE); |
| @@ -378,7 +378,7 @@ nouveau_hwmon_set_pwm1_enable(struct device *d, struct device_attribute *a, | |||
| 378 | { | 378 | { |
| 379 | struct drm_device *dev = dev_get_drvdata(d); | 379 | struct drm_device *dev = dev_get_drvdata(d); |
| 380 | struct nouveau_drm *drm = nouveau_drm(dev); | 380 | struct nouveau_drm *drm = nouveau_drm(dev); |
| 381 | struct nvkm_therm *therm = nvxx_therm(&drm->device); | 381 | struct nvkm_therm *therm = nvxx_therm(&drm->client.device); |
| 382 | long value; | 382 | long value; |
| 383 | int ret; | 383 | int ret; |
| 384 | 384 | ||
| @@ -401,7 +401,7 @@ nouveau_hwmon_get_pwm1(struct device *d, struct device_attribute *a, char *buf) | |||
| 401 | { | 401 | { |
| 402 | struct drm_device *dev = dev_get_drvdata(d); | 402 | struct drm_device *dev = dev_get_drvdata(d); |
| 403 | struct nouveau_drm *drm = nouveau_drm(dev); | 403 | struct nouveau_drm *drm = nouveau_drm(dev); |
| 404 | struct nvkm_therm *therm = nvxx_therm(&drm->device); | 404 | struct nvkm_therm *therm = nvxx_therm(&drm->client.device); |
| 405 | int ret; | 405 | int ret; |
| 406 | 406 | ||
| 407 | ret = therm->fan_get(therm); | 407 | ret = therm->fan_get(therm); |
| @@ -417,7 +417,7 @@ nouveau_hwmon_set_pwm1(struct device *d, struct device_attribute *a, | |||
| 417 | { | 417 | { |
| 418 | struct drm_device *dev = dev_get_drvdata(d); | 418 | struct drm_device *dev = dev_get_drvdata(d); |
| 419 | struct nouveau_drm *drm = nouveau_drm(dev); | 419 | struct nouveau_drm *drm = nouveau_drm(dev); |
| 420 | struct nvkm_therm *therm = nvxx_therm(&drm->device); | 420 | struct nvkm_therm *therm = nvxx_therm(&drm->client.device); |
| 421 | int ret = -ENODEV; | 421 | int ret = -ENODEV; |
| 422 | long value; | 422 | long value; |
| 423 | 423 | ||
| @@ -441,7 +441,7 @@ nouveau_hwmon_get_pwm1_min(struct device *d, | |||
| 441 | { | 441 | { |
| 442 | struct drm_device *dev = dev_get_drvdata(d); | 442 | struct drm_device *dev = dev_get_drvdata(d); |
| 443 | struct nouveau_drm *drm = nouveau_drm(dev); | 443 | struct nouveau_drm *drm = nouveau_drm(dev); |
| 444 | struct nvkm_therm *therm = nvxx_therm(&drm->device); | 444 | struct nvkm_therm *therm = nvxx_therm(&drm->client.device); |
| 445 | int ret; | 445 | int ret; |
| 446 | 446 | ||
| 447 | ret = therm->attr_get(therm, NVKM_THERM_ATTR_FAN_MIN_DUTY); | 447 | ret = therm->attr_get(therm, NVKM_THERM_ATTR_FAN_MIN_DUTY); |
| @@ -457,7 +457,7 @@ nouveau_hwmon_set_pwm1_min(struct device *d, struct device_attribute *a, | |||
| 457 | { | 457 | { |
| 458 | struct drm_device *dev = dev_get_drvdata(d); | 458 | struct drm_device *dev = dev_get_drvdata(d); |
| 459 | struct nouveau_drm *drm = nouveau_drm(dev); | 459 | struct nouveau_drm *drm = nouveau_drm(dev); |
| 460 | struct nvkm_therm *therm = nvxx_therm(&drm->device); | 460 | struct nvkm_therm *therm = nvxx_therm(&drm->client.device); |
| 461 | long value; | 461 | long value; |
| 462 | int ret; | 462 | int ret; |
| 463 | 463 | ||
| @@ -481,7 +481,7 @@ nouveau_hwmon_get_pwm1_max(struct device *d, | |||
| 481 | { | 481 | { |
| 482 | struct drm_device *dev = dev_get_drvdata(d); | 482 | struct drm_device *dev = dev_get_drvdata(d); |
| 483 | struct nouveau_drm *drm = nouveau_drm(dev); | 483 | struct nouveau_drm *drm = nouveau_drm(dev); |
| 484 | struct nvkm_therm *therm = nvxx_therm(&drm->device); | 484 | struct nvkm_therm *therm = nvxx_therm(&drm->client.device); |
| 485 | int ret; | 485 | int ret; |
| 486 | 486 | ||
| 487 | ret = therm->attr_get(therm, NVKM_THERM_ATTR_FAN_MAX_DUTY); | 487 | ret = therm->attr_get(therm, NVKM_THERM_ATTR_FAN_MAX_DUTY); |
| @@ -497,7 +497,7 @@ nouveau_hwmon_set_pwm1_max(struct device *d, struct device_attribute *a, | |||
| 497 | { | 497 | { |
| 498 | struct drm_device *dev = dev_get_drvdata(d); | 498 | struct drm_device *dev = dev_get_drvdata(d); |
| 499 | struct nouveau_drm *drm = nouveau_drm(dev); | 499 | struct nouveau_drm *drm = nouveau_drm(dev); |
| 500 | struct nvkm_therm *therm = nvxx_therm(&drm->device); | 500 | struct nvkm_therm *therm = nvxx_therm(&drm->client.device); |
| 501 | long value; | 501 | long value; |
| 502 | int ret; | 502 | int ret; |
| 503 | 503 | ||
| @@ -521,7 +521,7 @@ nouveau_hwmon_get_in0_input(struct device *d, | |||
| 521 | { | 521 | { |
| 522 | struct drm_device *dev = dev_get_drvdata(d); | 522 | struct drm_device *dev = dev_get_drvdata(d); |
| 523 | struct nouveau_drm *drm = nouveau_drm(dev); | 523 | struct nouveau_drm *drm = nouveau_drm(dev); |
| 524 | struct nvkm_volt *volt = nvxx_volt(&drm->device); | 524 | struct nvkm_volt *volt = nvxx_volt(&drm->client.device); |
| 525 | int ret; | 525 | int ret; |
| 526 | 526 | ||
| 527 | ret = nvkm_volt_get(volt); | 527 | ret = nvkm_volt_get(volt); |
| @@ -540,7 +540,7 @@ nouveau_hwmon_get_in0_min(struct device *d, | |||
| 540 | { | 540 | { |
| 541 | struct drm_device *dev = dev_get_drvdata(d); | 541 | struct drm_device *dev = dev_get_drvdata(d); |
| 542 | struct nouveau_drm *drm = nouveau_drm(dev); | 542 | struct nouveau_drm *drm = nouveau_drm(dev); |
| 543 | struct nvkm_volt *volt = nvxx_volt(&drm->device); | 543 | struct nvkm_volt *volt = nvxx_volt(&drm->client.device); |
| 544 | 544 | ||
| 545 | if (!volt || !volt->min_uv) | 545 | if (!volt || !volt->min_uv) |
| 546 | return -ENODEV; | 546 | return -ENODEV; |
| @@ -557,7 +557,7 @@ nouveau_hwmon_get_in0_max(struct device *d, | |||
| 557 | { | 557 | { |
| 558 | struct drm_device *dev = dev_get_drvdata(d); | 558 | struct drm_device *dev = dev_get_drvdata(d); |
| 559 | struct nouveau_drm *drm = nouveau_drm(dev); | 559 | struct nouveau_drm *drm = nouveau_drm(dev); |
| 560 | struct nvkm_volt *volt = nvxx_volt(&drm->device); | 560 | struct nvkm_volt *volt = nvxx_volt(&drm->client.device); |
| 561 | 561 | ||
| 562 | if (!volt || !volt->max_uv) | 562 | if (!volt || !volt->max_uv) |
| 563 | return -ENODEV; | 563 | return -ENODEV; |
| @@ -584,7 +584,7 @@ nouveau_hwmon_get_power1_input(struct device *d, struct device_attribute *a, | |||
| 584 | { | 584 | { |
| 585 | struct drm_device *dev = dev_get_drvdata(d); | 585 | struct drm_device *dev = dev_get_drvdata(d); |
| 586 | struct nouveau_drm *drm = nouveau_drm(dev); | 586 | struct nouveau_drm *drm = nouveau_drm(dev); |
| 587 | struct nvkm_iccsense *iccsense = nvxx_iccsense(&drm->device); | 587 | struct nvkm_iccsense *iccsense = nvxx_iccsense(&drm->client.device); |
| 588 | int result = nvkm_iccsense_read_all(iccsense); | 588 | int result = nvkm_iccsense_read_all(iccsense); |
| 589 | 589 | ||
| 590 | if (result < 0) | 590 | if (result < 0) |
| @@ -596,6 +596,32 @@ nouveau_hwmon_get_power1_input(struct device *d, struct device_attribute *a, | |||
| 596 | static SENSOR_DEVICE_ATTR(power1_input, S_IRUGO, | 596 | static SENSOR_DEVICE_ATTR(power1_input, S_IRUGO, |
| 597 | nouveau_hwmon_get_power1_input, NULL, 0); | 597 | nouveau_hwmon_get_power1_input, NULL, 0); |
| 598 | 598 | ||
| 599 | static ssize_t | ||
| 600 | nouveau_hwmon_get_power1_max(struct device *d, struct device_attribute *a, | ||
| 601 | char *buf) | ||
| 602 | { | ||
| 603 | struct drm_device *dev = dev_get_drvdata(d); | ||
| 604 | struct nouveau_drm *drm = nouveau_drm(dev); | ||
| 605 | struct nvkm_iccsense *iccsense = nvxx_iccsense(&drm->client.device); | ||
| 606 | return sprintf(buf, "%i\n", iccsense->power_w_max); | ||
| 607 | } | ||
| 608 | |||
| 609 | static SENSOR_DEVICE_ATTR(power1_max, S_IRUGO, | ||
| 610 | nouveau_hwmon_get_power1_max, NULL, 0); | ||
| 611 | |||
| 612 | static ssize_t | ||
| 613 | nouveau_hwmon_get_power1_crit(struct device *d, struct device_attribute *a, | ||
| 614 | char *buf) | ||
| 615 | { | ||
| 616 | struct drm_device *dev = dev_get_drvdata(d); | ||
| 617 | struct nouveau_drm *drm = nouveau_drm(dev); | ||
| 618 | struct nvkm_iccsense *iccsense = nvxx_iccsense(&drm->client.device); | ||
| 619 | return sprintf(buf, "%i\n", iccsense->power_w_crit); | ||
| 620 | } | ||
| 621 | |||
| 622 | static SENSOR_DEVICE_ATTR(power1_crit, S_IRUGO, | ||
| 623 | nouveau_hwmon_get_power1_crit, NULL, 0); | ||
| 624 | |||
| 599 | static struct attribute *hwmon_default_attributes[] = { | 625 | static struct attribute *hwmon_default_attributes[] = { |
| 600 | &sensor_dev_attr_name.dev_attr.attr, | 626 | &sensor_dev_attr_name.dev_attr.attr, |
| 601 | &sensor_dev_attr_update_rate.dev_attr.attr, | 627 | &sensor_dev_attr_update_rate.dev_attr.attr, |
| @@ -639,6 +665,12 @@ static struct attribute *hwmon_power_attributes[] = { | |||
| 639 | NULL | 665 | NULL |
| 640 | }; | 666 | }; |
| 641 | 667 | ||
| 668 | static struct attribute *hwmon_power_caps_attributes[] = { | ||
| 669 | &sensor_dev_attr_power1_max.dev_attr.attr, | ||
| 670 | &sensor_dev_attr_power1_crit.dev_attr.attr, | ||
| 671 | NULL | ||
| 672 | }; | ||
| 673 | |||
| 642 | static const struct attribute_group hwmon_default_attrgroup = { | 674 | static const struct attribute_group hwmon_default_attrgroup = { |
| 643 | .attrs = hwmon_default_attributes, | 675 | .attrs = hwmon_default_attributes, |
| 644 | }; | 676 | }; |
| @@ -657,6 +689,9 @@ static const struct attribute_group hwmon_in0_attrgroup = { | |||
| 657 | static const struct attribute_group hwmon_power_attrgroup = { | 689 | static const struct attribute_group hwmon_power_attrgroup = { |
| 658 | .attrs = hwmon_power_attributes, | 690 | .attrs = hwmon_power_attributes, |
| 659 | }; | 691 | }; |
| 692 | static const struct attribute_group hwmon_power_caps_attrgroup = { | ||
| 693 | .attrs = hwmon_power_caps_attributes, | ||
| 694 | }; | ||
| 660 | #endif | 695 | #endif |
| 661 | 696 | ||
| 662 | int | 697 | int |
| @@ -664,9 +699,9 @@ nouveau_hwmon_init(struct drm_device *dev) | |||
| 664 | { | 699 | { |
| 665 | #if defined(CONFIG_HWMON) || (defined(MODULE) && defined(CONFIG_HWMON_MODULE)) | 700 | #if defined(CONFIG_HWMON) || (defined(MODULE) && defined(CONFIG_HWMON_MODULE)) |
| 666 | struct nouveau_drm *drm = nouveau_drm(dev); | 701 | struct nouveau_drm *drm = nouveau_drm(dev); |
| 667 | struct nvkm_therm *therm = nvxx_therm(&drm->device); | 702 | struct nvkm_therm *therm = nvxx_therm(&drm->client.device); |
| 668 | struct nvkm_volt *volt = nvxx_volt(&drm->device); | 703 | struct nvkm_volt *volt = nvxx_volt(&drm->client.device); |
| 669 | struct nvkm_iccsense *iccsense = nvxx_iccsense(&drm->device); | 704 | struct nvkm_iccsense *iccsense = nvxx_iccsense(&drm->client.device); |
| 670 | struct nouveau_hwmon *hwmon; | 705 | struct nouveau_hwmon *hwmon; |
| 671 | struct device *hwmon_dev; | 706 | struct device *hwmon_dev; |
| 672 | int ret = 0; | 707 | int ret = 0; |
| @@ -728,8 +763,16 @@ nouveau_hwmon_init(struct drm_device *dev) | |||
| 728 | if (iccsense && iccsense->data_valid && !list_empty(&iccsense->rails)) { | 763 | if (iccsense && iccsense->data_valid && !list_empty(&iccsense->rails)) { |
| 729 | ret = sysfs_create_group(&hwmon_dev->kobj, | 764 | ret = sysfs_create_group(&hwmon_dev->kobj, |
| 730 | &hwmon_power_attrgroup); | 765 | &hwmon_power_attrgroup); |
| 766 | |||
| 731 | if (ret) | 767 | if (ret) |
| 732 | goto error; | 768 | goto error; |
| 769 | |||
| 770 | if (iccsense->power_w_max && iccsense->power_w_crit) { | ||
| 771 | ret = sysfs_create_group(&hwmon_dev->kobj, | ||
| 772 | &hwmon_power_caps_attrgroup); | ||
| 773 | if (ret) | ||
| 774 | goto error; | ||
| 775 | } | ||
| 733 | } | 776 | } |
| 734 | 777 | ||
| 735 | hwmon->hwmon = hwmon_dev; | 778 | hwmon->hwmon = hwmon_dev; |
| @@ -759,6 +802,7 @@ nouveau_hwmon_fini(struct drm_device *dev) | |||
| 759 | sysfs_remove_group(&hwmon->hwmon->kobj, &hwmon_fan_rpm_attrgroup); | 802 | sysfs_remove_group(&hwmon->hwmon->kobj, &hwmon_fan_rpm_attrgroup); |
| 760 | sysfs_remove_group(&hwmon->hwmon->kobj, &hwmon_in0_attrgroup); | 803 | sysfs_remove_group(&hwmon->hwmon->kobj, &hwmon_in0_attrgroup); |
| 761 | sysfs_remove_group(&hwmon->hwmon->kobj, &hwmon_power_attrgroup); | 804 | sysfs_remove_group(&hwmon->hwmon->kobj, &hwmon_power_attrgroup); |
| 805 | sysfs_remove_group(&hwmon->hwmon->kobj, &hwmon_power_caps_attrgroup); | ||
| 762 | 806 | ||
| 763 | hwmon_device_unregister(hwmon->hwmon); | 807 | hwmon_device_unregister(hwmon->hwmon); |
| 764 | } | 808 | } |
