usb_ehci.h 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184
  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. #define HCS_N_PORTS(p) (((p) >> 0) & 0xf)
  42. uint32_t cr_hccparams;
  43. uint8_t cr_hcsp_portrt[8];
  44. };
  45. struct ehci_hcor {
  46. uint32_t or_usbcmd;
  47. #define CMD_PARK (1 << 11) /* enable "park" */
  48. #define CMD_PARK_CNT(c) (((c) >> 8) & 3) /* how many transfers to park */
  49. #define CMD_ASE (1 << 5) /* async schedule enable */
  50. #define CMD_LRESET (1 << 7) /* partial reset */
  51. #define CMD_IAAD (1 << 5) /* "doorbell" interrupt */
  52. #define CMD_PSE (1 << 4) /* periodic schedule enable */
  53. #define CMD_RESET (1 << 1) /* reset HC not bus */
  54. #define CMD_RUN (1 << 0) /* start/stop HC */
  55. uint32_t or_usbsts;
  56. #define STD_ASS (1 << 15)
  57. #define STS_HALT (1 << 12)
  58. uint32_t or_usbintr;
  59. uint32_t or_frindex;
  60. uint32_t or_ctrldssegment;
  61. uint32_t or_periodiclistbase;
  62. uint32_t or_asynclistaddr;
  63. uint32_t _reserved_[9];
  64. uint32_t or_configflag;
  65. #define FLAG_CF (1 << 0) /* true: we'll support "high speed" */
  66. uint32_t or_portsc[2];
  67. uint32_t or_systune;
  68. };
  69. #define USBMODE 0x68 /* USB Device mode */
  70. #define USBMODE_SDIS (1 << 3) /* Stream disable */
  71. #define USBMODE_BE (1 << 2) /* BE/LE endiannes select */
  72. #define USBMODE_CM_HC (3 << 0) /* host controller mode */
  73. #define USBMODE_CM_IDLE (0 << 0) /* idle state */
  74. /* Interface descriptor */
  75. struct usb_linux_interface_descriptor {
  76. unsigned char bLength;
  77. unsigned char bDescriptorType;
  78. unsigned char bInterfaceNumber;
  79. unsigned char bAlternateSetting;
  80. unsigned char bNumEndpoints;
  81. unsigned char bInterfaceClass;
  82. unsigned char bInterfaceSubClass;
  83. unsigned char bInterfaceProtocol;
  84. unsigned char iInterface;
  85. } __attribute__ ((packed));
  86. /* Configuration descriptor information.. */
  87. struct usb_linux_config_descriptor {
  88. unsigned char bLength;
  89. unsigned char bDescriptorType;
  90. unsigned short wTotalLength;
  91. unsigned char bNumInterfaces;
  92. unsigned char bConfigurationValue;
  93. unsigned char iConfiguration;
  94. unsigned char bmAttributes;
  95. unsigned char MaxPower;
  96. } __attribute__ ((packed));
  97. #if defined CONFIG_EHCI_DESC_BIG_ENDIAN
  98. #define ehci_readl(x) (*((volatile u32 *)(x)))
  99. #define ehci_writel(a, b) (*((volatile u32 *)(a)) = ((volatile u32)b))
  100. #else
  101. #define ehci_readl(x) cpu_to_le32((*((volatile u32 *)(x))))
  102. #define ehci_writel(a, b) (*((volatile u32 *)(a)) = \
  103. cpu_to_le32(((volatile u32)b)))
  104. #endif
  105. #if defined CONFIG_EHCI_MMIO_BIG_ENDIAN
  106. #define hc32_to_cpu(x) be32_to_cpu((x))
  107. #define cpu_to_hc32(x) cpu_to_be32((x))
  108. #else
  109. #define hc32_to_cpu(x) le32_to_cpu((x))
  110. #define cpu_to_hc32(x) cpu_to_le32((x))
  111. #endif
  112. #define EHCI_PS_WKOC_E 0x00400000 /* RW wake on over current */
  113. #define EHCI_PS_WKDSCNNT_E 0x00200000 /* RW wake on disconnect */
  114. #define EHCI_PS_WKCNNT_E 0x00100000 /* RW wake on connect */
  115. #define EHCI_PS_PTC 0x000f0000 /* RW port test control */
  116. #define EHCI_PS_PIC 0x0000c000 /* RW port indicator control */
  117. #define EHCI_PS_PO 0x00002000 /* RW port owner */
  118. #define EHCI_PS_PP 0x00001000 /* RW,RO port power */
  119. #define EHCI_PS_LS 0x00000c00 /* RO line status */
  120. #define EHCI_PS_PR 0x00000100 /* RW port reset */
  121. #define EHCI_PS_SUSP 0x00000080 /* RW suspend */
  122. #define EHCI_PS_FPR 0x00000040 /* RW force port resume */
  123. #define EHCI_PS_OCC 0x00000020 /* RWC over current change */
  124. #define EHCI_PS_OCA 0x00000010 /* RO over current active */
  125. #define EHCI_PS_PEC 0x00000008 /* RWC port enable change */
  126. #define EHCI_PS_PE 0x00000004 /* RW port enable */
  127. #define EHCI_PS_CSC 0x00000002 /* RWC connect status change */
  128. #define EHCI_PS_CS 0x00000001 /* RO connect status */
  129. #define EHCI_PS_CLEAR (EHCI_PS_OCC | EHCI_PS_PEC | EHCI_PS_CSC)
  130. #define EHCI_PS_IS_LOWSPEED(x) (((x) & EHCI_PS_LS) == 0x00000400)
  131. /*
  132. * Schedule Interface Space.
  133. *
  134. * IMPORTANT: Software must ensure that no interface data structure
  135. * reachable by the EHCI host controller spans a 4K page boundary!
  136. *
  137. * Periodic transfers (i.e. isochronous and interrupt transfers) are
  138. * not supported.
  139. */
  140. /* Queue Element Transfer Descriptor (qTD). */
  141. struct qTD {
  142. uint32_t qt_next;
  143. #define QT_NEXT_TERMINATE 1
  144. uint32_t qt_altnext;
  145. uint32_t qt_token;
  146. uint32_t qt_buffer[5];
  147. };
  148. /* Queue Head (QH). */
  149. struct QH {
  150. uint32_t qh_link;
  151. #define QH_LINK_TERMINATE 1
  152. #define QH_LINK_TYPE_ITD 0
  153. #define QH_LINK_TYPE_QH 2
  154. #define QH_LINK_TYPE_SITD 4
  155. #define QH_LINK_TYPE_FSTN 6
  156. uint32_t qh_endpt1;
  157. uint32_t qh_endpt2;
  158. uint32_t qh_curtd;
  159. struct qTD qh_overlay;
  160. };
  161. /* Low level intit functions */
  162. int ehci_hcd_init(void);
  163. int ehci_hcd_stop(void);
  164. #endif /* USB_EHCI_H */