aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm/nouveau/nouveau_temp.c
diff options
context:
space:
mode:
authorFrancisco Jerez <currojerez@riseup.net>2010-09-23 14:58:38 -0400
committerBen Skeggs <bskeggs@redhat.com>2010-09-24 02:29:29 -0400
commit8155cac489eb8cc6fd96b9bdefacdf5a56e6ea32 (patch)
tree0fb54eb113e8cbac73836b9c48989f0bf42d4f2f /drivers/gpu/drm/nouveau/nouveau_temp.c
parente829d804d78c57b8e90039079284ac585f72851d (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.c50
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 86b170a851be..2f7785ca4e48 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)
154 nouveau_temp_safety_checks(dev); 154 nouveau_temp_safety_checks(dev);
155} 155}
156 156
157static s16 157static int
158nouveau_nv40_sensor_setup(struct drm_device *dev) 158nv40_sensor_setup(struct drm_device *dev)
159{ 159{
160 struct drm_nouveau_private *dev_priv = dev->dev_private; 160 struct drm_nouveau_private *dev_priv = dev->dev_private;
161 struct nouveau_pm_engine *pm = &dev_priv->engine.pm; 161 struct nouveau_pm_engine *pm = &dev_priv->engine.pm;
@@ -182,40 +182,34 @@ nouveau_nv40_sensor_setup(struct drm_device *dev)
182 return nv_rd32(dev, 0x0015b4) & 0x1fff; 182 return nv_rd32(dev, 0x0015b4) & 0x1fff;
183} 183}
184 184
185s16 185int
186nouveau_temp_get(struct drm_device *dev) 186nv40_temp_get(struct drm_device *dev)
187{ 187{
188 struct drm_nouveau_private *dev_priv = dev->dev_private; 188 struct drm_nouveau_private *dev_priv = dev->dev_private;
189 struct nouveau_pm_engine *pm = &dev_priv->engine.pm; 189 struct nouveau_pm_engine *pm = &dev_priv->engine.pm;
190 struct nouveau_pm_temp_sensor_constants *sensor = &pm->sensor_constants; 190 struct nouveau_pm_temp_sensor_constants *sensor = &pm->sensor_constants;
191 int offset = sensor->offset_mult / sensor->offset_div;
192 int core_temp;
191 193
192 if (dev_priv->chipset >= 0x84) { 194 if (dev_priv->chipset >= 0x50) {
193 return nv_rd32(dev, 0x20400); 195 core_temp = nv_rd32(dev, 0x20008);
194 } else if (dev_priv->chipset >= 0x40) {
195 u32 offset = sensor->offset_mult / sensor->offset_div;
196 u32 core_temp;
197
198 if (dev_priv->chipset >= 0x50) {
199 core_temp = nv_rd32(dev, 0x20008);
200 } else {
201 core_temp = nv_rd32(dev, 0x0015b4) & 0x1fff;
202 /* Setup the sensor if the temperature is 0 */
203 if (core_temp == 0)
204 core_temp = nouveau_nv40_sensor_setup(dev);
205 }
206
207 core_temp = core_temp * sensor->slope_mult / sensor->slope_div;
208 core_temp = core_temp + offset + sensor->offset_constant;
209
210 return core_temp;
211 } else { 196 } else {
212 NV_ERROR(dev, 197 core_temp = nv_rd32(dev, 0x0015b4) & 0x1fff;
213 "Temperature cannot be retrieved from an nv%x card\n", 198 /* Setup the sensor if the temperature is 0 */
214 dev_priv->chipset); 199 if (core_temp == 0)
215 return 0; 200 core_temp = nv40_sensor_setup(dev);
216 } 201 }
217 202
218 return 0; 203 core_temp = core_temp * sensor->slope_mult / sensor->slope_div;
204 core_temp = core_temp + offset + sensor->offset_constant;
205
206 return core_temp;
207}
208
209int
210nv84_temp_get(struct drm_device *dev)
211{
212 return nv_rd32(dev, 0x20400);
219} 213}
220 214
221void 215void