Re: Switching OMAP2430 MUSB between host and device mode

2013-10-10 Thread Huang Rui
Hi Felipe,

On Thu, Oct 10, 2013 at 12:44:05PM -0500, Felipe Balbi wrote:
> Hi,
> 
> On Fri, Oct 11, 2013 at 01:13:57AM +0800, Huang Rui wrote:
> > On Thu, Oct 10, 2013 at 11:26:47AM -0500, Felipe Balbi wrote:
> > > HI,
> > > 
> > > On Thu, Oct 10, 2013 at 11:45:47PM +0800, Huang Rui wrote:
> > > > On Thu, Oct 10, 2013 at 10:10:52AM -0500, Felipe Balbi wrote:
> > > > > On Tue, Oct 08, 2013 at 10:28:29AM -0400, Alan Stern wrote:
> > > > 
> > > > I also have a question for host and device mode switch at DWC3
> > > > controller with on PCI bus. I saw omap glue get extcon cable state to
> > > > identify ID pin, am I right?
> > > > 
> > > > if (extcon_get_cable_state(edev, "USB-HOST") == true)
> > > > dwc3_omap_set_mailbox(omap, OMAP_DWC3_ID_GROUND);
> > > > 
> > > > But I don't find any similar identification on PCI glue. So how PCI
> > > > glue execute this action?
> > > 
> > > OMAP is peculiar. Long story short, IP team always gives us some "nice"
> > > easter eggs heh. In this case, ID pin status doesn't go straight from
> > > transceiver to dwc3. Transceiver doesn't even know about the ID pin (or
> > > vbus) states, those two lines are routed to a discrete comparator and we
> > > need to manually write those to that mailbox you see.
> > > 
> > 
> > So do you mean omap is able to use any other external connector to
> > identify ID pin status, not only use transceiver?
> 
> no, I mean that OMAP's internal PHYs don't know anything about the
> analog side of USB (VBUS and ID comparators) so you need discretest to
> take care of that. That creates the need for some mechanism to pass VBUS
> and ID status to the internal PHYs and to DWC3, that mechanism is the
> mailbox you see us fiddling with.
> 

I got it.

> > > On PCI land I'm assuming this won't be the case and ID/VBUS lines are
> > > routed directly to a PHY with internal VBUS and ID comparators. If you
> > > want to *force* the IP into host mode, there's a debugfs for that. Just
> > > write "host" to /sys/kernel/debug/dwc3*/mode.
> > >
> > 
> > So if PCI land, we can't use internal ID pin status to switch the
> > roles between host and device. we only should configure the role at
> > user space by ourseleves for role switch, am I right? :)
> 
> it depends on how the IP was integrated and which PHY is used. I can't
> answer for every possible incarnation of the DWC3 IP using a PCI bridge
> around it, sorry.
> 
> In any case, just try it out. 99% of the cases I'd expect the correct
> cable to switch correct roles.
> 
> Well, there is the register mirroring problem with DWC3 which I'm tired
> of discussing in this list and outside of it, so I'd really suggest
> trying things out and seeing how host and device side registers behave.
> 
> Hint: some of those registers will corrupt and break functionality.
> There are quite a few folks working on an acceptable workaround until we
> have a test setup with dwc3 2.50a.
> 

Thanks a lot for your information! It's very helpful for me.
Alan, sorry for my noise.

Thanks,
Rui

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: Switching OMAP2430 MUSB between host and device mode

2013-10-10 Thread Felipe Balbi
Hi,

On Fri, Oct 11, 2013 at 01:13:57AM +0800, Huang Rui wrote:
> On Thu, Oct 10, 2013 at 11:26:47AM -0500, Felipe Balbi wrote:
> > HI,
> > 
> > On Thu, Oct 10, 2013 at 11:45:47PM +0800, Huang Rui wrote:
> > > On Thu, Oct 10, 2013 at 10:10:52AM -0500, Felipe Balbi wrote:
> > > > On Tue, Oct 08, 2013 at 10:28:29AM -0400, Alan Stern wrote:
> > > 
> > > I also have a question for host and device mode switch at DWC3
> > > controller with on PCI bus. I saw omap glue get extcon cable state to
> > > identify ID pin, am I right?
> > > 
> > > if (extcon_get_cable_state(edev, "USB-HOST") == true)
> > > dwc3_omap_set_mailbox(omap, OMAP_DWC3_ID_GROUND);
> > > 
> > > But I don't find any similar identification on PCI glue. So how PCI
> > > glue execute this action?
> > 
> > OMAP is peculiar. Long story short, IP team always gives us some "nice"
> > easter eggs heh. In this case, ID pin status doesn't go straight from
> > transceiver to dwc3. Transceiver doesn't even know about the ID pin (or
> > vbus) states, those two lines are routed to a discrete comparator and we
> > need to manually write those to that mailbox you see.
> > 
> 
> So do you mean omap is able to use any other external connector to
> identify ID pin status, not only use transceiver?

no, I mean that OMAP's internal PHYs don't know anything about the
analog side of USB (VBUS and ID comparators) so you need discretest to
take care of that. That creates the need for some mechanism to pass VBUS
and ID status to the internal PHYs and to DWC3, that mechanism is the
mailbox you see us fiddling with.

> > On PCI land I'm assuming this won't be the case and ID/VBUS lines are
> > routed directly to a PHY with internal VBUS and ID comparators. If you
> > want to *force* the IP into host mode, there's a debugfs for that. Just
> > write "host" to /sys/kernel/debug/dwc3*/mode.
> >
> 
> So if PCI land, we can't use internal ID pin status to switch the
> roles between host and device. we only should configure the role at
> user space by ourseleves for role switch, am I right? :)

it depends on how the IP was integrated and which PHY is used. I can't
answer for every possible incarnation of the DWC3 IP using a PCI bridge
around it, sorry.

In any case, just try it out. 99% of the cases I'd expect the correct
cable to switch correct roles.

Well, there is the register mirroring problem with DWC3 which I'm tired
of discussing in this list and outside of it, so I'd really suggest
trying things out and seeing how host and device side registers behave.

Hint: some of those registers will corrupt and break functionality.
There are quite a few folks working on an acceptable workaround until we
have a test setup with dwc3 2.50a.

-- 
balbi


signature.asc
Description: Digital signature


Re: Switching OMAP2430 MUSB between host and device mode

2013-10-10 Thread Huang Rui
On Thu, Oct 10, 2013 at 11:26:47AM -0500, Felipe Balbi wrote:
> HI,
> 
> On Thu, Oct 10, 2013 at 11:45:47PM +0800, Huang Rui wrote:
> > On Thu, Oct 10, 2013 at 10:10:52AM -0500, Felipe Balbi wrote:
> > > On Tue, Oct 08, 2013 at 10:28:29AM -0400, Alan Stern wrote:
> > 
> > I also have a question for host and device mode switch at DWC3
> > controller with on PCI bus. I saw omap glue get extcon cable state to
> > identify ID pin, am I right?
> > 
> > if (extcon_get_cable_state(edev, "USB-HOST") == true)
> > dwc3_omap_set_mailbox(omap, OMAP_DWC3_ID_GROUND);
> > 
> > But I don't find any similar identification on PCI glue. So how PCI
> > glue execute this action?
> 
> OMAP is peculiar. Long story short, IP team always gives us some "nice"
> easter eggs heh. In this case, ID pin status doesn't go straight from
> transceiver to dwc3. Transceiver doesn't even know about the ID pin (or
> vbus) states, those two lines are routed to a discrete comparator and we
> need to manually write those to that mailbox you see.
> 

So do you mean omap is able to use any other external connector to
identify ID pin status, not only use transceiver?

> On PCI land I'm assuming this won't be the case and ID/VBUS lines are
> routed directly to a PHY with internal VBUS and ID comparators. If you
> want to *force* the IP into host mode, there's a debugfs for that. Just
> write "host" to /sys/kernel/debug/dwc3*/mode.
>

So if PCI land, we can't use internal ID pin status to switch the
roles between host and device. we only should configure the role at
user space by ourseleves for role switch, am I right? :)

Thanks,
Rui

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: Switching OMAP2430 MUSB between host and device mode

2013-10-10 Thread Alan Stern
On Thu, 10 Oct 2013, Felipe Balbi wrote:

> IIRC the debugfs interface is suppposedly a little better.
> 
> /me goes check the code
> 
> here it goes, just wrote "force host" to
> /sys/kernel/debug/musb*/testmode
> 
> Hopefully they have that enabled :-)

Thanks for the information.  I'll try it out.

Alan Stern

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: Switching OMAP2430 MUSB between host and device mode

2013-10-10 Thread Felipe Balbi
HI,

On Thu, Oct 10, 2013 at 11:45:47PM +0800, Huang Rui wrote:
> On Thu, Oct 10, 2013 at 10:10:52AM -0500, Felipe Balbi wrote:
> > On Tue, Oct 08, 2013 at 10:28:29AM -0400, Alan Stern wrote:
> > > Felipe:
> > > 
> > > I've got an Android device that uses the omap2430 musb driver.  It's
> > > configured to go into device mode when it starts up, which I guess is
> > > the normal thing for Android devices to do.
> > > 
> > > Can you explain how to switch the controller over to host mode (and
> > > back)?  I tried writing "host" to the sysfs "mode" attribute, but all
> > > that happened was an immediate crash and reboot.
> > 
> > grounding ID pin should be enough. If you're getting a crash when
> > switching through sysfs, it's likely a bug in that kernel. Can you share
> > the crash ?
> >
> 
> I also have a question for host and device mode switch at DWC3
> controller with on PCI bus. I saw omap glue get extcon cable state to
> identify ID pin, am I right?
> 
> if (extcon_get_cable_state(edev, "USB-HOST") == true)
> dwc3_omap_set_mailbox(omap, OMAP_DWC3_ID_GROUND);
> 
> But I don't find any similar identification on PCI glue. So how PCI
> glue execute this action?

OMAP is peculiar. Long story short, IP team always gives us some "nice"
easter eggs heh. In this case, ID pin status doesn't go straight from
transceiver to dwc3. Transceiver doesn't even know about the ID pin (or
vbus) states, those two lines are routed to a discrete comparator and we
need to manually write those to that mailbox you see.

On PCI land I'm assuming this won't be the case and ID/VBUS lines are
routed directly to a PHY with internal VBUS and ID comparators. If you
want to *force* the IP into host mode, there's a debugfs for that. Just
write "host" to /sys/kernel/debug/dwc3*/mode.

cheers

-- 
balbi


signature.asc
Description: Digital signature


Re: Switching OMAP2430 MUSB between host and device mode

2013-10-10 Thread Felipe Balbi
Hi,

On Thu, Oct 10, 2013 at 11:49:17AM -0400, Alan Stern wrote:
> On Thu, 10 Oct 2013, Felipe Balbi wrote:
> 
> > On Tue, Oct 08, 2013 at 10:28:29AM -0400, Alan Stern wrote:
> > > Felipe:
> > > 
> > > I've got an Android device that uses the omap2430 musb driver.  It's
> > > configured to go into device mode when it starts up, which I guess is
> > > the normal thing for Android devices to do.
> > > 
> > > Can you explain how to switch the controller over to host mode (and
> > > back)?  I tried writing "host" to the sysfs "mode" attribute, but all
> > > that happened was an immediate crash and reboot.
> > 
> > grounding ID pin should be enough.
> 
> I can't ground the ID pin.  The USB port is exposed through a
> proprietary connector and cable; the far end of the cable has a normal
> (not micro) type-A plug.  (In case it matters, the device is a Nook 
> HD.)
> 
> > If you're getting a crash when
> > switching through sysfs, it's likely a bug in that kernel. Can you share
> > the crash ?
> 
> There's nothing to share.  The device's screen goes all black and a
> reboot begins right away.
> 
> Admittedly, this is a pretty old kernel (3.0 vintage).  Barnes & Noble
> doesn't upgrade the the software for their devices very much.
> 
> > > (Related to this, it is notable that the omap2430_musb_set_mode()  
> > > routine ignores its second argument, musb_mode.  That looks awfully
> > > strange, even if it is right.)
> > 
> > it's strange because it's wrong :-) In all fairness OMAP2430 and onwards
> > don't really need SW to switch between host and device roles, though.
> > 
> > It's only good for testing when you have the wrong cable and still want
> > to go to that role.
> 
> That's exactly the situation I'm in (except perhaps for the testing 
> part -- it's hard to get much information out of a commercial device).

IIRC the debugfs interface is suppposedly a little better.

/me goes check the code

here it goes, just wrote "force host" to
/sys/kernel/debug/musb*/testmode

Hopefully they have that enabled :-)

-- 
balbi


signature.asc
Description: Digital signature


Re: Switching OMAP2430 MUSB between host and device mode

2013-10-10 Thread Alan Stern
On Thu, 10 Oct 2013, Felipe Balbi wrote:

> On Tue, Oct 08, 2013 at 10:28:29AM -0400, Alan Stern wrote:
> > Felipe:
> > 
> > I've got an Android device that uses the omap2430 musb driver.  It's
> > configured to go into device mode when it starts up, which I guess is
> > the normal thing for Android devices to do.
> > 
> > Can you explain how to switch the controller over to host mode (and
> > back)?  I tried writing "host" to the sysfs "mode" attribute, but all
> > that happened was an immediate crash and reboot.
> 
> grounding ID pin should be enough.

I can't ground the ID pin.  The USB port is exposed through a
proprietary connector and cable; the far end of the cable has a normal
(not micro) type-A plug.  (In case it matters, the device is a Nook 
HD.)

> If you're getting a crash when
> switching through sysfs, it's likely a bug in that kernel. Can you share
> the crash ?

There's nothing to share.  The device's screen goes all black and a
reboot begins right away.

Admittedly, this is a pretty old kernel (3.0 vintage).  Barnes & Noble
doesn't upgrade the the software for their devices very much.

> > (Related to this, it is notable that the omap2430_musb_set_mode()  
> > routine ignores its second argument, musb_mode.  That looks awfully
> > strange, even if it is right.)
> 
> it's strange because it's wrong :-) In all fairness OMAP2430 and onwards
> don't really need SW to switch between host and device roles, though.
> 
> It's only good for testing when you have the wrong cable and still want
> to go to that role.

That's exactly the situation I'm in (except perhaps for the testing 
part -- it's hard to get much information out of a commercial device).

Alan Stern

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: Switching OMAP2430 MUSB between host and device mode

2013-10-10 Thread Huang Rui
Hi Felipe,

On Thu, Oct 10, 2013 at 10:10:52AM -0500, Felipe Balbi wrote:
> On Tue, Oct 08, 2013 at 10:28:29AM -0400, Alan Stern wrote:
> > Felipe:
> > 
> > I've got an Android device that uses the omap2430 musb driver.  It's
> > configured to go into device mode when it starts up, which I guess is
> > the normal thing for Android devices to do.
> > 
> > Can you explain how to switch the controller over to host mode (and
> > back)?  I tried writing "host" to the sysfs "mode" attribute, but all
> > that happened was an immediate crash and reboot.
> 
> grounding ID pin should be enough. If you're getting a crash when
> switching through sysfs, it's likely a bug in that kernel. Can you share
> the crash ?
>

I also have a question for host and device mode switch at DWC3
controller with on PCI bus. I saw omap glue get extcon cable state to
identify ID pin, am I right?

if (extcon_get_cable_state(edev, "USB-HOST") == true)
dwc3_omap_set_mailbox(omap, OMAP_DWC3_ID_GROUND);

But I don't find any similar identification on PCI glue. So how PCI
glue execute this action?

Thanks,
Rui

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: Switching OMAP2430 MUSB between host and device mode

2013-10-10 Thread Felipe Balbi
On Tue, Oct 08, 2013 at 10:28:29AM -0400, Alan Stern wrote:
> Felipe:
> 
> I've got an Android device that uses the omap2430 musb driver.  It's
> configured to go into device mode when it starts up, which I guess is
> the normal thing for Android devices to do.
> 
> Can you explain how to switch the controller over to host mode (and
> back)?  I tried writing "host" to the sysfs "mode" attribute, but all
> that happened was an immediate crash and reboot.

grounding ID pin should be enough. If you're getting a crash when
switching through sysfs, it's likely a bug in that kernel. Can you share
the crash ?

> (Related to this, it is notable that the omap2430_musb_set_mode()  
> routine ignores its second argument, musb_mode.  That looks awfully
> strange, even if it is right.)

it's strange because it's wrong :-) In all fairness OMAP2430 and onwards
don't really need SW to switch between host and device roles, though.

It's only good for testing when you have the wrong cable and still want
to go to that role.

-- 
balbi


signature.asc
Description: Digital signature


Switching OMAP2430 MUSB between host and device mode

2013-10-08 Thread Alan Stern
Felipe:

I've got an Android device that uses the omap2430 musb driver.  It's
configured to go into device mode when it starts up, which I guess is
the normal thing for Android devices to do.

Can you explain how to switch the controller over to host mode (and
back)?  I tried writing "host" to the sysfs "mode" attribute, but all
that happened was an immediate crash and reboot.

(Related to this, it is notable that the omap2430_musb_set_mode()  
routine ignores its second argument, musb_mode.  That looks awfully
strange, even if it is right.)

Thanks,

Alan Stern

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html