aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVille Syrjälä <[email protected]>2016-05-11 22:44:45 +0300
committerVille Syrjälä <[email protected]>2016-05-13 21:31:17 +0300
commit92891e45c313e22095c90eb36b283a3b39e90bd4 (patch)
tree3146eb52e814d96dc616cb4007c5caaf0c13aaa1
parent4e5ca60fd35a2f042902e8047c1273aa79409977 (diff)
drm/i915: Use skl_cdclk_decimal() on bxt
Both SKL and BXT need to fill in the "decimal" cdclk frequency into the CDCLK_CTL register. SKL uses a small helper to do the kHz->"decimal" conversion, whereas BXT has it open-coded. Use the helper on BXT too. While at it, change it to round to closest rather than down. It doesn't actually matter with the frequencies we have to deal with, but it seems like the right thing to do. Signed-off-by: Ville Syrjälä <[email protected]> Link: http://patchwork.freedesktop.org/patch/msgid/[email protected] Reviewed-by: Jani Nikula <[email protected]>
-rw-r--r--drivers/gpu/drm/i915/intel_display.c14
1 files changed, 7 insertions, 7 deletions
diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c
index c111ebcff36b..d837bc4a7e39 100644
--- a/drivers/gpu/drm/i915/intel_display.c
+++ b/drivers/gpu/drm/i915/intel_display.c
@@ -5336,6 +5336,12 @@ static void intel_update_cdclk(struct drm_device *dev)
intel_update_max_cdclk(dev);
}
+/* convert from kHz to .1 fixpoint MHz with -1MHz offset */
+static int skl_cdclk_decimal(int cdclk)
+{
+ return DIV_ROUND_CLOSEST(cdclk - 1000, 500);
+}
+
static void broxton_set_cdclk(struct drm_i915_private *dev_priv, int frequency)
{
uint32_t divider;
@@ -5435,8 +5441,7 @@ static void broxton_set_cdclk(struct drm_i915_private *dev_priv, int frequency)
val |= BXT_CDCLK_SSA_PRECHARGE_ENABLE;
val &= ~CDCLK_FREQ_DECIMAL_MASK;
- /* convert from kHz to .1 fixpoint MHz with -1MHz offset */
- val |= (frequency - 1000) / 500;
+ val |= skl_cdclk_decimal(frequency);
I915_WRITE(CDCLK_CTL, val);
}
@@ -5536,11 +5541,6 @@ static const struct skl_cdclk_entry {
{ .freq = 675000, .vco = 8100 },
};
-static unsigned int skl_cdclk_decimal(unsigned int freq)
-{
- return (freq - 1000) / 500;
-}
-
static unsigned int skl_cdclk_get_vco(unsigned int freq)
{
unsigned int i;