Received: by 2002:ab2:7b86:0:b0:1f7:5705:b850 with SMTP id q6csp40747lqh; Fri, 3 May 2024 12:40:30 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWUloqwrHHRaGOUOG5WBwlFwdTNB+jmvtxX+SC7YzW/E38P76bcBykyLuGIzDHGBRHVQeWO+DDaYfhOxtk9mqNDSBJwRwkW3TIR8GAo+Q== X-Google-Smtp-Source: AGHT+IGGhZYNIRJ0Bm/MGq+iT3Vw1TEWFGfKu/aXi/1uwAqRgJmY/c+RucSFeycAhvpZq30oT7gC X-Received: by 2002:a17:902:d486:b0:1eb:4c47:3454 with SMTP id c6-20020a170902d48600b001eb4c473454mr4917453plg.0.1714765229862; Fri, 03 May 2024 12:40:29 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1714765229; cv=pass; d=google.com; s=arc-20160816; b=xV+O0GFXI/i9WNLtwG9nWV/aSwSCP206qitFP4CKYTk7wtd0BJOjXbpYrXkpzlvZa3 g0hTH502vzXOGtffiEap9vBDkGah8tLpeMn11Vn0f9W5HOmRg1UykEcRFAWUNqzpH4q8 qN4SLaavlKYxGFQc9sbdAsnS8TWT14FCsZ9n8d3TBegugIkXoHYp6s2Jfrg4r9gtnslH 1BA5aFhED0WHMBzh+O0zVL2NYhlhEVFO9curuBK1hRw/Ue9vw4CEB5gUc0CPfOeuUma4 rAUQTwMu5DADc+SCSWXdKVxPySJOyVREjtI/pGuKsRiOt3pmncpx3YojmVCl0xCvDHNc pajg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=Q81sJcRQopdd0AojSEuxKZRimNurboPzOd6IdkglF0g=; fh=UFCKTC8uN4d0DvFpkldKNWLnw7DD8sRfx4y8gXtNsgA=; b=L9NfMJrVUY8bv/uGjBlgGzBIhBfNBcpy+dC8j3WJdduIdqK/b8c7c1L9zvtN8x21Vt K5bMefYViefuOv3cCamO29IU/EjWQoQB3GithnjqtgWdpZ6fqKI77ighNgLptKXyBowX cTaCmR0W7bN4A2NLc23s+wIS3jR5aWoqBs1dv7NyyryIrHKCC95wes4Y7qDqAR90m5SO Vb/zeUx40uovccmSu8hWD4bHQZiSXLjhzkrbFv0VVFqTk4e13UsZAZX73orGXoiJaK2N nxnjsqmEg+T0KTRmN9cxHCdbi/FpNoGW6Z0Lww3tuQgHIidD/wigAulv5SS7MR/YriNA C8bQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=XHannd6z; arc=pass (i=1 spf=pass spfdomain=linux.dev dkim=pass dkdomain=linux.dev dmarc=pass fromdomain=linux.dev); spf=pass (google.com: domain of linux-kernel+bounces-168130-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-168130-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id b14-20020a170903228e00b001e7a249fd08si366673plh.603.2024.05.03.12.40.29 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 May 2024 12:40:29 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-168130-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=XHannd6z; arc=pass (i=1 spf=pass spfdomain=linux.dev dkim=pass dkdomain=linux.dev dmarc=pass fromdomain=linux.dev); spf=pass (google.com: domain of linux-kernel+bounces-168130-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-168130-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 2C277B23D42 for ; Fri, 3 May 2024 19:31:36 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 1DABB1598EF; Fri, 3 May 2024 19:29:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="XHannd6z" Received: from out-178.mta1.migadu.com (out-178.mta1.migadu.com [95.215.58.178]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7C12D159580 for ; Fri, 3 May 2024 19:29:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=95.215.58.178 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714764589; cv=none; b=HDvlzXKhz88+3u9z7DKmKAOecHBR3uLWBj6emzMNsDsjh+PopN9wYWCAvGSK3+YgjHFwMA7TQFhZFbbPhqrZ+ZWe9kz9FBz5kRntj12bqHvR0MSOVaiL3fx3sqDuAE6FPKQJuB7UVdmJAaGK6fdC8ieDUuQ3RnoxL/jjsr65fls= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714764589; c=relaxed/simple; bh=pEcs7zpgNNeDJ3+vlO/rVBk1Wi06J5mmvZY+MN7cMA4=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=WfjGStJDOQIRmoJOKnlTMy43qBRhFBzXxLRHzk3Iokt0I8l2Ll9m+rZwmqB1YfhU8GAO+lzlzU2wWMOEuTTMuXnvErAC6VRQ3x3eXx1yqZMocYVUvbbB0zUjqTmD/TLYEilPJNPmKAP+6qoZzgmESYErJTSVgfeLlK0VcMqQ7+E= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=XHannd6z; arc=none smtp.client-ip=95.215.58.178 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1714764585; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Q81sJcRQopdd0AojSEuxKZRimNurboPzOd6IdkglF0g=; b=XHannd6zHXjUvfPxhWd3HDq1cHPpJg3ANzHt+r5amMBMuA+R3JwdcgXACXQXW6dFkBfAuA KkQDpiLGZ2uAGuZ2mAnAXYVecgYN0WuHwT6NhhCcdF86U9OZnUgTu1ZxDAp9Y3JOatw0xs xsW3h7B5748d9cGaqVd617W2grYM5AM= From: Sean Anderson To: Laurent Pinchart , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , dri-devel@lists.freedesktop.org Cc: linux-arm-kernel@lists.infradead.org, David Airlie , linux-kernel@vger.kernel.org, Daniel Vetter , Tomi Valkeinen , Michal Simek , Sean Anderson Subject: [PATCH v5 08/10] drm: zynqmp_dp: Split off several helper functions Date: Fri, 3 May 2024 15:29:20 -0400 Message-Id: <20240503192922.2172314-9-sean.anderson@linux.dev> In-Reply-To: <20240503192922.2172314-1-sean.anderson@linux.dev> References: <20240503192922.2172314-1-sean.anderson@linux.dev> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Migadu-Flow: FLOW_OUT In preparation for supporting compliance testing, split off several helper functions. No functional change intended. Signed-off-by: Sean Anderson Reviewed-by: Laurent Pinchart Reviewed-by: Tomi Valkeinen --- (no changes since v1) drivers/gpu/drm/xlnx/zynqmp_dp.c | 49 ++++++++++++++++++++++---------- 1 file changed, 34 insertions(+), 15 deletions(-) diff --git a/drivers/gpu/drm/xlnx/zynqmp_dp.c b/drivers/gpu/drm/xlnx/zynqmp_dp.c index 38610a5b932a..91767ddbe1ce 100644 --- a/drivers/gpu/drm/xlnx/zynqmp_dp.c +++ b/drivers/gpu/drm/xlnx/zynqmp_dp.c @@ -636,6 +636,7 @@ static void zynqmp_dp_adjust_train(struct zynqmp_dp *dp, /** * zynqmp_dp_update_vs_emph - Update the training values * @dp: DisplayPort IP core structure + * @train_set: A set of training values * * Update the training values based on the request from sink. The mapped values * are predefined, and values(vs, pe, pc) are from the device manual. @@ -643,12 +644,12 @@ static void zynqmp_dp_adjust_train(struct zynqmp_dp *dp, * Return: 0 if vs and emph are updated successfully, or the error code returned * by drm_dp_dpcd_write(). */ -static int zynqmp_dp_update_vs_emph(struct zynqmp_dp *dp) +static int zynqmp_dp_update_vs_emph(struct zynqmp_dp *dp, u8 *train_set) { unsigned int i; int ret; - ret = drm_dp_dpcd_write(&dp->aux, DP_TRAINING_LANE0_SET, dp->train_set, + ret = drm_dp_dpcd_write(&dp->aux, DP_TRAINING_LANE0_SET, train_set, dp->mode.lane_cnt); if (ret < 0) return ret; @@ -656,7 +657,7 @@ static int zynqmp_dp_update_vs_emph(struct zynqmp_dp *dp) for (i = 0; i < dp->mode.lane_cnt; i++) { u32 reg = ZYNQMP_DP_SUB_TX_PHY_PRECURSOR_LANE_0 + i * 4; union phy_configure_opts opts = { 0 }; - u8 train = dp->train_set[i]; + u8 train = train_set[i]; opts.dp.voltage[0] = (train & DP_TRAIN_VOLTAGE_SWING_MASK) >> DP_TRAIN_VOLTAGE_SWING_SHIFT; @@ -700,7 +701,7 @@ static int zynqmp_dp_link_train_cr(struct zynqmp_dp *dp) * So, This loop should exit before 512 iterations */ for (max_tries = 0; max_tries < 512; max_tries++) { - ret = zynqmp_dp_update_vs_emph(dp); + ret = zynqmp_dp_update_vs_emph(dp, dp->train_set); if (ret) return ret; @@ -765,7 +766,7 @@ static int zynqmp_dp_link_train_ce(struct zynqmp_dp *dp) return ret; for (tries = 0; tries < DP_MAX_TRAINING_TRIES; tries++) { - ret = zynqmp_dp_update_vs_emph(dp); + ret = zynqmp_dp_update_vs_emph(dp, dp->train_set); if (ret) return ret; @@ -788,28 +789,29 @@ static int zynqmp_dp_link_train_ce(struct zynqmp_dp *dp) } /** - * zynqmp_dp_train - Train the link + * zynqmp_dp_setup() - Set up major link parameters * @dp: DisplayPort IP core structure + * @bw_code: The link bandwidth as a multiple of 270 MHz + * @lane_cnt: The number of lanes to use + * @enhanced: Use enhanced framing + * @downspread: Enable spread-spectrum clocking * - * Return: 0 if all trains are done successfully, or corresponding error code. + * Return: 0 on success, or -errno on failure */ -static int zynqmp_dp_train(struct zynqmp_dp *dp) +static int zynqmp_dp_setup(struct zynqmp_dp *dp, u8 bw_code, u8 lane_cnt, + bool enhanced, bool downspread) { u32 reg; - u8 bw_code = dp->mode.bw_code; - u8 lane_cnt = dp->mode.lane_cnt; u8 aux_lane_cnt = lane_cnt; - bool enhanced; int ret; zynqmp_dp_write(dp, ZYNQMP_DP_LANE_COUNT_SET, lane_cnt); - enhanced = drm_dp_enhanced_frame_cap(dp->dpcd); if (enhanced) { zynqmp_dp_write(dp, ZYNQMP_DP_ENHANCED_FRAME_EN, 1); aux_lane_cnt |= DP_LANE_COUNT_ENHANCED_FRAME_EN; } - if (dp->dpcd[3] & 0x1) { + if (downspread) { zynqmp_dp_write(dp, ZYNQMP_DP_DOWNSPREAD_CTL, 1); drm_dp_dpcd_writeb(&dp->aux, DP_DOWNSPREAD_CTRL, DP_SPREAD_AMP_0_5); @@ -852,8 +854,25 @@ static int zynqmp_dp_train(struct zynqmp_dp *dp) } zynqmp_dp_write(dp, ZYNQMP_DP_PHY_CLOCK_SELECT, reg); - ret = zynqmp_dp_phy_ready(dp); - if (ret < 0) + return zynqmp_dp_phy_ready(dp); +} + + +/** + * zynqmp_dp_train - Train the link + * @dp: DisplayPort IP core structure + * + * Return: 0 if all trains are done successfully, or corresponding error code. + */ +static int zynqmp_dp_train(struct zynqmp_dp *dp) +{ + int ret; + + ret = zynqmp_dp_setup(dp, dp->mode.bw_code, dp->mode.lane_cnt, + drm_dp_enhanced_frame_cap(dp->dpcd), + dp->dpcd[DP_MAX_DOWNSPREAD] & + DP_MAX_DOWNSPREAD_0_5); + if (ret) return ret; zynqmp_dp_write(dp, ZYNQMP_DP_SCRAMBLING_DISABLE, 1); -- 2.35.1.1320.gc452695387.dirty