usbehci.h 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242
  1. /* override default macros from ../port/usb.h */
  2. #undef dprint
  3. #undef ddprint
  4. #undef deprint
  5. #undef ddeprint
  6. #define dprint if(ehcidebug)print
  7. #define ddprint if(ehcidebug>1)print
  8. #define deprint if(ehcidebug || ep->debug)print
  9. #define ddeprint if(ehcidebug>1 || ep->debug>1)print
  10. typedef struct Ctlr Ctlr;
  11. typedef struct Ecapio Ecapio;
  12. typedef struct Eopio Eopio;
  13. typedef struct Edbgio Edbgio;
  14. typedef struct Isoio Isoio;
  15. typedef struct Poll Poll;
  16. typedef struct Qh Qh;
  17. typedef struct Qtree Qtree;
  18. #pragma incomplete Ctlr;
  19. #pragma incomplete Ecapio;
  20. #pragma incomplete Eopio;
  21. #pragma incomplete Edbgio;
  22. #pragma incomplete Isoio;
  23. #pragma incomplete Poll;
  24. #pragma incomplete Qh;
  25. #pragma incomplete Qtree;
  26. /*
  27. * EHCI interface registers and bits
  28. */
  29. enum
  30. {
  31. Cnports = 0xF, /* nport bits in Ecapio parms. */
  32. Cdbgportshift = 20, /* debug port in Ecapio parms. */
  33. Cdbgportmask = 0xF,
  34. C64 = 1, /* 64-bits, in Ecapio capparms. */
  35. Ceecpshift = 8, /* extended capabilities ptr. in */
  36. Ceecpmask = 8, /* the Ecapio capparms reg. */
  37. Clegacy = 1, /* legacy support cap. id */
  38. CLbiossem = 2, /* legacy cap. bios sem. */
  39. CLossem = 3, /* legacy cap. os sem */
  40. /* typed links */
  41. Lterm = 1,
  42. Litd = 0<<1,
  43. Lqh = 1<<1,
  44. Lsitd = 2<<1,
  45. Lfstn = 3<<1, /* we don't use these */
  46. /* Cmd reg. */
  47. Cstop = 0x00000, /* stop running */
  48. Crun = 0x00001, /* start operation */
  49. Chcreset = 0x00002, /* host controller reset */
  50. Cflsmask = 0x0000C, /* frame list size bits */
  51. Cfls1024 = 0x00000, /* frame list size 1024 */
  52. Cfls512 = 0x00004, /* frame list size 512 frames */
  53. Cfls256 = 0x00008, /* frame list size 256 frames */
  54. Cpse = 0x00010, /* periodic sched. enable */
  55. Case = 0x00020, /* async sched. enable */
  56. Ciasync = 0x00040, /* interrupt on async advance doorbell */
  57. Citc1 = 0x10000, /* interrupt threshold ctl. 1 µframe */
  58. Citc4 = 0x40000, /* same. 2 µframes */
  59. /* ... */
  60. Citc8 = 0x80000, /* same. 8 µframes (can go up to 64) */
  61. /* Sts reg. */
  62. Sasyncss = 0x08000, /* aync schedule status */
  63. Speriodss = 0x04000, /* periodic schedule status */
  64. Srecl = 0x02000, /* reclamnation (empty async sched.) */
  65. Shalted = 0x01000, /* h.c. is halted */
  66. Sasync = 0x00020, /* interrupt on async advance */
  67. Sherr = 0x00010, /* host system error */
  68. Sfrroll = 0x00008, /* frame list roll over */
  69. Sportchg = 0x00004, /* port change detect */
  70. Serrintr = 0x00002, /* error interrupt */
  71. Sintr = 0x00001, /* interrupt */
  72. Sintrs = 0x0003F, /* interrupts status */
  73. /* Intr reg. */
  74. Iusb = 0x01, /* intr. on usb */
  75. Ierr = 0x02, /* intr. on usb error */
  76. Iportchg = 0x04, /* intr. on port change */
  77. Ifrroll = 0x08, /* intr. on frlist roll over */
  78. Ihcerr = 0x10, /* intr. on host error */
  79. Iasync = 0x20, /* intr. on async advance enable */
  80. Iall = 0x3F, /* all interrupts */
  81. /* Config reg. */
  82. Callmine = 1, /* route all ports to us */
  83. /* Portsc reg. */
  84. Pspresent = 0x00000001, /* device present */
  85. Psstatuschg = 0x00000002, /* Pspresent changed */
  86. Psenable = 0x00000004, /* device enabled */
  87. Pschange = 0x00000008, /* Psenable changed */
  88. Psresume = 0x00000040, /* resume detected */
  89. Pssuspend = 0x00000080, /* port suspended */
  90. Psreset = 0x00000100, /* port reset */
  91. Pspower = 0x00001000, /* port power on */
  92. Psowner = 0x00002000, /* port owned by companion */
  93. Pslinemask = 0x00000C00, /* line status bits */
  94. Pslow = 0x00000400, /* low speed device */
  95. /* Debug port csw reg. */
  96. Cowner = 0x40000000, /* port owned by ehci */
  97. Cenable = 0x10000000, /* debug port enabled */
  98. Cdone = 0x00010000, /* request is done */
  99. Cbusy = 0x00000400, /* port in use by a driver */
  100. Cerrmask= 0x00000380, /* error code bits */
  101. Chwerr = 0x00000100, /* hardware error */
  102. Cterr = 0x00000080, /* transaction error */
  103. Cfailed = 0x00000040, /* transaction did fail */
  104. Cgo = 0x00000020, /* execute the transaction */
  105. Cwrite = 0x00000010, /* request is a write */
  106. Clen = 0x0000000F, /* data len */
  107. /* Debug port pid reg. */
  108. Prpidshift = 16, /* received pid */
  109. Prpidmask = 0xFF,
  110. Pspidshift = 8, /* sent pid */
  111. Pspidmask = 0xFF,
  112. Ptokshift = 0, /* token pid */
  113. Ptokmask = 0xFF,
  114. Ptoggle = 0x00008800, /* to update toggles */
  115. Ptogglemask = 0x0000FF00,
  116. /* Debug port addr reg. */
  117. Adevshift = 8, /* device address */
  118. Adevmask = 0x7F,
  119. Aepshift = 0, /* endpoint number */
  120. Aepmask = 0xF,
  121. };
  122. /*
  123. * Capability registers (hw)
  124. */
  125. struct Ecapio
  126. {
  127. ulong cap; /* 00 controller capability register */
  128. ulong parms; /* 04 structural parameters register */
  129. ulong capparms; /* 08 capability parameters */
  130. ulong portroute; /* 0c not on the CS5536 */
  131. };
  132. /*
  133. * Debug port registers (hw)
  134. */
  135. struct Edbgio
  136. {
  137. ulong csw; /* control and status */
  138. ulong pid; /* USB pid */
  139. uchar data[8]; /* data buffer */
  140. ulong addr; /* device and endpoint addresses */
  141. };
  142. struct Poll
  143. {
  144. Lock;
  145. Rendez;
  146. int must;
  147. int does;
  148. };
  149. struct Ctlr
  150. {
  151. Rendez; /* for waiting to async advance doorbell */
  152. Lock; /* for ilock. qh lists and basic ctlr I/O */
  153. QLock portlck; /* for port resets/enable... (and doorbell) */
  154. int active; /* in use or not */
  155. Ecapio* capio; /* Capability i/o regs */
  156. Eopio* opio; /* Operational i/o regs */
  157. int nframes; /* 1024, 512, or 256 frames in the list */
  158. ulong* frames; /* periodic frame list (hw) */
  159. Qh* qhs; /* async Qh circular list for bulk/ctl */
  160. Qtree* tree; /* tree of Qhs for the periodic list */
  161. int ntree; /* number of dummy qhs in tree */
  162. Qh* intrqhs; /* list of (not dummy) qhs in tree */
  163. Isoio* iso; /* list of active Iso I/O */
  164. ulong load;
  165. ulong isoload;
  166. int nintr; /* number of interrupts attended */
  167. int ntdintr; /* number of intrs. with something to do */
  168. int nqhintr; /* number of async td intrs. */
  169. int nisointr; /* number of periodic td intrs. */
  170. int nreqs;
  171. Poll poll;
  172. };
  173. /*
  174. * Kirkwood-specific stuff
  175. */
  176. /*
  177. * Operational registers (hw)
  178. */
  179. struct Eopio
  180. {
  181. ulong cmd; /* 00 command */
  182. ulong sts; /* 04 status */
  183. ulong intr; /* 08 interrupt enable */
  184. ulong frno; /* 0c frame index */
  185. ulong seg; /* 10 bits 63:32 of EHCI datastructs (unused) */
  186. ulong frbase; /* 14 frame list base addr, 4096-byte boundary */
  187. ulong link; /* 18 link for async list */
  188. uchar d2c[0x40-0x1c]; /* 1c dummy */
  189. ulong config; /* 40 1: all ports default-routed to this HC */
  190. ulong portsc[1]; /* 44 Port status and control, one per port */
  191. /*
  192. * these are present on the Kirkwood USB controller.
  193. * are they standard now? Marvell doesn't document them publically.
  194. */
  195. uchar _pad0[0x64-0x48];
  196. ulong otgsc;
  197. ulong usbmode;
  198. ulong epsetupsts;
  199. ulong epprime;
  200. ulong epflush;
  201. ulong epsts;
  202. ulong epcompl;
  203. ulong epctl[6];
  204. /* freescale registers */
  205. uchar _pad1[0x2c0-0x98];
  206. ulong snoop1;
  207. ulong snoop2;
  208. ulong agecntthresh;
  209. ulong prictl; /* priority control */
  210. ulong sictl; /* system interface control */
  211. uchar _pad2[0x3c0-0x2d4];
  212. ulong ctl;
  213. };
  214. extern int ehcidebug;
  215. void ehcilinkage(Hci *hp);
  216. void ehcimeminit(Ctlr *ctlr);
  217. void ehcirun(Ctlr *ctlr, int on);