-
Notifications
You must be signed in to change notification settings - Fork 184
usb regs
Assumptions made on source code:
- looks like USB block is FUSB200.
- According to docs FUSB200 has 15 endpoints, but according to the source 10.
- BIT7
- BIT6 - 1 = HighSpeed is set (read only?)
- BIT5
- BIT4
- BIT3
- BIT2 - 1 = enable global Int
- BIT1
- BIT0 - 1 = set Remote Wake Up;
- BIT7 - usb config? (r/w)
- BIT6
- BIT5
- BIT4
- BIT3
- BIT2
- BIT1
- BIT0
- BIT0 - 1 ?? set on usb 2.0 init
- BIT7
- BIT6
- BIT5
- BIT4 - TEST_PKY - Test packed.
- BIT3 - TEST_SE0_NAK
- BIT2 - TEST_K
- BIT1 - TEST_J
- BIT0
According to FUSB200 doc:
DM(D-) DP(D+) Description
0 0 0: SE0
0 1 1: 'J' State
1 0 2: 'K' State
1 1 3: SE1
0: Control PHY to turn off 1.5K Ohm pull-up resistor
1: Control PHY to turn on 1.5K Ohm pull-up resistor
If TEST_PKY is set, the test packet must be filled into FIFO by DMA first.
- BIT7
- BIT6 - EP0 tx stall
- BIT5 - indicator that frame was transmitted.
- BIT4
- BIT3 - set to drom the fram?
- BIT2 - set CX_STL to stall Endpoint0 & will also clear FIFO0
- BIT1 -
- BIT0 - set CX_DONE to indicate the transmistion of control frame
- Write 32bit data to fifo
Theoretically INTR_MASK_BYTE should control INTR_SOURCE. Is it correct?
USB OUT FIFO
USB OUT FIFO
USB OUT FIFO
#define mUSB_REG_OUT_INT_ENABLE() USB_BYTE_REG_WRITE(ZM_INTR_MASK_BYTE_4_OFFSET, \
USB_BYTE_REG_READ(ZM_INTR_MASK_BYTE_4_OFFSET)&0x3f)
#define mUSB_REG_OUT_INT_DISABLE() USB_BYTE_REG_WRITE(ZM_INTR_MASK_BYTE_4_OFFSET, \
USB_BYTE_REG_READ(ZM_INTR_MASK_BYTE_4_OFFSET)&0xc0)
USB IN FIFO
USB IN FIFO
#define mUSB_STATUS_IN_INT_ENABLE() USB_BYTE_REG_WRITE(ZM_INTR_MASK_BYTE_6_OFFSET, \
USB_BYTE_REG_READ(ZM_INTR_MASK_BYTE_6_OFFSET)&0xbf)
#define mUSB_STATUS_IN_INT_DISABLE() USB_BYTE_REG_WRITE(ZM_INTR_MASK_BYTE_6_OFFSET, \
USB_BYTE_REG_READ(ZM_INTR_MASK_BYTE_6_OFFSET)|0xc0)
- BIT7 - group INTR 7
- BIT6 - group INTR 6
- BIT5 - group INTR 5
- BIT4 - group INTR 4
- BIT3 - group INTR 3
- BIT2 - group INTR 2
- BIT1 - group INTR 1
- BIT0 - group INTR 0
These bits indicate if fallowing groups got some interrupt.
- BIT7 - abort interrupt? should be cleared first?
- BIT6 -
- BIT5 -
- BIT4 - ep0 CMD_FAIL
- BIT3 - ep0 CMD_END
- BIT2 - USB EP0 OUT/rx interrupt
- BIT1 - USB EP0 IN/tx interrupt
- BIT0 - ep0 SETUP
- BIT7 - End of data.
- BIT6 - vUsb_Reg_Out(). Pending data in fifo for EP4. We need to read it out. Comments: we can read only 64bytes per time. If pending data is less then 64bytes or it is end of packet, then BIT6 and BIT7 will be set. If not, then only BIT6 is set.
these endpoints are handled by DMA
- BIT6 - vUsb_Status_In()?
- BIT7
- BIT6
- BIT5
- BIT4
- BIT3 - USB resume
- BIT2 - USB suspend
- BIT1 - USB reset interrupt.
- BIT0
code use: ZM_FUSB_BASE+0x30+(EPn-1)
(0x0F | FIFOn << 4) = OUT
(0xF0 | FIFOn) = IN
for FIFOn see mUsbFIFOMap registers.
Current configuration:
- 0x2f 0x00
- 0x30 0x0f <- EP1 = OUT + Start FIFO0
- 0x31 0xf2 <- EP2 = IN + Start FIFO2
- 0x32 0xfe <- EP3 = IN + Start FIFO14
- 0x33 0xff <- EP4 = OUT + Start FIFO15
- 0x34 0x4f
- 0x35 0x6f
- 0x36 0x00
- 0x37 0x00
- 0x38 0x00
- 0x39 0x00
- 0x3a 0x00
- 0x3b 0x00
- 0x3c 0x00
- 0x3d 0x00
- 0x3e 0x00
- BIT0 - BIT7; low size regs. Max size 0x7ff (ZM_EP_IN_MAX_SIZE_LOW_OFFSET + ZM_EP_IN_MAX_SIZE_HIGH_OFFSET)
- BIT7
- BIT6
- BIT5
- BIT4 - mUsbEPinRsTgSet
- BIT3 - mUsbEPinStallSet
- BIT0 - BIT2; High size regs
These offset + 2 Byte step for each endpoint.
For example EP0 = +0x00; EP1 = +0x02; or offset+(EPn << 1). In these address space will fit 15 endpoints.
- BIT0 - BIT7; low size regs. Max size 0x7ff (ZM_EP_OUT_MAX_SIZE_LOW_OFFSET + ZM_EP_OUT_MAX_SIZE_HIGH_OFFSET)
- BIT7
- BIT6
- BIT5
- BIT4 - mUsbEPoutRsTgSet
- BIT3 - mUsbEPoutStallSet
- BIT0 - BIT2; High size regs
These offset + 2 Byte step for each endpoint.
For example EP0 = +0x00; EP1 = +0x02; or offset+(EPn << 1). In these address space will fit 15 endpoints.
- BIT7
- BIT6
- BIT5
- BIT4 - Direction: 0 - OUT; 1 - IN.
- BIT0 - BIT3: assigned EP number.
Current layout:
- 0x80 0x01 - EP1 OUT
- 0x81 0x01 - EP1 OUT
- 0x82 0x12 - EP2 IN
- 0x83 0x12 - EP2 IN
- 0x84 0x05
- 0x85 0x05
- 0x86 0x06
- 0x87 0x06
- 0x88 0x00
- 0x89 0x00
- 0x8a 0x00
- 0x8b 0x00
- 0x8c 0x00
- 0x8d 0x00
- 0x8e 0x13
- 0x8f 0x04
-
BIT7 - If EPn use more then one FIFO, then this bit should be on the first
-
BIT6
-
BIT5
-
BIT4 - Block size: 0 - 64/512; 1 - 128/1024. It depends on initial FIFO size.
-
BIT2 - BIT3; number of FIFO blocks or better to say extra blocks? 0 - no more blocks; 1 - one block; 2 - two blocks.
-
BIT0 - BIT1; EP type: 0x1 - Iso; 0x2 - Bulk, 0x3 - Intr;
-
0x90 0x86
-
0x91 0x06
-
0x92 0x86
-
0x93 0x06
-
0x94 0x86
-
0x95 0x06
-
0x96 0x86
-
0x97 0x06
-
0x98 0x00
-
0x99 0x00
-
0x9a 0x00
-
0x9b 0x00
-
0x9c 0x00
-
0x9d 0x00
-
0x9e 0x83
-
0x9f 0x83
BIT3 - 1 xfer done?
comments: after sending data from target to host, set BIT3
BIT4 - 1 - reset fifo; 0 - disable reset?
comments: probably compatible with ZM_EP3_BYTE_COUNT_HIGH_OFFSET.
These name reg do not fit to pattern!!! Compare with 0x3e, 0x3f and 0x5e, 0x5f. If we have 0x3e, 0x3f and 0x5e, 0x5f, why do we need this register?
size of data in fifo buffer? never used?
size of data in fifo buffer. Maximum size of EP4 should be 64 Bytes. If reported value is bigger, then buffer is defiantly corrupt.
32bit data.
32bit data.
0x1 - 1 Byte, 0x3 - 2 Byte, 0x7 - 3 Byte; 0xf - 4 Byte.
we miss 7 bytes here
BIT10 - 1 - enable MP (EP6) downstream stream mode
BIT9 - 1 - enable MP (EP6) downstream DMA mode
BIT8 - 1 - enable HP (EP5) downstream DMA mode
BIT7 - 1 - enable HP (EP5) downstream stream mode
BIT6 - 1 - enable LP downstream stream mode
BIT5 - define the host dma buffer size - 4096(00) 8192 (01) 16384(10) 32768(11) bytes
BIT4 - ^
BIT3 - 0 - enable upstream stream mode: 1 - enable upstream packed mode;
BIT2 - 0 - Set into 64 byte mode (full speed) 1 - Set into 512 byte mode (usb highspeed)
BIT1 - 0 - disable upstream dma mode; 1 - enable upstream dma mode
BIT0 - 0 - disable LP down stream dma mode; 1 - eanble LP down stream dma mode
comments: ryan: 04/01: bit0 could disable lpdn dma, which is good at debugging while async_fifo have problem, we could disable this and check the fifo_rcv_size to see if we have correct at fifo or not LP - lo priotiry; MP - middle priority; HP - High priority;
set stream mode packet buffer critirea
0x0 = disable stream mode or 1 packet. So 0x9 is 10 packets?
set stream mode timeout critirea. the unit is 32 USB (30Mhz) clock cycles.