Re: [Nouveau] [PATCH v4 36/37] WIP volt/gk104: readout speedo

2016-04-20 Thread Martin Peres

On 18/04/16 22:14, Karol Herbst wrote:

this gk104 volt implementation has to be reworked a little, because the speedo
readout in maxwell doesn't need those strange 0 and 41 writes into 0x122634,
but it needs this PWM thing.

Maybe Maxwell is PWM only and we could just simplify it there, but without
proper knowledge there has some refactoring to be made.


This is not true, my GM206 is GPIO-based.



Signed-off-by: Karol Herbst 
---
  drm/nouveau/nvkm/subdev/volt/gk104.c | 19 +++
  1 file changed, 19 insertions(+)

diff --git a/drm/nouveau/nvkm/subdev/volt/gk104.c 
b/drm/nouveau/nvkm/subdev/volt/gk104.c
index b735173..81788c2 100644
--- a/drm/nouveau/nvkm/subdev/volt/gk104.c
+++ b/drm/nouveau/nvkm/subdev/volt/gk104.c
@@ -27,6 +27,7 @@
  #include 
  #include 
  #include 
+#include 
  
  #define gk104_volt(p) container_of((p), struct gk104_volt, base)

  struct gk104_volt {
@@ -64,13 +65,31 @@ 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);


I checked on a mmiotrace, and these writes are not only for this fuse. 
So they should be put in the gk104_fuse_read :)


After this,you can stop calling it a WIP patch and get rid of this 
confusing talk about the PWM voltage management, because I really do not 
get how it is relevant.


With this addressed:

Reviewed-by: Martin Peres 


+   ret = nvkm_fuse_read(fuse, 0x3a8);
+   nvkm_wr32(device, 0x122634, 0x41);
+   return ret;
+}
+
  static const struct nvkm_volt_func
  gk104_volt_pwm = {
.volt_get = gk104_volt_get,
.volt_set = gk104_volt_set,
+   .speedo_read = gk104_volt_speedo_read,
  }, gk104_volt_gpio = {
.vid_get = nvkm_voltgpio_get,
.vid_set = nvkm_voltgpio_set,
+   .speedo_read = gk104_volt_speedo_read,
  };
  
  int


___
Nouveau mailing list
Nouveau@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/nouveau


[Nouveau] [PATCH v4 36/37] WIP volt/gk104: readout speedo

2016-04-18 Thread Karol Herbst
this gk104 volt implementation has to be reworked a little, because the speedo
readout in maxwell doesn't need those strange 0 and 41 writes into 0x122634,
but it needs this PWM thing.

Maybe Maxwell is PWM only and we could just simplify it there, but without
proper knowledge there has some refactoring to be made.

Signed-off-by: Karol Herbst 
---
 drm/nouveau/nvkm/subdev/volt/gk104.c | 19 +++
 1 file changed, 19 insertions(+)

diff --git a/drm/nouveau/nvkm/subdev/volt/gk104.c 
b/drm/nouveau/nvkm/subdev/volt/gk104.c
index b735173..81788c2 100644
--- a/drm/nouveau/nvkm/subdev/volt/gk104.c
+++ b/drm/nouveau/nvkm/subdev/volt/gk104.c
@@ -27,6 +27,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #define gk104_volt(p) container_of((p), struct gk104_volt, base)
 struct gk104_volt {
@@ -64,13 +65,31 @@ 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 = {
.volt_get = gk104_volt_get,
.volt_set = gk104_volt_set,
+   .speedo_read = gk104_volt_speedo_read,
 }, gk104_volt_gpio = {
.vid_get = nvkm_voltgpio_get,
.vid_set = nvkm_voltgpio_set,
+   .speedo_read = gk104_volt_speedo_read,
 };
 
 int
-- 
2.8.1

___
Nouveau mailing list
Nouveau@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/nouveau