Received: by 2002:a05:6a10:eb17:0:0:0:0 with SMTP id hx23csp739914pxb; Fri, 3 Sep 2021 12:19:24 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzUdOb8jQOB0S8UljOqqmT1LygoCg3hj8Bw/qOeVGwPCqW5YBO5w6+GzMC6zXTIMMRYtfku X-Received: by 2002:a05:6638:cd:: with SMTP id w13mr537554jao.42.1630696764598; Fri, 03 Sep 2021 12:19:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1630696764; cv=none; d=google.com; s=arc-20160816; b=rav3uA+jDt9WfxYx/zb0A7cWLqgTp+nzpxjs9loXV5lvZ5uP8p2sHqg8To1cCxD5Ft y93Ug/eMhvEUIwPutp1vSB4YeWsWNE+raY1hZi94VI1e/JoX6JsCgupR4kCH5PYKgAFm ljj2Pg3eScJv7UR/pdL8GkPO5q1Kbppk0D1A1cIMRtJc3PJjyh5QmKDPhEIxVcBpP6je lH2WD3Si+mOojUosLdWPU2nbsCPa3SNrA2iow0wLE9DvUV0ri2jDxdp38ezSu6GNcQ2u 7UN8iKDdwbW76l6YdrG+aGo6uwkIGTHPVM3DYKBdkqVfYyW5cgYPdGIGax0ZcQKQ1gr0 a6tQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject:dkim-signature; bh=Jp+DzdKvplQFh1frqe9YEr4t0IdxJGv9l0U7vlDKxAE=; b=AvQ3F9535hvTvOPxyBRSWon469teywAJF7Off9DIduIKrm1jdKn6Krj1LSKI57boVd sdb4PCeOVp2CAc3VhVn2a599tdVYBJFQulSl/K32vF5SULdyX75F2rtKExQ4QcOYpOgw N6Prug4O81xepondxzhYBqtSk9VVXgsntrU3b8SnynKxcgfz4XqxkHn8nHPRnVa3wcaO 7whRpVfb7reRTwiBQD8VEgec3VMsXaGYijMLmgqytvVuvM101Lh2iG4XoGlUSRa7GfoG pJpvsMpuBzp4UoKkclT6QgJ6ASJqy4Mi7e5wiLQrC+SrHi9CtXIH29YKfrm8rF78bzfo 0OxQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=keN39KZ0; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id f7si154300ilq.58.2021.09.03.12.19.12; Fri, 03 Sep 2021 12:19:24 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=keN39KZ0; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1350597AbhICTKS (ORCPT + 99 others); Fri, 3 Sep 2021 15:10:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47336 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1350972AbhICTKS (ORCPT ); Fri, 3 Sep 2021 15:10:18 -0400 Received: from mail-lj1-x22b.google.com (mail-lj1-x22b.google.com [IPv6:2a00:1450:4864:20::22b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9B9D3C061760 for ; Fri, 3 Sep 2021 12:09:17 -0700 (PDT) Received: by mail-lj1-x22b.google.com with SMTP id s3so323778ljp.11 for ; Fri, 03 Sep 2021 12:09:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=Jp+DzdKvplQFh1frqe9YEr4t0IdxJGv9l0U7vlDKxAE=; b=keN39KZ0vWlLEi9OKwSw5hmoTYjcTN1CK1hkNb3IYonIbeR/xxBQuJVDFpLjlAkkI9 GPrlil9uV4fGOaNy9xCxE7EEwq8wfvYZ2gDdMjMLiqRZiy9zUdkm4IjuqTdHDf6PdvYi 1jrexSH0xQqQDwTqH3AAuIDKOUC9GPzLPFw1fWHWnxut47ou5bB3fe6BzUMcSM3VmjDM S2H9z3mK8LXHMNuNO07bQtwuOj7zaGx1fzU/EIEj2kV1a8D7JTocKqVtaizRYDTPtUSn M0Qpuq9vfw867cJV3haMXs1R3hv+VtLnHtXmKqQ5DqvfFkVkCp/DxEZH8t3Q2+V7FWah LFIg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=Jp+DzdKvplQFh1frqe9YEr4t0IdxJGv9l0U7vlDKxAE=; b=Fbkh7FwDX7sJZTc87MAAOfDON7SyFq352L7NABMxqtd+ZaD72cYgME+X7sI4CPXtn9 wzu+x3OP9r2nrjwRY9y0fxJCu34K/UiR1VwVD7PETZMlOMf1Uc5WmhBNT2d1v5Trn2BN aihNrmmlHYkN8L/a2HQBytSV27O3CoYwyIOaIWLhepJjMzyVQinzlNsvK1CUKfGXKlM0 dpD0j84C2DEKlvD62uWZ65ayAlsUZRYp6TP6ijaqHy9rGDXZbherOD6nWypT0NC40EVZ 3ZTOiKf3lSOwjZ+t48F+DfaMwcTSXjPXs5x6zPbpsi2pLSryKF3tQ0ETCo/Evk6Relst HZvA== X-Gm-Message-State: AOAM533Zf27Bo8gbMoWPBCSXsLfbqu+TNgn7vyGMVdIQeLQVbUOttx11 ouU+raPuxE+ghpvKmx/d70/new== X-Received: by 2002:a2e:94ce:: with SMTP id r14mr361343ljh.259.1630696155921; Fri, 03 Sep 2021 12:09:15 -0700 (PDT) Received: from [192.168.1.211] ([37.153.55.125]) by smtp.gmail.com with ESMTPSA id y35sm4060lje.127.2021.09.03.12.09.15 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 03 Sep 2021 12:09:15 -0700 (PDT) Subject: Re: [PATCH v2] phy: qcom-qmp: add support for display port voltage and pre-emphasis swing To: Kuogee Hsieh , robdclark@gmail.com, sean@poorly.run, swboyd@chromium.org, vkoul@kernel.org, agross@kernel.org, bjorn.andersson@linaro.org, robh+dt@kernel.org, devicetree@vger.kernel.org Cc: abhinavk@codeaurora.org, aravindh@codeaurora.org, freedreno@lists.freedesktop.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, kishon@ti.com, p.zabel@pengutronix.de References: <1630098658-23149-1-git-send-email-khsieh@codeaurora.org> From: Dmitry Baryshkov Message-ID: <72483937-8ccb-331b-e1af-8f30f6cefc07@linaro.org> Date: Fri, 3 Sep 2021 22:09:14 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.13.0 MIME-Version: 1.0 In-Reply-To: <1630098658-23149-1-git-send-email-khsieh@codeaurora.org> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-GB Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 28/08/2021 00:10, Kuogee Hsieh wrote: > Both voltage and pre-emphasis swing level are set during link training > negotiation between host and sink. There are totally four tables added. > A voltage swing table for both hbr and hbr1, a voltage table for both > hbr2 and hbr3, a pre-emphasis table for both hbr and hbr1 and a pre-emphasis > table for both hbr2 and hbr3. In addition, write 0x0a to TX_TX_POL_INV is > added to complete the sequence of configure dp phy base on HPG. > > Chnages in v2: > -- revise commit test > -- add Fixes tag > -- replaced voltage_swing_cfg with voltage > -- replaced pre_emphasis_cfg with emphasis > -- delete drv_lvl_reg and emp_post_reg parameters from qcom_qmp_v4_phy_configure_dp_swing() > -- delete drv_lvl_reg and emp_post_reg parameters from qcom_qmp_phy_configure_dp_swing() > > Fixes: aff188feb5e1 ("phy: qcom-qmp: add support for sm8250-usb3-dp phy") > Signed-off-by: Kuogee Hsieh > --- > drivers/phy/qualcomm/phy-qcom-qmp.c | 117 ++++++++++++++++++++++++++---------- > 1 file changed, 85 insertions(+), 32 deletions(-) > > diff --git a/drivers/phy/qualcomm/phy-qcom-qmp.c b/drivers/phy/qualcomm/phy-qcom-qmp.c > index 31036aa..021cbb0 100644 > --- a/drivers/phy/qualcomm/phy-qcom-qmp.c > +++ b/drivers/phy/qualcomm/phy-qcom-qmp.c > @@ -3546,12 +3546,11 @@ static const u8 qmp_dp_v3_voltage_swing_hbr_rbr[4][4] = { > { 0x1f, 0xff, 0xff, 0xff } > }; > > -static int qcom_qmp_phy_configure_dp_swing(struct qmp_phy *qphy, > - unsigned int drv_lvl_reg, unsigned int emp_post_reg) > +static int qcom_qmp_phy_configure_dp_swing(struct qmp_phy *qphy) As this becomes a v3-only function, could you please rename it to qcom_qmp_v3_phy_configure_dp_swing() > { > const struct phy_configure_opts_dp *dp_opts = &qphy->dp_opts; > unsigned int v_level = 0, p_level = 0; > - u8 voltage_swing_cfg, pre_emphasis_cfg; > + u8 voltage, emphasis; > int i; > > for (i = 0; i < dp_opts->lanes; i++) { > @@ -3560,26 +3559,25 @@ static int qcom_qmp_phy_configure_dp_swing(struct qmp_phy *qphy, > } > > if (dp_opts->link_rate <= 2700) { > - voltage_swing_cfg = qmp_dp_v3_voltage_swing_hbr_rbr[v_level][p_level]; > - pre_emphasis_cfg = qmp_dp_v3_pre_emphasis_hbr_rbr[v_level][p_level]; > + voltage = qmp_dp_v3_voltage_swing_hbr_rbr[v_level][p_level]; > + emphasis = qmp_dp_v3_pre_emphasis_hbr_rbr[v_level][p_level]; > } else { > - voltage_swing_cfg = qmp_dp_v3_voltage_swing_hbr3_hbr2[v_level][p_level]; > - pre_emphasis_cfg = qmp_dp_v3_pre_emphasis_hbr3_hbr2[v_level][p_level]; > + voltage = qmp_dp_v3_voltage_swing_hbr3_hbr2[v_level][p_level]; > + emphasis = qmp_dp_v3_pre_emphasis_hbr3_hbr2[v_level][p_level]; > } > > /* TODO: Move check to config check */ > - if (voltage_swing_cfg == 0xFF && pre_emphasis_cfg == 0xFF) > + if (voltage == 0xFF && emphasis == 0xFF) > return -EINVAL; > > /* Enable MUX to use Cursor values from these registers */ > - voltage_swing_cfg |= DP_PHY_TXn_TX_DRV_LVL_MUX_EN; > - pre_emphasis_cfg |= DP_PHY_TXn_TX_EMP_POST1_LVL_MUX_EN; > - > - writel(voltage_swing_cfg, qphy->tx + drv_lvl_reg); > - writel(pre_emphasis_cfg, qphy->tx + emp_post_reg); > - writel(voltage_swing_cfg, qphy->tx2 + drv_lvl_reg); > - writel(pre_emphasis_cfg, qphy->tx2 + emp_post_reg); > + voltage |= DP_PHY_TXn_TX_DRV_LVL_MUX_EN; > + emphasis |= DP_PHY_TXn_TX_EMP_POST1_LVL_MUX_EN; > > + writel(voltage, qphy->tx + QSERDES_V3_TX_TX_DRV_LVL); > + writel(emphasis, qphy->tx + QSERDES_V3_TX_TX_EMP_POST1_LVL); > + writel(voltage, qphy->tx2 + QSERDES_V3_TX_TX_DRV_LVL); > + writel(emphasis, qphy->tx2 + QSERDES_V3_TX_TX_EMP_POST1_LVL); > return 0; > } > > @@ -3588,9 +3586,7 @@ static void qcom_qmp_v3_phy_configure_dp_tx(struct qmp_phy *qphy) > const struct phy_configure_opts_dp *dp_opts = &qphy->dp_opts; > u32 bias_en, drvr_en; > > - if (qcom_qmp_phy_configure_dp_swing(qphy, > - QSERDES_V3_TX_TX_DRV_LVL, > - QSERDES_V3_TX_TX_EMP_POST1_LVL) < 0) > + if (qcom_qmp_phy_configure_dp_swing(qphy) < 0) > return; > > if (dp_opts->lanes == 1) { > @@ -3728,6 +3724,71 @@ static int qcom_qmp_v3_dp_phy_calibrate(struct qmp_phy *qphy) > return 0; > } > > +/* The values in these tables are given without MUX_EN (0x20) bit set */ > +static const u8 qmp_dp_v4_pre_emphasis_hbr3_hbr2[4][4] = { > + { 0x00, 0x0c, 0x15, 0x1b }, > + { 0x02, 0x0e, 0x16, 0xff }, > + { 0x02, 0x11, 0xff, 0xff }, > + { 0x04, 0xff, 0xff, 0xff } > +}; > + > +static const u8 qmp_dp_v4_voltage_swing_hbr3_hbr2[4][4] = { > + { 0x02, 0x12, 0x16, 0x1a }, > + { 0x09, 0x19, 0x1f, 0xff }, > + { 0x10, 0x1f, 0xff, 0xff }, > + { 0x1f, 0xff, 0xff, 0xff } > +}; > + > +static const u8 qmp_dp_v4_pre_emphasis_hbr_rbr[4][4] = { > + { 0x00, 0x0e, 0x15, 0x1b }, > + { 0x00, 0x0e, 0x15, 0xff }, > + { 0x00, 0x0e, 0xff, 0xff }, > + { 0x04, 0xff, 0xff, 0xff } > +}; > + > +static const u8 qmp_dp_v4_voltage_swing_hbr_rbr[4][4] = { > + { 0x08, 0x0f, 0x16, 0x1f }, > + { 0x11, 0x1e, 0x1f, 0xff }, > + { 0x16, 0x1f, 0xff, 0xff }, > + { 0x1f, 0xff, 0xff, 0xff } > +}; > + > +static int qcom_qmp_v4_phy_configure_dp_swing(struct qmp_phy *qphy) > +{ > + const struct phy_configure_opts_dp *dp_opts = &qphy->dp_opts; > + unsigned int v_level = 0, p_level = 0; > + u8 voltage, emphasis; > + int i; > + > + for (i = 0; i < dp_opts->lanes; i++) { > + v_level = max(v_level, dp_opts->voltage[i]); > + p_level = max(p_level, dp_opts->pre[i]); > + } > + > + if (dp_opts->link_rate <= 2700) { > + voltage = qmp_dp_v4_voltage_swing_hbr_rbr[v_level][p_level]; > + emphasis = qmp_dp_v4_pre_emphasis_hbr_rbr[v_level][p_level]; > + } else { > + voltage = qmp_dp_v4_voltage_swing_hbr3_hbr2[v_level][p_level]; > + emphasis = qmp_dp_v4_pre_emphasis_hbr3_hbr2[v_level][p_level]; > + } > + > + /* TODO: Move check to config check */ > + if (voltage == 0xFF && emphasis == 0xFF) > + return -EINVAL; > + > + /* Enable MUX to use Cursor values from these registers */ > + voltage |= DP_PHY_TXn_TX_DRV_LVL_MUX_EN; > + emphasis |= DP_PHY_TXn_TX_EMP_POST1_LVL_MUX_EN; > + > + writel(voltage, qphy->tx + QSERDES_V4_TX_TX_DRV_LVL); > + writel(emphasis, qphy->tx + QSERDES_V4_TX_TX_EMP_POST1_LVL); > + writel(voltage, qphy->tx2 + QSERDES_V4_TX_TX_DRV_LVL); > + writel(emphasis, qphy->tx2 + QSERDES_V4_TX_TX_EMP_POST1_LVL); > + > + return 0; > +} > + > static void qcom_qmp_v4_phy_dp_aux_init(struct qmp_phy *qphy) > { > writel(DP_PHY_PD_CTL_PWRDN | DP_PHY_PD_CTL_PSR_PWRDN | DP_PHY_PD_CTL_AUX_PWRDN | > @@ -3757,16 +3818,7 @@ static void qcom_qmp_v4_phy_dp_aux_init(struct qmp_phy *qphy) > > static void qcom_qmp_v4_phy_configure_dp_tx(struct qmp_phy *qphy) > { > - /* Program default values before writing proper values */ > - writel(0x27, qphy->tx + QSERDES_V4_TX_TX_DRV_LVL); > - writel(0x27, qphy->tx2 + QSERDES_V4_TX_TX_DRV_LVL); > - > - writel(0x20, qphy->tx + QSERDES_V4_TX_TX_EMP_POST1_LVL); > - writel(0x20, qphy->tx2 + QSERDES_V4_TX_TX_EMP_POST1_LVL); > - > - qcom_qmp_phy_configure_dp_swing(qphy, > - QSERDES_V4_TX_TX_DRV_LVL, > - QSERDES_V4_TX_TX_EMP_POST1_LVL); > + qcom_qmp_v4_phy_configure_dp_swing(qphy); > } > > static int qcom_qmp_v4_phy_configure_dp_phy(struct qmp_phy *qphy) > @@ -3885,6 +3937,9 @@ static int qcom_qmp_v4_phy_configure_dp_phy(struct qmp_phy *qphy) > writel(drvr1_en, qphy->tx2 + QSERDES_V4_TX_HIGHZ_DRVR_EN); > writel(bias1_en, qphy->tx2 + QSERDES_V4_TX_TRANSCEIVER_BIAS_EN); > > + writel(0x0a, qphy->tx + QSERDES_V4_TX_TX_POL_INV); > + writel(0x0a, qphy->tx2 + QSERDES_V4_TX_TX_POL_INV); > + > writel(0x18, qphy->pcs + QSERDES_DP_PHY_CFG); > udelay(2000); > writel(0x19, qphy->pcs + QSERDES_DP_PHY_CFG); > @@ -3896,11 +3951,9 @@ static int qcom_qmp_v4_phy_configure_dp_phy(struct qmp_phy *qphy) > 10000)) > return -ETIMEDOUT; > > - writel(0x0a, qphy->tx + QSERDES_V4_TX_TX_POL_INV); > - writel(0x0a, qphy->tx2 + QSERDES_V4_TX_TX_POL_INV); > > - writel(0x27, qphy->tx + QSERDES_V4_TX_TX_DRV_LVL); > - writel(0x27, qphy->tx2 + QSERDES_V4_TX_TX_DRV_LVL); > + writel(0x22, qphy->tx + QSERDES_V4_TX_TX_DRV_LVL); > + writel(0x22, qphy->tx2 + QSERDES_V4_TX_TX_DRV_LVL); > > writel(0x20, qphy->tx + QSERDES_V4_TX_TX_EMP_POST1_LVL); > writel(0x20, qphy->tx2 + QSERDES_V4_TX_TX_EMP_POST1_LVL); > -- With best wishes Dmitry