ohci-hcd.c 32 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242
  1. /*
  2. * OHCI HCD (Host Controller Driver) for USB.
  3. *
  4. * (C) Copyright 1999 Roman Weissgaerber <weissg@vienna.at>
  5. * (C) Copyright 2000-2004 David Brownell <dbrownell@users.sourceforge.net>
  6. *
  7. * [ Initialisation is based on Linus' ]
  8. * [ uhci code and gregs ohci fragments ]
  9. * [ (C) Copyright 1999 Linus Torvalds ]
  10. * [ (C) Copyright 1999 Gregory P. Smith]
  11. *
  12. *
  13. * OHCI is the main "non-Intel/VIA" standard for USB 1.1 host controller
  14. * interfaces (though some non-x86 Intel chips use it). It supports
  15. * smarter hardware than UHCI. A download link for the spec available
  16. * through the http://www.usb.org website.
  17. *
  18. * This file is licenced under the GPL.
  19. */
  20. #include <linux/module.h>
  21. #include <linux/moduleparam.h>
  22. #include <linux/pci.h>
  23. #include <linux/kernel.h>
  24. #include <linux/delay.h>
  25. #include <linux/ioport.h>
  26. #include <linux/sched.h>
  27. #include <linux/slab.h>
  28. #include <linux/errno.h>
  29. #include <linux/init.h>
  30. #include <linux/timer.h>
  31. #include <linux/list.h>
  32. #include <linux/usb.h>
  33. #include <linux/usb/otg.h>
  34. #include <linux/dma-mapping.h>
  35. #include <linux/dmapool.h>
  36. #include <linux/reboot.h>
  37. #include <linux/workqueue.h>
  38. #include <linux/debugfs.h>
  39. #include <asm/io.h>
  40. #include <asm/irq.h>
  41. #include <asm/system.h>
  42. #include <asm/unaligned.h>
  43. #include <asm/byteorder.h>
  44. #include "../core/hcd.h"
  45. #define DRIVER_AUTHOR "Roman Weissgaerber, David Brownell"
  46. #define DRIVER_DESC "USB 1.1 'Open' Host Controller (OHCI) Driver"
  47. /*-------------------------------------------------------------------------*/
  48. #undef OHCI_VERBOSE_DEBUG /* not always helpful */
  49. /* For initializing controller (mask in an HCFS mode too) */
  50. #define OHCI_CONTROL_INIT OHCI_CTRL_CBSR
  51. #define OHCI_INTR_INIT \
  52. (OHCI_INTR_MIE | OHCI_INTR_RHSC | OHCI_INTR_UE \
  53. | OHCI_INTR_RD | OHCI_INTR_WDH)
  54. #ifdef __hppa__
  55. /* On PA-RISC, PDC can leave IR set incorrectly; ignore it there. */
  56. #define IR_DISABLE
  57. #endif
  58. #ifdef CONFIG_ARCH_OMAP
  59. /* OMAP doesn't support IR (no SMM; not needed) */
  60. #define IR_DISABLE
  61. #endif
  62. /*-------------------------------------------------------------------------*/
  63. static const char hcd_name [] = "ohci_hcd";
  64. #define STATECHANGE_DELAY msecs_to_jiffies(300)
  65. #include "ohci.h"
  66. static void ohci_dump (struct ohci_hcd *ohci, int verbose);
  67. static int ohci_init (struct ohci_hcd *ohci);
  68. static void ohci_stop (struct usb_hcd *hcd);
  69. #if defined(CONFIG_PM) || defined(CONFIG_PCI)
  70. static int ohci_restart (struct ohci_hcd *ohci);
  71. #endif
  72. #ifdef CONFIG_PCI
  73. static void quirk_amd_pll(int state);
  74. static void amd_iso_dev_put(void);
  75. #else
  76. static inline void quirk_amd_pll(int state)
  77. {
  78. return;
  79. }
  80. static inline void amd_iso_dev_put(void)
  81. {
  82. return;
  83. }
  84. #endif
  85. #include "ohci-hub.c"
  86. #include "ohci-dbg.c"
  87. #include "ohci-mem.c"
  88. #include "ohci-q.c"
  89. /*
  90. * On architectures with edge-triggered interrupts we must never return
  91. * IRQ_NONE.
  92. */
  93. #if defined(CONFIG_SA1111) /* ... or other edge-triggered systems */
  94. #define IRQ_NOTMINE IRQ_HANDLED
  95. #else
  96. #define IRQ_NOTMINE IRQ_NONE
  97. #endif
  98. /* Some boards misreport power switching/overcurrent */
  99. static int distrust_firmware = 1;
  100. module_param (distrust_firmware, bool, 0);
  101. MODULE_PARM_DESC (distrust_firmware,
  102. "true to distrust firmware power/overcurrent setup");
  103. /* Some boards leave IR set wrongly, since they fail BIOS/SMM handshakes */
  104. static int no_handshake = 0;
  105. module_param (no_handshake, bool, 0);
  106. MODULE_PARM_DESC (no_handshake, "true (not default) disables BIOS handshake");
  107. /*-------------------------------------------------------------------------*/
  108. /*
  109. * queue up an urb for anything except the root hub
  110. */
  111. static int ohci_urb_enqueue (
  112. struct usb_hcd *hcd,
  113. struct urb *urb,
  114. gfp_t mem_flags
  115. ) {
  116. struct ohci_hcd *ohci = hcd_to_ohci (hcd);
  117. struct ed *ed;
  118. urb_priv_t *urb_priv;
  119. unsigned int pipe = urb->pipe;
  120. int i, size = 0;
  121. unsigned long flags;
  122. int retval = 0;
  123. #ifdef OHCI_VERBOSE_DEBUG
  124. urb_print(urb, "SUB", usb_pipein(pipe), -EINPROGRESS);
  125. #endif
  126. /* every endpoint has a ed, locate and maybe (re)initialize it */
  127. if (! (ed = ed_get (ohci, urb->ep, urb->dev, pipe, urb->interval)))
  128. return -ENOMEM;
  129. /* for the private part of the URB we need the number of TDs (size) */
  130. switch (ed->type) {
  131. case PIPE_CONTROL:
  132. /* td_submit_urb() doesn't yet handle these */
  133. if (urb->transfer_buffer_length > 4096)
  134. return -EMSGSIZE;
  135. /* 1 TD for setup, 1 for ACK, plus ... */
  136. size = 2;
  137. /* FALLTHROUGH */
  138. // case PIPE_INTERRUPT:
  139. // case PIPE_BULK:
  140. default:
  141. /* one TD for every 4096 Bytes (can be upto 8K) */
  142. size += urb->transfer_buffer_length / 4096;
  143. /* ... and for any remaining bytes ... */
  144. if ((urb->transfer_buffer_length % 4096) != 0)
  145. size++;
  146. /* ... and maybe a zero length packet to wrap it up */
  147. if (size == 0)
  148. size++;
  149. else if ((urb->transfer_flags & URB_ZERO_PACKET) != 0
  150. && (urb->transfer_buffer_length
  151. % usb_maxpacket (urb->dev, pipe,
  152. usb_pipeout (pipe))) == 0)
  153. size++;
  154. break;
  155. case PIPE_ISOCHRONOUS: /* number of packets from URB */
  156. size = urb->number_of_packets;
  157. break;
  158. }
  159. /* allocate the private part of the URB */
  160. urb_priv = kzalloc (sizeof (urb_priv_t) + size * sizeof (struct td *),
  161. mem_flags);
  162. if (!urb_priv)
  163. return -ENOMEM;
  164. INIT_LIST_HEAD (&urb_priv->pending);
  165. urb_priv->length = size;
  166. urb_priv->ed = ed;
  167. /* allocate the TDs (deferring hash chain updates) */
  168. for (i = 0; i < size; i++) {
  169. urb_priv->td [i] = td_alloc (ohci, mem_flags);
  170. if (!urb_priv->td [i]) {
  171. urb_priv->length = i;
  172. urb_free_priv (ohci, urb_priv);
  173. return -ENOMEM;
  174. }
  175. }
  176. spin_lock_irqsave (&ohci->lock, flags);
  177. /* don't submit to a dead HC */
  178. if (!test_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags)) {
  179. retval = -ENODEV;
  180. goto fail;
  181. }
  182. if (!HC_IS_RUNNING(hcd->state)) {
  183. retval = -ENODEV;
  184. goto fail;
  185. }
  186. retval = usb_hcd_link_urb_to_ep(hcd, urb);
  187. if (retval)
  188. goto fail;
  189. /* schedule the ed if needed */
  190. if (ed->state == ED_IDLE) {
  191. retval = ed_schedule (ohci, ed);
  192. if (retval < 0) {
  193. usb_hcd_unlink_urb_from_ep(hcd, urb);
  194. goto fail;
  195. }
  196. if (ed->type == PIPE_ISOCHRONOUS) {
  197. u16 frame = ohci_frame_no(ohci);
  198. /* delay a few frames before the first TD */
  199. frame += max_t (u16, 8, ed->interval);
  200. frame &= ~(ed->interval - 1);
  201. frame |= ed->branch;
  202. urb->start_frame = frame;
  203. /* yes, only URB_ISO_ASAP is supported, and
  204. * urb->start_frame is never used as input.
  205. */
  206. }
  207. } else if (ed->type == PIPE_ISOCHRONOUS)
  208. urb->start_frame = ed->last_iso + ed->interval;
  209. /* fill the TDs and link them to the ed; and
  210. * enable that part of the schedule, if needed
  211. * and update count of queued periodic urbs
  212. */
  213. urb->hcpriv = urb_priv;
  214. td_submit_urb (ohci, urb);
  215. fail:
  216. if (retval)
  217. urb_free_priv (ohci, urb_priv);
  218. spin_unlock_irqrestore (&ohci->lock, flags);
  219. return retval;
  220. }
  221. /*
  222. * decouple the URB from the HC queues (TDs, urb_priv).
  223. * reporting is always done
  224. * asynchronously, and we might be dealing with an urb that's
  225. * partially transferred, or an ED with other urbs being unlinked.
  226. */
  227. static int ohci_urb_dequeue(struct usb_hcd *hcd, struct urb *urb, int status)
  228. {
  229. struct ohci_hcd *ohci = hcd_to_ohci (hcd);
  230. unsigned long flags;
  231. int rc;
  232. #ifdef OHCI_VERBOSE_DEBUG
  233. urb_print(urb, "UNLINK", 1, status);
  234. #endif
  235. spin_lock_irqsave (&ohci->lock, flags);
  236. rc = usb_hcd_check_unlink_urb(hcd, urb, status);
  237. if (rc) {
  238. ; /* Do nothing */
  239. } else if (HC_IS_RUNNING(hcd->state)) {
  240. urb_priv_t *urb_priv;
  241. /* Unless an IRQ completed the unlink while it was being
  242. * handed to us, flag it for unlink and giveback, and force
  243. * some upcoming INTR_SF to call finish_unlinks()
  244. */
  245. urb_priv = urb->hcpriv;
  246. if (urb_priv) {
  247. if (urb_priv->ed->state == ED_OPER)
  248. start_ed_unlink (ohci, urb_priv->ed);
  249. }
  250. } else {
  251. /*
  252. * with HC dead, we won't respect hc queue pointers
  253. * any more ... just clean up every urb's memory.
  254. */
  255. if (urb->hcpriv)
  256. finish_urb(ohci, urb, status);
  257. }
  258. spin_unlock_irqrestore (&ohci->lock, flags);
  259. return rc;
  260. }
  261. /*-------------------------------------------------------------------------*/
  262. /* frees config/altsetting state for endpoints,
  263. * including ED memory, dummy TD, and bulk/intr data toggle
  264. */
  265. static void
  266. ohci_endpoint_disable (struct usb_hcd *hcd, struct usb_host_endpoint *ep)
  267. {
  268. struct ohci_hcd *ohci = hcd_to_ohci (hcd);
  269. unsigned long flags;
  270. struct ed *ed = ep->hcpriv;
  271. unsigned limit = 1000;
  272. /* ASSERT: any requests/urbs are being unlinked */
  273. /* ASSERT: nobody can be submitting urbs for this any more */
  274. if (!ed)
  275. return;
  276. rescan:
  277. spin_lock_irqsave (&ohci->lock, flags);
  278. if (!HC_IS_RUNNING (hcd->state)) {
  279. sanitize:
  280. ed->state = ED_IDLE;
  281. if (quirk_zfmicro(ohci) && ed->type == PIPE_INTERRUPT)
  282. ohci->eds_scheduled--;
  283. finish_unlinks (ohci, 0);
  284. }
  285. switch (ed->state) {
  286. case ED_UNLINK: /* wait for hw to finish? */
  287. /* major IRQ delivery trouble loses INTR_SF too... */
  288. if (limit-- == 0) {
  289. ohci_warn(ohci, "ED unlink timeout\n");
  290. if (quirk_zfmicro(ohci)) {
  291. ohci_warn(ohci, "Attempting ZF TD recovery\n");
  292. ohci->ed_to_check = ed;
  293. ohci->zf_delay = 2;
  294. }
  295. goto sanitize;
  296. }
  297. spin_unlock_irqrestore (&ohci->lock, flags);
  298. schedule_timeout_uninterruptible(1);
  299. goto rescan;
  300. case ED_IDLE: /* fully unlinked */
  301. if (list_empty (&ed->td_list)) {
  302. td_free (ohci, ed->dummy);
  303. ed_free (ohci, ed);
  304. break;
  305. }
  306. /* else FALL THROUGH */
  307. default:
  308. /* caller was supposed to have unlinked any requests;
  309. * that's not our job. can't recover; must leak ed.
  310. */
  311. ohci_err (ohci, "leak ed %p (#%02x) state %d%s\n",
  312. ed, ep->desc.bEndpointAddress, ed->state,
  313. list_empty (&ed->td_list) ? "" : " (has tds)");
  314. td_free (ohci, ed->dummy);
  315. break;
  316. }
  317. ep->hcpriv = NULL;
  318. spin_unlock_irqrestore (&ohci->lock, flags);
  319. return;
  320. }
  321. static int ohci_get_frame (struct usb_hcd *hcd)
  322. {
  323. struct ohci_hcd *ohci = hcd_to_ohci (hcd);
  324. return ohci_frame_no(ohci);
  325. }
  326. static void ohci_usb_reset (struct ohci_hcd *ohci)
  327. {
  328. ohci->hc_control = ohci_readl (ohci, &ohci->regs->control);
  329. ohci->hc_control &= OHCI_CTRL_RWC;
  330. ohci_writel (ohci, ohci->hc_control, &ohci->regs->control);
  331. }
  332. /* ohci_shutdown forcibly disables IRQs and DMA, helping kexec and
  333. * other cases where the next software may expect clean state from the
  334. * "firmware". this is bus-neutral, unlike shutdown() methods.
  335. */
  336. static void
  337. ohci_shutdown (struct usb_hcd *hcd)
  338. {
  339. struct ohci_hcd *ohci;
  340. ohci = hcd_to_ohci (hcd);
  341. ohci_writel (ohci, OHCI_INTR_MIE, &ohci->regs->intrdisable);
  342. ohci_usb_reset (ohci);
  343. /* flush the writes */
  344. (void) ohci_readl (ohci, &ohci->regs->control);
  345. }
  346. static int check_ed(struct ohci_hcd *ohci, struct ed *ed)
  347. {
  348. return (hc32_to_cpu(ohci, ed->hwINFO) & ED_IN) != 0
  349. && (hc32_to_cpu(ohci, ed->hwHeadP) & TD_MASK)
  350. == (hc32_to_cpu(ohci, ed->hwTailP) & TD_MASK)
  351. && !list_empty(&ed->td_list);
  352. }
  353. /* ZF Micro watchdog timer callback. The ZF Micro chipset sometimes completes
  354. * an interrupt TD but neglects to add it to the donelist. On systems with
  355. * this chipset, we need to periodically check the state of the queues to look
  356. * for such "lost" TDs.
  357. */
  358. static void unlink_watchdog_func(unsigned long _ohci)
  359. {
  360. unsigned long flags;
  361. unsigned max;
  362. unsigned seen_count = 0;
  363. unsigned i;
  364. struct ed **seen = NULL;
  365. struct ohci_hcd *ohci = (struct ohci_hcd *) _ohci;
  366. spin_lock_irqsave(&ohci->lock, flags);
  367. max = ohci->eds_scheduled;
  368. if (!max)
  369. goto done;
  370. if (ohci->ed_to_check)
  371. goto out;
  372. seen = kcalloc(max, sizeof *seen, GFP_ATOMIC);
  373. if (!seen)
  374. goto out;
  375. for (i = 0; i < NUM_INTS; i++) {
  376. struct ed *ed = ohci->periodic[i];
  377. while (ed) {
  378. unsigned temp;
  379. /* scan this branch of the periodic schedule tree */
  380. for (temp = 0; temp < seen_count; temp++) {
  381. if (seen[temp] == ed) {
  382. /* we've checked it and what's after */
  383. ed = NULL;
  384. break;
  385. }
  386. }
  387. if (!ed)
  388. break;
  389. seen[seen_count++] = ed;
  390. if (!check_ed(ohci, ed)) {
  391. ed = ed->ed_next;
  392. continue;
  393. }
  394. /* HC's TD list is empty, but HCD sees at least one
  395. * TD that's not been sent through the donelist.
  396. */
  397. ohci->ed_to_check = ed;
  398. ohci->zf_delay = 2;
  399. /* The HC may wait until the next frame to report the
  400. * TD as done through the donelist and INTR_WDH. (We
  401. * just *assume* it's not a multi-TD interrupt URB;
  402. * those could defer the IRQ more than one frame, using
  403. * DI...) Check again after the next INTR_SF.
  404. */
  405. ohci_writel(ohci, OHCI_INTR_SF,
  406. &ohci->regs->intrstatus);
  407. ohci_writel(ohci, OHCI_INTR_SF,
  408. &ohci->regs->intrenable);
  409. /* flush those writes */
  410. (void) ohci_readl(ohci, &ohci->regs->control);
  411. goto out;
  412. }
  413. }
  414. out:
  415. kfree(seen);
  416. if (ohci->eds_scheduled)
  417. mod_timer(&ohci->unlink_watchdog, round_jiffies(jiffies + HZ));
  418. done:
  419. spin_unlock_irqrestore(&ohci->lock, flags);
  420. }
  421. /*-------------------------------------------------------------------------*
  422. * HC functions
  423. *-------------------------------------------------------------------------*/
  424. /* init memory, and kick BIOS/SMM off */
  425. static int ohci_init (struct ohci_hcd *ohci)
  426. {
  427. int ret;
  428. struct usb_hcd *hcd = ohci_to_hcd(ohci);
  429. if (distrust_firmware)
  430. ohci->flags |= OHCI_QUIRK_HUB_POWER;
  431. disable (ohci);
  432. ohci->regs = hcd->regs;
  433. /* REVISIT this BIOS handshake is now moved into PCI "quirks", and
  434. * was never needed for most non-PCI systems ... remove the code?
  435. */
  436. #ifndef IR_DISABLE
  437. /* SMM owns the HC? not for long! */
  438. if (!no_handshake && ohci_readl (ohci,
  439. &ohci->regs->control) & OHCI_CTRL_IR) {
  440. u32 temp;
  441. ohci_dbg (ohci, "USB HC TakeOver from BIOS/SMM\n");
  442. /* this timeout is arbitrary. we make it long, so systems
  443. * depending on usb keyboards may be usable even if the
  444. * BIOS/SMM code seems pretty broken.
  445. */
  446. temp = 500; /* arbitrary: five seconds */
  447. ohci_writel (ohci, OHCI_INTR_OC, &ohci->regs->intrenable);
  448. ohci_writel (ohci, OHCI_OCR, &ohci->regs->cmdstatus);
  449. while (ohci_readl (ohci, &ohci->regs->control) & OHCI_CTRL_IR) {
  450. msleep (10);
  451. if (--temp == 0) {
  452. ohci_err (ohci, "USB HC takeover failed!"
  453. " (BIOS/SMM bug)\n");
  454. return -EBUSY;
  455. }
  456. }
  457. ohci_usb_reset (ohci);
  458. }
  459. #endif
  460. /* Disable HC interrupts */
  461. ohci_writel (ohci, OHCI_INTR_MIE, &ohci->regs->intrdisable);
  462. /* flush the writes, and save key bits like RWC */
  463. if (ohci_readl (ohci, &ohci->regs->control) & OHCI_CTRL_RWC)
  464. ohci->hc_control |= OHCI_CTRL_RWC;
  465. /* Read the number of ports unless overridden */
  466. if (ohci->num_ports == 0)
  467. ohci->num_ports = roothub_a(ohci) & RH_A_NDP;
  468. if (ohci->hcca)
  469. return 0;
  470. ohci->hcca = dma_alloc_coherent (hcd->self.controller,
  471. sizeof *ohci->hcca, &ohci->hcca_dma, 0);
  472. if (!ohci->hcca)
  473. return -ENOMEM;
  474. if ((ret = ohci_mem_init (ohci)) < 0)
  475. ohci_stop (hcd);
  476. else {
  477. create_debug_files (ohci);
  478. }
  479. return ret;
  480. }
  481. /*-------------------------------------------------------------------------*/
  482. /* Start an OHCI controller, set the BUS operational
  483. * resets USB and controller
  484. * enable interrupts
  485. */
  486. static int ohci_run (struct ohci_hcd *ohci)
  487. {
  488. u32 mask, temp;
  489. int first = ohci->fminterval == 0;
  490. struct usb_hcd *hcd = ohci_to_hcd(ohci);
  491. disable (ohci);
  492. /* boot firmware should have set this up (5.1.1.3.1) */
  493. if (first) {
  494. temp = ohci_readl (ohci, &ohci->regs->fminterval);
  495. ohci->fminterval = temp & 0x3fff;
  496. if (ohci->fminterval != FI)
  497. ohci_dbg (ohci, "fminterval delta %d\n",
  498. ohci->fminterval - FI);
  499. ohci->fminterval |= FSMP (ohci->fminterval) << 16;
  500. /* also: power/overcurrent flags in roothub.a */
  501. }
  502. /* Reset USB nearly "by the book". RemoteWakeupConnected has
  503. * to be checked in case boot firmware (BIOS/SMM/...) has set up
  504. * wakeup in a way the bus isn't aware of (e.g., legacy PCI PM).
  505. * If the bus glue detected wakeup capability then it should
  506. * already be enabled. Either way, if wakeup should be enabled
  507. * but isn't, we'll enable it now.
  508. */
  509. if ((ohci->hc_control & OHCI_CTRL_RWC) != 0
  510. && !device_can_wakeup(hcd->self.controller))
  511. device_init_wakeup(hcd->self.controller, 1);
  512. switch (ohci->hc_control & OHCI_CTRL_HCFS) {
  513. case OHCI_USB_OPER:
  514. temp = 0;
  515. break;
  516. case OHCI_USB_SUSPEND:
  517. case OHCI_USB_RESUME:
  518. ohci->hc_control &= OHCI_CTRL_RWC;
  519. ohci->hc_control |= OHCI_USB_RESUME;
  520. temp = 10 /* msec wait */;
  521. break;
  522. // case OHCI_USB_RESET:
  523. default:
  524. ohci->hc_control &= OHCI_CTRL_RWC;
  525. ohci->hc_control |= OHCI_USB_RESET;
  526. temp = 50 /* msec wait */;
  527. break;
  528. }
  529. ohci_writel (ohci, ohci->hc_control, &ohci->regs->control);
  530. // flush the writes
  531. (void) ohci_readl (ohci, &ohci->regs->control);
  532. msleep(temp);
  533. memset (ohci->hcca, 0, sizeof (struct ohci_hcca));
  534. /* 2msec timelimit here means no irqs/preempt */
  535. spin_lock_irq (&ohci->lock);
  536. retry:
  537. /* HC Reset requires max 10 us delay */
  538. ohci_writel (ohci, OHCI_HCR, &ohci->regs->cmdstatus);
  539. temp = 30; /* ... allow extra time */
  540. while ((ohci_readl (ohci, &ohci->regs->cmdstatus) & OHCI_HCR) != 0) {
  541. if (--temp == 0) {
  542. spin_unlock_irq (&ohci->lock);
  543. ohci_err (ohci, "USB HC reset timed out!\n");
  544. return -1;
  545. }
  546. udelay (1);
  547. }
  548. /* now we're in the SUSPEND state ... must go OPERATIONAL
  549. * within 2msec else HC enters RESUME
  550. *
  551. * ... but some hardware won't init fmInterval "by the book"
  552. * (SiS, OPTi ...), so reset again instead. SiS doesn't need
  553. * this if we write fmInterval after we're OPERATIONAL.
  554. * Unclear about ALi, ServerWorks, and others ... this could
  555. * easily be a longstanding bug in chip init on Linux.
  556. */
  557. if (ohci->flags & OHCI_QUIRK_INITRESET) {
  558. ohci_writel (ohci, ohci->hc_control, &ohci->regs->control);
  559. // flush those writes
  560. (void) ohci_readl (ohci, &ohci->regs->control);
  561. }
  562. /* Tell the controller where the control and bulk lists are
  563. * The lists are empty now. */
  564. ohci_writel (ohci, 0, &ohci->regs->ed_controlhead);
  565. ohci_writel (ohci, 0, &ohci->regs->ed_bulkhead);
  566. /* a reset clears this */
  567. ohci_writel (ohci, (u32) ohci->hcca_dma, &ohci->regs->hcca);
  568. periodic_reinit (ohci);
  569. /* some OHCI implementations are finicky about how they init.
  570. * bogus values here mean not even enumeration could work.
  571. */
  572. if ((ohci_readl (ohci, &ohci->regs->fminterval) & 0x3fff0000) == 0
  573. || !ohci_readl (ohci, &ohci->regs->periodicstart)) {
  574. if (!(ohci->flags & OHCI_QUIRK_INITRESET)) {
  575. ohci->flags |= OHCI_QUIRK_INITRESET;
  576. ohci_dbg (ohci, "enabling initreset quirk\n");
  577. goto retry;
  578. }
  579. spin_unlock_irq (&ohci->lock);
  580. ohci_err (ohci, "init err (%08x %04x)\n",
  581. ohci_readl (ohci, &ohci->regs->fminterval),
  582. ohci_readl (ohci, &ohci->regs->periodicstart));
  583. return -EOVERFLOW;
  584. }
  585. /* use rhsc irqs after khubd is fully initialized */
  586. hcd->poll_rh = 1;
  587. hcd->uses_new_polling = 1;
  588. /* start controller operations */
  589. ohci->hc_control &= OHCI_CTRL_RWC;
  590. ohci->hc_control |= OHCI_CONTROL_INIT | OHCI_USB_OPER;
  591. ohci_writel (ohci, ohci->hc_control, &ohci->regs->control);
  592. hcd->state = HC_STATE_RUNNING;
  593. /* wake on ConnectStatusChange, matching external hubs */
  594. ohci_writel (ohci, RH_HS_DRWE, &ohci->regs->roothub.status);
  595. /* Choose the interrupts we care about now, others later on demand */
  596. mask = OHCI_INTR_INIT;
  597. ohci_writel (ohci, ~0, &ohci->regs->intrstatus);
  598. ohci_writel (ohci, mask, &ohci->regs->intrenable);
  599. /* handle root hub init quirks ... */
  600. temp = roothub_a (ohci);
  601. temp &= ~(RH_A_PSM | RH_A_OCPM);
  602. if (ohci->flags & OHCI_QUIRK_SUPERIO) {
  603. /* NSC 87560 and maybe others */
  604. temp |= RH_A_NOCP;
  605. temp &= ~(RH_A_POTPGT | RH_A_NPS);
  606. ohci_writel (ohci, temp, &ohci->regs->roothub.a);
  607. } else if ((ohci->flags & OHCI_QUIRK_AMD756) ||
  608. (ohci->flags & OHCI_QUIRK_HUB_POWER)) {
  609. /* hub power always on; required for AMD-756 and some
  610. * Mac platforms. ganged overcurrent reporting, if any.
  611. */
  612. temp |= RH_A_NPS;
  613. ohci_writel (ohci, temp, &ohci->regs->roothub.a);
  614. }
  615. ohci_writel (ohci, RH_HS_LPSC, &ohci->regs->roothub.status);
  616. ohci_writel (ohci, (temp & RH_A_NPS) ? 0 : RH_B_PPCM,
  617. &ohci->regs->roothub.b);
  618. // flush those writes
  619. (void) ohci_readl (ohci, &ohci->regs->control);
  620. ohci->next_statechange = jiffies + STATECHANGE_DELAY;
  621. spin_unlock_irq (&ohci->lock);
  622. // POTPGT delay is bits 24-31, in 2 ms units.
  623. mdelay ((temp >> 23) & 0x1fe);
  624. hcd->state = HC_STATE_RUNNING;
  625. if (quirk_zfmicro(ohci)) {
  626. /* Create timer to watch for bad queue state on ZF Micro */
  627. setup_timer(&ohci->unlink_watchdog, unlink_watchdog_func,
  628. (unsigned long) ohci);
  629. ohci->eds_scheduled = 0;
  630. ohci->ed_to_check = NULL;
  631. }
  632. ohci_dump (ohci, 1);
  633. return 0;
  634. }
  635. /*-------------------------------------------------------------------------*/
  636. /* an interrupt happens */
  637. static irqreturn_t ohci_irq (struct usb_hcd *hcd)
  638. {
  639. struct ohci_hcd *ohci = hcd_to_ohci (hcd);
  640. struct ohci_regs __iomem *regs = ohci->regs;
  641. int ints;
  642. /* Read interrupt status (and flush pending writes). We ignore the
  643. * optimization of checking the LSB of hcca->done_head; it doesn't
  644. * work on all systems (edge triggering for OHCI can be a factor).
  645. */
  646. ints = ohci_readl(ohci, &regs->intrstatus);
  647. /* Check for an all 1's result which is a typical consequence
  648. * of dead, unclocked, or unplugged (CardBus...) devices
  649. */
  650. if (ints == ~(u32)0) {
  651. disable (ohci);
  652. ohci_dbg (ohci, "device removed!\n");
  653. return IRQ_HANDLED;
  654. }
  655. /* We only care about interrupts that are enabled */
  656. ints &= ohci_readl(ohci, &regs->intrenable);
  657. /* interrupt for some other device? */
  658. if (ints == 0)
  659. return IRQ_NOTMINE;
  660. if (ints & OHCI_INTR_UE) {
  661. // e.g. due to PCI Master/Target Abort
  662. if (quirk_nec(ohci)) {
  663. /* Workaround for a silicon bug in some NEC chips used
  664. * in Apple's PowerBooks. Adapted from Darwin code.
  665. */
  666. ohci_err (ohci, "OHCI Unrecoverable Error, scheduling NEC chip restart\n");
  667. ohci_writel (ohci, OHCI_INTR_UE, &regs->intrdisable);
  668. schedule_work (&ohci->nec_work);
  669. } else {
  670. disable (ohci);
  671. ohci_err (ohci, "OHCI Unrecoverable Error, disabled\n");
  672. }
  673. ohci_dump (ohci, 1);
  674. ohci_usb_reset (ohci);
  675. }
  676. if (ints & OHCI_INTR_RHSC) {
  677. ohci_vdbg(ohci, "rhsc\n");
  678. ohci->next_statechange = jiffies + STATECHANGE_DELAY;
  679. ohci_writel(ohci, OHCI_INTR_RD | OHCI_INTR_RHSC,
  680. &regs->intrstatus);
  681. /* NOTE: Vendors didn't always make the same implementation
  682. * choices for RHSC. Many followed the spec; RHSC triggers
  683. * on an edge, like setting and maybe clearing a port status
  684. * change bit. With others it's level-triggered, active
  685. * until khubd clears all the port status change bits. We'll
  686. * always disable it here and rely on polling until khubd
  687. * re-enables it.
  688. */
  689. ohci_writel(ohci, OHCI_INTR_RHSC, &regs->intrdisable);
  690. usb_hcd_poll_rh_status(hcd);
  691. }
  692. /* For connect and disconnect events, we expect the controller
  693. * to turn on RHSC along with RD. But for remote wakeup events
  694. * this might not happen.
  695. */
  696. else if (ints & OHCI_INTR_RD) {
  697. ohci_vdbg(ohci, "resume detect\n");
  698. ohci_writel(ohci, OHCI_INTR_RD, &regs->intrstatus);
  699. hcd->poll_rh = 1;
  700. if (ohci->autostop) {
  701. spin_lock (&ohci->lock);
  702. ohci_rh_resume (ohci);
  703. spin_unlock (&ohci->lock);
  704. } else
  705. usb_hcd_resume_root_hub(hcd);
  706. }
  707. if (ints & OHCI_INTR_WDH) {
  708. spin_lock (&ohci->lock);
  709. dl_done_list (ohci);
  710. spin_unlock (&ohci->lock);
  711. }
  712. if (quirk_zfmicro(ohci) && (ints & OHCI_INTR_SF)) {
  713. spin_lock(&ohci->lock);
  714. if (ohci->ed_to_check) {
  715. struct ed *ed = ohci->ed_to_check;
  716. if (check_ed(ohci, ed)) {
  717. /* HC thinks the TD list is empty; HCD knows
  718. * at least one TD is outstanding
  719. */
  720. if (--ohci->zf_delay == 0) {
  721. struct td *td = list_entry(
  722. ed->td_list.next,
  723. struct td, td_list);
  724. ohci_warn(ohci,
  725. "Reclaiming orphan TD %p\n",
  726. td);
  727. takeback_td(ohci, td);
  728. ohci->ed_to_check = NULL;
  729. }
  730. } else
  731. ohci->ed_to_check = NULL;
  732. }
  733. spin_unlock(&ohci->lock);
  734. }
  735. /* could track INTR_SO to reduce available PCI/... bandwidth */
  736. /* handle any pending URB/ED unlinks, leaving INTR_SF enabled
  737. * when there's still unlinking to be done (next frame).
  738. */
  739. spin_lock (&ohci->lock);
  740. if (ohci->ed_rm_list)
  741. finish_unlinks (ohci, ohci_frame_no(ohci));
  742. if ((ints & OHCI_INTR_SF) != 0
  743. && !ohci->ed_rm_list
  744. && !ohci->ed_to_check
  745. && HC_IS_RUNNING(hcd->state))
  746. ohci_writel (ohci, OHCI_INTR_SF, &regs->intrdisable);
  747. spin_unlock (&ohci->lock);
  748. if (HC_IS_RUNNING(hcd->state)) {
  749. ohci_writel (ohci, ints, &regs->intrstatus);
  750. ohci_writel (ohci, OHCI_INTR_MIE, &regs->intrenable);
  751. // flush those writes
  752. (void) ohci_readl (ohci, &ohci->regs->control);
  753. }
  754. return IRQ_HANDLED;
  755. }
  756. /*-------------------------------------------------------------------------*/
  757. static void ohci_stop (struct usb_hcd *hcd)
  758. {
  759. struct ohci_hcd *ohci = hcd_to_ohci (hcd);
  760. ohci_dump (ohci, 1);
  761. flush_scheduled_work();
  762. ohci_usb_reset (ohci);
  763. ohci_writel (ohci, OHCI_INTR_MIE, &ohci->regs->intrdisable);
  764. free_irq(hcd->irq, hcd);
  765. hcd->irq = -1;
  766. if (quirk_zfmicro(ohci))
  767. del_timer(&ohci->unlink_watchdog);
  768. if (quirk_amdiso(ohci))
  769. amd_iso_dev_put();
  770. remove_debug_files (ohci);
  771. ohci_mem_cleanup (ohci);
  772. if (ohci->hcca) {
  773. dma_free_coherent (hcd->self.controller,
  774. sizeof *ohci->hcca,
  775. ohci->hcca, ohci->hcca_dma);
  776. ohci->hcca = NULL;
  777. ohci->hcca_dma = 0;
  778. }
  779. }
  780. /*-------------------------------------------------------------------------*/
  781. #if defined(CONFIG_PM) || defined(CONFIG_PCI)
  782. /* must not be called from interrupt context */
  783. static int ohci_restart (struct ohci_hcd *ohci)
  784. {
  785. int temp;
  786. int i;
  787. struct urb_priv *priv;
  788. spin_lock_irq(&ohci->lock);
  789. disable (ohci);
  790. /* Recycle any "live" eds/tds (and urbs). */
  791. if (!list_empty (&ohci->pending))
  792. ohci_dbg(ohci, "abort schedule...\n");
  793. list_for_each_entry (priv, &ohci->pending, pending) {
  794. struct urb *urb = priv->td[0]->urb;
  795. struct ed *ed = priv->ed;
  796. switch (ed->state) {
  797. case ED_OPER:
  798. ed->state = ED_UNLINK;
  799. ed->hwINFO |= cpu_to_hc32(ohci, ED_DEQUEUE);
  800. ed_deschedule (ohci, ed);
  801. ed->ed_next = ohci->ed_rm_list;
  802. ed->ed_prev = NULL;
  803. ohci->ed_rm_list = ed;
  804. /* FALLTHROUGH */
  805. case ED_UNLINK:
  806. break;
  807. default:
  808. ohci_dbg(ohci, "bogus ed %p state %d\n",
  809. ed, ed->state);
  810. }
  811. if (!urb->unlinked)
  812. urb->unlinked = -ESHUTDOWN;
  813. }
  814. finish_unlinks (ohci, 0);
  815. spin_unlock_irq(&ohci->lock);
  816. /* paranoia, in case that didn't work: */
  817. /* empty the interrupt branches */
  818. for (i = 0; i < NUM_INTS; i++) ohci->load [i] = 0;
  819. for (i = 0; i < NUM_INTS; i++) ohci->hcca->int_table [i] = 0;
  820. /* no EDs to remove */
  821. ohci->ed_rm_list = NULL;
  822. /* empty control and bulk lists */
  823. ohci->ed_controltail = NULL;
  824. ohci->ed_bulktail = NULL;
  825. if ((temp = ohci_run (ohci)) < 0) {
  826. ohci_err (ohci, "can't restart, %d\n", temp);
  827. return temp;
  828. }
  829. ohci_dbg(ohci, "restart complete\n");
  830. return 0;
  831. }
  832. #endif
  833. /*-------------------------------------------------------------------------*/
  834. MODULE_AUTHOR (DRIVER_AUTHOR);
  835. MODULE_DESCRIPTION(DRIVER_DESC);
  836. MODULE_LICENSE ("GPL");
  837. #ifdef CONFIG_PCI
  838. #include "ohci-pci.c"
  839. #define PCI_DRIVER ohci_pci_driver
  840. #endif
  841. #if defined(CONFIG_ARCH_SA1100) && defined(CONFIG_SA1111)
  842. #include "ohci-sa1111.c"
  843. #define SA1111_DRIVER ohci_hcd_sa1111_driver
  844. #endif
  845. #ifdef CONFIG_ARCH_S3C2410
  846. #include "ohci-s3c2410.c"
  847. #define PLATFORM_DRIVER ohci_hcd_s3c2410_driver
  848. #endif
  849. #ifdef CONFIG_ARCH_OMAP
  850. #include "ohci-omap.c"
  851. #define PLATFORM_DRIVER ohci_hcd_omap_driver
  852. #endif
  853. #ifdef CONFIG_ARCH_LH7A404
  854. #include "ohci-lh7a404.c"
  855. #define PLATFORM_DRIVER ohci_hcd_lh7a404_driver
  856. #endif
  857. #if defined(CONFIG_PXA27x) || defined(CONFIG_PXA3xx)
  858. #include "ohci-pxa27x.c"
  859. #define PLATFORM_DRIVER ohci_hcd_pxa27x_driver
  860. #endif
  861. #ifdef CONFIG_ARCH_EP93XX
  862. #include "ohci-ep93xx.c"
  863. #define PLATFORM_DRIVER ohci_hcd_ep93xx_driver
  864. #endif
  865. #ifdef CONFIG_SOC_AU1X00
  866. #include "ohci-au1xxx.c"
  867. #define PLATFORM_DRIVER ohci_hcd_au1xxx_driver
  868. #endif
  869. #ifdef CONFIG_PNX8550
  870. #include "ohci-pnx8550.c"
  871. #define PLATFORM_DRIVER ohci_hcd_pnx8550_driver
  872. #endif
  873. #ifdef CONFIG_USB_OHCI_HCD_PPC_SOC
  874. #include "ohci-ppc-soc.c"
  875. #define PLATFORM_DRIVER ohci_hcd_ppc_soc_driver
  876. #endif
  877. #ifdef CONFIG_ARCH_AT91
  878. #include "ohci-at91.c"
  879. #define PLATFORM_DRIVER ohci_hcd_at91_driver
  880. #endif
  881. #ifdef CONFIG_ARCH_PNX4008
  882. #include "ohci-pnx4008.c"
  883. #define PLATFORM_DRIVER usb_hcd_pnx4008_driver
  884. #endif
  885. #if defined(CONFIG_CPU_SUBTYPE_SH7720) || \
  886. defined(CONFIG_CPU_SUBTYPE_SH7721) || \
  887. defined(CONFIG_CPU_SUBTYPE_SH7763)
  888. #include "ohci-sh.c"
  889. #define PLATFORM_DRIVER ohci_hcd_sh_driver
  890. #endif
  891. #ifdef CONFIG_USB_OHCI_HCD_PPC_OF
  892. #include "ohci-ppc-of.c"
  893. #define OF_PLATFORM_DRIVER ohci_hcd_ppc_of_driver
  894. #endif
  895. #ifdef CONFIG_PPC_PS3
  896. #include "ohci-ps3.c"
  897. #define PS3_SYSTEM_BUS_DRIVER ps3_ohci_driver
  898. #endif
  899. #ifdef CONFIG_USB_OHCI_HCD_SSB
  900. #include "ohci-ssb.c"
  901. #define SSB_OHCI_DRIVER ssb_ohci_driver
  902. #endif
  903. #ifdef CONFIG_MFD_SM501
  904. #include "ohci-sm501.c"
  905. #define SM501_OHCI_DRIVER ohci_hcd_sm501_driver
  906. #endif
  907. #ifdef CONFIG_MFD_TC6393XB
  908. #include "ohci-tmio.c"
  909. #define TMIO_OHCI_DRIVER ohci_hcd_tmio_driver
  910. #endif
  911. #if !defined(PCI_DRIVER) && \
  912. !defined(PLATFORM_DRIVER) && \
  913. !defined(OF_PLATFORM_DRIVER) && \
  914. !defined(SA1111_DRIVER) && \
  915. !defined(PS3_SYSTEM_BUS_DRIVER) && \
  916. !defined(SM501_OHCI_DRIVER) && \
  917. !defined(TMIO_OHCI_DRIVER) && \
  918. !defined(SSB_OHCI_DRIVER)
  919. #error "missing bus glue for ohci-hcd"
  920. #endif
  921. static int __init ohci_hcd_mod_init(void)
  922. {
  923. int retval = 0;
  924. if (usb_disabled())
  925. return -ENODEV;
  926. printk(KERN_INFO "%s: " DRIVER_DESC "\n", hcd_name);
  927. pr_debug ("%s: block sizes: ed %Zd td %Zd\n", hcd_name,
  928. sizeof (struct ed), sizeof (struct td));
  929. set_bit(USB_OHCI_LOADED, &usb_hcds_loaded);
  930. #ifdef DEBUG
  931. ohci_debug_root = debugfs_create_dir("ohci", NULL);
  932. if (!ohci_debug_root) {
  933. retval = -ENOENT;
  934. goto error_debug;
  935. }
  936. #endif
  937. #ifdef PS3_SYSTEM_BUS_DRIVER
  938. retval = ps3_ohci_driver_register(&PS3_SYSTEM_BUS_DRIVER);
  939. if (retval < 0)
  940. goto error_ps3;
  941. #endif
  942. #ifdef PLATFORM_DRIVER
  943. retval = platform_driver_register(&PLATFORM_DRIVER);
  944. if (retval < 0)
  945. goto error_platform;
  946. #endif
  947. #ifdef OF_PLATFORM_DRIVER
  948. retval = of_register_platform_driver(&OF_PLATFORM_DRIVER);
  949. if (retval < 0)
  950. goto error_of_platform;
  951. #endif
  952. #ifdef SA1111_DRIVER
  953. retval = sa1111_driver_register(&SA1111_DRIVER);
  954. if (retval < 0)
  955. goto error_sa1111;
  956. #endif
  957. #ifdef PCI_DRIVER
  958. retval = pci_register_driver(&PCI_DRIVER);
  959. if (retval < 0)
  960. goto error_pci;
  961. #endif
  962. #ifdef SSB_OHCI_DRIVER
  963. retval = ssb_driver_register(&SSB_OHCI_DRIVER);
  964. if (retval)
  965. goto error_ssb;
  966. #endif
  967. #ifdef SM501_OHCI_DRIVER
  968. retval = platform_driver_register(&SM501_OHCI_DRIVER);
  969. if (retval < 0)
  970. goto error_sm501;
  971. #endif
  972. #ifdef TMIO_OHCI_DRIVER
  973. retval = platform_driver_register(&TMIO_OHCI_DRIVER);
  974. if (retval < 0)
  975. goto error_tmio;
  976. #endif
  977. return retval;
  978. /* Error path */
  979. #ifdef TMIO_OHCI_DRIVER
  980. platform_driver_unregister(&TMIO_OHCI_DRIVER);
  981. error_tmio:
  982. #endif
  983. #ifdef SM501_OHCI_DRIVER
  984. platform_driver_unregister(&SM501_OHCI_DRIVER);
  985. error_sm501:
  986. #endif
  987. #ifdef SSB_OHCI_DRIVER
  988. ssb_driver_unregister(&SSB_OHCI_DRIVER);
  989. error_ssb:
  990. #endif
  991. #ifdef PCI_DRIVER
  992. pci_unregister_driver(&PCI_DRIVER);
  993. error_pci:
  994. #endif
  995. #ifdef SA1111_DRIVER
  996. sa1111_driver_unregister(&SA1111_DRIVER);
  997. error_sa1111:
  998. #endif
  999. #ifdef OF_PLATFORM_DRIVER
  1000. of_unregister_platform_driver(&OF_PLATFORM_DRIVER);
  1001. error_of_platform:
  1002. #endif
  1003. #ifdef PLATFORM_DRIVER
  1004. platform_driver_unregister(&PLATFORM_DRIVER);
  1005. error_platform:
  1006. #endif
  1007. #ifdef PS3_SYSTEM_BUS_DRIVER
  1008. ps3_ohci_driver_unregister(&PS3_SYSTEM_BUS_DRIVER);
  1009. error_ps3:
  1010. #endif
  1011. #ifdef DEBUG
  1012. debugfs_remove(ohci_debug_root);
  1013. ohci_debug_root = NULL;
  1014. error_debug:
  1015. #endif
  1016. clear_bit(USB_OHCI_LOADED, &usb_hcds_loaded);
  1017. return retval;
  1018. }
  1019. module_init(ohci_hcd_mod_init);
  1020. static void __exit ohci_hcd_mod_exit(void)
  1021. {
  1022. #ifdef TMIO_OHCI_DRIVER
  1023. platform_driver_unregister(&TMIO_OHCI_DRIVER);
  1024. #endif
  1025. #ifdef SM501_OHCI_DRIVER
  1026. platform_driver_unregister(&SM501_OHCI_DRIVER);
  1027. #endif
  1028. #ifdef SSB_OHCI_DRIVER
  1029. ssb_driver_unregister(&SSB_OHCI_DRIVER);
  1030. #endif
  1031. #ifdef PCI_DRIVER
  1032. pci_unregister_driver(&PCI_DRIVER);
  1033. #endif
  1034. #ifdef SA1111_DRIVER
  1035. sa1111_driver_unregister(&SA1111_DRIVER);
  1036. #endif
  1037. #ifdef OF_PLATFORM_DRIVER
  1038. of_unregister_platform_driver(&OF_PLATFORM_DRIVER);
  1039. #endif
  1040. #ifdef PLATFORM_DRIVER
  1041. platform_driver_unregister(&PLATFORM_DRIVER);
  1042. #endif
  1043. #ifdef PS3_SYSTEM_BUS_DRIVER
  1044. ps3_ohci_driver_unregister(&PS3_SYSTEM_BUS_DRIVER);
  1045. #endif
  1046. #ifdef DEBUG
  1047. debugfs_remove(ohci_debug_root);
  1048. #endif
  1049. clear_bit(USB_OHCI_LOADED, &usb_hcds_loaded);
  1050. }
  1051. module_exit(ohci_hcd_mod_exit);