[{"id":1789407,"web_url":"http://patchwork.ozlabs.org/comment/1789407/","msgid":"<e357cfd7-b5a3-29d8-02d7-2bf75a05aa19@ti.com>","list_archive_url":null,"date":"2017-10-18T11:19:27","subject":"Re: [PATCH v3 4/4] phy: rockchip-typec: Do the calibration more\n\tcorrectly","submitter":{"id":14965,"url":"http://patchwork.ozlabs.org/api/people/14965/","name":"Kishon Vijay Abraham I","email":"kishon@ti.com"},"content":"On Friday 22 September 2017 10:14 PM, Douglas Anderson wrote:\n> Calculate the calibration code as per the docs.  The docs talk about\n> reading and averaging the pullup and pulldown calibration codes.  They\n> also talk about adding in some adjustment codes.  Let's do what the\n> docs say.\n> \n> In practice this doesn't seem to matter a whole lot.  On a device I\n> tested the pullup and pulldown codes were nearly the same (0x23 and\n> 0x24) and the adjustment codes were 0.\n> \n> Reviewed-by: Chris Zhong <zyw@rock-chips.com>\n> Signed-off-by: Douglas Anderson <dianders@chromium.org>\n\nmerged the 3rd and 4th patch to next. Thanks!\n\n-Kishon\n> ---\n> \n> Changes in v3: None\n> Changes in v2:\n> - Removed extra blank line.\n> \n>  drivers/phy/rockchip/phy-rockchip-typec.c | 27 ++++++++++++++++++---------\n>  1 file changed, 18 insertions(+), 9 deletions(-)\n> \n> diff --git a/drivers/phy/rockchip/phy-rockchip-typec.c b/drivers/phy/rockchip/phy-rockchip-typec.c\n> index 95f8f23676b4..a96635447d48 100644\n> --- a/drivers/phy/rockchip/phy-rockchip-typec.c\n> +++ b/drivers/phy/rockchip/phy-rockchip-typec.c\n> @@ -560,24 +560,33 @@ static void tcphy_dp_aux_calibration(struct rockchip_typec_phy *tcphy)\n>  \tu16 val;\n>  \tu16 tx_ana_ctrl_reg_1;\n>  \tu16 tx_ana_ctrl_reg_2;\n> -\ts32 pu_calib_code;\n> -\n> -\t/* disable txda_cal_latch_en for rewrite the calibration values */\n> -\ttx_ana_ctrl_reg_1 = readl(tcphy->base + TX_ANA_CTRL_REG_1);\n> -\ttx_ana_ctrl_reg_1 &= ~TXDA_CAL_LATCH_EN;\n> -\twritel(tx_ana_ctrl_reg_1, tcphy->base + TX_ANA_CTRL_REG_1);\n> +\ts32 pu_calib_code, pd_calib_code;\n> +\ts32 pu_adj, pd_adj;\n> +\tu16 calib;\n>  \n>  \t/*\n> -\t * read a resistor calibration code from CMN_TXPUCAL_CTRL[5:0] and\n> -\t * write it to TX_DIG_CTRL_REG_2[5:0].\n> +\t * Calculate calibration code as per docs: use an average of the\n> +\t * pull down and pull up.  Then add in adjustments.\n>  \t */\n>  \tval = readl(tcphy->base + CMN_TXPUCAL_CTRL);\n>  \tpu_calib_code = CMN_CALIB_CODE_POS(val);\n> +\tval = readl(tcphy->base + CMN_TXPDCAL_CTRL);\n> +\tpd_calib_code = CMN_CALIB_CODE_POS(val);\n> +\tval = readl(tcphy->base + CMN_TXPU_ADJ_CTRL);\n> +\tpu_adj = CMN_CALIB_CODE(val);\n> +\tval = readl(tcphy->base + CMN_TXPD_ADJ_CTRL);\n> +\tpd_adj = CMN_CALIB_CODE(val);\n> +\tcalib = (pu_calib_code + pd_calib_code) / 2 + pu_adj + pd_adj;\n> +\n> +\t/* disable txda_cal_latch_en for rewrite the calibration values */\n> +\ttx_ana_ctrl_reg_1 = readl(tcphy->base + TX_ANA_CTRL_REG_1);\n> +\ttx_ana_ctrl_reg_1 &= ~TXDA_CAL_LATCH_EN;\n> +\twritel(tx_ana_ctrl_reg_1, tcphy->base + TX_ANA_CTRL_REG_1);\n>  \n>  \t/* write the calibration, then delay 10 ms as sample in docs */\n>  \tval = readl(tcphy->base + TX_DIG_CTRL_REG_2);\n>  \tval &= ~(TX_RESCAL_CODE_MASK << TX_RESCAL_CODE_OFFSET);\n> -\tval |= pu_calib_code << TX_RESCAL_CODE_OFFSET;\n> +\tval |= calib << TX_RESCAL_CODE_OFFSET;\n>  \twritel(val, tcphy->base + TX_DIG_CTRL_REG_2);\n>  \tusleep_range(10000, 10050);\n>  \n>","headers":{"Return-Path":"<linux-arm-kernel-bounces+incoming-imx=patchwork.ozlabs.org@lists.infradead.org>","X-Original-To":"incoming-imx@patchwork.ozlabs.org","Delivered-To":"patchwork-incoming-imx@bilbo.ozlabs.org","Authentication-Results":["ozlabs.org;\n\tspf=none (mailfrom) smtp.mailfrom=lists.infradead.org\n\t(client-ip=65.50.211.133; helo=bombadil.infradead.org;\n\tenvelope-from=linux-arm-kernel-bounces+incoming-imx=patchwork.ozlabs.org@lists.infradead.org;\n\treceiver=<UNKNOWN>)","ozlabs.org; dkim=pass (2048-bit key;\n\tunprotected) header.d=lists.infradead.org\n\theader.i=@lists.infradead.org header.b=\"Wa+isuXd\"; \n\tdkim=fail reason=\"signature verification failed\" (1024-bit key;\n\tunprotected) header.d=ti.com header.i=@ti.com header.b=\"FWzg/SGL\"; \n\tdkim-atps=neutral"],"Received":["from bombadil.infradead.org (bombadil.infradead.org\n\t[65.50.211.133])\n\t(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256\n\tbits)) (No client certificate requested)\n\tby ozlabs.org (Postfix) with ESMTPS id 3yH8kF6PYQz9t4P\n\tfor <incoming-imx@patchwork.ozlabs.org>;\n\tWed, 18 Oct 2017 22:20:37 +1100 (AEDT)","from localhost ([127.0.0.1] helo=bombadil.infradead.org)\n\tby bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux))\n\tid 1e4mOm-0006Q8-HF; Wed, 18 Oct 2017 11:20:32 +0000","from fllnx209.ext.ti.com ([198.47.19.16])\n\tby bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux))\n\tid 1e4mOe-0005CT-9u; Wed, 18 Oct 2017 11:20:29 +0000","from dflxv15.itg.ti.com ([128.247.5.124])\n\tby fllnx209.ext.ti.com (8.15.1/8.15.1) with ESMTP id v9IBJarV028078; \n\tWed, 18 Oct 2017 06:19:36 -0500","from DFLE112.ent.ti.com (dfle112.ent.ti.com [10.64.6.33])\n\tby dflxv15.itg.ti.com (8.14.3/8.13.8) with ESMTP id v9IBJV6G002088;\n\tWed, 18 Oct 2017 06:19:31 -0500","from DFLE102.ent.ti.com (10.64.6.23) by DFLE112.ent.ti.com\n\t(10.64.6.33) with Microsoft SMTP Server (version=TLS1_2,\n\tcipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.1.845.34;\n\tWed, 18 Oct 2017 06:19:31 -0500","from dlep33.itg.ti.com (157.170.170.75) by DFLE102.ent.ti.com\n\t(10.64.6.23) with Microsoft SMTP Server (version=TLS1_0,\n\tcipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.1.845.34 via Frontend\n\tTransport; Wed, 18 Oct 2017 06:19:31 -0500","from [172.24.190.233] (ileax41-snat.itg.ti.com [10.172.224.153])\n\tby dlep33.itg.ti.com (8.14.3/8.13.8) with ESMTP id v9IBJSQi016655;\n\tWed, 18 Oct 2017 06:19:28 -0500"],"DKIM-Signature":["v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed;\n\td=lists.infradead.org; s=bombadil.20170209; h=Sender:\n\tContent-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post:\n\tList-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:Date:\n\tMessage-ID:From:References:To:Subject:Reply-To:Content-ID:Content-Description\n\t:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:\n\tList-Owner; bh=KGo7ZKtYbBIaauvb7N7dnvm8m+sSdrBGU/ZFbA1lems=;\n\tb=Wa+isuXdFz3g+c\n\tN3B2gPF6URBxbx+8NmK1LIHzhENPoqHeUJcbA+Y2sbbS2hSfGzmEKL32FJwszw8R5ktM1S+eljek2\n\tTgPdBolEnnJ1BiV7bh85SM5cRoTXiTjzHPA9CmXyUmJvYbC8h0n31YEjbKTJUogU2Overr+SArE/P\n\tXJDnQew0yLtNV6Dv7V1oUMdu897IbiVDLQLk/If/0p2+Mf7Z4eRuLZbdbmXknWlMNKe22rLFLMDvf\n\twwkRKrnXGdCrs1q8MTWFjv3w+a+ocYKJYKSmIJTC6EKI+nK7IJq8Y7ICDLHH97XX57XVp+WmP85T+\n\terKXdS9C83P3KBl0r0aA==;","v=1; a=rsa-sha256; c=relaxed/simple; d=ti.com;\n\ts=ti-com-17Q1; t=1508325576;\n\tbh=0YPma6TSqGr99vo1k7aTAMwb4bfWYnVWiaTAjK80JJA=;\n\th=Subject:To:References:CC:From:Date:In-Reply-To;\n\tb=FWzg/SGL2wjhj82RoxbtS5L6K/YBNFxxow4Lhjs022+9qsRHR1XDuTLNqclNdbTpf\n\teBd78nRwRqeWFgFjVhAUNOIlJV4en5LRH0VnHXA3mAG0fT+sQwTrE++oeuWF9RW8NN\n\ta3Hzp0PhJWt+Rxm3nmFMRWa6EBwPJp4OhAegEbPE="],"Subject":"Re: [PATCH v3 4/4] phy: rockchip-typec: Do the calibration more\n\tcorrectly","To":"Douglas Anderson <dianders@chromium.org>, <heiko@sntech.de>,\n\t<zyw@rock-chips.com>","References":"<20170922164406.27606-1-dianders@chromium.org>\n\t<20170922164406.27606-5-dianders@chromium.org>","From":"Kishon Vijay Abraham I <kishon@ti.com>","Message-ID":"<e357cfd7-b5a3-29d8-02d7-2bf75a05aa19@ti.com>","Date":"Wed, 18 Oct 2017 16:49:27 +0530","User-Agent":"Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101\n\tThunderbird/45.7.0","MIME-Version":"1.0","In-Reply-To":"<20170922164406.27606-5-dianders@chromium.org>","X-EXCLAIMER-MD-CONFIG":"e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180","X-CRM114-Version":"20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 ","X-CRM114-CacheID":"sfid-20171018_042024_476734_801D5CC4 ","X-CRM114-Status":"GOOD (  13.29  )","X-Spam-Score":"-2.0 (--)","X-Spam-Report":"SpamAssassin version 3.4.1 on bombadil.infradead.org summary:\n\tContent analysis details:   (-2.0 points)\n\tpts rule name              description\n\t---- ----------------------\n\t--------------------------------------------------\n\t-0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at http://www.dnswl.org/,\n\tno trust [198.47.19.16 listed in list.dnswl.org]\n\t-0.0 SPF_PASS               SPF: sender matches SPF record\n\t-0.0 RP_MATCHES_RCVD Envelope sender domain matches handover relay\n\tdomain\n\t-1.9 BAYES_00               BODY: Bayes spam probability is 0 to 1%\n\t[score: 0.0000]\n\t-0.1 DKIM_VALID Message has at least one valid DKIM or DK signature\n\t0.1 DKIM_SIGNED            Message has a DKIM or DK signature,\n\tnot necessarily valid\n\t-0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from\n\tauthor's domain","X-BeenThere":"linux-arm-kernel@lists.infradead.org","X-Mailman-Version":"2.1.21","Precedence":"list","List-Unsubscribe":"<http://lists.infradead.org/mailman/options/linux-arm-kernel>,\n\t<mailto:linux-arm-kernel-request@lists.infradead.org?subject=unsubscribe>","List-Archive":"<http://lists.infradead.org/pipermail/linux-arm-kernel/>","List-Post":"<mailto:linux-arm-kernel@lists.infradead.org>","List-Help":"<mailto:linux-arm-kernel-request@lists.infradead.org?subject=help>","List-Subscribe":"<http://lists.infradead.org/mailman/listinfo/linux-arm-kernel>,\n\t<mailto:linux-arm-kernel-request@lists.infradead.org?subject=subscribe>","Cc":"shawnn@chromium.org, linux-kernel@vger.kernel.org, dnschneid@chromium.org,\n\tlinux-rockchip@lists.infradead.org, groeck@chromium.org,\n\tlinux-arm-kernel@lists.infradead.org","Content-Type":"text/plain; charset=\"us-ascii\"","Content-Transfer-Encoding":"7bit","Sender":"\"linux-arm-kernel\" <linux-arm-kernel-bounces@lists.infradead.org>","Errors-To":"linux-arm-kernel-bounces+incoming-imx=patchwork.ozlabs.org@lists.infradead.org","List-Id":"linux-imx-kernel.lists.patchwork.ozlabs.org"}}]