summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVince Hsu <vinceh@nvidia.com>2015-04-23 17:26:12 +0800
committerAlexandre Courbot <acourbot@nvidia.com>2015-08-06 13:26:23 +0900
commite51edc140393b42a967c999f2255f24af36ef020 (patch)
treec90e38be1c25daf9beeb0f628508dbf8f40b71ec
parente562731d6750eadbb5d5a8b64fe3b646b7728d0f (diff)
downloadnouveau-e51edc140393b42a967c999f2255f24af36ef020.tar.gz
drm/nouveau/volt: add function get_voltage_by_id()
We need the exact voltage value to calculate the PLL coefficients for GM20B. Signed-off-by: Vince Hsu <vinceh@nvidia.com>
-rw-r--r--drm/nouveau/include/nvkm/subdev/volt.h1
-rw-r--r--drm/nouveau/nvkm/subdev/volt/base.c10
2 files changed, 11 insertions, 0 deletions
diff --git a/drm/nouveau/include/nvkm/subdev/volt.h b/drm/nouveau/include/nvkm/subdev/volt.h
index e3d7243fb..ed9fb9704 100644
--- a/drm/nouveau/include/nvkm/subdev/volt.h
+++ b/drm/nouveau/include/nvkm/subdev/volt.h
@@ -15,6 +15,7 @@ struct nvkm_volt {
int (*vid_set)(struct nvkm_volt *, u8 vid);
int (*set)(struct nvkm_volt *, u32 uv);
int (*set_id)(struct nvkm_volt *, u8 id, int condition);
+ int (*get_voltage_by_id)(struct nvkm_volt *, u8 vid);
u8 vid_mask;
u8 vid_nr;
diff --git a/drm/nouveau/nvkm/subdev/volt/base.c b/drm/nouveau/nvkm/subdev/volt/base.c
index 39f15803f..69f0e3ce2 100644
--- a/drm/nouveau/nvkm/subdev/volt/base.c
+++ b/drm/nouveau/nvkm/subdev/volt/base.c
@@ -44,6 +44,15 @@ nvkm_volt_get(struct nvkm_volt *volt)
}
static int
+nvkm_volt_get_voltage_by_id(struct nvkm_volt *volt, u8 id)
+{
+ if (id >= volt->vid_nr)
+ return -EINVAL;
+
+ return volt->vid[id].uv;
+}
+
+static int
nvkm_volt_set(struct nvkm_volt *volt, u32 uv)
{
if (volt->vid_set) {
@@ -179,6 +188,7 @@ nvkm_volt_create_(struct nvkm_object *parent, struct nvkm_object *engine,
volt->get = nvkm_volt_get;
volt->set = nvkm_volt_set;
volt->set_id = nvkm_volt_set_id;
+ volt->get_voltage_by_id = nvkm_volt_get_voltage_by_id;
/* Assuming the non-bios device should build the voltage table later */
if (bios)