Skip to content

Commit

Permalink
drm/i915/cdclk: Re-use bxt_cdclk_ctl() when sanitizing
Browse files Browse the repository at this point in the history
The function bxt_cdclk_ctl() is responsible for deriving the value for
CDCLK_CTL; use it instead of repeating the same logic.

v2:
  - Use a better commit message body by making it more self-contained
    and not referring to stuff from the subject line. (Matt)

Reviewed-by: Matt Roper <matthew.d.roper@intel.com>
Signed-off-by: Gustavo Sousa <gustavo.sousa@intel.com>
Signed-off-by: Matt Roper <matthew.d.roper@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20240105140538.183553-5-gustavo.sousa@intel.com
  • Loading branch information
Gustavo Sousa authored and Matt Roper committed Jan 8, 2024
1 parent ebb9c42 commit 935e486
Showing 1 changed file with 3 additions and 23 deletions.
26 changes: 3 additions & 23 deletions drivers/gpu/drm/i915/display/intel_cdclk.c
Original file line number Diff line number Diff line change
Expand Up @@ -2051,7 +2051,7 @@ static void bxt_set_cdclk(struct drm_i915_private *dev_priv,
static void bxt_sanitize_cdclk(struct drm_i915_private *dev_priv)
{
u32 cdctl, expected;
int cdclk, clock, vco;
int cdclk, vco;

intel_update_cdclk(dev_priv);
intel_cdclk_dump_config(dev_priv, &dev_priv->display.cdclk.hw, "Current CDCLK");
Expand All @@ -2076,35 +2076,15 @@ static void bxt_sanitize_cdclk(struct drm_i915_private *dev_priv)
* so sanitize this register.
*/
cdctl = intel_de_read(dev_priv, CDCLK_CTL);
expected = bxt_cdclk_ctl(dev_priv, &dev_priv->display.cdclk.hw, INVALID_PIPE);

/*
* Let's ignore the pipe field, since BIOS could have configured the
* dividers both synching to an active pipe, or asynchronously
* (PIPE_NONE).
*/
cdctl &= ~bxt_cdclk_cd2x_pipe(dev_priv, INVALID_PIPE);

if (DISPLAY_VER(dev_priv) >= 20)
expected = MDCLK_SOURCE_SEL_CDCLK_PLL;
else
expected = skl_cdclk_decimal(cdclk);

/* Figure out what CD2X divider we should be using for this cdclk */
if (HAS_CDCLK_SQUASH(dev_priv))
clock = dev_priv->display.cdclk.hw.vco / 2;
else
clock = dev_priv->display.cdclk.hw.cdclk;

expected |= bxt_cdclk_cd2x_div_sel(dev_priv, clock,
dev_priv->display.cdclk.hw.vco);

/*
* Disable SSA Precharge when CD clock frequency < 500 MHz,
* enable otherwise.
*/
if ((IS_GEMINILAKE(dev_priv) || IS_BROXTON(dev_priv)) &&
dev_priv->display.cdclk.hw.cdclk >= 500000)
expected |= BXT_CDCLK_SSA_PRECHARGE_ENABLE;
expected &= ~bxt_cdclk_cd2x_pipe(dev_priv, INVALID_PIPE);

if (cdctl == expected)
/* All well; nothing to sanitize */
Expand Down

0 comments on commit 935e486

Please sign in to comment.