All of lore.kernel.org
 help / color / mirror / Atom feed
From: Lucas De Marchi <lucas.demarchi@intel.com>
To: Mika Kahola <mika.kahola@intel.com>
Cc: intel-gfx@lists.freedesktop.org,
	Paulo Zanoni <paulo.r.zanoni@intel.com>,
	Rodrigo Vivi <rodrigo.vivi@intel.com>
Subject: Re: [PATCH 11/24] drm/i915/icl: Get DDI clock for ICL based on PLLs.
Date: Tue, 22 May 2018 22:48:04 -0700	[thread overview]
Message-ID: <20180523054803.GA18678@ldmartin-desk.amr.corp.intel.com> (raw)
In-Reply-To: <1526989483.27355.4.camel@intel.com>

On Tue, May 22, 2018 at 02:44:43PM +0300, Mika Kahola wrote:
> On Mon, 2018-05-21 at 17:25 -0700, Paulo Zanoni wrote:
> > From: Manasi Navare <manasi.d.navare@intel.com>
> > 
> > PLLs are the source clocks for the DDIs so in order
> > to determine the ddi clock we need to check the PLL
> > configuration.
> > 
> > This gets a little tricky for ICL since there is
> > no register bit that maps directly to the link clock.
> > So this patch creates a separate function in intel_dpll_mgr.c
> > to obtain the write array PLL Params and compares the set
> > pll_params with the table to get the corresponding link
> > clock.
> > 
> > Cc: Rodrigo Vivi <rodrigo.vivi@intel.com>
> > Cc: Mika Kahola <mika.kahola@intel.com>
> > Cc: Paulo Zanoni <paulo.r.zanoni@intel.com>
> > Signed-off-by: Manasi Navare <manasi.d.navare@intel.com>
> > Signed-off-by: Lucas De Marchi <lucas.demarchi@intel.com>

Reviewed-by: Lucas De Marchi <lucas.demarchi@intel.com>

> > Signed-off-by: Paulo Zanoni <paulo.r.zanoni@intel.com>
> > ---
> >  drivers/gpu/drm/i915/i915_reg.h       |  3 ++
> >  drivers/gpu/drm/i915/intel_ddi.c      | 26 ++++++++++++++
> >  drivers/gpu/drm/i915/intel_dpll_mgr.c | 66
> > +++++++++++++++++++++++++++++++++++
> >  drivers/gpu/drm/i915/intel_dpll_mgr.h |  2 ++
> >  4 files changed, 97 insertions(+)
> > 
> > diff --git a/drivers/gpu/drm/i915/i915_reg.h
> > b/drivers/gpu/drm/i915/i915_reg.h
> > index 7f27fe2e38c7..26903cffabf6 100644
> > --- a/drivers/gpu/drm/i915/i915_reg.h
> > +++ b/drivers/gpu/drm/i915/i915_reg.h
> > @@ -9182,13 +9182,16 @@ enum skl_power_gate {
> >  #define  DPLL_CFGCR1_QDIV_RATIO_MASK	(0xff << 10)
> >  #define  DPLL_CFGCR1_QDIV_RATIO_SHIFT	(10)
> >  #define  DPLL_CFGCR1_QDIV_RATIO(x)	((x) << 10)
> > +#define  DPLL_CFGCR1_QDIV_MODE_SHIFT	(9)
> >  #define  DPLL_CFGCR1_QDIV_MODE(x)	((x) << 9)
> >  #define  DPLL_CFGCR1_KDIV_MASK		(7 << 6)
> > +#define  DPLL_CFGCR1_KDIV_SHIFT		(6)
> >  #define  DPLL_CFGCR1_KDIV(x)		((x) << 6)
> >  #define  DPLL_CFGCR1_KDIV_1		(1 << 6)
> >  #define  DPLL_CFGCR1_KDIV_2		(2 << 6)
> >  #define  DPLL_CFGCR1_KDIV_4		(4 << 6)
> >  #define  DPLL_CFGCR1_PDIV_MASK		(0xf << 2)
> > +#define  DPLL_CFGCR1_PDIV_SHIFT		(2)
> >  #define  DPLL_CFGCR1_PDIV(x)		((x) << 2)
> >  #define  DPLL_CFGCR1_PDIV_2		(1 << 2)
> >  #define  DPLL_CFGCR1_PDIV_3		(2 << 2)
> > diff --git a/drivers/gpu/drm/i915/intel_ddi.c
> > b/drivers/gpu/drm/i915/intel_ddi.c
> > index d8ae82001f83..0d8bed8e2200 100644
> > --- a/drivers/gpu/drm/i915/intel_ddi.c
> > +++ b/drivers/gpu/drm/i915/intel_ddi.c
> > @@ -1458,6 +1458,30 @@ static void ddi_dotclock_get(struct
> > intel_crtc_state *pipe_config)
> >  	pipe_config->base.adjusted_mode.crtc_clock = dotclock;
> >  }
> >  
> > +static void icl_ddi_clock_get(struct intel_encoder *encoder,
> > +			      struct intel_crtc_state *pipe_config)
> > +{
> > +	struct drm_i915_private *dev_priv = to_i915(encoder-
> > >base.dev);
> > +	enum port port = encoder->port;
> > +	int link_clock = 0;
> > +	uint32_t pll_id;
> > +
> > +	pll_id = intel_get_shared_dpll_id(dev_priv, pipe_config-
> > >shared_dpll);
> > +	if (port == PORT_A || port == PORT_B) {
> > +		if (encoder->type == INTEL_OUTPUT_HDMI)
> > +			link_clock = cnl_calc_wrpll_link(dev_priv,
> > pll_id);
> > +		else
> > +			link_clock =
> > icl_calc_dp_combo_pll_link(dev_priv,
> > +								pll_
> > id);
> > +	} else {
> > +		/* FIXME - Add for MG PLL */
> > +		WARN(1, "MG PLL clock_get code not implemented
> > yet\n");
> > +	}
> > +
> > +	pipe_config->port_clock = link_clock;
> > +	ddi_dotclock_get(pipe_config);
> > +}
> > +
> >  static void cnl_ddi_clock_get(struct intel_encoder *encoder,
> >  			      struct intel_crtc_state *pipe_config)
> >  {
> > @@ -1651,6 +1675,8 @@ static void intel_ddi_clock_get(struct
> > intel_encoder *encoder,
> >  		bxt_ddi_clock_get(encoder, pipe_config);
> >  	else if (IS_CANNONLAKE(dev_priv))
> >  		cnl_ddi_clock_get(encoder, pipe_config);
> > +	else if (IS_ICELAKE(dev_priv))
> > +		icl_ddi_clock_get(encoder, pipe_config);
> >  }
> >  
> >  void intel_ddi_set_pipe_settings(const struct intel_crtc_state
> > *crtc_state)
> > diff --git a/drivers/gpu/drm/i915/intel_dpll_mgr.c
> > b/drivers/gpu/drm/i915/intel_dpll_mgr.c
> > index 383fbc15113d..3cc837f74ffb 100644
> > --- a/drivers/gpu/drm/i915/intel_dpll_mgr.c
> > +++ b/drivers/gpu/drm/i915/intel_dpll_mgr.c
> > @@ -2525,6 +2525,72 @@ static bool icl_calc_dpll_state(struct
> > intel_crtc_state *crtc_state,
> >  	return true;
> >  }
> >  
> > +int icl_calc_dp_combo_pll_link(struct drm_i915_private *dev_priv,
> > +			       uint32_t pll_id)
> > +{
> > +	uint32_t cfgcr0, cfgcr1;
> > +	uint32_t pdiv, kdiv, qdiv_mode, qdiv_ratio, dco_integer,
> > dco_fraction;
> > +	const struct skl_wrpll_params *params;
> > +	int index, n_entries, link_clock = 0;
> > +
> > +	/* Read back values from DPLL CFGCR registers */
> > +	cfgcr0 = I915_READ(ICL_DPLL_CFGCR0(pll_id));
> > +	cfgcr1 = I915_READ(ICL_DPLL_CFGCR1(pll_id));
> > +
> > +	dco_integer = cfgcr0 & DPLL_CFGCR0_DCO_INTEGER_MASK;
> > +	dco_fraction = (cfgcr0 & DPLL_CFGCR0_DCO_FRACTION_MASK) >>
> > +		DPLL_CFGCR0_DCO_FRACTION_SHIFT;
> > +	pdiv = (cfgcr1 & DPLL_CFGCR1_PDIV_MASK) >>
> > DPLL_CFGCR1_PDIV_SHIFT;
> > +	kdiv = (cfgcr1 & DPLL_CFGCR1_KDIV_MASK) >>
> > DPLL_CFGCR1_KDIV_SHIFT;
> > +	qdiv_mode = (cfgcr1 & DPLL_CFGCR1_QDIV_MODE(1)) >>
> > +		DPLL_CFGCR1_QDIV_MODE_SHIFT;
> > +	qdiv_ratio = (cfgcr1 & DPLL_CFGCR1_QDIV_RATIO_MASK) >>
> > +		DPLL_CFGCR1_QDIV_RATIO_SHIFT;
> > +
> > +	params = dev_priv->cdclk.hw.ref == 24000 ?
> > +		icl_dp_combo_pll_24MHz_values :
> > +		icl_dp_combo_pll_19_2MHz_values;
> > +	n_entries = ARRAY_SIZE(icl_dp_combo_pll_24MHz_values);
> > +
> > +	for (index = 0; index < n_entries; index++) {
> > +		if (dco_integer == params[index].dco_integer &&
> > +		    dco_fraction == params[index].dco_fraction &&
> > +		    pdiv == params[index].pdiv &&
> > +		    kdiv == params[index].kdiv &&
> > +		    qdiv_mode == params[index].qdiv_mode &&
> > +		    qdiv_ratio == params[index].qdiv_ratio)
> > +			break;
> > +	}
> > +	WARN(index == n_entries, "Invalid PLL Parameters");
> > +
> > +	/* Map PLL Index to Link Clock */
> > +	switch (index) {
> > +	case 0:
> > +		link_clock = 540000;
> > +		break;
> > +	case 1:
> > +		link_clock = 270000;
> > +		break;
> > +	case 2:
> > +		link_clock = 162000;
> > +		break;
> > +	case 3:
> > +		link_clock = 324000;
> > +		break;
> > +	case 4:
> > +		link_clock = 432000;
> > +		break;
> > +	case 5:
> > +		link_clock = 432000;
> > +		break;
> > +	case 6:
> > +		link_clock = 810000;
> > +		break;
> Just to play it safe, we could add 
> 
> 	default:
> 		MISSING_CASE();
> 	}
> 
> here and return with some default link clock value.

There will already be a warning above when index == n_entries. And then
we will return 0.


> 
> > +
> > +	return link_clock;
> > +}
> > +
> >  static enum port icl_mg_pll_id_to_port(enum intel_dpll_id id)
> >  {
> >  	return id - DPLL_ID_ICL_MGPLL1 + PORT_C;
> > diff --git a/drivers/gpu/drm/i915/intel_dpll_mgr.h
> > b/drivers/gpu/drm/i915/intel_dpll_mgr.h
> > index 7a0cd564a9ee..78915057d2e6 100644
> > --- a/drivers/gpu/drm/i915/intel_dpll_mgr.h
> > +++ b/drivers/gpu/drm/i915/intel_dpll_mgr.h
> > @@ -336,5 +336,7 @@ void intel_shared_dpll_init(struct drm_device
> > *dev);
> >  
> >  void intel_dpll_dump_hw_state(struct drm_i915_private *dev_priv,
> >  			      struct intel_dpll_hw_state *hw_state);
> > +int icl_calc_dp_combo_pll_link(struct drm_i915_private *dev_priv,
> > +			       uint32_t pll_id);
> >  
> >  #endif /* _INTEL_DPLL_MGR_H_ */
> -- 
> Mika Kahola - Intel OTC
> 
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

  reply	other threads:[~2018-05-23  5:48 UTC|newest]

Thread overview: 127+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-05-22  0:25 [PATCH 00/24] More ICL display patches Paulo Zanoni
2018-05-22  0:25 ` [PATCH 01/24] drm/i915/icl: Extend AUX F interrupts to ICL Paulo Zanoni
2018-05-23 19:02   ` Srivatsa, Anusha
2018-05-22  0:25 ` [PATCH 02/24] drm/i915/icl: GSE interrupt moves from DE_MISC to GU_MISC Paulo Zanoni
2018-05-24  9:22   ` Mika Kuoppala
2018-05-24 22:51     ` Dhinakaran Pandiyan
2018-05-25 12:00       ` Mika Kuoppala
2018-05-25 19:43         ` [PATCH v2] " Dhinakaran Pandiyan
2018-05-25 19:56           ` Chris Wilson
2018-06-14  1:51             ` Dhinakaran Pandiyan
2018-06-14 10:32               ` Ville Syrjälä
2018-06-14 20:21                 ` Dhinakaran Pandiyan
2018-06-14 19:54             ` [PATCH v3] " Dhinakaran Pandiyan
2018-06-15 23:18               ` Paulo Zanoni
2018-05-22  0:25 ` [PATCH 03/24] drm/i915/icl: introduce tc_port Paulo Zanoni
2018-05-22  6:13   ` Kumar, Mahesh
2018-05-22  0:25 ` [PATCH 04/24] drm/i915/icl: Support for TC North Display interrupts Paulo Zanoni
2018-06-13 22:20   ` Lucas De Marchi
2018-06-15 23:47     ` Paulo Zanoni
2018-05-22  0:25 ` [PATCH 05/24] drm/i915/icp: Add Interrupt Support Paulo Zanoni
2018-05-24 23:53   ` Lucas De Marchi
2018-05-25  0:45     ` Dhinakaran Pandiyan
2018-05-25  0:43       ` Lucas De Marchi
2018-05-30  0:04         ` Lucas De Marchi
2018-06-13 22:23           ` Lucas De Marchi
2018-06-14  0:04             ` Paulo Zanoni
2018-06-14  2:21             ` Dhinakaran Pandiyan
2018-06-18 19:10               ` Anusha Srivatsa
2018-05-22  0:25 ` [PATCH 06/24] drm/i915/ICL: Add register definition for DFLEXDPMLE Paulo Zanoni
2018-05-25  0:26   ` Paulo Zanoni
2018-05-25 16:14     ` Lucas De Marchi
2018-05-25 16:58       ` Manasi Navare
2018-05-25 18:52   ` [PATCH v2 " Manasi Navare
2018-05-25 19:03   ` [PATCH v3 06/24] drm/i915/icl: " Manasi Navare
2018-05-22  0:25 ` [PATCH 07/24] drm/i915/icl: Add DDI HDMI level selection for ICL Paulo Zanoni
2018-05-25 16:26   ` Lucas De Marchi
2018-06-01 22:32     ` Paulo Zanoni
2018-06-11 23:51       ` Lucas De Marchi
2018-05-22  0:25 ` [PATCH 08/24] drm/i915/icl: Map VBT DDC Pin to BSpec DDC Pin Paulo Zanoni
2018-05-23 19:43   ` James Ausmus
2018-05-22  0:25 ` [PATCH 09/24] drm/i915/icl: Add Icelake PCH detection Paulo Zanoni
2018-05-25  0:29   ` Paulo Zanoni
2018-05-22  0:25 ` [PATCH 10/24] drm/i915/icl: add icelake_get_ddi_pll() Paulo Zanoni
2018-06-13 23:15   ` Lucas De Marchi
2018-06-13 23:51     ` Paulo Zanoni
2018-06-13 23:55       ` Lucas De Marchi
2018-05-22  0:25 ` [PATCH 11/24] drm/i915/icl: Get DDI clock for ICL based on PLLs Paulo Zanoni
2018-05-22 11:44   ` Mika Kahola
2018-05-23  5:48     ` Lucas De Marchi [this message]
2018-05-23 21:54     ` Paulo Zanoni
2018-05-23 21:15   ` Paulo Zanoni
2018-05-23 22:44   ` [PATCH v2 " Paulo Zanoni
2018-05-24 13:12     ` Mika Kahola
2018-05-22  0:25 ` [PATCH 12/24] drm/i915/icl: Calculate link clock using the new registers Paulo Zanoni
2018-05-25  0:33   ` Paulo Zanoni
2018-05-22  0:25 ` [PATCH 13/24] drm/i915/icl: unconditionally init DDI for every port Paulo Zanoni
2018-06-13 23:34   ` Lucas De Marchi
2018-06-13 23:47     ` Paulo Zanoni
2018-05-22  0:25 ` [PATCH 14/24] drm/i915/icl: start adding the TBT pll Paulo Zanoni
2018-06-14  0:37   ` Lucas De Marchi
2018-05-22  0:25 ` [PATCH 15/24] drm/i915/icl: compute the TBT PLL registers Paulo Zanoni
2018-06-08 20:19   ` Srivatsa, Anusha
2018-06-13 21:19     ` Paulo Zanoni
2018-06-18 19:57       ` Srivatsa, Anusha
2018-06-13 21:42   ` [PATCH v2 " Paulo Zanoni
2018-05-22  0:25 ` [PATCH 16/24] drm/i915/icl: Handle hotplug interrupts for DP over TBT Paulo Zanoni
2018-06-14  0:51   ` Lucas De Marchi
2018-05-22  0:25 ` [PATCH 17/24] drm/i915/icl: Add 10-bit support for hdmi Paulo Zanoni
2018-06-20 16:55   ` Ville Syrjälä
2018-05-22  0:25 ` [PATCH 18/24] drm/i915/icl: implement icl_digital_port_connected() Paulo Zanoni
2018-06-19 22:28   ` Lucas De Marchi
2018-06-20 21:01     ` Paulo Zanoni
2018-05-22  0:25 ` [PATCH 19/24] drm/i915/icl: store the port type for TC ports Paulo Zanoni
2018-06-14 19:59   ` Rodrigo Vivi
2018-06-21  0:37     ` Paulo Zanoni
2018-05-22  0:25 ` [PATCH 20/24] drm/i915/icl: implement the tc/legacy HPD {dis, }connect flow for DP Paulo Zanoni
2018-06-21 22:04   ` Srivatsa, Anusha
2018-07-11 21:28     ` Paulo Zanoni
2018-05-22  0:25 ` [PATCH 21/24] drm/i915/icl: implement the legacy HPD {dis, }connect flow for HDMI Paulo Zanoni
2018-06-26 11:41   ` Mika Kahola
2018-05-22  0:25 ` [PATCH 22/24] drm/i915/icl: Update FIA supported lane count for hpd Paulo Zanoni
2018-06-21 22:45   ` Srivatsa, Anusha
2018-05-22  0:25 ` [PATCH 23/24] drm/i915/icl: program MG_DP_MODE Paulo Zanoni
2018-06-19 12:59   ` Maarten Lankhorst
2018-06-19 13:00     ` Maarten Lankhorst
2018-05-22  0:25 ` [PATCH 24/24] drm/i915/icl: toggle PHY clock gating around link training Paulo Zanoni
2018-06-19 13:22   ` Maarten Lankhorst
2018-05-22  0:38 ` ✗ Fi.CI.CHECKPATCH: warning for More ICL display patches Patchwork
2018-05-22  0:45 ` ✗ Fi.CI.SPARSE: " Patchwork
2018-05-22  1:00 ` ✓ Fi.CI.BAT: success " Patchwork
2018-05-22  1:52 ` ✓ Fi.CI.IGT: " Patchwork
2018-05-23 22:59 ` ✗ Fi.CI.CHECKPATCH: warning for More ICL display patches (rev2) Patchwork
2018-05-23 23:06 ` ✗ Fi.CI.SPARSE: " Patchwork
2018-05-23 23:19 ` ✓ Fi.CI.BAT: success " Patchwork
2018-05-24  0:54 ` ✗ Fi.CI.IGT: failure " Patchwork
2018-05-24 23:42 ` [PATCH 25/24] drm/i915/icl: fix gmbus gpio pin mapping Paulo Zanoni
2018-05-24 23:42   ` [PATCH 26/24] drm/i915/icl: Add allowed DP rates for Icelake Paulo Zanoni
2018-05-25 18:32     ` James Ausmus
2018-06-01 23:43       ` Paulo Zanoni
2018-06-14 19:24         ` Rodrigo Vivi
2018-06-15  0:45           ` Manasi Navare
2018-06-15  5:20             ` Rodrigo Vivi
2018-06-14 19:23     ` Rodrigo Vivi
2018-06-19 20:39       ` Manasi Navare
2018-05-24 23:42   ` [PATCH 27/24] drm/i915/dp: Add support for HBR3 and TPS4 during link training Paulo Zanoni
2018-05-25 18:41     ` James Ausmus
2018-05-24 23:42   ` [PATCH 28/24] drm/i915/icl: implement DVFS for ICL Paulo Zanoni
2018-06-14 19:47     ` Rodrigo Vivi
2018-05-24 23:42   ` [PATCH 29/24] drm/i915/icl: DP_AUX_E is valid on ICL+ Paulo Zanoni
2018-05-25  0:12     ` Paulo Zanoni
2018-06-11 23:01       ` Paulo Zanoni
2018-05-24 23:42   ` [PATCH 30/24] drm/i915/icl: update VBT's child_device_config flags2 field Paulo Zanoni
2018-06-14 19:33     ` Rodrigo Vivi
2018-05-25  0:36   ` [PATCH 25/24] drm/i915/icl: fix gmbus gpio pin mapping Lucas De Marchi
2018-05-25 16:24     ` Ville Syrjälä
2018-05-25 16:26       ` Lucas De Marchi
2018-06-14 19:28     ` Rodrigo Vivi
2018-06-14 19:07   ` Rodrigo Vivi
2018-06-14 20:43     ` Paulo Zanoni
2018-05-24 23:59 ` ✗ Fi.CI.CHECKPATCH: warning for More ICL display patches (rev7) Patchwork
2018-05-25  0:06 ` ✗ Fi.CI.SPARSE: " Patchwork
2018-05-25  0:14 ` ✗ Fi.CI.BAT: failure " Patchwork
2018-05-25  0:49 ` ✗ Fi.CI.BAT: failure for More ICL display patches (rev8) Patchwork
2018-05-25 20:11 ` ✗ Fi.CI.BAT: failure for More ICL display patches (rev11) Patchwork
2018-06-01 23:22 ` [PATCH 00/24] More ICL display patches Paulo Zanoni
2018-06-13 21:49 ` ✗ Fi.CI.BAT: failure for More ICL display patches (rev12) Patchwork
2018-06-14 20:20 ` ✗ Fi.CI.BAT: failure for More ICL display patches (rev13) 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=20180523054803.GA18678@ldmartin-desk.amr.corp.intel.com \
    --to=lucas.demarchi@intel.com \
    --cc=intel-gfx@lists.freedesktop.org \
    --cc=mika.kahola@intel.com \
    --cc=paulo.r.zanoni@intel.com \
    --cc=rodrigo.vivi@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.