blob: 53ba8a56592effe83aa1e235f87c997946748464 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
2 * Universal Host Controller Interface driver for USB.
3 *
4 * Maintainer: Alan Stern <stern@rowland.harvard.edu>
5 *
6 * (C) Copyright 1999 Linus Torvalds
7 * (C) Copyright 1999-2002 Johannes Erdfelt, johannes@erdfelt.com
8 * (C) Copyright 1999 Randy Dunlap
9 * (C) Copyright 1999 Georg Acher, acher@in.tum.de
10 * (C) Copyright 1999 Deti Fliegl, deti@fliegl.de
11 * (C) Copyright 1999 Thomas Sailer, sailer@ife.ee.ethz.ch
12 * (C) Copyright 1999 Roman Weissgaerber, weissg@vienna.at
13 * (C) Copyright 2000 Yggdrasil Computing, Inc. (port of new PCI interface
14 * support from usb-ohci.c by Adam Richter, adam@yggdrasil.com).
15 * (C) Copyright 1999 Gregory P. Smith (from usb-ohci.c)
Alan Stern4daaa872005-04-09 17:30:08 -040016 * (C) Copyright 2004-2005 Alan Stern, stern@rowland.harvard.edu
Linus Torvalds1da177e2005-04-16 15:20:36 -070017 *
18 * Intel documents this fairly well, and as far as I know there
19 * are no royalties or anything like that, but even so there are
20 * people who decided that they want to do the same thing in a
21 * completely different way.
22 *
Linus Torvalds1da177e2005-04-16 15:20:36 -070023 */
24
25#include <linux/config.h>
26#ifdef CONFIG_USB_DEBUG
27#define DEBUG
28#else
29#undef DEBUG
30#endif
31#include <linux/module.h>
32#include <linux/pci.h>
33#include <linux/kernel.h>
34#include <linux/init.h>
35#include <linux/delay.h>
36#include <linux/ioport.h>
37#include <linux/sched.h>
38#include <linux/slab.h>
39#include <linux/smp_lock.h>
40#include <linux/errno.h>
41#include <linux/unistd.h>
42#include <linux/interrupt.h>
43#include <linux/spinlock.h>
44#include <linux/debugfs.h>
45#include <linux/pm.h>
46#include <linux/dmapool.h>
47#include <linux/dma-mapping.h>
48#include <linux/usb.h>
49#include <linux/bitops.h>
50
51#include <asm/uaccess.h>
52#include <asm/io.h>
53#include <asm/irq.h>
54#include <asm/system.h>
55
56#include "../core/hcd.h"
57#include "uhci-hcd.h"
58
59/*
60 * Version Information
61 */
Alan Sternc8f4fe42005-04-09 17:27:32 -040062#define DRIVER_VERSION "v2.3"
Linus Torvalds1da177e2005-04-16 15:20:36 -070063#define DRIVER_AUTHOR "Linus 'Frodo Rabbit' Torvalds, Johannes Erdfelt, \
64Randy Dunlap, Georg Acher, Deti Fliegl, Thomas Sailer, Roman Weissgaerber, \
65Alan Stern"
66#define DRIVER_DESC "USB Universal Host Controller Interface driver"
67
68/*
69 * debug = 0, no debugging messages
70 * debug = 1, dump failed URB's except for stalls
71 * debug = 2, dump all failed URB's (including stalls)
72 * show all queues in /debug/uhci/[pci_addr]
73 * debug = 3, show all TD's in URB's when dumping
74 */
75#ifdef DEBUG
76static int debug = 1;
77#else
78static int debug = 0;
79#endif
80module_param(debug, int, S_IRUGO | S_IWUSR);
81MODULE_PARM_DESC(debug, "Debug level");
82static char *errbuf;
83#define ERRBUF_LEN (32 * 1024)
84
85static kmem_cache_t *uhci_up_cachep; /* urb_priv */
86
Alan Stern6c1b4452005-04-21 16:04:58 -040087static void suspend_rh(struct uhci_hcd *uhci, enum uhci_rh_state new_state);
88static void wakeup_rh(struct uhci_hcd *uhci);
Linus Torvalds1da177e2005-04-16 15:20:36 -070089static void uhci_get_current_frame_number(struct uhci_hcd *uhci);
Linus Torvalds1da177e2005-04-16 15:20:36 -070090
91/* If a transfer is still active after this much time, turn off FSBR */
92#define IDLE_TIMEOUT msecs_to_jiffies(50)
93#define FSBR_DELAY msecs_to_jiffies(50)
94
95/* When we timeout an idle transfer for FSBR, we'll switch it over to */
96/* depth first traversal. We'll do it in groups of this number of TD's */
97/* to make sure it doesn't hog all of the bandwidth */
98#define DEPTH_INTERVAL 5
99
Alan Sternf5946f82005-04-09 17:26:00 -0400100static inline void restart_timer(struct uhci_hcd *uhci)
101{
102 mod_timer(&uhci->stall_timer, jiffies + msecs_to_jiffies(100));
103}
104
Linus Torvalds1da177e2005-04-16 15:20:36 -0700105#include "uhci-hub.c"
106#include "uhci-debug.c"
107#include "uhci-q.c"
108
Alan Sterna8bed8b2005-04-09 17:29:00 -0400109/*
110 * Make sure the controller is completely inactive, unable to
111 * generate interrupts or do DMA.
112 */
Alan Stern014e73c2005-04-09 17:24:42 -0400113static void reset_hc(struct uhci_hcd *uhci)
114{
Alan Sternc074b412005-04-22 14:39:12 -0400115 int port;
116
Alan Sterna8bed8b2005-04-09 17:29:00 -0400117 /* Turn off PIRQ enable and SMI enable. (This also turns off the
118 * BIOS's USB Legacy Support.) Turn off all the R/WC bits too.
Alan Stern014e73c2005-04-09 17:24:42 -0400119 */
Alan Sterna8bed8b2005-04-09 17:29:00 -0400120 pci_write_config_word(to_pci_dev(uhci_dev(uhci)), USBLEGSUP,
121 USBLEGSUP_RWC);
122
123 /* Reset the HC - this will force us to get a
124 * new notification of any already connected
125 * ports due to the virtual disconnect that it
126 * implies.
127 */
128 outw(USBCMD_HCRESET, uhci->io_addr + USBCMD);
129 mb();
130 udelay(5);
131 if (inw(uhci->io_addr + USBCMD) & USBCMD_HCRESET)
132 dev_warn(uhci_dev(uhci), "HCRESET not completed yet!\n");
133
134 /* Just to be safe, disable interrupt requests and
135 * make sure the controller is stopped.
136 */
Alan Stern014e73c2005-04-09 17:24:42 -0400137 outw(0, uhci->io_addr + USBINTR);
Alan Sterna8bed8b2005-04-09 17:29:00 -0400138 outw(0, uhci->io_addr + USBCMD);
Alan Stern014e73c2005-04-09 17:24:42 -0400139
Alan Sternc074b412005-04-22 14:39:12 -0400140 /* HCRESET doesn't affect the Suspend, Reset, and Resume Detect
141 * bits in the port status and control registers.
142 * We have to clear them by hand.
143 */
144 for (port = 0; port < uhci->rh_numports; ++port)
145 outw(0, uhci->io_addr + USBPORTSC1 + (port * 2));
146
Alan Sterna8bed8b2005-04-09 17:29:00 -0400147 uhci->port_c_suspend = uhci->suspended_ports =
148 uhci->resuming_ports = 0;
Alan Sternc8f4fe42005-04-09 17:27:32 -0400149 uhci->rh_state = UHCI_RH_RESET;
Alan Sterna8bed8b2005-04-09 17:29:00 -0400150 uhci->is_stopped = UHCI_IS_STOPPED;
151 uhci_to_hcd(uhci)->state = HC_STATE_HALT;
Alan Stern6c1b4452005-04-21 16:04:58 -0400152 uhci_to_hcd(uhci)->poll_rh = 0;
Alan Stern014e73c2005-04-09 17:24:42 -0400153}
154
Alan Sterna8bed8b2005-04-09 17:29:00 -0400155/*
Alan Stern4daaa872005-04-09 17:30:08 -0400156 * Last rites for a defunct/nonfunctional controller
Alan Stern02597d22005-04-28 14:51:27 -0400157 * or one we don't want to use any more.
Alan Stern4daaa872005-04-09 17:30:08 -0400158 */
159static void hc_died(struct uhci_hcd *uhci)
160{
161 reset_hc(uhci);
162 uhci->hc_inaccessible = 1;
Alan Stern6c1b4452005-04-21 16:04:58 -0400163 del_timer(&uhci->stall_timer);
Alan Stern4daaa872005-04-09 17:30:08 -0400164}
165
166/*
Alan Sterna8bed8b2005-04-09 17:29:00 -0400167 * Initialize a controller that was newly discovered or has just been
168 * resumed. In either case we can't be sure of its previous state.
169 */
170static void check_and_reset_hc(struct uhci_hcd *uhci)
171{
172 u16 legsup;
173 unsigned int cmd, intr;
174
175 /*
176 * When restarting a suspended controller, we expect all the
177 * settings to be the same as we left them:
178 *
Alan Sternc074b412005-04-22 14:39:12 -0400179 * PIRQ and SMI disabled, no R/W bits set in USBLEGSUP;
Alan Sterna8bed8b2005-04-09 17:29:00 -0400180 * Controller is stopped and configured with EGSM set;
181 * No interrupts enabled except possibly Resume Detect.
182 *
183 * If any of these conditions are violated we do a complete reset.
184 */
185 pci_read_config_word(to_pci_dev(uhci_dev(uhci)), USBLEGSUP, &legsup);
Alan Sternc074b412005-04-22 14:39:12 -0400186 if (legsup & ~(USBLEGSUP_RO | USBLEGSUP_RWC)) {
Alan Sterna8bed8b2005-04-09 17:29:00 -0400187 dev_dbg(uhci_dev(uhci), "%s: legsup = 0x%04x\n",
188 __FUNCTION__, legsup);
189 goto reset_needed;
190 }
191
192 cmd = inw(uhci->io_addr + USBCMD);
193 if ((cmd & USBCMD_RS) || !(cmd & USBCMD_CF) || !(cmd & USBCMD_EGSM)) {
194 dev_dbg(uhci_dev(uhci), "%s: cmd = 0x%04x\n",
195 __FUNCTION__, cmd);
196 goto reset_needed;
197 }
198
199 intr = inw(uhci->io_addr + USBINTR);
200 if (intr & (~USBINTR_RESUME)) {
201 dev_dbg(uhci_dev(uhci), "%s: intr = 0x%04x\n",
202 __FUNCTION__, intr);
203 goto reset_needed;
204 }
205 return;
206
207reset_needed:
208 dev_dbg(uhci_dev(uhci), "Performing full reset\n");
209 reset_hc(uhci);
210}
211
212/*
213 * Store the basic register settings needed by the controller.
214 */
215static void configure_hc(struct uhci_hcd *uhci)
216{
217 /* Set the frame length to the default: 1 ms exactly */
218 outb(USBSOF_DEFAULT, uhci->io_addr + USBSOF);
219
220 /* Store the frame list base address */
221 outl(uhci->fl->dma_handle, uhci->io_addr + USBFLBASEADD);
222
223 /* Set the current frame number */
224 outw(uhci->frame_number, uhci->io_addr + USBFRNUM);
225
226 /* Mark controller as running before we enable interrupts */
227 uhci_to_hcd(uhci)->state = HC_STATE_RUNNING;
228 mb();
229
230 /* Enable PIRQ */
231 pci_write_config_word(to_pci_dev(uhci_dev(uhci)), USBLEGSUP,
232 USBLEGSUP_DEFAULT);
233}
234
235
Alan Sternc8f4fe42005-04-09 17:27:32 -0400236static int resume_detect_interrupts_are_broken(struct uhci_hcd *uhci)
Alan Stern014e73c2005-04-09 17:24:42 -0400237{
Alan Sternc8f4fe42005-04-09 17:27:32 -0400238 int port;
Alan Stern014e73c2005-04-09 17:24:42 -0400239
Alan Sternc8f4fe42005-04-09 17:27:32 -0400240 switch (to_pci_dev(uhci_dev(uhci))->vendor) {
241 default:
242 break;
Alan Stern014e73c2005-04-09 17:24:42 -0400243
Alan Sternc8f4fe42005-04-09 17:27:32 -0400244 case PCI_VENDOR_ID_GENESYS:
245 /* Genesys Logic's GL880S controllers don't generate
246 * resume-detect interrupts.
247 */
248 return 1;
249
250 case PCI_VENDOR_ID_INTEL:
251 /* Some of Intel's USB controllers have a bug that causes
252 * resume-detect interrupts if any port has an over-current
253 * condition. To make matters worse, some motherboards
254 * hardwire unused USB ports' over-current inputs active!
255 * To prevent problems, we will not enable resume-detect
256 * interrupts if any ports are OC.
257 */
258 for (port = 0; port < uhci->rh_numports; ++port) {
259 if (inw(uhci->io_addr + USBPORTSC1 + port * 2) &
260 USBPORTSC_OC)
261 return 1;
262 }
263 break;
264 }
265 return 0;
266}
267
Alan Sterna8bed8b2005-04-09 17:29:00 -0400268static void suspend_rh(struct uhci_hcd *uhci, enum uhci_rh_state new_state)
Alan Sternc8f4fe42005-04-09 17:27:32 -0400269__releases(uhci->lock)
270__acquires(uhci->lock)
271{
272 int auto_stop;
273 int int_enable;
274
275 auto_stop = (new_state == UHCI_RH_AUTO_STOPPED);
276 dev_dbg(uhci_dev(uhci), "%s%s\n", __FUNCTION__,
277 (auto_stop ? " (auto-stop)" : ""));
278
279 /* If we get a suspend request when we're already auto-stopped
280 * then there's nothing to do.
281 */
282 if (uhci->rh_state == UHCI_RH_AUTO_STOPPED) {
283 uhci->rh_state = new_state;
284 return;
285 }
286
287 /* Enable resume-detect interrupts if they work.
288 * Then enter Global Suspend mode, still configured.
289 */
290 int_enable = (resume_detect_interrupts_are_broken(uhci) ?
291 0 : USBINTR_RESUME);
292 outw(int_enable, uhci->io_addr + USBINTR);
293 outw(USBCMD_EGSM | USBCMD_CF, uhci->io_addr + USBCMD);
Alan Sterna8bed8b2005-04-09 17:29:00 -0400294 mb();
Alan Sternc8f4fe42005-04-09 17:27:32 -0400295 udelay(5);
296
297 /* If we're auto-stopping then no devices have been attached
298 * for a while, so there shouldn't be any active URBs and the
299 * controller should stop after a few microseconds. Otherwise
300 * we will give the controller one frame to stop.
301 */
302 if (!auto_stop && !(inw(uhci->io_addr + USBSTS) & USBSTS_HCH)) {
303 uhci->rh_state = UHCI_RH_SUSPENDING;
304 spin_unlock_irq(&uhci->lock);
305 msleep(1);
306 spin_lock_irq(&uhci->lock);
Alan Stern4daaa872005-04-09 17:30:08 -0400307 if (uhci->hc_inaccessible) /* Died */
308 return;
Alan Sternc8f4fe42005-04-09 17:27:32 -0400309 }
310 if (!(inw(uhci->io_addr + USBSTS) & USBSTS_HCH))
311 dev_warn(uhci_dev(uhci), "Controller not stopped yet!\n");
312
Alan Stern014e73c2005-04-09 17:24:42 -0400313 uhci_get_current_frame_number(uhci);
Alan Sternc8f4fe42005-04-09 17:27:32 -0400314 smp_wmb();
315
316 uhci->rh_state = new_state;
Alan Stern014e73c2005-04-09 17:24:42 -0400317 uhci->is_stopped = UHCI_IS_STOPPED;
Alan Stern6c1b4452005-04-21 16:04:58 -0400318 del_timer(&uhci->stall_timer);
319 uhci_to_hcd(uhci)->poll_rh = !int_enable;
Alan Stern014e73c2005-04-09 17:24:42 -0400320
321 uhci_scan_schedule(uhci, NULL);
322}
323
Alan Sterna8bed8b2005-04-09 17:29:00 -0400324static void start_rh(struct uhci_hcd *uhci)
325{
Alan Sterna8bed8b2005-04-09 17:29:00 -0400326 uhci->is_stopped = 0;
327 smp_wmb();
328
329 /* Mark it configured and running with a 64-byte max packet.
330 * All interrupts are enabled, even though RESUME won't do anything.
331 */
332 outw(USBCMD_RS | USBCMD_CF | USBCMD_MAXP, uhci->io_addr + USBCMD);
333 outw(USBINTR_TIMEOUT | USBINTR_RESUME | USBINTR_IOC | USBINTR_SP,
334 uhci->io_addr + USBINTR);
335 mb();
Alan Stern6c1b4452005-04-21 16:04:58 -0400336 uhci->rh_state = UHCI_RH_RUNNING;
337 uhci_to_hcd(uhci)->poll_rh = 1;
338 restart_timer(uhci);
Alan Sterna8bed8b2005-04-09 17:29:00 -0400339}
340
341static void wakeup_rh(struct uhci_hcd *uhci)
Alan Sternc8f4fe42005-04-09 17:27:32 -0400342__releases(uhci->lock)
343__acquires(uhci->lock)
Alan Stern014e73c2005-04-09 17:24:42 -0400344{
Alan Sternc8f4fe42005-04-09 17:27:32 -0400345 dev_dbg(uhci_dev(uhci), "%s%s\n", __FUNCTION__,
346 uhci->rh_state == UHCI_RH_AUTO_STOPPED ?
347 " (auto-start)" : "");
Alan Stern014e73c2005-04-09 17:24:42 -0400348
Alan Sternc8f4fe42005-04-09 17:27:32 -0400349 /* If we are auto-stopped then no devices are attached so there's
350 * no need for wakeup signals. Otherwise we send Global Resume
351 * for 20 ms.
352 */
353 if (uhci->rh_state == UHCI_RH_SUSPENDED) {
354 uhci->rh_state = UHCI_RH_RESUMING;
355 outw(USBCMD_FGR | USBCMD_EGSM | USBCMD_CF,
356 uhci->io_addr + USBCMD);
357 spin_unlock_irq(&uhci->lock);
358 msleep(20);
359 spin_lock_irq(&uhci->lock);
Alan Stern4daaa872005-04-09 17:30:08 -0400360 if (uhci->hc_inaccessible) /* Died */
361 return;
Alan Stern014e73c2005-04-09 17:24:42 -0400362
Alan Sternc8f4fe42005-04-09 17:27:32 -0400363 /* End Global Resume and wait for EOP to be sent */
364 outw(USBCMD_CF, uhci->io_addr + USBCMD);
Alan Sterna8bed8b2005-04-09 17:29:00 -0400365 mb();
Alan Sternc8f4fe42005-04-09 17:27:32 -0400366 udelay(4);
367 if (inw(uhci->io_addr + USBCMD) & USBCMD_FGR)
368 dev_warn(uhci_dev(uhci), "FGR not stopped yet!\n");
Alan Stern014e73c2005-04-09 17:24:42 -0400369 }
Alan Sternc8f4fe42005-04-09 17:27:32 -0400370
Alan Sterna8bed8b2005-04-09 17:29:00 -0400371 start_rh(uhci);
Alan Stern014e73c2005-04-09 17:24:42 -0400372
Alan Stern6c1b4452005-04-21 16:04:58 -0400373 /* Restart root hub polling */
374 mod_timer(&uhci_to_hcd(uhci)->rh_timer, jiffies);
Alan Stern014e73c2005-04-09 17:24:42 -0400375}
376
Alan Sternf5946f82005-04-09 17:26:00 -0400377static void stall_callback(unsigned long _uhci)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700378{
Alan Sternf5946f82005-04-09 17:26:00 -0400379 struct uhci_hcd *uhci = (struct uhci_hcd *) _uhci;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700380 unsigned long flags;
381
382 spin_lock_irqsave(&uhci->lock, flags);
383 uhci_scan_schedule(uhci, NULL);
Alan Sternf5946f82005-04-09 17:26:00 -0400384 check_fsbr(uhci);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700385
Alan Stern6c1b4452005-04-21 16:04:58 -0400386 if (!uhci->is_stopped)
387 restart_timer(uhci);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700388 spin_unlock_irqrestore(&uhci->lock, flags);
389}
390
Linus Torvalds1da177e2005-04-16 15:20:36 -0700391static irqreturn_t uhci_irq(struct usb_hcd *hcd, struct pt_regs *regs)
392{
393 struct uhci_hcd *uhci = hcd_to_uhci(hcd);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700394 unsigned short status;
Alan Stern4daaa872005-04-09 17:30:08 -0400395 unsigned long flags;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700396
397 /*
398 * Read the interrupt status, and write it back to clear the
399 * interrupt cause. Contrary to the UHCI specification, the
400 * "HC Halted" status bit is persistent: it is RO, not R/WC.
401 */
Alan Sterna8bed8b2005-04-09 17:29:00 -0400402 status = inw(uhci->io_addr + USBSTS);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700403 if (!(status & ~USBSTS_HCH)) /* shared interrupt, not mine */
404 return IRQ_NONE;
Alan Sterna8bed8b2005-04-09 17:29:00 -0400405 outw(status, uhci->io_addr + USBSTS); /* Clear it */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700406
407 if (status & ~(USBSTS_USBINT | USBSTS_ERROR | USBSTS_RD)) {
408 if (status & USBSTS_HSE)
409 dev_err(uhci_dev(uhci), "host system error, "
410 "PCI problems?\n");
411 if (status & USBSTS_HCPE)
412 dev_err(uhci_dev(uhci), "host controller process "
413 "error, something bad happened!\n");
Alan Stern4daaa872005-04-09 17:30:08 -0400414 if (status & USBSTS_HCH) {
415 spin_lock_irqsave(&uhci->lock, flags);
416 if (uhci->rh_state >= UHCI_RH_RUNNING) {
417 dev_err(uhci_dev(uhci),
418 "host controller halted, "
Linus Torvalds1da177e2005-04-16 15:20:36 -0700419 "very bad!\n");
Alan Stern4daaa872005-04-09 17:30:08 -0400420 hc_died(uhci);
421 spin_unlock_irqrestore(&uhci->lock, flags);
422 return IRQ_HANDLED;
423 }
424 spin_unlock_irqrestore(&uhci->lock, flags);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700425 }
426 }
427
428 if (status & USBSTS_RD)
Alan Stern6c1b4452005-04-21 16:04:58 -0400429 usb_hcd_poll_rh_status(hcd);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700430
Alan Stern4daaa872005-04-09 17:30:08 -0400431 spin_lock_irqsave(&uhci->lock, flags);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700432 uhci_scan_schedule(uhci, regs);
Alan Stern4daaa872005-04-09 17:30:08 -0400433 spin_unlock_irqrestore(&uhci->lock, flags);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700434
435 return IRQ_HANDLED;
436}
437
Linus Torvalds1da177e2005-04-16 15:20:36 -0700438/*
439 * Store the current frame number in uhci->frame_number if the controller
440 * is runnning
441 */
442static void uhci_get_current_frame_number(struct uhci_hcd *uhci)
443{
444 if (!uhci->is_stopped)
445 uhci->frame_number = inw(uhci->io_addr + USBFRNUM);
446}
447
Linus Torvalds1da177e2005-04-16 15:20:36 -0700448/*
449 * De-allocate all resources
450 */
451static void release_uhci(struct uhci_hcd *uhci)
452{
453 int i;
454
455 for (i = 0; i < UHCI_NUM_SKELQH; i++)
456 if (uhci->skelqh[i]) {
457 uhci_free_qh(uhci, uhci->skelqh[i]);
458 uhci->skelqh[i] = NULL;
459 }
460
461 if (uhci->term_td) {
462 uhci_free_td(uhci, uhci->term_td);
463 uhci->term_td = NULL;
464 }
465
466 if (uhci->qh_pool) {
467 dma_pool_destroy(uhci->qh_pool);
468 uhci->qh_pool = NULL;
469 }
470
471 if (uhci->td_pool) {
472 dma_pool_destroy(uhci->td_pool);
473 uhci->td_pool = NULL;
474 }
475
476 if (uhci->fl) {
477 dma_free_coherent(uhci_dev(uhci), sizeof(*uhci->fl),
478 uhci->fl, uhci->fl->dma_handle);
479 uhci->fl = NULL;
480 }
481
482 if (uhci->dentry) {
483 debugfs_remove(uhci->dentry);
484 uhci->dentry = NULL;
485 }
486}
487
488static int uhci_reset(struct usb_hcd *hcd)
489{
490 struct uhci_hcd *uhci = hcd_to_uhci(hcd);
Alan Sternc074b412005-04-22 14:39:12 -0400491 unsigned io_size = (unsigned) hcd->rsrc_len;
492 int port;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700493
494 uhci->io_addr = (unsigned long) hcd->rsrc_start;
495
Alan Sternc074b412005-04-22 14:39:12 -0400496 /* The UHCI spec says devices must have 2 ports, and goes on to say
497 * they may have more but gives no way to determine how many there
498 * are. However, according to the UHCI spec, Bit 7 of the port
499 * status and control register is always set to 1. So we try to
500 * use this to our advantage.
501 */
502 for (port = 0; port < (io_size - USBPORTSC1) / 2; port++) {
503 unsigned int portstatus;
504
505 portstatus = inw(uhci->io_addr + USBPORTSC1 + (port * 2));
506 if (!(portstatus & 0x0080))
507 break;
508 }
509 if (debug)
510 dev_info(uhci_dev(uhci), "detected %d ports\n", port);
511
512 /* Anything less than 2 or greater than 7 is weird,
513 * so we'll ignore it.
514 */
515 if (port < 2 || port > UHCI_RH_MAXCHILD) {
516 dev_info(uhci_dev(uhci), "port count misdetected? "
517 "forcing to 2 ports\n");
518 port = 2;
519 }
520 uhci->rh_numports = port;
521
Alan Sterna8bed8b2005-04-09 17:29:00 -0400522 /* Kick BIOS off this hardware and reset if the controller
523 * isn't already safely quiescent.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700524 */
Alan Sterna8bed8b2005-04-09 17:29:00 -0400525 check_and_reset_hc(uhci);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700526 return 0;
527}
528
Alan Stern02597d22005-04-28 14:51:27 -0400529/* Make sure the controller is quiescent and that we're not using it
530 * any more. This is mainly for the benefit of programs which, like kexec,
531 * expect the hardware to be idle: not doing DMA or generating IRQs.
532 *
533 * This routine may be called in a damaged or failing kernel. Hence we
534 * do not acquire the spinlock before shutting down the controller.
535 */
536static void uhci_shutdown(struct pci_dev *pdev)
537{
538 struct usb_hcd *hcd = (struct usb_hcd *) pci_get_drvdata(pdev);
539
540 hc_died(hcd_to_uhci(hcd));
541}
542
Linus Torvalds1da177e2005-04-16 15:20:36 -0700543/*
544 * Allocate a frame list, and then setup the skeleton
545 *
546 * The hardware doesn't really know any difference
547 * in the queues, but the order does matter for the
548 * protocols higher up. The order is:
549 *
550 * - any isochronous events handled before any
551 * of the queues. We don't do that here, because
552 * we'll create the actual TD entries on demand.
553 * - The first queue is the interrupt queue.
554 * - The second queue is the control queue, split into low- and full-speed
555 * - The third queue is bulk queue.
556 * - The fourth queue is the bandwidth reclamation queue, which loops back
557 * to the full-speed control queue.
558 */
559static int uhci_start(struct usb_hcd *hcd)
560{
561 struct uhci_hcd *uhci = hcd_to_uhci(hcd);
562 int retval = -EBUSY;
Alan Sternc074b412005-04-22 14:39:12 -0400563 int i;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700564 dma_addr_t dma_handle;
565 struct usb_device *udev;
566 struct dentry *dentry;
567
Alan Stern6c1b4452005-04-21 16:04:58 -0400568 hcd->uses_new_polling = 1;
Alan Stern4daaa872005-04-09 17:30:08 -0400569 if (pci_find_capability(to_pci_dev(uhci_dev(uhci)), PCI_CAP_ID_PM))
570 hcd->can_wakeup = 1; /* Assume it supports PME# */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700571
Alan Stern4daaa872005-04-09 17:30:08 -0400572 dentry = debugfs_create_file(hcd->self.bus_name,
573 S_IFREG|S_IRUGO|S_IWUSR, uhci_debugfs_root, uhci,
574 &uhci_debug_operations);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700575 if (!dentry) {
Alan Stern4daaa872005-04-09 17:30:08 -0400576 dev_err(uhci_dev(uhci),
577 "couldn't create uhci debugfs entry\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700578 retval = -ENOMEM;
579 goto err_create_debug_entry;
580 }
581 uhci->dentry = dentry;
582
583 uhci->fsbr = 0;
584 uhci->fsbrtimeout = 0;
585
586 spin_lock_init(&uhci->lock);
587 INIT_LIST_HEAD(&uhci->qh_remove_list);
588
589 INIT_LIST_HEAD(&uhci->td_remove_list);
590
591 INIT_LIST_HEAD(&uhci->urb_remove_list);
592
593 INIT_LIST_HEAD(&uhci->urb_list);
594
595 INIT_LIST_HEAD(&uhci->complete_list);
596
597 init_waitqueue_head(&uhci->waitqh);
598
Alan Sternf5946f82005-04-09 17:26:00 -0400599 init_timer(&uhci->stall_timer);
600 uhci->stall_timer.function = stall_callback;
601 uhci->stall_timer.data = (unsigned long) uhci;
602
Linus Torvalds1da177e2005-04-16 15:20:36 -0700603 uhci->fl = dma_alloc_coherent(uhci_dev(uhci), sizeof(*uhci->fl),
604 &dma_handle, 0);
605 if (!uhci->fl) {
606 dev_err(uhci_dev(uhci), "unable to allocate "
607 "consistent memory for frame list\n");
608 goto err_alloc_fl;
609 }
610
611 memset((void *)uhci->fl, 0, sizeof(*uhci->fl));
612
613 uhci->fl->dma_handle = dma_handle;
614
615 uhci->td_pool = dma_pool_create("uhci_td", uhci_dev(uhci),
616 sizeof(struct uhci_td), 16, 0);
617 if (!uhci->td_pool) {
618 dev_err(uhci_dev(uhci), "unable to create td dma_pool\n");
619 goto err_create_td_pool;
620 }
621
622 uhci->qh_pool = dma_pool_create("uhci_qh", uhci_dev(uhci),
623 sizeof(struct uhci_qh), 16, 0);
624 if (!uhci->qh_pool) {
625 dev_err(uhci_dev(uhci), "unable to create qh dma_pool\n");
626 goto err_create_qh_pool;
627 }
628
629 /* Initialize the root hub */
630
Linus Torvalds1da177e2005-04-16 15:20:36 -0700631 udev = usb_alloc_dev(NULL, &hcd->self, 0);
632 if (!udev) {
633 dev_err(uhci_dev(uhci), "unable to allocate root hub\n");
634 goto err_alloc_root_hub;
635 }
636
637 uhci->term_td = uhci_alloc_td(uhci, udev);
638 if (!uhci->term_td) {
639 dev_err(uhci_dev(uhci), "unable to allocate terminating TD\n");
640 goto err_alloc_term_td;
641 }
642
643 for (i = 0; i < UHCI_NUM_SKELQH; i++) {
644 uhci->skelqh[i] = uhci_alloc_qh(uhci, udev);
645 if (!uhci->skelqh[i]) {
646 dev_err(uhci_dev(uhci), "unable to allocate QH\n");
647 goto err_alloc_skelqh;
648 }
649 }
650
651 /*
652 * 8 Interrupt queues; link all higher int queues to int1,
653 * then link int1 to control and control to bulk
654 */
655 uhci->skel_int128_qh->link =
656 uhci->skel_int64_qh->link =
657 uhci->skel_int32_qh->link =
658 uhci->skel_int16_qh->link =
659 uhci->skel_int8_qh->link =
660 uhci->skel_int4_qh->link =
661 uhci->skel_int2_qh->link =
662 cpu_to_le32(uhci->skel_int1_qh->dma_handle) | UHCI_PTR_QH;
663 uhci->skel_int1_qh->link = cpu_to_le32(uhci->skel_ls_control_qh->dma_handle) | UHCI_PTR_QH;
664
665 uhci->skel_ls_control_qh->link = cpu_to_le32(uhci->skel_fs_control_qh->dma_handle) | UHCI_PTR_QH;
666 uhci->skel_fs_control_qh->link = cpu_to_le32(uhci->skel_bulk_qh->dma_handle) | UHCI_PTR_QH;
667 uhci->skel_bulk_qh->link = cpu_to_le32(uhci->skel_term_qh->dma_handle) | UHCI_PTR_QH;
668
669 /* This dummy TD is to work around a bug in Intel PIIX controllers */
670 uhci_fill_td(uhci->term_td, 0, (UHCI_NULL_DATA_SIZE << 21) |
671 (0x7f << TD_TOKEN_DEVADDR_SHIFT) | USB_PID_IN, 0);
672 uhci->term_td->link = cpu_to_le32(uhci->term_td->dma_handle);
673
674 uhci->skel_term_qh->link = UHCI_PTR_TERM;
675 uhci->skel_term_qh->element = cpu_to_le32(uhci->term_td->dma_handle);
676
677 /*
678 * Fill the frame list: make all entries point to the proper
679 * interrupt queue.
680 *
681 * The interrupt queues will be interleaved as evenly as possible.
682 * There's not much to be done about period-1 interrupts; they have
683 * to occur in every frame. But we can schedule period-2 interrupts
684 * in odd-numbered frames, period-4 interrupts in frames congruent
685 * to 2 (mod 4), and so on. This way each frame only has two
686 * interrupt QHs, which will help spread out bandwidth utilization.
687 */
688 for (i = 0; i < UHCI_NUMFRAMES; i++) {
689 int irq;
690
691 /*
692 * ffs (Find First bit Set) does exactly what we need:
693 * 1,3,5,... => ffs = 0 => use skel_int2_qh = skelqh[6],
694 * 2,6,10,... => ffs = 1 => use skel_int4_qh = skelqh[5], etc.
695 * ffs > 6 => not on any high-period queue, so use
696 * skel_int1_qh = skelqh[7].
697 * Add UHCI_NUMFRAMES to insure at least one bit is set.
698 */
699 irq = 6 - (int) __ffs(i + UHCI_NUMFRAMES);
700 if (irq < 0)
701 irq = 7;
702
703 /* Only place we don't use the frame list routines */
704 uhci->fl->frame[i] = UHCI_PTR_QH |
705 cpu_to_le32(uhci->skelqh[irq]->dma_handle);
706 }
707
708 /*
709 * Some architectures require a full mb() to enforce completion of
Alan Sterna8bed8b2005-04-09 17:29:00 -0400710 * the memory writes above before the I/O transfers in configure_hc().
Linus Torvalds1da177e2005-04-16 15:20:36 -0700711 */
712 mb();
Alan Sterna8bed8b2005-04-09 17:29:00 -0400713
714 configure_hc(uhci);
715 start_rh(uhci);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700716
Linus Torvalds1da177e2005-04-16 15:20:36 -0700717 udev->speed = USB_SPEED_FULL;
718
719 if (usb_hcd_register_root_hub(udev, hcd) != 0) {
720 dev_err(uhci_dev(uhci), "unable to start root hub\n");
721 retval = -ENOMEM;
722 goto err_start_root_hub;
723 }
724
725 return 0;
726
727/*
728 * error exits:
729 */
730err_start_root_hub:
Alan Sterna8bed8b2005-04-09 17:29:00 -0400731 reset_hc(uhci);
Alan Stern6c1b4452005-04-21 16:04:58 -0400732 del_timer_sync(&uhci->stall_timer);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700733
734err_alloc_skelqh:
735 for (i = 0; i < UHCI_NUM_SKELQH; i++)
736 if (uhci->skelqh[i]) {
737 uhci_free_qh(uhci, uhci->skelqh[i]);
738 uhci->skelqh[i] = NULL;
739 }
740
741 uhci_free_td(uhci, uhci->term_td);
742 uhci->term_td = NULL;
743
744err_alloc_term_td:
745 usb_put_dev(udev);
746
747err_alloc_root_hub:
748 dma_pool_destroy(uhci->qh_pool);
749 uhci->qh_pool = NULL;
750
751err_create_qh_pool:
752 dma_pool_destroy(uhci->td_pool);
753 uhci->td_pool = NULL;
754
755err_create_td_pool:
756 dma_free_coherent(uhci_dev(uhci), sizeof(*uhci->fl),
757 uhci->fl, uhci->fl->dma_handle);
758 uhci->fl = NULL;
759
760err_alloc_fl:
761 debugfs_remove(uhci->dentry);
762 uhci->dentry = NULL;
763
764err_create_debug_entry:
765 return retval;
766}
767
768static void uhci_stop(struct usb_hcd *hcd)
769{
770 struct uhci_hcd *uhci = hcd_to_uhci(hcd);
771
Linus Torvalds1da177e2005-04-16 15:20:36 -0700772 spin_lock_irq(&uhci->lock);
Alan Sterna8bed8b2005-04-09 17:29:00 -0400773 reset_hc(uhci);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700774 uhci_scan_schedule(uhci, NULL);
775 spin_unlock_irq(&uhci->lock);
Alan Stern6c1b4452005-04-21 16:04:58 -0400776
777 del_timer_sync(&uhci->stall_timer);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700778 release_uhci(uhci);
779}
780
781#ifdef CONFIG_PM
Alan Sterna8bed8b2005-04-09 17:29:00 -0400782static int uhci_rh_suspend(struct usb_hcd *hcd)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700783{
784 struct uhci_hcd *uhci = hcd_to_uhci(hcd);
785
786 spin_lock_irq(&uhci->lock);
Alan Stern4daaa872005-04-09 17:30:08 -0400787 if (!uhci->hc_inaccessible) /* Not dead */
788 suspend_rh(uhci, UHCI_RH_SUSPENDED);
Alan Sterna8bed8b2005-04-09 17:29:00 -0400789 spin_unlock_irq(&uhci->lock);
790 return 0;
791}
792
793static int uhci_rh_resume(struct usb_hcd *hcd)
794{
795 struct uhci_hcd *uhci = hcd_to_uhci(hcd);
Alan Stern4daaa872005-04-09 17:30:08 -0400796 int rc = 0;
Alan Sterna8bed8b2005-04-09 17:29:00 -0400797
798 spin_lock_irq(&uhci->lock);
Alan Stern4daaa872005-04-09 17:30:08 -0400799 if (uhci->hc_inaccessible) {
800 if (uhci->rh_state == UHCI_RH_SUSPENDED) {
801 dev_warn(uhci_dev(uhci), "HC isn't running!\n");
802 rc = -ENODEV;
803 }
804 /* Otherwise the HC is dead */
805 } else
806 wakeup_rh(uhci);
Alan Sterna8bed8b2005-04-09 17:29:00 -0400807 spin_unlock_irq(&uhci->lock);
Alan Stern4daaa872005-04-09 17:30:08 -0400808 return rc;
Alan Sterna8bed8b2005-04-09 17:29:00 -0400809}
810
811static int uhci_suspend(struct usb_hcd *hcd, pm_message_t message)
812{
813 struct uhci_hcd *uhci = hcd_to_uhci(hcd);
Alan Stern4daaa872005-04-09 17:30:08 -0400814 int rc = 0;
Alan Sterna8bed8b2005-04-09 17:29:00 -0400815
816 dev_dbg(uhci_dev(uhci), "%s\n", __FUNCTION__);
817
818 spin_lock_irq(&uhci->lock);
Alan Stern4daaa872005-04-09 17:30:08 -0400819 if (uhci->hc_inaccessible) /* Dead or already suspended */
820 goto done;
Alan Sterna8bed8b2005-04-09 17:29:00 -0400821
822#ifndef CONFIG_USB_SUSPEND
823 /* Otherwise this would never happen */
824 suspend_rh(uhci, UHCI_RH_SUSPENDED);
825#endif
826
Alan Stern4daaa872005-04-09 17:30:08 -0400827 if (uhci->rh_state > UHCI_RH_SUSPENDED) {
828 dev_warn(uhci_dev(uhci), "Root hub isn't suspended!\n");
829 hcd->state = HC_STATE_RUNNING;
830 rc = -EBUSY;
831 goto done;
832 };
833
Alan Sterna8bed8b2005-04-09 17:29:00 -0400834 /* All PCI host controllers are required to disable IRQ generation
835 * at the source, so we must turn off PIRQ.
836 */
837 pci_write_config_word(to_pci_dev(uhci_dev(uhci)), USBLEGSUP, 0);
838 uhci->hc_inaccessible = 1;
839
840 /* FIXME: Enable non-PME# remote wakeup? */
841
Alan Stern4daaa872005-04-09 17:30:08 -0400842done:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700843 spin_unlock_irq(&uhci->lock);
Alan Stern6c1b4452005-04-21 16:04:58 -0400844 if (rc == 0)
845 del_timer_sync(&hcd->rh_timer);
Alan Stern4daaa872005-04-09 17:30:08 -0400846 return rc;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700847}
848
849static int uhci_resume(struct usb_hcd *hcd)
850{
851 struct uhci_hcd *uhci = hcd_to_uhci(hcd);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700852
Alan Sterna8bed8b2005-04-09 17:29:00 -0400853 dev_dbg(uhci_dev(uhci), "%s\n", __FUNCTION__);
854
Alan Stern4daaa872005-04-09 17:30:08 -0400855 if (uhci->rh_state == UHCI_RH_RESET) /* Dead */
856 return 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700857 spin_lock_irq(&uhci->lock);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700858
Alan Sterna8bed8b2005-04-09 17:29:00 -0400859 /* FIXME: Disable non-PME# remote wakeup? */
860
861 uhci->hc_inaccessible = 0;
862
863 /* The BIOS may have changed the controller settings during a
864 * system wakeup. Check it and reconfigure to avoid problems.
865 */
866 check_and_reset_hc(uhci);
867 configure_hc(uhci);
868
869#ifndef CONFIG_USB_SUSPEND
870 /* Otherwise this would never happen */
871 wakeup_rh(uhci);
872#endif
873 if (uhci->rh_state == UHCI_RH_RESET)
874 suspend_rh(uhci, UHCI_RH_SUSPENDED);
875
Linus Torvalds1da177e2005-04-16 15:20:36 -0700876 spin_unlock_irq(&uhci->lock);
Alan Stern6c1b4452005-04-21 16:04:58 -0400877
878 if (hcd->poll_rh)
879 usb_hcd_poll_rh_status(hcd);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700880 return 0;
881}
882#endif
883
884/* Wait until all the URBs for a particular device/endpoint are gone */
885static void uhci_hcd_endpoint_disable(struct usb_hcd *hcd,
886 struct usb_host_endpoint *ep)
887{
888 struct uhci_hcd *uhci = hcd_to_uhci(hcd);
889
890 wait_event_interruptible(uhci->waitqh, list_empty(&ep->urb_list));
891}
892
893static int uhci_hcd_get_frame_number(struct usb_hcd *hcd)
894{
895 struct uhci_hcd *uhci = hcd_to_uhci(hcd);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700896 unsigned long flags;
Alan Sternc8f4fe42005-04-09 17:27:32 -0400897 int is_stopped;
898 int frame_number;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700899
900 /* Minimize latency by avoiding the spinlock */
901 local_irq_save(flags);
Alan Sternc8f4fe42005-04-09 17:27:32 -0400902 is_stopped = uhci->is_stopped;
903 smp_rmb();
904 frame_number = (is_stopped ? uhci->frame_number :
Linus Torvalds1da177e2005-04-16 15:20:36 -0700905 inw(uhci->io_addr + USBFRNUM));
906 local_irq_restore(flags);
907 return frame_number;
908}
909
910static const char hcd_name[] = "uhci_hcd";
911
912static const struct hc_driver uhci_driver = {
913 .description = hcd_name,
914 .product_desc = "UHCI Host Controller",
915 .hcd_priv_size = sizeof(struct uhci_hcd),
916
917 /* Generic hardware linkage */
918 .irq = uhci_irq,
919 .flags = HCD_USB11,
920
921 /* Basic lifecycle operations */
922 .reset = uhci_reset,
923 .start = uhci_start,
924#ifdef CONFIG_PM
925 .suspend = uhci_suspend,
926 .resume = uhci_resume,
Alan Sterna8bed8b2005-04-09 17:29:00 -0400927 .hub_suspend = uhci_rh_suspend,
928 .hub_resume = uhci_rh_resume,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700929#endif
930 .stop = uhci_stop,
931
932 .urb_enqueue = uhci_urb_enqueue,
933 .urb_dequeue = uhci_urb_dequeue,
934
935 .endpoint_disable = uhci_hcd_endpoint_disable,
936 .get_frame_number = uhci_hcd_get_frame_number,
937
938 .hub_status_data = uhci_hub_status_data,
939 .hub_control = uhci_hub_control,
940};
941
942static const struct pci_device_id uhci_pci_ids[] = { {
943 /* handle any USB UHCI controller */
944 PCI_DEVICE_CLASS(((PCI_CLASS_SERIAL_USB << 8) | 0x00), ~0),
945 .driver_data = (unsigned long) &uhci_driver,
946 }, { /* end: all zeroes */ }
947};
948
949MODULE_DEVICE_TABLE(pci, uhci_pci_ids);
950
951static struct pci_driver uhci_pci_driver = {
952 .name = (char *)hcd_name,
953 .id_table = uhci_pci_ids,
954
955 .probe = usb_hcd_pci_probe,
956 .remove = usb_hcd_pci_remove,
Alan Stern02597d22005-04-28 14:51:27 -0400957 .shutdown = uhci_shutdown,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700958
959#ifdef CONFIG_PM
960 .suspend = usb_hcd_pci_suspend,
961 .resume = usb_hcd_pci_resume,
962#endif /* PM */
963};
964
965static int __init uhci_hcd_init(void)
966{
967 int retval = -ENOMEM;
968
969 printk(KERN_INFO DRIVER_DESC " " DRIVER_VERSION "\n");
970
971 if (usb_disabled())
972 return -ENODEV;
973
974 if (debug) {
975 errbuf = kmalloc(ERRBUF_LEN, GFP_KERNEL);
976 if (!errbuf)
977 goto errbuf_failed;
978 }
979
980 uhci_debugfs_root = debugfs_create_dir("uhci", NULL);
981 if (!uhci_debugfs_root)
982 goto debug_failed;
983
984 uhci_up_cachep = kmem_cache_create("uhci_urb_priv",
985 sizeof(struct urb_priv), 0, 0, NULL, NULL);
986 if (!uhci_up_cachep)
987 goto up_failed;
988
989 retval = pci_register_driver(&uhci_pci_driver);
990 if (retval)
991 goto init_failed;
992
993 return 0;
994
995init_failed:
996 if (kmem_cache_destroy(uhci_up_cachep))
997 warn("not all urb_priv's were freed!");
998
999up_failed:
1000 debugfs_remove(uhci_debugfs_root);
1001
1002debug_failed:
Jesper Juhl1bc3c9e2005-04-18 17:39:34 -07001003 kfree(errbuf);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001004
1005errbuf_failed:
1006
1007 return retval;
1008}
1009
1010static void __exit uhci_hcd_cleanup(void)
1011{
1012 pci_unregister_driver(&uhci_pci_driver);
1013
1014 if (kmem_cache_destroy(uhci_up_cachep))
1015 warn("not all urb_priv's were freed!");
1016
1017 debugfs_remove(uhci_debugfs_root);
Jesper Juhl1bc3c9e2005-04-18 17:39:34 -07001018 kfree(errbuf);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001019}
1020
1021module_init(uhci_hcd_init);
1022module_exit(uhci_hcd_cleanup);
1023
1024MODULE_AUTHOR(DRIVER_AUTHOR);
1025MODULE_DESCRIPTION(DRIVER_DESC);
1026MODULE_LICENSE("GPL");