From patchwork Tue Apr 8 17:47:40 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Todd Previte X-Patchwork-Id: 3950181 Return-Path: X-Original-To: patchwork-intel-gfx@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id B90CDBFF02 for ; Tue, 8 Apr 2014 17:48:08 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id E895B203B5 for ; Tue, 8 Apr 2014 17:48:07 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 2BABD203AC for ; Tue, 8 Apr 2014 17:48:07 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id B98336E4D5; Tue, 8 Apr 2014 10:48:06 -0700 (PDT) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mail-pd0-f177.google.com (mail-pd0-f177.google.com [209.85.192.177]) by gabe.freedesktop.org (Postfix) with ESMTP id B0DBB6E4D5 for ; Tue, 8 Apr 2014 10:48:05 -0700 (PDT) Received: by mail-pd0-f177.google.com with SMTP id y10so1310127pdj.36 for ; Tue, 08 Apr 2014 10:48:05 -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:in-reply-to:references; bh=74Y9UvP0Mu2OyP3uAdgOy5B6uxoiI8Z7tgbAUJ9MljE=; b=a80HKqdB+iljweuRMk+Oq3DR4ZdNMpW5WnvpamoWOM3bqiwd7dckzUZw+ngkDen0jN 07joBFcfvXwP6wo6CN3h39UETo5T1hAU5kEcTB9bXSN9tvuYLUs/OJG1yLoQvO29n5f+ VHZCrmhB2Cp3ovnRHWtUilZmreIa78lVp8GRykjy+I1nxpESmD5bJtmBkm8kSyvyjARi V9+5atRb8ty0K+23z3RsddZrMPaty9OwELcRY67enNjjZsByoMvmm2WcTPdZ6gRM7ZYZ TF6tCdWGwXpaEhD0PT3Po86rKgvGaO/YmxEqBG+4EV+NhX5G9d9tvMOFEVCtiAMcAawl 9lag== X-Received: by 10.68.136.162 with SMTP id qb2mr6224846pbb.88.1396979285407; Tue, 08 Apr 2014 10:48:05 -0700 (PDT) Received: from localhost.localdomain (ip72-201-95-47.ph.ph.cox.net. [72.201.95.47]) by mx.google.com with ESMTPSA id e6sm5973219pbg.4.2014.04.08.10.48.03 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 08 Apr 2014 10:48:04 -0700 (PDT) From: Todd Previte To: intel-gfx@lists.freedesktop.org Date: Tue, 8 Apr 2014 10:47:40 -0700 Message-Id: <1396979263-3245-3-git-send-email-tprevite@gmail.com> X-Mailer: git-send-email 1.8.3.2 In-Reply-To: <1396979263-3245-1-git-send-email-tprevite@gmail.com> References: <1396979263-3245-1-git-send-email-tprevite@gmail.com> Subject: [Intel-gfx] [PATCH 2/5] drm/i915: Displayport - Add function to check link status X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Adds a function to check the link status across all lanes for Displayport. This is functionality required to establish more fine-grained control over the Displayport interface, both for operational reliability and compliance testing. Signed-off-by: Todd Previte --- drivers/gpu/drm/i915/intel_dp.c | 61 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) diff --git a/drivers/gpu/drm/i915/intel_dp.c b/drivers/gpu/drm/i915/intel_dp.c index 64c9803..c865c32 100644 --- a/drivers/gpu/drm/i915/intel_dp.c +++ b/drivers/gpu/drm/i915/intel_dp.c @@ -38,6 +38,22 @@ #define DP_LINK_CHECK_TIMEOUT (10 * 1000) +typedef enum { + LINK_TRAINING_STATUS_OK = 0, + LINK_TRAINING_CR_FAILED, + LINK_TRAINING_CR_COMPLETE, + LINK_TRAINING_CE_FAILED, + LINK_TRAINING_CE_COMPLETE, + LINK_TRAINING_STATUS_READ_FAILED +} IntelDPLinkTrainingStatus; + +typedef enum { + DP_LINK_TRAINING_STATE_IDLE = 0, + DP_LINK_TRAINING_STATE_CLOCK_REC, + DP_LINK_TRAINING_STATE_CHANNEL_EQ, + DP_LINK_TRAINING_STATE_ADJUST +} DPLinkTrainingState; + struct dp_link_dpll { int link_bw; struct dpll dpll; @@ -2356,6 +2372,51 @@ intel_dp_set_signal_levels(struct intel_dp *intel_dp, uint32_t *DP) *DP = (*DP & ~mask) | signal_levels; } +bool +intel_dp_verify_link_status(DPLinkTrainingState state, + uint8_t lane_count, + uint8_t *link_status) +{ + uint32_t status = 0; + bool link_ok = false; + uint8_t ls[5]; + + switch (state) { + case DP_LINK_TRAINING_STATE_CLOCK_REC: + status = (link_status[0] & DP_LANE_CR_DONE) + + ((link_status[0] >> 4) & DP_LANE_CR_DONE) + + (link_status[1] & DP_LANE_CR_DONE) + + ((link_status[1] >> 4) & DP_LANE_CR_DONE); + // Valid CR status = sum of bits == lane count + link_ok = status == lane_count ? true : false; + break; + case DP_LINK_TRAINING_STATE_CHANNEL_EQ: + ls[0] = ((link_status[0] & DP_LANE_CHANNEL_EQ_DONE) >> 1) + + ((link_status[0] & DP_LANE_SYMBOL_LOCKED) >> 2); + ls[1] = (((link_status[0] >> 4) & DP_LANE_CHANNEL_EQ_DONE) >> 1) + + (((link_status[0] >> 4) & DP_LANE_SYMBOL_LOCKED) >> 2); + ls[2] = ((link_status[1] & DP_LANE_CHANNEL_EQ_DONE) >> 1) + + ((link_status[1] & DP_LANE_SYMBOL_LOCKED) >> 2); + ls[3] = (((link_status[1] >> 4) & DP_LANE_CHANNEL_EQ_DONE) >> 1) + + (((link_status[1] >> 4) & DP_LANE_SYMBOL_LOCKED) >> 2); + ls[4] = link_status[2] & DP_INTERLANE_ALIGN_DONE; + // Combine lane status - must equal active lane count + status = ls[0] + ls[1] + ls[2] + ls[3]; + // CE status is all lanes + lane alignment (ls[4]) + link_ok = (status == lane_count) && ls[4] ? true : false; + break; + default: + // Invalid state for checking link status + break; + } + + if (!link_ok) { + // FIXME: Log failure here, detailed error status output + } + + return link_ok; +} + uint32_t intel_dp_set_training_pattern(uint8_t training_pattern, struct intel_dp *intel_dp)