add min/max voltage to hwmon
cover add min/max voltage to hwmon
The first patch is also part of my reclocking series
Karol Herbst (2):
volt: save the voltage range we are able to set
hwmon: add in_min and in_max
drm/nouveau/include/nvkm/subdev/volt.h | 3 +++ drm/nouveau/nouveau_hwmon.c | 36 ++++++++++++++++++++++++++++++++++ drm/nouveau/nvkm/subdev/volt/base.c | 14 ++++++++++++- 3 files changed, 52 insertions(+), 1 deletion(-)
Signature · 6 lines
2.8.1 _______________________________________________ Nouveau mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/nouveau
A message that is not in the archive (sent off-list or not yet received): 1461172498-5547-1-git-send-email-karolherbst-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
PATCH 1/2 volt: save the voltage range we are able to set
From: Karol Herbst <[email protected]>
We shouldn't set voltages below the min or above the max voltage the gpu is able to set, so save the range.
Signed-off-by Karol Herbst <[email protected]>
Reviewed-by Martin Peres <[email protected]>
Tested-by Pierre Moreau <[email protected]>
Signed-off-by Karol Herbst <[email protected]>
--- drm/nouveau/include/nvkm/subdev/volt.h | 3 +++ drm/nouveau/nvkm/subdev/volt/base.c | 14 +++++++++++++- 2 files changed, 16 insertions(+), 1 deletion(-)
drm/nouveau/include/nvkm/subdev/volt.h +3 -0
@@ -12,6 +12,9 @@ struct nvkm_volt {u32 uv;u8 vid; } vid[256 ]; + +u32 max_uv; +u32 min_uv; };int nvkm_volt_get (struct nvkm_volt *);
drm/nouveau/nvkm/subdev/volt/base.c +13 -1
@@ -120,6 +120,8 @@ nvkm_volt_parse_bios(struct nvkm_bios *bios, struct nvkm_volt *volt) data =nvbios_volt_parse (bios, &ver, &hdr, &cnt, &len, &info);if (data && info.vidmask && info.base && info.step) { + volt->min_uv = info.min; + volt->max_uv = info.max;for (i =0 ; i < info.vidmask +1 ; i++) {if (info.base >= info.min && info.base <= info.max) {
@@ -131,6 +133,8 @@ nvkm_volt_parse_bios(struct nvkm_bios *bios, struct nvkm_volt *volt) } volt->vid_mask = info.vidmask; }else if (data && info.vidmask) { + volt->min_uv =0xffffffff ; + volt->max_uv =0 ;for (i =0 ; i < cnt; i++) { data =nvbios_volt_entry_parse (bios, i, &ver, &hdr, &ivid);
@@ -138,9 +142,14 @@ nvkm_volt_parse_bios(struct nvkm_bios *bios, struct nvkm_volt *volt) volt->vid[volt->vid_nr].uv = ivid.voltage; volt->vid[volt->vid_nr].vid = ivid.vid; volt->vid_nr++; + volt->min_uv =min (volt->min_uv, ivid.voltage); + volt->max_uv =max (volt->max_uv, ivid.voltage); } } volt->vid_mask = info.vidmask; + }else if (data && info.type ==NVBIOS_VOLT_PWM ) { + volt->min_uv = info.base; + volt->max_uv = info.base + info.pwm_range; } }
@@ -181,8 +190,11 @@ nvkm_volt_ctor(const struct nvkm_volt_func *func, struct nvkm_device *device, volt->func = func;/* Assuming the non-bios device should build the voltage table later */ -if (bios) +if (bios) {nvkm_volt_parse_bios (bios, volt); +nvkm_debug (&volt->subdev,"min: %iuv max: %iuv\n" , + volt->min_uv, volt->max_uv); + }if (volt->vid_nr) {for (i =0 ; i < volt->vid_nr; i++) {
Signature · 6 lines
2.8.1 _______________________________________________ Nouveau mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/nouveau
PATCH 2/2 hwmon: add in_min and in_max
In reply to a message not in the archiveFrom: Karol Herbst <[email protected]>
Signed-off-by Karol Herbst <[email protected]>
--- drm/nouveau/nouveau_hwmon.c | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+)
drm/nouveau/nouveau_hwmon.c +36 -0
@@ -535,6 +535,40 @@ static SENSOR_DEVICE_ATTR(in0_input, S_IRUGO, nouveau_hwmon_get_in0_input, NULL, 0);static ssize_t +nouveau_hwmon_get_in0_min (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_volt *volt =nvxx_volt (&drm->device); + +if (!volt || !volt->min_uv) +return -ENODEV ; + +return sprintf (buf,"%i\n" , volt->min_uv /1000 ); +} + +static SENSOR_DEVICE_ATTR(in0_min, S_IRUGO, + nouveau_hwmon_get_in0_min, NULL, 0); + +static ssize_t +nouveau_hwmon_get_in0_max (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_volt *volt =nvxx_volt (&drm->device); + +if (!volt || !volt->max_uv) +return -ENODEV ; + +return sprintf (buf,"%i\n" , volt->max_uv /1000 ); +} + +static SENSOR_DEVICE_ATTR(in0_max, S_IRUGO, + nouveau_hwmon_get_in0_max, NULL, 0); + +static ssize_t nouveau_hwmon_get_in0_label (struct device *d,struct device_attribute *a,char *buf) {
@@ -594,6 +628,8 @@ static struct attribute *hwmon_pwm_fan_attributes[] = {static struct attribute *hwmon_in0_attributes[] = { &sensor_dev_attr_in0_input.dev_attr.attr, + &sensor_dev_attr_in0_min.dev_attr.attr, + &sensor_dev_attr_in0_max.dev_attr.attr, &sensor_dev_attr_in0_label.dev_attr.attr,NULL };
Signature · 6 lines
2.8.1 _______________________________________________ Nouveau mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/nouveau