diff options
author | Francisco Jerez <currojerez@riseup.net> | 2010-09-23 20:58:38 +0200 |
---|---|---|
committer | Ben Skeggs <bskeggs@redhat.com> | 2010-09-24 16:29:29 +1000 |
commit | 8155cac489eb8cc6fd96b9bdefacdf5a56e6ea32 (patch) | |
tree | 0fb54eb113e8cbac73836b9c48989f0bf42d4f2f /drivers/gpu/drm/nouveau/nouveau_temp.c | |
parent | e829d804d78c57b8e90039079284ac585f72851d (diff) |
drm/nouveau: Refactor nouveau_temp_get() into engine pointers.
Signed-off-by: Francisco Jerez <currojerez@riseup.net>
Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
Diffstat (limited to 'drivers/gpu/drm/nouveau/nouveau_temp.c')
-rw-r--r-- | drivers/gpu/drm/nouveau/nouveau_temp.c | 50 |
1 files changed, 22 insertions, 28 deletions
diff --git a/drivers/gpu/drm/nouveau/nouveau_temp.c b/drivers/gpu/drm/nouveau/nouveau_temp.c index 86b170a851b..2f7785ca4e4 100644 --- a/drivers/gpu/drm/nouveau/nouveau_temp.c +++ b/drivers/gpu/drm/nouveau/nouveau_temp.c @@ -154,8 +154,8 @@ nouveau_temp_vbios_parse(struct drm_device *dev, u8 *temp) nouveau_temp_safety_checks(dev); } -static s16 -nouveau_nv40_sensor_setup(struct drm_device *dev) +static int +nv40_sensor_setup(struct drm_device *dev) { struct drm_nouveau_private *dev_priv = dev->dev_private; struct nouveau_pm_engine *pm = &dev_priv->engine.pm; @@ -182,40 +182,34 @@ nouveau_nv40_sensor_setup(struct drm_device *dev) return nv_rd32(dev, 0x0015b4) & 0x1fff; } -s16 -nouveau_temp_get(struct drm_device *dev) +int +nv40_temp_get(struct drm_device *dev) { struct drm_nouveau_private *dev_priv = dev->dev_private; struct nouveau_pm_engine *pm = &dev_priv->engine.pm; struct nouveau_pm_temp_sensor_constants *sensor = &pm->sensor_constants; + int offset = sensor->offset_mult / sensor->offset_div; + int core_temp; - if (dev_priv->chipset >= 0x84) { - return nv_rd32(dev, 0x20400); - } else if (dev_priv->chipset >= 0x40) { - u32 offset = sensor->offset_mult / sensor->offset_div; - u32 core_temp; - - if (dev_priv->chipset >= 0x50) { - core_temp = nv_rd32(dev, 0x20008); - } else { - core_temp = nv_rd32(dev, 0x0015b4) & 0x1fff; - /* Setup the sensor if the temperature is 0 */ - if (core_temp == 0) - core_temp = nouveau_nv40_sensor_setup(dev); - } - - core_temp = core_temp * sensor->slope_mult / sensor->slope_div; - core_temp = core_temp + offset + sensor->offset_constant; - - return core_temp; + if (dev_priv->chipset >= 0x50) { + core_temp = nv_rd32(dev, 0x20008); } else { - NV_ERROR(dev, - "Temperature cannot be retrieved from an nv%x card\n", - dev_priv->chipset); - return 0; + core_temp = nv_rd32(dev, 0x0015b4) & 0x1fff; + /* Setup the sensor if the temperature is 0 */ + if (core_temp == 0) + core_temp = nv40_sensor_setup(dev); } - return 0; + core_temp = core_temp * sensor->slope_mult / sensor->slope_div; + core_temp = core_temp + offset + sensor->offset_constant; + + return core_temp; +} + +int +nv84_temp_get(struct drm_device *dev) +{ + return nv_rd32(dev, 0x20400); } void |