[7/9] volt: parse the both max voltage entries

Submitted by Karol Herbst on Feb. 29, 2016, 12:42 p.m.

Details

Message ID 1456749738-5145-8-git-send-email-nouveau@karolherbst.de
State New
Headers show
Series "Groundwork for clocking fixes" ( rev: 1 ) in Nouveau

Not browsing as part of any series.

Commit Message

Karol Herbst Feb. 29, 2016, 12:42 p.m.
these entries specify a maximum voltage nvidia never exceeds, we shouldn't do
that to after finally fixing volting.

Signed-off-by: Karol Herbst <nouveau@karolherbst.de>
---
 drm/nouveau/include/nvkm/subdev/bios/vmap.h |  2 ++
 drm/nouveau/include/nvkm/subdev/volt.h      |  2 ++
 drm/nouveau/nvkm/subdev/bios/vmap.c         |  5 +++++
 drm/nouveau/nvkm/subdev/volt/base.c         | 11 +++++++++++
 4 files changed, 20 insertions(+)

Patch hide | download patch | download mbox

diff --git a/drm/nouveau/include/nvkm/subdev/bios/vmap.h b/drm/nouveau/include/nvkm/subdev/bios/vmap.h
index 3f1e142..c036315 100644
--- a/drm/nouveau/include/nvkm/subdev/bios/vmap.h
+++ b/drm/nouveau/include/nvkm/subdev/bios/vmap.h
@@ -1,6 +1,8 @@ 
 #ifndef __NVBIOS_VMAP_H__
 #define __NVBIOS_VMAP_H__
 struct nvbios_vmap {
+	u8  max0;
+	u8  max1;
 };
 
 u16 nvbios_vmap_table(struct nvkm_bios *, u8 *ver, u8 *hdr, u8 *cnt, u8 *len);
diff --git a/drm/nouveau/include/nvkm/subdev/volt.h b/drm/nouveau/include/nvkm/subdev/volt.h
index fb73b90..fe51809 100644
--- a/drm/nouveau/include/nvkm/subdev/volt.h
+++ b/drm/nouveau/include/nvkm/subdev/volt.h
@@ -15,6 +15,8 @@  struct nvkm_volt {
 
 	u32 max_uv;
 	u32 min_uv;
+	u8 max0_vid;
+	u8 max1_vid;
 };
 
 int nvkm_volt_get(struct nvkm_volt *);
diff --git a/drm/nouveau/nvkm/subdev/bios/vmap.c b/drm/nouveau/nvkm/subdev/bios/vmap.c
index 9db3f0c..159c456 100644
--- a/drm/nouveau/nvkm/subdev/bios/vmap.c
+++ b/drm/nouveau/nvkm/subdev/bios/vmap.c
@@ -61,7 +61,12 @@  nvbios_vmap_parse(struct nvkm_bios *bios, u8 *ver, u8 *hdr, u8 *cnt, u8 *len,
 	memset(info, 0x00, sizeof(*info));
 	switch (!!vmap * *ver) {
 	case 0x10:
+		info->max0 = 0xff;
+		info->max1 = 0xff;
+		break;
 	case 0x20:
+		info->max0 = nvbios_rd08(bios, vmap + 0x7);
+		info->max1 = nvbios_rd08(bios, vmap + 0x8);
 		break;
 	}
 	return vmap;
diff --git a/drm/nouveau/nvkm/subdev/volt/base.c b/drm/nouveau/nvkm/subdev/volt/base.c
index c6089d9..ea513d6 100644
--- a/drm/nouveau/nvkm/subdev/volt/base.c
+++ b/drm/nouveau/nvkm/subdev/volt/base.c
@@ -192,9 +192,20 @@  nvkm_volt_ctor(const struct nvkm_volt_func *func, struct nvkm_device *device,
 
 	/* Assuming the non-bios device should build the voltage table later */
 	if (bios) {
+		u8 ver, hdr, cnt, len;
+		struct nvbios_vmap vmap;
+
 		nvkm_volt_parse_bios(bios, volt);
 		nvkm_debug(&volt->subdev, "min: %iuv max: %iuv\n",
 			   volt->min_uv, volt->max_uv);
+
+		if (nvbios_vmap_parse(bios, &ver, &hdr, &cnt, &len, &vmap)) {
+			volt->max0_vid = vmap.max0;
+			volt->max1_vid = vmap.max1;
+		} else {
+			volt->max0_vid = 0xff;
+			volt->max1_vid = 0xff;
+		}
 	}
 
 	if (volt->vid_nr) {