2009年2月20日 星期五

USB EHCI




usb 2.0定义了低速(ls),全速(fs),高速(hs)传输。EHCI仅仅支持高速传输,所以它必须还要有一个companion HC

fs/ls 设备插入到root hub port,会由companion HC(uhci/ohci)发现并管理设备
fs/ls 设备插入到usb 2.0 hub(not root hub),那么由ehci 通过split transaction和transanction translation(tt)支持fs/ls 设备


  • PCI configuration (space) register
    • BAR0 - USBBASE
    • FLADJ
    • PORTWAKECAP
  • (memory-mapped) regster space (defined by PCI USB base register)
    • HC capability register
    • HC operational register
  • Memory space used for schedule & management
    • Periodic frame list
    • Asynchronous list queue head pointer
    • Isochronous (high-speed) transfer descriptor (iTD)
    • Split transaction isochronous transfer (siTD)
    • Queue head (QH)
    • Periodic frame span traversal node (FSTN)
    • Queue element transfer descriptor (qTD)







Interrupt polling timming

ref ehci 3.6 Queue Head, 3.6.2 p49 Interrupt schedule mask (uFrame S-mask)
if S-mask[(1 << FRINDEX[0:2])] == 1 則此qh會被執行

poll rate: 1,2,4,8
ref ehci:4.10.7
大於1的poll rate是利用qh: S-Mask來達成的
poll rate 8: S-mask只有1個bit被設1
poll rate 4: S-mask中有2個bit被設1
poll rate 2: S-mask中有4個bit被設1
poll rate 1: S-mask中8個bit都是1,不過這樣就不需要它了



Host Initialization (ref EHCI r1.0 4.1 p.53)
  • USBBASE, FLADJ
  • CTRLDSSEGMENT
  • USBINTR
  • PERIODICLISTBASE, with T-Bits of all elements set
  • USBCMD for interrupt threshold, frame list size, and turn on the HC
  • CONFIGFLAG


Device detection& handover (ref EHCI r1.0 4.2.2 p.56)
  • EHCI is port owner initially
  • device connected, port detect the change, set the port connect change bit, (if enabled) issue interrupt
  • driver check LineStatus (PORTSC[11:10])
    • Not Low-speed device, perform EHCI reset (PORTSC[8])
      • if PortEnable (PORTSC[2]) == 1, the device is a High-speed device
      • if PortEnable (PORTSC[2]) == 0, the device is a Full-speed device, set PortOwner (PORTSC[13]) to 1 to release the port ownership
    • Low-speed device, set PortOwner(PORTSC[13]) to 1 to release the port ownership

Whenever the PortOwner(PORTSC[13]) is set to 1,
  • EHCI set the disconnect change bit, (if enabled) issue interrupt, and the port reported no device connected.
While EHCI doesn't own the port, the port stay in disconnected state.
When disconnect occur, both cHC and EHCI would detect the disconnect event, and the port ownership is returned to the EHCI.


Periodic Schedule
  • Interrupt Transfer use queue head
  • isochronous transfer uses iTD and siTD
Asynchronous Schedule
  • Control and bulk transfer use queue head


EHCI r1.0
http://www.intel.com/technology/usb/download/ehci-r10.pdf

understanding linux usb ehci device driver(1)
http://blog.csdn.net/lm_tom/archive/2007/09/09/1778031.aspx

understanding linux usb ehci device driver(2)
http://blog.csdn.net/lm_tom/archive/2007/09/22/1795931.aspx

understanding linux usb ehci device driver(3)
http://blog.csdn.net/lm_tom/archive/2007/09/22/1795956.aspx

Linux那些事儿 之 我是EHCI主机控制器
http://blog.csdn.net/fudan_abc/category/338973.aspx

2 則留言:

大頭鰱 提到...

你好! 我在網路上看到你的blog 找到你, 我現在遇到關於 usb host 的問題你可以分享給我嗎?

mkl 提到...

你可以提出來
我盡量試試看