usbUhci.h
上传用户:luoyougen
上传日期:2008-05-12
资源大小:23136k
文件大小:13k
源码类别:

VxWorks

开发平台:

C/C++

  1. /* usbUhci.h - UHCI hardware interface definitions */
  2. /* Copyright 2000 Wind River Systems, Inc. */
  3. /*
  4. Modification history
  5. --------------------
  6. 01b,10may99,rcb Update style per suggestions from Claudio at WRS.
  7. 01a,27apr99,rcb First.
  8. */
  9. #ifndef __INCusbUhcih
  10. #define __INCusbUhcih
  11. #ifdef __cplusplus
  12. extern "C" {
  13. #endif
  14. /*
  15. DESCRIPTION
  16. Defines the USB UHCI (Universal Host Controller Interface) register file
  17. interface and memory structures shared between USB software and the UHCI
  18. hardware.  
  19. Please refer to Intel's UHCI specification, Revision 1.1 or later, for more 
  20. information.
  21. NOTE: The memory structures must not be padded, so the compiler must be
  22. set to use the "no packing" or "0-byte packing" option.  Compile-time checks
  23. are included in this file to ensure that structures compile to the correct
  24. size.
  25. */
  26. /***************************************************************************
  27.  *     Register Definitions
  28.  ***************************************************************************/
  29. /*
  30.  * UHCI registers in the regular I/O address space.
  31.  */
  32. #define UHCI_USBCMD     0x0     /* r/w  WORD    USB Command */
  33. #define UHCI_USBSTS     0x2     /* r/wc WORD    USB Status */
  34. #define UHCI_USBINTR     0x4     /* r/w  WORD    USB Interrupt Enable */
  35. #define UHCI_FRNUM     0x6     /* r/w  WORD    Frame Number */
  36. #define UHCI_FRBASEADD     0x8     /* r/w  DWORD   Frame List Base Address */
  37. #define UHCI_SOFMOD     0xc     /* r/w  BYTE    Start of Frame Modify */
  38. #define UHCI_PORTSC1     0x10    /* r/wc WORD    Port 1 Status/Control */
  39. #define UHCI_PORTSC2     0x12    /* r/wc WORD    Port 2 Status/Control */
  40. /*
  41.  * PCI registers relevant to UHCI in configuration space.
  42.  */
  43. #define UHCI_PCI_CLASSC     0x9     /* r/o  24-bits Class Code Register */
  44. #define UHCI_PCI_USBBASE    0x20    /* r/w  DWORD   IO Space Base Address */
  45. #define UHCI_PCI_SBRN     0x60    /* r/o  BYTE    Serial Bus Release No. */
  46. /*
  47.  * UHCI_USBCMD register definition.
  48.  */
  49. #define UHCI_CMD_MAXP     0x0080  /* Max Packet */
  50.     /* 1=64 bytes, 0=32 bytes */
  51. #define UHCI_CMD_CF     0x0040  /* Configure Flag */
  52. #define UHCI_CMD_SWDBG     0x0020  /* Software Debug. */
  53.     /* 1=debug mode, 0=normal mode */
  54. #define UHCI_CMD_FGR     0x0010  /* Force Global Resume. */
  55.     /* 1=host ctlr sends global resume */
  56. #define UHCI_CMD_EGSM     0x0008  /* Enter Global Suspect Mode */
  57.     /* 1=host ctlr enters global suspend */
  58. #define UHCI_CMD_GRESET     0x0004  /* Global reset */
  59.     /* 1=host ctlr sends global reset */
  60. #define UHCI_CMD_HCRESET    0x0002  /* Host Controller Reset */
  61.     /* 1=host ctlr reset */
  62. #define UHCI_CMD_RS     0x0001  /* Run/Stop. */
  63.     /* 1=run, 0=stop */
  64. /*
  65.  * UHCI_USBSTS register definition.
  66.  */
  67. #define UHCI_STS_HALTED     0x0020  /* Host Controller Halted */
  68. #define UHCI_STS_PROCERR    0x0010  /* Host Controller Process Error */
  69. #define UHCI_STS_HOSTERR    0x0008  /* Host System Error */
  70. #define UHCI_STS_RESUME     0x0004  /* Resume Detect */
  71. #define UHCI_STS_USBERR     0x0002  /* USB Error Interrupt */
  72. #define UHCI_STS_USBINT     0x0001  /* USB Interrupt */
  73. /*
  74.  * UHCI_USBINTR register definition.
  75.  */
  76. #define UHCI_INTR_SHORT     0x0008  /* Short Packet Interrupt Enable */
  77.     /* 1=Enabled, 0=Disabled */
  78. #define UHCI_INTR_COMPLETE  0x0004  /* Interrupt On Complete Enable */
  79.     /* 1=Enabled, 0=Disabled */
  80. #define UHCI_INTR_RESUME    0x0002  /* Resume Interrupt Enable */
  81.     /* 1=Enabled, 0=Disabled */
  82. #define UHCI_INTR_TIME_CRC  0x0001  /* Timeout/CRC Interrupt Enable */
  83.     /* 1=Enabled, 0=Disabled */
  84. /*
  85.  * UHCI_FRNUM register definition.
  86.  */
  87. #define UHCI_FRN_MASK     0x07ff  /* The low 11-bits of UHCI_FRNUM contain */
  88.     /* the current USB frame number. */
  89. /*
  90.  * UHCI_FLBASEADD register definition.
  91.  *
  92.  * Bits 31:12 of this register define bits 31:12, respectively, of the base
  93.  * address of the UHCI frame list in physical memory.  The frame list must be
  94.  * aligned on a 4k boundary.
  95.  */
  96. /*
  97.  * UHCI_SOFMOD register definition.
  98.  */
  99. #define UHCI_SOF_MASK     0x7f    /* The low 7-bits of UHCI_SOFMOD contain */
  100.     /* a count from 0..127 which is added to */
  101.     /* UHCI_SOF_BASE to determine start-of- */
  102.     /* frame timing. */
  103. #define UHCI_SOF_BASE     11936   /* Base value for start-of-frame timing */
  104. #define UHCI_SOF_MAX     12063   /* max value for start-of-frame timing */
  105. #define UHCI_SOF_DEFAULT    64     /* UHCI_SOFMOD defaults to 64, yielding */
  106.     /* a default start-of-frame timing of */
  107.     /* 11936+64 = 12000. */
  108. /*
  109.  * UHCI_PORTSCn register definition.
  110.  */
  111. #define UHCI_PORT_SUSPEND   0x1000  /* Suspend state */
  112.     /* 1=port in suspend, 0=not suspended */
  113. #define UHCI_PORT_RESET     0x0200  /* Port reset */
  114.     /* 1=Port is in reset, 0=port not reset */
  115. #define UHCI_PORT_LOWSPEED  0x0100  /* Low Speed Device Attached */
  116.     /* 1=low speed dev, 0=full speed dev */
  117. #define UHCI_PORT_RESUME    0x0040  /* Resume Detect */
  118.     /* 1=resume detected/driven, 0=no resume */
  119. #define UHCI_PORT_LINESTS   0x0030  /* Line Status */
  120.     /* bit 4=D+, bit 5=D- logical levels */
  121. #define UHCI_PORT_ENBCHG    0x0008  /* Port Enable/Disable Change */
  122.     /* 1=port status changed, 0=no change */
  123. #define UHCI_PORT_ENABLE    0x0004  /* Port Enabled/Disabled */
  124.     /* 1=Enable, 0=Disable */
  125. #define UHCI_PORT_CNCTCHG   0x0002  /* Connect Status Change */
  126.     /* 1=Connect status changed, 0=no change */
  127. #define UHCI_PORT_CNCTSTS   0x0001  /* Current Connect Status */
  128.     /* 1=Device present, 0=no device */
  129. /*
  130.  * UHCI_PCI_CLASSC register definition.
  131.  */
  132. #define UHCI_CLASSC_BASEC_MASK 0xff0000    /* Base class code mask */
  133. #define UHCI_CLASSC_BASEC_ROT 16     /* Base class code bit loc */
  134. #define UHCI_CLASSC_SCC_MASK 0x00ff00    /* Sub-Class code mask */
  135. #define UHCI_CLASSC_SCC_ROT 8     /* Sub-Class code bit loc */
  136. #define UHCI_CLASSC_PI_MASK 0x0000ff    /* Programming Interface mask */
  137. #define UHCI_CLASSC_PI_ROT 0     /* Programming Interface bit loc */
  138. /* Macros to retrieve class code fields */
  139. #define UHCI_CLASSC_BASEC(x) 
  140.     (((x) & UHCI_CLASSC_BASEC_MASK) >> UHCI_CLASSC_BASEC_ROT)
  141. #define UHCI_CLASSC_SCC(x) 
  142.     (((x) & UHCI_CLASSC_SCC_MASK) >> UHCI_CLASSC_SCC_ROT)
  143. #define UHCI_CLASSC_PI(x) 
  144.     (((x) & UHCI_CLASSC_PI_MASK) >> UHCI_CLASSC_PI_ROT)
  145. #define UHCI_CLASS 0x0c     /* BASEC value for serial bus */
  146. #define UHCI_SUBCLASS 0x03     /* SCC value for USB */
  147. #define UHCI_PGMIF 0x00     /* no specific pgm i/f defined */
  148. /*
  149.  * UHCI_PCI_USBBASE register definition.
  150.  */
  151. #define UHCI_USBBASE_MASK 0x0000ffe0  /* Bits 15:5 define I/O base */
  152. /* Macro to retrieve base address */
  153. #define UHCI_USBBASE(x)  ((x) & UHCI_USBBASE_MASK)
  154. /* 
  155.  * UHCI_PCI_SBRN register definition.
  156.  *
  157.  * Bits 7:0 define the USB release number supported by the host controller
  158.  */
  159. #define UHCI_SBRN_PREREL    0x00    /* Pre-release 1.0 */
  160. #define UHCI_SBRN_REL10     0x10    /* Release 1.0 */
  161. /* number of ports on a UHC */
  162. #define UHCI_PORTS     2
  163. /* 
  164.  * UHCI_FRAME_WINDOW defines the maximum number of frames "into the future"
  165.  * for which an isochronous transfer may be scheduled.
  166.  */
  167. #define UHCI_FRAME_WINDOW     1024    /* 1024 entries in frame list */
  168. /* values for emulated UHC hub descriptor */
  169. #define UHCI_PWR_ON_2_PWR_GOOD     1     /* = 2msec for pwr on to pwr good */
  170. #define UHCI_HUB_CONTR_CURRENT     0     /* 0 mA for hub ctlr current */
  171. #define UHCI_HUB_INTERVAL     0xff    /* hub service interval */
  172. /***************************************************************************
  173.  *        Memory Structure Definitions
  174.  ***************************************************************************/
  175. /*
  176.  * UHCI link pointers, including frame list pointers and the pointers found
  177.  * in UHCI_TD and UHCI_QH structures, use the same basic structure as defined 
  178.  * below.  The exception is the VF (Depth/Breadth select) which is only used
  179.  * in the UHCI_TD structure.
  180.  */
  181. #define UHCI_LINK_PTR_MASK 0xfffffff0  /* Adrs of first obj */
  182. #define UHCI_LINK_VF 0x00000004  /* Depth/Breadth select */
  183.     /* 1=Depth first, 0=breadth first */
  184. #define UHCI_LINK_QH 0x00000002  /* QH/TD Select */
  185. #define UHCI_LINK_TD 0x00000000  /* 1=QH, 0=TD */
  186. #define UHCI_LINK_TERMINATE 0x00000001  /* Terminate */
  187.     /* 1=End of list, 0=pointer valid */
  188. /* the UHCI frame list has 1024 entries (1024 @ 4 bytes each = 4k) */
  189. #define UHCI_FRAME_LIST_ENTRIES     1024
  190. #define UHCI_FRAME_LIST_ALIGNMENT   4096
  191. #define UHCI_TD_ALIGNMENT     16
  192. #define UHCI_QH_ALIGNMENT     16
  193. /*
  194.  * UHCI_FRAME_LIST
  195.  *
  196.  * NOTE: Frame list must be allocated on a 4k page boundary
  197.  */
  198. typedef struct uhci_frame_list
  199.     {
  200.     UINT32  linkPtr [UHCI_FRAME_LIST_ENTRIES]; /* pointers to TD or QH */
  201.     } UHCI_FRAME_LIST, *pUHCI_FRAME_LIST;
  202. /*
  203.  * Transfer Descriptor.
  204.  *
  205.  * NOTE: Each TD must be aligned on a 16-byte boundary.
  206.  */
  207. typedef struct uhci_td
  208.     {
  209.     UINT32  linkPtr;     /* Link Pointer to another TD or QH */
  210.     UINT32  ctlSts;     /* Control and Status */
  211.     UINT32  token;     /* Token for packet header */
  212.     UINT32  bfrPtr;     /* Data buffer pointer */
  213.     UINT32  software [4];     /* 4 DWORDs reserved for software */
  214.     } UHCI_TD, *pUHCI_TD;
  215. #define UHCI_TD_LEN 32     /* TD length required by UHCI hardware */
  216. #define UHCI_TD_ACTLEN sizeof (UHCI_TD)
  217. /*
  218.  * UHCI_TD.CtlSts definition.
  219.  */
  220. #define UHCI_TDCS_SHORT  0x20000000  /* Short Packet Detect */
  221.     /* 1=Enable, 0=Disable */
  222. #define UHCI_TDCS_ERRCTR_MASK 0x18000000  /* Error Counter Mask */
  223. #define UHCI_TDCS_ERRCTR_NOLIM 0x00000000  /* No limit */
  224. #define UHCI_TDCS_ERRCTR_1ERR 0x08000000  /* 1 error */
  225. #define UHCI_TDCS_ERRCTR_2ERR 0x10000000  /* 2 errors */
  226. #define UHCI_TDCS_ERRCTR_3ERR 0x18000000  /* 3 errors */
  227. #define UHCI_TDCS_LOWSPEED 0x04000000  /* Low Speed Device */
  228.     /* 1=low speed dev, 0=full speed */
  229. #define UHCI_TDCS_ISOCH  0x02000000  /* Isochronous Select */
  230.     /* 1=isoch TD, 0=non-isoch TD */
  231. #define UHCI_TDCS_COMPLETE 0x01000000  /* Interrupt on Complete */
  232.     /* 1=Issue IOC */
  233.     /* Cmd execution status bits */
  234. #define UHCI_TDCS_STS_ACTIVE 0x00800000  /* Active */
  235. #define UHCI_TDCS_STS_STALLED 0x00400000  /* Stalled */
  236. #define UHCI_TDCS_STS_DBUFERR 0x00200000  /* Data buffer error */
  237. #define UHCI_TDCS_STS_BABBLE 0x00100000  /* Babble Detected */
  238. #define UHCI_TDCS_STS_NAK 0x00080000  /* NAK Received */
  239. #define UHCI_TDCS_STS_TIME_CRC 0x00040000  /* CRC/Timeout error */
  240. #define UHCI_TDCS_STS_BITSTUFF 0x00020000  /* Bitstuff error */
  241. #define UHCI_TDCS_ACTLEN_MASK 0x000007ff  /* Actual Length mask */
  242. #define UHCI_TDCS_ACTLEN_ROT 0     /* Actual length bit loc */
  243. #define UHCI_PACKET_SIZE_MASK 0x000007ff  /* Mask for 11-bit field */
  244. /* Macro to retrieve UHCI_TDCS_ACTLEN
  245.  *
  246.  * NOTE: UHCI actlen is one less than the real length.
  247.  * The macro compensates automatically.
  248.  */
  249. #define UHCI_TDCS_ACTLEN(x) 
  250.     ((((x) >> UHCI_TDCS_ACTLEN_ROT) + 1) & UHCI_PACKET_SIZE_MASK)
  251. /*
  252.  * UHCI_TD.Token definition.
  253.  */
  254. #define UHCI_TDTOK_MAXLEN_MASK 0xffe00000  /* Maximum length mask */
  255. #define UHCI_TDTOK_MAXLEN_ROT 21     /* Maximum length bit loc */
  256. #define UHCI_TDTOK_DATA_TOGGLE 0x00080000  /* Data Toggle */
  257.     /* 0=DATA0, 1=DATA1 */
  258. #define UHCI_TDTOK_ENDPT_MASK 0x00078000  /* Endpoint Mask */
  259. #define UHCI_TDTOK_ENDPT_ROT 15     /* Endpoint bit loc */
  260. #define UHCI_TDTOK_DEVADRS_MASK 0x00007f00  /* Device Address Mask */
  261. #define UHCI_TDTOK_DEVADRS_ROT 8     /* Device Address bit loc */
  262. #define UHCI_TDTOK_PID_MASK 0x000000ff  /* Packet ID mask */
  263. #define UHCI_TDTOK_PID_ROT 0     /* Packet ID bit loc */
  264. /* Macros to retrieve/format UHCI_TDTOK_MAXLEN 
  265.  *
  266.  * NOTE: UHCI maxlen is one less than the real length. The macro 
  267.  * compensates automatically.
  268.  */
  269. #define UHCI_TDTOK_MAXLEN(x) 
  270.     ((((x) >> UHCI_TDTOK_MAXLEN_ROT) + 1) & UHCI_PACKET_SIZE_MASK)
  271. #define UHCI_TDTOK_MAXLEN_FMT(x) 
  272.     ((((x) - 1) & UHCI_PACKET_SIZE_MASK) << UHCI_TDTOK_MAXLEN_ROT)
  273. /* Macros to retrieve/format UHCI_TDTOK_ENDPT */
  274. #define UHCI_TDTOK_ENDPT(x) 
  275.     (((x) & UHCI_TDTOK_ENDPT_MASK) >> UHCI_TDTOK_ENDPT_ROT)
  276. #define UHCI_TDTOK_ENDPT_FMT(x) 
  277.     (((x) << UHCI_TDTOK_ENDPT_ROT) & UHCI_TDTOK_ENDPT_MASK)
  278. /* Macros to retrieve/format UHCI_TDTOK_DEVADRS */
  279. #define UHCI_TDTOK_DEVADRS(x) 
  280.     (((x) & UHCI_TDTOK_DEVADRS_MASK) >> UHCI_TDTOK_DEVADRS_ROT)
  281. #define UHCI_TDTOK_DEVADRS_FMT(x) 
  282.     (((x) << UHCI_TDTOK_DEVADRS_ROT) & UHCI_TDTOK_DEVADRS_MASK)
  283. /* Macros to retrieve/format UHCI_TDTOK_PID */
  284. #define UHCI_TDTOK_PID(x) 
  285.     (((x) & UHCI_TDTOK_PID_MASK) >> UHCI_TDTOK_PID_ROT)
  286. #define UHCI_TDTOK_PID_FMT(x) 
  287.     (((x) << UHCI_TDTOK_PID_ROT) & UHCI_TDTOK_PID_MASK)
  288. /*
  289.  * Queue Head.
  290.  *
  291.  * NOTE: Each Queue Head (QH) must be aligned on a 16-byte boundary.
  292.  */
  293. typedef struct uhci_qh
  294.     {
  295.     UINT32  qhLink; /* Link pointer to next QH */
  296.     UINT32  tdLink; /* Link to queue element */
  297.     } UHCI_QH, *pUHCI_QH;
  298. #define UHCI_QH_LEN 8     /* QH length required by UHCI hardware */
  299. #define UHCI_QH_ACTLEN sizeof (UHCI_QH)
  300. #ifdef __cplusplus
  301. }
  302. #endif
  303. #endif /* __INCusbUhcih */
  304. /* End of file. */