]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
drm/nouveau/volt/gf100-: Add speedo
authorKarol Herbst <karolherbst@gmail.com>
Sun, 17 Jul 2016 18:05:45 +0000 (20:05 +0200)
committerBen Skeggs <bskeggs@redhat.com>
Wed, 12 Oct 2016 07:29:27 +0000 (17:29 +1000)
v5: Squashed speedo related commits.

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

index bc8e9c9dcf168218356592896348bf0cf6dda522..08ef9983c6435825d8deeb08573349e3a0e6ebd8 100644 (file)
@@ -25,6 +25,8 @@ struct nvkm_volt {
        u8 max0_id;
        u8 max1_id;
        u8 max2_id;
+
+       int speedo;
 };
 
 int nvkm_volt_map(struct nvkm_volt *volt, u8 id, u8 temperature);
index ec59d58becdcd2d9310b021fe8b4010c93e18b6d..771419ff8338410e405f8c612f9f43172c7ee7ff 100644 (file)
@@ -195,6 +195,14 @@ nvkm_volt_parse_bios(struct nvkm_bios *bios, struct nvkm_volt *volt)
        }
 }
 
+static int
+nvkm_volt_speedo_read(struct nvkm_volt *volt)
+{
+       if (volt->func->speedo_read)
+               return volt->func->speedo_read(volt);
+       return -EINVAL;
+}
+
 static int
 nvkm_volt_init(struct nvkm_subdev *subdev)
 {
@@ -209,6 +217,21 @@ nvkm_volt_init(struct nvkm_subdev *subdev)
        return 0;
 }
 
+static int
+nvkm_volt_oneinit(struct nvkm_subdev *subdev)
+{
+       struct nvkm_volt *volt = nvkm_volt(subdev);
+
+       volt->speedo = nvkm_volt_speedo_read(volt);
+       if (volt->speedo > 0)
+               nvkm_debug(&volt->subdev, "speedo %x\n", volt->speedo);
+
+       if (volt->func->oneinit)
+               return volt->func->oneinit(volt);
+
+       return 0;
+}
+
 static void *
 nvkm_volt_dtor(struct nvkm_subdev *subdev)
 {
@@ -219,6 +242,7 @@ static const struct nvkm_subdev_func
 nvkm_volt = {
        .dtor = nvkm_volt_dtor,
        .init = nvkm_volt_init,
+       .oneinit = nvkm_volt_oneinit,
 };
 
 void
index c21100fda47e1753f7fd521c3970de518932b93f..d9ed6925ca6422c94f802ee109815a4ff5dabf52 100644 (file)
  */
 #include "priv.h"
 
+#include <subdev/fuse.h>
+
+static int
+gf100_volt_speedo_read(struct nvkm_volt *volt)
+{
+       struct nvkm_device *device = volt->subdev.device;
+       struct nvkm_fuse *fuse = device->fuse;
+
+       if (!fuse)
+               return -EINVAL;
+
+       return nvkm_fuse_read(fuse, 0x1cc);
+}
+
+int
+gf100_volt_oneinit(struct nvkm_volt *volt)
+{
+       struct nvkm_subdev *subdev = &volt->subdev;
+       if (volt->speedo <= 0)
+               nvkm_error(subdev, "couldn't find speedo value, volting not "
+                          "possible\n");
+       return 0;
+}
+
 static const struct nvkm_volt_func
 gf100_volt = {
+       .oneinit = gf100_volt_oneinit,
        .vid_get = nvkm_voltgpio_get,
        .vid_set = nvkm_voltgpio_set,
+       .speedo_read = gf100_volt_speedo_read,
 };
 
 int
index 420bd84d84834083cfddcb56203811af94a5d799..b2c5d1166a1394ebda84b739811b62db7d939fd8 100644 (file)
@@ -27,6 +27,7 @@
 #include <subdev/gpio.h>
 #include <subdev/bios.h>
 #include <subdev/bios/volt.h>
+#include <subdev/fuse.h>
 
 #define gk104_volt(p) container_of((p), struct gk104_volt, base)
 struct gk104_volt {
@@ -64,13 +65,33 @@ gk104_volt_set(struct nvkm_volt *base, u32 uv)
        return 0;
 }
 
+static int
+gk104_volt_speedo_read(struct nvkm_volt *volt)
+{
+       struct nvkm_device *device = volt->subdev.device;
+       struct nvkm_fuse *fuse = device->fuse;
+       int ret;
+
+       if (!fuse)
+               return -EINVAL;
+
+       nvkm_wr32(device, 0x122634, 0x0);
+       ret = nvkm_fuse_read(fuse, 0x3a8);
+       nvkm_wr32(device, 0x122634, 0x41);
+       return ret;
+}
+
 static const struct nvkm_volt_func
 gk104_volt_pwm = {
+       .oneinit = gf100_volt_oneinit,
        .volt_get = gk104_volt_get,
        .volt_set = gk104_volt_set,
+       .speedo_read = gk104_volt_speedo_read,
 }, gk104_volt_gpio = {
+       .oneinit = gf100_volt_oneinit,
        .vid_get = nvkm_voltgpio_get,
        .vid_set = nvkm_voltgpio_set,
+       .speedo_read = gk104_volt_speedo_read,
 };
 
 int
index d5140d991161318cf13f6f815d5ab9c76d4ee50e..354bafe4b4e2d7b9bac66060c5990d2cf8b78274 100644 (file)
@@ -9,11 +9,13 @@ int nvkm_volt_new_(const struct nvkm_volt_func *, struct nvkm_device *,
                   int index, struct nvkm_volt **);
 
 struct nvkm_volt_func {
+       int (*oneinit)(struct nvkm_volt *);
        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);
+       int (*speedo_read)(struct nvkm_volt *);
 };
 
 int nvkm_voltgpio_init(struct nvkm_volt *);
@@ -23,4 +25,6 @@ int nvkm_voltgpio_set(struct nvkm_volt *, u8);
 int nvkm_voltpwm_init(struct nvkm_volt *volt);
 int nvkm_voltpwm_get(struct nvkm_volt *volt);
 int nvkm_voltpwm_set(struct nvkm_volt *volt, u32 uv);
+
+int gf100_volt_oneinit(struct nvkm_volt *);
 #endif