usb_ehci.h 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167
  1. /*-
  2. * Copyright (c) 2007-2008, Juniper Networks, Inc.
  3. * All rights reserved.
  4. *
  5. * This program is free software; you can redistribute it and/or
  6. * modify it under the terms of the GNU General Public License as
  7. * published by the Free Software Foundation version 2 of
  8. * the License.
  9. *
  10. * This program is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License
  16. * along with this program; if not, write to the Free Software
  17. * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  18. * MA 02111-1307 USA
  19. */
  20. #ifndef USB_EHCI_H
  21. #define USB_EHCI_H
  22. /* (shifted) direction/type/recipient from the USB 2.0 spec, table 9.2 */
  23. #define DeviceRequest \
  24. ((USB_DIR_IN | USB_TYPE_STANDARD | USB_RECIP_DEVICE) << 8)
  25. #define DeviceOutRequest \
  26. ((USB_DIR_OUT | USB_TYPE_STANDARD | USB_RECIP_DEVICE) << 8)
  27. #define InterfaceRequest \
  28. ((USB_DIR_IN | USB_TYPE_STANDARD | USB_RECIP_INTERFACE) << 8)
  29. #define EndpointRequest \
  30. ((USB_DIR_IN | USB_TYPE_STANDARD | USB_RECIP_INTERFACE) << 8)
  31. #define EndpointOutRequest \
  32. ((USB_DIR_OUT | USB_TYPE_STANDARD | USB_RECIP_INTERFACE) << 8)
  33. /*
  34. * Register Space.
  35. */
  36. struct ehci_hccr {
  37. uint32_t cr_capbase;
  38. #define HC_LENGTH(p) (((p) >> 0) & 0x00ff)
  39. #define HC_VERSION(p) (((p) >> 16) & 0xffff)
  40. uint32_t cr_hcsparams;
  41. uint32_t cr_hccparams;
  42. uint8_t cr_hcsp_portrt[8];
  43. };
  44. struct ehci_hcor {
  45. uint32_t or_usbcmd;
  46. #define CMD_ASE (1 << 5)
  47. uint32_t or_usbsts;
  48. #define STD_ASS (1 << 15)
  49. uint32_t or_usbintr;
  50. uint32_t or_frindex;
  51. uint32_t or_ctrldssegment;
  52. uint32_t or_periodiclistbase;
  53. uint32_t or_asynclistaddr;
  54. uint32_t _reserved_[9];
  55. uint32_t or_configflag;
  56. uint32_t or_portsc[2];
  57. uint32_t or_systune;
  58. };
  59. /* Interface descriptor */
  60. struct usb_linux_interface_descriptor {
  61. unsigned char bLength;
  62. unsigned char bDescriptorType;
  63. unsigned char bInterfaceNumber;
  64. unsigned char bAlternateSetting;
  65. unsigned char bNumEndpoints;
  66. unsigned char bInterfaceClass;
  67. unsigned char bInterfaceSubClass;
  68. unsigned char bInterfaceProtocol;
  69. unsigned char iInterface;
  70. } __attribute__ ((packed));
  71. /* Configuration descriptor information.. */
  72. struct usb_linux_config_descriptor {
  73. unsigned char bLength;
  74. unsigned char bDescriptorType;
  75. unsigned short wTotalLength;
  76. unsigned char bNumInterfaces;
  77. unsigned char bConfigurationValue;
  78. unsigned char iConfiguration;
  79. unsigned char bmAttributes;
  80. unsigned char MaxPower;
  81. } __attribute__ ((packed));
  82. #if defined CONFIG_EHCI_DESC_BIG_ENDIAN
  83. #define ehci_readl(x) (x)
  84. #define ehci_writel(a, b) (a) = (b)
  85. #else
  86. #define ehci_readl(x) cpu_to_le32((x))
  87. #define ehci_writel(a, b) (a) = cpu_to_le32((b))
  88. #endif
  89. #if defined CONFIG_EHCI_MMIO_BIG_ENDIAN
  90. #define hc32_to_cpu(x) be32_to_cpu((x))
  91. #define cpu_to_hc32(x) cpu_to_be32((x))
  92. #else
  93. #define hc32_to_cpu(x) le32_to_cpu((x))
  94. #define cpu_to_hc32(x) cpu_to_le32((x))
  95. #endif
  96. #define EHCI_PS_WKOC_E 0x00400000 /* RW wake on over current */
  97. #define EHCI_PS_WKDSCNNT_E 0x00200000 /* RW wake on disconnect */
  98. #define EHCI_PS_WKCNNT_E 0x00100000 /* RW wake on connect */
  99. #define EHCI_PS_PTC 0x000f0000 /* RW port test control */
  100. #define EHCI_PS_PIC 0x0000c000 /* RW port indicator control */
  101. #define EHCI_PS_PO 0x00002000 /* RW port owner */
  102. #define EHCI_PS_PP 0x00001000 /* RW,RO port power */
  103. #define EHCI_PS_LS 0x00000c00 /* RO line status */
  104. #define EHCI_PS_PR 0x00000100 /* RW port reset */
  105. #define EHCI_PS_SUSP 0x00000080 /* RW suspend */
  106. #define EHCI_PS_FPR 0x00000040 /* RW force port resume */
  107. #define EHCI_PS_OCC 0x00000020 /* RWC over current change */
  108. #define EHCI_PS_OCA 0x00000010 /* RO over current active */
  109. #define EHCI_PS_PEC 0x00000008 /* RWC port enable change */
  110. #define EHCI_PS_PE 0x00000004 /* RW port enable */
  111. #define EHCI_PS_CSC 0x00000002 /* RWC connect status change */
  112. #define EHCI_PS_CS 0x00000001 /* RO connect status */
  113. #define EHCI_PS_CLEAR (EHCI_PS_OCC | EHCI_PS_PEC | EHCI_PS_CSC)
  114. #define EHCI_PS_IS_LOWSPEED(x) (((x) & EHCI_PS_LS) == 0x00000400)
  115. /*
  116. * Schedule Interface Space.
  117. *
  118. * IMPORTANT: Software must ensure that no interface data structure
  119. * reachable by the EHCI host controller spans a 4K page boundary!
  120. *
  121. * Periodic transfers (i.e. isochronous and interrupt transfers) are
  122. * not supported.
  123. */
  124. /* Queue Element Transfer Descriptor (qTD). */
  125. struct qTD {
  126. uint32_t qt_next;
  127. #define QT_NEXT_TERMINATE 1
  128. uint32_t qt_altnext;
  129. uint32_t qt_token;
  130. uint32_t qt_buffer[5];
  131. };
  132. /* Queue Head (QH). */
  133. struct QH {
  134. uint32_t qh_link;
  135. #define QH_LINK_TERMINATE 1
  136. #define QH_LINK_TYPE_ITD 0
  137. #define QH_LINK_TYPE_QH 2
  138. #define QH_LINK_TYPE_SITD 4
  139. #define QH_LINK_TYPE_FSTN 6
  140. uint32_t qh_endpt1;
  141. uint32_t qh_endpt2;
  142. uint32_t qh_curtd;
  143. struct qTD qh_overlay;
  144. };
  145. /* Low level intit functions */
  146. int ehci_hcd_init(void);
  147. int ehci_hcd_stop(void);
  148. #endif /* USB_EHCI_H */