ohci-hcd.c 32 KB

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