From patchwork Fri Jan 12 10:08:24 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: William Wu X-Patchwork-Id: 10160165 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 5B31860327 for ; Fri, 12 Jan 2018 10:09:04 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3AB482893C for ; Fri, 12 Jan 2018 10:09:04 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2F34428982; Fri, 12 Jan 2018 10:09:04 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.7 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, RCVD_IN_DNSWL_MED, RCVD_IN_SORBS_WEB autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 9BE0E2893C for ; Fri, 12 Jan 2018 10:09:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=PP30U5eyzw5mHHL/XjwwRmOnetKVV4Ma3nBpFZBRlzc=; b=XsSgZ9ugZjjnzs4zTGUgjQCBAj s9JBfmxW7xxcQJdC6qufaFl7ADV3f9DoW5WlVJs0iICepUQPBuONnOz5RRuA4IcIOoNoeUIxTsKSX 1K7j9mcz2zUieEm46iZAAebfWqkYpDqgPLa2/0KgKMe8nZljxEIqvdQq9kSkiA0kovRv0M0BtUIpt 6g6ooqrTpzG579CTkGqOFlxoetUFiTtfdsNBRHom2BHO65H724JyR6eZGhyzIfWxGR+9jhXhFpFHc /M7fiv7LYLG+Latyf7WgpX25MBy8fzEWGHjImQlP8EhjpBhJXkzVcm+DkaOSeJCCEKw2IxZpZ6QHx 2dBlEgRw==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.89 #1 (Red Hat Linux)) id 1eZwGj-0001Ow-Hv; Fri, 12 Jan 2018 10:09:01 +0000 Received: from regular1.263xmail.com ([211.150.99.137]) by bombadil.infradead.org with esmtps (Exim 4.89 #1 (Red Hat Linux)) id 1eZwGU-0001Bz-9z; Fri, 12 Jan 2018 10:08:48 +0000 Received: from william.wu?rock-chips.com (unknown [192.168.167.153]) by regular1.263xmail.com (Postfix) with ESMTP id BB88ADC0D; Fri, 12 Jan 2018 18:08:37 +0800 (CST) X-263anti-spam: KSV:0; X-MAIL-GRAY: 0 X-MAIL-DELIVERY: 1 X-KSVirus-check: 0 X-ABS-CHECKED: 4 Received: from localhost.localdomain (localhost [127.0.0.1]) by smtp.263.net (Postfix) with ESMTPA id 984E03AA; Fri, 12 Jan 2018 18:08:34 +0800 (CST) X-RL-SENDER: william.wu@rock-chips.com X-FST-TO: kishon@ti.com X-SENDER-IP: 58.22.7.114 X-LOGIN-NAME: william.wu@rock-chips.com X-UNIQUE-TAG: <2a3f26f5a4fcf42ce801cc40c9e6ce82> X-ATTACHMENT-NUM: 0 X-SENDER: wulf@rock-chips.com X-DNS-TYPE: 0 Received: from unknown (unknown [58.22.7.114]) by smtp.263.net (Postfix) whith SMTP id 25924LQOCBJ; Fri, 12 Jan 2018 18:08:38 +0800 (CST) From: William Wu To: kishon@ti.com Subject: [PATCH 3/3] phy: rockchip-typec: reset USB3 controller before initializing PHY Date: Fri, 12 Jan 2018 18:08:24 +0800 Message-Id: <1515751704-13213-4-git-send-email-william.wu@rock-chips.com> X-Mailer: git-send-email 2.0.0 In-Reply-To: <1515751704-13213-1-git-send-email-william.wu@rock-chips.com> References: <1515751704-13213-1-git-send-email-william.wu@rock-chips.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180112_020846_689235_B92A1B2F X-CRM114-Status: GOOD ( 10.87 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: huangtao@rock-chips.com, devicetree@vger.kernel.org, heiko@sntech.de, groeck@google.com, frank.wang@rock-chips.com, lin.huang@rock-chips.com, linux-kernel@vger.kernel.org, dianders@google.com, linux-rockchip@lists.infradead.org, robh+dt@kernel.org, william.wu@rock-chips.com, briannorris@google.com, John.Youn@synopsys.com, daniel.meng@rock-chips.com, linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP According to the RK3399 TRM, for Type-C USB start-up sequence, we need to hold the whole USB 3.0 OTG controller in reset state to keep the PIPE power state in P2 while initializing PHY. This is because when initialize the Type-C PHY for USB3, we need to configure the PHY and PMA for the selected mode of operation, and wait for the PMA and PIPE ready, if the USB3 OTG controller isn't in P2 state, it may cause waiting timeout. Without this patch, waiting for the PMA and PIPE ready timeout issue easily happens when we shutdown the Logic on RK3399 and do the suspend/resume stress test. Signed-off-by: William Wu Tested-by: Enric Balletbo i Serra --- drivers/phy/rockchip/phy-rockchip-typec.c | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/drivers/phy/rockchip/phy-rockchip-typec.c b/drivers/phy/rockchip/phy-rockchip-typec.c index ee85fa0..68a5840 100644 --- a/drivers/phy/rockchip/phy-rockchip-typec.c +++ b/drivers/phy/rockchip/phy-rockchip-typec.c @@ -372,6 +372,7 @@ struct rockchip_typec_phy { struct reset_control *uphy_rst; struct reset_control *pipe_rst; struct reset_control *tcphy_rst; + struct reset_control *otg_rst; struct rockchip_usb3phy_port_cfg port_cfgs; /* mutex to protect access to individual PHYs */ struct mutex lock; @@ -841,10 +842,16 @@ static int rockchip_usb3_phy_power_on(struct phy *phy) if (tcphy->mode == new_mode) goto unlock_ret; + ret = reset_control_assert(tcphy->otg_rst); + if (ret < 0) { + dev_err(tcphy->dev, "failed to assert otg reset: %d\n", ret); + goto unlock_ret; + } + if (tcphy->mode == MODE_DISCONNECT) { ret = tcphy_phy_init(tcphy, new_mode); if (ret) - goto unlock_ret; + goto unlock_deassert; } /* wait TCPHY for pipe ready */ @@ -852,7 +859,7 @@ static int rockchip_usb3_phy_power_on(struct phy *phy) regmap_read(tcphy->grf_regs, reg->offset, &val); if (!(val & BIT(reg->enable_bit))) { tcphy->mode |= new_mode & (MODE_DFP_USB | MODE_UFP_USB); - goto unlock_ret; + goto unlock_deassert; } usleep_range(10, 20); } @@ -862,6 +869,11 @@ static int rockchip_usb3_phy_power_on(struct phy *phy) ret = -ETIMEDOUT; +unlock_deassert: + ret = reset_control_deassert(tcphy->otg_rst); + if (ret < 0) + dev_err(tcphy->dev, "failed to deassert otg reset: %d\n", ret); + unlock_ret: mutex_unlock(&tcphy->lock); return ret; @@ -1066,6 +1078,12 @@ static int tcphy_parse_dt(struct rockchip_typec_phy *tcphy, return PTR_ERR(tcphy->tcphy_rst); } + tcphy->otg_rst = devm_reset_control_get(dev, "usb3-otg"); + if (IS_ERR(tcphy->otg_rst)) { + dev_err(dev, "no otg_rst reset control found\n"); + return PTR_ERR(tcphy->otg_rst); + } + return 0; }