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/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; if so we'll just enable it again.
  507. */
  508. if ((ohci->hc_control & OHCI_CTRL_RWC) != 0)
  509. device_set_wakeup_capable(hcd->self.controller, 1);
  510. switch (ohci->hc_control & OHCI_CTRL_HCFS) {
  511. case OHCI_USB_OPER:
  512. temp = 0;
  513. break;
  514. case OHCI_USB_SUSPEND:
  515. case OHCI_USB_RESUME:
  516. ohci->hc_control &= OHCI_CTRL_RWC;
  517. ohci->hc_control |= OHCI_USB_RESUME;
  518. temp = 10 /* msec wait */;
  519. break;
  520. // case OHCI_USB_RESET:
  521. default:
  522. ohci->hc_control &= OHCI_CTRL_RWC;
  523. ohci->hc_control |= OHCI_USB_RESET;
  524. temp = 50 /* msec wait */;
  525. break;
  526. }
  527. ohci_writel (ohci, ohci->hc_control, &ohci->regs->control);
  528. // flush the writes
  529. (void) ohci_readl (ohci, &ohci->regs->control);
  530. msleep(temp);
  531. memset (ohci->hcca, 0, sizeof (struct ohci_hcca));
  532. /* 2msec timelimit here means no irqs/preempt */
  533. spin_lock_irq (&ohci->lock);
  534. retry:
  535. /* HC Reset requires max 10 us delay */
  536. ohci_writel (ohci, OHCI_HCR, &ohci->regs->cmdstatus);
  537. temp = 30; /* ... allow extra time */
  538. while ((ohci_readl (ohci, &ohci->regs->cmdstatus) & OHCI_HCR) != 0) {
  539. if (--temp == 0) {
  540. spin_unlock_irq (&ohci->lock);
  541. ohci_err (ohci, "USB HC reset timed out!\n");
  542. return -1;
  543. }
  544. udelay (1);
  545. }
  546. /* now we're in the SUSPEND state ... must go OPERATIONAL
  547. * within 2msec else HC enters RESUME
  548. *
  549. * ... but some hardware won't init fmInterval "by the book"
  550. * (SiS, OPTi ...), so reset again instead. SiS doesn't need
  551. * this if we write fmInterval after we're OPERATIONAL.
  552. * Unclear about ALi, ServerWorks, and others ... this could
  553. * easily be a longstanding bug in chip init on Linux.
  554. */
  555. if (ohci->flags & OHCI_QUIRK_INITRESET) {
  556. ohci_writel (ohci, ohci->hc_control, &ohci->regs->control);
  557. // flush those writes
  558. (void) ohci_readl (ohci, &ohci->regs->control);
  559. }
  560. /* Tell the controller where the control and bulk lists are
  561. * The lists are empty now. */
  562. ohci_writel (ohci, 0, &ohci->regs->ed_controlhead);
  563. ohci_writel (ohci, 0, &ohci->regs->ed_bulkhead);
  564. /* a reset clears this */
  565. ohci_writel (ohci, (u32) ohci->hcca_dma, &ohci->regs->hcca);
  566. periodic_reinit (ohci);
  567. /* some OHCI implementations are finicky about how they init.
  568. * bogus values here mean not even enumeration could work.
  569. */
  570. if ((ohci_readl (ohci, &ohci->regs->fminterval) & 0x3fff0000) == 0
  571. || !ohci_readl (ohci, &ohci->regs->periodicstart)) {
  572. if (!(ohci->flags & OHCI_QUIRK_INITRESET)) {
  573. ohci->flags |= OHCI_QUIRK_INITRESET;
  574. ohci_dbg (ohci, "enabling initreset quirk\n");
  575. goto retry;
  576. }
  577. spin_unlock_irq (&ohci->lock);
  578. ohci_err (ohci, "init err (%08x %04x)\n",
  579. ohci_readl (ohci, &ohci->regs->fminterval),
  580. ohci_readl (ohci, &ohci->regs->periodicstart));
  581. return -EOVERFLOW;
  582. }
  583. /* use rhsc irqs after khubd is fully initialized */
  584. hcd->poll_rh = 1;
  585. hcd->uses_new_polling = 1;
  586. /* start controller operations */
  587. ohci->hc_control &= OHCI_CTRL_RWC;
  588. ohci->hc_control |= OHCI_CONTROL_INIT | OHCI_USB_OPER;
  589. ohci_writel (ohci, ohci->hc_control, &ohci->regs->control);
  590. hcd->state = HC_STATE_RUNNING;
  591. /* wake on ConnectStatusChange, matching external hubs */
  592. ohci_writel (ohci, RH_HS_DRWE, &ohci->regs->roothub.status);
  593. /* Choose the interrupts we care about now, others later on demand */
  594. mask = OHCI_INTR_INIT;
  595. ohci_writel (ohci, ~0, &ohci->regs->intrstatus);
  596. ohci_writel (ohci, mask, &ohci->regs->intrenable);
  597. /* handle root hub init quirks ... */
  598. temp = roothub_a (ohci);
  599. temp &= ~(RH_A_PSM | RH_A_OCPM);
  600. if (ohci->flags & OHCI_QUIRK_SUPERIO) {
  601. /* NSC 87560 and maybe others */
  602. temp |= RH_A_NOCP;
  603. temp &= ~(RH_A_POTPGT | RH_A_NPS);
  604. ohci_writel (ohci, temp, &ohci->regs->roothub.a);
  605. } else if ((ohci->flags & OHCI_QUIRK_AMD756) ||
  606. (ohci->flags & OHCI_QUIRK_HUB_POWER)) {
  607. /* hub power always on; required for AMD-756 and some
  608. * Mac platforms. ganged overcurrent reporting, if any.
  609. */
  610. temp |= RH_A_NPS;
  611. ohci_writel (ohci, temp, &ohci->regs->roothub.a);
  612. }
  613. ohci_writel (ohci, RH_HS_LPSC, &ohci->regs->roothub.status);
  614. ohci_writel (ohci, (temp & RH_A_NPS) ? 0 : RH_B_PPCM,
  615. &ohci->regs->roothub.b);
  616. // flush those writes
  617. (void) ohci_readl (ohci, &ohci->regs->control);
  618. ohci->next_statechange = jiffies + STATECHANGE_DELAY;
  619. spin_unlock_irq (&ohci->lock);
  620. // POTPGT delay is bits 24-31, in 2 ms units.
  621. mdelay ((temp >> 23) & 0x1fe);
  622. hcd->state = HC_STATE_RUNNING;
  623. if (quirk_zfmicro(ohci)) {
  624. /* Create timer to watch for bad queue state on ZF Micro */
  625. setup_timer(&ohci->unlink_watchdog, unlink_watchdog_func,
  626. (unsigned long) ohci);
  627. ohci->eds_scheduled = 0;
  628. ohci->ed_to_check = NULL;
  629. }
  630. ohci_dump (ohci, 1);
  631. return 0;
  632. }
  633. /*-------------------------------------------------------------------------*/
  634. /* an interrupt happens */
  635. static irqreturn_t ohci_irq (struct usb_hcd *hcd)
  636. {
  637. struct ohci_hcd *ohci = hcd_to_ohci (hcd);
  638. struct ohci_regs __iomem *regs = ohci->regs;
  639. int ints;
  640. /* Read interrupt status (and flush pending writes). We ignore the
  641. * optimization of checking the LSB of hcca->done_head; it doesn't
  642. * work on all systems (edge triggering for OHCI can be a factor).
  643. */
  644. ints = ohci_readl(ohci, &regs->intrstatus);
  645. /* Check for an all 1's result which is a typical consequence
  646. * of dead, unclocked, or unplugged (CardBus...) devices
  647. */
  648. if (ints == ~(u32)0) {
  649. disable (ohci);
  650. ohci_dbg (ohci, "device removed!\n");
  651. return IRQ_HANDLED;
  652. }
  653. /* We only care about interrupts that are enabled */
  654. ints &= ohci_readl(ohci, &regs->intrenable);
  655. /* interrupt for some other device? */
  656. if (ints == 0)
  657. return IRQ_NOTMINE;
  658. if (ints & OHCI_INTR_UE) {
  659. // e.g. due to PCI Master/Target Abort
  660. if (quirk_nec(ohci)) {
  661. /* Workaround for a silicon bug in some NEC chips used
  662. * in Apple's PowerBooks. Adapted from Darwin code.
  663. */
  664. ohci_err (ohci, "OHCI Unrecoverable Error, scheduling NEC chip restart\n");
  665. ohci_writel (ohci, OHCI_INTR_UE, &regs->intrdisable);
  666. schedule_work (&ohci->nec_work);
  667. } else {
  668. disable (ohci);
  669. ohci_err (ohci, "OHCI Unrecoverable Error, disabled\n");
  670. }
  671. ohci_dump (ohci, 1);
  672. ohci_usb_reset (ohci);
  673. }
  674. if (ints & OHCI_INTR_RHSC) {
  675. ohci_vdbg(ohci, "rhsc\n");
  676. ohci->next_statechange = jiffies + STATECHANGE_DELAY;
  677. ohci_writel(ohci, OHCI_INTR_RD | OHCI_INTR_RHSC,
  678. &regs->intrstatus);
  679. /* NOTE: Vendors didn't always make the same implementation
  680. * choices for RHSC. Many followed the spec; RHSC triggers
  681. * on an edge, like setting and maybe clearing a port status
  682. * change bit. With others it's level-triggered, active
  683. * until khubd clears all the port status change bits. We'll
  684. * always disable it here and rely on polling until khubd
  685. * re-enables it.
  686. */
  687. ohci_writel(ohci, OHCI_INTR_RHSC, &regs->intrdisable);
  688. usb_hcd_poll_rh_status(hcd);
  689. }
  690. /* For connect and disconnect events, we expect the controller
  691. * to turn on RHSC along with RD. But for remote wakeup events
  692. * this might not happen.
  693. */
  694. else if (ints & OHCI_INTR_RD) {
  695. ohci_vdbg(ohci, "resume detect\n");
  696. ohci_writel(ohci, OHCI_INTR_RD, &regs->intrstatus);
  697. hcd->poll_rh = 1;
  698. if (ohci->autostop) {
  699. spin_lock (&ohci->lock);
  700. ohci_rh_resume (ohci);
  701. spin_unlock (&ohci->lock);
  702. } else
  703. usb_hcd_resume_root_hub(hcd);
  704. }
  705. if (ints & OHCI_INTR_WDH) {
  706. spin_lock (&ohci->lock);
  707. dl_done_list (ohci);
  708. spin_unlock (&ohci->lock);
  709. }
  710. if (quirk_zfmicro(ohci) && (ints & OHCI_INTR_SF)) {
  711. spin_lock(&ohci->lock);
  712. if (ohci->ed_to_check) {
  713. struct ed *ed = ohci->ed_to_check;
  714. if (check_ed(ohci, ed)) {
  715. /* HC thinks the TD list is empty; HCD knows
  716. * at least one TD is outstanding
  717. */
  718. if (--ohci->zf_delay == 0) {
  719. struct td *td = list_entry(
  720. ed->td_list.next,
  721. struct td, td_list);
  722. ohci_warn(ohci,
  723. "Reclaiming orphan TD %p\n",
  724. td);
  725. takeback_td(ohci, td);
  726. ohci->ed_to_check = NULL;
  727. }
  728. } else
  729. ohci->ed_to_check = NULL;
  730. }
  731. spin_unlock(&ohci->lock);
  732. }
  733. /* could track INTR_SO to reduce available PCI/... bandwidth */
  734. /* handle any pending URB/ED unlinks, leaving INTR_SF enabled
  735. * when there's still unlinking to be done (next frame).
  736. */
  737. spin_lock (&ohci->lock);
  738. if (ohci->ed_rm_list)
  739. finish_unlinks (ohci, ohci_frame_no(ohci));
  740. if ((ints & OHCI_INTR_SF) != 0
  741. && !ohci->ed_rm_list
  742. && !ohci->ed_to_check
  743. && HC_IS_RUNNING(hcd->state))
  744. ohci_writel (ohci, OHCI_INTR_SF, &regs->intrdisable);
  745. spin_unlock (&ohci->lock);
  746. if (HC_IS_RUNNING(hcd->state)) {
  747. ohci_writel (ohci, ints, &regs->intrstatus);
  748. ohci_writel (ohci, OHCI_INTR_MIE, &regs->intrenable);
  749. // flush those writes
  750. (void) ohci_readl (ohci, &ohci->regs->control);
  751. }
  752. return IRQ_HANDLED;
  753. }
  754. /*-------------------------------------------------------------------------*/
  755. static void ohci_stop (struct usb_hcd *hcd)
  756. {
  757. struct ohci_hcd *ohci = hcd_to_ohci (hcd);
  758. ohci_dump (ohci, 1);
  759. flush_scheduled_work();
  760. ohci_usb_reset (ohci);
  761. ohci_writel (ohci, OHCI_INTR_MIE, &ohci->regs->intrdisable);
  762. free_irq(hcd->irq, hcd);
  763. hcd->irq = -1;
  764. if (quirk_zfmicro(ohci))
  765. del_timer(&ohci->unlink_watchdog);
  766. if (quirk_amdiso(ohci))
  767. amd_iso_dev_put();
  768. remove_debug_files (ohci);
  769. ohci_mem_cleanup (ohci);
  770. if (ohci->hcca) {
  771. dma_free_coherent (hcd->self.controller,
  772. sizeof *ohci->hcca,
  773. ohci->hcca, ohci->hcca_dma);
  774. ohci->hcca = NULL;
  775. ohci->hcca_dma = 0;
  776. }
  777. }
  778. /*-------------------------------------------------------------------------*/
  779. #if defined(CONFIG_PM) || defined(CONFIG_PCI)
  780. /* must not be called from interrupt context */
  781. static int ohci_restart (struct ohci_hcd *ohci)
  782. {
  783. int temp;
  784. int i;
  785. struct urb_priv *priv;
  786. spin_lock_irq(&ohci->lock);
  787. disable (ohci);
  788. /* Recycle any "live" eds/tds (and urbs). */
  789. if (!list_empty (&ohci->pending))
  790. ohci_dbg(ohci, "abort schedule...\n");
  791. list_for_each_entry (priv, &ohci->pending, pending) {
  792. struct urb *urb = priv->td[0]->urb;
  793. struct ed *ed = priv->ed;
  794. switch (ed->state) {
  795. case ED_OPER:
  796. ed->state = ED_UNLINK;
  797. ed->hwINFO |= cpu_to_hc32(ohci, ED_DEQUEUE);
  798. ed_deschedule (ohci, ed);
  799. ed->ed_next = ohci->ed_rm_list;
  800. ed->ed_prev = NULL;
  801. ohci->ed_rm_list = ed;
  802. /* FALLTHROUGH */
  803. case ED_UNLINK:
  804. break;
  805. default:
  806. ohci_dbg(ohci, "bogus ed %p state %d\n",
  807. ed, ed->state);
  808. }
  809. if (!urb->unlinked)
  810. urb->unlinked = -ESHUTDOWN;
  811. }
  812. finish_unlinks (ohci, 0);
  813. spin_unlock_irq(&ohci->lock);
  814. /* paranoia, in case that didn't work: */
  815. /* empty the interrupt branches */
  816. for (i = 0; i < NUM_INTS; i++) ohci->load [i] = 0;
  817. for (i = 0; i < NUM_INTS; i++) ohci->hcca->int_table [i] = 0;
  818. /* no EDs to remove */
  819. ohci->ed_rm_list = NULL;
  820. /* empty control and bulk lists */
  821. ohci->ed_controltail = NULL;
  822. ohci->ed_bulktail = NULL;
  823. if ((temp = ohci_run (ohci)) < 0) {
  824. ohci_err (ohci, "can't restart, %d\n", temp);
  825. return temp;
  826. }
  827. ohci_dbg(ohci, "restart complete\n");
  828. return 0;
  829. }
  830. #endif
  831. /*-------------------------------------------------------------------------*/
  832. MODULE_AUTHOR (DRIVER_AUTHOR);
  833. MODULE_DESCRIPTION(DRIVER_DESC);
  834. MODULE_LICENSE ("GPL");
  835. #ifdef CONFIG_PCI
  836. #include "ohci-pci.c"
  837. #define PCI_DRIVER ohci_pci_driver
  838. #endif
  839. #if defined(CONFIG_ARCH_SA1100) && defined(CONFIG_SA1111)
  840. #include "ohci-sa1111.c"
  841. #define SA1111_DRIVER ohci_hcd_sa1111_driver
  842. #endif
  843. #ifdef CONFIG_ARCH_S3C2410
  844. #include "ohci-s3c2410.c"
  845. #define PLATFORM_DRIVER ohci_hcd_s3c2410_driver
  846. #endif
  847. #ifdef CONFIG_ARCH_OMAP
  848. #include "ohci-omap.c"
  849. #define PLATFORM_DRIVER ohci_hcd_omap_driver
  850. #endif
  851. #ifdef CONFIG_ARCH_LH7A404
  852. #include "ohci-lh7a404.c"
  853. #define PLATFORM_DRIVER ohci_hcd_lh7a404_driver
  854. #endif
  855. #if defined(CONFIG_PXA27x) || defined(CONFIG_PXA3xx)
  856. #include "ohci-pxa27x.c"
  857. #define PLATFORM_DRIVER ohci_hcd_pxa27x_driver
  858. #endif
  859. #ifdef CONFIG_ARCH_EP93XX
  860. #include "ohci-ep93xx.c"
  861. #define PLATFORM_DRIVER ohci_hcd_ep93xx_driver
  862. #endif
  863. #ifdef CONFIG_SOC_AU1X00
  864. #include "ohci-au1xxx.c"
  865. #define PLATFORM_DRIVER ohci_hcd_au1xxx_driver
  866. #endif
  867. #ifdef CONFIG_PNX8550
  868. #include "ohci-pnx8550.c"
  869. #define PLATFORM_DRIVER ohci_hcd_pnx8550_driver
  870. #endif
  871. #ifdef CONFIG_USB_OHCI_HCD_PPC_SOC
  872. #include "ohci-ppc-soc.c"
  873. #define PLATFORM_DRIVER ohci_hcd_ppc_soc_driver
  874. #endif
  875. #ifdef CONFIG_ARCH_AT91
  876. #include "ohci-at91.c"
  877. #define PLATFORM_DRIVER ohci_hcd_at91_driver
  878. #endif
  879. #ifdef CONFIG_ARCH_PNX4008
  880. #include "ohci-pnx4008.c"
  881. #define PLATFORM_DRIVER usb_hcd_pnx4008_driver
  882. #endif
  883. #if defined(CONFIG_CPU_SUBTYPE_SH7720) || \
  884. defined(CONFIG_CPU_SUBTYPE_SH7721) || \
  885. defined(CONFIG_CPU_SUBTYPE_SH7763)
  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", NULL);
  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);