ehci-hcd.c 34 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276
  1. /*
  2. * Copyright (c) 2000-2004 by David Brownell
  3. *
  4. * This program is free software; you can redistribute it and/or modify it
  5. * under the terms of the GNU General Public License as published by the
  6. * Free Software Foundation; either version 2 of the License, or (at your
  7. * option) any later version.
  8. *
  9. * This program is distributed in the hope that it will be useful, but
  10. * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  11. * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
  12. * for more details.
  13. *
  14. * You should have received a copy of the GNU General Public License
  15. * along with this program; if not, write to the Free Software Foundation,
  16. * Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  17. */
  18. #include <linux/config.h>
  19. #ifdef CONFIG_USB_DEBUG
  20. #define DEBUG
  21. #else
  22. #undef DEBUG
  23. #endif
  24. #include <linux/module.h>
  25. #include <linux/pci.h>
  26. #include <linux/dmapool.h>
  27. #include <linux/kernel.h>
  28. #include <linux/delay.h>
  29. #include <linux/ioport.h>
  30. #include <linux/sched.h>
  31. #include <linux/slab.h>
  32. #include <linux/smp_lock.h>
  33. #include <linux/errno.h>
  34. #include <linux/init.h>
  35. #include <linux/timer.h>
  36. #include <linux/list.h>
  37. #include <linux/interrupt.h>
  38. #include <linux/reboot.h>
  39. #include <linux/usb.h>
  40. #include <linux/moduleparam.h>
  41. #include <linux/dma-mapping.h>
  42. #include "../core/hcd.h"
  43. #include <asm/byteorder.h>
  44. #include <asm/io.h>
  45. #include <asm/irq.h>
  46. #include <asm/system.h>
  47. #include <asm/unaligned.h>
  48. /*-------------------------------------------------------------------------*/
  49. /*
  50. * EHCI hc_driver implementation ... experimental, incomplete.
  51. * Based on the final 1.0 register interface specification.
  52. *
  53. * USB 2.0 shows up in upcoming www.pcmcia.org technology.
  54. * First was PCMCIA, like ISA; then CardBus, which is PCI.
  55. * Next comes "CardBay", using USB 2.0 signals.
  56. *
  57. * Contains additional contributions by Brad Hards, Rory Bolt, and others.
  58. * Special thanks to Intel and VIA for providing host controllers to
  59. * test this driver on, and Cypress (including In-System Design) for
  60. * providing early devices for those host controllers to talk to!
  61. *
  62. * HISTORY:
  63. *
  64. * 2004-05-10 Root hub and PCI suspend/resume support; remote wakeup. (db)
  65. * 2004-02-24 Replace pci_* with generic dma_* API calls (dsaxena@plexity.net)
  66. * 2003-12-29 Rewritten high speed iso transfer support (by Michal Sojka,
  67. * <sojkam@centrum.cz>, updates by DB).
  68. *
  69. * 2002-11-29 Correct handling for hw async_next register.
  70. * 2002-08-06 Handling for bulk and interrupt transfers is mostly shared;
  71. * only scheduling is different, no arbitrary limitations.
  72. * 2002-07-25 Sanity check PCI reads, mostly for better cardbus support,
  73. * clean up HC run state handshaking.
  74. * 2002-05-24 Preliminary FS/LS interrupts, using scheduling shortcuts
  75. * 2002-05-11 Clear TT errors for FS/LS ctrl/bulk. Fill in some other
  76. * missing pieces: enabling 64bit dma, handoff from BIOS/SMM.
  77. * 2002-05-07 Some error path cleanups to report better errors; wmb();
  78. * use non-CVS version id; better iso bandwidth claim.
  79. * 2002-04-19 Control/bulk/interrupt submit no longer uses giveback() on
  80. * errors in submit path. Bugfixes to interrupt scheduling/processing.
  81. * 2002-03-05 Initial high-speed ISO support; reduce ITD memory; shift
  82. * more checking to generic hcd framework (db). Make it work with
  83. * Philips EHCI; reduce PCI traffic; shorten IRQ path (Rory Bolt).
  84. * 2002-01-14 Minor cleanup; version synch.
  85. * 2002-01-08 Fix roothub handoff of FS/LS to companion controllers.
  86. * 2002-01-04 Control/Bulk queuing behaves.
  87. *
  88. * 2001-12-12 Initial patch version for Linux 2.5.1 kernel.
  89. * 2001-June Works with usb-storage and NEC EHCI on 2.4
  90. */
  91. #define DRIVER_VERSION "10 Dec 2004"
  92. #define DRIVER_AUTHOR "David Brownell"
  93. #define DRIVER_DESC "USB 2.0 'Enhanced' Host Controller (EHCI) Driver"
  94. static const char hcd_name [] = "ehci_hcd";
  95. #undef EHCI_VERBOSE_DEBUG
  96. #undef EHCI_URB_TRACE
  97. #ifdef DEBUG
  98. #define EHCI_STATS
  99. #endif
  100. /* magic numbers that can affect system performance */
  101. #define EHCI_TUNE_CERR 3 /* 0-3 qtd retries; 0 == don't stop */
  102. #define EHCI_TUNE_RL_HS 4 /* nak throttle; see 4.9 */
  103. #define EHCI_TUNE_RL_TT 0
  104. #define EHCI_TUNE_MULT_HS 1 /* 1-3 transactions/uframe; 4.10.3 */
  105. #define EHCI_TUNE_MULT_TT 1
  106. #define EHCI_TUNE_FLS 2 /* (small) 256 frame schedule */
  107. #define EHCI_IAA_JIFFIES (HZ/100) /* arbitrary; ~10 msec */
  108. #define EHCI_IO_JIFFIES (HZ/10) /* io watchdog > irq_thresh */
  109. #define EHCI_ASYNC_JIFFIES (HZ/20) /* async idle timeout */
  110. #define EHCI_SHRINK_JIFFIES (HZ/200) /* async qh unlink delay */
  111. /* Initial IRQ latency: faster than hw default */
  112. static int log2_irq_thresh = 0; // 0 to 6
  113. module_param (log2_irq_thresh, int, S_IRUGO);
  114. MODULE_PARM_DESC (log2_irq_thresh, "log2 IRQ latency, 1-64 microframes");
  115. /* initial park setting: slower than hw default */
  116. static unsigned park = 0;
  117. module_param (park, uint, S_IRUGO);
  118. MODULE_PARM_DESC (park, "park setting; 1-3 back-to-back async packets");
  119. #define INTR_MASK (STS_IAA | STS_FATAL | STS_PCD | STS_ERR | STS_INT)
  120. /*-------------------------------------------------------------------------*/
  121. #include "ehci.h"
  122. #include "ehci-dbg.c"
  123. /*-------------------------------------------------------------------------*/
  124. /*
  125. * handshake - spin reading hc until handshake completes or fails
  126. * @ptr: address of hc register to be read
  127. * @mask: bits to look at in result of read
  128. * @done: value of those bits when handshake succeeds
  129. * @usec: timeout in microseconds
  130. *
  131. * Returns negative errno, or zero on success
  132. *
  133. * Success happens when the "mask" bits have the specified value (hardware
  134. * handshake done). There are two failure modes: "usec" have passed (major
  135. * hardware flakeout), or the register reads as all-ones (hardware removed).
  136. *
  137. * That last failure should_only happen in cases like physical cardbus eject
  138. * before driver shutdown. But it also seems to be caused by bugs in cardbus
  139. * bridge shutdown: shutting down the bridge before the devices using it.
  140. */
  141. static int handshake (void __iomem *ptr, u32 mask, u32 done, int usec)
  142. {
  143. u32 result;
  144. do {
  145. result = readl (ptr);
  146. if (result == ~(u32)0) /* card removed */
  147. return -ENODEV;
  148. result &= mask;
  149. if (result == done)
  150. return 0;
  151. udelay (1);
  152. usec--;
  153. } while (usec > 0);
  154. return -ETIMEDOUT;
  155. }
  156. /* force HC to halt state from unknown (EHCI spec section 2.3) */
  157. static int ehci_halt (struct ehci_hcd *ehci)
  158. {
  159. u32 temp = readl (&ehci->regs->status);
  160. if ((temp & STS_HALT) != 0)
  161. return 0;
  162. temp = readl (&ehci->regs->command);
  163. temp &= ~CMD_RUN;
  164. writel (temp, &ehci->regs->command);
  165. return handshake (&ehci->regs->status, STS_HALT, STS_HALT, 16 * 125);
  166. }
  167. /* put TDI/ARC silicon into EHCI mode */
  168. static void tdi_reset (struct ehci_hcd *ehci)
  169. {
  170. u32 __iomem *reg_ptr;
  171. u32 tmp;
  172. reg_ptr = (u32 __iomem *)(((u8 __iomem *)ehci->regs) + 0x68);
  173. tmp = readl (reg_ptr);
  174. tmp |= 0x3;
  175. writel (tmp, reg_ptr);
  176. }
  177. /* reset a non-running (STS_HALT == 1) controller */
  178. static int ehci_reset (struct ehci_hcd *ehci)
  179. {
  180. int retval;
  181. u32 command = readl (&ehci->regs->command);
  182. command |= CMD_RESET;
  183. dbg_cmd (ehci, "reset", command);
  184. writel (command, &ehci->regs->command);
  185. ehci_to_hcd(ehci)->state = HC_STATE_HALT;
  186. ehci->next_statechange = jiffies;
  187. retval = handshake (&ehci->regs->command, CMD_RESET, 0, 250 * 1000);
  188. if (retval)
  189. return retval;
  190. if (ehci_is_TDI(ehci))
  191. tdi_reset (ehci);
  192. return retval;
  193. }
  194. /* idle the controller (from running) */
  195. static void ehci_quiesce (struct ehci_hcd *ehci)
  196. {
  197. u32 temp;
  198. #ifdef DEBUG
  199. if (!HC_IS_RUNNING (ehci_to_hcd(ehci)->state))
  200. BUG ();
  201. #endif
  202. /* wait for any schedule enables/disables to take effect */
  203. temp = readl (&ehci->regs->command) << 10;
  204. temp &= STS_ASS | STS_PSS;
  205. if (handshake (&ehci->regs->status, STS_ASS | STS_PSS,
  206. temp, 16 * 125) != 0) {
  207. ehci_to_hcd(ehci)->state = HC_STATE_HALT;
  208. return;
  209. }
  210. /* then disable anything that's still active */
  211. temp = readl (&ehci->regs->command);
  212. temp &= ~(CMD_ASE | CMD_IAAD | CMD_PSE);
  213. writel (temp, &ehci->regs->command);
  214. /* hardware can take 16 microframes to turn off ... */
  215. if (handshake (&ehci->regs->status, STS_ASS | STS_PSS,
  216. 0, 16 * 125) != 0) {
  217. ehci_to_hcd(ehci)->state = HC_STATE_HALT;
  218. return;
  219. }
  220. }
  221. /*-------------------------------------------------------------------------*/
  222. static void ehci_work(struct ehci_hcd *ehci, struct pt_regs *regs);
  223. #include "ehci-hub.c"
  224. #include "ehci-mem.c"
  225. #include "ehci-q.c"
  226. #include "ehci-sched.c"
  227. /*-------------------------------------------------------------------------*/
  228. static void ehci_watchdog (unsigned long param)
  229. {
  230. struct ehci_hcd *ehci = (struct ehci_hcd *) param;
  231. unsigned long flags;
  232. spin_lock_irqsave (&ehci->lock, flags);
  233. /* lost IAA irqs wedge things badly; seen with a vt8235 */
  234. if (ehci->reclaim) {
  235. u32 status = readl (&ehci->regs->status);
  236. if (status & STS_IAA) {
  237. ehci_vdbg (ehci, "lost IAA\n");
  238. COUNT (ehci->stats.lost_iaa);
  239. writel (STS_IAA, &ehci->regs->status);
  240. ehci->reclaim_ready = 1;
  241. }
  242. }
  243. /* stop async processing after it's idled a bit */
  244. if (test_bit (TIMER_ASYNC_OFF, &ehci->actions))
  245. start_unlink_async (ehci, ehci->async);
  246. /* ehci could run by timer, without IRQs ... */
  247. ehci_work (ehci, NULL);
  248. spin_unlock_irqrestore (&ehci->lock, flags);
  249. }
  250. #ifdef CONFIG_PCI
  251. /* EHCI 0.96 (and later) section 5.1 says how to kick BIOS/SMM/...
  252. * off the controller (maybe it can boot from highspeed USB disks).
  253. */
  254. static int bios_handoff (struct ehci_hcd *ehci, int where, u32 cap)
  255. {
  256. struct pci_dev *pdev = to_pci_dev(ehci_to_hcd(ehci)->self.controller);
  257. /* always say Linux will own the hardware */
  258. pci_write_config_byte(pdev, where + 3, 1);
  259. /* maybe wait a while for BIOS to respond */
  260. if (cap & (1 << 16)) {
  261. int msec = 5000;
  262. do {
  263. msleep(10);
  264. msec -= 10;
  265. pci_read_config_dword(pdev, where, &cap);
  266. } while ((cap & (1 << 16)) && msec);
  267. if (cap & (1 << 16)) {
  268. ehci_err(ehci, "BIOS handoff failed (%d, %08x)\n",
  269. where, cap);
  270. // some BIOS versions seem buggy...
  271. // return 1;
  272. ehci_warn (ehci, "continuing after BIOS bug...\n");
  273. /* disable all SMIs, and clear "BIOS owns" flag */
  274. pci_write_config_dword(pdev, where + 4, 0);
  275. pci_write_config_byte(pdev, where + 2, 0);
  276. } else
  277. ehci_dbg(ehci, "BIOS handoff succeeded\n");
  278. }
  279. return 0;
  280. }
  281. #endif
  282. static int
  283. ehci_reboot (struct notifier_block *self, unsigned long code, void *null)
  284. {
  285. struct ehci_hcd *ehci;
  286. ehci = container_of (self, struct ehci_hcd, reboot_notifier);
  287. /* make BIOS/etc use companion controller during reboot */
  288. writel (0, &ehci->regs->configured_flag);
  289. return 0;
  290. }
  291. static void ehci_port_power (struct ehci_hcd *ehci, int is_on)
  292. {
  293. unsigned port;
  294. if (!HCS_PPC (ehci->hcs_params))
  295. return;
  296. ehci_dbg (ehci, "...power%s ports...\n", is_on ? "up" : "down");
  297. for (port = HCS_N_PORTS (ehci->hcs_params); port > 0; )
  298. (void) ehci_hub_control(ehci_to_hcd(ehci),
  299. is_on ? SetPortFeature : ClearPortFeature,
  300. USB_PORT_FEAT_POWER,
  301. port--, NULL, 0);
  302. msleep(20);
  303. }
  304. /* called by khubd or root hub init threads */
  305. static int ehci_hc_reset (struct usb_hcd *hcd)
  306. {
  307. struct ehci_hcd *ehci = hcd_to_ehci (hcd);
  308. u32 temp;
  309. unsigned count = 256/4;
  310. spin_lock_init (&ehci->lock);
  311. ehci->caps = hcd->regs;
  312. ehci->regs = hcd->regs + HC_LENGTH (readl (&ehci->caps->hc_capbase));
  313. dbg_hcs_params (ehci, "reset");
  314. dbg_hcc_params (ehci, "reset");
  315. /* cache this readonly data; minimize chip reads */
  316. ehci->hcs_params = readl (&ehci->caps->hcs_params);
  317. #ifdef CONFIG_PCI
  318. if (hcd->self.controller->bus == &pci_bus_type) {
  319. struct pci_dev *pdev = to_pci_dev(hcd->self.controller);
  320. switch (pdev->vendor) {
  321. case PCI_VENDOR_ID_TDI:
  322. if (pdev->device == PCI_DEVICE_ID_TDI_EHCI) {
  323. ehci->is_tdi_rh_tt = 1;
  324. tdi_reset (ehci);
  325. }
  326. break;
  327. case PCI_VENDOR_ID_AMD:
  328. /* AMD8111 EHCI doesn't work, according to AMD errata */
  329. if (pdev->device == 0x7463) {
  330. ehci_info (ehci, "ignoring AMD8111 (errata)\n");
  331. return -EIO;
  332. }
  333. break;
  334. case PCI_VENDOR_ID_NVIDIA:
  335. /* NVidia reports that certain chips don't handle
  336. * QH, ITD, or SITD addresses above 2GB. (But TD,
  337. * data buffer, and periodic schedule are normal.)
  338. */
  339. switch (pdev->device) {
  340. case 0x003c: /* MCP04 */
  341. case 0x005b: /* CK804 */
  342. case 0x00d8: /* CK8 */
  343. case 0x00e8: /* CK8S */
  344. if (pci_set_consistent_dma_mask(pdev,
  345. DMA_31BIT_MASK) < 0)
  346. ehci_warn (ehci, "can't enable NVidia "
  347. "workaround for >2GB RAM\n");
  348. break;
  349. }
  350. break;
  351. }
  352. /* optional debug port, normally in the first BAR */
  353. temp = pci_find_capability (pdev, 0x0a);
  354. if (temp) {
  355. pci_read_config_dword(pdev, temp, &temp);
  356. temp >>= 16;
  357. if ((temp & (3 << 13)) == (1 << 13)) {
  358. temp &= 0x1fff;
  359. ehci->debug = hcd->regs + temp;
  360. temp = readl (&ehci->debug->control);
  361. ehci_info (ehci, "debug port %d%s\n",
  362. HCS_DEBUG_PORT(ehci->hcs_params),
  363. (temp & DBGP_ENABLED)
  364. ? " IN USE"
  365. : "");
  366. if (!(temp & DBGP_ENABLED))
  367. ehci->debug = NULL;
  368. }
  369. }
  370. temp = HCC_EXT_CAPS (readl (&ehci->caps->hcc_params));
  371. } else
  372. temp = 0;
  373. /* EHCI 0.96 and later may have "extended capabilities" */
  374. while (temp && count--) {
  375. u32 cap;
  376. pci_read_config_dword (to_pci_dev(hcd->self.controller),
  377. temp, &cap);
  378. ehci_dbg (ehci, "capability %04x at %02x\n", cap, temp);
  379. switch (cap & 0xff) {
  380. case 1: /* BIOS/SMM/... handoff */
  381. if (bios_handoff (ehci, temp, cap) != 0)
  382. return -EOPNOTSUPP;
  383. break;
  384. case 0: /* illegal reserved capability */
  385. ehci_warn (ehci, "illegal capability!\n");
  386. cap = 0;
  387. /* FALLTHROUGH */
  388. default: /* unknown */
  389. break;
  390. }
  391. temp = (cap >> 8) & 0xff;
  392. }
  393. if (!count) {
  394. ehci_err (ehci, "bogus capabilities ... PCI problems!\n");
  395. return -EIO;
  396. }
  397. if (ehci_is_TDI(ehci))
  398. ehci_reset (ehci);
  399. #endif
  400. ehci_port_power (ehci, 0);
  401. /* at least the Genesys GL880S needs fixup here */
  402. temp = HCS_N_CC(ehci->hcs_params) * HCS_N_PCC(ehci->hcs_params);
  403. temp &= 0x0f;
  404. if (temp && HCS_N_PORTS(ehci->hcs_params) > temp) {
  405. ehci_dbg (ehci, "bogus port configuration: "
  406. "cc=%d x pcc=%d < ports=%d\n",
  407. HCS_N_CC(ehci->hcs_params),
  408. HCS_N_PCC(ehci->hcs_params),
  409. HCS_N_PORTS(ehci->hcs_params));
  410. #ifdef CONFIG_PCI
  411. if (hcd->self.controller->bus == &pci_bus_type) {
  412. struct pci_dev *pdev;
  413. pdev = to_pci_dev(hcd->self.controller);
  414. switch (pdev->vendor) {
  415. case 0x17a0: /* GENESYS */
  416. /* GL880S: should be PORTS=2 */
  417. temp |= (ehci->hcs_params & ~0xf);
  418. ehci->hcs_params = temp;
  419. break;
  420. case PCI_VENDOR_ID_NVIDIA:
  421. /* NF4: should be PCC=10 */
  422. break;
  423. }
  424. }
  425. #endif
  426. }
  427. /* force HC to halt state */
  428. return ehci_halt (ehci);
  429. }
  430. static int ehci_start (struct usb_hcd *hcd)
  431. {
  432. struct ehci_hcd *ehci = hcd_to_ehci (hcd);
  433. u32 temp;
  434. int retval;
  435. u32 hcc_params;
  436. u8 sbrn = 0;
  437. int first;
  438. /* skip some things on restart paths */
  439. first = (ehci->watchdog.data == 0);
  440. if (first) {
  441. init_timer (&ehci->watchdog);
  442. ehci->watchdog.function = ehci_watchdog;
  443. ehci->watchdog.data = (unsigned long) ehci;
  444. }
  445. /*
  446. * hw default: 1K periodic list heads, one per frame.
  447. * periodic_size can shrink by USBCMD update if hcc_params allows.
  448. */
  449. ehci->periodic_size = DEFAULT_I_TDPS;
  450. if (first && (retval = ehci_mem_init (ehci, GFP_KERNEL)) < 0)
  451. return retval;
  452. /* controllers may cache some of the periodic schedule ... */
  453. hcc_params = readl (&ehci->caps->hcc_params);
  454. if (HCC_ISOC_CACHE (hcc_params)) // full frame cache
  455. ehci->i_thresh = 8;
  456. else // N microframes cached
  457. ehci->i_thresh = 2 + HCC_ISOC_THRES (hcc_params);
  458. ehci->reclaim = NULL;
  459. ehci->reclaim_ready = 0;
  460. ehci->next_uframe = -1;
  461. /* controller state: unknown --> reset */
  462. /* EHCI spec section 4.1 */
  463. if ((retval = ehci_reset (ehci)) != 0) {
  464. ehci_mem_cleanup (ehci);
  465. return retval;
  466. }
  467. writel (ehci->periodic_dma, &ehci->regs->frame_list);
  468. #ifdef CONFIG_PCI
  469. if (hcd->self.controller->bus == &pci_bus_type) {
  470. struct pci_dev *pdev;
  471. u16 port_wake;
  472. pdev = to_pci_dev(hcd->self.controller);
  473. /* Serial Bus Release Number is at PCI 0x60 offset */
  474. pci_read_config_byte(pdev, 0x60, &sbrn);
  475. /* port wake capability, reported by boot firmware */
  476. pci_read_config_word(pdev, 0x62, &port_wake);
  477. hcd->can_wakeup = (port_wake & 1) != 0;
  478. /* help hc dma work well with cachelines */
  479. retval = pci_set_mwi(pdev);
  480. if (retval)
  481. ehci_dbg(ehci, "unable to enable MWI - not fatal.\n");
  482. }
  483. #endif
  484. /*
  485. * dedicate a qh for the async ring head, since we couldn't unlink
  486. * a 'real' qh without stopping the async schedule [4.8]. use it
  487. * as the 'reclamation list head' too.
  488. * its dummy is used in hw_alt_next of many tds, to prevent the qh
  489. * from automatically advancing to the next td after short reads.
  490. */
  491. if (first) {
  492. ehci->async->qh_next.qh = NULL;
  493. ehci->async->hw_next = QH_NEXT (ehci->async->qh_dma);
  494. ehci->async->hw_info1 = cpu_to_le32 (QH_HEAD);
  495. ehci->async->hw_token = cpu_to_le32 (QTD_STS_HALT);
  496. ehci->async->hw_qtd_next = EHCI_LIST_END;
  497. ehci->async->qh_state = QH_STATE_LINKED;
  498. ehci->async->hw_alt_next = QTD_NEXT (ehci->async->dummy->qtd_dma);
  499. }
  500. writel ((u32)ehci->async->qh_dma, &ehci->regs->async_next);
  501. /*
  502. * hcc_params controls whether ehci->regs->segment must (!!!)
  503. * be used; it constrains QH/ITD/SITD and QTD locations.
  504. * pci_pool consistent memory always uses segment zero.
  505. * streaming mappings for I/O buffers, like pci_map_single(),
  506. * can return segments above 4GB, if the device allows.
  507. *
  508. * NOTE: the dma mask is visible through dma_supported(), so
  509. * drivers can pass this info along ... like NETIF_F_HIGHDMA,
  510. * Scsi_Host.highmem_io, and so forth. It's readonly to all
  511. * host side drivers though.
  512. */
  513. if (HCC_64BIT_ADDR (hcc_params)) {
  514. writel (0, &ehci->regs->segment);
  515. #if 0
  516. // this is deeply broken on almost all architectures
  517. if (!dma_set_mask (hcd->self.controller, DMA_64BIT_MASK))
  518. ehci_info (ehci, "enabled 64bit DMA\n");
  519. #endif
  520. }
  521. /* clear interrupt enables, set irq latency */
  522. if (log2_irq_thresh < 0 || log2_irq_thresh > 6)
  523. log2_irq_thresh = 0;
  524. temp = 1 << (16 + log2_irq_thresh);
  525. if (HCC_CANPARK(hcc_params)) {
  526. /* HW default park == 3, on hardware that supports it (like
  527. * NVidia and ALI silicon), maximizes throughput on the async
  528. * schedule by avoiding QH fetches between transfers.
  529. *
  530. * With fast usb storage devices and NForce2, "park" seems to
  531. * make problems: throughput reduction (!), data errors...
  532. */
  533. if (park) {
  534. park = min (park, (unsigned) 3);
  535. temp |= CMD_PARK;
  536. temp |= park << 8;
  537. }
  538. ehci_info (ehci, "park %d\n", park);
  539. }
  540. if (HCC_PGM_FRAMELISTLEN (hcc_params)) {
  541. /* periodic schedule size can be smaller than default */
  542. temp &= ~(3 << 2);
  543. temp |= (EHCI_TUNE_FLS << 2);
  544. switch (EHCI_TUNE_FLS) {
  545. case 0: ehci->periodic_size = 1024; break;
  546. case 1: ehci->periodic_size = 512; break;
  547. case 2: ehci->periodic_size = 256; break;
  548. default: BUG ();
  549. }
  550. }
  551. // Philips, Intel, and maybe others need CMD_RUN before the
  552. // root hub will detect new devices (why?); NEC doesn't
  553. temp |= CMD_RUN;
  554. writel (temp, &ehci->regs->command);
  555. dbg_cmd (ehci, "init", temp);
  556. /* set async sleep time = 10 us ... ? */
  557. /*
  558. * Start, enabling full USB 2.0 functionality ... usb 1.1 devices
  559. * are explicitly handed to companion controller(s), so no TT is
  560. * involved with the root hub. (Except where one is integrated,
  561. * and there's no companion controller unless maybe for USB OTG.)
  562. */
  563. if (first) {
  564. ehci->reboot_notifier.notifier_call = ehci_reboot;
  565. register_reboot_notifier (&ehci->reboot_notifier);
  566. }
  567. hcd->state = HC_STATE_RUNNING;
  568. writel (FLAG_CF, &ehci->regs->configured_flag);
  569. readl (&ehci->regs->command); /* unblock posted write */
  570. temp = HC_VERSION(readl (&ehci->caps->hc_capbase));
  571. ehci_info (ehci,
  572. "USB %x.%x %s, EHCI %x.%02x, driver %s\n",
  573. ((sbrn & 0xf0)>>4), (sbrn & 0x0f),
  574. first ? "initialized" : "restarted",
  575. temp >> 8, temp & 0xff, DRIVER_VERSION);
  576. writel (INTR_MASK, &ehci->regs->intr_enable); /* Turn On Interrupts */
  577. if (first)
  578. create_debug_files (ehci);
  579. return 0;
  580. }
  581. /* always called by thread; normally rmmod */
  582. static void ehci_stop (struct usb_hcd *hcd)
  583. {
  584. struct ehci_hcd *ehci = hcd_to_ehci (hcd);
  585. ehci_dbg (ehci, "stop\n");
  586. /* Turn off port power on all root hub ports. */
  587. ehci_port_power (ehci, 0);
  588. /* no more interrupts ... */
  589. del_timer_sync (&ehci->watchdog);
  590. spin_lock_irq(&ehci->lock);
  591. if (HC_IS_RUNNING (hcd->state))
  592. ehci_quiesce (ehci);
  593. ehci_reset (ehci);
  594. writel (0, &ehci->regs->intr_enable);
  595. spin_unlock_irq(&ehci->lock);
  596. /* let companion controllers work when we aren't */
  597. writel (0, &ehci->regs->configured_flag);
  598. unregister_reboot_notifier (&ehci->reboot_notifier);
  599. remove_debug_files (ehci);
  600. /* root hub is shut down separately (first, when possible) */
  601. spin_lock_irq (&ehci->lock);
  602. if (ehci->async)
  603. ehci_work (ehci, NULL);
  604. spin_unlock_irq (&ehci->lock);
  605. ehci_mem_cleanup (ehci);
  606. #ifdef EHCI_STATS
  607. ehci_dbg (ehci, "irq normal %ld err %ld reclaim %ld (lost %ld)\n",
  608. ehci->stats.normal, ehci->stats.error, ehci->stats.reclaim,
  609. ehci->stats.lost_iaa);
  610. ehci_dbg (ehci, "complete %ld unlink %ld\n",
  611. ehci->stats.complete, ehci->stats.unlink);
  612. #endif
  613. dbg_status (ehci, "ehci_stop completed", readl (&ehci->regs->status));
  614. }
  615. static int ehci_get_frame (struct usb_hcd *hcd)
  616. {
  617. struct ehci_hcd *ehci = hcd_to_ehci (hcd);
  618. return (readl (&ehci->regs->frame_index) >> 3) % ehci->periodic_size;
  619. }
  620. /*-------------------------------------------------------------------------*/
  621. #ifdef CONFIG_PM
  622. /* suspend/resume, section 4.3 */
  623. /* These routines rely on the bus (pci, platform, etc)
  624. * to handle powerdown and wakeup, and currently also on
  625. * transceivers that don't need any software attention to set up
  626. * the right sort of wakeup.
  627. */
  628. static int ehci_suspend (struct usb_hcd *hcd, pm_message_t message)
  629. {
  630. struct ehci_hcd *ehci = hcd_to_ehci (hcd);
  631. if (time_before (jiffies, ehci->next_statechange))
  632. msleep (100);
  633. #ifdef CONFIG_USB_SUSPEND
  634. (void) usb_suspend_device (hcd->self.root_hub, message);
  635. #else
  636. usb_lock_device (hcd->self.root_hub);
  637. (void) ehci_hub_suspend (hcd);
  638. usb_unlock_device (hcd->self.root_hub);
  639. #endif
  640. // save (PCI) FLADJ in case of Vaux power loss
  641. // ... we'd only use it to handle clock skew
  642. return 0;
  643. }
  644. static int ehci_resume (struct usb_hcd *hcd)
  645. {
  646. struct ehci_hcd *ehci = hcd_to_ehci (hcd);
  647. unsigned port;
  648. struct usb_device *root = hcd->self.root_hub;
  649. int retval = -EINVAL;
  650. // maybe restore (PCI) FLADJ
  651. if (time_before (jiffies, ehci->next_statechange))
  652. msleep (100);
  653. /* If any port is suspended (or owned by the companion),
  654. * we know we can/must resume the HC (and mustn't reset it).
  655. */
  656. for (port = HCS_N_PORTS (ehci->hcs_params); port > 0; ) {
  657. u32 status;
  658. port--;
  659. status = readl (&ehci->regs->port_status [port]);
  660. if (!(status & PORT_POWER))
  661. continue;
  662. if (status & (PORT_SUSPEND | PORT_OWNER)) {
  663. down (&hcd->self.root_hub->serialize);
  664. retval = ehci_hub_resume (hcd);
  665. up (&hcd->self.root_hub->serialize);
  666. break;
  667. }
  668. if (!root->children [port])
  669. continue;
  670. dbg_port (ehci, __FUNCTION__, port + 1, status);
  671. usb_set_device_state (root->children[port],
  672. USB_STATE_NOTATTACHED);
  673. }
  674. /* Else reset, to cope with power loss or flush-to-storage
  675. * style "resume" having activated BIOS during reboot.
  676. */
  677. if (port == 0) {
  678. (void) ehci_halt (ehci);
  679. (void) ehci_reset (ehci);
  680. (void) ehci_hc_reset (hcd);
  681. /* emptying the schedule aborts any urbs */
  682. spin_lock_irq (&ehci->lock);
  683. if (ehci->reclaim)
  684. ehci->reclaim_ready = 1;
  685. ehci_work (ehci, NULL);
  686. spin_unlock_irq (&ehci->lock);
  687. /* restart; khubd will disconnect devices */
  688. retval = ehci_start (hcd);
  689. /* here we "know" root ports should always stay powered;
  690. * but some controllers may lose all power.
  691. */
  692. ehci_port_power (ehci, 1);
  693. }
  694. return retval;
  695. }
  696. #endif
  697. /*-------------------------------------------------------------------------*/
  698. /*
  699. * ehci_work is called from some interrupts, timers, and so on.
  700. * it calls driver completion functions, after dropping ehci->lock.
  701. */
  702. static void ehci_work (struct ehci_hcd *ehci, struct pt_regs *regs)
  703. {
  704. timer_action_done (ehci, TIMER_IO_WATCHDOG);
  705. if (ehci->reclaim_ready)
  706. end_unlink_async (ehci, regs);
  707. /* another CPU may drop ehci->lock during a schedule scan while
  708. * it reports urb completions. this flag guards against bogus
  709. * attempts at re-entrant schedule scanning.
  710. */
  711. if (ehci->scanning)
  712. return;
  713. ehci->scanning = 1;
  714. scan_async (ehci, regs);
  715. if (ehci->next_uframe != -1)
  716. scan_periodic (ehci, regs);
  717. ehci->scanning = 0;
  718. /* the IO watchdog guards against hardware or driver bugs that
  719. * misplace IRQs, and should let us run completely without IRQs.
  720. * such lossage has been observed on both VT6202 and VT8235.
  721. */
  722. if (HC_IS_RUNNING (ehci_to_hcd(ehci)->state) &&
  723. (ehci->async->qh_next.ptr != NULL ||
  724. ehci->periodic_sched != 0))
  725. timer_action (ehci, TIMER_IO_WATCHDOG);
  726. }
  727. /*-------------------------------------------------------------------------*/
  728. static irqreturn_t ehci_irq (struct usb_hcd *hcd, struct pt_regs *regs)
  729. {
  730. struct ehci_hcd *ehci = hcd_to_ehci (hcd);
  731. u32 status;
  732. int bh;
  733. spin_lock (&ehci->lock);
  734. status = readl (&ehci->regs->status);
  735. /* e.g. cardbus physical eject */
  736. if (status == ~(u32) 0) {
  737. ehci_dbg (ehci, "device removed\n");
  738. goto dead;
  739. }
  740. status &= INTR_MASK;
  741. if (!status) { /* irq sharing? */
  742. spin_unlock(&ehci->lock);
  743. return IRQ_NONE;
  744. }
  745. /* clear (just) interrupts */
  746. writel (status, &ehci->regs->status);
  747. readl (&ehci->regs->command); /* unblock posted write */
  748. bh = 0;
  749. #ifdef EHCI_VERBOSE_DEBUG
  750. /* unrequested/ignored: Frame List Rollover */
  751. dbg_status (ehci, "irq", status);
  752. #endif
  753. /* INT, ERR, and IAA interrupt rates can be throttled */
  754. /* normal [4.15.1.2] or error [4.15.1.1] completion */
  755. if (likely ((status & (STS_INT|STS_ERR)) != 0)) {
  756. if (likely ((status & STS_ERR) == 0))
  757. COUNT (ehci->stats.normal);
  758. else
  759. COUNT (ehci->stats.error);
  760. bh = 1;
  761. }
  762. /* complete the unlinking of some qh [4.15.2.3] */
  763. if (status & STS_IAA) {
  764. COUNT (ehci->stats.reclaim);
  765. ehci->reclaim_ready = 1;
  766. bh = 1;
  767. }
  768. /* remote wakeup [4.3.1] */
  769. if ((status & STS_PCD) && hcd->remote_wakeup) {
  770. unsigned i = HCS_N_PORTS (ehci->hcs_params);
  771. /* resume root hub? */
  772. status = readl (&ehci->regs->command);
  773. if (!(status & CMD_RUN))
  774. writel (status | CMD_RUN, &ehci->regs->command);
  775. while (i--) {
  776. status = readl (&ehci->regs->port_status [i]);
  777. if (status & PORT_OWNER)
  778. continue;
  779. if (!(status & PORT_RESUME)
  780. || ehci->reset_done [i] != 0)
  781. continue;
  782. /* start 20 msec resume signaling from this port,
  783. * and make khubd collect PORT_STAT_C_SUSPEND to
  784. * stop that signaling.
  785. */
  786. ehci->reset_done [i] = jiffies + msecs_to_jiffies (20);
  787. mod_timer (&hcd->rh_timer,
  788. ehci->reset_done [i] + 1);
  789. ehci_dbg (ehci, "port %d remote wakeup\n", i + 1);
  790. }
  791. }
  792. /* PCI errors [4.15.2.4] */
  793. if (unlikely ((status & STS_FATAL) != 0)) {
  794. /* bogus "fatal" IRQs appear on some chips... why? */
  795. status = readl (&ehci->regs->status);
  796. dbg_cmd (ehci, "fatal", readl (&ehci->regs->command));
  797. dbg_status (ehci, "fatal", status);
  798. if (status & STS_HALT) {
  799. ehci_err (ehci, "fatal error\n");
  800. dead:
  801. ehci_reset (ehci);
  802. writel (0, &ehci->regs->configured_flag);
  803. /* generic layer kills/unlinks all urbs, then
  804. * uses ehci_stop to clean up the rest
  805. */
  806. bh = 1;
  807. }
  808. }
  809. if (bh)
  810. ehci_work (ehci, regs);
  811. spin_unlock (&ehci->lock);
  812. return IRQ_HANDLED;
  813. }
  814. /*-------------------------------------------------------------------------*/
  815. /*
  816. * non-error returns are a promise to giveback() the urb later
  817. * we drop ownership so next owner (or urb unlink) can get it
  818. *
  819. * urb + dev is in hcd.self.controller.urb_list
  820. * we're queueing TDs onto software and hardware lists
  821. *
  822. * hcd-specific init for hcpriv hasn't been done yet
  823. *
  824. * NOTE: control, bulk, and interrupt share the same code to append TDs
  825. * to a (possibly active) QH, and the same QH scanning code.
  826. */
  827. static int ehci_urb_enqueue (
  828. struct usb_hcd *hcd,
  829. struct usb_host_endpoint *ep,
  830. struct urb *urb,
  831. unsigned mem_flags
  832. ) {
  833. struct ehci_hcd *ehci = hcd_to_ehci (hcd);
  834. struct list_head qtd_list;
  835. INIT_LIST_HEAD (&qtd_list);
  836. switch (usb_pipetype (urb->pipe)) {
  837. // case PIPE_CONTROL:
  838. // case PIPE_BULK:
  839. default:
  840. if (!qh_urb_transaction (ehci, urb, &qtd_list, mem_flags))
  841. return -ENOMEM;
  842. return submit_async (ehci, ep, urb, &qtd_list, mem_flags);
  843. case PIPE_INTERRUPT:
  844. if (!qh_urb_transaction (ehci, urb, &qtd_list, mem_flags))
  845. return -ENOMEM;
  846. return intr_submit (ehci, ep, urb, &qtd_list, mem_flags);
  847. case PIPE_ISOCHRONOUS:
  848. if (urb->dev->speed == USB_SPEED_HIGH)
  849. return itd_submit (ehci, urb, mem_flags);
  850. else
  851. return sitd_submit (ehci, urb, mem_flags);
  852. }
  853. }
  854. static void unlink_async (struct ehci_hcd *ehci, struct ehci_qh *qh)
  855. {
  856. /* if we need to use IAA and it's busy, defer */
  857. if (qh->qh_state == QH_STATE_LINKED
  858. && ehci->reclaim
  859. && HC_IS_RUNNING (ehci_to_hcd(ehci)->state)) {
  860. struct ehci_qh *last;
  861. for (last = ehci->reclaim;
  862. last->reclaim;
  863. last = last->reclaim)
  864. continue;
  865. qh->qh_state = QH_STATE_UNLINK_WAIT;
  866. last->reclaim = qh;
  867. /* bypass IAA if the hc can't care */
  868. } else if (!HC_IS_RUNNING (ehci_to_hcd(ehci)->state) && ehci->reclaim)
  869. end_unlink_async (ehci, NULL);
  870. /* something else might have unlinked the qh by now */
  871. if (qh->qh_state == QH_STATE_LINKED)
  872. start_unlink_async (ehci, qh);
  873. }
  874. /* remove from hardware lists
  875. * completions normally happen asynchronously
  876. */
  877. static int ehci_urb_dequeue (struct usb_hcd *hcd, struct urb *urb)
  878. {
  879. struct ehci_hcd *ehci = hcd_to_ehci (hcd);
  880. struct ehci_qh *qh;
  881. unsigned long flags;
  882. spin_lock_irqsave (&ehci->lock, flags);
  883. switch (usb_pipetype (urb->pipe)) {
  884. // case PIPE_CONTROL:
  885. // case PIPE_BULK:
  886. default:
  887. qh = (struct ehci_qh *) urb->hcpriv;
  888. if (!qh)
  889. break;
  890. unlink_async (ehci, qh);
  891. break;
  892. case PIPE_INTERRUPT:
  893. qh = (struct ehci_qh *) urb->hcpriv;
  894. if (!qh)
  895. break;
  896. switch (qh->qh_state) {
  897. case QH_STATE_LINKED:
  898. intr_deschedule (ehci, qh);
  899. /* FALL THROUGH */
  900. case QH_STATE_IDLE:
  901. qh_completions (ehci, qh, NULL);
  902. break;
  903. default:
  904. ehci_dbg (ehci, "bogus qh %p state %d\n",
  905. qh, qh->qh_state);
  906. goto done;
  907. }
  908. /* reschedule QH iff another request is queued */
  909. if (!list_empty (&qh->qtd_list)
  910. && HC_IS_RUNNING (hcd->state)) {
  911. int status;
  912. status = qh_schedule (ehci, qh);
  913. spin_unlock_irqrestore (&ehci->lock, flags);
  914. if (status != 0) {
  915. // shouldn't happen often, but ...
  916. // FIXME kill those tds' urbs
  917. err ("can't reschedule qh %p, err %d",
  918. qh, status);
  919. }
  920. return status;
  921. }
  922. break;
  923. case PIPE_ISOCHRONOUS:
  924. // itd or sitd ...
  925. // wait till next completion, do it then.
  926. // completion irqs can wait up to 1024 msec,
  927. break;
  928. }
  929. done:
  930. spin_unlock_irqrestore (&ehci->lock, flags);
  931. return 0;
  932. }
  933. /*-------------------------------------------------------------------------*/
  934. // bulk qh holds the data toggle
  935. static void
  936. ehci_endpoint_disable (struct usb_hcd *hcd, struct usb_host_endpoint *ep)
  937. {
  938. struct ehci_hcd *ehci = hcd_to_ehci (hcd);
  939. unsigned long flags;
  940. struct ehci_qh *qh, *tmp;
  941. /* ASSERT: any requests/urbs are being unlinked */
  942. /* ASSERT: nobody can be submitting urbs for this any more */
  943. rescan:
  944. spin_lock_irqsave (&ehci->lock, flags);
  945. qh = ep->hcpriv;
  946. if (!qh)
  947. goto done;
  948. /* endpoints can be iso streams. for now, we don't
  949. * accelerate iso completions ... so spin a while.
  950. */
  951. if (qh->hw_info1 == 0) {
  952. ehci_vdbg (ehci, "iso delay\n");
  953. goto idle_timeout;
  954. }
  955. if (!HC_IS_RUNNING (hcd->state))
  956. qh->qh_state = QH_STATE_IDLE;
  957. switch (qh->qh_state) {
  958. case QH_STATE_LINKED:
  959. for (tmp = ehci->async->qh_next.qh;
  960. tmp && tmp != qh;
  961. tmp = tmp->qh_next.qh)
  962. continue;
  963. /* periodic qh self-unlinks on empty */
  964. if (!tmp)
  965. goto nogood;
  966. unlink_async (ehci, qh);
  967. /* FALL THROUGH */
  968. case QH_STATE_UNLINK: /* wait for hw to finish? */
  969. idle_timeout:
  970. spin_unlock_irqrestore (&ehci->lock, flags);
  971. schedule_timeout_uninterruptible(1);
  972. goto rescan;
  973. case QH_STATE_IDLE: /* fully unlinked */
  974. if (list_empty (&qh->qtd_list)) {
  975. qh_put (qh);
  976. break;
  977. }
  978. /* else FALL THROUGH */
  979. default:
  980. nogood:
  981. /* caller was supposed to have unlinked any requests;
  982. * that's not our job. just leak this memory.
  983. */
  984. ehci_err (ehci, "qh %p (#%02x) state %d%s\n",
  985. qh, ep->desc.bEndpointAddress, qh->qh_state,
  986. list_empty (&qh->qtd_list) ? "" : "(has tds)");
  987. break;
  988. }
  989. ep->hcpriv = NULL;
  990. done:
  991. spin_unlock_irqrestore (&ehci->lock, flags);
  992. return;
  993. }
  994. /*-------------------------------------------------------------------------*/
  995. static const struct hc_driver ehci_driver = {
  996. .description = hcd_name,
  997. .product_desc = "EHCI Host Controller",
  998. .hcd_priv_size = sizeof(struct ehci_hcd),
  999. /*
  1000. * generic hardware linkage
  1001. */
  1002. .irq = ehci_irq,
  1003. .flags = HCD_MEMORY | HCD_USB2,
  1004. /*
  1005. * basic lifecycle operations
  1006. */
  1007. .reset = ehci_hc_reset,
  1008. .start = ehci_start,
  1009. #ifdef CONFIG_PM
  1010. .suspend = ehci_suspend,
  1011. .resume = ehci_resume,
  1012. #endif
  1013. .stop = ehci_stop,
  1014. /*
  1015. * managing i/o requests and associated device resources
  1016. */
  1017. .urb_enqueue = ehci_urb_enqueue,
  1018. .urb_dequeue = ehci_urb_dequeue,
  1019. .endpoint_disable = ehci_endpoint_disable,
  1020. /*
  1021. * scheduling support
  1022. */
  1023. .get_frame_number = ehci_get_frame,
  1024. /*
  1025. * root hub support
  1026. */
  1027. .hub_status_data = ehci_hub_status_data,
  1028. .hub_control = ehci_hub_control,
  1029. .hub_suspend = ehci_hub_suspend,
  1030. .hub_resume = ehci_hub_resume,
  1031. };
  1032. /*-------------------------------------------------------------------------*/
  1033. /* EHCI 1.0 doesn't require PCI */
  1034. #ifdef CONFIG_PCI
  1035. /* PCI driver selection metadata; PCI hotplugging uses this */
  1036. static const struct pci_device_id pci_ids [] = { {
  1037. /* handle any USB 2.0 EHCI controller */
  1038. PCI_DEVICE_CLASS(((PCI_CLASS_SERIAL_USB << 8) | 0x20), ~0),
  1039. .driver_data = (unsigned long) &ehci_driver,
  1040. },
  1041. { /* end: all zeroes */ }
  1042. };
  1043. MODULE_DEVICE_TABLE (pci, pci_ids);
  1044. /* pci driver glue; this is a "new style" PCI driver module */
  1045. static struct pci_driver ehci_pci_driver = {
  1046. .name = (char *) hcd_name,
  1047. .id_table = pci_ids,
  1048. .probe = usb_hcd_pci_probe,
  1049. .remove = usb_hcd_pci_remove,
  1050. #ifdef CONFIG_PM
  1051. .suspend = usb_hcd_pci_suspend,
  1052. .resume = usb_hcd_pci_resume,
  1053. #endif
  1054. };
  1055. #endif /* PCI */
  1056. #define DRIVER_INFO DRIVER_VERSION " " DRIVER_DESC
  1057. MODULE_DESCRIPTION (DRIVER_INFO);
  1058. MODULE_AUTHOR (DRIVER_AUTHOR);
  1059. MODULE_LICENSE ("GPL");
  1060. static int __init init (void)
  1061. {
  1062. if (usb_disabled())
  1063. return -ENODEV;
  1064. pr_debug ("%s: block sizes: qh %Zd qtd %Zd itd %Zd sitd %Zd\n",
  1065. hcd_name,
  1066. sizeof (struct ehci_qh), sizeof (struct ehci_qtd),
  1067. sizeof (struct ehci_itd), sizeof (struct ehci_sitd));
  1068. return pci_register_driver (&ehci_pci_driver);
  1069. }
  1070. module_init (init);
  1071. static void __exit cleanup (void)
  1072. {
  1073. pci_unregister_driver (&ehci_pci_driver);
  1074. }
  1075. module_exit (cleanup);