From patchwork Wed Sep 19 11:30:27 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kishon Vijay Abraham I X-Patchwork-Id: 1476911 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) by patchwork2.kernel.org (Postfix) with ESMTP id F29ADDF280 for ; Wed, 19 Sep 2012 11:33:12 +0000 (UTC) Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1TEIUz-0001PG-8U; Wed, 19 Sep 2012 11:31:21 +0000 Received: from devils.ext.ti.com ([198.47.26.153]) by merlin.infradead.org with esmtps (Exim 4.76 #1 (Red Hat Linux)) id 1TEIUS-0001FY-QK for linux-arm-kernel@lists.infradead.org; Wed, 19 Sep 2012 11:30:50 +0000 Received: from dbdp20.itg.ti.com ([172.24.170.38]) by devils.ext.ti.com (8.13.7/8.13.7) with ESMTP id q8JBUeZQ015752; Wed, 19 Sep 2012 06:30:41 -0500 Received: from DBDE71.ent.ti.com (localhost [127.0.0.1]) by dbdp20.itg.ti.com (8.13.8/8.13.8) with ESMTP id q8JBUaSK009710; Wed, 19 Sep 2012 17:00:39 +0530 (IST) Received: from dbdp32.itg.ti.com (172.24.170.251) by DBDE71.ent.ti.com (172.24.170.149) with Microsoft SMTP Server id 14.1.323.3; Wed, 19 Sep 2012 17:00:36 +0530 Received: from a0393678lt.apr.dhcp.ti.com (smtpvbd.itg.ti.com [172.24.170.250]) by dbdp32.itg.ti.com (8.13.8/8.13.8) with ESMTP id q8JBUU3S005476; Wed, 19 Sep 2012 17:00:36 +0530 From: Kishon Vijay Abraham I To: , , , , , , , , , , , Subject: [PATCH 2/4] usb: dwc3: Fix gadget pullup in SS mode Date: Wed, 19 Sep 2012 17:00:27 +0530 Message-ID: <1348054229-27362-3-git-send-email-kishon@ti.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1348054229-27362-1-git-send-email-kishon@ti.com> References: <1348054229-27362-1-git-send-email-kishon@ti.com> MIME-Version: 1.0 X-Spam-Note: CRM114 invocation failed X-Spam-Score: -7.5 (-------) X-Spam-Report: SpamAssassin version 3.3.2 on merlin.infradead.org summary: Content analysis details: (-7.5 points) pts rule name description ---- ---------------------- -------------------------------------------------- -5.0 RCVD_IN_DNSWL_HI RBL: Sender listed at http://www.dnswl.org/, high trust [198.47.26.153 listed in list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record -0.6 RP_MATCHES_RCVD Envelope sender domain matches handover relay domain -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] Cc: Moiz Sonasath X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: linux-arm-kernel-bounces@lists.infradead.org Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org From: Moiz Sonasath For the gadget pullup functionality to work in SS mode it requires a particular sequence of toggling the run-stop bit. Here is the required sequence: - Set DCTL[31] - Clear DCTL[31] - Clear OMAP5430_CONTROL_CORE__PHY_POWER_USB[14] - Clear DCTL[8:5] = 0x00 - Set DCTL[8:5] = 0x05 - Wait 25 Ms - Set DCTL[31] - Set OMAP5430_CONTROL_CORE__PHY_POWER_USB[14] Tested rigourously the gadget pull-up functionality in bot HS and SS modes. Signed-off-by: Moiz Sonasath Signed-off-by: Kishon Vijay Abraham I --- drivers/usb/dwc3/gadget.c | 21 +++++++++++++++------ drivers/usb/phy/omap-usb3.c | 16 ++++++++++++++++ include/linux/usb/phy.h | 10 +++++++++- 3 files changed, 40 insertions(+), 7 deletions(-) diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c index 58fdfad..bcc0102 100644 --- a/drivers/usb/dwc3/gadget.c +++ b/drivers/usb/dwc3/gadget.c @@ -49,6 +49,7 @@ #include #include +#include #include "core.h" #include "gadget.h" @@ -1417,19 +1418,27 @@ static int dwc3_gadget_run_stop(struct dwc3 *dwc, int is_on) reg = dwc3_readl(dwc->regs, DWC3_DCTL); if (is_on) { if (dwc->revision <= DWC3_REVISION_187A) { - reg &= ~DWC3_DCTL_TRGTULST_MASK; - reg |= DWC3_DCTL_TRGTULST_RX_DET; + reg &= ~DWC3_DCTL_ULSTCHNGREQ_MASK; + dwc3_writel(dwc->regs, DWC3_DCTL, reg); + reg |= DWC3_DCTL_ULSTCHNG_RX_DETECT; + dwc3_writel(dwc->regs, DWC3_DCTL, reg); + mdelay(25); + reg |= DWC3_DCTL_RUN_STOP; + dwc3_writel(dwc->regs, DWC3_DCTL, reg); + usb_phy_poweron(dwc->usb3_phy); } - if (dwc->revision >= DWC3_REVISION_194A) + if (dwc->revision >= DWC3_REVISION_194A) { reg &= ~DWC3_DCTL_KEEP_CONNECT; - reg |= DWC3_DCTL_RUN_STOP; + reg |= DWC3_DCTL_RUN_STOP; + dwc3_writel(dwc->regs, DWC3_DCTL, reg); + } } else { reg &= ~DWC3_DCTL_RUN_STOP; + dwc3_writel(dwc->regs, DWC3_DCTL, reg); + usb_phy_shutdown(dwc->usb3_phy); } - dwc3_writel(dwc->regs, DWC3_DCTL, reg); - do { reg = dwc3_readl(dwc->regs, DWC3_DSTS); if (is_on) { diff --git a/drivers/usb/phy/omap-usb3.c b/drivers/usb/phy/omap-usb3.c index 4dc84ca..26402d5 100644 --- a/drivers/usb/phy/omap-usb3.c +++ b/drivers/usb/phy/omap-usb3.c @@ -212,6 +212,20 @@ static int omap_usb3_init(struct usb_phy *x) return 0; } +static void omap_usb3_poweron(struct usb_phy *x) +{ + struct omap_usb *phy = phy_to_omapusb(x); + + omap5_usb_phy_power(phy, 1); +} + +static void omap_usb3_shutdown(struct usb_phy *x) +{ + struct omap_usb *phy = phy_to_omapusb(x); + + omap5_usb_phy_power(phy, 0); +} + static int __devinit omap_usb3_probe(struct platform_device *pdev) { struct omap_usb *phy; @@ -253,6 +267,8 @@ static int __devinit omap_usb3_probe(struct platform_device *pdev) phy->phy.dev = phy->dev; phy->phy.label = "omap-usb3"; phy->phy.init = omap_usb3_init; + phy->phy.poweron = omap_usb3_poweron; + phy->phy.shutdown = omap_usb3_shutdown; phy->phy.set_suspend = omap_usb3_suspend; phy->is_suspended = 1; diff --git a/include/linux/usb/phy.h b/include/linux/usb/phy.h index 06b5bae..aaa8e16 100644 --- a/include/linux/usb/phy.h +++ b/include/linux/usb/phy.h @@ -86,8 +86,9 @@ struct usb_phy { /* to support controllers that have multiple transceivers */ struct list_head head; - /* initialize/shutdown the OTG controller */ + /* initialize/poweron/shutdown the OTG controller */ int (*init)(struct usb_phy *x); + void (*poweron)(struct usb_phy *x); void (*shutdown)(struct usb_phy *x); /* effective for B devices, ignored for A-peripheral */ @@ -135,6 +136,13 @@ usb_phy_init(struct usb_phy *x) } static inline void +usb_phy_poweron(struct usb_phy *x) +{ + if (x->poweron) + x->poweron(x); +} + +static inline void usb_phy_shutdown(struct usb_phy *x) { if (x->shutdown)