au1x00_usb_ohci.c 45 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726
  1. /*
  2. * URB OHCI HCD (Host Controller Driver) for USB on the AU1x00.
  3. *
  4. * (C) Copyright 2003
  5. * Gary Jennejohn, DENX Software Engineering <garyj@denx.de>
  6. *
  7. * See file CREDITS for list of people who contributed to this
  8. * project.
  9. *
  10. * This program is free software; you can redistribute it and/or
  11. * modify it under the terms of the GNU General Public License as
  12. * published by the Free Software Foundation; either version 2 of
  13. * the License, or (at your option) any later version.
  14. *
  15. * This program is distributed in the hope that it will be useful,
  16. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  17. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  18. * GNU General Public License for more details.
  19. *
  20. * You should have received a copy of the GNU General Public License
  21. * along with this program; if not, write to the Free Software
  22. * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  23. * MA 02111-1307 USA
  24. *
  25. * Note: Part of this code has been derived from linux
  26. *
  27. */
  28. /*
  29. * IMPORTANT NOTES
  30. * 1 - this driver is intended for use with USB Mass Storage Devices
  31. * (BBB) ONLY. There is NO support for Interrupt or Isochronous pipes!
  32. */
  33. #include <config.h>
  34. #ifdef CONFIG_USB_OHCI
  35. /* #include <pci.h> no PCI on the AU1x00 */
  36. #include <common.h>
  37. #include <malloc.h>
  38. #include <asm/io.h>
  39. #include <asm/au1x00.h>
  40. #include <usb.h>
  41. #include "au1x00_usb_ohci.h"
  42. #define OHCI_USE_NPS /* force NoPowerSwitching mode */
  43. #define OHCI_VERBOSE_DEBUG /* not always helpful */
  44. #define OHCI_FILL_TRACE
  45. #define USBH_ENABLE_BE (1<<0)
  46. #define USBH_ENABLE_C (1<<1)
  47. #define USBH_ENABLE_E (1<<2)
  48. #define USBH_ENABLE_CE (1<<3)
  49. #define USBH_ENABLE_RD (1<<4)
  50. #ifdef __LITTLE_ENDIAN
  51. #define USBH_ENABLE_INIT (USBH_ENABLE_CE | USBH_ENABLE_E | USBH_ENABLE_C)
  52. #else
  53. #define USBH_ENABLE_INIT (USBH_ENABLE_CE | USBH_ENABLE_E | USBH_ENABLE_C | USBH_ENABLE_BE)
  54. #endif
  55. /* For initializing controller (mask in an HCFS mode too) */
  56. #define OHCI_CONTROL_INIT \
  57. (OHCI_CTRL_CBSR & 0x3) | OHCI_CTRL_IE | OHCI_CTRL_PLE
  58. #undef readl
  59. #undef writel
  60. #define readl(a) au_readl((long)(a))
  61. #define writel(v,a) au_writel((v),(int)(a))
  62. #define min_t(type,x,y) ({ type __x = (x); type __y = (y); __x < __y ? __x: __y; })
  63. #define DEBUG
  64. #ifdef DEBUG
  65. #define dbg(format, arg...) printf("DEBUG: " format "\n", ## arg)
  66. #else
  67. #define dbg(format, arg...) do {} while(0)
  68. #endif /* DEBUG */
  69. #define err(format, arg...) printf("ERROR: " format "\n", ## arg)
  70. #define SHOW_INFO
  71. #ifdef SHOW_INFO
  72. #define info(format, arg...) printf("INFO: " format "\n", ## arg)
  73. #else
  74. #define info(format, arg...) do {} while(0)
  75. #endif
  76. #define m16_swap(x) swap_16(x)
  77. #define m32_swap(x) swap_32(x)
  78. /* global ohci_t */
  79. static ohci_t gohci;
  80. /* this must be aligned to a 256 byte boundary */
  81. struct ohci_hcca ghcca[1];
  82. /* a pointer to the aligned storage */
  83. struct ohci_hcca *phcca;
  84. /* this allocates EDs for all possible endpoints */
  85. struct ohci_device ohci_dev;
  86. /* urb_priv */
  87. urb_priv_t urb_priv;
  88. /* RHSC flag */
  89. int got_rhsc;
  90. /* device which was disconnected */
  91. struct usb_device *devgone;
  92. /*-------------------------------------------------------------------------*/
  93. /* AMD-756 (D2 rev) reports corrupt register contents in some cases.
  94. * The erratum (#4) description is incorrect. AMD's workaround waits
  95. * till some bits (mostly reserved) are clear; ok for all revs.
  96. */
  97. #define OHCI_QUIRK_AMD756 0xabcd
  98. #define read_roothub(hc, register, mask) ({ \
  99. u32 temp = readl (&hc->regs->roothub.register); \
  100. if (hc->flags & OHCI_QUIRK_AMD756) \
  101. while (temp & mask) \
  102. temp = readl (&hc->regs->roothub.register); \
  103. temp; })
  104. static u32 roothub_a (struct ohci *hc)
  105. { return read_roothub (hc, a, 0xfc0fe000); }
  106. static inline u32 roothub_b (struct ohci *hc)
  107. { return readl (&hc->regs->roothub.b); }
  108. static inline u32 roothub_status (struct ohci *hc)
  109. { return readl (&hc->regs->roothub.status); }
  110. static u32 roothub_portstatus (struct ohci *hc, int i)
  111. { return read_roothub (hc, portstatus [i], 0xffe0fce0); }
  112. /* forward declaration */
  113. static int hc_interrupt (void);
  114. static void
  115. td_submit_job (struct usb_device * dev, unsigned long pipe, void * buffer,
  116. int transfer_len, struct devrequest * setup, urb_priv_t * urb, int interval);
  117. /*-------------------------------------------------------------------------*
  118. * URB support functions
  119. *-------------------------------------------------------------------------*/
  120. /* free HCD-private data associated with this URB */
  121. static void urb_free_priv (urb_priv_t * urb)
  122. {
  123. int i;
  124. int last;
  125. struct td * td;
  126. last = urb->length - 1;
  127. if (last >= 0) {
  128. for (i = 0; i <= last; i++) {
  129. td = urb->td[i];
  130. if (td) {
  131. td->usb_dev = NULL;
  132. urb->td[i] = NULL;
  133. }
  134. }
  135. }
  136. }
  137. /*-------------------------------------------------------------------------*/
  138. #ifdef DEBUG
  139. static int sohci_get_current_frame_number (struct usb_device * dev);
  140. /* debug| print the main components of an URB
  141. * small: 0) header + data packets 1) just header */
  142. static void pkt_print (struct usb_device * dev, unsigned long pipe, void * buffer,
  143. int transfer_len, struct devrequest * setup, char * str, int small)
  144. {
  145. urb_priv_t * purb = &urb_priv;
  146. dbg("%s URB:[%4x] dev:%2d,ep:%2d-%c,type:%s,len:%d/%d stat:%#lx",
  147. str,
  148. sohci_get_current_frame_number (dev),
  149. usb_pipedevice (pipe),
  150. usb_pipeendpoint (pipe),
  151. usb_pipeout (pipe)? 'O': 'I',
  152. usb_pipetype (pipe) < 2? (usb_pipeint (pipe)? "INTR": "ISOC"):
  153. (usb_pipecontrol (pipe)? "CTRL": "BULK"),
  154. purb->actual_length,
  155. transfer_len, dev->status);
  156. #ifdef OHCI_VERBOSE_DEBUG
  157. if (!small) {
  158. int i, len;
  159. if (usb_pipecontrol (pipe)) {
  160. printf (__FILE__ ": cmd(8):");
  161. for (i = 0; i < 8 ; i++)
  162. printf (" %02x", ((__u8 *) setup) [i]);
  163. printf ("\n");
  164. }
  165. if (transfer_len > 0 && buffer) {
  166. printf (__FILE__ ": data(%d/%d):",
  167. purb->actual_length,
  168. transfer_len);
  169. len = usb_pipeout (pipe)?
  170. transfer_len: purb->actual_length;
  171. for (i = 0; i < 16 && i < len; i++)
  172. printf (" %02x", ((__u8 *) buffer) [i]);
  173. printf ("%s\n", i < len? "...": "");
  174. }
  175. }
  176. #endif
  177. }
  178. /* just for debugging; prints non-empty branches of the int ed tree inclusive iso eds*/
  179. void ep_print_int_eds (ohci_t *ohci, char * str) {
  180. int i, j;
  181. __u32 * ed_p;
  182. for (i= 0; i < 32; i++) {
  183. j = 5;
  184. ed_p = &(ohci->hcca->int_table [i]);
  185. if (*ed_p == 0)
  186. continue;
  187. printf (__FILE__ ": %s branch int %2d(%2x):", str, i, i);
  188. while (*ed_p != 0 && j--) {
  189. ed_t *ed = (ed_t *)m32_swap(ed_p);
  190. printf (" ed: %4x;", ed->hwINFO);
  191. ed_p = &ed->hwNextED;
  192. }
  193. printf ("\n");
  194. }
  195. }
  196. static void ohci_dump_intr_mask (char *label, __u32 mask)
  197. {
  198. dbg ("%s: 0x%08x%s%s%s%s%s%s%s%s%s",
  199. label,
  200. mask,
  201. (mask & OHCI_INTR_MIE) ? " MIE" : "",
  202. (mask & OHCI_INTR_OC) ? " OC" : "",
  203. (mask & OHCI_INTR_RHSC) ? " RHSC" : "",
  204. (mask & OHCI_INTR_FNO) ? " FNO" : "",
  205. (mask & OHCI_INTR_UE) ? " UE" : "",
  206. (mask & OHCI_INTR_RD) ? " RD" : "",
  207. (mask & OHCI_INTR_SF) ? " SF" : "",
  208. (mask & OHCI_INTR_WDH) ? " WDH" : "",
  209. (mask & OHCI_INTR_SO) ? " SO" : ""
  210. );
  211. }
  212. static void maybe_print_eds (char *label, __u32 value)
  213. {
  214. ed_t *edp = (ed_t *)value;
  215. if (value) {
  216. dbg ("%s %08x", label, value);
  217. dbg ("%08x", edp->hwINFO);
  218. dbg ("%08x", edp->hwTailP);
  219. dbg ("%08x", edp->hwHeadP);
  220. dbg ("%08x", edp->hwNextED);
  221. }
  222. }
  223. static char * hcfs2string (int state)
  224. {
  225. switch (state) {
  226. case OHCI_USB_RESET: return "reset";
  227. case OHCI_USB_RESUME: return "resume";
  228. case OHCI_USB_OPER: return "operational";
  229. case OHCI_USB_SUSPEND: return "suspend";
  230. }
  231. return "?";
  232. }
  233. /* dump control and status registers */
  234. static void ohci_dump_status (ohci_t *controller)
  235. {
  236. struct ohci_regs *regs = controller->regs;
  237. __u32 temp;
  238. temp = readl (&regs->revision) & 0xff;
  239. if (temp != 0x10)
  240. dbg ("spec %d.%d", (temp >> 4), (temp & 0x0f));
  241. temp = readl (&regs->control);
  242. dbg ("control: 0x%08x%s%s%s HCFS=%s%s%s%s%s CBSR=%d", temp,
  243. (temp & OHCI_CTRL_RWE) ? " RWE" : "",
  244. (temp & OHCI_CTRL_RWC) ? " RWC" : "",
  245. (temp & OHCI_CTRL_IR) ? " IR" : "",
  246. hcfs2string (temp & OHCI_CTRL_HCFS),
  247. (temp & OHCI_CTRL_BLE) ? " BLE" : "",
  248. (temp & OHCI_CTRL_CLE) ? " CLE" : "",
  249. (temp & OHCI_CTRL_IE) ? " IE" : "",
  250. (temp & OHCI_CTRL_PLE) ? " PLE" : "",
  251. temp & OHCI_CTRL_CBSR
  252. );
  253. temp = readl (&regs->cmdstatus);
  254. dbg ("cmdstatus: 0x%08x SOC=%d%s%s%s%s", temp,
  255. (temp & OHCI_SOC) >> 16,
  256. (temp & OHCI_OCR) ? " OCR" : "",
  257. (temp & OHCI_BLF) ? " BLF" : "",
  258. (temp & OHCI_CLF) ? " CLF" : "",
  259. (temp & OHCI_HCR) ? " HCR" : ""
  260. );
  261. ohci_dump_intr_mask ("intrstatus", readl (&regs->intrstatus));
  262. ohci_dump_intr_mask ("intrenable", readl (&regs->intrenable));
  263. maybe_print_eds ("ed_periodcurrent", readl (&regs->ed_periodcurrent));
  264. maybe_print_eds ("ed_controlhead", readl (&regs->ed_controlhead));
  265. maybe_print_eds ("ed_controlcurrent", readl (&regs->ed_controlcurrent));
  266. maybe_print_eds ("ed_bulkhead", readl (&regs->ed_bulkhead));
  267. maybe_print_eds ("ed_bulkcurrent", readl (&regs->ed_bulkcurrent));
  268. maybe_print_eds ("donehead", readl (&regs->donehead));
  269. }
  270. static void ohci_dump_roothub (ohci_t *controller, int verbose)
  271. {
  272. __u32 temp, ndp, i;
  273. temp = roothub_a (controller);
  274. ndp = (temp & RH_A_NDP);
  275. if (verbose) {
  276. dbg ("roothub.a: %08x POTPGT=%d%s%s%s%s%s NDP=%d", temp,
  277. ((temp & RH_A_POTPGT) >> 24) & 0xff,
  278. (temp & RH_A_NOCP) ? " NOCP" : "",
  279. (temp & RH_A_OCPM) ? " OCPM" : "",
  280. (temp & RH_A_DT) ? " DT" : "",
  281. (temp & RH_A_NPS) ? " NPS" : "",
  282. (temp & RH_A_PSM) ? " PSM" : "",
  283. ndp
  284. );
  285. temp = roothub_b (controller);
  286. dbg ("roothub.b: %08x PPCM=%04x DR=%04x",
  287. temp,
  288. (temp & RH_B_PPCM) >> 16,
  289. (temp & RH_B_DR)
  290. );
  291. temp = roothub_status (controller);
  292. dbg ("roothub.status: %08x%s%s%s%s%s%s",
  293. temp,
  294. (temp & RH_HS_CRWE) ? " CRWE" : "",
  295. (temp & RH_HS_OCIC) ? " OCIC" : "",
  296. (temp & RH_HS_LPSC) ? " LPSC" : "",
  297. (temp & RH_HS_DRWE) ? " DRWE" : "",
  298. (temp & RH_HS_OCI) ? " OCI" : "",
  299. (temp & RH_HS_LPS) ? " LPS" : ""
  300. );
  301. }
  302. for (i = 0; i < ndp; i++) {
  303. temp = roothub_portstatus (controller, i);
  304. dbg ("roothub.portstatus [%d] = 0x%08x%s%s%s%s%s%s%s%s%s%s%s%s",
  305. i,
  306. temp,
  307. (temp & RH_PS_PRSC) ? " PRSC" : "",
  308. (temp & RH_PS_OCIC) ? " OCIC" : "",
  309. (temp & RH_PS_PSSC) ? " PSSC" : "",
  310. (temp & RH_PS_PESC) ? " PESC" : "",
  311. (temp & RH_PS_CSC) ? " CSC" : "",
  312. (temp & RH_PS_LSDA) ? " LSDA" : "",
  313. (temp & RH_PS_PPS) ? " PPS" : "",
  314. (temp & RH_PS_PRS) ? " PRS" : "",
  315. (temp & RH_PS_POCI) ? " POCI" : "",
  316. (temp & RH_PS_PSS) ? " PSS" : "",
  317. (temp & RH_PS_PES) ? " PES" : "",
  318. (temp & RH_PS_CCS) ? " CCS" : ""
  319. );
  320. }
  321. }
  322. static void ohci_dump (ohci_t *controller, int verbose)
  323. {
  324. dbg ("OHCI controller usb-%s state", controller->slot_name);
  325. /* dumps some of the state we know about */
  326. ohci_dump_status (controller);
  327. if (verbose)
  328. ep_print_int_eds (controller, "hcca");
  329. dbg ("hcca frame #%04x", controller->hcca->frame_no);
  330. ohci_dump_roothub (controller, 1);
  331. }
  332. #endif /* DEBUG */
  333. /*-------------------------------------------------------------------------*
  334. * Interface functions (URB)
  335. *-------------------------------------------------------------------------*/
  336. /* get a transfer request */
  337. int sohci_submit_job(struct usb_device *dev, unsigned long pipe, void *buffer,
  338. int transfer_len, struct devrequest *setup, int interval)
  339. {
  340. ohci_t *ohci;
  341. ed_t * ed;
  342. urb_priv_t *purb_priv;
  343. int i, size = 0;
  344. ohci = &gohci;
  345. /* when controller's hung, permit only roothub cleanup attempts
  346. * such as powering down ports */
  347. if (ohci->disabled) {
  348. err("sohci_submit_job: EPIPE");
  349. return -1;
  350. }
  351. /* every endpoint has a ed, locate and fill it */
  352. if (!(ed = ep_add_ed (dev, pipe))) {
  353. err("sohci_submit_job: ENOMEM");
  354. return -1;
  355. }
  356. /* for the private part of the URB we need the number of TDs (size) */
  357. switch (usb_pipetype (pipe)) {
  358. case PIPE_BULK: /* one TD for every 4096 Byte */
  359. size = (transfer_len - 1) / 4096 + 1;
  360. break;
  361. case PIPE_CONTROL: /* 1 TD for setup, 1 for ACK and 1 for every 4096 B */
  362. size = (transfer_len == 0)? 2:
  363. (transfer_len - 1) / 4096 + 3;
  364. break;
  365. }
  366. if (size >= (N_URB_TD - 1)) {
  367. err("need %d TDs, only have %d", size, N_URB_TD);
  368. return -1;
  369. }
  370. purb_priv = &urb_priv;
  371. purb_priv->pipe = pipe;
  372. /* fill the private part of the URB */
  373. purb_priv->length = size;
  374. purb_priv->ed = ed;
  375. purb_priv->actual_length = 0;
  376. /* allocate the TDs */
  377. /* note that td[0] was allocated in ep_add_ed */
  378. for (i = 0; i < size; i++) {
  379. purb_priv->td[i] = td_alloc (dev);
  380. if (!purb_priv->td[i]) {
  381. purb_priv->length = i;
  382. urb_free_priv (purb_priv);
  383. err("sohci_submit_job: ENOMEM");
  384. return -1;
  385. }
  386. }
  387. if (ed->state == ED_NEW || (ed->state & ED_DEL)) {
  388. urb_free_priv (purb_priv);
  389. err("sohci_submit_job: EINVAL");
  390. return -1;
  391. }
  392. /* link the ed into a chain if is not already */
  393. if (ed->state != ED_OPER)
  394. ep_link (ohci, ed);
  395. /* fill the TDs and link it to the ed */
  396. td_submit_job(dev, pipe, buffer, transfer_len, setup, purb_priv, interval);
  397. return 0;
  398. }
  399. /*-------------------------------------------------------------------------*/
  400. #ifdef DEBUG
  401. /* tell us the current USB frame number */
  402. static int sohci_get_current_frame_number (struct usb_device *usb_dev)
  403. {
  404. ohci_t *ohci = &gohci;
  405. return m16_swap (ohci->hcca->frame_no);
  406. }
  407. #endif
  408. /*-------------------------------------------------------------------------*
  409. * ED handling functions
  410. *-------------------------------------------------------------------------*/
  411. /* link an ed into one of the HC chains */
  412. static int ep_link (ohci_t *ohci, ed_t *edi)
  413. {
  414. volatile ed_t *ed = edi;
  415. ed->state = ED_OPER;
  416. switch (ed->type) {
  417. case PIPE_CONTROL:
  418. ed->hwNextED = 0;
  419. if (ohci->ed_controltail == NULL) {
  420. writel ((long)ed, &ohci->regs->ed_controlhead);
  421. } else {
  422. ohci->ed_controltail->hwNextED = m32_swap (ed);
  423. }
  424. ed->ed_prev = ohci->ed_controltail;
  425. if (!ohci->ed_controltail && !ohci->ed_rm_list[0] &&
  426. !ohci->ed_rm_list[1] && !ohci->sleeping) {
  427. ohci->hc_control |= OHCI_CTRL_CLE;
  428. writel (ohci->hc_control, &ohci->regs->control);
  429. }
  430. ohci->ed_controltail = edi;
  431. break;
  432. case PIPE_BULK:
  433. ed->hwNextED = 0;
  434. if (ohci->ed_bulktail == NULL) {
  435. writel ((long)ed, &ohci->regs->ed_bulkhead);
  436. } else {
  437. ohci->ed_bulktail->hwNextED = m32_swap (ed);
  438. }
  439. ed->ed_prev = ohci->ed_bulktail;
  440. if (!ohci->ed_bulktail && !ohci->ed_rm_list[0] &&
  441. !ohci->ed_rm_list[1] && !ohci->sleeping) {
  442. ohci->hc_control |= OHCI_CTRL_BLE;
  443. writel (ohci->hc_control, &ohci->regs->control);
  444. }
  445. ohci->ed_bulktail = edi;
  446. break;
  447. }
  448. return 0;
  449. }
  450. /*-------------------------------------------------------------------------*/
  451. /* unlink an ed from one of the HC chains.
  452. * just the link to the ed is unlinked.
  453. * the link from the ed still points to another operational ed or 0
  454. * so the HC can eventually finish the processing of the unlinked ed */
  455. static int ep_unlink (ohci_t *ohci, ed_t *ed)
  456. {
  457. ed->hwINFO |= m32_swap (OHCI_ED_SKIP);
  458. switch (ed->type) {
  459. case PIPE_CONTROL:
  460. if (ed->ed_prev == NULL) {
  461. if (!ed->hwNextED) {
  462. ohci->hc_control &= ~OHCI_CTRL_CLE;
  463. writel (ohci->hc_control, &ohci->regs->control);
  464. }
  465. writel (m32_swap (*((__u32 *)&ed->hwNextED)), &ohci->regs->ed_controlhead);
  466. } else {
  467. ed->ed_prev->hwNextED = ed->hwNextED;
  468. }
  469. if (ohci->ed_controltail == ed) {
  470. ohci->ed_controltail = ed->ed_prev;
  471. } else {
  472. ((ed_t *)m32_swap (*((__u32 *)&ed->hwNextED)))->ed_prev = ed->ed_prev;
  473. }
  474. break;
  475. case PIPE_BULK:
  476. if (ed->ed_prev == NULL) {
  477. if (!ed->hwNextED) {
  478. ohci->hc_control &= ~OHCI_CTRL_BLE;
  479. writel (ohci->hc_control, &ohci->regs->control);
  480. }
  481. writel (m32_swap (*((__u32 *)&ed->hwNextED)), &ohci->regs->ed_bulkhead);
  482. } else {
  483. ed->ed_prev->hwNextED = ed->hwNextED;
  484. }
  485. if (ohci->ed_bulktail == ed) {
  486. ohci->ed_bulktail = ed->ed_prev;
  487. } else {
  488. ((ed_t *)m32_swap (*((__u32 *)&ed->hwNextED)))->ed_prev = ed->ed_prev;
  489. }
  490. break;
  491. }
  492. ed->state = ED_UNLINK;
  493. return 0;
  494. }
  495. /*-------------------------------------------------------------------------*/
  496. /* add/reinit an endpoint; this should be done once at the usb_set_configuration command,
  497. * but the USB stack is a little bit stateless so we do it at every transaction
  498. * if the state of the ed is ED_NEW then a dummy td is added and the state is changed to ED_UNLINK
  499. * in all other cases the state is left unchanged
  500. * the ed info fields are setted anyway even though most of them should not change */
  501. static ed_t * ep_add_ed (struct usb_device *usb_dev, unsigned long pipe)
  502. {
  503. td_t *td;
  504. ed_t *ed_ret;
  505. volatile ed_t *ed;
  506. ed = ed_ret = &ohci_dev.ed[(usb_pipeendpoint (pipe) << 1) |
  507. (usb_pipecontrol (pipe)? 0: usb_pipeout (pipe))];
  508. if ((ed->state & ED_DEL) || (ed->state & ED_URB_DEL)) {
  509. err("ep_add_ed: pending delete");
  510. /* pending delete request */
  511. return NULL;
  512. }
  513. if (ed->state == ED_NEW) {
  514. ed->hwINFO = m32_swap (OHCI_ED_SKIP); /* skip ed */
  515. /* dummy td; end of td list for ed */
  516. td = td_alloc (usb_dev);
  517. ed->hwTailP = m32_swap (td);
  518. ed->hwHeadP = ed->hwTailP;
  519. ed->state = ED_UNLINK;
  520. ed->type = usb_pipetype (pipe);
  521. ohci_dev.ed_cnt++;
  522. }
  523. ed->hwINFO = m32_swap (usb_pipedevice (pipe)
  524. | usb_pipeendpoint (pipe) << 7
  525. | (usb_pipeisoc (pipe)? 0x8000: 0)
  526. | (usb_pipecontrol (pipe)? 0: (usb_pipeout (pipe)? 0x800: 0x1000))
  527. | usb_pipeslow (pipe) << 13
  528. | usb_maxpacket (usb_dev, pipe) << 16);
  529. return ed_ret;
  530. }
  531. /*-------------------------------------------------------------------------*
  532. * TD handling functions
  533. *-------------------------------------------------------------------------*/
  534. /* enqueue next TD for this URB (OHCI spec 5.2.8.2) */
  535. static void td_fill (ohci_t *ohci, unsigned int info,
  536. void *data, int len,
  537. struct usb_device *dev, int index, urb_priv_t *urb_priv)
  538. {
  539. volatile td_t *td, *td_pt;
  540. #ifdef OHCI_FILL_TRACE
  541. int i;
  542. #endif
  543. if (index > urb_priv->length) {
  544. err("index > length");
  545. return;
  546. }
  547. /* use this td as the next dummy */
  548. td_pt = urb_priv->td [index];
  549. td_pt->hwNextTD = 0;
  550. /* fill the old dummy TD */
  551. td = urb_priv->td [index] = (td_t *)(m32_swap (urb_priv->ed->hwTailP) & ~0xf);
  552. td->ed = urb_priv->ed;
  553. td->next_dl_td = NULL;
  554. td->index = index;
  555. td->data = (__u32)data;
  556. #ifdef OHCI_FILL_TRACE
  557. if (1 || (usb_pipebulk(urb_priv->pipe) &&
  558. usb_pipeout(urb_priv->pipe))) {
  559. for (i = 0; i < len; i++)
  560. printf("td->data[%d] %#2x\n",i, ((unsigned char *)(td->data+0x80000000))[i]);
  561. }
  562. #endif
  563. if (!len)
  564. data = 0;
  565. td->hwINFO = m32_swap (info);
  566. td->hwCBP = m32_swap (data);
  567. if (data)
  568. td->hwBE = m32_swap (data + len - 1);
  569. else
  570. td->hwBE = 0;
  571. td->hwNextTD = m32_swap (td_pt);
  572. td->hwPSW [0] = m16_swap (((__u32)data & 0x0FFF) | 0xE000);
  573. /* append to queue */
  574. td->ed->hwTailP = td->hwNextTD;
  575. }
  576. /*-------------------------------------------------------------------------*/
  577. /* prepare all TDs of a transfer */
  578. #define kseg_to_phys(x) ((void *)((__u32)(x) - 0x80000000))
  579. static void td_submit_job (struct usb_device *dev, unsigned long pipe, void *buffer,
  580. int transfer_len, struct devrequest *setup, urb_priv_t *urb, int interval)
  581. {
  582. ohci_t *ohci = &gohci;
  583. int data_len = transfer_len;
  584. void *data;
  585. int cnt = 0;
  586. __u32 info = 0;
  587. unsigned int toggle = 0;
  588. /* OHCI handles the DATA-toggles itself, we just use the USB-toggle bits for reseting */
  589. if(usb_gettoggle(dev, usb_pipeendpoint(pipe), usb_pipeout(pipe))) {
  590. toggle = TD_T_TOGGLE;
  591. } else {
  592. toggle = TD_T_DATA0;
  593. usb_settoggle(dev, usb_pipeendpoint(pipe), usb_pipeout(pipe), 1);
  594. }
  595. urb->td_cnt = 0;
  596. if (data_len)
  597. data = kseg_to_phys(buffer);
  598. else
  599. data = 0;
  600. switch (usb_pipetype (pipe)) {
  601. case PIPE_BULK:
  602. info = usb_pipeout (pipe)?
  603. TD_CC | TD_DP_OUT : TD_CC | TD_DP_IN ;
  604. while(data_len > 4096) {
  605. td_fill (ohci, info | (cnt? TD_T_TOGGLE:toggle), data, 4096, dev, cnt, urb);
  606. data += 4096; data_len -= 4096; cnt++;
  607. }
  608. info = usb_pipeout (pipe)?
  609. TD_CC | TD_DP_OUT : TD_CC | TD_R | TD_DP_IN ;
  610. td_fill (ohci, info | (cnt? TD_T_TOGGLE:toggle), data, data_len, dev, cnt, urb);
  611. cnt++;
  612. if (!ohci->sleeping)
  613. writel (OHCI_BLF, &ohci->regs->cmdstatus); /* start bulk list */
  614. break;
  615. case PIPE_CONTROL:
  616. info = TD_CC | TD_DP_SETUP | TD_T_DATA0;
  617. td_fill (ohci, info, kseg_to_phys(setup), 8, dev, cnt++, urb);
  618. if (data_len > 0) {
  619. info = usb_pipeout (pipe)?
  620. TD_CC | TD_R | TD_DP_OUT | TD_T_DATA1 : TD_CC | TD_R | TD_DP_IN | TD_T_DATA1;
  621. /* NOTE: mishandles transfers >8K, some >4K */
  622. td_fill (ohci, info, data, data_len, dev, cnt++, urb);
  623. }
  624. info = usb_pipeout (pipe)?
  625. TD_CC | TD_DP_IN | TD_T_DATA1: TD_CC | TD_DP_OUT | TD_T_DATA1;
  626. td_fill (ohci, info, data, 0, dev, cnt++, urb);
  627. if (!ohci->sleeping)
  628. writel (OHCI_CLF, &ohci->regs->cmdstatus); /* start Control list */
  629. break;
  630. }
  631. if (urb->length != cnt)
  632. dbg("TD LENGTH %d != CNT %d", urb->length, cnt);
  633. }
  634. /*-------------------------------------------------------------------------*
  635. * Done List handling functions
  636. *-------------------------------------------------------------------------*/
  637. /* calculate the transfer length and update the urb */
  638. static void dl_transfer_length(td_t * td)
  639. {
  640. __u32 tdINFO, tdBE, tdCBP;
  641. urb_priv_t *lurb_priv = &urb_priv;
  642. tdINFO = m32_swap (td->hwINFO);
  643. tdBE = m32_swap (td->hwBE);
  644. tdCBP = m32_swap (td->hwCBP);
  645. if (!(usb_pipecontrol(lurb_priv->pipe) &&
  646. ((td->index == 0) || (td->index == lurb_priv->length - 1)))) {
  647. if (tdBE != 0) {
  648. if (td->hwCBP == 0)
  649. lurb_priv->actual_length += tdBE - td->data + 1;
  650. else
  651. lurb_priv->actual_length += tdCBP - td->data;
  652. }
  653. }
  654. }
  655. /*-------------------------------------------------------------------------*/
  656. /* replies to the request have to be on a FIFO basis so
  657. * we reverse the reversed done-list */
  658. static td_t * dl_reverse_done_list (ohci_t *ohci)
  659. {
  660. __u32 td_list_hc;
  661. td_t *td_rev = NULL;
  662. td_t *td_list = NULL;
  663. urb_priv_t *lurb_priv = NULL;
  664. td_list_hc = m32_swap (ohci->hcca->done_head) & 0xfffffff0;
  665. ohci->hcca->done_head = 0;
  666. while (td_list_hc) {
  667. td_list = (td_t *)td_list_hc;
  668. if (TD_CC_GET (m32_swap (td_list->hwINFO))) {
  669. lurb_priv = &urb_priv;
  670. dbg(" USB-error/status: %x : %p",
  671. TD_CC_GET (m32_swap (td_list->hwINFO)), td_list);
  672. if (td_list->ed->hwHeadP & m32_swap (0x1)) {
  673. if (lurb_priv && ((td_list->index + 1) < lurb_priv->length)) {
  674. td_list->ed->hwHeadP =
  675. (lurb_priv->td[lurb_priv->length - 1]->hwNextTD & m32_swap (0xfffffff0)) |
  676. (td_list->ed->hwHeadP & m32_swap (0x2));
  677. lurb_priv->td_cnt += lurb_priv->length - td_list->index - 1;
  678. } else
  679. td_list->ed->hwHeadP &= m32_swap (0xfffffff2);
  680. }
  681. }
  682. td_list->next_dl_td = td_rev;
  683. td_rev = td_list;
  684. td_list_hc = m32_swap (td_list->hwNextTD) & 0xfffffff0;
  685. }
  686. return td_list;
  687. }
  688. /*-------------------------------------------------------------------------*/
  689. /* td done list */
  690. static int dl_done_list (ohci_t *ohci, td_t *td_list)
  691. {
  692. td_t *td_list_next = NULL;
  693. ed_t *ed;
  694. int cc = 0;
  695. int stat = 0;
  696. /* urb_t *urb; */
  697. urb_priv_t *lurb_priv;
  698. __u32 tdINFO, edHeadP, edTailP;
  699. while (td_list) {
  700. td_list_next = td_list->next_dl_td;
  701. lurb_priv = &urb_priv;
  702. tdINFO = m32_swap (td_list->hwINFO);
  703. ed = td_list->ed;
  704. dl_transfer_length(td_list);
  705. /* error code of transfer */
  706. cc = TD_CC_GET (tdINFO);
  707. if (cc != 0) {
  708. dbg("ConditionCode %#x", cc);
  709. stat = cc_to_error[cc];
  710. }
  711. if (ed->state != ED_NEW) {
  712. edHeadP = m32_swap (ed->hwHeadP) & 0xfffffff0;
  713. edTailP = m32_swap (ed->hwTailP);
  714. /* unlink eds if they are not busy */
  715. if ((edHeadP == edTailP) && (ed->state == ED_OPER))
  716. ep_unlink (ohci, ed);
  717. }
  718. td_list = td_list_next;
  719. }
  720. return stat;
  721. }
  722. /*-------------------------------------------------------------------------*
  723. * Virtual Root Hub
  724. *-------------------------------------------------------------------------*/
  725. /* Device descriptor */
  726. static __u8 root_hub_dev_des[] =
  727. {
  728. 0x12, /* __u8 bLength; */
  729. 0x01, /* __u8 bDescriptorType; Device */
  730. 0x10, /* __u16 bcdUSB; v1.1 */
  731. 0x01,
  732. 0x09, /* __u8 bDeviceClass; HUB_CLASSCODE */
  733. 0x00, /* __u8 bDeviceSubClass; */
  734. 0x00, /* __u8 bDeviceProtocol; */
  735. 0x08, /* __u8 bMaxPacketSize0; 8 Bytes */
  736. 0x00, /* __u16 idVendor; */
  737. 0x00,
  738. 0x00, /* __u16 idProduct; */
  739. 0x00,
  740. 0x00, /* __u16 bcdDevice; */
  741. 0x00,
  742. 0x00, /* __u8 iManufacturer; */
  743. 0x01, /* __u8 iProduct; */
  744. 0x00, /* __u8 iSerialNumber; */
  745. 0x01 /* __u8 bNumConfigurations; */
  746. };
  747. /* Configuration descriptor */
  748. static __u8 root_hub_config_des[] =
  749. {
  750. 0x09, /* __u8 bLength; */
  751. 0x02, /* __u8 bDescriptorType; Configuration */
  752. 0x19, /* __u16 wTotalLength; */
  753. 0x00,
  754. 0x01, /* __u8 bNumInterfaces; */
  755. 0x01, /* __u8 bConfigurationValue; */
  756. 0x00, /* __u8 iConfiguration; */
  757. 0x40, /* __u8 bmAttributes;
  758. Bit 7: Bus-powered, 6: Self-powered, 5 Remote-wakwup, 4..0: resvd */
  759. 0x00, /* __u8 MaxPower; */
  760. /* interface */
  761. 0x09, /* __u8 if_bLength; */
  762. 0x04, /* __u8 if_bDescriptorType; Interface */
  763. 0x00, /* __u8 if_bInterfaceNumber; */
  764. 0x00, /* __u8 if_bAlternateSetting; */
  765. 0x01, /* __u8 if_bNumEndpoints; */
  766. 0x09, /* __u8 if_bInterfaceClass; HUB_CLASSCODE */
  767. 0x00, /* __u8 if_bInterfaceSubClass; */
  768. 0x00, /* __u8 if_bInterfaceProtocol; */
  769. 0x00, /* __u8 if_iInterface; */
  770. /* endpoint */
  771. 0x07, /* __u8 ep_bLength; */
  772. 0x05, /* __u8 ep_bDescriptorType; Endpoint */
  773. 0x81, /* __u8 ep_bEndpointAddress; IN Endpoint 1 */
  774. 0x03, /* __u8 ep_bmAttributes; Interrupt */
  775. 0x02, /* __u16 ep_wMaxPacketSize; ((MAX_ROOT_PORTS + 1) / 8 */
  776. 0x00,
  777. 0xff /* __u8 ep_bInterval; 255 ms */
  778. };
  779. static unsigned char root_hub_str_index0[] =
  780. {
  781. 0x04, /* __u8 bLength; */
  782. 0x03, /* __u8 bDescriptorType; String-descriptor */
  783. 0x09, /* __u8 lang ID */
  784. 0x04, /* __u8 lang ID */
  785. };
  786. static unsigned char root_hub_str_index1[] =
  787. {
  788. 28, /* __u8 bLength; */
  789. 0x03, /* __u8 bDescriptorType; String-descriptor */
  790. 'O', /* __u8 Unicode */
  791. 0, /* __u8 Unicode */
  792. 'H', /* __u8 Unicode */
  793. 0, /* __u8 Unicode */
  794. 'C', /* __u8 Unicode */
  795. 0, /* __u8 Unicode */
  796. 'I', /* __u8 Unicode */
  797. 0, /* __u8 Unicode */
  798. ' ', /* __u8 Unicode */
  799. 0, /* __u8 Unicode */
  800. 'R', /* __u8 Unicode */
  801. 0, /* __u8 Unicode */
  802. 'o', /* __u8 Unicode */
  803. 0, /* __u8 Unicode */
  804. 'o', /* __u8 Unicode */
  805. 0, /* __u8 Unicode */
  806. 't', /* __u8 Unicode */
  807. 0, /* __u8 Unicode */
  808. ' ', /* __u8 Unicode */
  809. 0, /* __u8 Unicode */
  810. 'H', /* __u8 Unicode */
  811. 0, /* __u8 Unicode */
  812. 'u', /* __u8 Unicode */
  813. 0, /* __u8 Unicode */
  814. 'b', /* __u8 Unicode */
  815. 0, /* __u8 Unicode */
  816. };
  817. /* Hub class-specific descriptor is constructed dynamically */
  818. /*-------------------------------------------------------------------------*/
  819. #define OK(x) len = (x); break
  820. #ifdef DEBUG
  821. #define WR_RH_STAT(x) {info("WR:status %#8x", (x));writel((x), &gohci.regs->roothub.status);}
  822. #define WR_RH_PORTSTAT(x) {info("WR:portstatus[%d] %#8x", wIndex-1, (x));writel((x), &gohci.regs->roothub.portstatus[wIndex-1]);}
  823. #else
  824. #define WR_RH_STAT(x) writel((x), &gohci.regs->roothub.status)
  825. #define WR_RH_PORTSTAT(x) writel((x), &gohci.regs->roothub.portstatus[wIndex-1])
  826. #endif
  827. #define RD_RH_STAT roothub_status(&gohci)
  828. #define RD_RH_PORTSTAT roothub_portstatus(&gohci,wIndex-1)
  829. /* request to virtual root hub */
  830. int rh_check_port_status(ohci_t *controller)
  831. {
  832. __u32 temp, ndp, i;
  833. int res;
  834. res = -1;
  835. temp = roothub_a (controller);
  836. ndp = (temp & RH_A_NDP);
  837. for (i = 0; i < ndp; i++) {
  838. temp = roothub_portstatus (controller, i);
  839. /* check for a device disconnect */
  840. if (((temp & (RH_PS_PESC | RH_PS_CSC)) ==
  841. (RH_PS_PESC | RH_PS_CSC)) &&
  842. ((temp & RH_PS_CCS) == 0)) {
  843. res = i;
  844. break;
  845. }
  846. }
  847. return res;
  848. }
  849. static int ohci_submit_rh_msg(struct usb_device *dev, unsigned long pipe,
  850. void *buffer, int transfer_len, struct devrequest *cmd)
  851. {
  852. void * data = buffer;
  853. int leni = transfer_len;
  854. int len = 0;
  855. int stat = 0;
  856. __u32 datab[4];
  857. __u8 *data_buf = (__u8 *)datab;
  858. __u16 bmRType_bReq;
  859. __u16 wValue;
  860. __u16 wIndex;
  861. __u16 wLength;
  862. #ifdef DEBUG
  863. urb_priv.actual_length = 0;
  864. pkt_print(dev, pipe, buffer, transfer_len, cmd, "SUB(rh)", usb_pipein(pipe));
  865. #else
  866. wait_ms(1);
  867. #endif
  868. if (usb_pipeint(pipe)) {
  869. info("Root-Hub submit IRQ: NOT implemented");
  870. return 0;
  871. }
  872. bmRType_bReq = cmd->requesttype | (cmd->request << 8);
  873. wValue = m16_swap (cmd->value);
  874. wIndex = m16_swap (cmd->index);
  875. wLength = m16_swap (cmd->length);
  876. info("Root-Hub: adr: %2x cmd(%1x): %08x %04x %04x %04x",
  877. dev->devnum, 8, bmRType_bReq, wValue, wIndex, wLength);
  878. switch (bmRType_bReq) {
  879. /* Request Destination:
  880. without flags: Device,
  881. RH_INTERFACE: interface,
  882. RH_ENDPOINT: endpoint,
  883. RH_CLASS means HUB here,
  884. RH_OTHER | RH_CLASS almost ever means HUB_PORT here
  885. */
  886. case RH_GET_STATUS:
  887. *(__u16 *) data_buf = m16_swap (1); OK (2);
  888. case RH_GET_STATUS | RH_INTERFACE:
  889. *(__u16 *) data_buf = m16_swap (0); OK (2);
  890. case RH_GET_STATUS | RH_ENDPOINT:
  891. *(__u16 *) data_buf = m16_swap (0); OK (2);
  892. case RH_GET_STATUS | RH_CLASS:
  893. *(__u32 *) data_buf = m32_swap (
  894. RD_RH_STAT & ~(RH_HS_CRWE | RH_HS_DRWE));
  895. OK (4);
  896. case RH_GET_STATUS | RH_OTHER | RH_CLASS:
  897. *(__u32 *) data_buf = m32_swap (RD_RH_PORTSTAT); OK (4);
  898. case RH_CLEAR_FEATURE | RH_ENDPOINT:
  899. switch (wValue) {
  900. case (RH_ENDPOINT_STALL): OK (0);
  901. }
  902. break;
  903. case RH_CLEAR_FEATURE | RH_CLASS:
  904. switch (wValue) {
  905. case RH_C_HUB_LOCAL_POWER:
  906. OK(0);
  907. case (RH_C_HUB_OVER_CURRENT):
  908. WR_RH_STAT(RH_HS_OCIC); OK (0);
  909. }
  910. break;
  911. case RH_CLEAR_FEATURE | RH_OTHER | RH_CLASS:
  912. switch (wValue) {
  913. case (RH_PORT_ENABLE):
  914. WR_RH_PORTSTAT (RH_PS_CCS ); OK (0);
  915. case (RH_PORT_SUSPEND):
  916. WR_RH_PORTSTAT (RH_PS_POCI); OK (0);
  917. case (RH_PORT_POWER):
  918. WR_RH_PORTSTAT (RH_PS_LSDA); OK (0);
  919. case (RH_C_PORT_CONNECTION):
  920. WR_RH_PORTSTAT (RH_PS_CSC ); OK (0);
  921. case (RH_C_PORT_ENABLE):
  922. WR_RH_PORTSTAT (RH_PS_PESC); OK (0);
  923. case (RH_C_PORT_SUSPEND):
  924. WR_RH_PORTSTAT (RH_PS_PSSC); OK (0);
  925. case (RH_C_PORT_OVER_CURRENT):
  926. WR_RH_PORTSTAT (RH_PS_OCIC); OK (0);
  927. case (RH_C_PORT_RESET):
  928. WR_RH_PORTSTAT (RH_PS_PRSC); OK (0);
  929. }
  930. break;
  931. case RH_SET_FEATURE | RH_OTHER | RH_CLASS:
  932. switch (wValue) {
  933. case (RH_PORT_SUSPEND):
  934. WR_RH_PORTSTAT (RH_PS_PSS ); OK (0);
  935. case (RH_PORT_RESET): /* BUG IN HUP CODE *********/
  936. if (RD_RH_PORTSTAT & RH_PS_CCS)
  937. WR_RH_PORTSTAT (RH_PS_PRS);
  938. OK (0);
  939. case (RH_PORT_POWER):
  940. WR_RH_PORTSTAT (RH_PS_PPS ); OK (0);
  941. case (RH_PORT_ENABLE): /* BUG IN HUP CODE *********/
  942. if (RD_RH_PORTSTAT & RH_PS_CCS)
  943. WR_RH_PORTSTAT (RH_PS_PES );
  944. OK (0);
  945. }
  946. break;
  947. case RH_SET_ADDRESS: gohci.rh.devnum = wValue; OK(0);
  948. case RH_GET_DESCRIPTOR:
  949. switch ((wValue & 0xff00) >> 8) {
  950. case (0x01): /* device descriptor */
  951. len = min_t(unsigned int,
  952. leni,
  953. min_t(unsigned int,
  954. sizeof (root_hub_dev_des),
  955. wLength));
  956. data_buf = root_hub_dev_des; OK(len);
  957. case (0x02): /* configuration descriptor */
  958. len = min_t(unsigned int,
  959. leni,
  960. min_t(unsigned int,
  961. sizeof (root_hub_config_des),
  962. wLength));
  963. data_buf = root_hub_config_des; OK(len);
  964. case (0x03): /* string descriptors */
  965. if(wValue==0x0300) {
  966. len = min_t(unsigned int,
  967. leni,
  968. min_t(unsigned int,
  969. sizeof (root_hub_str_index0),
  970. wLength));
  971. data_buf = root_hub_str_index0;
  972. OK(len);
  973. }
  974. if(wValue==0x0301) {
  975. len = min_t(unsigned int,
  976. leni,
  977. min_t(unsigned int,
  978. sizeof (root_hub_str_index1),
  979. wLength));
  980. data_buf = root_hub_str_index1;
  981. OK(len);
  982. }
  983. default:
  984. stat = USB_ST_STALLED;
  985. }
  986. break;
  987. case RH_GET_DESCRIPTOR | RH_CLASS:
  988. {
  989. __u32 temp = roothub_a (&gohci);
  990. data_buf [0] = 9; /* min length; */
  991. data_buf [1] = 0x29;
  992. data_buf [2] = temp & RH_A_NDP;
  993. data_buf [3] = 0;
  994. if (temp & RH_A_PSM) /* per-port power switching? */
  995. data_buf [3] |= 0x1;
  996. if (temp & RH_A_NOCP) /* no overcurrent reporting? */
  997. data_buf [3] |= 0x10;
  998. else if (temp & RH_A_OCPM) /* per-port overcurrent reporting? */
  999. data_buf [3] |= 0x8;
  1000. /* corresponds to data_buf[4-7] */
  1001. datab [1] = 0;
  1002. data_buf [5] = (temp & RH_A_POTPGT) >> 24;
  1003. temp = roothub_b (&gohci);
  1004. data_buf [7] = temp & RH_B_DR;
  1005. if (data_buf [2] < 7) {
  1006. data_buf [8] = 0xff;
  1007. } else {
  1008. data_buf [0] += 2;
  1009. data_buf [8] = (temp & RH_B_DR) >> 8;
  1010. data_buf [10] = data_buf [9] = 0xff;
  1011. }
  1012. len = min_t(unsigned int, leni,
  1013. min_t(unsigned int, data_buf [0], wLength));
  1014. OK (len);
  1015. }
  1016. case RH_GET_CONFIGURATION: *(__u8 *) data_buf = 0x01; OK (1);
  1017. case RH_SET_CONFIGURATION: WR_RH_STAT (0x10000); OK (0);
  1018. default:
  1019. dbg ("unsupported root hub command");
  1020. stat = USB_ST_STALLED;
  1021. }
  1022. #ifdef DEBUG
  1023. ohci_dump_roothub (&gohci, 1);
  1024. #else
  1025. wait_ms(1);
  1026. #endif
  1027. len = min_t(int, len, leni);
  1028. if (data != data_buf)
  1029. memcpy (data, data_buf, len);
  1030. dev->act_len = len;
  1031. dev->status = stat;
  1032. #ifdef DEBUG
  1033. if (transfer_len)
  1034. urb_priv.actual_length = transfer_len;
  1035. pkt_print(dev, pipe, buffer, transfer_len, cmd, "RET(rh)", 0/*usb_pipein(pipe)*/);
  1036. #else
  1037. wait_ms(1);
  1038. #endif
  1039. return stat;
  1040. }
  1041. /*-------------------------------------------------------------------------*/
  1042. /* common code for handling submit messages - used for all but root hub */
  1043. /* accesses. */
  1044. int submit_common_msg(struct usb_device *dev, unsigned long pipe, void *buffer,
  1045. int transfer_len, struct devrequest *setup, int interval)
  1046. {
  1047. int stat = 0;
  1048. int maxsize = usb_maxpacket(dev, pipe);
  1049. int timeout;
  1050. /* device pulled? Shortcut the action. */
  1051. if (devgone == dev) {
  1052. dev->status = USB_ST_CRC_ERR;
  1053. return 0;
  1054. }
  1055. #ifdef DEBUG
  1056. urb_priv.actual_length = 0;
  1057. pkt_print(dev, pipe, buffer, transfer_len, setup, "SUB", usb_pipein(pipe));
  1058. #else
  1059. wait_ms(1);
  1060. #endif
  1061. if (!maxsize) {
  1062. err("submit_common_message: pipesize for pipe %lx is zero",
  1063. pipe);
  1064. return -1;
  1065. }
  1066. if (sohci_submit_job(dev, pipe, buffer, transfer_len, setup, interval) < 0) {
  1067. err("sohci_submit_job failed");
  1068. return -1;
  1069. }
  1070. wait_ms(10);
  1071. /* ohci_dump_status(&gohci); */
  1072. /* allow more time for a BULK device to react - some are slow */
  1073. #define BULK_TO 5000 /* timeout in milliseconds */
  1074. if (usb_pipebulk(pipe))
  1075. timeout = BULK_TO;
  1076. else
  1077. timeout = 100;
  1078. timeout *= 4;
  1079. /* wait for it to complete */
  1080. for (;;) {
  1081. /* check whether the controller is done */
  1082. stat = hc_interrupt();
  1083. if (stat < 0) {
  1084. stat = USB_ST_CRC_ERR;
  1085. break;
  1086. }
  1087. if (stat >= 0 && stat != 0xff) {
  1088. /* 0xff is returned for an SF-interrupt */
  1089. break;
  1090. }
  1091. if (--timeout) {
  1092. udelay(250); /* wait_ms(1); */
  1093. } else {
  1094. err("CTL:TIMEOUT ");
  1095. stat = USB_ST_CRC_ERR;
  1096. break;
  1097. }
  1098. }
  1099. /* we got an Root Hub Status Change interrupt */
  1100. if (got_rhsc) {
  1101. #ifdef DEBUG
  1102. ohci_dump_roothub (&gohci, 1);
  1103. #endif
  1104. got_rhsc = 0;
  1105. /* abuse timeout */
  1106. timeout = rh_check_port_status(&gohci);
  1107. if (timeout >= 0) {
  1108. #if 0 /* this does nothing useful, but leave it here in case that changes */
  1109. /* the called routine adds 1 to the passed value */
  1110. usb_hub_port_connect_change(gohci.rh.dev, timeout - 1);
  1111. #endif
  1112. /*
  1113. * XXX
  1114. * This is potentially dangerous because it assumes
  1115. * that only one device is ever plugged in!
  1116. */
  1117. devgone = dev;
  1118. }
  1119. }
  1120. dev->status = stat;
  1121. dev->act_len = transfer_len;
  1122. #ifdef DEBUG
  1123. pkt_print(dev, pipe, buffer, transfer_len, setup, "RET(ctlr)", usb_pipein(pipe));
  1124. #else
  1125. wait_ms(1);
  1126. #endif
  1127. /* free TDs in urb_priv */
  1128. urb_free_priv (&urb_priv);
  1129. return 0;
  1130. }
  1131. /* submit routines called from usb.c */
  1132. int submit_bulk_msg(struct usb_device *dev, unsigned long pipe, void *buffer,
  1133. int transfer_len)
  1134. {
  1135. info("submit_bulk_msg");
  1136. return submit_common_msg(dev, pipe, buffer, transfer_len, NULL, 0);
  1137. }
  1138. int submit_control_msg(struct usb_device *dev, unsigned long pipe, void *buffer,
  1139. int transfer_len, struct devrequest *setup)
  1140. {
  1141. int maxsize = usb_maxpacket(dev, pipe);
  1142. info("submit_control_msg");
  1143. #ifdef DEBUG
  1144. urb_priv.actual_length = 0;
  1145. pkt_print(dev, pipe, buffer, transfer_len, setup, "SUB", usb_pipein(pipe));
  1146. #else
  1147. wait_ms(1);
  1148. #endif
  1149. if (!maxsize) {
  1150. err("submit_control_message: pipesize for pipe %lx is zero",
  1151. pipe);
  1152. return -1;
  1153. }
  1154. if (((pipe >> 8) & 0x7f) == gohci.rh.devnum) {
  1155. gohci.rh.dev = dev;
  1156. /* root hub - redirect */
  1157. return ohci_submit_rh_msg(dev, pipe, buffer, transfer_len,
  1158. setup);
  1159. }
  1160. return submit_common_msg(dev, pipe, buffer, transfer_len, setup, 0);
  1161. }
  1162. int submit_int_msg(struct usb_device *dev, unsigned long pipe, void *buffer,
  1163. int transfer_len, int interval)
  1164. {
  1165. info("submit_int_msg");
  1166. return -1;
  1167. }
  1168. /*-------------------------------------------------------------------------*
  1169. * HC functions
  1170. *-------------------------------------------------------------------------*/
  1171. /* reset the HC and BUS */
  1172. static int hc_reset (ohci_t *ohci)
  1173. {
  1174. int timeout = 30;
  1175. int smm_timeout = 50; /* 0,5 sec */
  1176. if (readl (&ohci->regs->control) & OHCI_CTRL_IR) { /* SMM owns the HC */
  1177. writel (OHCI_OCR, &ohci->regs->cmdstatus); /* request ownership */
  1178. info("USB HC TakeOver from SMM");
  1179. while (readl (&ohci->regs->control) & OHCI_CTRL_IR) {
  1180. wait_ms (10);
  1181. if (--smm_timeout == 0) {
  1182. err("USB HC TakeOver failed!");
  1183. return -1;
  1184. }
  1185. }
  1186. }
  1187. /* Disable HC interrupts */
  1188. writel (OHCI_INTR_MIE, &ohci->regs->intrdisable);
  1189. dbg("USB HC reset_hc usb-%s: ctrl = 0x%X ;",
  1190. ohci->slot_name,
  1191. readl (&ohci->regs->control));
  1192. /* Reset USB (needed by some controllers) */
  1193. writel (0, &ohci->regs->control);
  1194. /* HC Reset requires max 10 us delay */
  1195. writel (OHCI_HCR, &ohci->regs->cmdstatus);
  1196. while ((readl (&ohci->regs->cmdstatus) & OHCI_HCR) != 0) {
  1197. if (--timeout == 0) {
  1198. err("USB HC reset timed out!");
  1199. return -1;
  1200. }
  1201. udelay (1);
  1202. }
  1203. return 0;
  1204. }
  1205. /*-------------------------------------------------------------------------*/
  1206. /* Start an OHCI controller, set the BUS operational
  1207. * enable interrupts
  1208. * connect the virtual root hub */
  1209. static int hc_start (ohci_t * ohci)
  1210. {
  1211. __u32 mask;
  1212. unsigned int fminterval;
  1213. ohci->disabled = 1;
  1214. /* Tell the controller where the control and bulk lists are
  1215. * The lists are empty now. */
  1216. writel (0, &ohci->regs->ed_controlhead);
  1217. writel (0, &ohci->regs->ed_bulkhead);
  1218. writel ((__u32)ohci->hcca, &ohci->regs->hcca); /* a reset clears this */
  1219. fminterval = 0x2edf;
  1220. writel ((fminterval * 9) / 10, &ohci->regs->periodicstart);
  1221. fminterval |= ((((fminterval - 210) * 6) / 7) << 16);
  1222. writel (fminterval, &ohci->regs->fminterval);
  1223. writel (0x628, &ohci->regs->lsthresh);
  1224. /* start controller operations */
  1225. ohci->hc_control = OHCI_CONTROL_INIT | OHCI_USB_OPER;
  1226. ohci->disabled = 0;
  1227. writel (ohci->hc_control, &ohci->regs->control);
  1228. /* disable all interrupts */
  1229. mask = (OHCI_INTR_SO | OHCI_INTR_WDH | OHCI_INTR_SF | OHCI_INTR_RD |
  1230. OHCI_INTR_UE | OHCI_INTR_FNO | OHCI_INTR_RHSC |
  1231. OHCI_INTR_OC | OHCI_INTR_MIE);
  1232. writel (mask, &ohci->regs->intrdisable);
  1233. /* clear all interrupts */
  1234. mask &= ~OHCI_INTR_MIE;
  1235. writel (mask, &ohci->regs->intrstatus);
  1236. /* Choose the interrupts we care about now - but w/o MIE */
  1237. mask = OHCI_INTR_RHSC | OHCI_INTR_UE | OHCI_INTR_WDH | OHCI_INTR_SO;
  1238. writel (mask, &ohci->regs->intrenable);
  1239. #ifdef OHCI_USE_NPS
  1240. /* required for AMD-756 and some Mac platforms */
  1241. writel ((roothub_a (ohci) | RH_A_NPS) & ~RH_A_PSM,
  1242. &ohci->regs->roothub.a);
  1243. writel (RH_HS_LPSC, &ohci->regs->roothub.status);
  1244. #endif /* OHCI_USE_NPS */
  1245. #define mdelay(n) ({unsigned long msec=(n); while (msec--) udelay(1000);})
  1246. /* POTPGT delay is bits 24-31, in 2 ms units. */
  1247. mdelay ((roothub_a (ohci) >> 23) & 0x1fe);
  1248. /* connect the virtual root hub */
  1249. ohci->rh.devnum = 0;
  1250. return 0;
  1251. }
  1252. /*-------------------------------------------------------------------------*/
  1253. /* an interrupt happens */
  1254. static int
  1255. hc_interrupt (void)
  1256. {
  1257. ohci_t *ohci = &gohci;
  1258. struct ohci_regs *regs = ohci->regs;
  1259. int ints;
  1260. int stat = -1;
  1261. if ((ohci->hcca->done_head != 0) && !(m32_swap (ohci->hcca->done_head) & 0x01)) {
  1262. ints = OHCI_INTR_WDH;
  1263. } else {
  1264. ints = readl (&regs->intrstatus);
  1265. }
  1266. /* dbg("Interrupt: %x frame: %x", ints, le16_to_cpu (ohci->hcca->frame_no)); */
  1267. if (ints & OHCI_INTR_RHSC) {
  1268. got_rhsc = 1;
  1269. }
  1270. if (ints & OHCI_INTR_UE) {
  1271. ohci->disabled++;
  1272. err ("OHCI Unrecoverable Error, controller usb-%s disabled",
  1273. ohci->slot_name);
  1274. /* e.g. due to PCI Master/Target Abort */
  1275. #ifdef DEBUG
  1276. ohci_dump (ohci, 1);
  1277. #else
  1278. wait_ms(1);
  1279. #endif
  1280. /* FIXME: be optimistic, hope that bug won't repeat often. */
  1281. /* Make some non-interrupt context restart the controller. */
  1282. /* Count and limit the retries though; either hardware or */
  1283. /* software errors can go forever... */
  1284. hc_reset (ohci);
  1285. return -1;
  1286. }
  1287. if (ints & OHCI_INTR_WDH) {
  1288. wait_ms(1);
  1289. writel (OHCI_INTR_WDH, &regs->intrdisable);
  1290. stat = dl_done_list (&gohci, dl_reverse_done_list (&gohci));
  1291. writel (OHCI_INTR_WDH, &regs->intrenable);
  1292. }
  1293. if (ints & OHCI_INTR_SO) {
  1294. dbg("USB Schedule overrun\n");
  1295. writel (OHCI_INTR_SO, &regs->intrenable);
  1296. stat = -1;
  1297. }
  1298. /* FIXME: this assumes SOF (1/ms) interrupts don't get lost... */
  1299. if (ints & OHCI_INTR_SF) {
  1300. unsigned int frame = m16_swap (ohci->hcca->frame_no) & 1;
  1301. wait_ms(1);
  1302. writel (OHCI_INTR_SF, &regs->intrdisable);
  1303. if (ohci->ed_rm_list[frame] != NULL)
  1304. writel (OHCI_INTR_SF, &regs->intrenable);
  1305. stat = 0xff;
  1306. }
  1307. writel (ints, &regs->intrstatus);
  1308. return stat;
  1309. }
  1310. /*-------------------------------------------------------------------------*/
  1311. /*-------------------------------------------------------------------------*/
  1312. /* De-allocate all resources.. */
  1313. static void hc_release_ohci (ohci_t *ohci)
  1314. {
  1315. dbg ("USB HC release ohci usb-%s", ohci->slot_name);
  1316. if (!ohci->disabled)
  1317. hc_reset (ohci);
  1318. }
  1319. /*-------------------------------------------------------------------------*/
  1320. #define __read_32bit_c0_register(source, sel) \
  1321. ({ int __res; \
  1322. if (sel == 0) \
  1323. __asm__ __volatile__( \
  1324. "mfc0\t%0, " #source "\n\t" \
  1325. : "=r" (__res)); \
  1326. else \
  1327. __asm__ __volatile__( \
  1328. ".set\tmips32\n\t" \
  1329. "mfc0\t%0, " #source ", " #sel "\n\t" \
  1330. ".set\tmips0\n\t" \
  1331. : "=r" (__res)); \
  1332. __res; \
  1333. })
  1334. #define read_c0_prid() __read_32bit_c0_register($15, 0)
  1335. /*
  1336. * low level initalisation routine, called from usb.c
  1337. */
  1338. static char ohci_inited = 0;
  1339. int usb_lowlevel_init(void)
  1340. {
  1341. u32 pin_func;
  1342. u32 sys_freqctrl, sys_clksrc;
  1343. u32 prid = read_c0_prid();
  1344. dbg("in usb_lowlevel_init\n");
  1345. /* zero and disable FREQ2 */
  1346. sys_freqctrl = au_readl(SYS_FREQCTRL0);
  1347. sys_freqctrl &= ~0xFFF00000;
  1348. au_writel(sys_freqctrl, SYS_FREQCTRL0);
  1349. /* zero and disable USBH/USBD clocks */
  1350. sys_clksrc = au_readl(SYS_CLKSRC);
  1351. sys_clksrc &= ~0x00007FE0;
  1352. au_writel(sys_clksrc, SYS_CLKSRC);
  1353. sys_freqctrl = au_readl(SYS_FREQCTRL0);
  1354. sys_freqctrl &= ~0xFFF00000;
  1355. sys_clksrc = au_readl(SYS_CLKSRC);
  1356. sys_clksrc &= ~0x00007FE0;
  1357. switch (prid & 0x000000FF) {
  1358. case 0x00: /* DA */
  1359. case 0x01: /* HA */
  1360. case 0x02: /* HB */
  1361. /* CPU core freq to 48MHz to slow it way down... */
  1362. au_writel(4, SYS_CPUPLL);
  1363. /*
  1364. * Setup 48MHz FREQ2 from CPUPLL for USB Host
  1365. */
  1366. /* FRDIV2=3 -> div by 8 of 384MHz -> 48MHz */
  1367. sys_freqctrl |= ((3<<22) | (1<<21) | (0<<20));
  1368. au_writel(sys_freqctrl, SYS_FREQCTRL0);
  1369. /* CPU core freq to 384MHz */
  1370. au_writel(0x20, SYS_CPUPLL);
  1371. printf("Au1000: 48MHz OHCI workaround enabled\n");
  1372. break;
  1373. default: /* HC and newer */
  1374. /* FREQ2 = aux/2 = 48 MHz */
  1375. sys_freqctrl |= ((0<<22) | (1<<21) | (1<<20));
  1376. au_writel(sys_freqctrl, SYS_FREQCTRL0);
  1377. break;
  1378. }
  1379. /*
  1380. * Route 48MHz FREQ2 into USB Host and/or Device
  1381. */
  1382. sys_clksrc |= ((4<<12) | (0<<11) | (0<<10));
  1383. au_writel(sys_clksrc, SYS_CLKSRC);
  1384. /* configure pins GPIO[14:9] as GPIO */
  1385. pin_func = au_readl(SYS_PINFUNC) & (u32)(~0x8080);
  1386. au_writel(pin_func, SYS_PINFUNC);
  1387. au_writel(0x2800, SYS_TRIOUTCLR);
  1388. au_writel(0x0030, SYS_OUTPUTCLR);
  1389. dbg("OHCI board setup complete\n");
  1390. /* enable host controller */
  1391. au_writel(USBH_ENABLE_CE, USB_HOST_CONFIG);
  1392. udelay(1000);
  1393. au_writel(USBH_ENABLE_INIT, USB_HOST_CONFIG);
  1394. udelay(1000);
  1395. /* wait for reset complete (read register twice; see au1500 errata) */
  1396. while (au_readl(USB_HOST_CONFIG),
  1397. !(au_readl(USB_HOST_CONFIG) & USBH_ENABLE_RD))
  1398. udelay(1000);
  1399. dbg("OHCI clock running\n");
  1400. memset (&gohci, 0, sizeof (ohci_t));
  1401. memset (&urb_priv, 0, sizeof (urb_priv_t));
  1402. /* align the storage */
  1403. if ((__u32)&ghcca[0] & 0xff) {
  1404. err("HCCA not aligned!!");
  1405. return -1;
  1406. }
  1407. phcca = &ghcca[0];
  1408. info("aligned ghcca %p", phcca);
  1409. memset(&ohci_dev, 0, sizeof(struct ohci_device));
  1410. if ((__u32)&ohci_dev.ed[0] & 0x7) {
  1411. err("EDs not aligned!!");
  1412. return -1;
  1413. }
  1414. memset(gtd, 0, sizeof(td_t) * (NUM_TD + 1));
  1415. if ((__u32)gtd & 0x7) {
  1416. err("TDs not aligned!!");
  1417. return -1;
  1418. }
  1419. ptd = gtd;
  1420. gohci.hcca = phcca;
  1421. memset (phcca, 0, sizeof (struct ohci_hcca));
  1422. gohci.disabled = 1;
  1423. gohci.sleeping = 0;
  1424. gohci.irq = -1;
  1425. gohci.regs = (struct ohci_regs *)(USB_OHCI_BASE | 0xA0000000);
  1426. gohci.flags = 0;
  1427. gohci.slot_name = "au1x00";
  1428. dbg("OHCI revision: 0x%08x\n"
  1429. " RH: a: 0x%08x b: 0x%08x\n",
  1430. readl(&gohci.regs->revision),
  1431. readl(&gohci.regs->roothub.a), readl(&gohci.regs->roothub.b));
  1432. if (hc_reset (&gohci) < 0)
  1433. goto errout;
  1434. /* FIXME this is a second HC reset; why?? */
  1435. writel (gohci.hc_control = OHCI_USB_RESET, &gohci.regs->control);
  1436. wait_ms (10);
  1437. if (hc_start (&gohci) < 0)
  1438. goto errout;
  1439. #ifdef DEBUG
  1440. ohci_dump (&gohci, 1);
  1441. #else
  1442. wait_ms(1);
  1443. #endif
  1444. ohci_inited = 1;
  1445. return 0;
  1446. errout:
  1447. err("OHCI initialization error\n");
  1448. hc_release_ohci (&gohci);
  1449. /* Initialization failed */
  1450. au_writel(readl(USB_HOST_CONFIG) & ~USBH_ENABLE_CE, USB_HOST_CONFIG);
  1451. return -1;
  1452. }
  1453. int usb_lowlevel_stop(void)
  1454. {
  1455. /* this gets called really early - before the controller has */
  1456. /* even been initialized! */
  1457. if (!ohci_inited)
  1458. return 0;
  1459. /* TODO release any interrupts, etc. */
  1460. /* call hc_release_ohci() here ? */
  1461. hc_reset (&gohci);
  1462. /* may not want to do this */
  1463. /* Disable clock */
  1464. au_writel(readl(USB_HOST_CONFIG) & ~USBH_ENABLE_CE, USB_HOST_CONFIG);
  1465. return 0;
  1466. }
  1467. #endif /* CONFIG_USB_OHCI */