javispedro
|
2010-05-28
, 08:47
|
|
Posts: 2,355 |
Thanked: 5,249 times |
Joined on Jan 2009
@ Barcelona
|
#961
|
The Following 3 Users Say Thank You to javispedro For This Useful Post: | ||
|
2010-05-28
, 10:32
|
|
Posts: 2,222 |
Thanked: 12,651 times |
Joined on Mar 2010
@ SOL 3
|
#962
|
I have started to wonder if Nokia is actually not allowed to assist in these efforts to determine how to manually turn the USB controller to hostmode, due to USB Consortium crap, or if its just due to the bme system being closed-source. Does the partial OTG software implementation in the drivers provide any actual benefits beyond pure peripheral mode? Or is it there because they started work on OTG and realized they couldn't finish it, and reworked that code instead of removing all the OTG-ness.
I have been wondering about literally hacking the bme. basically, the program would not change, and maybe with the magic of LD_PRELOAD and some tracing, we'd fake out the syscalls/library calls it would make (akin to how rootkits hide themselves).
The Following 2 Users Say Thank You to joerg_rw For This Useful Post: | ||
|
2010-05-28
, 11:28
|
|
Posts: 2,222 |
Thanked: 12,651 times |
Joined on Mar 2010
@ SOL 3
|
#963
|
To check this was one of the reasons I had started testing with the N810. All of the previous devices (including non id pin in connector ones) use a_host state.
bit 7 FORCE_HOST:
Set this bit to forcibly put the USB controller into Host mode when SESSION bit is set,
regardless of whether it is connected to any peripheral. The controller remains in Host mode
until the Session bit is cleared, even if a device is disconnected. And if the FORCE_HOST but
remains set, it will re-enter Host mode next time the SESSION bit is set. The operating speed is
determined using the FORCE_HS and FORCE_FS bits.
23.1.3.4.6 FORCE_HOST
The Force Host test mode enables the user to instruct the core to operate in Host mode, regardless of
whether it is actually connected to any peripheral i.e. the state of the CID input and the LINESTATE and
HOSTDISCON signals are ignored. (While in this mode, the state of the HOSTDISCON signal can be read
from bit 7 of the DevCtl register.)
This mode, which is selected by setting bit 7 within the Testmode register, allows implementation of the
USB TEST_FORCE_ENABLE (7.1.20). It can also be used for debugging PHY problems in hardware.
While the FORCE_HOST bit remains set, the core will enter Host mode when the Session bit is set and
remain in Host mode until the Session bit is cleared even if a connected device is disconnected during the
session. The operating speed while in this mode is determined for the setting of the FORCE_HS and
FORCE_FS bits of the Testmode register in Section 23.1.4.11.
HOSTDISCONNECT_RISE
Generate an interrupt event notification when
Hostdisconnect changes from low to high. Applicable only in
host mode (DpPulldown and DmPulldown both set to 1b).
The Following 16 Users Say Thank You to joerg_rw For This Useful Post: | ||
Big Phat Jan, blue_led, Chrome, egoshin, frals, fw190, hcm, javispedro, jkq, joshv06, MohammadAG, S0urcerr0r, SpeedEvil, titan, trx, zod |
|
2010-05-28
, 13:54
|
Posts: 946 |
Thanked: 1,650 times |
Joined on Oct 2009
@ Germany
|
#964
|
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.
The Following 2 Users Say Thank You to titan For This Useful Post: | ||
|
2010-05-28
, 15:18
|
|
Posts: 2,222 |
Thanked: 12,651 times |
Joined on Mar 2010
@ SOL 3
|
#965
|
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?
The operating speed while in this mode is determined for the setting of the FORCE_HS and
FORCE_FS bits of the Testmode register in Section 23.1.4.11.
The Following 7 Users Say Thank You to joerg_rw For This Useful Post: | ||
|
2010-05-28
, 15:56
|
Posts: 243 |
Thanked: 172 times |
Joined on Sep 2007
@ silicon valley
|
#966
|
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 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
Then we set SESSION bit
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 *).
if (testmode & MUSB_TEST_FORCE_HOST) { u8 r,reg; void __iomem *mbase = musb->mregs; musb_force_term(musb->mregs,MUSB_TERM_HOST_HIGHSPEED); r = musb_ulpi_readb(mbase, ISP1704_DEBUG); DBG(1,"Linestate %x\n",r); switch(r) { case 2: musb->port1_status |= USB_PORT_STAT_LOW_SPEED; reg = musb_readb(mbase, MUSB_TESTMODE); reg &= ~MUSB_TEST_FORCE_FS; reg &= ~MUSB_TEST_FORCE_HS; musb_writeb(mbase, MUSB_TESTMODE, reg); reg = musb_readb(mbase, MUSB_POWER); reg &= ~MUSB_POWER_HSENAB; musb_writeb(mbase, MUSB_POWER, reg); musb_force_term(musb->mregs,MUSB_TERM_HOST_LOWSPEED); break; case 1: /*High or full speed*/ reg = musb_readb(mbase, MUSB_TESTMODE); if(reg & MUSB_TEST_FORCE_HS) { /*High speed*/ reg &= ~MUSB_TEST_FORCE_FS; musb_writeb(mbase, MUSB_TESTMODE, reg); reg = musb_readb(mbase, MUSB_POWER); reg |= MUSB_POWER_HSENAB; musb_writeb(mbase, MUSB_POWER, reg); } else { /*Full speed*/ reg |= MUSB_TEST_FORCE_FS; musb_writeb(mbase, MUSB_TESTMODE, reg); reg = musb_readb(mbase, MUSB_POWER); reg &= ~MUSB_POWER_HSENAB; musb_writeb(mbase, MUSB_POWER, reg); } musb_force_term(mbase,MUSB_TERM_HOST_FULLSPEED); break; case 0: case 3: /*invalid*/ WARNING("Invalid line state of %d\n",r); break; } } else { /* high vs full speed is just a guess until after reset */ if (devctl & MUSB_DEVCTL_LSDEV) musb->port1_status |= USB_PORT_STAT_LOW_SPEED; }
|
2010-05-28
, 16:05
|
Posts: 243 |
Thanked: 172 times |
Joined on Sep 2007
@ silicon valley
|
#967
|
|
2010-05-28
, 16:27
|
|
Posts: 2,222 |
Thanked: 12,651 times |
Joined on Mar 2010
@ SOL 3
|
#968
|
The Following 2 Users Say Thank You to joerg_rw For This Useful Post: | ||
|
2010-05-28
, 19:54
|
Posts: 306 |
Thanked: 566 times |
Joined on Jan 2010
@ Romania
|
#969
|
The Following 5 Users Say Thank You to blue_led For This Useful Post: | ||
|
2010-05-28
, 20:33
|
Posts: 243 |
Thanked: 172 times |
Joined on Sep 2007
@ silicon valley
|
#970
|
Tags |
awesomeness in the works, boulevard of broken deals, host, i am the dealbreaker, inspector gadget lies, mobidapter is a scam, nokia fanbois, otg, over 9000, usb, usbcontrol |
|