From patchwork Sat Sep 3 21:55:28 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Randy Li X-Patchwork-Id: 9312289 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 349C66075E for ; Sat, 3 Sep 2016 21:56:13 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2C919289C2 for ; Sat, 3 Sep 2016 21:56:13 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 20FB128CD0; Sat, 3 Sep 2016 21:56:13 +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=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id C1830289C2 for ; Sat, 3 Sep 2016 21:56:12 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.85_2 #1 (Red Hat Linux)) id 1bgIv6-0006jz-Eg; Sat, 03 Sep 2016 21:56:12 +0000 Received: from kozue.soulik.info ([108.61.200.231]) by bombadil.infradead.org with esmtps (Exim 4.85_2 #1 (Red Hat Linux)) id 1bgIuz-0006gj-KC for linux-rockchip@lists.infradead.org; Sat, 03 Sep 2016 21:56:07 +0000 Received: from ritsuko.sumomo.pri (unknown [IPv6:2001:470:b30d:2::3bd]) by kozue.soulik.info (Postfix) with ESMTPA id 47D101028E9; Sun, 4 Sep 2016 06:55:47 +0900 (JST) From: Randy Li To: linux-usb@vger.kernel.org Subject: [PATCH v7 3/4] usb: dwc2: assert phy reset when waking up in rk3288 platform Date: Sun, 4 Sep 2016 05:55:28 +0800 Message-Id: <1472939729-15187-4-git-send-email-ayaka@soulik.info> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1472939729-15187-1-git-send-email-ayaka@soulik.info> References: <1472939729-15187-1-git-send-email-ayaka@soulik.info> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160903_145605_851910_125F2FE2 X-CRM114-Status: GOOD ( 10.40 ) X-BeenThere: linux-rockchip@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: Upstream kernel work for Rockchip platforms List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: mark.rutland@arm.com, devicetree@vger.kernel.org, heiko@sntech.de, felipe.balbi@linux.intel.com, gregkh@linuxfoundation.org, Randy Li , randy.li@rock-chips.com, linux-kernel@vger.kernel.org, John.Youn@synopsys.com, linux-rockchip@lists.infradead.org, robh+dt@kernel.org, kishon@ti.com MIME-Version: 1.0 Sender: "Linux-rockchip" Errors-To: linux-rockchip-bounces+patchwork-linux-rockchip=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP On the rk3288 USB host-only port (the one that's not the OTG-enabled port) the PHY can get into a bad state when a wakeup is asserted (not just a wakeup from full system suspend but also a wakeup from autosuspend). We can get the PHY out of its bad state by asserting its "port reset", but unfortunately that seems to assert a reset onto the USB bus so it could confuse things if we don't actually deenumerate / reenumerate the device. We can also get the PHY out of its bad state by fully resetting it using the reset from the CRU (clock reset unit) in chip, which does a more full reset. The CRU-based reset appears to actually cause devices on the bus to be removed and reinserted, which fixes the problem (albeit in a hacky way). It's unfortunate that we need to do a full re-enumeration of devices at wakeup time, but this is better than alternative of letting the bus get wedged. Signed-off-by: Randy Li --- drivers/usb/dwc2/core_intr.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/drivers/usb/dwc2/core_intr.c b/drivers/usb/dwc2/core_intr.c index d85c5c9..08485b7 100644 --- a/drivers/usb/dwc2/core_intr.c +++ b/drivers/usb/dwc2/core_intr.c @@ -345,6 +345,7 @@ static void dwc2_handle_session_req_intr(struct dwc2_hsotg *hsotg) static void dwc2_handle_wakeup_detected_intr(struct dwc2_hsotg *hsotg) { int ret; + struct device_node *np = hsotg->dev->of_node; /* Clear interrupt */ dwc2_writel(GINTSTS_WKUPINT, hsotg->regs + GINTSTS); @@ -379,6 +380,17 @@ static void dwc2_handle_wakeup_detected_intr(struct dwc2_hsotg *hsotg) /* Restart the Phy Clock */ pcgcctl &= ~PCGCTL_STOPPCLK; dwc2_writel(pcgcctl, hsotg->regs + PCGCTL); + + /* + * It is a quirk in Rockchip RK3288, causing by + * a hardware bug. This will propagate out and + * eventually we'll re-enumerate the device. + * Not great but the best we can do + */ + if (of_device_is_compatible(np, "rockchip,rk3288-usb") + && (NULL != hsotg->phy->ops->reset)) + hsotg->phy->ops->reset(hsotg->phy); + mod_timer(&hsotg->wkp_timer, jiffies + msecs_to_jiffies(71)); } else {