ehci-hcd.c 34 KB

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