diff options
author | Ben Skeggs <bskeggs@redhat.com> | 2011-07-27 20:52:13 -0400 |
---|---|---|
committer | Ben Skeggs <bskeggs@redhat.com> | 2011-12-21 04:01:10 -0500 |
commit | 04de6a046188d86ff60b1ede974dbf580287fc98 (patch) | |
tree | d6ed41b5f6f00580ca446bdc07f6f392028a0179 /drivers/gpu/drm | |
parent | 9232969e19ae7251a93ab72e405cf71e5109ec05 (diff) |
drm/nv41/pm: implement a second type of fanspeed pwm
Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
Diffstat (limited to 'drivers/gpu/drm')
-rw-r--r-- | drivers/gpu/drm/nouveau/nouveau_pm.h | 2 | ||||
-rw-r--r-- | drivers/gpu/drm/nouveau/nouveau_state.c | 7 | ||||
-rw-r--r-- | drivers/gpu/drm/nouveau/nv40_pm.c | 27 |
3 files changed, 36 insertions, 0 deletions
diff --git a/drivers/gpu/drm/nouveau/nouveau_pm.h b/drivers/gpu/drm/nouveau/nouveau_pm.h index bbab7013aed1..f19b0507fdfd 100644 --- a/drivers/gpu/drm/nouveau/nouveau_pm.h +++ b/drivers/gpu/drm/nouveau/nouveau_pm.h | |||
@@ -58,6 +58,8 @@ void *nv40_pm_clocks_pre(struct drm_device *, struct nouveau_pm_level *); | |||
58 | void nv40_pm_clocks_set(struct drm_device *, void *); | 58 | void nv40_pm_clocks_set(struct drm_device *, void *); |
59 | int nv40_pm_fanspeed_get(struct drm_device *); | 59 | int nv40_pm_fanspeed_get(struct drm_device *); |
60 | int nv40_pm_fanspeed_set(struct drm_device *, int percent); | 60 | int nv40_pm_fanspeed_set(struct drm_device *, int percent); |
61 | int nv41_pm_fanspeed_get(struct drm_device *); | ||
62 | int nv41_pm_fanspeed_set(struct drm_device *, int percent); | ||
61 | 63 | ||
62 | /* nv50_pm.c */ | 64 | /* nv50_pm.c */ |
63 | int nv50_pm_clock_get(struct drm_device *, u32 id); | 65 | int nv50_pm_clock_get(struct drm_device *, u32 id); |
diff --git a/drivers/gpu/drm/nouveau/nouveau_state.c b/drivers/gpu/drm/nouveau/nouveau_state.c index 06664e779792..0806d017d86b 100644 --- a/drivers/gpu/drm/nouveau/nouveau_state.c +++ b/drivers/gpu/drm/nouveau/nouveau_state.c | |||
@@ -298,6 +298,13 @@ static int nouveau_init_engine_ptrs(struct drm_device *dev) | |||
298 | engine->pm.fanspeed_get = nv40_pm_fanspeed_get; | 298 | engine->pm.fanspeed_get = nv40_pm_fanspeed_get; |
299 | engine->pm.fanspeed_set = nv40_pm_fanspeed_set; | 299 | engine->pm.fanspeed_set = nv40_pm_fanspeed_set; |
300 | break; | 300 | break; |
301 | case 0x42: | ||
302 | case 0x43: | ||
303 | case 0x47: | ||
304 | case 0x4b: | ||
305 | engine->pm.fanspeed_get = nv41_pm_fanspeed_get; | ||
306 | engine->pm.fanspeed_set = nv41_pm_fanspeed_set; | ||
307 | break; | ||
301 | default: | 308 | default: |
302 | break; | 309 | break; |
303 | } | 310 | } |
diff --git a/drivers/gpu/drm/nouveau/nv40_pm.c b/drivers/gpu/drm/nouveau/nv40_pm.c index c969bcbab547..e7660b175de6 100644 --- a/drivers/gpu/drm/nouveau/nv40_pm.c +++ b/drivers/gpu/drm/nouveau/nv40_pm.c | |||
@@ -372,3 +372,30 @@ nv40_pm_fanspeed_set(struct drm_device *dev, int percent) | |||
372 | nv_wr32(dev, 0x0010f0, 0x80000000 | (duty << 16) | divs); | 372 | nv_wr32(dev, 0x0010f0, 0x80000000 | (duty << 16) | divs); |
373 | return 0; | 373 | return 0; |
374 | } | 374 | } |
375 | |||
376 | int | ||
377 | nv41_pm_fanspeed_get(struct drm_device *dev) | ||
378 | { | ||
379 | u32 reg = nv_rd32(dev, 0x0015f4); | ||
380 | if (reg & 0x80000000) { | ||
381 | u32 divs = nv_rd32(dev, 0x0015f8); | ||
382 | u32 duty = (reg & 0x7fffffff); | ||
383 | if (divs && divs >= duty) | ||
384 | return ((divs - duty) * 100) / divs; | ||
385 | } | ||
386 | |||
387 | return 100; | ||
388 | } | ||
389 | |||
390 | int | ||
391 | nv41_pm_fanspeed_set(struct drm_device *dev, int percent) | ||
392 | { | ||
393 | struct drm_nouveau_private *dev_priv = dev->dev_private; | ||
394 | struct nouveau_pm_engine *pm = &dev_priv->engine.pm; | ||
395 | u32 divs = pm->pwm_divisor; | ||
396 | u32 duty = ((100 - percent) * divs) / 100; | ||
397 | |||
398 | nv_wr32(dev, 0x0015f8, divs); | ||
399 | nv_wr32(dev, 0x0015f4, duty | 0x80000000); | ||
400 | return 0; | ||
401 | } | ||