42 static char *nouveau_perflvl;
46 static int nouveau_perflvl_wr;
65 if (ret && ret != -
ENODEV) {
66 NV_ERROR(drm,
"fanspeed set failed: %d\n", ret);
74 NV_ERROR(drm,
"voltage set failed: %d\n", ret);
90 if (perflvl == pm->
cur)
93 ret = nouveau_pm_perflvl_aux(dev, perflvl, pm->
cur, perflvl);
106 ret = nouveau_pm_perflvl_aux(dev, perflvl, perflvl, pm->
cur);
115 nouveau_pm_perflvl_aux(dev, perflvl, perflvl, pm->
cur);
142 perflvl = profile->
func->select(profile);
145 if (perflvl != pm->
cur) {
146 u64 time0 = ptimer->
read(ptimer);
148 NV_INFO(drm,
"setting performance level: %d", perflvl->
id);
149 ret = nouveau_pm_perflvl_set(dev, perflvl);
151 NV_INFO(drm,
"> reclocking failed: %d\n\n", ret);
153 NV_INFO(drm,
"> reclocking took %lluns\n\n",
154 ptimer->
read(ptimer) - time0);
159 profile_find(
struct drm_device *dev,
const char *
string)
173 nouveau_pm_profile_set(
struct drm_device *dev,
const char *profile)
180 if (nouveau_perflvl_wr != 7777)
183 strncpy(
string, profile,
sizeof(
string));
184 string[
sizeof(
string) - 1] = 0;
185 if ((ptr =
strchr(
string,
'\n')))
190 ac = profile_find(dev, ptr);
194 dc = profile_find(dev, ptr);
219 .destroy = nouveau_pm_static_dummy,
220 .init = nouveau_pm_static_dummy,
221 .fini = nouveau_pm_static_dummy,
222 .select = nouveau_pm_static_select,
233 memset(perflvl, 0,
sizeof(*perflvl));
260 nouveau_pm_perflvl_info(
struct nouveau_pm_level *perflvl,
char *ptr,
int len)
262 char c[16],
s[16],
v[32],
f[16],
m[16];
266 snprintf(c,
sizeof(c),
" core %dMHz", perflvl->
core / 1000);
278 snprintf(v,
sizeof(v),
" voltage %dmV-%dmV",
282 snprintf(v,
sizeof(v),
" voltage %dmV",
290 snprintf(ptr, len,
"%s%s%s%s%s\n", c, s, m, v, f);
294 nouveau_pm_get_perflvl_info(
struct device *
d,
306 nouveau_pm_perflvl_info(perflvl, ptr, len);
319 snprintf(ptr, len,
"profile: %s, %s\nc:",
324 ret = nouveau_pm_perflvl_get(dev, &cur);
326 nouveau_pm_perflvl_info(&cur, ptr, len);
332 const char *buf,
size_t count)
337 ret = nouveau_pm_profile_set(dev, buf);
344 nouveau_pm_get_perflvl, nouveau_pm_set_perflvl);
351 struct device *d = &dev->pdev->dev;
363 perflvl->
dev_attr.show = nouveau_pm_get_perflvl_info;
369 NV_ERROR(drm,
"failed pervlvl %d sysfs: %d\n",
384 struct device *d = &dev->pdev->dev;
398 #if defined(CONFIG_HWMON) || (defined(MODULE) && defined(CONFIG_HWMON_MODULE))
423 const char *buf,
size_t count)
430 if (kstrtol(buf, 10, &value) == -
EINVAL)
438 nouveau_hwmon_set_max_temp,
462 if (kstrtol(buf, 10, &value) == -
EINVAL)
470 nouveau_hwmon_critical_temp,
471 nouveau_hwmon_set_critical_temp,
478 return sprintf(buf,
"nouveau\n");
482 static ssize_t nouveau_hwmon_show_update_rate(
struct device *dev,
489 nouveau_hwmon_show_update_rate,
506 nouveau_hwmon_get_pwm1_enable(
struct device *d,
518 return sprintf(buf,
"%i\n", ret);
523 const char *buf,
size_t count)
541 nouveau_hwmon_get_pwm1_enable,
542 nouveau_hwmon_set_pwm1_enable, 0);
556 return sprintf(buf,
"%i\n", ret);
561 const char *buf,
size_t count)
569 if (nouveau_perflvl_wr != 7777)
572 if (kstrtol(buf, 10, &value) == -
EINVAL)
575 ret = therm->
fan_set(therm, value);
583 nouveau_hwmon_get_pwm1,
584 nouveau_hwmon_set_pwm1, 0);
587 nouveau_hwmon_get_pwm1_min(
struct device *d,
599 return sprintf(buf,
"%i\n", ret);
604 const char *buf,
size_t count)
612 if (kstrtol(buf, 10, &value) == -
EINVAL)
623 nouveau_hwmon_get_pwm1_min,
624 nouveau_hwmon_set_pwm1_min, 0);
627 nouveau_hwmon_get_pwm1_max(
struct device *d,
639 return sprintf(buf,
"%i\n", ret);
644 const char *buf,
size_t count)
652 if (kstrtol(buf, 10, &value) == -
EINVAL)
663 nouveau_hwmon_get_pwm1_max,
664 nouveau_hwmon_set_pwm1_max, 0);
666 static struct attribute *hwmon_attributes[] = {
667 &sensor_dev_attr_temp1_input.dev_attr.attr,
668 &sensor_dev_attr_temp1_max.dev_attr.attr,
669 &sensor_dev_attr_temp1_crit.dev_attr.attr,
670 &sensor_dev_attr_name.dev_attr.attr,
671 &sensor_dev_attr_update_rate.dev_attr.attr,
674 static struct attribute *hwmon_fan_rpm_attributes[] = {
675 &sensor_dev_attr_fan0_input.dev_attr.attr,
678 static struct attribute *hwmon_pwm_fan_attributes[] = {
679 &sensor_dev_attr_pwm1_enable.dev_attr.attr,
680 &sensor_dev_attr_pwm1.dev_attr.attr,
681 &sensor_dev_attr_pwm1_min.dev_attr.attr,
682 &sensor_dev_attr_pwm1_max.dev_attr.attr,
687 .
attrs = hwmon_attributes,
690 .
attrs = hwmon_fan_rpm_attributes,
693 .
attrs = hwmon_pwm_fan_attributes,
704 #if defined(CONFIG_HWMON) || (defined(MODULE) && defined(CONFIG_HWMON_MODULE))
712 if (IS_ERR(hwmon_dev)) {
713 ret = PTR_ERR(hwmon_dev);
714 NV_ERROR(drm,
"Unable to register hwmon device: %d\n", ret);
732 &hwmon_pwm_fan_attrgroup);
740 &hwmon_fan_rpm_attrgroup);
745 pm->
hwmon = hwmon_dev;
750 NV_ERROR(drm,
"Unable to create some hwmon sysfs files: %d\n", ret);
763 #if defined(CONFIG_HWMON) || (defined(MODULE) && defined(CONFIG_HWMON_MODULE))
769 &hwmon_pwm_fan_attrgroup);
771 &hwmon_fan_rpm_attrgroup);
778 #if defined(CONFIG_ACPI) && defined(CONFIG_POWER_SUPPLY)
784 struct acpi_bus_event *
entry = (
struct acpi_bus_event *)data;
786 if (
strcmp(entry->device_class,
"ac_adapter") == 0) {
789 NV_DEBUG(drm,
"power supply changed: %s\n", ac ?
"AC" :
"DC");
858 ret = nouveau_pm_perflvl_get(dev, &pm->
boot);
860 NV_ERROR(drm,
"failed to determine boot perflvl\n");
881 nouveau_pm_perflvl_info(&pm->
perflvl[i], info,
sizeof(info));
885 nouveau_pm_perflvl_info(&pm->
boot, info,
sizeof(info));
889 if (nouveau_perflvl !=
NULL)
890 nouveau_pm_profile_set(dev, nouveau_perflvl);
892 nouveau_sysfs_init(dev);
893 nouveau_hwmon_init(dev);
894 #if defined(CONFIG_ACPI) && defined(CONFIG_POWER_SUPPLY)
895 pm->
acpi_nb.notifier_call = nouveau_pm_acpi_event;
910 profile->
func->destroy(profile);
914 nouveau_pm_perflvl_set(dev, &pm->
boot);
919 #if defined(CONFIG_ACPI) && defined(CONFIG_POWER_SUPPLY)
922 nouveau_hwmon_fini(dev);
923 nouveau_sysfs_fini(dev);
940 nouveau_pm_perflvl_set(dev, perflvl);