public inbox for intel-gfx@lists.freedesktop.org
 help / color / mirror / Atom feed
From: Eugeni Dodonov <eugeni.dodonov@intel.com>
To: intel-gfx@lists.freedesktop.org
Cc: Eugeni Dodonov <eugeni.dodonov@intel.com>
Subject: [PATCH 14/25] drm/i915: support DDI training in FDI mode
Date: Wed,  9 May 2012 15:37:21 -0300	[thread overview]
Message-ID: <1336588652-702-15-git-send-email-eugeni.dodonov@intel.com> (raw)
In-Reply-To: <1336588652-702-1-git-send-email-eugeni.dodonov@intel.com>

Starting with Haswell, DDI ports can work in FDI mode to support
connectivity with the outputs located on the PCH.

This commit adds support for such connections in the intel_ddi module, and
provides Haswell-specific functionality to make it work.

v2: simplify the commit as per Daniel Vetter suggestion.

Signed-off-by: Eugeni Dodonov <eugeni.dodonov@intel.com>
---
 drivers/gpu/drm/i915/intel_ddi.c     |  115 ++++++++++++++++++++++++++++++++++
 drivers/gpu/drm/i915/intel_display.c |    2 +
 drivers/gpu/drm/i915/intel_drv.h     |    1 +
 3 files changed, 118 insertions(+)

diff --git a/drivers/gpu/drm/i915/intel_ddi.c b/drivers/gpu/drm/i915/intel_ddi.c
index 08f210b..f44aae1 100644
--- a/drivers/gpu/drm/i915/intel_ddi.c
+++ b/drivers/gpu/drm/i915/intel_ddi.c
@@ -105,3 +105,118 @@ void intel_prepare_ddi(struct drm_device *dev)
 		intel_prepare_ddi_buffers(dev, PORT_E, true);
 	}
 }
+
+static const long hsw_ddi_buf_ctl_values[] = {
+	DDI_BUF_EMP_400MV_0DB_HSW,
+	DDI_BUF_EMP_400MV_3_5DB_HSW,
+	DDI_BUF_EMP_400MV_6DB_HSW,
+	DDI_BUF_EMP_400MV_9_5DB_HSW,
+	DDI_BUF_EMP_600MV_0DB_HSW,
+	DDI_BUF_EMP_600MV_3_5DB_HSW,
+	DDI_BUF_EMP_600MV_6DB_HSW,
+	DDI_BUF_EMP_800MV_0DB_HSW,
+	DDI_BUF_EMP_800MV_3_5DB_HSW
+};
+
+
+/* Starting with Haswell, different DDI ports can work in FDI mode for
+ * connection to the PCH-located connectors. For this, it is necessary to train
+ * both the DDI port and PCH receiver for the desired DDI buffer settings.
+ *
+ * The recommended port to work in FDI mode is DDI E, which we use here. Also,
+ * please note that when FDI mode is active on DDI E, it shares 2 lines with
+ * DDI A (which is used for eDP)
+ */
+
+void hsw_fdi_link_train(struct drm_crtc *crtc)
+{
+	struct drm_device *dev = crtc->dev;
+	struct drm_i915_private *dev_priv = dev->dev_private;
+	struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
+	int pipe = intel_crtc->pipe;
+	u32 reg, temp, i;
+
+	/* Configure CPU PLL, wait for warmup */
+	I915_WRITE(SPLL_CTL,
+			SPLL_PLL_ENABLE |
+			SPLL_PLL_FREQ_1350MHz |
+			SPLL_PLL_SCC);
+
+	/* Use SPLL to drive the output when in FDI mode */
+	I915_WRITE(PORT_CLK_SEL(PORT_E),
+			PORT_CLK_SEL_SPLL);
+	I915_WRITE(PIPE_CLK_SEL(pipe),
+			PIPE_CLK_SEL_PORT(PORT_E));
+
+	udelay(20);
+
+	/* Start the training iterating through available voltages and emphasis */
+	for (i=0; i < ARRAY_SIZE(hsw_ddi_buf_ctl_values); i++) {
+		/* Configure DP_TP_CTL with auto-training */
+		I915_WRITE(DP_TP_CTL(PORT_E),
+					DP_TP_CTL_FDI_AUTOTRAIN |
+					DP_TP_CTL_ENHANCED_FRAME_ENABLE |
+					DP_TP_CTL_LINK_TRAIN_PAT1 |
+					DP_TP_CTL_ENABLE);
+
+		/* Configure and enable DDI_BUF_CTL for DDI E with next voltage */
+		temp = I915_READ(DDI_BUF_CTL(PORT_E));
+		temp = (temp & ~DDI_BUF_EMP_MASK);
+		I915_WRITE(DDI_BUF_CTL(PORT_E),
+				temp |
+				DDI_BUF_CTL_ENABLE |
+				DDI_PORT_WIDTH_X2 |
+				hsw_ddi_buf_ctl_values[i]);
+
+		udelay(600);
+
+		/* Enable CPU FDI Receiver with auto-training */
+		reg = FDI_RX_CTL(pipe);
+		I915_WRITE(reg,
+				I915_READ(reg) |
+					FDI_LINK_TRAIN_AUTO |
+					FDI_RX_ENABLE |
+					FDI_LINK_TRAIN_PATTERN_1_CPT |
+					FDI_RX_ENHANCE_FRAME_ENABLE |
+					FDI_PORT_WIDTH_2X_LPT |
+					FDI_RX_PLL_ENABLE);
+		POSTING_READ(reg);
+		udelay(100);
+
+		temp = I915_READ(DP_TP_STATUS(PORT_E));
+		if (temp & DP_TP_STATUS_AUTOTRAIN_DONE) {
+			DRM_DEBUG_DRIVER("BUF_CTL training done on %d step\n", i);
+
+			/* Enable normal pixel sending for FDI */
+			I915_WRITE(DP_TP_CTL(PORT_E),
+						DP_TP_CTL_FDI_AUTOTRAIN |
+						DP_TP_CTL_LINK_TRAIN_NORMAL |
+						DP_TP_CTL_ENHANCED_FRAME_ENABLE |
+						DP_TP_CTL_ENABLE);
+
+			/* Enable PIPE_DDI_FUNC_CTL for the pipe to work in FDI mode */
+			temp = I915_READ(DDI_FUNC_CTL(pipe));
+			temp &= ~PIPE_DDI_PORT_MASK;
+			temp |= PIPE_DDI_SELECT_PORT(PORT_E) |
+					PIPE_DDI_MODE_SELECT_FDI |
+					PIPE_DDI_FUNC_ENABLE |
+					PIPE_DDI_PORT_WIDTH_X2;
+			I915_WRITE(DDI_FUNC_CTL(pipe),
+					temp);
+			break;
+		} else {
+			DRM_ERROR("Error training BUF_CTL %d\n", i);
+
+			/* Disable DP_TP_CTL and FDI_RX_CTL) and retry */
+			I915_WRITE(DP_TP_CTL(PORT_E),
+					I915_READ(DP_TP_CTL(PORT_E)) &
+						~DP_TP_CTL_ENABLE);
+			I915_WRITE(FDI_RX_CTL(pipe),
+					I915_READ(FDI_RX_CTL(pipe)) &
+						~FDI_RX_PLL_ENABLE);
+			continue;
+		}
+	}
+
+	DRM_DEBUG_KMS("FDI train done.\n");
+}
diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c
index 24b7b51..dbd8222 100644
--- a/drivers/gpu/drm/i915/intel_display.c
+++ b/drivers/gpu/drm/i915/intel_display.c
@@ -6603,6 +6603,8 @@ static void intel_init_display(struct drm_device *dev)
 			/* FIXME: detect B0+ stepping and use auto training */
 			dev_priv->display.fdi_link_train = ivb_manual_fdi_link_train;
 			dev_priv->display.write_eld = ironlake_write_eld;
+		} else if (IS_HASWELL(dev)) {
+			dev_priv->display.fdi_link_train = hsw_fdi_link_train;
 		} else
 			dev_priv->display.update_wm = NULL;
 	} else if (IS_VALLEYVIEW(dev)) {
diff --git a/drivers/gpu/drm/i915/intel_drv.h b/drivers/gpu/drm/i915/intel_drv.h
index e6ce02b..a5bb5b6 100644
--- a/drivers/gpu/drm/i915/intel_drv.h
+++ b/drivers/gpu/drm/i915/intel_drv.h
@@ -447,6 +447,7 @@ extern void intel_write_eld(struct drm_encoder *encoder,
 			    struct drm_display_mode *mode);
 extern void intel_cpt_verify_modeset(struct drm_device *dev, int pipe);
 extern void intel_prepare_ddi(struct drm_device *dev);
+extern void hsw_fdi_link_train(struct drm_crtc *crtc);
 
 /* For use by IVB LP watermark workaround in intel_sprite.c */
 extern void intel_update_watermarks(struct drm_device *dev);
-- 
1.7.10

  parent reply	other threads:[~2012-05-09 18:40 UTC|newest]

Thread overview: 39+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-05-09 18:37 [PATCH 00/25] Haswell fixes Eugeni Dodonov
2012-05-09 18:37 ` [PATCH 01/25] drm/i915: add new Haswell DIP controls registers Eugeni Dodonov
2012-05-10  0:34   ` Paulo Zanoni
2012-05-10  1:02     ` Eugeni Dodonov
2012-05-10  3:03       ` Paulo Zanoni
2012-05-10  8:32         ` Daniel Vetter
2012-05-10 13:18   ` Eugeni Dodonov
2012-05-09 18:37 ` [PATCH 02/25] drm/i915: reuse Ivy Bridge interrupts code for Haswell Eugeni Dodonov
2012-05-09 18:37 ` [PATCH 03/25] drm/i915: add support for SBI ops Eugeni Dodonov
2012-05-09 18:37 ` [PATCH 04/25] drm/i915: calculate watermarks for devices that have 3 pipes Eugeni Dodonov
2012-05-09 18:37 ` [PATCH 05/25] drm/i915: properly check for pipe count Eugeni Dodonov
2012-05-09 18:37 ` [PATCH 06/25] drm/i915: show unknown sdvox registers on hdmi init Eugeni Dodonov
2012-05-09 18:37 ` [PATCH 07/25] drm/i915: do not use fdi_normal_train on Haswell Eugeni Dodonov
2012-05-09 18:37 ` [PATCH 08/25] drm/i915: detect PCH encoders " Eugeni Dodonov
2012-05-09 21:46   ` Daniel Vetter
2012-05-09 23:30     ` Eugeni Dodonov
2012-05-09 18:37 ` [PATCH 09/25] drm/i915: enable power wells on Haswell init Eugeni Dodonov
2012-05-09 21:42   ` Daniel Vetter
2012-05-09 23:29     ` Eugeni Dodonov
2012-05-10 14:48       ` Daniel Vetter
2012-05-10 15:08         ` Eugeni Dodonov
2012-05-09 18:37 ` [PATCH 10/25] drm/i915: add LPT PCH checks Eugeni Dodonov
2012-05-09 18:37 ` [PATCH 11/25] drm/i915: handle DDI-related assertions Eugeni Dodonov
2012-05-09 18:37 ` [PATCH 12/25] drm/i915: account for only one PCH receiver on Haswell Eugeni Dodonov
2012-05-09 18:37 ` [PATCH 13/25] drm/i915: initialize DDI buffer translations Eugeni Dodonov
2012-05-09 18:37 ` Eugeni Dodonov [this message]
2012-05-09 18:37 ` [PATCH 15/25] drm/i915: use ironlake eld write routine for Haswell Eugeni Dodonov
2012-05-09 18:37 ` [PATCH 16/25] drm/i915: define Haswell watermarks and clock gating Eugeni Dodonov
2012-05-09 18:37 ` [PATCH 17/25] drm/i915: program WM_LINETIME on Haswell Eugeni Dodonov
2012-05-09 18:37 ` [PATCH 18/25] drm/i915: disable pipe DDI function when disabling pipe Eugeni Dodonov
2012-05-09 18:37 ` [PATCH 19/25] drm/i915: program iCLKIP on Lynx Point Eugeni Dodonov
2012-05-09 18:37 ` [PATCH 20/25] drm/i915: detect digital outputs on Haswell Eugeni Dodonov
2012-05-09 18:37 ` [PATCH 21/25] drm/i915: add support for DDI-controlled digital outputs Eugeni Dodonov
2012-05-09 18:37 ` [PATCH 22/25] drm/i915: add WR PLL programming table Eugeni Dodonov
2012-05-09 18:37 ` [PATCH 23/25] drm/i915: move HDMI structs to shared location Eugeni Dodonov
2012-05-09 22:05   ` Daniel Vetter
2012-05-09 18:37 ` [PATCH 24/25] drm/i915: prepare HDMI link for Haswell Eugeni Dodonov
2012-05-09 18:37 ` [PATCH 25/25] drm/i915: hook Haswell devices in place Eugeni Dodonov
2012-05-10 15:56   ` Daniel Vetter

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=1336588652-702-15-git-send-email-eugeni.dodonov@intel.com \
    --to=eugeni.dodonov@intel.com \
    --cc=intel-gfx@lists.freedesktop.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox