All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Ville Syrjälä" <ville.syrjala@linux.intel.com>
To: Lucas De Marchi <lucas.demarchi@intel.com>
Cc: intel-gfx@lists.freedesktop.org
Subject: Re: [PATCH 2/5] drm/i915/icl: use a function pointer for pll_write when enabling
Date: Fri, 8 Mar 2019 22:19:54 +0200	[thread overview]
Message-ID: <20190308201954.GW3888@intel.com> (raw)
In-Reply-To: <20190306012636.18619-3-lucas.demarchi@intel.com>

On Tue, Mar 05, 2019 at 05:26:33PM -0800, Lucas De Marchi wrote:
> This allows us to share the icl_pll_enable() between the different types
> of PLL while allowing the caller to differentiate how to write the
> registers.
> 
> Signed-off-by: Lucas De Marchi <lucas.demarchi@intel.com>
> ---
>  drivers/gpu/drm/i915/intel_dpll_mgr.c | 18 ++++++++----------
>  1 file changed, 8 insertions(+), 10 deletions(-)
> 
> diff --git a/drivers/gpu/drm/i915/intel_dpll_mgr.c b/drivers/gpu/drm/i915/intel_dpll_mgr.c
> index 3b3de99756d6..5511bc23ea3d 100644
> --- a/drivers/gpu/drm/i915/intel_dpll_mgr.c
> +++ b/drivers/gpu/drm/i915/intel_dpll_mgr.c
> @@ -3118,9 +3118,10 @@ static void icl_mg_pll_write(struct drm_i915_private *dev_priv,
>  
>  static void icl_pll_enable(struct drm_i915_private *dev_priv,
>  			   struct intel_shared_dpll *pll,
> -			   i915_reg_t enable_reg)
> +			   i915_reg_t enable_reg,
> +			   void (*pll_write)(struct drm_i915_private *dev_priv,
> +					     struct intel_shared_dpll *pll))
>  {
> -	const enum intel_dpll_id id = pll->info->id;
>  	u32 val;
>  
>  	val = I915_READ(enable_reg);
> @@ -3133,12 +3134,9 @@ static void icl_pll_enable(struct drm_i915_private *dev_priv,
>  	 */
>  	if (intel_wait_for_register(dev_priv, enable_reg, PLL_POWER_STATE,
>  				    PLL_POWER_STATE, 1))
> -		DRM_ERROR("PLL %d Power not enabled\n", id);
> +		DRM_ERROR("PLL %d Power not enabled\n", pll->info->id);
>  
> -	if (intel_dpll_is_combophy(id) || id == DPLL_ID_ICL_TBTPLL)
> -		icl_dpll_write(dev_priv, pll);
> -	else
> -		icl_mg_pll_write(dev_priv, pll);
> +	pll_write(dev_priv, pll);

Hmm. Would it be cleaner to just exract the pll power
enable/disable and pll enable/disable parts into small helpers?
It looks like like glk/cnl also follow this same pattern, so
there may be a chance to reuse the code on those platforms
as well.

>  
>  	/*
>  	 * DVFS pre sequence would be here, but in our driver the cdclk code
> @@ -3152,7 +3150,7 @@ static void icl_pll_enable(struct drm_i915_private *dev_priv,
>  
>  	if (intel_wait_for_register(dev_priv, enable_reg, PLL_LOCK, PLL_LOCK,
>  				    1)) /* 600us actually. */
> -		DRM_ERROR("PLL %d not locked\n", id);
> +		DRM_ERROR("PLL %d not locked\n", pll->info->id);
>  
>  	/* DVFS post sequence would be here. See the comment above. */
>  }
> @@ -3162,7 +3160,7 @@ static void combo_pll_enable(struct drm_i915_private *dev_priv,
>  {
>  	i915_reg_t enable_reg = icl_pll_id_to_enable_reg(pll->info->id);
>  
> -	icl_pll_enable(dev_priv, pll, enable_reg);
> +	icl_pll_enable(dev_priv, pll, enable_reg, icl_dpll_write);
>  }
>  
>  static void mg_pll_enable(struct drm_i915_private *dev_priv,
> @@ -3171,7 +3169,7 @@ static void mg_pll_enable(struct drm_i915_private *dev_priv,
>  	i915_reg_t enable_reg =
>  		MG_PLL_ENABLE(icl_pll_id_to_tc_port(pll->info->id));
>  
> -	icl_pll_enable(dev_priv, pll, enable_reg);
> +	icl_pll_enable(dev_priv, pll, enable_reg, icl_mg_pll_write);
>  }
>  
>  static void icl_pll_disable(struct drm_i915_private *dev_priv,
> -- 
> 2.20.1

-- 
Ville Syrjälä
Intel
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

  reply	other threads:[~2019-03-08 20:19 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-03-06  1:26 [PATCH 0/5] drm/i915/icl: split pll functions Lucas De Marchi
2019-03-06  1:26 ` [PATCH 1/5] drm/i915/icl: split combo and mg pll enable Lucas De Marchi
2019-03-06  1:26 ` [PATCH 2/5] drm/i915/icl: use a function pointer for pll_write when enabling Lucas De Marchi
2019-03-08 20:19   ` Ville Syrjälä [this message]
2019-03-06  1:26 ` [PATCH 3/5] drm/i915/icl: split combo and mg pll disable Lucas De Marchi
2019-03-06  1:26 ` [PATCH 4/5] drm/i915/icl: split combo and tbt pll funcs Lucas De Marchi
2019-03-06  1:26 ` [PATCH 5/5] drm/i915/icl: remove intel_dpll_is_combophy() Lucas De Marchi
2019-03-06  1:54 ` ✓ Fi.CI.BAT: success for drm/i915/icl: split pll functions Patchwork
2019-03-06  9:16 ` ✓ 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=20190308201954.GW3888@intel.com \
    --to=ville.syrjala@linux.intel.com \
    --cc=intel-gfx@lists.freedesktop.org \
    --cc=lucas.demarchi@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.