public inbox for linux-omap@vger.kernel.org
 help / color / mirror / Atom feed
From: Peter Barada <peterb@logicpd.com>
To: felipe.balbi@nokia.com
Cc: "Pandita, Vikram" <vikram.pandita@ti.com>,
	"Gadiyar, Anand" <gadiyar@ti.com>,
	linux-omap <linux-omap@vger.kernel.org>
Subject: Re: Question regarding MUSB and dynamic fifo sizing
Date: Mon, 10 Aug 2009 10:33:19 -0400	[thread overview]
Message-ID: <1249914799.25044.4.camel@blitz> (raw)
In-Reply-To: <20090808071705.GA11844@nokia.com>

On Sat, 2009-08-08 at 10:17 +0300, Felipe Balbi wrote:
> Hi,
> 
> On Sat, Aug 08, 2009 at 09:43:13AM +0300, Felipe Balbi wrote:
> > On Fri, Aug 07, 2009 at 10:17:12PM +0200, Balbi Felipe (Nokia-D/Helsinki) wrote:
> > > On Fri, Aug 07, 2009 at 09:22:33PM +0200, ext Peter Barada wrote:
> > > > Someting strange is going on.  If I boot with the MUSB->OTG adapter ->
> > > > thumbdrive plugged in, and then modprobe the driver, it finds the
> > > > thumbdrive.  I can then remove/reinsert the OTG adapter -> thumbdrive
> > > > multiple times, and each time it is enumerated.
> > > > 
> > > > If I boot w/o the OTG adapter -> thumbdrive plugged in, modprobe the
> > > > musb driver, and then plug in the OTG adaptor ->thumbdrive, it is not
> > > > enumerated.
> > > > 
> > > > Any idea why I need the OTG adapter -> thumbdrive plugged in at kernel
> > > > boot for it to enumerate the thumbdrive?
> > > 
> > > which board are you using ?
> > 
> > ok, got you. it's 35xx-based with twl4030.
> > 
> > when you plug the micro-a cable, see on drivers/usb/otg/twl4030-usb.c
> > what happens. You should have a print about the link status, see if that
> > is ID.
> > 
> > Then try something like this patch:
> > 
> > diff --git a/drivers/usb/otg/twl4030-usb.c b/drivers/usb/otg/twl4030-usb.c
> > index 9e3e7a5..4bc5b7f 100644
> > --- a/drivers/usb/otg/twl4030-usb.c
> > +++ b/drivers/usb/otg/twl4030-usb.c

Felipe,

Thanks for the patch.  With the following modified patch (to fit my tree
as my pull was from the Kevin's PM tree, commit
7c5cb7862d32cb344be7831d466535d5255e35ac) it worked like a charm:

diff --exclude CVS -uNr linux-2.6.28-rc8/drivers/usb/otg/twl4030-usb.c
linux-2.6.28-rc8.modified/drivers/usb/otg/twl4030-usb.c
--- linux-2.6.28-rc8/drivers/usb/otg/twl4030-usb.c	2009-08-09
12:52:51.000000000 -0400
+++ linux-2.6.28-rc8.modified/drivers/usb/otg/twl4030-usb.c	2009-08-09
03:38:20.000000000 -0400
@@ -250,6 +250,8 @@
 };
 
 struct twl4030_usb {
+	/* used for driving or not vbus */
+	struct work_struct      vbus_work;
 	struct otg_transceiver	otg;
 	struct device		*dev;
 
@@ -263,6 +265,7 @@
 	u8			linkstat;
 	u8			asleep;
 	bool			irq_enabled;
+        bool                    drive_vbus;
 };
 
 /* internal define on top of container_of */
@@ -344,6 +347,18 @@
 	return twl4030_usb_write(twl, reg + 2, bits);
 }
 
+static void twl4030_vbus_work(struct work_struct *work)
+{
+       struct twl4030_usb      *twl = container_of(work, struct
twl4030_usb, vbus_work);
+
+       if (twl->drive_vbus)
+               (void) twl4030_usb_set_bits(twl, TWL4030_OTG_CTRL,
+                               TWL4030_OTG_CTRL_DRVVBUS);
+       else
+               (void) twl4030_usb_set_bits(twl, TWL4030_OTG_CTRL,
+                               TWL4030_OTG_CTRL_DRVVBUS);
+}
+
 /*-------------------------------------------------------------------------*/
 
 static enum linkstat twl4030_usb_linkstat(struct twl4030_usb *twl)
@@ -374,12 +389,16 @@
 	if (linkstat == USB_LINK_ID) {
 		twl->otg.default_a = true;
 		twl->otg.state = OTG_STATE_A_IDLE;
+		twl->drive_vbus = true;
 	} else {
 		twl->otg.default_a = false;
 		twl->otg.state = OTG_STATE_B_IDLE;
+		twl->drive_vbus = false;
 	}
 	spin_unlock_irq(&twl->lock);
 
+	schedule_work(&twl->vbus_work);
+
 	return linkstat;
 }
 
@@ -657,6 +676,8 @@
 	if (!twl)
 		return -ENOMEM;
 
+	INIT_WORK(&twl->vbus_work, twl4030_vbus_work);
+
 	twl->dev		= &pdev->dev;
 	twl->irq		= platform_get_irq(pdev, 0);
 	twl->otg.dev		= twl->dev;

With it I can enumerate my OTG adapter/thumbdrive on insertion.

-- 
Peter Barada <peterb@logicpd.com>
Logic Product Development, Inc.

  reply	other threads:[~2009-08-10 14:29 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-08-06 20:10 Question regarding MUSB and dynamic fifo sizing Peter Barada
2009-08-06 20:11 ` Gadiyar, Anand
2009-08-07 17:23   ` Peter Barada
2009-08-07 17:25     ` Pandita, Vikram
2009-08-07 17:55       ` Peter Barada
2009-08-07 19:22       ` Peter Barada
2009-08-07 20:17         ` Felipe Balbi
2009-08-08  6:43           ` Felipe Balbi
2009-08-08  7:17             ` Felipe Balbi
2009-08-10 14:33               ` Peter Barada [this message]
2009-08-10 16:16                 ` Felipe Balbi
2009-08-10 17:00                   ` Peter Barada
2009-08-10 17:02                     ` Felipe Balbi
2009-08-10 17:28                       ` Peter Barada
2009-08-10 18:48                         ` Felipe Balbi
2009-08-10 20:42                           ` Peter Barada
2009-08-11  6:33                             ` Felipe Balbi
2009-08-11 15:21                               ` Peter Barada
2009-08-11 20:51                                 ` Felipe Balbi
2009-08-11 21:17                                   ` Peter Barada
2009-08-11 21:17                                     ` Felipe Balbi
2009-08-20 16:29                                       ` Peter Barada
2009-08-08  3:04         ` Gupta, Ajay Kumar
2009-08-08  5:03           ` Pandita, Vikram

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1249914799.25044.4.camel@blitz \
    --to=peterb@logicpd.com \
    --cc=felipe.balbi@nokia.com \
    --cc=gadiyar@ti.com \
    --cc=linux-omap@vger.kernel.org \
    --cc=vikram.pandita@ti.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox