From patchwork Fri Jul 23 09:36:09 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bryan Wu X-Patchwork-Id: 59760 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from chlorine.canonical.com (chlorine.canonical.com [91.189.94.204]) by ozlabs.org (Postfix) with ESMTP id 217DDB70F2 for ; Fri, 23 Jul 2010 19:36:22 +1000 (EST) Received: from localhost ([127.0.0.1] helo=chlorine.canonical.com) by chlorine.canonical.com with esmtp (Exim 4.69) (envelope-from ) id 1OcEfv-0003QF-Jx; Fri, 23 Jul 2010 10:36:15 +0100 Received: from adelie.canonical.com ([91.189.90.139]) by chlorine.canonical.com with esmtp (Exim 4.69) (envelope-from ) id 1OcEfr-0003N4-G6 for kernel-team@lists.ubuntu.com; Fri, 23 Jul 2010 10:36:11 +0100 Received: from hutte.canonical.com ([91.189.90.181]) by adelie.canonical.com with esmtp (Exim 4.69 #1 (Debian)) id 1OcEfq-0002wv-Dx; Fri, 23 Jul 2010 10:36:10 +0100 Received: from [193.85.232.179] (helo=canonical.com) by hutte.canonical.com with esmtpsa (TLS-1.0:DHE_RSA_AES_128_CBC_SHA1:16) (Exim 4.69) (envelope-from ) id 1OcEfq-0007JU-8I; Fri, 23 Jul 2010 10:36:10 +0100 From: Bryan Wu To: felipe.balbi@nokia.com, linux-usb@vger.kernel.org Subject: [PATCH] musb: move usb_add_hcd to the core init code from gadget code Date: Fri, 23 Jul 2010 17:36:09 +0800 Message-Id: <1279877769-5210-1-git-send-email-bryan.wu@canonical.com> X-Mailer: git-send-email 1.7.0.4 Cc: kernel-team@lists.ubuntu.com, linux-kernel@vger.kernel.org, ricardo.salveti@canonical.com X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.9 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: kernel-team-bounces@lists.ubuntu.com Errors-To: kernel-team-bounces@lists.ubuntu.com BugLink: http://bugs.launchpad.net/bugs/608312 usb_add_hcd was only called when we insmod the gadget class module or built-in that gadget class driver. If musb is configured as OTG controller, we need to insmod or built-in gadget class driver to make our Host mode fucntion works. In our Ubuntu system, normally we compiled all the gadget class drivers as modules. Then users can insmod the gadget modules as they want. But without the gadget class driver running, we needs host function to support common USB devices. This patch fix this issue and tested on omap3 beagle boards. Signed-off-by: Bryan Wu --- drivers/usb/musb/musb_core.c | 15 +++++++-------- drivers/usb/musb/musb_gadget.c | 18 ------------------ 2 files changed, 7 insertions(+), 26 deletions(-) diff --git a/drivers/usb/musb/musb_core.c b/drivers/usb/musb/musb_core.c index 5eb9318..6b30a6d 100644 --- a/drivers/usb/musb/musb_core.c +++ b/drivers/usb/musb/musb_core.c @@ -1521,14 +1521,6 @@ irqreturn_t musb_interrupt(struct musb *musb) (devctl & MUSB_DEVCTL_HM) ? "host" : "peripheral", musb->int_usb, musb->int_tx, musb->int_rx); -#ifdef CONFIG_USB_GADGET_MUSB_HDRC - if (is_otg_enabled(musb) || is_peripheral_enabled(musb)) - if (!musb->gadget_driver) { - DBG(5, "No gadget driver loaded\n"); - return IRQ_HANDLED; - } -#endif - /* the core can interrupt us for multiple reasons; docs have * a generic interrupt flowchart to follow */ @@ -2071,6 +2063,13 @@ bad_config: if (status) goto fail; + if (is_otg_enabled(musb)) { + status = usb_add_hcd(musb_to_hcd(musb), -1, 0); + if (status) + goto fail; + musb_start(musb); + } + DBG(1, "%s mode, status %d, dev%02x\n", is_otg_enabled(musb) ? "OTG" : "PERIPHERAL", status, diff --git a/drivers/usb/musb/musb_gadget.c b/drivers/usb/musb/musb_gadget.c index cbcf14a..ddeb9d8 100644 --- a/drivers/usb/musb/musb_gadget.c +++ b/drivers/usb/musb/musb_gadget.c @@ -1748,24 +1748,6 @@ int usb_gadget_register_driver(struct usb_gadget_driver *driver) otg_set_peripheral(musb->xceiv, &musb->g); spin_unlock_irqrestore(&musb->lock, flags); - - if (is_otg_enabled(musb)) { - DBG(3, "OTG startup...\n"); - - /* REVISIT: funcall to other code, which also - * handles power budgeting ... this way also - * ensures HdrcStart is indirectly called. - */ - retval = usb_add_hcd(musb_to_hcd(musb), -1, 0); - if (retval < 0) { - DBG(1, "add_hcd failed, %d\n", retval); - spin_lock_irqsave(&musb->lock, flags); - otg_set_peripheral(musb->xceiv, NULL); - musb->gadget_driver = NULL; - musb->g.dev.driver = NULL; - spin_unlock_irqrestore(&musb->lock, flags); - } - } } return retval;