aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm/i915/intel_display.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/gpu/drm/i915/intel_display.c')
-rw-r--r--drivers/gpu/drm/i915/intel_display.c27
1 files changed, 14 insertions, 13 deletions
diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c
index 6d038c567462..11a303ecb058 100644
--- a/drivers/gpu/drm/i915/intel_display.c
+++ b/drivers/gpu/drm/i915/intel_display.c
@@ -4465,6 +4465,7 @@ static void modeset_update_crtc_power_domains(struct drm_device *dev)
4465 intel_display_set_init_power(dev_priv, false); 4465 intel_display_set_init_power(dev_priv, false);
4466} 4466}
4467 4467
4468/* returns HPLL frequency in kHz */
4468int valleyview_get_vco(struct drm_i915_private *dev_priv) 4469int valleyview_get_vco(struct drm_i915_private *dev_priv)
4469{ 4470{
4470 int hpll_freq, vco_freq[] = { 800, 1600, 2000, 2400 }; 4471 int hpll_freq, vco_freq[] = { 800, 1600, 2000, 2400 };
@@ -4475,7 +4476,7 @@ int valleyview_get_vco(struct drm_i915_private *dev_priv)
4475 CCK_FUSE_HPLL_FREQ_MASK; 4476 CCK_FUSE_HPLL_FREQ_MASK;
4476 mutex_unlock(&dev_priv->dpio_lock); 4477 mutex_unlock(&dev_priv->dpio_lock);
4477 4478
4478 return vco_freq[hpll_freq]; 4479 return vco_freq[hpll_freq] * 1000;
4479} 4480}
4480 4481
4481/* Adjust CDclk dividers to allow high res or save power if possible */ 4482/* Adjust CDclk dividers to allow high res or save power if possible */
@@ -4487,9 +4488,9 @@ static void valleyview_set_cdclk(struct drm_device *dev, int cdclk)
4487 WARN_ON(valleyview_cur_cdclk(dev_priv) != dev_priv->vlv_cdclk_freq); 4488 WARN_ON(valleyview_cur_cdclk(dev_priv) != dev_priv->vlv_cdclk_freq);
4488 dev_priv->vlv_cdclk_freq = cdclk; 4489 dev_priv->vlv_cdclk_freq = cdclk;
4489 4490
4490 if (cdclk >= 320) /* jump to highest voltage for 400MHz too */ 4491 if (cdclk >= 320000) /* jump to highest voltage for 400MHz too */
4491 cmd = 2; 4492 cmd = 2;
4492 else if (cdclk == 266) 4493 else if (cdclk == 266667)
4493 cmd = 1; 4494 cmd = 1;
4494 else 4495 else
4495 cmd = 0; 4496 cmd = 0;
@@ -4506,11 +4507,11 @@ static void valleyview_set_cdclk(struct drm_device *dev, int cdclk)
4506 } 4507 }
4507 mutex_unlock(&dev_priv->rps.hw_lock); 4508 mutex_unlock(&dev_priv->rps.hw_lock);
4508 4509
4509 if (cdclk == 400) { 4510 if (cdclk == 400000) {
4510 u32 divider, vco; 4511 u32 divider, vco;
4511 4512
4512 vco = valleyview_get_vco(dev_priv); 4513 vco = valleyview_get_vco(dev_priv);
4513 divider = ((vco << 1) / cdclk) - 1; 4514 divider = DIV_ROUND_CLOSEST(vco << 1, cdclk) - 1;
4514 4515
4515 mutex_lock(&dev_priv->dpio_lock); 4516 mutex_lock(&dev_priv->dpio_lock);
4516 /* adjust cdclk divider */ 4517 /* adjust cdclk divider */
@@ -4530,7 +4531,7 @@ static void valleyview_set_cdclk(struct drm_device *dev, int cdclk)
4530 * For high bandwidth configs, we set a higher latency in the bunit 4531 * For high bandwidth configs, we set a higher latency in the bunit
4531 * so that the core display fetch happens in time to avoid underruns. 4532 * so that the core display fetch happens in time to avoid underruns.
4532 */ 4533 */
4533 if (cdclk == 400) 4534 if (cdclk == 400000)
4534 val |= 4500 / 250; /* 4.5 usec */ 4535 val |= 4500 / 250; /* 4.5 usec */
4535 else 4536 else
4536 val |= 3000 / 250; /* 3.0 usec */ 4537 val |= 3000 / 250; /* 3.0 usec */
@@ -4554,7 +4555,7 @@ int valleyview_cur_cdclk(struct drm_i915_private *dev_priv)
4554 4555
4555 divider &= 0xf; 4556 divider &= 0xf;
4556 4557
4557 cur_cdclk = (vco << 1) / (divider + 1); 4558 cur_cdclk = DIV_ROUND_CLOSEST(vco << 1, divider + 1);
4558 4559
4559 return cur_cdclk; 4560 return cur_cdclk;
4560} 4561}
@@ -4571,12 +4572,12 @@ static int valleyview_calc_cdclk(struct drm_i915_private *dev_priv,
4571 * So we check to see whether we're above 90% of the lower bin and 4572 * So we check to see whether we're above 90% of the lower bin and
4572 * adjust if needed. 4573 * adjust if needed.
4573 */ 4574 */
4574 if (max_pixclk > 288000) { 4575 if (max_pixclk > 320000*9/10)
4575 return 400; 4576 return 400000;
4576 } else if (max_pixclk > 240000) { 4577 else if (max_pixclk > 266667*9/10)
4577 return 320; 4578 return 320000;
4578 } else 4579 else
4579 return 266; 4580 return 266667;
4580 /* Looks like the 200MHz CDclk freq doesn't work on some configs */ 4581 /* Looks like the 200MHz CDclk freq doesn't work on some configs */
4581} 4582}
4582 4583