diff options
author | Eugeni Dodonov <eugeni.dodonov@intel.com> | 2012-04-18 14:29:24 -0400 |
---|---|---|
committer | Daniel Vetter <daniel.vetter@ffwll.ch> | 2012-04-18 16:00:21 -0400 |
commit | dde18883def89af28bd0c01aff3c7962b82dda18 (patch) | |
tree | 755727cff65b8e15df159563f6f6ec0acdccb6b6 /drivers/gpu/drm/i915/intel_pm.c | |
parent | 2b4e57bd7a6a855dd1229f8cfbbdebfbc3f933be (diff) |
drm/i915: move emon functionality into intel_pm module
This moves the Ironlake energy monitoring functionality into intel_pm
module.
Acked-by: Jesse Barnes <jbarnes@virtuousgeek.org>
Acked-by: Ben Widawsky <benjamin.widawsky@intel.com>
Signed-off-by: Eugeni Dodonov <eugeni.dodonov@intel.com>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Diffstat (limited to 'drivers/gpu/drm/i915/intel_pm.c')
-rw-r--r-- | drivers/gpu/drm/i915/intel_pm.c | 86 |
1 files changed, 86 insertions, 0 deletions
diff --git a/drivers/gpu/drm/i915/intel_pm.c b/drivers/gpu/drm/i915/intel_pm.c index 2f45de3339bf..832130e57731 100644 --- a/drivers/gpu/drm/i915/intel_pm.c +++ b/drivers/gpu/drm/i915/intel_pm.c | |||
@@ -2492,3 +2492,89 @@ void ironlake_enable_rc6(struct drm_device *dev) | |||
2492 | mutex_unlock(&dev->struct_mutex); | 2492 | mutex_unlock(&dev->struct_mutex); |
2493 | } | 2493 | } |
2494 | 2494 | ||
2495 | static unsigned long intel_pxfreq(u32 vidfreq) | ||
2496 | { | ||
2497 | unsigned long freq; | ||
2498 | int div = (vidfreq & 0x3f0000) >> 16; | ||
2499 | int post = (vidfreq & 0x3000) >> 12; | ||
2500 | int pre = (vidfreq & 0x7); | ||
2501 | |||
2502 | if (!pre) | ||
2503 | return 0; | ||
2504 | |||
2505 | freq = ((div * 133333) / ((1<<post) * pre)); | ||
2506 | |||
2507 | return freq; | ||
2508 | } | ||
2509 | |||
2510 | void intel_init_emon(struct drm_device *dev) | ||
2511 | { | ||
2512 | struct drm_i915_private *dev_priv = dev->dev_private; | ||
2513 | u32 lcfuse; | ||
2514 | u8 pxw[16]; | ||
2515 | int i; | ||
2516 | |||
2517 | /* Disable to program */ | ||
2518 | I915_WRITE(ECR, 0); | ||
2519 | POSTING_READ(ECR); | ||
2520 | |||
2521 | /* Program energy weights for various events */ | ||
2522 | I915_WRITE(SDEW, 0x15040d00); | ||
2523 | I915_WRITE(CSIEW0, 0x007f0000); | ||
2524 | I915_WRITE(CSIEW1, 0x1e220004); | ||
2525 | I915_WRITE(CSIEW2, 0x04000004); | ||
2526 | |||
2527 | for (i = 0; i < 5; i++) | ||
2528 | I915_WRITE(PEW + (i * 4), 0); | ||
2529 | for (i = 0; i < 3; i++) | ||
2530 | I915_WRITE(DEW + (i * 4), 0); | ||
2531 | |||
2532 | /* Program P-state weights to account for frequency power adjustment */ | ||
2533 | for (i = 0; i < 16; i++) { | ||
2534 | u32 pxvidfreq = I915_READ(PXVFREQ_BASE + (i * 4)); | ||
2535 | unsigned long freq = intel_pxfreq(pxvidfreq); | ||
2536 | unsigned long vid = (pxvidfreq & PXVFREQ_PX_MASK) >> | ||
2537 | PXVFREQ_PX_SHIFT; | ||
2538 | unsigned long val; | ||
2539 | |||
2540 | val = vid * vid; | ||
2541 | val *= (freq / 1000); | ||
2542 | val *= 255; | ||
2543 | val /= (127*127*900); | ||
2544 | if (val > 0xff) | ||
2545 | DRM_ERROR("bad pxval: %ld\n", val); | ||
2546 | pxw[i] = val; | ||
2547 | } | ||
2548 | /* Render standby states get 0 weight */ | ||
2549 | pxw[14] = 0; | ||
2550 | pxw[15] = 0; | ||
2551 | |||
2552 | for (i = 0; i < 4; i++) { | ||
2553 | u32 val = (pxw[i*4] << 24) | (pxw[(i*4)+1] << 16) | | ||
2554 | (pxw[(i*4)+2] << 8) | (pxw[(i*4)+3]); | ||
2555 | I915_WRITE(PXW + (i * 4), val); | ||
2556 | } | ||
2557 | |||
2558 | /* Adjust magic regs to magic values (more experimental results) */ | ||
2559 | I915_WRITE(OGW0, 0); | ||
2560 | I915_WRITE(OGW1, 0); | ||
2561 | I915_WRITE(EG0, 0x00007f00); | ||
2562 | I915_WRITE(EG1, 0x0000000e); | ||
2563 | I915_WRITE(EG2, 0x000e0000); | ||
2564 | I915_WRITE(EG3, 0x68000300); | ||
2565 | I915_WRITE(EG4, 0x42000000); | ||
2566 | I915_WRITE(EG5, 0x00140031); | ||
2567 | I915_WRITE(EG6, 0); | ||
2568 | I915_WRITE(EG7, 0); | ||
2569 | |||
2570 | for (i = 0; i < 8; i++) | ||
2571 | I915_WRITE(PXWL + (i * 4), 0); | ||
2572 | |||
2573 | /* Enable PMON + select events */ | ||
2574 | I915_WRITE(ECR, 0x80000019); | ||
2575 | |||
2576 | lcfuse = I915_READ(LCFUSE02); | ||
2577 | |||
2578 | dev_priv->corr = (lcfuse & LCFUSE_HIV_MASK); | ||
2579 | } | ||
2580 | |||