ehci-hcd.c 34 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254
  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. }
  335. /* optional debug port, normally in the first BAR */
  336. temp = pci_find_capability (pdev, 0x0a);
  337. if (temp) {
  338. pci_read_config_dword(pdev, temp, &temp);
  339. temp >>= 16;
  340. if ((temp & (3 << 13)) == (1 << 13)) {
  341. temp &= 0x1fff;
  342. ehci->debug = hcd->regs + temp;
  343. temp = readl (&ehci->debug->control);
  344. ehci_info (ehci, "debug port %d%s\n",
  345. HCS_DEBUG_PORT(ehci->hcs_params),
  346. (temp & DBGP_ENABLED)
  347. ? " IN USE"
  348. : "");
  349. if (!(temp & DBGP_ENABLED))
  350. ehci->debug = NULL;
  351. }
  352. }
  353. temp = HCC_EXT_CAPS (readl (&ehci->caps->hcc_params));
  354. } else
  355. temp = 0;
  356. /* EHCI 0.96 and later may have "extended capabilities" */
  357. while (temp && count--) {
  358. u32 cap;
  359. pci_read_config_dword (to_pci_dev(hcd->self.controller),
  360. temp, &cap);
  361. ehci_dbg (ehci, "capability %04x at %02x\n", cap, temp);
  362. switch (cap & 0xff) {
  363. case 1: /* BIOS/SMM/... handoff */
  364. if (bios_handoff (ehci, temp, cap) != 0)
  365. return -EOPNOTSUPP;
  366. break;
  367. case 0: /* illegal reserved capability */
  368. ehci_warn (ehci, "illegal capability!\n");
  369. cap = 0;
  370. /* FALLTHROUGH */
  371. default: /* unknown */
  372. break;
  373. }
  374. temp = (cap >> 8) & 0xff;
  375. }
  376. if (!count) {
  377. ehci_err (ehci, "bogus capabilities ... PCI problems!\n");
  378. return -EIO;
  379. }
  380. if (ehci_is_TDI(ehci))
  381. ehci_reset (ehci);
  382. #endif
  383. ehci_port_power (ehci, 0);
  384. /* at least the Genesys GL880S needs fixup here */
  385. temp = HCS_N_CC(ehci->hcs_params) * HCS_N_PCC(ehci->hcs_params);
  386. temp &= 0x0f;
  387. if (temp && HCS_N_PORTS(ehci->hcs_params) > temp) {
  388. ehci_dbg (ehci, "bogus port configuration: "
  389. "cc=%d x pcc=%d < ports=%d\n",
  390. HCS_N_CC(ehci->hcs_params),
  391. HCS_N_PCC(ehci->hcs_params),
  392. HCS_N_PORTS(ehci->hcs_params));
  393. #ifdef CONFIG_PCI
  394. if (hcd->self.controller->bus == &pci_bus_type) {
  395. struct pci_dev *pdev;
  396. pdev = to_pci_dev(hcd->self.controller);
  397. switch (pdev->vendor) {
  398. case 0x17a0: /* GENESYS */
  399. /* GL880S: should be PORTS=2 */
  400. temp |= (ehci->hcs_params & ~0xf);
  401. ehci->hcs_params = temp;
  402. break;
  403. case PCI_VENDOR_ID_NVIDIA:
  404. /* NF4: should be PCC=10 */
  405. break;
  406. }
  407. }
  408. #endif
  409. }
  410. /* force HC to halt state */
  411. return ehci_halt (ehci);
  412. }
  413. static int ehci_start (struct usb_hcd *hcd)
  414. {
  415. struct ehci_hcd *ehci = hcd_to_ehci (hcd);
  416. u32 temp;
  417. int retval;
  418. u32 hcc_params;
  419. u8 sbrn = 0;
  420. int first;
  421. /* skip some things on restart paths */
  422. first = (ehci->watchdog.data == 0);
  423. if (first) {
  424. init_timer (&ehci->watchdog);
  425. ehci->watchdog.function = ehci_watchdog;
  426. ehci->watchdog.data = (unsigned long) ehci;
  427. }
  428. /*
  429. * hw default: 1K periodic list heads, one per frame.
  430. * periodic_size can shrink by USBCMD update if hcc_params allows.
  431. */
  432. ehci->periodic_size = DEFAULT_I_TDPS;
  433. if (first && (retval = ehci_mem_init (ehci, GFP_KERNEL)) < 0)
  434. return retval;
  435. /* controllers may cache some of the periodic schedule ... */
  436. hcc_params = readl (&ehci->caps->hcc_params);
  437. if (HCC_ISOC_CACHE (hcc_params)) // full frame cache
  438. ehci->i_thresh = 8;
  439. else // N microframes cached
  440. ehci->i_thresh = 2 + HCC_ISOC_THRES (hcc_params);
  441. ehci->reclaim = NULL;
  442. ehci->reclaim_ready = 0;
  443. ehci->next_uframe = -1;
  444. /* controller state: unknown --> reset */
  445. /* EHCI spec section 4.1 */
  446. if ((retval = ehci_reset (ehci)) != 0) {
  447. ehci_mem_cleanup (ehci);
  448. return retval;
  449. }
  450. writel (ehci->periodic_dma, &ehci->regs->frame_list);
  451. #ifdef CONFIG_PCI
  452. if (hcd->self.controller->bus == &pci_bus_type) {
  453. struct pci_dev *pdev;
  454. u16 port_wake;
  455. pdev = to_pci_dev(hcd->self.controller);
  456. /* Serial Bus Release Number is at PCI 0x60 offset */
  457. pci_read_config_byte(pdev, 0x60, &sbrn);
  458. /* port wake capability, reported by boot firmware */
  459. pci_read_config_word(pdev, 0x62, &port_wake);
  460. hcd->can_wakeup = (port_wake & 1) != 0;
  461. /* help hc dma work well with cachelines */
  462. pci_set_mwi (pdev);
  463. }
  464. #endif
  465. /*
  466. * dedicate a qh for the async ring head, since we couldn't unlink
  467. * a 'real' qh without stopping the async schedule [4.8]. use it
  468. * as the 'reclamation list head' too.
  469. * its dummy is used in hw_alt_next of many tds, to prevent the qh
  470. * from automatically advancing to the next td after short reads.
  471. */
  472. if (first) {
  473. ehci->async->qh_next.qh = NULL;
  474. ehci->async->hw_next = QH_NEXT (ehci->async->qh_dma);
  475. ehci->async->hw_info1 = cpu_to_le32 (QH_HEAD);
  476. ehci->async->hw_token = cpu_to_le32 (QTD_STS_HALT);
  477. ehci->async->hw_qtd_next = EHCI_LIST_END;
  478. ehci->async->qh_state = QH_STATE_LINKED;
  479. ehci->async->hw_alt_next = QTD_NEXT (ehci->async->dummy->qtd_dma);
  480. }
  481. writel ((u32)ehci->async->qh_dma, &ehci->regs->async_next);
  482. /*
  483. * hcc_params controls whether ehci->regs->segment must (!!!)
  484. * be used; it constrains QH/ITD/SITD and QTD locations.
  485. * pci_pool consistent memory always uses segment zero.
  486. * streaming mappings for I/O buffers, like pci_map_single(),
  487. * can return segments above 4GB, if the device allows.
  488. *
  489. * NOTE: the dma mask is visible through dma_supported(), so
  490. * drivers can pass this info along ... like NETIF_F_HIGHDMA,
  491. * Scsi_Host.highmem_io, and so forth. It's readonly to all
  492. * host side drivers though.
  493. */
  494. if (HCC_64BIT_ADDR (hcc_params)) {
  495. writel (0, &ehci->regs->segment);
  496. #if 0
  497. // this is deeply broken on almost all architectures
  498. if (!dma_set_mask (hcd->self.controller, DMA_64BIT_MASK))
  499. ehci_info (ehci, "enabled 64bit DMA\n");
  500. #endif
  501. }
  502. /* clear interrupt enables, set irq latency */
  503. if (log2_irq_thresh < 0 || log2_irq_thresh > 6)
  504. log2_irq_thresh = 0;
  505. temp = 1 << (16 + log2_irq_thresh);
  506. if (HCC_CANPARK(hcc_params)) {
  507. /* HW default park == 3, on hardware that supports it (like
  508. * NVidia and ALI silicon), maximizes throughput on the async
  509. * schedule by avoiding QH fetches between transfers.
  510. *
  511. * With fast usb storage devices and NForce2, "park" seems to
  512. * make problems: throughput reduction (!), data errors...
  513. */
  514. if (park) {
  515. park = min (park, (unsigned) 3);
  516. temp |= CMD_PARK;
  517. temp |= park << 8;
  518. }
  519. ehci_info (ehci, "park %d\n", park);
  520. }
  521. if (HCC_PGM_FRAMELISTLEN (hcc_params)) {
  522. /* periodic schedule size can be smaller than default */
  523. temp &= ~(3 << 2);
  524. temp |= (EHCI_TUNE_FLS << 2);
  525. switch (EHCI_TUNE_FLS) {
  526. case 0: ehci->periodic_size = 1024; break;
  527. case 1: ehci->periodic_size = 512; break;
  528. case 2: ehci->periodic_size = 256; break;
  529. default: BUG ();
  530. }
  531. }
  532. // Philips, Intel, and maybe others need CMD_RUN before the
  533. // root hub will detect new devices (why?); NEC doesn't
  534. temp |= CMD_RUN;
  535. writel (temp, &ehci->regs->command);
  536. dbg_cmd (ehci, "init", temp);
  537. /* set async sleep time = 10 us ... ? */
  538. /*
  539. * Start, enabling full USB 2.0 functionality ... usb 1.1 devices
  540. * are explicitly handed to companion controller(s), so no TT is
  541. * involved with the root hub. (Except where one is integrated,
  542. * and there's no companion controller unless maybe for USB OTG.)
  543. */
  544. if (first) {
  545. ehci->reboot_notifier.notifier_call = ehci_reboot;
  546. register_reboot_notifier (&ehci->reboot_notifier);
  547. }
  548. hcd->state = HC_STATE_RUNNING;
  549. writel (FLAG_CF, &ehci->regs->configured_flag);
  550. readl (&ehci->regs->command); /* unblock posted write */
  551. temp = HC_VERSION(readl (&ehci->caps->hc_capbase));
  552. ehci_info (ehci,
  553. "USB %x.%x %s, EHCI %x.%02x, driver %s\n",
  554. ((sbrn & 0xf0)>>4), (sbrn & 0x0f),
  555. first ? "initialized" : "restarted",
  556. temp >> 8, temp & 0xff, DRIVER_VERSION);
  557. writel (INTR_MASK, &ehci->regs->intr_enable); /* Turn On Interrupts */
  558. if (first)
  559. create_debug_files (ehci);
  560. return 0;
  561. }
  562. /* always called by thread; normally rmmod */
  563. static void ehci_stop (struct usb_hcd *hcd)
  564. {
  565. struct ehci_hcd *ehci = hcd_to_ehci (hcd);
  566. ehci_dbg (ehci, "stop\n");
  567. /* Turn off port power on all root hub ports. */
  568. ehci_port_power (ehci, 0);
  569. /* no more interrupts ... */
  570. del_timer_sync (&ehci->watchdog);
  571. spin_lock_irq(&ehci->lock);
  572. if (HC_IS_RUNNING (hcd->state))
  573. ehci_quiesce (ehci);
  574. ehci_reset (ehci);
  575. writel (0, &ehci->regs->intr_enable);
  576. spin_unlock_irq(&ehci->lock);
  577. /* let companion controllers work when we aren't */
  578. writel (0, &ehci->regs->configured_flag);
  579. unregister_reboot_notifier (&ehci->reboot_notifier);
  580. remove_debug_files (ehci);
  581. /* root hub is shut down separately (first, when possible) */
  582. spin_lock_irq (&ehci->lock);
  583. if (ehci->async)
  584. ehci_work (ehci, NULL);
  585. spin_unlock_irq (&ehci->lock);
  586. ehci_mem_cleanup (ehci);
  587. #ifdef EHCI_STATS
  588. ehci_dbg (ehci, "irq normal %ld err %ld reclaim %ld (lost %ld)\n",
  589. ehci->stats.normal, ehci->stats.error, ehci->stats.reclaim,
  590. ehci->stats.lost_iaa);
  591. ehci_dbg (ehci, "complete %ld unlink %ld\n",
  592. ehci->stats.complete, ehci->stats.unlink);
  593. #endif
  594. dbg_status (ehci, "ehci_stop completed", readl (&ehci->regs->status));
  595. }
  596. static int ehci_get_frame (struct usb_hcd *hcd)
  597. {
  598. struct ehci_hcd *ehci = hcd_to_ehci (hcd);
  599. return (readl (&ehci->regs->frame_index) >> 3) % ehci->periodic_size;
  600. }
  601. /*-------------------------------------------------------------------------*/
  602. #ifdef CONFIG_PM
  603. /* suspend/resume, section 4.3 */
  604. /* These routines rely on the bus (pci, platform, etc)
  605. * to handle powerdown and wakeup, and currently also on
  606. * transceivers that don't need any software attention to set up
  607. * the right sort of wakeup.
  608. */
  609. static int ehci_suspend (struct usb_hcd *hcd, pm_message_t message)
  610. {
  611. struct ehci_hcd *ehci = hcd_to_ehci (hcd);
  612. if (time_before (jiffies, ehci->next_statechange))
  613. msleep (100);
  614. #ifdef CONFIG_USB_SUSPEND
  615. (void) usb_suspend_device (hcd->self.root_hub, message);
  616. #else
  617. usb_lock_device (hcd->self.root_hub);
  618. (void) ehci_hub_suspend (hcd);
  619. usb_unlock_device (hcd->self.root_hub);
  620. #endif
  621. // save (PCI) FLADJ in case of Vaux power loss
  622. // ... we'd only use it to handle clock skew
  623. return 0;
  624. }
  625. static int ehci_resume (struct usb_hcd *hcd)
  626. {
  627. struct ehci_hcd *ehci = hcd_to_ehci (hcd);
  628. unsigned port;
  629. struct usb_device *root = hcd->self.root_hub;
  630. int retval = -EINVAL;
  631. // maybe restore (PCI) FLADJ
  632. if (time_before (jiffies, ehci->next_statechange))
  633. msleep (100);
  634. /* If any port is suspended, we know we can/must resume the HC. */
  635. for (port = HCS_N_PORTS (ehci->hcs_params); port > 0; ) {
  636. u32 status;
  637. port--;
  638. status = readl (&ehci->regs->port_status [port]);
  639. if (status & PORT_SUSPEND) {
  640. down (&hcd->self.root_hub->serialize);
  641. retval = ehci_hub_resume (hcd);
  642. up (&hcd->self.root_hub->serialize);
  643. break;
  644. }
  645. if (!root->children [port])
  646. continue;
  647. dbg_port (ehci, __FUNCTION__, port + 1, status);
  648. usb_set_device_state (root->children[port],
  649. USB_STATE_NOTATTACHED);
  650. }
  651. /* Else reset, to cope with power loss or flush-to-storage
  652. * style "resume" having activated BIOS during reboot.
  653. */
  654. if (port == 0) {
  655. (void) ehci_halt (ehci);
  656. (void) ehci_reset (ehci);
  657. (void) ehci_hc_reset (hcd);
  658. /* emptying the schedule aborts any urbs */
  659. spin_lock_irq (&ehci->lock);
  660. if (ehci->reclaim)
  661. ehci->reclaim_ready = 1;
  662. ehci_work (ehci, NULL);
  663. spin_unlock_irq (&ehci->lock);
  664. /* restart; khubd will disconnect devices */
  665. retval = ehci_start (hcd);
  666. /* here we "know" root ports should always stay powered;
  667. * but some controllers may lose all power.
  668. */
  669. ehci_port_power (ehci, 1);
  670. }
  671. return retval;
  672. }
  673. #endif
  674. /*-------------------------------------------------------------------------*/
  675. /*
  676. * ehci_work is called from some interrupts, timers, and so on.
  677. * it calls driver completion functions, after dropping ehci->lock.
  678. */
  679. static void ehci_work (struct ehci_hcd *ehci, struct pt_regs *regs)
  680. {
  681. timer_action_done (ehci, TIMER_IO_WATCHDOG);
  682. if (ehci->reclaim_ready)
  683. end_unlink_async (ehci, regs);
  684. /* another CPU may drop ehci->lock during a schedule scan while
  685. * it reports urb completions. this flag guards against bogus
  686. * attempts at re-entrant schedule scanning.
  687. */
  688. if (ehci->scanning)
  689. return;
  690. ehci->scanning = 1;
  691. scan_async (ehci, regs);
  692. if (ehci->next_uframe != -1)
  693. scan_periodic (ehci, regs);
  694. ehci->scanning = 0;
  695. /* the IO watchdog guards against hardware or driver bugs that
  696. * misplace IRQs, and should let us run completely without IRQs.
  697. * such lossage has been observed on both VT6202 and VT8235.
  698. */
  699. if (HC_IS_RUNNING (ehci_to_hcd(ehci)->state) &&
  700. (ehci->async->qh_next.ptr != NULL ||
  701. ehci->periodic_sched != 0))
  702. timer_action (ehci, TIMER_IO_WATCHDOG);
  703. }
  704. /*-------------------------------------------------------------------------*/
  705. static irqreturn_t ehci_irq (struct usb_hcd *hcd, struct pt_regs *regs)
  706. {
  707. struct ehci_hcd *ehci = hcd_to_ehci (hcd);
  708. u32 status;
  709. int bh;
  710. spin_lock (&ehci->lock);
  711. status = readl (&ehci->regs->status);
  712. /* e.g. cardbus physical eject */
  713. if (status == ~(u32) 0) {
  714. ehci_dbg (ehci, "device removed\n");
  715. goto dead;
  716. }
  717. status &= INTR_MASK;
  718. if (!status) { /* irq sharing? */
  719. spin_unlock(&ehci->lock);
  720. return IRQ_NONE;
  721. }
  722. /* clear (just) interrupts */
  723. writel (status, &ehci->regs->status);
  724. readl (&ehci->regs->command); /* unblock posted write */
  725. bh = 0;
  726. #ifdef EHCI_VERBOSE_DEBUG
  727. /* unrequested/ignored: Frame List Rollover */
  728. dbg_status (ehci, "irq", status);
  729. #endif
  730. /* INT, ERR, and IAA interrupt rates can be throttled */
  731. /* normal [4.15.1.2] or error [4.15.1.1] completion */
  732. if (likely ((status & (STS_INT|STS_ERR)) != 0)) {
  733. if (likely ((status & STS_ERR) == 0))
  734. COUNT (ehci->stats.normal);
  735. else
  736. COUNT (ehci->stats.error);
  737. bh = 1;
  738. }
  739. /* complete the unlinking of some qh [4.15.2.3] */
  740. if (status & STS_IAA) {
  741. COUNT (ehci->stats.reclaim);
  742. ehci->reclaim_ready = 1;
  743. bh = 1;
  744. }
  745. /* remote wakeup [4.3.1] */
  746. if ((status & STS_PCD) && hcd->remote_wakeup) {
  747. unsigned i = HCS_N_PORTS (ehci->hcs_params);
  748. /* resume root hub? */
  749. status = readl (&ehci->regs->command);
  750. if (!(status & CMD_RUN))
  751. writel (status | CMD_RUN, &ehci->regs->command);
  752. while (i--) {
  753. status = readl (&ehci->regs->port_status [i]);
  754. if (status & PORT_OWNER)
  755. continue;
  756. if (!(status & PORT_RESUME)
  757. || ehci->reset_done [i] != 0)
  758. continue;
  759. /* start 20 msec resume signaling from this port,
  760. * and make khubd collect PORT_STAT_C_SUSPEND to
  761. * stop that signaling.
  762. */
  763. ehci->reset_done [i] = jiffies + msecs_to_jiffies (20);
  764. mod_timer (&hcd->rh_timer,
  765. ehci->reset_done [i] + 1);
  766. ehci_dbg (ehci, "port %d remote wakeup\n", i + 1);
  767. }
  768. }
  769. /* PCI errors [4.15.2.4] */
  770. if (unlikely ((status & STS_FATAL) != 0)) {
  771. /* bogus "fatal" IRQs appear on some chips... why? */
  772. status = readl (&ehci->regs->status);
  773. dbg_cmd (ehci, "fatal", readl (&ehci->regs->command));
  774. dbg_status (ehci, "fatal", status);
  775. if (status & STS_HALT) {
  776. ehci_err (ehci, "fatal error\n");
  777. dead:
  778. ehci_reset (ehci);
  779. writel (0, &ehci->regs->configured_flag);
  780. /* generic layer kills/unlinks all urbs, then
  781. * uses ehci_stop to clean up the rest
  782. */
  783. bh = 1;
  784. }
  785. }
  786. if (bh)
  787. ehci_work (ehci, regs);
  788. spin_unlock (&ehci->lock);
  789. return IRQ_HANDLED;
  790. }
  791. /*-------------------------------------------------------------------------*/
  792. /*
  793. * non-error returns are a promise to giveback() the urb later
  794. * we drop ownership so next owner (or urb unlink) can get it
  795. *
  796. * urb + dev is in hcd.self.controller.urb_list
  797. * we're queueing TDs onto software and hardware lists
  798. *
  799. * hcd-specific init for hcpriv hasn't been done yet
  800. *
  801. * NOTE: control, bulk, and interrupt share the same code to append TDs
  802. * to a (possibly active) QH, and the same QH scanning code.
  803. */
  804. static int ehci_urb_enqueue (
  805. struct usb_hcd *hcd,
  806. struct usb_host_endpoint *ep,
  807. struct urb *urb,
  808. int mem_flags
  809. ) {
  810. struct ehci_hcd *ehci = hcd_to_ehci (hcd);
  811. struct list_head qtd_list;
  812. INIT_LIST_HEAD (&qtd_list);
  813. switch (usb_pipetype (urb->pipe)) {
  814. // case PIPE_CONTROL:
  815. // case PIPE_BULK:
  816. default:
  817. if (!qh_urb_transaction (ehci, urb, &qtd_list, mem_flags))
  818. return -ENOMEM;
  819. return submit_async (ehci, ep, urb, &qtd_list, mem_flags);
  820. case PIPE_INTERRUPT:
  821. if (!qh_urb_transaction (ehci, urb, &qtd_list, mem_flags))
  822. return -ENOMEM;
  823. return intr_submit (ehci, ep, urb, &qtd_list, mem_flags);
  824. case PIPE_ISOCHRONOUS:
  825. if (urb->dev->speed == USB_SPEED_HIGH)
  826. return itd_submit (ehci, urb, mem_flags);
  827. else
  828. return sitd_submit (ehci, urb, mem_flags);
  829. }
  830. }
  831. static void unlink_async (struct ehci_hcd *ehci, struct ehci_qh *qh)
  832. {
  833. /* if we need to use IAA and it's busy, defer */
  834. if (qh->qh_state == QH_STATE_LINKED
  835. && ehci->reclaim
  836. && HC_IS_RUNNING (ehci_to_hcd(ehci)->state)) {
  837. struct ehci_qh *last;
  838. for (last = ehci->reclaim;
  839. last->reclaim;
  840. last = last->reclaim)
  841. continue;
  842. qh->qh_state = QH_STATE_UNLINK_WAIT;
  843. last->reclaim = qh;
  844. /* bypass IAA if the hc can't care */
  845. } else if (!HC_IS_RUNNING (ehci_to_hcd(ehci)->state) && ehci->reclaim)
  846. end_unlink_async (ehci, NULL);
  847. /* something else might have unlinked the qh by now */
  848. if (qh->qh_state == QH_STATE_LINKED)
  849. start_unlink_async (ehci, qh);
  850. }
  851. /* remove from hardware lists
  852. * completions normally happen asynchronously
  853. */
  854. static int ehci_urb_dequeue (struct usb_hcd *hcd, struct urb *urb)
  855. {
  856. struct ehci_hcd *ehci = hcd_to_ehci (hcd);
  857. struct ehci_qh *qh;
  858. unsigned long flags;
  859. spin_lock_irqsave (&ehci->lock, flags);
  860. switch (usb_pipetype (urb->pipe)) {
  861. // case PIPE_CONTROL:
  862. // case PIPE_BULK:
  863. default:
  864. qh = (struct ehci_qh *) urb->hcpriv;
  865. if (!qh)
  866. break;
  867. unlink_async (ehci, qh);
  868. break;
  869. case PIPE_INTERRUPT:
  870. qh = (struct ehci_qh *) urb->hcpriv;
  871. if (!qh)
  872. break;
  873. switch (qh->qh_state) {
  874. case QH_STATE_LINKED:
  875. intr_deschedule (ehci, qh);
  876. /* FALL THROUGH */
  877. case QH_STATE_IDLE:
  878. qh_completions (ehci, qh, NULL);
  879. break;
  880. default:
  881. ehci_dbg (ehci, "bogus qh %p state %d\n",
  882. qh, qh->qh_state);
  883. goto done;
  884. }
  885. /* reschedule QH iff another request is queued */
  886. if (!list_empty (&qh->qtd_list)
  887. && HC_IS_RUNNING (hcd->state)) {
  888. int status;
  889. status = qh_schedule (ehci, qh);
  890. spin_unlock_irqrestore (&ehci->lock, flags);
  891. if (status != 0) {
  892. // shouldn't happen often, but ...
  893. // FIXME kill those tds' urbs
  894. err ("can't reschedule qh %p, err %d",
  895. qh, status);
  896. }
  897. return status;
  898. }
  899. break;
  900. case PIPE_ISOCHRONOUS:
  901. // itd or sitd ...
  902. // wait till next completion, do it then.
  903. // completion irqs can wait up to 1024 msec,
  904. break;
  905. }
  906. done:
  907. spin_unlock_irqrestore (&ehci->lock, flags);
  908. return 0;
  909. }
  910. /*-------------------------------------------------------------------------*/
  911. // bulk qh holds the data toggle
  912. static void
  913. ehci_endpoint_disable (struct usb_hcd *hcd, struct usb_host_endpoint *ep)
  914. {
  915. struct ehci_hcd *ehci = hcd_to_ehci (hcd);
  916. unsigned long flags;
  917. struct ehci_qh *qh, *tmp;
  918. /* ASSERT: any requests/urbs are being unlinked */
  919. /* ASSERT: nobody can be submitting urbs for this any more */
  920. rescan:
  921. spin_lock_irqsave (&ehci->lock, flags);
  922. qh = ep->hcpriv;
  923. if (!qh)
  924. goto done;
  925. /* endpoints can be iso streams. for now, we don't
  926. * accelerate iso completions ... so spin a while.
  927. */
  928. if (qh->hw_info1 == 0) {
  929. ehci_vdbg (ehci, "iso delay\n");
  930. goto idle_timeout;
  931. }
  932. if (!HC_IS_RUNNING (hcd->state))
  933. qh->qh_state = QH_STATE_IDLE;
  934. switch (qh->qh_state) {
  935. case QH_STATE_LINKED:
  936. for (tmp = ehci->async->qh_next.qh;
  937. tmp && tmp != qh;
  938. tmp = tmp->qh_next.qh)
  939. continue;
  940. /* periodic qh self-unlinks on empty */
  941. if (!tmp)
  942. goto nogood;
  943. unlink_async (ehci, qh);
  944. /* FALL THROUGH */
  945. case QH_STATE_UNLINK: /* wait for hw to finish? */
  946. idle_timeout:
  947. spin_unlock_irqrestore (&ehci->lock, flags);
  948. set_current_state (TASK_UNINTERRUPTIBLE);
  949. schedule_timeout (1);
  950. goto rescan;
  951. case QH_STATE_IDLE: /* fully unlinked */
  952. if (list_empty (&qh->qtd_list)) {
  953. qh_put (qh);
  954. break;
  955. }
  956. /* else FALL THROUGH */
  957. default:
  958. nogood:
  959. /* caller was supposed to have unlinked any requests;
  960. * that's not our job. just leak this memory.
  961. */
  962. ehci_err (ehci, "qh %p (#%02x) state %d%s\n",
  963. qh, ep->desc.bEndpointAddress, qh->qh_state,
  964. list_empty (&qh->qtd_list) ? "" : "(has tds)");
  965. break;
  966. }
  967. ep->hcpriv = NULL;
  968. done:
  969. spin_unlock_irqrestore (&ehci->lock, flags);
  970. return;
  971. }
  972. /*-------------------------------------------------------------------------*/
  973. static const struct hc_driver ehci_driver = {
  974. .description = hcd_name,
  975. .product_desc = "EHCI Host Controller",
  976. .hcd_priv_size = sizeof(struct ehci_hcd),
  977. /*
  978. * generic hardware linkage
  979. */
  980. .irq = ehci_irq,
  981. .flags = HCD_MEMORY | HCD_USB2,
  982. /*
  983. * basic lifecycle operations
  984. */
  985. .reset = ehci_hc_reset,
  986. .start = ehci_start,
  987. #ifdef CONFIG_PM
  988. .suspend = ehci_suspend,
  989. .resume = ehci_resume,
  990. #endif
  991. .stop = ehci_stop,
  992. /*
  993. * managing i/o requests and associated device resources
  994. */
  995. .urb_enqueue = ehci_urb_enqueue,
  996. .urb_dequeue = ehci_urb_dequeue,
  997. .endpoint_disable = ehci_endpoint_disable,
  998. /*
  999. * scheduling support
  1000. */
  1001. .get_frame_number = ehci_get_frame,
  1002. /*
  1003. * root hub support
  1004. */
  1005. .hub_status_data = ehci_hub_status_data,
  1006. .hub_control = ehci_hub_control,
  1007. .hub_suspend = ehci_hub_suspend,
  1008. .hub_resume = ehci_hub_resume,
  1009. };
  1010. /*-------------------------------------------------------------------------*/
  1011. /* EHCI 1.0 doesn't require PCI */
  1012. #ifdef CONFIG_PCI
  1013. /* PCI driver selection metadata; PCI hotplugging uses this */
  1014. static const struct pci_device_id pci_ids [] = { {
  1015. /* handle any USB 2.0 EHCI controller */
  1016. PCI_DEVICE_CLASS(((PCI_CLASS_SERIAL_USB << 8) | 0x20), ~0),
  1017. .driver_data = (unsigned long) &ehci_driver,
  1018. },
  1019. { /* end: all zeroes */ }
  1020. };
  1021. MODULE_DEVICE_TABLE (pci, pci_ids);
  1022. /* pci driver glue; this is a "new style" PCI driver module */
  1023. static struct pci_driver ehci_pci_driver = {
  1024. .name = (char *) hcd_name,
  1025. .id_table = pci_ids,
  1026. .probe = usb_hcd_pci_probe,
  1027. .remove = usb_hcd_pci_remove,
  1028. #ifdef CONFIG_PM
  1029. .suspend = usb_hcd_pci_suspend,
  1030. .resume = usb_hcd_pci_resume,
  1031. #endif
  1032. };
  1033. #endif /* PCI */
  1034. #define DRIVER_INFO DRIVER_VERSION " " DRIVER_DESC
  1035. MODULE_DESCRIPTION (DRIVER_INFO);
  1036. MODULE_AUTHOR (DRIVER_AUTHOR);
  1037. MODULE_LICENSE ("GPL");
  1038. static int __init init (void)
  1039. {
  1040. if (usb_disabled())
  1041. return -ENODEV;
  1042. pr_debug ("%s: block sizes: qh %Zd qtd %Zd itd %Zd sitd %Zd\n",
  1043. hcd_name,
  1044. sizeof (struct ehci_qh), sizeof (struct ehci_qtd),
  1045. sizeof (struct ehci_itd), sizeof (struct ehci_sitd));
  1046. return pci_register_driver (&ehci_pci_driver);
  1047. }
  1048. module_init (init);
  1049. static void __exit cleanup (void)
  1050. {
  1051. pci_unregister_driver (&ehci_pci_driver);
  1052. }
  1053. module_exit (cleanup);