[Intel-gfx] [PATCH 08/19] drm/i915: manual FDI training for Ivy Bridge

2011-04-28 Thread Jesse Barnes
A0 stepping chips need to use manual training, but the bits have all
moved.  So fix things up so we can at least train FDI for VGA links.

Signed-off-by: Jesse Barnes jbar...@virtuousgeek.org
---
 drivers/gpu/drm/i915/i915_reg.h  |   10 +++
 drivers/gpu/drm/i915/intel_display.c |  128 +-
 2 files changed, 135 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/i915/i915_reg.h b/drivers/gpu/drm/i915/i915_reg.h
index 8848411..aba3fe5 100644
--- a/drivers/gpu/drm/i915/i915_reg.h
+++ b/drivers/gpu/drm/i915/i915_reg.h
@@ -3105,7 +3105,15 @@
 #define  FDI_TX_ENHANCE_FRAME_ENABLE(118)
 /* Ironlake: hardwired to 1 */
 #define  FDI_TX_PLL_ENABLE  (114)
+
+/* Ivybridge has different bits for lolz */
+#define  FDI_LINK_TRAIN_PATTERN_1_IVB   (08)
+#define  FDI_LINK_TRAIN_PATTERN_2_IVB   (18)
+#define  FDI_LINK_TRAIN_PATTERN_IDLE_IVB(28)
+#define  FDI_LINK_TRAIN_NONE_IVB(38)
+
 /* both Tx and Rx */
+#define  FDI_LINK_TRAIN_AUTO   (110)
 #define  FDI_SCRAMBLING_ENABLE  (07)
 #define  FDI_SCRAMBLING_DISABLE (17)
 
@@ -3115,6 +3123,8 @@
 #define FDI_RX_CTL(pipe) _PIPE(pipe, _FDI_RXA_CTL, _FDI_RXB_CTL)
 #define  FDI_RX_ENABLE  (131)
 /* train, dp width same as FDI_TX */
+#define  FDI_FS_ERRC_ENABLE(127)
+#define  FDI_FE_ERRC_ENABLE(126)
 #define  FDI_DP_PORT_WIDTH_X8   (719)
 #define  FDI_8BPC   (016)
 #define  FDI_10BPC  (116)
diff --git a/drivers/gpu/drm/i915/intel_display.c 
b/drivers/gpu/drm/i915/intel_display.c
index 0dadc8e..ab840a6 100644
--- a/drivers/gpu/drm/i915/intel_display.c
+++ b/drivers/gpu/drm/i915/intel_display.c
@@ -2047,8 +2047,13 @@ static void intel_fdi_normal_train(struct drm_crtc *crtc)
/* enable normal train */
reg = FDI_TX_CTL(pipe);
temp = I915_READ(reg);
-   temp = ~FDI_LINK_TRAIN_NONE;
-   temp |= FDI_LINK_TRAIN_NONE | FDI_TX_ENHANCE_FRAME_ENABLE;
+   if (IS_GEN6(dev)) {
+   temp = ~FDI_LINK_TRAIN_NONE;
+   temp |= FDI_LINK_TRAIN_NONE | FDI_TX_ENHANCE_FRAME_ENABLE;
+   } else if (IS_IVYBRIDGE(dev)) {
+   temp = ~FDI_LINK_TRAIN_NONE_IVB;
+   temp |= FDI_LINK_TRAIN_NONE_IVB | FDI_TX_ENHANCE_FRAME_ENABLE;
+   }
I915_WRITE(reg, temp);
 
reg = FDI_RX_CTL(pipe);
@@ -2065,6 +2070,11 @@ static void intel_fdi_normal_train(struct drm_crtc *crtc)
/* wait one idle pattern time */
POSTING_READ(reg);
udelay(1000);
+
+   /* IVB wants error correction enabled */
+   if (IS_IVYBRIDGE(dev))
+   I915_WRITE(reg, I915_READ(reg) | FDI_FS_ERRC_ENABLE |
+  FDI_FE_ERRC_ENABLE);
 }
 
 /* The FDI link training functions for ILK/Ibexpeak. */
@@ -2292,7 +2302,116 @@ static void gen6_fdi_link_train(struct drm_crtc *crtc)
DRM_DEBUG_KMS(FDI train done.\n);
 }
 
-static void ironlake_fdi_enable(struct drm_crtc *crtc)
+/* Manual link training for Ivy Bridge A0 parts */
+static void ivb_manual_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;
+
+   /* Train 1: umask FDI RX Interrupt symbol_lock and bit_lock bit
+  for train result */
+   reg = FDI_RX_IMR(pipe);
+   temp = I915_READ(reg);
+   temp = ~FDI_RX_SYMBOL_LOCK;
+   temp = ~FDI_RX_BIT_LOCK;
+   I915_WRITE(reg, temp);
+
+   POSTING_READ(reg);
+   udelay(150);
+
+   /* enable CPU FDI TX and PCH FDI RX */
+   reg = FDI_TX_CTL(pipe);
+   temp = I915_READ(reg);
+   temp = ~(7  19);
+   temp |= (intel_crtc-fdi_lanes - 1)  19;
+   temp = ~(FDI_LINK_TRAIN_AUTO | FDI_LINK_TRAIN_NONE_IVB);
+   temp |= FDI_LINK_TRAIN_PATTERN_1_IVB;
+   temp = ~FDI_LINK_TRAIN_VOL_EMP_MASK;
+   temp |= FDI_LINK_TRAIN_400MV_0DB_SNB_B;
+   I915_WRITE(reg, temp | FDI_TX_ENABLE);
+
+   reg = FDI_RX_CTL(pipe);
+   temp = I915_READ(reg);
+   temp = ~FDI_LINK_TRAIN_AUTO;
+   temp = ~FDI_LINK_TRAIN_PATTERN_MASK_CPT;
+   temp |= FDI_LINK_TRAIN_PATTERN_1_CPT;
+   I915_WRITE(reg, temp | FDI_RX_ENABLE);
+
+   POSTING_READ(reg);
+   udelay(150);
+
+   for (i = 0; i  4; i++ ) {
+   reg = FDI_TX_CTL(pipe);
+   temp = I915_READ(reg);
+   temp = ~FDI_LINK_TRAIN_VOL_EMP_MASK;
+   temp |= snb_b_fdi_train_param[i];
+   I915_WRITE(reg, temp);
+
+   POSTING_READ(reg);
+   udelay(500);
+
+   reg = FDI_RX_IIR(pipe);
+   temp = I915_READ(reg);
+   DRM_DEBUG_KMS(FDI_RX_IIR 0x%x\n, temp);
+
+   if (temp  FDI_RX_BIT_LOCK ||
+   (I915_READ(reg)  FDI_RX_BIT_LOCK)) {
+   

Re: [Intel-gfx] [PATCH 08/19] drm/i915: manual FDI training for Ivy Bridge

2011-04-28 Thread Keith Packard
On Thu, 28 Apr 2011 15:12:54 -0700, Jesse Barnes jbar...@virtuousgeek.org 
wrote:

 + if (IS_GEN6(dev)) {
 + temp = ~FDI_LINK_TRAIN_NONE;
 + temp |= FDI_LINK_TRAIN_NONE | FDI_TX_ENHANCE_FRAME_ENABLE;
 + } else if (IS_IVYBRIDGE(dev)) {
 + temp = ~FDI_LINK_TRAIN_NONE_IVB;
 + temp |= FDI_LINK_TRAIN_NONE_IVB | FDI_TX_ENHANCE_FRAME_ENABLE;
 + }

This seems inconsistent using IS_GEN6 for SNB and IS_IVYBRIDGE for IVB?

-- 
keith.pack...@intel.com


pgphLRgI1zdSN.pgp
Description: PGP signature
___
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx


Re: [Intel-gfx] [PATCH 08/19] drm/i915: manual FDI training for Ivy Bridge

2011-04-28 Thread Jesse Barnes
On Thu, 28 Apr 2011 15:43:10 -0700
Keith Packard kei...@keithp.com wrote:

 On Thu, 28 Apr 2011 15:12:54 -0700, Jesse Barnes jbar...@virtuousgeek.org 
 wrote:
 
  +   if (IS_GEN6(dev)) {
  +   temp = ~FDI_LINK_TRAIN_NONE;
  +   temp |= FDI_LINK_TRAIN_NONE | FDI_TX_ENHANCE_FRAME_ENABLE;
  +   } else if (IS_IVYBRIDGE(dev)) {
  +   temp = ~FDI_LINK_TRAIN_NONE_IVB;
  +   temp |= FDI_LINK_TRAIN_NONE_IVB | FDI_TX_ENHANCE_FRAME_ENABLE;
  +   }
 
 This seems inconsistent using IS_GEN6 for SNB and IS_IVYBRIDGE for IVB?

Yes, there are several IS_GEN checks that I'd argue are wrong, I can
clean them up in a subsequent.

-- 
Jesse Barnes, Intel Open Source Technology Center
___
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx