From patchwork Mon Oct 12 06:25:17 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ander Conselvan de Oliveira X-Patchwork-Id: 7372351 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.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id BA14EBEEA4 for ; Mon, 12 Oct 2015 06:25:38 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id B8BDC2071E for ; Mon, 12 Oct 2015 06:25:37 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 1966A20752 for ; Mon, 12 Oct 2015 06:25:36 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 7C7FF6E4F2; Sun, 11 Oct 2015 23:25:35 -0700 (PDT) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by gabe.freedesktop.org (Postfix) with ESMTP id 793CE6E568 for ; Sun, 11 Oct 2015 23:25:34 -0700 (PDT) Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga103.fm.intel.com with ESMTP; 11 Oct 2015 23:25:34 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.17,671,1437462000"; d="scan'208";a="824490833" Received: from linux.intel.com ([10.23.219.25]) by orsmga002.jf.intel.com with ESMTP; 11 Oct 2015 23:25:34 -0700 Received: from localhost (unknown [10.252.4.61]) by linux.intel.com (Postfix) with ESMTP id D17F06A4005; Sun, 11 Oct 2015 23:24:35 -0700 (PDT) From: Ander Conselvan de Oliveira To: intel-gfx@lists.freedesktop.org Date: Mon, 12 Oct 2015 09:25:17 +0300 Message-Id: <1444631122-7586-5-git-send-email-ander.conselvan.de.oliveira@intel.com> X-Mailer: git-send-email 2.4.3 In-Reply-To: <1444631122-7586-1-git-send-email-ander.conselvan.de.oliveira@intel.com> References: <1444631122-7586-1-git-send-email-ander.conselvan.de.oliveira@intel.com> Cc: Ander Conselvan de Oliveira Subject: [Intel-gfx] [PATCH 4/9] drm/i915: Use struct intel_dp_signal_levels for eDP on SNB and IVB X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.18 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.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable 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 Use the new struct intel_dp_signal_levels to store voltage swing and pre emphasis levels for eDP on SNB and IVB. --- drivers/gpu/drm/i915/intel_dp_signal_levels.c | 132 ++++++++++++++++++-------- 1 file changed, 91 insertions(+), 41 deletions(-) diff --git a/drivers/gpu/drm/i915/intel_dp_signal_levels.c b/drivers/gpu/drm/i915/intel_dp_signal_levels.c index 317a2b4..7e74f8c 100644 --- a/drivers/gpu/drm/i915/intel_dp_signal_levels.c +++ b/drivers/gpu/drm/i915/intel_dp_signal_levels.c @@ -448,7 +448,6 @@ static const struct signal_levels gen4_signal_levels = { .set = gen4_set_signal_levels, }; -/* Not for eDP */ static const struct signal_levels snb_signal_levels = { .max_voltage = DP_TRAIN_VOLTAGE_SWING_LEVEL_3, .max_pre_emph = { @@ -461,73 +460,123 @@ static const struct signal_levels snb_signal_levels = { .set = gen4_set_signal_levels, }; -/* Gen6's DP voltage swing and pre-emphasis control */ -static uint32_t -gen6_edp_signal_levels(uint8_t train_set) +/* SNB's DP voltage swing and pre-emphasis control */ +static void +snb_edp_set_signal_levels(struct intel_dp *intel_dp, uint8_t train_set) { - int signal_levels = train_set & (DP_TRAIN_VOLTAGE_SWING_MASK | - DP_TRAIN_PRE_EMPHASIS_MASK); - switch (signal_levels) { + uint32_t signal_levels; + + train_set &= + (DP_TRAIN_VOLTAGE_SWING_MASK | DP_TRAIN_PRE_EMPHASIS_MASK); + + switch (train_set) { case DP_TRAIN_VOLTAGE_SWING_LEVEL_0 | DP_TRAIN_PRE_EMPH_LEVEL_0: case DP_TRAIN_VOLTAGE_SWING_LEVEL_1 | DP_TRAIN_PRE_EMPH_LEVEL_0: - return EDP_LINK_TRAIN_400_600MV_0DB_SNB_B; + signal_levels = EDP_LINK_TRAIN_400_600MV_0DB_SNB_B; + break; case DP_TRAIN_VOLTAGE_SWING_LEVEL_0 | DP_TRAIN_PRE_EMPH_LEVEL_1: - return EDP_LINK_TRAIN_400MV_3_5DB_SNB_B; + signal_levels = EDP_LINK_TRAIN_400MV_3_5DB_SNB_B; + break; case DP_TRAIN_VOLTAGE_SWING_LEVEL_0 | DP_TRAIN_PRE_EMPH_LEVEL_2: case DP_TRAIN_VOLTAGE_SWING_LEVEL_1 | DP_TRAIN_PRE_EMPH_LEVEL_2: - return EDP_LINK_TRAIN_400_600MV_6DB_SNB_B; + signal_levels = EDP_LINK_TRAIN_400_600MV_6DB_SNB_B; + break; case DP_TRAIN_VOLTAGE_SWING_LEVEL_1 | DP_TRAIN_PRE_EMPH_LEVEL_1: case DP_TRAIN_VOLTAGE_SWING_LEVEL_2 | DP_TRAIN_PRE_EMPH_LEVEL_1: - return EDP_LINK_TRAIN_600_800MV_3_5DB_SNB_B; + signal_levels = EDP_LINK_TRAIN_600_800MV_3_5DB_SNB_B; + break; case DP_TRAIN_VOLTAGE_SWING_LEVEL_2 | DP_TRAIN_PRE_EMPH_LEVEL_0: case DP_TRAIN_VOLTAGE_SWING_LEVEL_3 | DP_TRAIN_PRE_EMPH_LEVEL_0: - return EDP_LINK_TRAIN_800_1200MV_0DB_SNB_B; + signal_levels = EDP_LINK_TRAIN_800_1200MV_0DB_SNB_B; + break; default: DRM_DEBUG_KMS("Unsupported voltage swing/pre-emphasis level:" - "0x%x\n", signal_levels); - return EDP_LINK_TRAIN_400_600MV_0DB_SNB_B; + "0x%x\n", train_set); + signal_levels = EDP_LINK_TRAIN_400_600MV_0DB_SNB_B; } + + DRM_DEBUG_KMS("Using signal levels %08x\n", signal_levels); + + intel_dp->DP &= ~EDP_LINK_TRAIN_VOL_EMP_MASK_SNB; + intel_dp->DP |= signal_levels; } -/* Gen7's DP voltage swing and pre-emphasis control */ -static uint32_t -gen7_edp_signal_levels(uint8_t train_set) +static const struct signal_levels snb_edp_signal_levels = { + .max_voltage = DP_TRAIN_VOLTAGE_SWING_LEVEL_2, + .max_pre_emph = { + DP_TRAIN_PRE_EMPH_LEVEL_2, + DP_TRAIN_PRE_EMPH_LEVEL_2, + DP_TRAIN_PRE_EMPH_LEVEL_1, + DP_TRAIN_PRE_EMPH_LEVEL_0, + }, + + .set = snb_edp_set_signal_levels, +}; + +/* IVB's DP voltage swing and pre-emphasis control */ +static void +ivb_edp_set_signal_levels(struct intel_dp *intel_dp, uint8_t train_set) { - int signal_levels = train_set & (DP_TRAIN_VOLTAGE_SWING_MASK | - DP_TRAIN_PRE_EMPHASIS_MASK); - switch (signal_levels) { + uint32_t signal_levels; + + train_set &= + (DP_TRAIN_VOLTAGE_SWING_MASK | DP_TRAIN_PRE_EMPHASIS_MASK); + + switch (train_set) { case DP_TRAIN_VOLTAGE_SWING_LEVEL_0 | DP_TRAIN_PRE_EMPH_LEVEL_0: - return EDP_LINK_TRAIN_400MV_0DB_IVB; + signal_levels = EDP_LINK_TRAIN_400MV_0DB_IVB; + break; case DP_TRAIN_VOLTAGE_SWING_LEVEL_0 | DP_TRAIN_PRE_EMPH_LEVEL_1: - return EDP_LINK_TRAIN_400MV_3_5DB_IVB; + signal_levels = EDP_LINK_TRAIN_400MV_3_5DB_IVB; + break; case DP_TRAIN_VOLTAGE_SWING_LEVEL_0 | DP_TRAIN_PRE_EMPH_LEVEL_2: - return EDP_LINK_TRAIN_400MV_6DB_IVB; + signal_levels = EDP_LINK_TRAIN_400MV_6DB_IVB; + break; case DP_TRAIN_VOLTAGE_SWING_LEVEL_1 | DP_TRAIN_PRE_EMPH_LEVEL_0: - return EDP_LINK_TRAIN_600MV_0DB_IVB; + signal_levels = EDP_LINK_TRAIN_600MV_0DB_IVB; + break; case DP_TRAIN_VOLTAGE_SWING_LEVEL_1 | DP_TRAIN_PRE_EMPH_LEVEL_1: - return EDP_LINK_TRAIN_600MV_3_5DB_IVB; + signal_levels = EDP_LINK_TRAIN_600MV_3_5DB_IVB; + break; case DP_TRAIN_VOLTAGE_SWING_LEVEL_2 | DP_TRAIN_PRE_EMPH_LEVEL_0: - return EDP_LINK_TRAIN_800MV_0DB_IVB; + signal_levels = EDP_LINK_TRAIN_800MV_0DB_IVB; + break; case DP_TRAIN_VOLTAGE_SWING_LEVEL_2 | DP_TRAIN_PRE_EMPH_LEVEL_1: - return EDP_LINK_TRAIN_800MV_3_5DB_IVB; + signal_levels = EDP_LINK_TRAIN_800MV_3_5DB_IVB; + break; default: DRM_DEBUG_KMS("Unsupported voltage swing/pre-emphasis level:" - "0x%x\n", signal_levels); - return EDP_LINK_TRAIN_500MV_0DB_IVB; + "0x%x\n", train_set); + signal_levels = EDP_LINK_TRAIN_500MV_0DB_IVB; } + + DRM_DEBUG_KMS("Using signal levels %08x\n", signal_levels); + + intel_dp->DP &= ~EDP_LINK_TRAIN_VOL_EMP_MASK_IVB; + intel_dp->DP |= signal_levels; } +static const struct signal_levels ivb_edp_signal_levels = { + .max_voltage = DP_TRAIN_VOLTAGE_SWING_LEVEL_2, + .max_pre_emph = { + DP_TRAIN_PRE_EMPH_LEVEL_2, + DP_TRAIN_PRE_EMPH_LEVEL_1, + DP_TRAIN_PRE_EMPH_LEVEL_1, + DP_TRAIN_PRE_EMPH_LEVEL_0, + }, + + .set = ivb_edp_set_signal_levels, +}; + static void _update_signal_levels(struct intel_dp *intel_dp) { struct intel_digital_port *intel_dig_port = dp_to_dig_port(intel_dp); - enum port port = intel_dig_port->port; struct drm_device *dev = intel_dig_port->base.base.dev; uint32_t signal_levels, mask = 0; - uint8_t train_set = intel_dp->train_set[0]; if (HAS_DDI(dev)) { signal_levels = ddi_signal_levels(intel_dp); @@ -540,12 +589,6 @@ _update_signal_levels(struct intel_dp *intel_dp) signal_levels = chv_signal_levels(intel_dp); } else if (IS_VALLEYVIEW(dev)) { signal_levels = vlv_signal_levels(intel_dp); - } else if (IS_GEN7(dev) && port == PORT_A) { - signal_levels = gen7_edp_signal_levels(train_set); - mask = EDP_LINK_TRAIN_VOL_EMP_MASK_IVB; - } else if (IS_GEN6(dev) && port == PORT_A) { - signal_levels = gen6_edp_signal_levels(train_set); - mask = EDP_LINK_TRAIN_VOL_EMP_MASK_SNB; } else { WARN(1, "Should be calling intel_dp->signal_levels->set instead."); return; @@ -605,9 +648,16 @@ intel_dp_init_signal_levels(struct intel_dp *intel_dp) struct intel_digital_port *intel_dig_port = dp_to_dig_port(intel_dp); enum port port = intel_dig_port->port; - if (port != PORT_A && (IS_IVYBRIDGE(dev) || IS_GEN6(dev))) - intel_dp->signal_levels = &snb_signal_levels; - - if (INTEL_INFO(dev)->gen <= 5) + if (IS_IVYBRIDGE(dev)) { + if (port == PORT_A) + intel_dp->signal_levels = &ivb_edp_signal_levels; + else + intel_dp->signal_levels = &snb_signal_levels; + } else if (IS_GEN6(dev)) { + if (port == PORT_A) + intel_dp->signal_levels = &snb_edp_signal_levels; + else + intel_dp->signal_levels = &snb_signal_levels; + } else if (INTEL_INFO(dev)->gen <= 5) intel_dp->signal_levels = &gen4_signal_levels; }