summaryrefslogtreecommitdiff
path: root/drivers/gpu/drm/nouveau/core/subdev/therm
diff options
context:
space:
mode:
authorBen Skeggs <bskeggs@redhat.com>2012-12-04 12:10:19 +1000
committerBen Skeggs <bskeggs@redhat.com>2013-02-20 16:00:17 +1000
commit9cbcd3374a1db6a2faeb660bb49feb9af25c84ec (patch)
treea7a3d40dc1f398da1914164f051d6c7f2f084637 /drivers/gpu/drm/nouveau/core/subdev/therm
parent7b49bd684cea3916405e1de2f8173ac42cebc87b (diff)
drm/nvd0/therm: add support for hardware fan tachometer
Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
Diffstat (limited to 'drivers/gpu/drm/nouveau/core/subdev/therm')
-rw-r--r--drivers/gpu/drm/nouveau/core/subdev/therm/nva3.c2
-rw-r--r--drivers/gpu/drm/nouveau/core/subdev/therm/nvd0.c25
-rw-r--r--drivers/gpu/drm/nouveau/core/subdev/therm/priv.h2
3 files changed, 27 insertions, 2 deletions
diff --git a/drivers/gpu/drm/nouveau/core/subdev/therm/nva3.c b/drivers/gpu/drm/nouveau/core/subdev/therm/nva3.c
index f4738082f358..9a8daf4b36d5 100644
--- a/drivers/gpu/drm/nouveau/core/subdev/therm/nva3.c
+++ b/drivers/gpu/drm/nouveau/core/subdev/therm/nva3.c
@@ -30,7 +30,7 @@ struct nva3_therm_priv {
struct nouveau_therm_priv base;
};
-static int
+int
nva3_therm_fan_sense(struct nouveau_therm *therm)
{
u32 tach = nv_rd32(therm, 0x00e728) & 0x0000ffff;
diff --git a/drivers/gpu/drm/nouveau/core/subdev/therm/nvd0.c b/drivers/gpu/drm/nouveau/core/subdev/therm/nvd0.c
index b001cd39b5a7..f0336a09cf9e 100644
--- a/drivers/gpu/drm/nouveau/core/subdev/therm/nvd0.c
+++ b/drivers/gpu/drm/nouveau/core/subdev/therm/nvd0.c
@@ -76,6 +76,28 @@ nvd0_fan_pwm_clock(struct nouveau_therm *therm)
}
static int
+nvd0_therm_init(struct nouveau_object *object)
+{
+ struct nvd0_therm_priv *priv = (void *)object;
+ int ret;
+
+ ret = nouveau_therm_init(&priv->base.base);
+ if (ret)
+ return ret;
+
+ /* enable fan tach, count revolutions per-second */
+ nv_mask(priv, 0x00e720, 0x00000003, 0x00000002);
+ if (priv->base.fan.tach.func != DCB_GPIO_UNUSED) {
+ nv_mask(priv, 0x00d79c, 0x000000ff, priv->base.fan.tach.line);
+ nv_wr32(priv, 0x00e724, nv_device(priv)->crystal * 1000);
+ nv_mask(priv, 0x00e720, 0x00000001, 0x00000001);
+ }
+ nv_mask(priv, 0x00e720, 0x00000002, 0x00000000);
+
+ return 0;
+}
+
+static int
nvd0_therm_ctor(struct nouveau_object *parent,
struct nouveau_object *engine,
struct nouveau_oclass *oclass, void *data, u32 size,
@@ -93,6 +115,7 @@ nvd0_therm_ctor(struct nouveau_object *parent,
priv->base.fan.pwm_set = nvd0_fan_pwm_set;
priv->base.fan.pwm_clock = nvd0_fan_pwm_clock;
priv->base.base.temp_get = nv50_temp_get;
+ priv->base.base.fan_sense = nva3_therm_fan_sense;
return 0;
}
@@ -102,7 +125,7 @@ nvd0_therm_oclass = {
.ofuncs = &(struct nouveau_ofuncs) {
.ctor = nvd0_therm_ctor,
.dtor = _nouveau_therm_dtor,
- .init = _nouveau_therm_init,
+ .init = nvd0_therm_init,
.fini = _nouveau_therm_fini,
},
};
diff --git a/drivers/gpu/drm/nouveau/core/subdev/therm/priv.h b/drivers/gpu/drm/nouveau/core/subdev/therm/priv.h
index 33fbc596ee4f..bb940e9d4e8f 100644
--- a/drivers/gpu/drm/nouveau/core/subdev/therm/priv.h
+++ b/drivers/gpu/drm/nouveau/core/subdev/therm/priv.h
@@ -80,4 +80,6 @@ int nv50_fan_pwm_set(struct nouveau_therm *, int, u32, u32);
int nv50_fan_pwm_clock(struct nouveau_therm *);
int nv50_temp_get(struct nouveau_therm *therm);
+int nva3_therm_fan_sense(struct nouveau_therm *);
+
#endif