|
@@ -34,6 +34,7 @@
|
|
#include "nouveau_drm.h"
|
|
#include "nouveau_drm.h"
|
|
#include "nouveau_hwmon.h"
|
|
#include "nouveau_hwmon.h"
|
|
|
|
|
|
|
|
+#include <nvkm/subdev/iccsense.h>
|
|
#include <nvkm/subdev/volt.h>
|
|
#include <nvkm/subdev/volt.h>
|
|
|
|
|
|
#if defined(CONFIG_HWMON) || (defined(MODULE) && defined(CONFIG_HWMON_MODULE))
|
|
#if defined(CONFIG_HWMON) || (defined(MODULE) && defined(CONFIG_HWMON_MODULE))
|
|
@@ -543,6 +544,24 @@ nouveau_hwmon_get_in0_label(struct device *d,
|
|
static SENSOR_DEVICE_ATTR(in0_label, S_IRUGO,
|
|
static SENSOR_DEVICE_ATTR(in0_label, S_IRUGO,
|
|
nouveau_hwmon_get_in0_label, NULL, 0);
|
|
nouveau_hwmon_get_in0_label, NULL, 0);
|
|
|
|
|
|
|
|
+static ssize_t
|
|
|
|
+nouveau_hwmon_get_power1_input(struct device *d, struct device_attribute *a,
|
|
|
|
+ char *buf)
|
|
|
|
+{
|
|
|
|
+ struct drm_device *dev = dev_get_drvdata(d);
|
|
|
|
+ struct nouveau_drm *drm = nouveau_drm(dev);
|
|
|
|
+ struct nvkm_iccsense *iccsense = nvxx_iccsense(&drm->device);
|
|
|
|
+ int result = nvkm_iccsense_read_all(iccsense);
|
|
|
|
+
|
|
|
|
+ if (result < 0)
|
|
|
|
+ return result;
|
|
|
|
+
|
|
|
|
+ return sprintf(buf, "%i\n", result);
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+static SENSOR_DEVICE_ATTR(power1_input, S_IRUGO,
|
|
|
|
+ nouveau_hwmon_get_power1_input, NULL, 0);
|
|
|
|
+
|
|
static struct attribute *hwmon_default_attributes[] = {
|
|
static struct attribute *hwmon_default_attributes[] = {
|
|
&sensor_dev_attr_name.dev_attr.attr,
|
|
&sensor_dev_attr_name.dev_attr.attr,
|
|
&sensor_dev_attr_update_rate.dev_attr.attr,
|
|
&sensor_dev_attr_update_rate.dev_attr.attr,
|
|
@@ -579,6 +598,11 @@ static struct attribute *hwmon_in0_attributes[] = {
|
|
NULL
|
|
NULL
|
|
};
|
|
};
|
|
|
|
|
|
|
|
+static struct attribute *hwmon_power_attributes[] = {
|
|
|
|
+ &sensor_dev_attr_power1_input.dev_attr.attr,
|
|
|
|
+ NULL
|
|
|
|
+};
|
|
|
|
+
|
|
static const struct attribute_group hwmon_default_attrgroup = {
|
|
static const struct attribute_group hwmon_default_attrgroup = {
|
|
.attrs = hwmon_default_attributes,
|
|
.attrs = hwmon_default_attributes,
|
|
};
|
|
};
|
|
@@ -594,6 +618,9 @@ static const struct attribute_group hwmon_pwm_fan_attrgroup = {
|
|
static const struct attribute_group hwmon_in0_attrgroup = {
|
|
static const struct attribute_group hwmon_in0_attrgroup = {
|
|
.attrs = hwmon_in0_attributes,
|
|
.attrs = hwmon_in0_attributes,
|
|
};
|
|
};
|
|
|
|
+static const struct attribute_group hwmon_power_attrgroup = {
|
|
|
|
+ .attrs = hwmon_power_attributes,
|
|
|
|
+};
|
|
#endif
|
|
#endif
|
|
|
|
|
|
int
|
|
int
|
|
@@ -603,6 +630,7 @@ nouveau_hwmon_init(struct drm_device *dev)
|
|
struct nouveau_drm *drm = nouveau_drm(dev);
|
|
struct nouveau_drm *drm = nouveau_drm(dev);
|
|
struct nvkm_therm *therm = nvxx_therm(&drm->device);
|
|
struct nvkm_therm *therm = nvxx_therm(&drm->device);
|
|
struct nvkm_volt *volt = nvxx_volt(&drm->device);
|
|
struct nvkm_volt *volt = nvxx_volt(&drm->device);
|
|
|
|
+ struct nvkm_iccsense *iccsense = nvxx_iccsense(&drm->device);
|
|
struct nouveau_hwmon *hwmon;
|
|
struct nouveau_hwmon *hwmon;
|
|
struct device *hwmon_dev;
|
|
struct device *hwmon_dev;
|
|
int ret = 0;
|
|
int ret = 0;
|
|
@@ -662,6 +690,13 @@ nouveau_hwmon_init(struct drm_device *dev)
|
|
goto error;
|
|
goto error;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ if (iccsense && iccsense->data_valid && iccsense->rail_count) {
|
|
|
|
+ ret = sysfs_create_group(&hwmon_dev->kobj,
|
|
|
|
+ &hwmon_power_attrgroup);
|
|
|
|
+ if (ret)
|
|
|
|
+ goto error;
|
|
|
|
+ }
|
|
|
|
+
|
|
hwmon->hwmon = hwmon_dev;
|
|
hwmon->hwmon = hwmon_dev;
|
|
|
|
|
|
return 0;
|
|
return 0;
|
|
@@ -688,6 +723,7 @@ nouveau_hwmon_fini(struct drm_device *dev)
|
|
sysfs_remove_group(&hwmon->hwmon->kobj, &hwmon_pwm_fan_attrgroup);
|
|
sysfs_remove_group(&hwmon->hwmon->kobj, &hwmon_pwm_fan_attrgroup);
|
|
sysfs_remove_group(&hwmon->hwmon->kobj, &hwmon_fan_rpm_attrgroup);
|
|
sysfs_remove_group(&hwmon->hwmon->kobj, &hwmon_fan_rpm_attrgroup);
|
|
sysfs_remove_group(&hwmon->hwmon->kobj, &hwmon_in0_attrgroup);
|
|
sysfs_remove_group(&hwmon->hwmon->kobj, &hwmon_in0_attrgroup);
|
|
|
|
+ sysfs_remove_group(&hwmon->hwmon->kobj, &hwmon_power_attrgroup);
|
|
|
|
|
|
hwmon_device_unregister(hwmon->hwmon);
|
|
hwmon_device_unregister(hwmon->hwmon);
|
|
}
|
|
}
|