From patchwork Thu Feb 17 06:36:10 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Kalliguddi, Hema" X-Patchwork-Id: 569301 X-Patchwork-Delegate: me@felipebalbi.com Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id p1H6aTSL005148 for ; Thu, 17 Feb 2011 06:36:48 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755034Ab1BQGgd (ORCPT ); Thu, 17 Feb 2011 01:36:33 -0500 Received: from comal.ext.ti.com ([198.47.26.152]:36281 "EHLO comal.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754980Ab1BQGgb (ORCPT ); Thu, 17 Feb 2011 01:36:31 -0500 Received: from dbdp31.itg.ti.com ([172.24.170.98]) by comal.ext.ti.com (8.13.7/8.13.7) with ESMTP id p1H6aPt3002148 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Thu, 17 Feb 2011 00:36:27 -0600 Received: from localhost.localdomain (localhost [127.0.0.1]) by dbdp31.itg.ti.com (8.13.8/8.13.8) with ESMTP id p1H6aC9d018119; Thu, 17 Feb 2011 12:06:24 +0530 (IST) From: Hema HK To: linux-usb@vger.kernel.org Cc: linux-omap@vger.kernel.org, "Kalliguddi, Hema" , Felipe Balbi , Tony Lindgren , Paul Walmsley Subject: [7/7 v4] usb: musb: OMAP4430: Fix usb device detection if connected during boot Date: Thu, 17 Feb 2011 12:06:10 +0530 Message-Id: <1297924570-3750-7-git-send-email-hemahk@ti.com> X-Mailer: git-send-email 1.7.0.4 In-Reply-To: <1297924570-3750-1-git-send-email-hemahk@ti.com> References: <1297924570-3750-1-git-send-email-hemahk@ti.com> Sender: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter1.kernel.org [140.211.167.41]); Thu, 17 Feb 2011 06:36:48 +0000 (UTC) Index: linux-2.6/drivers/usb/musb/musb_gadget.c =================================================================== --- linux-2.6.orig/drivers/usb/musb/musb_gadget.c +++ linux-2.6/drivers/usb/musb/musb_gadget.c @@ -1855,6 +1855,10 @@ int usb_gadget_probe_driver(struct usb_g } else { hcd->self.uses_pio_for_control = 1; } + + if ((musb->xceiv->last_event == USB_EVENT_ID) + && musb->xceiv->set_vbus) + otg_set_vbus(musb->xceiv, 1); } } Index: linux-2.6/drivers/usb/musb/omap2430.c =================================================================== --- linux-2.6.orig/drivers/usb/musb/omap2430.c +++ linux-2.6/drivers/usb/musb/omap2430.c @@ -328,16 +328,56 @@ static int omap2430_musb_init(struct mus if (status) DBG(1, "notification register failed\n"); - /* check whether cable is already connected */ - if (musb->xceiv->state ==OTG_STATE_B_IDLE) - musb_otg_notifications(&musb->nb, 1, - musb->xceiv->gadget); - setup_timer(&musb_idle_timer, musb_do_idle, (unsigned long) musb); return 0; } +static void omap2430_musb_enable(struct musb *musb) +{ + u8 devctl; + unsigned long timeout = jiffies + msecs_to_jiffies(1000); + struct device *dev = musb->controller; + struct musb_hdrc_platform_data *pdata = dev->platform_data; + struct omap_musb_board_data *data = pdata->board_data; + + switch (musb->xceiv->last_event) { + + case USB_EVENT_ID: + otg_init(musb->xceiv); + if (data->interface_type == MUSB_INTERFACE_UTMI) { + devctl = musb_readb(musb->mregs, MUSB_DEVCTL); + /* start the session */ + devctl |= MUSB_DEVCTL_SESSION; + musb_writeb(musb->mregs, MUSB_DEVCTL, devctl); + while (musb_readb(musb->mregs, MUSB_DEVCTL) & + MUSB_DEVCTL_BDEVICE) { + cpu_relax(); + + if (time_after(jiffies, timeout)) { + dev_err(musb->controller, + "configured as A device timeout"); + break; + } + } + } + break; + + case USB_EVENT_VBUS: + otg_init(musb->xceiv); + break; + + default: + break; + } +} + +static void omap2430_musb_disable(struct musb *musb) +{ + if (musb->xceiv->last_event) + otg_shutdown(musb->xceiv); +} + static int omap2430_musb_exit(struct musb *musb) { @@ -355,6 +395,9 @@ static const struct musb_platform_ops om .try_idle = omap2430_musb_try_idle, .set_vbus = omap2430_musb_set_vbus, + + .enable = omap2430_musb_enable, + .disable = omap2430_musb_disable, }; static u64 omap2430_dmamask = DMA_BIT_MASK(32);