![]() |
Re: N900 will not allow USB OTG!
Quote:
|
Re: N900 will not allow USB OTG!
Quote:
The whole bme stuff doesn't interfere right now, as we don't want OTG so we don't need the USB driver controlled VBUS ringing (needed for HNP & SRP), and I so far fail to see evidence a "stop bme" neutered bme would conflict with pure hostmode. |
Re: N900 will not allow USB OTG!
Quote:
I studied 2 versions of SPRUF98 for OTG-USB, and found there are actually 3 'correct' ways to put the musb core to hostmode: * ID pin grounded causing the corresponding flag bit in RXCMD from PHY being asserted, which results in A role for the device and puts musb core into hostmode (for obvious reasons this seems not possible on N900) * HNP to walk the musb core thru the state transitions involved with host role change (the thing egoshin somewhat accidentally exploited by keeping VBUS alive so session end wasn't detected when swapping the cable, and which might be possible to do by blue_led suggested method, without need of a kickstart PC) * FORCE_HOSTMODE bit, which - according to SPRUF98D - October 2009, "§23.1.4.11 Register to Enable the USB 2.0 Test Modes (TESTMODE)" does: Quote:
559 static irqreturn_t musb_stage0_irq() in musb_core.c which is driven entirely by IRQ triggered by the musb core harware, won't play nice. Nevertheless we can probably, even definitely, by some patches force the software statemachine into the correct state when sensing a "echo host >mode" is done. Same time we would config the musb core and PHY correctly (set FORCE_HOST bit, enable the DM_PD and DP_PD resistors in PHY for physical hostmode config, etc), and then poll HOSTDISCON from DevCtl register, to detect attachment/removal of a peripheral and his pullup R. We will need a patch in USB protocol driver (I'm wildly guessing here) to do this poll and start chatting with peripheral when due. description of the FORCE_HOST operation mode Quote:
Quote:
|
Re: N900 will not allow USB OTG!
do you think it would be possible to disable FORCE_HOSTMODE at CONNECT IRQ and enable it again at DISCONNECT IRQ?
or the other way around: temporarily enable FORCE_HOSTMODE upon CONNECT set devctl, and disable it again? Quote:
|
Re: N900 will not allow USB OTG!
Quote:
peripheral has 1 pullup R 1k5 (depending on low speed / full speed either on DP or DM line) host detects attachment of peripheral when one of the D lines is pulled up (= HOSTDISCON) So, to detect attachment of a peripheral, the host MUST have both pulldown R enabled (this is obviously the default idle state of N900) Also host MUST (for the normal procedure) provide 5V VBUS, otherwise the peripheral (unpowered) has no means to pullup any D line N900 switches from default idle PHY config (which is similar to host config, 2 pulldown, see above) to peripheral PHY config (= 1 pullup, no pulldowns), on sensing VBUS. Musb_hdrc driver, musb core, and PHY all do not know about bq24150, so enabling boost mode aka 5V supply mode will make the N900 think it has been attached to a host -> change to peripheral mode -> we lost the game. We need to explicitly switch to hostmode by doing 'echo host >mode', as without that we don't have a means to detect attachment of a peripheral correctly. So on issuing 'echo host >mode': *) We need to FORCE_HOST, make sure the pulldowns stay enabled, do other mandatory configs wrt for example powersaving mode - refer to SPRUF98, and start VBUS supply boost if that is what we want (quite usually it is. Except for externally powered host mode, i.e. host mode while charging, using a Y-cable) Then we set SESSION bit [edited after first tests] Then we can poll for HOSTDISCON flag changing state, which signals us one of the D lines was pulled up. I have to speculate a little what's correct sequence from then, probably we check whether D+ or D- was pulled up (we can read out from PHY's debug register iirc), and set LowSpeed / FullSpeed accordingly Quote:
Now we are ready to pass control to the logical driver talking to the connected peripheral, i.e. start ENUM, aka force software statemachine into hostmode Whenever the logical aka protocol driver detects a disconnect of peripheral, either by timeout, or by HOSTDISCON changing state, it needs to reset SESSION, and we go back to *) When we do a 'echo OTG >mode', the driver needs to stop logic protocol subdriver if there's still a session established, then disable VBUS boost if it was enabled, reset musb core and PHY, and restart the software state machine. Please take the above with a grain of salt, it was written down quickly from memory, without checking back with the datasheets/specs etc, to give you a quick start in the right general direction. I may edit this post if I find inaccuracies on a later more close check, so reread occasionally please. |
Re: N900 will not allow USB OTG!
Quote:
Code:
if (testmode & MUSB_TEST_FORCE_HOST) { |
Re: N900 will not allow USB OTG!
Also, once this is ready, to my knowledge there is no reason you couldn't kick all of this off via the id pin interrupt from the twl4030 and stop it when the cable is disconnected.
|
Re: N900 will not allow USB OTG!
Quote:
801 if (int_usb & MUSB_INTR_CONNECT) {... The problem I see is we never enter the whole 559 static irqreturn_t musb_stage0_irq() function, once we've set FORCE_HOST correctly, as it will disable the IRQ generation from musb core. So we can either postpone FORCE_HOST & setting SESSION until the core threw an IRQ for MUSB_INTR_CONNECT, and do it then same time as the speed settings you have there. My concern is we need VBUS (usually) for a CONNECT to happen (btw MUSB_INTR_CONNECT is the same like the HOSTDISCON IRQ?). This may cause the core to enter peripheral state on PHY 1707 sensing VBUS, if we don't set FORCE_HOST prior to supplying VBUS Or we do a soft-IRQ/simulated IRQ by calling the routine directly. I don't know if that will work though, as for all I understand it's a IRQ callback function which might be a little icky to call directly. cheers jOERG [edit] There is no IRQ from TWL4030 ID pin, for two reasons: 1) we don't use twl4030 at all for USB, so the ID pin IRQ needs to be handled somewhere else and passed in to the USB driver stuff 2) it's unclear if the ID pin really is connected from TWL4030:R11 to the USB receptacle, and it's pretty hard to virtually impossible to find a micro-B plug with ID pin grounded |
Re: N900 will not allow USB OTG!
2 Attachment(s)
the id pin of usb receptacle is very connected to twl chip
i use a modified uB to A adapted during my tests you can see orange a jumper and i can replace it with resistors twl chip have inside comparator sensing 0, 100k 200k 400k resistor between id pin and ground ( old ? charger specs ?! ) tear id to ground switch to a_idle as expected |
Re: N900 will not allow USB OTG!
Yup, we've known about the id pin causing an interrupt and by default switching to a_idle and also setting some sysfs file to read id (I forget which) instead of vbus. That only changes that particular state.
When vcc is applied logically you should go to a_wait_bcon, that may not be useful though. At some point I got an SRP when I started a session under forced host mode. I do not recall the exact sequence to get there. IIRC you'll find within that state machine for irq 0 people already fake out some interrupts. I have always booted with the usb cable attached and in the latest kernel I think I saw some fixes related to that, so I'm hopeful those patches will help. In context save and restore the resistors are set back to peripheral, and somewhere in either plat-omap or mach-omap2 the phy can be put into low power mode(?) also resetting back to peripheral for automatic charger detection. Need to fix that, those changes are on my implemented but untested list as I am getting a kernel panic atm during boot. If this doesn't work I'm going to patch 2.6.29 with beagleboard musb patches and see what the differences are to the maemo 2.6.28, though I am told musb is flaky on the beagleboard too. I think there is a patch to fix not being able to leave suspend under host mode if it happens, and that was a state I saw. I was also trying to prevent suspend outright |
All times are GMT. The time now is 18:15. |
vBulletin® Version 3.8.8