Other Parts Discussed in Thread: OMAP-L138
Hi,
I've been spending time writing code for the OHCI-compliant USB peripheral on the C6748 and am experiencing some problems.
Basically, I've set up the HCD pretty much as OpenHCI dictates. I successfully detect when a device attaches, wait 100ms, reset the device and then I try and get the (first eight bytes of the) device descriptor. Now this is where I am not having much success.
I've set up the endpoint descriptors list for the control list to do, by default, a GET_DESCRIPTOR request with a length of 8 bytes. To see what the state of shared memory is, please first see my debug output:
ControlList is now:
|
ED 0xc23240f0 -> GTD 0xc00937f0 -> GTD 0xc2324240 -> GTD 0xc232b740 -> GTD 0xc232b750 (dummy)
ED 0xc23240f0:
FunctionAddress : 0
EndpointNumber : 0
Direction : 0
sKip : 0
Format : 0
MaximumPacketSize : 8
TDQueueTailPointer : 0xc232b750
Halted : 0
toggleCarry : 0
TDQueueHeadPointer : 0xc00937f0
NextED : 0x0
GTD 0xc00937f0:
BufferRounding : 1
Direction : 0
DelayInterrupt : 0
DataToggle : 2
ErrorCount : 0
ConditionCode : 0xf
CurrentBufferPointer : 0xc2324168
NextTD : 0xc2324240
BufferEnd : 0xc232416f
GTD 0xc2324240:
BufferRounding : 1
Direction : 2
DelayInterrupt : 0
DataToggle : 3
ErrorCount : 0
ConditionCode : 0xf
CurrentBufferPointer : 0xc23241b0
NextTD : 0xc232b740
BufferEnd : 0xc23241b7
GTD 0xc232b740:
BufferRounding : 0
Direction : 1
DelayInterrupt : 0
DataToggle : 3
ErrorCount : 0
ConditionCode : 0xf
CurrentBufferPointer : 0x0
NextTD : 0xc232b750
BufferEnd : 0x0
GTD 0xc232b750 (dummy):
BufferRounding : 0
Direction : 0
DelayInterrupt : 0
DataToggle : 0
ErrorCount : 0
ConditionCode : 0x0
CurrentBufferPointer : 0x0
NextTD : 0x0
BufferEnd : 0x0
For anyone interested, here's some actual memory that relates to these values ...
0xc00937f0: 0xF2040000 0xC2324168 0xC2324240 0xC232416F
0xc23240f0: 0x00080000 0xC232B750 0xC00937F0 0x00000000
0xc2324240: 0xF3140000 0xC23241B0 0xC232B740 0xC23241B7
0xc232b740: 0xF3080000 0x00000000 0xC232B750 0x00000000
0xc232b750: 0x00000000 0x00000000 0x00000000 0x00000000
... and heres some of the C6748's USB1 registers at the same time instance ...
USB1DSP
REVID = 0x00000010
REV = 0x10
HcControl = 0x00000280
Reserved = 0x0
RWE = DISABLE (0x0)
RWC = ENABLE (0x1)
IR = *
HCFS = USBOPERATIONAL (0x2)
BLE = DISABLE (0x0)
CLE = DISABLE (0x0)
IE = DISABLE (0x0)
PLE = DISABLE (0x0)
CBSR = RATIO11 (0x0)
HcCommandStatus = 0x00000000
Reserved = 0x0
SOC = 0x0
Reserved = 0x0
OCR = 0x0
BLF = CLEAR (0x0)
CLF = CLEAR (0x0)
HCR = CLEAR (0x0)
HcInterruptStatus = 0x00000004
Rsvd = 0x0
OC = 0x0
Reserved = 0x0
RHSC = 0x0
FNO = 0x0
UE = 0x0
RD = 0x0
SF = 0x1
WDH = 0x0
SO = 0x0
HcInterruptEnable = 0x8000007B
MIE = ENABLE (0x1)
OC = IGNORE (0x0)
Reserved = 0x0
RHSC = ENABLE (0x1)
FNO = ENABLE (0x1)
UE = ENABLE (0x1)
RD = ENABLE (0x1)
SF = IGNORE (0x0)
WDH = ENABLE (0x1)
SO = ENABLE (0x1)
HcInterruptDisable = 0x8000007B
MIE = DISABLE (0x1)
OC = IGNORE (0x0)
Reserved = 0x0
RHSC = DISABLE (0x1)
FNO = DISABLE (0x1)
UE = DISABLE (0x1)
RD = DISABLE (0x1)
SF = IGNORE (0x0)
WDH = DISABLE (0x1)
SO = DISABLE (0x1)
HcHCCA = 0xC234D600
HCCA = 0xC234D6
Reserved = 0x0
HcPeriodCurrentED = 0x00000000
PCED = 0x0
Reserved = 0x0
HcControlHeadED = 0xC23240F0
CHED = 0xC23240F
Reserved = 0x0
HcControlCurrentED = 0x00000000
CCED = 0x0
Reserved = 0x0
HcBulkHeadED = 0x00000000
BHED = 0x0
Reserved = 0x0
HcBulkCurrentED = 0x00000000
BCED = 0x0
Reserved = 0x0
HcDoneHead = 0x00000000
DH = 0x0
Reserved = 0x0
HcFmInterval = 0x27782EDF
FIT = 0x0
FSMPS = 0x13BC
Reserved = 0x0
FrameInterval = 0x2EDF
HcFmRemaining = 0x0000209F
FRT = 0x0
Reserved = 0x0
FR = 0x209F
HcFmNumber = 0x00007E2E
Reserved = 0x0
FN = 0x7E2E
HcPeriodicStart = 0x00002A30
Reserved = 0x0
PS = 0x2A30
HcLSThreshold = 0x00000628
Reserved = 0x0
LST = 0x628
HcRhDescriptorA = 0x02001202
POTPGT = 0x2
Reserved = 0x0
NOCP = DISABLE (0x1)
OCPM = GLOBAL (0x0)
DT = 0x0
NPS = ALWAYSON (0x1)
PSM = GLOBAL (0x0)
NDP = 0x2
HcRhDescriptorB = 0x00000000
PPCM = P1GPDIS (0x0)
DR = P1DR (0x0)
HcRhStatus = 0x00000000
CRWE = *
Reserved = 0x0
OCIC = NOEFFECT (0x0)
LPSC = NOEFFECT (0x0)
DRWE = NOEFFECT (0x0)
Reserved = 0x0
OCI = 0x0
LPS = NOEFFECT (0x0)
HcRhPortStatus = 0x00000101
Reserved = 0x0
PRSC = NOEFFECT (0x0)
OCIC = NOEFFECT (0x0)
PSSC = NOEFFECT (0x0)
PESC = NOEFFECT (0x0)
CSC = NOEFFECT (0x0)
Reserved = 0x0
LSDA = NOEFFECT (0x0)
PPS = PPSSET (0x1)
Reserved = 0x0
PRS = NOEFFECT (0x0)
POCI = NOEFFECT (0x0)
PSS = NOEFFECT (0x0)
PES = NOEFFECT (0x0)
CCS = CLEAR (0x1)
This is more or less correct -- at least from my interpretation of the OHCI 1.0a specification.
I then set CLF (CommandListFilled) in HhCommandStatus and CLE (CommandListEnabled) in HcControl to try and get the HC (i.e. C6748's integrated OHCI-compliant PHY for USB1) to do the actual work and transfer some data.
The problem is that I don't always get a response. Most of the time I do not get an WritebackDoneHead interrupt, and if I do, it is to tell me that the first of the transfers (the SETUP one) failed and the endpoint is now halted. A lot of the time, however, I do *not* get a WritebackDoneHead interrupt and nothing else happens. If I halt the program and manually set CLF then usually I do get an interrupt saying the first transfer failed and the endpoint is now halted.
Whether or not I get an interrupt in the first place seems to depend on seemingly unrelated things, such as including debug output in the program. Could I be missing some timeouts somewhere? I currently timeout between connection and reset (100ms), and a little while after reset (100ms).
I also do not always understand how the HC seems to modify the transfer descriptor lists. A lot of the time, the HC sets the NextTransferDescriptorPtr field of a transfer descriptor to 0x00000000 (I guess this is correct as HcDoneHead is 0x00000000 to start with) but then does not update the accompanying endpoint descriptors TransferDescriptorQueueHeadPtr.
If any one is able to help me make some progress with my firmware, it'd be greatly appreciated.
Kind regards,
Mark