ohci-hcd.c 32 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241
  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. #if defined(CONFIG_ARCH_S3C2410) || defined(CONFIG_ARCH_S3C64XX)
  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. defined(CONFIG_CPU_SUBTYPE_SH7786)
  887. #include "ohci-sh.c"
  888. #define PLATFORM_DRIVER ohci_hcd_sh_driver
  889. #endif
  890. #ifdef CONFIG_USB_OHCI_HCD_PPC_OF
  891. #include "ohci-ppc-of.c"
  892. #define OF_PLATFORM_DRIVER ohci_hcd_ppc_of_driver
  893. #endif
  894. #ifdef CONFIG_PPC_PS3
  895. #include "ohci-ps3.c"
  896. #define PS3_SYSTEM_BUS_DRIVER ps3_ohci_driver
  897. #endif
  898. #ifdef CONFIG_USB_OHCI_HCD_SSB
  899. #include "ohci-ssb.c"
  900. #define SSB_OHCI_DRIVER ssb_ohci_driver
  901. #endif
  902. #ifdef CONFIG_MFD_SM501
  903. #include "ohci-sm501.c"
  904. #define SM501_OHCI_DRIVER ohci_hcd_sm501_driver
  905. #endif
  906. #ifdef CONFIG_MFD_TC6393XB
  907. #include "ohci-tmio.c"
  908. #define TMIO_OHCI_DRIVER ohci_hcd_tmio_driver
  909. #endif
  910. #if !defined(PCI_DRIVER) && \
  911. !defined(PLATFORM_DRIVER) && \
  912. !defined(OF_PLATFORM_DRIVER) && \
  913. !defined(SA1111_DRIVER) && \
  914. !defined(PS3_SYSTEM_BUS_DRIVER) && \
  915. !defined(SM501_OHCI_DRIVER) && \
  916. !defined(TMIO_OHCI_DRIVER) && \
  917. !defined(SSB_OHCI_DRIVER)
  918. #error "missing bus glue for ohci-hcd"
  919. #endif
  920. static int __init ohci_hcd_mod_init(void)
  921. {
  922. int retval = 0;
  923. if (usb_disabled())
  924. return -ENODEV;
  925. printk(KERN_INFO "%s: " DRIVER_DESC "\n", hcd_name);
  926. pr_debug ("%s: block sizes: ed %Zd td %Zd\n", hcd_name,
  927. sizeof (struct ed), sizeof (struct td));
  928. set_bit(USB_OHCI_LOADED, &usb_hcds_loaded);
  929. #ifdef DEBUG
  930. ohci_debug_root = debugfs_create_dir("ohci", NULL);
  931. if (!ohci_debug_root) {
  932. retval = -ENOENT;
  933. goto error_debug;
  934. }
  935. #endif
  936. #ifdef PS3_SYSTEM_BUS_DRIVER
  937. retval = ps3_ohci_driver_register(&PS3_SYSTEM_BUS_DRIVER);
  938. if (retval < 0)
  939. goto error_ps3;
  940. #endif
  941. #ifdef PLATFORM_DRIVER
  942. retval = platform_driver_register(&PLATFORM_DRIVER);
  943. if (retval < 0)
  944. goto error_platform;
  945. #endif
  946. #ifdef OF_PLATFORM_DRIVER
  947. retval = of_register_platform_driver(&OF_PLATFORM_DRIVER);
  948. if (retval < 0)
  949. goto error_of_platform;
  950. #endif
  951. #ifdef SA1111_DRIVER
  952. retval = sa1111_driver_register(&SA1111_DRIVER);
  953. if (retval < 0)
  954. goto error_sa1111;
  955. #endif
  956. #ifdef PCI_DRIVER
  957. retval = pci_register_driver(&PCI_DRIVER);
  958. if (retval < 0)
  959. goto error_pci;
  960. #endif
  961. #ifdef SSB_OHCI_DRIVER
  962. retval = ssb_driver_register(&SSB_OHCI_DRIVER);
  963. if (retval)
  964. goto error_ssb;
  965. #endif
  966. #ifdef SM501_OHCI_DRIVER
  967. retval = platform_driver_register(&SM501_OHCI_DRIVER);
  968. if (retval < 0)
  969. goto error_sm501;
  970. #endif
  971. #ifdef TMIO_OHCI_DRIVER
  972. retval = platform_driver_register(&TMIO_OHCI_DRIVER);
  973. if (retval < 0)
  974. goto error_tmio;
  975. #endif
  976. return retval;
  977. /* Error path */
  978. #ifdef TMIO_OHCI_DRIVER
  979. platform_driver_unregister(&TMIO_OHCI_DRIVER);
  980. error_tmio:
  981. #endif
  982. #ifdef SM501_OHCI_DRIVER
  983. platform_driver_unregister(&SM501_OHCI_DRIVER);
  984. error_sm501:
  985. #endif
  986. #ifdef SSB_OHCI_DRIVER
  987. ssb_driver_unregister(&SSB_OHCI_DRIVER);
  988. error_ssb:
  989. #endif
  990. #ifdef PCI_DRIVER
  991. pci_unregister_driver(&PCI_DRIVER);
  992. error_pci:
  993. #endif
  994. #ifdef SA1111_DRIVER
  995. sa1111_driver_unregister(&SA1111_DRIVER);
  996. error_sa1111:
  997. #endif
  998. #ifdef OF_PLATFORM_DRIVER
  999. of_unregister_platform_driver(&OF_PLATFORM_DRIVER);
  1000. error_of_platform:
  1001. #endif
  1002. #ifdef PLATFORM_DRIVER
  1003. platform_driver_unregister(&PLATFORM_DRIVER);
  1004. error_platform:
  1005. #endif
  1006. #ifdef PS3_SYSTEM_BUS_DRIVER
  1007. ps3_ohci_driver_unregister(&PS3_SYSTEM_BUS_DRIVER);
  1008. error_ps3:
  1009. #endif
  1010. #ifdef DEBUG
  1011. debugfs_remove(ohci_debug_root);
  1012. ohci_debug_root = NULL;
  1013. error_debug:
  1014. #endif
  1015. clear_bit(USB_OHCI_LOADED, &usb_hcds_loaded);
  1016. return retval;
  1017. }
  1018. module_init(ohci_hcd_mod_init);
  1019. static void __exit ohci_hcd_mod_exit(void)
  1020. {
  1021. #ifdef TMIO_OHCI_DRIVER
  1022. platform_driver_unregister(&TMIO_OHCI_DRIVER);
  1023. #endif
  1024. #ifdef SM501_OHCI_DRIVER
  1025. platform_driver_unregister(&SM501_OHCI_DRIVER);
  1026. #endif
  1027. #ifdef SSB_OHCI_DRIVER
  1028. ssb_driver_unregister(&SSB_OHCI_DRIVER);
  1029. #endif
  1030. #ifdef PCI_DRIVER
  1031. pci_unregister_driver(&PCI_DRIVER);
  1032. #endif
  1033. #ifdef SA1111_DRIVER
  1034. sa1111_driver_unregister(&SA1111_DRIVER);
  1035. #endif
  1036. #ifdef OF_PLATFORM_DRIVER
  1037. of_unregister_platform_driver(&OF_PLATFORM_DRIVER);
  1038. #endif
  1039. #ifdef PLATFORM_DRIVER
  1040. platform_driver_unregister(&PLATFORM_DRIVER);
  1041. #endif
  1042. #ifdef PS3_SYSTEM_BUS_DRIVER
  1043. ps3_ohci_driver_unregister(&PS3_SYSTEM_BUS_DRIVER);
  1044. #endif
  1045. #ifdef DEBUG
  1046. debugfs_remove(ohci_debug_root);
  1047. #endif
  1048. clear_bit(USB_OHCI_LOADED, &usb_hcds_loaded);
  1049. }
  1050. module_exit(ohci_hcd_mod_exit);