Commit 4c58a05b authored by Martin Peres's avatar Martin Peres Committed by Ben Skeggs

drm/nouveau/volt: add support for non-vid-based voltage controllers

This patch is not ideal but it definitely beats a rewrite of the current
interface and is very self-contained.
Signed-off-by: default avatarMartin Peres <martin.peres@free.fr>
Signed-off-by: default avatarBen Skeggs <bskeggs@redhat.com>
parent 7bddeba9
...@@ -30,7 +30,12 @@ ...@@ -30,7 +30,12 @@
int int
nvkm_volt_get(struct nvkm_volt *volt) nvkm_volt_get(struct nvkm_volt *volt)
{ {
int ret = volt->func->vid_get(volt), i; int ret, i;
if (volt->func->volt_get)
return volt->func->volt_get(volt);
ret = volt->func->vid_get(volt);
if (ret >= 0) { if (ret >= 0) {
for (i = 0; i < volt->vid_nr; i++) { for (i = 0; i < volt->vid_nr; i++) {
if (volt->vid[i].vid == ret) if (volt->vid[i].vid == ret)
...@@ -46,6 +51,10 @@ nvkm_volt_set(struct nvkm_volt *volt, u32 uv) ...@@ -46,6 +51,10 @@ nvkm_volt_set(struct nvkm_volt *volt, u32 uv)
{ {
struct nvkm_subdev *subdev = &volt->subdev; struct nvkm_subdev *subdev = &volt->subdev;
int i, ret = -EINVAL; int i, ret = -EINVAL;
if (volt->func->volt_set)
return volt->func->volt_set(volt, uv);
for (i = 0; i < volt->vid_nr; i++) { for (i = 0; i < volt->vid_nr; i++) {
if (volt->vid[i].uv == uv) { if (volt->vid[i].uv == uv) {
ret = volt->func->vid_set(volt, volt->vid[i].vid); ret = volt->func->vid_set(volt, volt->vid[i].vid);
......
...@@ -9,6 +9,8 @@ int nvkm_volt_new_(const struct nvkm_volt_func *, struct nvkm_device *, ...@@ -9,6 +9,8 @@ int nvkm_volt_new_(const struct nvkm_volt_func *, struct nvkm_device *,
int index, struct nvkm_volt **); int index, struct nvkm_volt **);
struct nvkm_volt_func { struct nvkm_volt_func {
int (*volt_get)(struct nvkm_volt *);
int (*volt_set)(struct nvkm_volt *, u32 uv);
int (*vid_get)(struct nvkm_volt *); int (*vid_get)(struct nvkm_volt *);
int (*vid_set)(struct nvkm_volt *, u8 vid); int (*vid_set)(struct nvkm_volt *, u8 vid);
int (*set_id)(struct nvkm_volt *, u8 id, int condition); int (*set_id)(struct nvkm_volt *, u8 id, int condition);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment