drm/nouveau/volt: add support for non-vid-based voltage controllers
authorMartin Peres <martin.peres@free.fr>
Wed, 9 Sep 2015 01:05:51 +0000 (04:05 +0300)
committerBen Skeggs <bskeggs@redhat.com>
Tue, 3 Nov 2015 05:02:18 +0000 (15:02 +1000)
This patch is not ideal but it definitely beats a rewrite of the current
interface and is very self-contained.

Signed-off-by: Martin Peres <martin.peres@free.fr>
Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
drivers/gpu/drm/nouveau/nvkm/subdev/volt/base.c
drivers/gpu/drm/nouveau/nvkm/subdev/volt/priv.h

index 4752dbd339230302bce484526ade6bd8c876fafc..50b5649ad1a47ee43b7c39778946a9ffdc40d872 100644 (file)
 int
 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) {
                for (i = 0; i < volt->vid_nr; i++) {
                        if (volt->vid[i].vid == ret)
@@ -46,6 +51,10 @@ nvkm_volt_set(struct nvkm_volt *volt, u32 uv)
 {
        struct nvkm_subdev *subdev = &volt->subdev;
        int i, ret = -EINVAL;
+
+       if (volt->func->volt_set)
+               return volt->func->volt_set(volt, uv);
+
        for (i = 0; i < volt->vid_nr; i++) {
                if (volt->vid[i].uv == uv) {
                        ret = volt->func->vid_set(volt, volt->vid[i].vid);
index 394f37c723afa5fdacf11c91137b2babf38251e8..cdb3d9f80aa60ae308ff37c5b008c9cf96d87b60 100644 (file)
@@ -9,6 +9,8 @@ int nvkm_volt_new_(const struct nvkm_volt_func *, struct nvkm_device *,
                   int index, struct nvkm_volt **);
 
 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_set)(struct nvkm_volt *, u8 vid);
        int (*set_id)(struct nvkm_volt *, u8 id, int condition);