public inbox for intel-gfx@lists.freedesktop.org
 help / color / mirror / Atom feed
* [PATCH 00/10] Split the HSW/BDW PLL code a bit more
@ 2014-07-29 17:06 Damien Lespiau
  2014-07-29 17:06 ` [PATCH 01/10] drm/i915: Specify when the PLL hw state fields are valid Damien Lespiau
                   ` (10 more replies)
  0 siblings, 11 replies; 13+ messages in thread
From: Damien Lespiau @ 2014-07-29 17:06 UTC (permalink / raw)
  To: intel-gfx

Turns out we were optimistic. intel_ prefixes don't tend to last and this is
one of those times.

-- 
Damien

Damien Lespiau (10):
  drm/i915: Specify when the PLL hw state fields are valid
  drm/i915: Add a space to the shared DPLL debug message
  drm/i915: Extract the HSW DDI selection code into its own function
  drm/i915: Extract the HSW/BDW shared dpll init code
  drm/i915: Restrict hsw_dp_set_ddi_pll_sel() to HSW/BDW
  drm/i915: Fix stale comment for intel_ddi_pll_select()
  drm/i915: Split the BDW/HSW specific shared pll selection
  drm/i915: Make intel_ddi_calculate_wrpll() HSW/BDW specific
  drm/i915: Split the CDCLK retrieval per-platform
  drm/i915: Make ddi_clock_gate() HSW/BDW specific

 drivers/gpu/drm/i915/i915_drv.h      |   3 +
 drivers/gpu/drm/i915/intel_ddi.c     | 124 +++++++++++++++++++++++------------
 drivers/gpu/drm/i915/intel_display.c |  29 ++++----
 drivers/gpu/drm/i915/intel_dp.c      |   2 +-
 4 files changed, 105 insertions(+), 53 deletions(-)

-- 
1.8.3.1

^ permalink raw reply	[flat|nested] 13+ messages in thread

* [PATCH 01/10] drm/i915: Specify when the PLL hw state fields are valid
  2014-07-29 17:06 [PATCH 00/10] Split the HSW/BDW PLL code a bit more Damien Lespiau
@ 2014-07-29 17:06 ` Damien Lespiau
  2014-07-29 17:06 ` [PATCH 02/10] drm/i915: Add a space to the shared DPLL debug message Damien Lespiau
                   ` (9 subsequent siblings)
  10 siblings, 0 replies; 13+ messages in thread
From: Damien Lespiau @ 2014-07-29 17:06 UTC (permalink / raw)
  To: intel-gfx

Not all those fields are valid on a given platform. Make it explicit.

Unions could also be used, but were cluttering some code paths with
if/else ladders.

v2: Don't use anonymous unions (Daniel)

Signed-off-by: Damien Lespiau <damien.lespiau@intel.com>
---
 drivers/gpu/drm/i915/i915_drv.h | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
index ef38c3b..d604f4f 100644
--- a/drivers/gpu/drm/i915/i915_drv.h
+++ b/drivers/gpu/drm/i915/i915_drv.h
@@ -197,10 +197,13 @@ enum intel_dpll_id {
 #define I915_NUM_PLLS 2
 
 struct intel_dpll_hw_state {
+	/* i9xx, pch plls */
 	uint32_t dpll;
 	uint32_t dpll_md;
 	uint32_t fp0;
 	uint32_t fp1;
+
+	/* hsw, bdw */
 	uint32_t wrpll;
 };
 
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH 02/10] drm/i915: Add a space to the shared DPLL debug message
  2014-07-29 17:06 [PATCH 00/10] Split the HSW/BDW PLL code a bit more Damien Lespiau
  2014-07-29 17:06 ` [PATCH 01/10] drm/i915: Specify when the PLL hw state fields are valid Damien Lespiau
@ 2014-07-29 17:06 ` Damien Lespiau
  2014-07-29 17:06 ` [PATCH 03/10] drm/i915: Extract the HSW DDI selection code into its own function Damien Lespiau
                   ` (8 subsequent siblings)
  10 siblings, 0 replies; 13+ messages in thread
From: Damien Lespiau @ 2014-07-29 17:06 UTC (permalink / raw)
  To: intel-gfx

Signed-off-by: Damien Lespiau <damien.lespiau@intel.com>
---
 drivers/gpu/drm/i915/intel_display.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c
index 1edfd1a..0147652 100644
--- a/drivers/gpu/drm/i915/intel_display.c
+++ b/drivers/gpu/drm/i915/intel_display.c
@@ -1778,7 +1778,7 @@ static void intel_enable_shared_dpll(struct intel_crtc *crtc)
 	if (WARN_ON(pll->refcount == 0))
 		return;
 
-	DRM_DEBUG_KMS("enable %s (active %d, on? %d)for crtc %d\n",
+	DRM_DEBUG_KMS("enable %s (active %d, on? %d) for crtc %d\n",
 		      pll->name, pll->active, pll->on,
 		      crtc->base.base.id);
 
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH 03/10] drm/i915: Extract the HSW DDI selection code into its own function
  2014-07-29 17:06 [PATCH 00/10] Split the HSW/BDW PLL code a bit more Damien Lespiau
  2014-07-29 17:06 ` [PATCH 01/10] drm/i915: Specify when the PLL hw state fields are valid Damien Lespiau
  2014-07-29 17:06 ` [PATCH 02/10] drm/i915: Add a space to the shared DPLL debug message Damien Lespiau
@ 2014-07-29 17:06 ` Damien Lespiau
  2014-07-29 17:06 ` [PATCH 04/10] drm/i915: Extract the HSW/BDW shared dpll init code Damien Lespiau
                   ` (7 subsequent siblings)
  10 siblings, 0 replies; 13+ messages in thread
From: Damien Lespiau @ 2014-07-29 17:06 UTC (permalink / raw)
  To: intel-gfx

Future platform will slightly change that.

Signed-off-by: Damien Lespiau <damien.lespiau@intel.com>
---
 drivers/gpu/drm/i915/intel_display.c | 27 +++++++++++++++++----------
 1 file changed, 17 insertions(+), 10 deletions(-)

diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c
index 0147652..5678c68 100644
--- a/drivers/gpu/drm/i915/intel_display.c
+++ b/drivers/gpu/drm/i915/intel_display.c
@@ -7573,6 +7573,22 @@ static int haswell_crtc_mode_set(struct drm_crtc *crtc,
 	return 0;
 }
 
+static void haswell_get_ddi_pll(struct drm_i915_private *dev_priv,
+				enum port port,
+				struct intel_crtc_config *pipe_config)
+{
+	pipe_config->ddi_pll_sel = I915_READ(PORT_CLK_SEL(port));
+
+	switch (pipe_config->ddi_pll_sel) {
+	case PORT_CLK_SEL_WRPLL1:
+		pipe_config->shared_dpll = DPLL_ID_WRPLL1;
+		break;
+	case PORT_CLK_SEL_WRPLL2:
+		pipe_config->shared_dpll = DPLL_ID_WRPLL2;
+		break;
+	}
+}
+
 static void haswell_get_ddi_port_state(struct intel_crtc *crtc,
 				       struct intel_crtc_config *pipe_config)
 {
@@ -7586,16 +7602,7 @@ static void haswell_get_ddi_port_state(struct intel_crtc *crtc,
 
 	port = (tmp & TRANS_DDI_PORT_MASK) >> TRANS_DDI_PORT_SHIFT;
 
-	pipe_config->ddi_pll_sel = I915_READ(PORT_CLK_SEL(port));
-
-	switch (pipe_config->ddi_pll_sel) {
-	case PORT_CLK_SEL_WRPLL1:
-		pipe_config->shared_dpll = DPLL_ID_WRPLL1;
-		break;
-	case PORT_CLK_SEL_WRPLL2:
-		pipe_config->shared_dpll = DPLL_ID_WRPLL2;
-		break;
-	}
+	haswell_get_ddi_pll(dev_priv, port, pipe_config);
 
 	if (pipe_config->shared_dpll >= 0) {
 		pll = &dev_priv->shared_dplls[pipe_config->shared_dpll];
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH 04/10] drm/i915: Extract the HSW/BDW shared dpll init code
  2014-07-29 17:06 [PATCH 00/10] Split the HSW/BDW PLL code a bit more Damien Lespiau
                   ` (2 preceding siblings ...)
  2014-07-29 17:06 ` [PATCH 03/10] drm/i915: Extract the HSW DDI selection code into its own function Damien Lespiau
@ 2014-07-29 17:06 ` Damien Lespiau
  2014-07-29 17:06 ` [PATCH 05/10] drm/i915: Restrict hsw_dp_set_ddi_pll_sel() to HSW/BDW Damien Lespiau
                   ` (6 subsequent siblings)
  10 siblings, 0 replies; 13+ messages in thread
From: Damien Lespiau @ 2014-07-29 17:06 UTC (permalink / raw)
  To: intel-gfx

So we can easily provide an alternate implementation in the future.

Signed-off-by: Damien Lespiau <damien.lespiau@intel.com>
---
 drivers/gpu/drm/i915/intel_ddi.c | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/i915/intel_ddi.c b/drivers/gpu/drm/i915/intel_ddi.c
index 1848906..55d7dad 100644
--- a/drivers/gpu/drm/i915/intel_ddi.c
+++ b/drivers/gpu/drm/i915/intel_ddi.c
@@ -1248,10 +1248,8 @@ static const char * const hsw_ddi_pll_names[] = {
 	"WRPLL 2",
 };
 
-void intel_ddi_pll_init(struct drm_device *dev)
+static void hsw_shared_dplls_init(struct drm_i915_private *dev_priv)
 {
-	struct drm_i915_private *dev_priv = dev->dev_private;
-	uint32_t val = I915_READ(LCPLL_CTL);
 	int i;
 
 	dev_priv->num_shared_dpll = 2;
@@ -1264,6 +1262,14 @@ void intel_ddi_pll_init(struct drm_device *dev)
 		dev_priv->shared_dplls[i].get_hw_state =
 			hsw_ddi_pll_get_hw_state;
 	}
+}
+
+void intel_ddi_pll_init(struct drm_device *dev)
+{
+	struct drm_i915_private *dev_priv = dev->dev_private;
+	uint32_t val = I915_READ(LCPLL_CTL);
+
+	hsw_shared_dplls_init(dev_priv);
 
 	/* The LCPLL register should be turned on by the BIOS. For now let's
 	 * just check its state and print errors in case something is wrong.
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH 05/10] drm/i915: Restrict hsw_dp_set_ddi_pll_sel() to HSW/BDW
  2014-07-29 17:06 [PATCH 00/10] Split the HSW/BDW PLL code a bit more Damien Lespiau
                   ` (3 preceding siblings ...)
  2014-07-29 17:06 ` [PATCH 04/10] drm/i915: Extract the HSW/BDW shared dpll init code Damien Lespiau
@ 2014-07-29 17:06 ` Damien Lespiau
  2014-07-29 18:15   ` Daniel Vetter
  2014-07-29 17:06 ` [PATCH 06/10] drm/i915: Fix stale comment for intel_ddi_pll_select() Damien Lespiau
                   ` (5 subsequent siblings)
  10 siblings, 1 reply; 13+ messages in thread
From: Damien Lespiau @ 2014-07-29 17:06 UTC (permalink / raw)
  To: intel-gfx

Future platform will use config->ddi_pll_sel in a different way.

Signed-off-by: Damien Lespiau <damien.lespiau@intel.com>
---
 drivers/gpu/drm/i915/intel_dp.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/i915/intel_dp.c b/drivers/gpu/drm/i915/intel_dp.c
index ea6ff71..bdbe8f7 100644
--- a/drivers/gpu/drm/i915/intel_dp.c
+++ b/drivers/gpu/drm/i915/intel_dp.c
@@ -976,7 +976,7 @@ found:
 				&pipe_config->dp_m2_n2);
 	}
 
-	if (HAS_DDI(dev))
+	if (IS_HASWELL(dev) || IS_BROADWELL(dev))
 		hsw_dp_set_ddi_pll_sel(pipe_config, intel_dp->link_bw);
 	else
 		intel_dp_set_clock(encoder, pipe_config, intel_dp->link_bw);
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH 06/10] drm/i915: Fix stale comment for intel_ddi_pll_select()
  2014-07-29 17:06 [PATCH 00/10] Split the HSW/BDW PLL code a bit more Damien Lespiau
                   ` (4 preceding siblings ...)
  2014-07-29 17:06 ` [PATCH 05/10] drm/i915: Restrict hsw_dp_set_ddi_pll_sel() to HSW/BDW Damien Lespiau
@ 2014-07-29 17:06 ` Damien Lespiau
  2014-07-29 17:06 ` [PATCH 07/10] drm/i915: Split the BDW/HSW specific shared pll selection Damien Lespiau
                   ` (4 subsequent siblings)
  10 siblings, 0 replies; 13+ messages in thread
From: Damien Lespiau @ 2014-07-29 17:06 UTC (permalink / raw)
  To: intel-gfx

Since the run-time PM on DPMS series, this function has an outdated
comment. Refresh it a bit.

Signed-off-by: Damien Lespiau <damien.lespiau@intel.com>
---
 drivers/gpu/drm/i915/intel_ddi.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/i915/intel_ddi.c b/drivers/gpu/drm/i915/intel_ddi.c
index 55d7dad..4012a7b 100644
--- a/drivers/gpu/drm/i915/intel_ddi.c
+++ b/drivers/gpu/drm/i915/intel_ddi.c
@@ -709,10 +709,11 @@ intel_ddi_calculate_wrpll(int clock /* in Hz */,
 }
 
 /*
- * Tries to find a PLL for the CRTC. If it finds, it increases the refcount and
- * stores it in intel_crtc->ddi_pll_sel, so other mode sets won't be able to
- * steal the selected PLL. You need to call intel_ddi_pll_enable to actually
- * enable the PLL.
+ * Tries to find a *shared* PLL for the CRTC and store it in
+ * intel_crtc->ddi_pll_sel.
+ *
+ * For private DPLLs, compute_config() should do the selection for us. This
+ * function should be folded into compute_config() eventually.
  */
 bool intel_ddi_pll_select(struct intel_crtc *intel_crtc)
 {
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH 07/10] drm/i915: Split the BDW/HSW specific shared pll selection
  2014-07-29 17:06 [PATCH 00/10] Split the HSW/BDW PLL code a bit more Damien Lespiau
                   ` (5 preceding siblings ...)
  2014-07-29 17:06 ` [PATCH 06/10] drm/i915: Fix stale comment for intel_ddi_pll_select() Damien Lespiau
@ 2014-07-29 17:06 ` Damien Lespiau
  2014-07-29 17:06 ` [PATCH 08/10] drm/i915: Make intel_ddi_calculate_wrpll() HSW/BDW specific Damien Lespiau
                   ` (3 subsequent siblings)
  10 siblings, 0 replies; 13+ messages in thread
From: Damien Lespiau @ 2014-07-29 17:06 UTC (permalink / raw)
  To: intel-gfx

We'll need a different algorithm to select the shared DPLL.

Signed-off-by: Damien Lespiau <damien.lespiau@intel.com>
---
 drivers/gpu/drm/i915/intel_ddi.c | 39 +++++++++++++++++++++++----------------
 1 file changed, 23 insertions(+), 16 deletions(-)

diff --git a/drivers/gpu/drm/i915/intel_ddi.c b/drivers/gpu/drm/i915/intel_ddi.c
index 4012a7b..98e2fd5 100644
--- a/drivers/gpu/drm/i915/intel_ddi.c
+++ b/drivers/gpu/drm/i915/intel_ddi.c
@@ -708,23 +708,10 @@ intel_ddi_calculate_wrpll(int clock /* in Hz */,
 	*r2_out = best.r2;
 }
 
-/*
- * Tries to find a *shared* PLL for the CRTC and store it in
- * intel_crtc->ddi_pll_sel.
- *
- * For private DPLLs, compute_config() should do the selection for us. This
- * function should be folded into compute_config() eventually.
- */
-bool intel_ddi_pll_select(struct intel_crtc *intel_crtc)
+static bool
+hsw_ddi_pll_select(struct intel_crtc *intel_crtc, int output, int clock)
 {
-	struct drm_crtc *crtc = &intel_crtc->base;
-	struct intel_encoder *intel_encoder = intel_ddi_get_crtc_encoder(crtc);
-	int type = intel_encoder->type;
-	int clock = intel_crtc->config.port_clock;
-
-	intel_put_shared_dpll(intel_crtc);
-
-	if (type == INTEL_OUTPUT_HDMI) {
+	if (output == INTEL_OUTPUT_HDMI) {
 		struct intel_shared_dpll *pll;
 		uint32_t val;
 		unsigned p, n2, r2;
@@ -750,6 +737,26 @@ bool intel_ddi_pll_select(struct intel_crtc *intel_crtc)
 	return true;
 }
 
+
+/*
+ * Tries to find a *shared* PLL for the CRTC and store it in
+ * intel_crtc->ddi_pll_sel.
+ *
+ * For private DPLLs, compute_config() should do the selection for us. This
+ * function should be folded into compute_config() eventually.
+ */
+bool intel_ddi_pll_select(struct intel_crtc *intel_crtc)
+{
+	struct drm_crtc *crtc = &intel_crtc->base;
+	struct intel_encoder *intel_encoder = intel_ddi_get_crtc_encoder(crtc);
+	int type = intel_encoder->type;
+	int clock = intel_crtc->config.port_clock;
+
+	intel_put_shared_dpll(intel_crtc);
+
+	return hsw_ddi_pll_select(intel_crtc, type, clock);
+}
+
 void intel_ddi_set_pipe_settings(struct drm_crtc *crtc)
 {
 	struct drm_i915_private *dev_priv = crtc->dev->dev_private;
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH 08/10] drm/i915: Make intel_ddi_calculate_wrpll() HSW/BDW specific
  2014-07-29 17:06 [PATCH 00/10] Split the HSW/BDW PLL code a bit more Damien Lespiau
                   ` (6 preceding siblings ...)
  2014-07-29 17:06 ` [PATCH 07/10] drm/i915: Split the BDW/HSW specific shared pll selection Damien Lespiau
@ 2014-07-29 17:06 ` Damien Lespiau
  2014-07-29 17:06 ` [PATCH 09/10] drm/i915: Split the CDCLK retrieval per-platform Damien Lespiau
                   ` (2 subsequent siblings)
  10 siblings, 0 replies; 13+ messages in thread
From: Damien Lespiau @ 2014-07-29 17:06 UTC (permalink / raw)
  To: intel-gfx

Signed-off-by: Damien Lespiau <damien.lespiau@intel.com>
---
 drivers/gpu/drm/i915/intel_ddi.c | 15 ++++++++-------
 1 file changed, 8 insertions(+), 7 deletions(-)

diff --git a/drivers/gpu/drm/i915/intel_ddi.c b/drivers/gpu/drm/i915/intel_ddi.c
index 98e2fd5..69dc54c 100644
--- a/drivers/gpu/drm/i915/intel_ddi.c
+++ b/drivers/gpu/drm/i915/intel_ddi.c
@@ -644,8 +644,8 @@ void intel_ddi_clock_get(struct intel_encoder *encoder,
 }
 
 static void
-intel_ddi_calculate_wrpll(int clock /* in Hz */,
-			  unsigned *r2_out, unsigned *n2_out, unsigned *p_out)
+hsw_ddi_calculate_wrpll(int clock /* in Hz */,
+			unsigned *r2_out, unsigned *n2_out, unsigned *p_out)
 {
 	uint64_t freq2k;
 	unsigned p, n2, r2;
@@ -709,14 +709,16 @@ intel_ddi_calculate_wrpll(int clock /* in Hz */,
 }
 
 static bool
-hsw_ddi_pll_select(struct intel_crtc *intel_crtc, int output, int clock)
+hsw_ddi_pll_select(struct intel_crtc *intel_crtc,
+		   struct intel_encoder *intel_encoder,
+		   int clock)
 {
-	if (output == INTEL_OUTPUT_HDMI) {
+	if (intel_encoder->type == INTEL_OUTPUT_HDMI) {
 		struct intel_shared_dpll *pll;
 		uint32_t val;
 		unsigned p, n2, r2;
 
-		intel_ddi_calculate_wrpll(clock * 1000, &r2, &n2, &p);
+		hsw_ddi_calculate_wrpll(clock * 1000, &r2, &n2, &p);
 
 		val = WRPLL_PLL_ENABLE | WRPLL_PLL_LCPLL |
 		      WRPLL_DIVIDER_REFERENCE(r2) | WRPLL_DIVIDER_FEEDBACK(n2) |
@@ -749,12 +751,11 @@ bool intel_ddi_pll_select(struct intel_crtc *intel_crtc)
 {
 	struct drm_crtc *crtc = &intel_crtc->base;
 	struct intel_encoder *intel_encoder = intel_ddi_get_crtc_encoder(crtc);
-	int type = intel_encoder->type;
 	int clock = intel_crtc->config.port_clock;
 
 	intel_put_shared_dpll(intel_crtc);
 
-	return hsw_ddi_pll_select(intel_crtc, type, clock);
+	return hsw_ddi_pll_select(intel_crtc, intel_encoder, clock);
 }
 
 void intel_ddi_set_pipe_settings(struct drm_crtc *crtc)
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH 09/10] drm/i915: Split the CDCLK retrieval per-platform
  2014-07-29 17:06 [PATCH 00/10] Split the HSW/BDW PLL code a bit more Damien Lespiau
                   ` (7 preceding siblings ...)
  2014-07-29 17:06 ` [PATCH 08/10] drm/i915: Make intel_ddi_calculate_wrpll() HSW/BDW specific Damien Lespiau
@ 2014-07-29 17:06 ` Damien Lespiau
  2014-07-29 17:06 ` [PATCH 10/10] drm/i915: Make ddi_clock_gate() HSW/BDW specific Damien Lespiau
  2014-07-29 18:20 ` [PATCH 00/10] Split the HSW/BDW PLL code a bit more Daniel Vetter
  10 siblings, 0 replies; 13+ messages in thread
From: Damien Lespiau @ 2014-07-29 17:06 UTC (permalink / raw)
  To: intel-gfx

This is only going to get worse, so split it now to avoid adding more
cases to the if/else ladder.

Suggested-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Signed-off-by: Damien Lespiau <damien.lespiau@intel.com>
---
 drivers/gpu/drm/i915/intel_ddi.c | 55 +++++++++++++++++++++++++++-------------
 1 file changed, 38 insertions(+), 17 deletions(-)

diff --git a/drivers/gpu/drm/i915/intel_ddi.c b/drivers/gpu/drm/i915/intel_ddi.c
index 69dc54c..2aad888 100644
--- a/drivers/gpu/drm/i915/intel_ddi.c
+++ b/drivers/gpu/drm/i915/intel_ddi.c
@@ -1192,31 +1192,52 @@ static void intel_disable_ddi(struct intel_encoder *intel_encoder)
 	}
 }
 
-int intel_ddi_get_cdclk_freq(struct drm_i915_private *dev_priv)
+static int bdw_get_cdclk_freq(struct drm_i915_private *dev_priv)
+{
+	uint32_t lcpll = I915_READ(LCPLL_CTL);
+	uint32_t freq = lcpll & LCPLL_CLK_FREQ_MASK;
+
+	if (lcpll & LCPLL_CD_SOURCE_FCLK)
+		return 800000;
+	else if (I915_READ(FUSE_STRAP) & HSW_CDCLK_LIMIT)
+		return 450000;
+	else if (freq == LCPLL_CLK_FREQ_450)
+		return 450000;
+	else if (freq == LCPLL_CLK_FREQ_54O_BDW)
+		return 540000;
+	else if (freq == LCPLL_CLK_FREQ_337_5_BDW)
+		return 337500;
+	else
+		return 675000;
+}
+
+static int hsw_get_cdclk_freq(struct drm_i915_private *dev_priv)
 {
 	struct drm_device *dev = dev_priv->dev;
 	uint32_t lcpll = I915_READ(LCPLL_CTL);
 	uint32_t freq = lcpll & LCPLL_CLK_FREQ_MASK;
 
-	if (lcpll & LCPLL_CD_SOURCE_FCLK) {
+	if (lcpll & LCPLL_CD_SOURCE_FCLK)
 		return 800000;
-	} else if (I915_READ(FUSE_STRAP) & HSW_CDCLK_LIMIT) {
+	else if (I915_READ(FUSE_STRAP) & HSW_CDCLK_LIMIT)
 		return 450000;
-	} else if (freq == LCPLL_CLK_FREQ_450) {
+	else if (freq == LCPLL_CLK_FREQ_450)
 		return 450000;
-	} else if (IS_HASWELL(dev)) {
-		if (IS_ULT(dev))
-			return 337500;
-		else
-			return 540000;
-	} else {
-		if (freq == LCPLL_CLK_FREQ_54O_BDW)
-			return 540000;
-		else if (freq == LCPLL_CLK_FREQ_337_5_BDW)
-			return 337500;
-		else
-			return 675000;
-	}
+	else if (IS_ULT(dev))
+		return 337500;
+	else
+		return 540000;
+}
+
+int intel_ddi_get_cdclk_freq(struct drm_i915_private *dev_priv)
+{
+	struct drm_device *dev = dev_priv->dev;
+
+	if (IS_BROADWELL(dev))
+		return bdw_get_cdclk_freq(dev_priv);
+
+	/* Haswell */
+	return hsw_get_cdclk_freq(dev_priv);
 }
 
 static void hsw_ddi_pll_enable(struct drm_i915_private *dev_priv,
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH 10/10] drm/i915: Make ddi_clock_gate() HSW/BDW specific
  2014-07-29 17:06 [PATCH 00/10] Split the HSW/BDW PLL code a bit more Damien Lespiau
                   ` (8 preceding siblings ...)
  2014-07-29 17:06 ` [PATCH 09/10] drm/i915: Split the CDCLK retrieval per-platform Damien Lespiau
@ 2014-07-29 17:06 ` Damien Lespiau
  2014-07-29 18:20 ` [PATCH 00/10] Split the HSW/BDW PLL code a bit more Daniel Vetter
  10 siblings, 0 replies; 13+ messages in thread
From: Damien Lespiau @ 2014-07-29 17:06 UTC (permalink / raw)
  To: intel-gfx

Turns out we were again way too naive and optimistic, of course things
will change.

Signed-off-by: Damien Lespiau <damien.lespiau@intel.com>
---
 drivers/gpu/drm/i915/intel_ddi.c | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/i915/intel_ddi.c b/drivers/gpu/drm/i915/intel_ddi.c
index 2aad888..a6024de 100644
--- a/drivers/gpu/drm/i915/intel_ddi.c
+++ b/drivers/gpu/drm/i915/intel_ddi.c
@@ -587,8 +587,8 @@ static int intel_ddi_calc_wrpll_link(struct drm_i915_private *dev_priv,
 	return (refclk * n * 100) / (p * r);
 }
 
-void intel_ddi_clock_get(struct intel_encoder *encoder,
-			 struct intel_crtc_config *pipe_config)
+static void hsw_ddi_clock_get(struct intel_encoder *encoder,
+			      struct intel_crtc_config *pipe_config)
 {
 	struct drm_i915_private *dev_priv = encoder->base.dev->dev_private;
 	int link_clock = 0;
@@ -643,6 +643,12 @@ void intel_ddi_clock_get(struct intel_encoder *encoder,
 		pipe_config->adjusted_mode.crtc_clock = pipe_config->port_clock;
 }
 
+void intel_ddi_clock_get(struct intel_encoder *encoder,
+			 struct intel_crtc_config *pipe_config)
+{
+	hsw_ddi_clock_get(encoder, pipe_config);
+}
+
 static void
 hsw_ddi_calculate_wrpll(int clock /* in Hz */,
 			unsigned *r2_out, unsigned *n2_out, unsigned *p_out)
@@ -1480,7 +1486,7 @@ void intel_ddi_get_config(struct intel_encoder *encoder,
 		dev_priv->vbt.edp_bpp = pipe_config->pipe_bpp;
 	}
 
-	intel_ddi_clock_get(encoder, pipe_config);
+	hsw_ddi_clock_get(encoder, pipe_config);
 }
 
 static void intel_ddi_destroy(struct drm_encoder *encoder)
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 13+ messages in thread

* Re: [PATCH 05/10] drm/i915: Restrict hsw_dp_set_ddi_pll_sel() to HSW/BDW
  2014-07-29 17:06 ` [PATCH 05/10] drm/i915: Restrict hsw_dp_set_ddi_pll_sel() to HSW/BDW Damien Lespiau
@ 2014-07-29 18:15   ` Daniel Vetter
  0 siblings, 0 replies; 13+ messages in thread
From: Daniel Vetter @ 2014-07-29 18:15 UTC (permalink / raw)
  To: Damien Lespiau; +Cc: intel-gfx

On Tue, Jul 29, 2014 at 06:06:20PM +0100, Damien Lespiau wrote:
> Future platform will use config->ddi_pll_sel in a different way.
> 
> Signed-off-by: Damien Lespiau <damien.lespiau@intel.com>
> ---
>  drivers/gpu/drm/i915/intel_dp.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/gpu/drm/i915/intel_dp.c b/drivers/gpu/drm/i915/intel_dp.c
> index ea6ff71..bdbe8f7 100644
> --- a/drivers/gpu/drm/i915/intel_dp.c
> +++ b/drivers/gpu/drm/i915/intel_dp.c
> @@ -976,7 +976,7 @@ found:
>  				&pipe_config->dp_m2_n2);
>  	}
>  
> -	if (HAS_DDI(dev))
> +	if (IS_HASWELL(dev) || IS_BROADWELL(dev))
>  		hsw_dp_set_ddi_pll_sel(pipe_config, intel_dp->link_bw);
>  	else
>  		intel_dp_set_clock(encoder, pipe_config, intel_dp->link_bw);

We could do an s/intel/gmch/ here too ... Or g4x.
-Daniel

> -- 
> 1.8.3.1
> 
> _______________________________________________
> Intel-gfx mailing list
> Intel-gfx@lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/intel-gfx

-- 
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH 00/10] Split the HSW/BDW PLL code a bit more
  2014-07-29 17:06 [PATCH 00/10] Split the HSW/BDW PLL code a bit more Damien Lespiau
                   ` (9 preceding siblings ...)
  2014-07-29 17:06 ` [PATCH 10/10] drm/i915: Make ddi_clock_gate() HSW/BDW specific Damien Lespiau
@ 2014-07-29 18:20 ` Daniel Vetter
  10 siblings, 0 replies; 13+ messages in thread
From: Daniel Vetter @ 2014-07-29 18:20 UTC (permalink / raw)
  To: Damien Lespiau; +Cc: intel-gfx

On Tue, Jul 29, 2014 at 06:06:15PM +0100, Damien Lespiau wrote:
> Turns out we were optimistic. intel_ prefixes don't tend to last and this is
> one of those times.

Pulled in the entire series to dinq, thanks.
-Daniel

> 
> -- 
> Damien
> 
> Damien Lespiau (10):
>   drm/i915: Specify when the PLL hw state fields are valid
>   drm/i915: Add a space to the shared DPLL debug message
>   drm/i915: Extract the HSW DDI selection code into its own function
>   drm/i915: Extract the HSW/BDW shared dpll init code
>   drm/i915: Restrict hsw_dp_set_ddi_pll_sel() to HSW/BDW
>   drm/i915: Fix stale comment for intel_ddi_pll_select()
>   drm/i915: Split the BDW/HSW specific shared pll selection
>   drm/i915: Make intel_ddi_calculate_wrpll() HSW/BDW specific
>   drm/i915: Split the CDCLK retrieval per-platform
>   drm/i915: Make ddi_clock_gate() HSW/BDW specific
> 
>  drivers/gpu/drm/i915/i915_drv.h      |   3 +
>  drivers/gpu/drm/i915/intel_ddi.c     | 124 +++++++++++++++++++++++------------
>  drivers/gpu/drm/i915/intel_display.c |  29 ++++----
>  drivers/gpu/drm/i915/intel_dp.c      |   2 +-
>  4 files changed, 105 insertions(+), 53 deletions(-)
> 
> -- 
> 1.8.3.1
> 
> _______________________________________________
> Intel-gfx mailing list
> Intel-gfx@lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/intel-gfx

-- 
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch

^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2014-07-29 18:20 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-07-29 17:06 [PATCH 00/10] Split the HSW/BDW PLL code a bit more Damien Lespiau
2014-07-29 17:06 ` [PATCH 01/10] drm/i915: Specify when the PLL hw state fields are valid Damien Lespiau
2014-07-29 17:06 ` [PATCH 02/10] drm/i915: Add a space to the shared DPLL debug message Damien Lespiau
2014-07-29 17:06 ` [PATCH 03/10] drm/i915: Extract the HSW DDI selection code into its own function Damien Lespiau
2014-07-29 17:06 ` [PATCH 04/10] drm/i915: Extract the HSW/BDW shared dpll init code Damien Lespiau
2014-07-29 17:06 ` [PATCH 05/10] drm/i915: Restrict hsw_dp_set_ddi_pll_sel() to HSW/BDW Damien Lespiau
2014-07-29 18:15   ` Daniel Vetter
2014-07-29 17:06 ` [PATCH 06/10] drm/i915: Fix stale comment for intel_ddi_pll_select() Damien Lespiau
2014-07-29 17:06 ` [PATCH 07/10] drm/i915: Split the BDW/HSW specific shared pll selection Damien Lespiau
2014-07-29 17:06 ` [PATCH 08/10] drm/i915: Make intel_ddi_calculate_wrpll() HSW/BDW specific Damien Lespiau
2014-07-29 17:06 ` [PATCH 09/10] drm/i915: Split the CDCLK retrieval per-platform Damien Lespiau
2014-07-29 17:06 ` [PATCH 10/10] drm/i915: Make ddi_clock_gate() HSW/BDW specific Damien Lespiau
2014-07-29 18:20 ` [PATCH 00/10] Split the HSW/BDW PLL code a bit more Daniel Vetter

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox