All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Lisovskiy, Stanislav" <stanislav.lisovskiy@intel.com>
To: Mika Kahola <mika.kahola@intel.com>
Cc: intel-gfx@lists.freedesktop.org
Subject: Re: [Intel-gfx] [PATCH v2 3/5] drm/i915/display/dg2: Set CD clock squashing registers
Date: Tue, 23 Nov 2021 10:55:01 +0200	[thread overview]
Message-ID: <20211123085501.GC17614@intel.com> (raw)
In-Reply-To: <20211119131348.725220-4-mika.kahola@intel.com>

On Fri, Nov 19, 2021 at 03:13:46PM +0200, Mika Kahola wrote:
> Set CD clock squashing registers based on selected CD clock.
> 
> v2: use slk_cdclk_decimal() to compute decimal values instead of a
>     specific table (Ville)
>     Set waveform based on CD clock table (Ville)
>     Drop unnecessary local variable (Ville)
> v3: Correct function naming (Ville)
>     Correct if-else structure (Ville)
> [v4: vsyrjala: Fix spaces vs. tabs]
> [v5: vsyrjala: Fix cd2x divider calculation (Uma),
>                Add warn to waveform lookup (Uma),
>                Handle bypass freq in waveform lookup,
>                Generalize waveform handling in bxt_set_cdclk()]
>

Reviewed-by: Stanislav Lisovskiy <stanislav.lisovskiy@intel.com>
 
> Signed-off-by: Mika Kahola <mika.kahola@intel.com>
> Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
> ---
>  drivers/gpu/drm/i915/display/intel_cdclk.c | 41 +++++++++++++++++++++-
>  drivers/gpu/drm/i915/i915_reg.h            |  8 +++++
>  2 files changed, 48 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/gpu/drm/i915/display/intel_cdclk.c b/drivers/gpu/drm/i915/display/intel_cdclk.c
> index 3a61d52bdc0e..560383e8c5b6 100644
> --- a/drivers/gpu/drm/i915/display/intel_cdclk.c
> +++ b/drivers/gpu/drm/i915/display/intel_cdclk.c
> @@ -1638,6 +1638,26 @@ static u32 bxt_cdclk_cd2x_div_sel(struct drm_i915_private *dev_priv,
>  	}
>  }
>  
> +static u32 cdclk_squash_waveform(struct drm_i915_private *dev_priv,
> +				 int cdclk)
> +{
> +	const struct intel_cdclk_vals *table = dev_priv->cdclk.table;
> +	int i;
> +
> +	if (cdclk == dev_priv->cdclk.hw.bypass)
> +		return 0;
> +
> +	for (i = 0; table[i].refclk; i++)
> +		if (table[i].refclk == dev_priv->cdclk.hw.ref &&
> +		    table[i].cdclk == cdclk)
> +			return table[i].waveform;
> +
> +	drm_WARN(&dev_priv->drm, 1, "cdclk %d not valid for refclk %u\n",
> +		 cdclk, dev_priv->cdclk.hw.ref);
> +
> +	return 0xffff;
> +}
> +
>  static void bxt_set_cdclk(struct drm_i915_private *dev_priv,
>  			  const struct intel_cdclk_config *cdclk_config,
>  			  enum pipe pipe)
> @@ -1645,6 +1665,8 @@ static void bxt_set_cdclk(struct drm_i915_private *dev_priv,
>  	int cdclk = cdclk_config->cdclk;
>  	int vco = cdclk_config->vco;
>  	u32 val;
> +	u16 waveform;
> +	int clock;
>  	int ret;
>  
>  	/* Inform power controller of upcoming frequency change. */
> @@ -1688,7 +1710,24 @@ static void bxt_set_cdclk(struct drm_i915_private *dev_priv,
>  			bxt_de_pll_enable(dev_priv, vco);
>  	}
>  
> -	val = bxt_cdclk_cd2x_div_sel(dev_priv, cdclk, vco) |
> +	waveform = cdclk_squash_waveform(dev_priv, cdclk);
> +
> +	if (waveform)
> +		clock = vco / 2;
> +	else
> +		clock = cdclk;
> +
> +	if (has_cdclk_squasher(dev_priv)) {
> +		u32 squash_ctl = 0;
> +
> +		if (waveform)
> +			squash_ctl = CDCLK_SQUASH_ENABLE |
> +				CDCLK_SQUASH_WINDOW_SIZE(0xf) | waveform;
> +
> +		intel_de_write(dev_priv, CDCLK_SQUASH_CTL, squash_ctl);
> +	}
> +
> +	val = bxt_cdclk_cd2x_div_sel(dev_priv, clock, vco) |
>  		bxt_cdclk_cd2x_pipe(dev_priv, pipe) |
>  		skl_cdclk_decimal(cdclk);
>  
> diff --git a/drivers/gpu/drm/i915/i915_reg.h b/drivers/gpu/drm/i915/i915_reg.h
> index 3450818802c2..36f14f243190 100644
> --- a/drivers/gpu/drm/i915/i915_reg.h
> +++ b/drivers/gpu/drm/i915/i915_reg.h
> @@ -10654,6 +10654,14 @@ enum skl_power_gate {
>  #define  BXT_CDCLK_SSA_PRECHARGE_ENABLE	(1 << 16)
>  #define  CDCLK_FREQ_DECIMAL_MASK	(0x7ff)
>  
> +/* CDCLK_SQUASH_CTL */
> +#define CDCLK_SQUASH_CTL		_MMIO(0x46008)
> +#define  CDCLK_SQUASH_ENABLE		REG_BIT(31)
> +#define  CDCLK_SQUASH_WINDOW_SIZE_MASK	REG_GENMASK(27, 24)
> +#define  CDCLK_SQUASH_WINDOW_SIZE(x)	REG_FIELD_PREP(CDCLK_SQUASH_WINDOW_SIZE_MASK, (x))
> +#define  CDCLK_SQUASH_WAVEFORM_MASK	REG_GENMASK(15, 0)
> +#define  CDCLK_SQUASH_WAVEFORM(x)	REG_FIELD_PREP(CDCLK_SQUASH_WAVEFORM_MASK, (x))
> +
>  /* LCPLL_CTL */
>  #define LCPLL1_CTL		_MMIO(0x46010)
>  #define LCPLL2_CTL		_MMIO(0x46014)
> -- 
> 2.27.0
> 

  reply	other threads:[~2021-11-23  8:55 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-11-19 13:13 [Intel-gfx] [PATCH v2 0/5] Add support for CD clock squashing feature Mika Kahola
2021-11-19 13:13 ` [Intel-gfx] [PATCH v2 1/5] drm/i915/display/dg2: Introduce CD clock squashing table Mika Kahola
2021-11-23  8:53   ` Lisovskiy, Stanislav
2021-11-19 13:13 ` [Intel-gfx] [PATCH v2 2/5] drm/i915/display/dg2: Sanitize CD clock Mika Kahola
2021-11-23  8:54   ` Lisovskiy, Stanislav
2021-11-19 13:13 ` [Intel-gfx] [PATCH v2 3/5] drm/i915/display/dg2: Set CD clock squashing registers Mika Kahola
2021-11-23  8:55   ` Lisovskiy, Stanislav [this message]
2021-11-19 13:13 ` [Intel-gfx] [PATCH v2 4/5] drm/i915/display/dg2: Read CD clock from squasher table Mika Kahola
2021-11-23  8:55   ` Lisovskiy, Stanislav
2021-11-19 13:13 ` [Intel-gfx] [PATCH v2 5/5] drm/i915: Allow cdclk squasher to be reconfigured live Mika Kahola
2021-11-22 13:02   ` Kahola, Mika
2021-11-19 13:46 ` [Intel-gfx] ✗ Fi.CI.CHECKPATCH: warning for Add support for CD clock squashing feature Patchwork
2021-11-19 13:47 ` [Intel-gfx] ✗ Fi.CI.SPARSE: " Patchwork
2021-11-19 14:23 ` [Intel-gfx] ✓ Fi.CI.BAT: success " Patchwork
2021-11-19 17:29 ` [Intel-gfx] ✓ Fi.CI.IGT: " Patchwork

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20211123085501.GC17614@intel.com \
    --to=stanislav.lisovskiy@intel.com \
    --cc=intel-gfx@lists.freedesktop.org \
    --cc=mika.kahola@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.