From patchwork Tue Aug 28 22:06:48 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paulo Zanoni X-Patchwork-Id: 1382851 Return-Path: X-Original-To: patchwork-intel-gfx@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by patchwork1.kernel.org (Postfix) with ESMTP id 117913FDF5 for ; Tue, 28 Aug 2012 22:19:52 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id D714B9E9C6 for ; Tue, 28 Aug 2012 15:19:51 -0700 (PDT) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mail-yx0-f177.google.com (mail-yx0-f177.google.com [209.85.213.177]) by gabe.freedesktop.org (Postfix) with ESMTP id A0BD29E73D for ; Tue, 28 Aug 2012 15:07:53 -0700 (PDT) Received: by mail-yx0-f177.google.com with SMTP id q9so1203648yen.36 for ; Tue, 28 Aug 2012 15:07:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references; bh=Wi1FxlV8AkuiSncZ2xI4s2ZARlXgKDV5XKZAbMKfBB8=; b=G4mzGkYpOlBzMA1vKmyqxa+Gt2vP2Z52Ls2T6yhd95TVpbHdjz7cmR9fnmFx5W6zHL 6aIAt99VeH+ObT9omlksb7FgfGjBbpns2pkWyEfO8wRjB56Onllc4sbaVdaX0dOmlZYC H/8Cy5hDkdQXFljAGDkPfiuhwq6No/tAq6v4euyxGmjzHInuc5AYL5CA+Zb4Vj/uan1P sEAV8IcuWvwTZd5PaRLsTOYZm+xDhQLMEqMDKcNzQ4exij6VbWGe5C4yimfE4aZ6xMbs xAf+layYL2eR8hHQcgl+X9TvU3Cac3nE4ziHZUBNT0F4YtjKXbO/ciS+lovYcHPqYXu1 fHcQ== Received: by 10.236.74.37 with SMTP id w25mr15818275yhd.30.1346191673571; Tue, 28 Aug 2012 15:07:53 -0700 (PDT) Received: from vicky.domain.invalid (189.114.178.236.dynamic.adsl.gvt.net.br. [189.114.178.236]) by mx.google.com with ESMTPS id z3sm4434172anj.20.2012.08.28.15.07.50 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 28 Aug 2012 15:07:52 -0700 (PDT) From: Paulo Zanoni To: intel-gfx@lists.freedesktop.org Date: Tue, 28 Aug 2012 19:06:48 -0300 Message-Id: <1346191621-12996-18-git-send-email-przanoni@gmail.com> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1346191621-12996-1-git-send-email-przanoni@gmail.com> References: <1346191621-12996-1-git-send-email-przanoni@gmail.com> Cc: Paulo Zanoni Subject: [Intel-gfx] [RFC 17/30] drm/i915: add intel_ddi_prepare_link_retrain X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: intel-gfx-bounces+patchwork-intel-gfx=patchwork.kernel.org@lists.freedesktop.org Errors-To: intel-gfx-bounces+patchwork-intel-gfx=patchwork.kernel.org@lists.freedesktop.org From: Paulo Zanoni In order to retrain the link we have to disable everything, then reenable. Signed-off-by: Paulo Zanoni --- drivers/gpu/drm/i915/intel_ddi.c | 43 ++++++++++++++++++++++++++++++++++++++++ drivers/gpu/drm/i915/intel_dp.c | 17 +++++++++------- drivers/gpu/drm/i915/intel_drv.h | 1 + 3 files changed, 54 insertions(+), 7 deletions(-) diff --git a/drivers/gpu/drm/i915/intel_ddi.c b/drivers/gpu/drm/i915/intel_ddi.c index 151963e..ed38bb3 100644 --- a/drivers/gpu/drm/i915/intel_ddi.c +++ b/drivers/gpu/drm/i915/intel_ddi.c @@ -1125,3 +1125,46 @@ void intel_ddi_pll_init(struct drm_device *dev) if (lcpll_needs_change) I915_WRITE(LCPLL_CTL, lcpll_val); } + +static void intel_ddi_enable_dp_port(struct intel_encoder *intel_encoder) +{ + struct drm_device *dev = intel_encoder->base.dev; + struct drm_i915_private *dev_priv = dev->dev_private; + struct intel_dp *intel_dp = enc_to_intel_dp(&intel_encoder->base); + int port = intel_dp->port; + uint32_t tp_val; + + tp_val = DP_TP_CTL_ENABLE | DP_TP_CTL_MODE_SST | + DP_TP_CTL_LINK_TRAIN_PAT1 | DP_TP_CTL_SCRAMBLE_DISABLE; + if (intel_dp->link_configuration[1] & DP_LANE_COUNT_ENHANCED_FRAME_EN) + tp_val |= DP_TP_CTL_ENHANCED_FRAME_ENABLE; + I915_WRITE(DP_TP_CTL(port), tp_val); + POSTING_READ(DP_TP_CTL(port)); + + intel_dp->DP |= DDI_BUF_CTL_ENABLE; + I915_WRITE(DDI_BUF_CTL(port), intel_dp->DP); + POSTING_READ(DDI_BUF_CTL(port)); + + udelay(600); +} + +void intel_ddi_prepare_link_retrain(struct drm_encoder *encoder) +{ + struct intel_encoder *intel_encoder = to_intel_encoder(encoder); + struct drm_crtc *crtc = encoder->crtc; + struct drm_crtc_helper_funcs *crtc_funcs; + + if (!crtc) { + WARN(1, "Retraining encoder without crtc\n"); + return; + } + + crtc_funcs = crtc->helper_private; + + intel_ddi_disable(encoder); + + intel_ddi_pll_mode_set(crtc); + intel_ddi_enable_dp_port(intel_encoder); + intel_ddi_enable_pipe(intel_encoder); + (*crtc_funcs->dpms)(crtc, DRM_MODE_DPMS_ON); +} diff --git a/drivers/gpu/drm/i915/intel_dp.c b/drivers/gpu/drm/i915/intel_dp.c index e59d676..1feeac5 100644 --- a/drivers/gpu/drm/i915/intel_dp.c +++ b/drivers/gpu/drm/i915/intel_dp.c @@ -1813,7 +1813,8 @@ intel_dp_set_link_train(struct intel_dp *intel_dp, static void intel_dp_start_link_train(struct intel_dp *intel_dp) { - struct drm_device *dev = intel_dp->base.base.dev; + struct drm_encoder *encoder = &intel_dp->base.base; + struct drm_device *dev = encoder->dev; struct drm_i915_private *dev_priv = dev->dev_private; struct intel_crtc *intel_crtc = to_intel_crtc(intel_dp->base.base.crtc); int i; @@ -1822,12 +1823,14 @@ intel_dp_start_link_train(struct intel_dp *intel_dp) int voltage_tries, loop_tries; uint32_t DP = intel_dp->DP; - /* - * On CPT we have to enable the port in training pattern 1, which - * will happen below in intel_dp_set_link_train. Otherwise, enable - * the port and wait for it to become active. - */ - if (!HAS_PCH_CPT(dev)) { + if (IS_HASWELL(dev)) { + intel_ddi_prepare_link_retrain(encoder); + } else if (!HAS_PCH_CPT(dev)) { + /* + * On CPT we have to enable the port in training pattern 1, + * which will happen below in intel_dp_set_link_train. + * Otherwise, enable the port and wait for it to become active. + */ I915_WRITE(intel_dp->output_reg, intel_dp->DP); POSTING_READ(intel_dp->output_reg); intel_wait_for_vblank(dev, intel_crtc->pipe); diff --git a/drivers/gpu/drm/i915/intel_drv.h b/drivers/gpu/drm/i915/intel_drv.h index f3f5b83..a8ef8ca 100644 --- a/drivers/gpu/drm/i915/intel_drv.h +++ b/drivers/gpu/drm/i915/intel_drv.h @@ -535,5 +535,6 @@ extern void intel_ddi_mode_set(struct drm_encoder *encoder, extern void intel_ddi_pll_init(struct drm_device *dev); extern void intel_ddi_disable(struct drm_encoder *encoder); extern void intel_ddi_commit(struct drm_encoder *encoder); +extern void intel_ddi_prepare_link_retrain(struct drm_encoder *encoder); #endif /* __INTEL_DRV_H__ */