From patchwork Tue Nov 5 01:55:23 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Chen X-Patchwork-Id: 3138691 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 565619F3C4 for ; Tue, 5 Nov 2013 02:18:42 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 42E0C205F5 for ; Tue, 5 Nov 2013 02:18:41 +0000 (UTC) Received: from casper.infradead.org (casper.infradead.org [85.118.1.10]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 27780205E5 for ; Tue, 5 Nov 2013 02:18:40 +0000 (UTC) Received: from merlin.infradead.org ([2001:4978:20e::2]) by casper.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1VdWCP-0005aA-VX; Tue, 05 Nov 2013 02:16:58 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1VdWBv-0004bj-UC; Tue, 05 Nov 2013 02:16:27 +0000 Received: from ch1ehsobe003.messaging.microsoft.com ([216.32.181.183] helo=ch1outboundpool.messaging.microsoft.com) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1VdWBt-0004Yt-RG for linux-arm-kernel@lists.infradead.org; Tue, 05 Nov 2013 02:16:26 +0000 Received: from mail120-ch1-R.bigfish.com (10.43.68.238) by CH1EHSOBE004.bigfish.com (10.43.70.54) with Microsoft SMTP Server id 14.1.225.22; Tue, 5 Nov 2013 02:16:04 +0000 Received: from mail120-ch1 (localhost [127.0.0.1]) by mail120-ch1-R.bigfish.com (Postfix) with ESMTP id 0D7422400EC; Tue, 5 Nov 2013 02:16:04 +0000 (UTC) X-Forefront-Antispam-Report: CIP:70.37.183.190; KIP:(null); UIP:(null); IPV:NLI; H:mail.freescale.net; RD:none; EFVD:NLI X-SpamScore: 0 X-BigFish: VS0(zzzz1f42h2148h208ch1ee6h1de0h1fdah2073h2146h1202h1e76h1d1ah1d2ah1fc6hzz1de098h8275bh1de097hz2dh2a8h839hd24he5bhf0ah1288h12a5h12a9h12bdh12e5h137ah139eh13b6h1441h1504h1537h162dh1631h1758h1898h18e1h1946h19b5h1ad9h1b0ah1b2fh2222h1fb3h1d0ch1d2eh1d3fh1dfeh1dffh1e23h1fe8h1ff5h2218h2216h1155h) Received: from mail120-ch1 (localhost.localdomain [127.0.0.1]) by mail120-ch1 (MessageSwitch) id 1383617761382970_31663; Tue, 5 Nov 2013 02:16:01 +0000 (UTC) Received: from CH1EHSMHS026.bigfish.com (snatpool2.int.messaging.microsoft.com [10.43.68.237]) by mail120-ch1.bigfish.com (Postfix) with ESMTP id 4C9F5340040; Tue, 5 Nov 2013 02:16:01 +0000 (UTC) Received: from mail.freescale.net (70.37.183.190) by CH1EHSMHS026.bigfish.com (10.43.70.26) with Microsoft SMTP Server (TLS) id 14.16.227.3; Tue, 5 Nov 2013 02:16:00 +0000 Received: from az84smr01.freescale.net (10.64.34.197) by 039-SN1MMR1-003.039d.mgd.msft.net (10.84.1.16) with Microsoft SMTP Server (TLS) id 14.3.158.2; Tue, 5 Nov 2013 02:16:00 +0000 Received: from shlinux1.ap.freescale.net (shlinux1.ap.freescale.net [10.192.225.216]) by az84smr01.freescale.net (8.14.3/8.14.0) with ESMTP id rA52FMTw027964; Mon, 4 Nov 2013 19:15:56 -0700 From: Peter Chen To: , , Subject: [PATCH v3 08/10] usb: chipidea: host: add quirk for ehci operation Date: Tue, 5 Nov 2013 09:55:23 +0800 Message-ID: <1383616525-10769-9-git-send-email-peter.chen@freescale.com> X-Mailer: git-send-email 1.7.1 In-Reply-To: <1383616525-10769-1-git-send-email-peter.chen@freescale.com> References: <1383616525-10769-1-git-send-email-peter.chen@freescale.com> MIME-Version: 1.0 X-OriginatorOrg: freescale.com X-FOPE-CONNECTOR: Id%0$Dn%*$RO%0$TLS%0$FQDN%$TlsDn% X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20131104_211625_922159_57F70060 X-CRM114-Status: GOOD ( 16.18 ) X-Spam-Score: -2.6 (--) Cc: marex@denx.de, m.grzeschik@pengutronix.de, frank.li@freescale.com, alexander.shishkin@linux.intel.com, linux-usb@vger.kernel.org, peter.chen@freescale.com, kernel@pengutronix.de, linux@arm.linux.org.uk, festevam@gmail.com, linux-arm-kernel@lists.infradead.org, lw@karo-electronics.de X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP For chipidea controller, it does not follow ehci spec strictly. Taking resume signal as an example, it will stop resume signal about 20-21ms later automatically, but standard ehci spec says, the resume signal is controlled by software (clear portsc.PORT_RESUME). This operation causes some remote wakeup problems for high speed devices due to host controller does not send SOF in time since software can't guarantee set run/stop bit in time (run/stop bit was cleared at the ehci suspend routine). When software sets run/stop bit, it needs 1 SoF time to make it effect. If we close the PHY clock just after setting run/stop bit, it does not be set in practice, so a software delay is needed. Signed-off-by: Peter Chen --- drivers/usb/chipidea/host.c | 51 +++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 51 insertions(+), 0 deletions(-) diff --git a/drivers/usb/chipidea/host.c b/drivers/usb/chipidea/host.c index 06fd042..de0c2de 100644 --- a/drivers/usb/chipidea/host.c +++ b/drivers/usb/chipidea/host.c @@ -33,6 +33,53 @@ #include "host.h" static struct hc_driver __read_mostly ci_ehci_hc_driver; +static int (*orig_bus_suspend)(struct usb_hcd *hcd); + +static int ci_ehci_bus_suspend(struct usb_hcd *hcd) +{ + struct ehci_hcd *ehci = hcd_to_ehci(hcd); + int port; + u32 tmp; + + int ret = orig_bus_suspend(hcd); + + if (ret) + return ret; + + port = HCS_N_PORTS(ehci->hcs_params); + while (port--) { + u32 __iomem *reg = &ehci->regs->port_status[port]; + u32 portsc = ehci_readl(ehci, reg); + + if (portsc & PORT_CONNECT) { + /* + * For chipidea, the resume signal will be ended + * automatically, so for remote wakeup case, the + * usbcmd.rs may not be set before the resume has + * ended if other resume path consumes too much + * time (~23ms-24ms), in that case, the SOF will not + * send out within 3ms after resume ends, then the + * device will enter suspend again. + */ + if (hcd->self.root_hub->do_remote_wakeup) { + ehci_dbg(ehci, + "Remote wakeup is enabled, " + "and device is on the port\n"); + + tmp = ehci_readl(ehci, &ehci->regs->command); + tmp |= CMD_RUN; + ehci_writel(ehci, tmp, &ehci->regs->command); + /* + * It needs a short delay between set RUNSTOP + * and set PHCD. + */ + udelay(125); + } + } + } + + return 0; +} static irqreturn_t host_irq(struct ci_hdrc *ci) { @@ -135,5 +182,9 @@ int ci_hdrc_host_init(struct ci_hdrc *ci) ehci_init_driver(&ci_ehci_hc_driver, NULL); + orig_bus_suspend = ci_ehci_hc_driver.bus_suspend; + + ci_ehci_hc_driver.bus_suspend = ci_ehci_bus_suspend; + return 0; }