Commit 92891e45 authored by Ville Syrjälä's avatar Ville Syrjälä

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: default avatarVille Syrjälä <ville.syrjala@linux.intel.com>
Link: http://patchwork.freedesktop.org/patch/msgid/1462995892-32416-7-git-send-email-ville.syrjala@linux.intel.comReviewed-by: default avatarJani Nikula <jani.nikula@intel.com>
parent 4e5ca60f
...@@ -5336,6 +5336,12 @@ static void intel_update_cdclk(struct drm_device *dev) ...@@ -5336,6 +5336,12 @@ static void intel_update_cdclk(struct drm_device *dev)
intel_update_max_cdclk(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) static void broxton_set_cdclk(struct drm_i915_private *dev_priv, int frequency)
{ {
uint32_t divider; uint32_t divider;
...@@ -5435,8 +5441,7 @@ static void broxton_set_cdclk(struct drm_i915_private *dev_priv, int frequency) ...@@ -5435,8 +5441,7 @@ static void broxton_set_cdclk(struct drm_i915_private *dev_priv, int frequency)
val |= BXT_CDCLK_SSA_PRECHARGE_ENABLE; val |= BXT_CDCLK_SSA_PRECHARGE_ENABLE;
val &= ~CDCLK_FREQ_DECIMAL_MASK; val &= ~CDCLK_FREQ_DECIMAL_MASK;
/* convert from kHz to .1 fixpoint MHz with -1MHz offset */ val |= skl_cdclk_decimal(frequency);
val |= (frequency - 1000) / 500;
I915_WRITE(CDCLK_CTL, val); I915_WRITE(CDCLK_CTL, val);
} }
...@@ -5536,11 +5541,6 @@ static const struct skl_cdclk_entry { ...@@ -5536,11 +5541,6 @@ static const struct skl_cdclk_entry {
{ .freq = 675000, .vco = 8100 }, { .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) static unsigned int skl_cdclk_get_vco(unsigned int freq)
{ {
unsigned int i; unsigned int i;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment