diff options
| author | Steven Whitehouse <swhiteho@redhat.com> | 2006-09-28 08:29:59 -0400 |
|---|---|---|
| committer | Steven Whitehouse <swhiteho@redhat.com> | 2006-09-28 08:29:59 -0400 |
| commit | 185a257f2f73bcd89050ad02da5bedbc28fc43fa (patch) | |
| tree | 5e32586114534ed3f2165614cba3d578f5d87307 /drivers/usb/host | |
| parent | 3f1a9aaeffd8d1cbc5ab9776c45cbd66af1c9699 (diff) | |
| parent | a77c64c1a641950626181b4857abb701d8f38ccc (diff) | |
Merge branch 'master' into gfs2
Diffstat (limited to 'drivers/usb/host')
35 files changed, 4207 insertions, 252 deletions
diff --git a/drivers/usb/host/Kconfig b/drivers/usb/host/Kconfig index b93d71d28db7..cf10cbc98f80 100644 --- a/drivers/usb/host/Kconfig +++ b/drivers/usb/host/Kconfig | |||
| @@ -83,6 +83,7 @@ config USB_OHCI_HCD | |||
| 83 | tristate "OHCI HCD support" | 83 | tristate "OHCI HCD support" |
| 84 | depends on USB && USB_ARCH_HAS_OHCI | 84 | depends on USB && USB_ARCH_HAS_OHCI |
| 85 | select ISP1301_OMAP if MACH_OMAP_H2 || MACH_OMAP_H3 | 85 | select ISP1301_OMAP if MACH_OMAP_H2 || MACH_OMAP_H3 |
| 86 | select I2C if ARCH_PNX4008 | ||
| 86 | ---help--- | 87 | ---help--- |
| 87 | The Open Host Controller Interface (OHCI) is a standard for accessing | 88 | The Open Host Controller Interface (OHCI) is a standard for accessing |
| 88 | USB 1.1 host controller hardware. It does more in hardware than Intel's | 89 | USB 1.1 host controller hardware. It does more in hardware than Intel's |
| @@ -141,6 +142,34 @@ config USB_UHCI_HCD | |||
| 141 | To compile this driver as a module, choose M here: the | 142 | To compile this driver as a module, choose M here: the |
| 142 | module will be called uhci-hcd. | 143 | module will be called uhci-hcd. |
| 143 | 144 | ||
| 145 | config USB_U132_HCD | ||
| 146 | tristate "Elan U132 Adapter Host Controller" | ||
| 147 | depends on USB && USB_FTDI_ELAN | ||
| 148 | default M | ||
| 149 | help | ||
| 150 | The U132 adapter is a USB to CardBus adapter specifically designed | ||
| 151 | for PC cards that contain an OHCI host controller. Typical PC cards | ||
| 152 | are the Orange Mobile 3G Option GlobeTrotter Fusion card. The U132 | ||
| 153 | adapter will *NOT* work with PC cards that do not contain an OHCI | ||
| 154 | controller. | ||
| 155 | |||
| 156 | For those PC cards that contain multiple OHCI controllers only ther | ||
| 157 | first one is used. | ||
| 158 | |||
| 159 | The driver consists of two modules, the "ftdi-elan" module is a | ||
| 160 | USB client driver that interfaces to the FTDI chip within ELAN's | ||
| 161 | USB-to-PCMCIA adapter, and this "u132-hcd" module is a USB host | ||
| 162 | controller driver that talks to the OHCI controller within the | ||
| 163 | CardBus cards that are inserted in the U132 adapter. | ||
| 164 | |||
| 165 | This driver has been tested with a CardBus OHCI USB adapter, and | ||
| 166 | worked with a USB PEN Drive inserted into the first USB port of | ||
| 167 | the PCCARD. A rather pointless thing to do, but useful for testing. | ||
| 168 | |||
| 169 | It is safe to say M here. | ||
| 170 | |||
| 171 | See also <http://www.elandigitalsystems.com/support/ufaq/u132linux.php> | ||
| 172 | |||
| 144 | config USB_SL811_HCD | 173 | config USB_SL811_HCD |
| 145 | tristate "SL811HS HCD support" | 174 | tristate "SL811HS HCD support" |
| 146 | depends on USB | 175 | depends on USB |
diff --git a/drivers/usb/host/Makefile b/drivers/usb/host/Makefile index e3020f4b17be..a2e58c86849f 100644 --- a/drivers/usb/host/Makefile +++ b/drivers/usb/host/Makefile | |||
| @@ -14,4 +14,5 @@ obj-$(CONFIG_USB_OHCI_HCD) += ohci-hcd.o | |||
| 14 | obj-$(CONFIG_USB_UHCI_HCD) += uhci-hcd.o | 14 | obj-$(CONFIG_USB_UHCI_HCD) += uhci-hcd.o |
| 15 | obj-$(CONFIG_USB_SL811_HCD) += sl811-hcd.o | 15 | obj-$(CONFIG_USB_SL811_HCD) += sl811-hcd.o |
| 16 | obj-$(CONFIG_USB_SL811_CS) += sl811_cs.o | 16 | obj-$(CONFIG_USB_SL811_CS) += sl811_cs.o |
| 17 | obj-$(CONFIG_USB_U132_HCD) += u132-hcd.o | ||
| 17 | obj-$(CONFIG_ETRAX_ARCH_V10) += hc_crisv10.o | 18 | obj-$(CONFIG_ETRAX_ARCH_V10) += hc_crisv10.o |
diff --git a/drivers/usb/host/ehci-au1xxx.c b/drivers/usb/host/ehci-au1xxx.c index 26ed757d22a6..5d1b12aad776 100644 --- a/drivers/usb/host/ehci-au1xxx.c +++ b/drivers/usb/host/ehci-au1xxx.c | |||
| @@ -200,6 +200,7 @@ static const struct hc_driver ehci_au1xxx_hc_driver = { | |||
| 200 | .reset = ehci_init, | 200 | .reset = ehci_init, |
| 201 | .start = ehci_run, | 201 | .start = ehci_run, |
| 202 | .stop = ehci_stop, | 202 | .stop = ehci_stop, |
| 203 | .shutdown = ehci_shutdown, | ||
| 203 | 204 | ||
| 204 | /* | 205 | /* |
| 205 | * managing i/o requests and associated device resources | 206 | * managing i/o requests and associated device resources |
| @@ -268,6 +269,7 @@ MODULE_ALIAS("au1xxx-ehci"); | |||
| 268 | static struct platform_driver ehci_hcd_au1xxx_driver = { | 269 | static struct platform_driver ehci_hcd_au1xxx_driver = { |
| 269 | .probe = ehci_hcd_au1xxx_drv_probe, | 270 | .probe = ehci_hcd_au1xxx_drv_probe, |
| 270 | .remove = ehci_hcd_au1xxx_drv_remove, | 271 | .remove = ehci_hcd_au1xxx_drv_remove, |
| 272 | .shutdown = usb_hcd_platform_shutdown, | ||
| 271 | /*.suspend = ehci_hcd_au1xxx_drv_suspend, */ | 273 | /*.suspend = ehci_hcd_au1xxx_drv_suspend, */ |
| 272 | /*.resume = ehci_hcd_au1xxx_drv_resume, */ | 274 | /*.resume = ehci_hcd_au1xxx_drv_resume, */ |
| 273 | .driver = { | 275 | .driver = { |
diff --git a/drivers/usb/host/ehci-dbg.c b/drivers/usb/host/ehci-dbg.c index 65ac9fef3a7c..23b95b2bfe15 100644 --- a/drivers/usb/host/ehci-dbg.c +++ b/drivers/usb/host/ehci-dbg.c | |||
| @@ -1,6 +1,6 @@ | |||
| 1 | /* | 1 | /* |
| 2 | * Copyright (c) 2001-2002 by David Brownell | 2 | * Copyright (c) 2001-2002 by David Brownell |
| 3 | * | 3 | * |
| 4 | * This program is free software; you can redistribute it and/or modify it | 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 | 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 | 6 | * Free Software Foundation; either version 2 of the License, or (at your |
| @@ -65,7 +65,7 @@ static void dbg_hcs_params (struct ehci_hcd *ehci, char *label) | |||
| 65 | for (i = 0; i < HCS_N_PORTS (params); i++) { | 65 | for (i = 0; i < HCS_N_PORTS (params); i++) { |
| 66 | // FIXME MIPS won't readb() ... | 66 | // FIXME MIPS won't readb() ... |
| 67 | byte = readb (&ehci->caps->portroute[(i>>1)]); | 67 | byte = readb (&ehci->caps->portroute[(i>>1)]); |
| 68 | sprintf(tmp, "%d ", | 68 | sprintf(tmp, "%d ", |
| 69 | ((i & 0x1) ? ((byte)&0xf) : ((byte>>4)&0xf))); | 69 | ((i & 0x1) ? ((byte)&0xf) : ((byte>>4)&0xf))); |
| 70 | strcat(buf, tmp); | 70 | strcat(buf, tmp); |
| 71 | } | 71 | } |
| @@ -141,12 +141,12 @@ dbg_qh (const char *label, struct ehci_hcd *ehci, struct ehci_qh *qh) | |||
| 141 | } | 141 | } |
| 142 | 142 | ||
| 143 | static void __attribute__((__unused__)) | 143 | static void __attribute__((__unused__)) |
| 144 | dbg_itd (const char *label, struct ehci_hcd *ehci, struct ehci_itd *itd) | 144 | dbg_itd (const char *label, struct ehci_hcd *ehci, struct ehci_itd *itd) |
| 145 | { | 145 | { |
| 146 | ehci_dbg (ehci, "%s [%d] itd %p, next %08x, urb %p\n", | 146 | ehci_dbg (ehci, "%s [%d] itd %p, next %08x, urb %p\n", |
| 147 | label, itd->frame, itd, le32_to_cpu(itd->hw_next), itd->urb); | 147 | label, itd->frame, itd, le32_to_cpu(itd->hw_next), itd->urb); |
| 148 | ehci_dbg (ehci, | 148 | ehci_dbg (ehci, |
| 149 | " trans: %08x %08x %08x %08x %08x %08x %08x %08x\n", | 149 | " trans: %08x %08x %08x %08x %08x %08x %08x %08x\n", |
| 150 | le32_to_cpu(itd->hw_transaction[0]), | 150 | le32_to_cpu(itd->hw_transaction[0]), |
| 151 | le32_to_cpu(itd->hw_transaction[1]), | 151 | le32_to_cpu(itd->hw_transaction[1]), |
| 152 | le32_to_cpu(itd->hw_transaction[2]), | 152 | le32_to_cpu(itd->hw_transaction[2]), |
| @@ -156,7 +156,7 @@ dbg_itd (const char *label, struct ehci_hcd *ehci, struct ehci_itd *itd) | |||
| 156 | le32_to_cpu(itd->hw_transaction[6]), | 156 | le32_to_cpu(itd->hw_transaction[6]), |
| 157 | le32_to_cpu(itd->hw_transaction[7])); | 157 | le32_to_cpu(itd->hw_transaction[7])); |
| 158 | ehci_dbg (ehci, | 158 | ehci_dbg (ehci, |
| 159 | " buf: %08x %08x %08x %08x %08x %08x %08x\n", | 159 | " buf: %08x %08x %08x %08x %08x %08x %08x\n", |
| 160 | le32_to_cpu(itd->hw_bufp[0]), | 160 | le32_to_cpu(itd->hw_bufp[0]), |
| 161 | le32_to_cpu(itd->hw_bufp[1]), | 161 | le32_to_cpu(itd->hw_bufp[1]), |
| 162 | le32_to_cpu(itd->hw_bufp[2]), | 162 | le32_to_cpu(itd->hw_bufp[2]), |
| @@ -171,12 +171,12 @@ dbg_itd (const char *label, struct ehci_hcd *ehci, struct ehci_itd *itd) | |||
| 171 | } | 171 | } |
| 172 | 172 | ||
| 173 | static void __attribute__((__unused__)) | 173 | static void __attribute__((__unused__)) |
| 174 | dbg_sitd (const char *label, struct ehci_hcd *ehci, struct ehci_sitd *sitd) | 174 | dbg_sitd (const char *label, struct ehci_hcd *ehci, struct ehci_sitd *sitd) |
| 175 | { | 175 | { |
| 176 | ehci_dbg (ehci, "%s [%d] sitd %p, next %08x, urb %p\n", | 176 | ehci_dbg (ehci, "%s [%d] sitd %p, next %08x, urb %p\n", |
| 177 | label, sitd->frame, sitd, le32_to_cpu(sitd->hw_next), sitd->urb); | 177 | label, sitd->frame, sitd, le32_to_cpu(sitd->hw_next), sitd->urb); |
| 178 | ehci_dbg (ehci, | 178 | ehci_dbg (ehci, |
| 179 | " addr %08x sched %04x result %08x buf %08x %08x\n", | 179 | " addr %08x sched %04x result %08x buf %08x %08x\n", |
| 180 | le32_to_cpu(sitd->hw_fullspeed_ep), | 180 | le32_to_cpu(sitd->hw_fullspeed_ep), |
| 181 | le32_to_cpu(sitd->hw_uframe), | 181 | le32_to_cpu(sitd->hw_uframe), |
| 182 | le32_to_cpu(sitd->hw_results), | 182 | le32_to_cpu(sitd->hw_results), |
| @@ -451,7 +451,7 @@ show_async (struct class_device *class_dev, char *buf) | |||
| 451 | *buf = 0; | 451 | *buf = 0; |
| 452 | 452 | ||
| 453 | bus = class_get_devdata(class_dev); | 453 | bus = class_get_devdata(class_dev); |
| 454 | hcd = bus->hcpriv; | 454 | hcd = bus_to_hcd(bus); |
| 455 | ehci = hcd_to_ehci (hcd); | 455 | ehci = hcd_to_ehci (hcd); |
| 456 | next = buf; | 456 | next = buf; |
| 457 | size = PAGE_SIZE; | 457 | size = PAGE_SIZE; |
| @@ -497,7 +497,7 @@ show_periodic (struct class_device *class_dev, char *buf) | |||
| 497 | seen_count = 0; | 497 | seen_count = 0; |
| 498 | 498 | ||
| 499 | bus = class_get_devdata(class_dev); | 499 | bus = class_get_devdata(class_dev); |
| 500 | hcd = bus->hcpriv; | 500 | hcd = bus_to_hcd(bus); |
| 501 | ehci = hcd_to_ehci (hcd); | 501 | ehci = hcd_to_ehci (hcd); |
| 502 | next = buf; | 502 | next = buf; |
| 503 | size = PAGE_SIZE; | 503 | size = PAGE_SIZE; |
| @@ -634,7 +634,7 @@ show_registers (struct class_device *class_dev, char *buf) | |||
| 634 | static char label [] = ""; | 634 | static char label [] = ""; |
| 635 | 635 | ||
| 636 | bus = class_get_devdata(class_dev); | 636 | bus = class_get_devdata(class_dev); |
| 637 | hcd = bus->hcpriv; | 637 | hcd = bus_to_hcd(bus); |
| 638 | ehci = hcd_to_ehci (hcd); | 638 | ehci = hcd_to_ehci (hcd); |
| 639 | next = buf; | 639 | next = buf; |
| 640 | size = PAGE_SIZE; | 640 | size = PAGE_SIZE; |
| @@ -754,9 +754,7 @@ show_registers (struct class_device *class_dev, char *buf) | |||
| 754 | } | 754 | } |
| 755 | 755 | ||
| 756 | if (ehci->reclaim) { | 756 | if (ehci->reclaim) { |
| 757 | temp = scnprintf (next, size, "reclaim qh %p%s\n", | 757 | temp = scnprintf (next, size, "reclaim qh %p\n", ehci->reclaim); |
| 758 | ehci->reclaim, | ||
| 759 | ehci->reclaim_ready ? " ready" : ""); | ||
| 760 | size -= temp; | 758 | size -= temp; |
| 761 | next += temp; | 759 | next += temp; |
| 762 | } | 760 | } |
| @@ -785,10 +783,11 @@ static CLASS_DEVICE_ATTR (registers, S_IRUGO, show_registers, NULL); | |||
| 785 | static inline void create_debug_files (struct ehci_hcd *ehci) | 783 | static inline void create_debug_files (struct ehci_hcd *ehci) |
| 786 | { | 784 | { |
| 787 | struct class_device *cldev = ehci_to_hcd(ehci)->self.class_dev; | 785 | struct class_device *cldev = ehci_to_hcd(ehci)->self.class_dev; |
| 786 | int retval; | ||
| 788 | 787 | ||
| 789 | class_device_create_file(cldev, &class_device_attr_async); | 788 | retval = class_device_create_file(cldev, &class_device_attr_async); |
| 790 | class_device_create_file(cldev, &class_device_attr_periodic); | 789 | retval = class_device_create_file(cldev, &class_device_attr_periodic); |
| 791 | class_device_create_file(cldev, &class_device_attr_registers); | 790 | retval = class_device_create_file(cldev, &class_device_attr_registers); |
| 792 | } | 791 | } |
| 793 | 792 | ||
| 794 | static inline void remove_debug_files (struct ehci_hcd *ehci) | 793 | static inline void remove_debug_files (struct ehci_hcd *ehci) |
diff --git a/drivers/usb/host/ehci-fsl.c b/drivers/usb/host/ehci-fsl.c index d030516edfb9..1a915e982c1c 100644 --- a/drivers/usb/host/ehci-fsl.c +++ b/drivers/usb/host/ehci-fsl.c | |||
| @@ -285,6 +285,7 @@ static const struct hc_driver ehci_fsl_hc_driver = { | |||
| 285 | .resume = ehci_bus_resume, | 285 | .resume = ehci_bus_resume, |
| 286 | #endif | 286 | #endif |
| 287 | .stop = ehci_stop, | 287 | .stop = ehci_stop, |
| 288 | .shutdown = ehci_shutdown, | ||
| 288 | 289 | ||
| 289 | /* | 290 | /* |
| 290 | * managing i/o requests and associated device resources | 291 | * managing i/o requests and associated device resources |
| @@ -329,6 +330,7 @@ MODULE_ALIAS("fsl-ehci"); | |||
| 329 | static struct platform_driver ehci_fsl_driver = { | 330 | static struct platform_driver ehci_fsl_driver = { |
| 330 | .probe = ehci_fsl_drv_probe, | 331 | .probe = ehci_fsl_drv_probe, |
| 331 | .remove = ehci_fsl_drv_remove, | 332 | .remove = ehci_fsl_drv_remove, |
| 333 | .shutdown = usb_hcd_platform_shutdown, | ||
| 332 | .driver = { | 334 | .driver = { |
| 333 | .name = "fsl-ehci", | 335 | .name = "fsl-ehci", |
| 334 | }, | 336 | }, |
diff --git a/drivers/usb/host/ehci-hcd.c b/drivers/usb/host/ehci-hcd.c index d63177a8eaea..5ac918591131 100644 --- a/drivers/usb/host/ehci-hcd.c +++ b/drivers/usb/host/ehci-hcd.c | |||
| @@ -1,6 +1,6 @@ | |||
| 1 | /* | 1 | /* |
| 2 | * Copyright (c) 2000-2004 by David Brownell | 2 | * Copyright (c) 2000-2004 by David Brownell |
| 3 | * | 3 | * |
| 4 | * This program is free software; you can redistribute it and/or modify it | 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 | 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 | 6 | * Free Software Foundation; either version 2 of the License, or (at your |
| @@ -70,7 +70,7 @@ | |||
| 70 | * 2002-08-06 Handling for bulk and interrupt transfers is mostly shared; | 70 | * 2002-08-06 Handling for bulk and interrupt transfers is mostly shared; |
| 71 | * only scheduling is different, no arbitrary limitations. | 71 | * only scheduling is different, no arbitrary limitations. |
| 72 | * 2002-07-25 Sanity check PCI reads, mostly for better cardbus support, | 72 | * 2002-07-25 Sanity check PCI reads, mostly for better cardbus support, |
| 73 | * clean up HC run state handshaking. | 73 | * clean up HC run state handshaking. |
| 74 | * 2002-05-24 Preliminary FS/LS interrupts, using scheduling shortcuts | 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 | 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. | 76 | * missing pieces: enabling 64bit dma, handoff from BIOS/SMM. |
| @@ -111,7 +111,7 @@ static const char hcd_name [] = "ehci_hcd"; | |||
| 111 | #define EHCI_TUNE_MULT_TT 1 | 111 | #define EHCI_TUNE_MULT_TT 1 |
| 112 | #define EHCI_TUNE_FLS 2 /* (small) 256 frame schedule */ | 112 | #define EHCI_TUNE_FLS 2 /* (small) 256 frame schedule */ |
| 113 | 113 | ||
| 114 | #define EHCI_IAA_JIFFIES (HZ/100) /* arbitrary; ~10 msec */ | 114 | #define EHCI_IAA_MSECS 10 /* arbitrary */ |
| 115 | #define EHCI_IO_JIFFIES (HZ/10) /* io watchdog > irq_thresh */ | 115 | #define EHCI_IO_JIFFIES (HZ/10) /* io watchdog > irq_thresh */ |
| 116 | #define EHCI_ASYNC_JIFFIES (HZ/20) /* async idle timeout */ | 116 | #define EHCI_ASYNC_JIFFIES (HZ/20) /* async idle timeout */ |
| 117 | #define EHCI_SHRINK_JIFFIES (HZ/200) /* async qh unlink delay */ | 117 | #define EHCI_SHRINK_JIFFIES (HZ/200) /* async qh unlink delay */ |
| @@ -254,6 +254,7 @@ static void ehci_quiesce (struct ehci_hcd *ehci) | |||
| 254 | 254 | ||
| 255 | /*-------------------------------------------------------------------------*/ | 255 | /*-------------------------------------------------------------------------*/ |
| 256 | 256 | ||
| 257 | static void end_unlink_async (struct ehci_hcd *ehci, struct pt_regs *regs); | ||
| 257 | static void ehci_work(struct ehci_hcd *ehci, struct pt_regs *regs); | 258 | static void ehci_work(struct ehci_hcd *ehci, struct pt_regs *regs); |
| 258 | 259 | ||
| 259 | #include "ehci-hub.c" | 260 | #include "ehci-hub.c" |
| @@ -263,28 +264,39 @@ static void ehci_work(struct ehci_hcd *ehci, struct pt_regs *regs); | |||
| 263 | 264 | ||
| 264 | /*-------------------------------------------------------------------------*/ | 265 | /*-------------------------------------------------------------------------*/ |
| 265 | 266 | ||
| 266 | static void ehci_watchdog (unsigned long param) | 267 | static void ehci_iaa_watchdog (unsigned long param) |
| 267 | { | 268 | { |
| 268 | struct ehci_hcd *ehci = (struct ehci_hcd *) param; | 269 | struct ehci_hcd *ehci = (struct ehci_hcd *) param; |
| 269 | unsigned long flags; | 270 | unsigned long flags; |
| 271 | u32 status; | ||
| 270 | 272 | ||
| 271 | spin_lock_irqsave (&ehci->lock, flags); | 273 | spin_lock_irqsave (&ehci->lock, flags); |
| 274 | WARN_ON(!ehci->reclaim); | ||
| 272 | 275 | ||
| 273 | /* lost IAA irqs wedge things badly; seen with a vt8235 */ | 276 | /* lost IAA irqs wedge things badly; seen first with a vt8235 */ |
| 274 | if (ehci->reclaim) { | 277 | if (ehci->reclaim) { |
| 275 | u32 status = readl (&ehci->regs->status); | 278 | status = readl (&ehci->regs->status); |
| 276 | |||
| 277 | if (status & STS_IAA) { | 279 | if (status & STS_IAA) { |
| 278 | ehci_vdbg (ehci, "lost IAA\n"); | 280 | ehci_vdbg (ehci, "lost IAA\n"); |
| 279 | COUNT (ehci->stats.lost_iaa); | 281 | COUNT (ehci->stats.lost_iaa); |
| 280 | writel (STS_IAA, &ehci->regs->status); | 282 | writel (STS_IAA, &ehci->regs->status); |
| 281 | ehci->reclaim_ready = 1; | 283 | end_unlink_async (ehci, NULL); |
| 282 | } | 284 | } |
| 283 | } | 285 | } |
| 284 | 286 | ||
| 285 | /* stop async processing after it's idled a bit */ | 287 | spin_unlock_irqrestore (&ehci->lock, flags); |
| 288 | } | ||
| 289 | |||
| 290 | static void ehci_watchdog (unsigned long param) | ||
| 291 | { | ||
| 292 | struct ehci_hcd *ehci = (struct ehci_hcd *) param; | ||
| 293 | unsigned long flags; | ||
| 294 | |||
| 295 | spin_lock_irqsave (&ehci->lock, flags); | ||
| 296 | |||
| 297 | /* stop async processing after it's idled a bit */ | ||
| 286 | if (test_bit (TIMER_ASYNC_OFF, &ehci->actions)) | 298 | if (test_bit (TIMER_ASYNC_OFF, &ehci->actions)) |
| 287 | start_unlink_async (ehci, ehci->async); | 299 | start_unlink_async (ehci, ehci->async); |
| 288 | 300 | ||
| 289 | /* ehci could run by timer, without IRQs ... */ | 301 | /* ehci could run by timer, without IRQs ... */ |
| 290 | ehci_work (ehci, NULL); | 302 | ehci_work (ehci, NULL); |
| @@ -292,21 +304,20 @@ static void ehci_watchdog (unsigned long param) | |||
| 292 | spin_unlock_irqrestore (&ehci->lock, flags); | 304 | spin_unlock_irqrestore (&ehci->lock, flags); |
| 293 | } | 305 | } |
| 294 | 306 | ||
| 295 | /* Reboot notifiers kick in for silicon on any bus (not just pci, etc). | 307 | /* ehci_shutdown kick in for silicon on any bus (not just pci, etc). |
| 296 | * This forcibly disables dma and IRQs, helping kexec and other cases | 308 | * This forcibly disables dma and IRQs, helping kexec and other cases |
| 297 | * where the next system software may expect clean state. | 309 | * where the next system software may expect clean state. |
| 298 | */ | 310 | */ |
| 299 | static int | 311 | static void |
| 300 | ehci_reboot (struct notifier_block *self, unsigned long code, void *null) | 312 | ehci_shutdown (struct usb_hcd *hcd) |
| 301 | { | 313 | { |
| 302 | struct ehci_hcd *ehci; | 314 | struct ehci_hcd *ehci; |
| 303 | 315 | ||
| 304 | ehci = container_of (self, struct ehci_hcd, reboot_notifier); | 316 | ehci = hcd_to_ehci (hcd); |
| 305 | (void) ehci_halt (ehci); | 317 | (void) ehci_halt (ehci); |
| 306 | 318 | ||
| 307 | /* make BIOS/etc use companion controller during reboot */ | 319 | /* make BIOS/etc use companion controller during reboot */ |
| 308 | writel (0, &ehci->regs->configured_flag); | 320 | writel (0, &ehci->regs->configured_flag); |
| 309 | return 0; | ||
| 310 | } | 321 | } |
| 311 | 322 | ||
| 312 | static void ehci_port_power (struct ehci_hcd *ehci, int is_on) | 323 | static void ehci_port_power (struct ehci_hcd *ehci, int is_on) |
| @@ -334,8 +345,6 @@ static void ehci_port_power (struct ehci_hcd *ehci, int is_on) | |||
| 334 | static void ehci_work (struct ehci_hcd *ehci, struct pt_regs *regs) | 345 | static void ehci_work (struct ehci_hcd *ehci, struct pt_regs *regs) |
| 335 | { | 346 | { |
| 336 | timer_action_done (ehci, TIMER_IO_WATCHDOG); | 347 | timer_action_done (ehci, TIMER_IO_WATCHDOG); |
| 337 | if (ehci->reclaim_ready) | ||
| 338 | end_unlink_async (ehci, regs); | ||
| 339 | 348 | ||
| 340 | /* another CPU may drop ehci->lock during a schedule scan while | 349 | /* another CPU may drop ehci->lock during a schedule scan while |
| 341 | * it reports urb completions. this flag guards against bogus | 350 | * it reports urb completions. this flag guards against bogus |
| @@ -370,6 +379,7 @@ static void ehci_stop (struct usb_hcd *hcd) | |||
| 370 | 379 | ||
| 371 | /* no more interrupts ... */ | 380 | /* no more interrupts ... */ |
| 372 | del_timer_sync (&ehci->watchdog); | 381 | del_timer_sync (&ehci->watchdog); |
| 382 | del_timer_sync (&ehci->iaa_watchdog); | ||
| 373 | 383 | ||
| 374 | spin_lock_irq(&ehci->lock); | 384 | spin_lock_irq(&ehci->lock); |
| 375 | if (HC_IS_RUNNING (hcd->state)) | 385 | if (HC_IS_RUNNING (hcd->state)) |
| @@ -381,7 +391,6 @@ static void ehci_stop (struct usb_hcd *hcd) | |||
| 381 | 391 | ||
| 382 | /* let companion controllers work when we aren't */ | 392 | /* let companion controllers work when we aren't */ |
| 383 | writel (0, &ehci->regs->configured_flag); | 393 | writel (0, &ehci->regs->configured_flag); |
| 384 | unregister_reboot_notifier (&ehci->reboot_notifier); | ||
| 385 | 394 | ||
| 386 | remove_debug_files (ehci); | 395 | remove_debug_files (ehci); |
| 387 | 396 | ||
| @@ -417,6 +426,10 @@ static int ehci_init(struct usb_hcd *hcd) | |||
| 417 | ehci->watchdog.function = ehci_watchdog; | 426 | ehci->watchdog.function = ehci_watchdog; |
| 418 | ehci->watchdog.data = (unsigned long) ehci; | 427 | ehci->watchdog.data = (unsigned long) ehci; |
| 419 | 428 | ||
| 429 | init_timer(&ehci->iaa_watchdog); | ||
| 430 | ehci->iaa_watchdog.function = ehci_iaa_watchdog; | ||
| 431 | ehci->iaa_watchdog.data = (unsigned long) ehci; | ||
| 432 | |||
| 420 | /* | 433 | /* |
| 421 | * hw default: 1K periodic list heads, one per frame. | 434 | * hw default: 1K periodic list heads, one per frame. |
| 422 | * periodic_size can shrink by USBCMD update if hcc_params allows. | 435 | * periodic_size can shrink by USBCMD update if hcc_params allows. |
| @@ -427,13 +440,12 @@ static int ehci_init(struct usb_hcd *hcd) | |||
| 427 | 440 | ||
| 428 | /* controllers may cache some of the periodic schedule ... */ | 441 | /* controllers may cache some of the periodic schedule ... */ |
| 429 | hcc_params = readl(&ehci->caps->hcc_params); | 442 | hcc_params = readl(&ehci->caps->hcc_params); |
| 430 | if (HCC_ISOC_CACHE(hcc_params)) // full frame cache | 443 | if (HCC_ISOC_CACHE(hcc_params)) // full frame cache |
| 431 | ehci->i_thresh = 8; | 444 | ehci->i_thresh = 8; |
| 432 | else // N microframes cached | 445 | else // N microframes cached |
| 433 | ehci->i_thresh = 2 + HCC_ISOC_THRES(hcc_params); | 446 | ehci->i_thresh = 2 + HCC_ISOC_THRES(hcc_params); |
| 434 | 447 | ||
| 435 | ehci->reclaim = NULL; | 448 | ehci->reclaim = NULL; |
| 436 | ehci->reclaim_ready = 0; | ||
| 437 | ehci->next_uframe = -1; | 449 | ehci->next_uframe = -1; |
| 438 | 450 | ||
| 439 | /* | 451 | /* |
| @@ -483,9 +495,6 @@ static int ehci_init(struct usb_hcd *hcd) | |||
| 483 | } | 495 | } |
| 484 | ehci->command = temp; | 496 | ehci->command = temp; |
| 485 | 497 | ||
| 486 | ehci->reboot_notifier.notifier_call = ehci_reboot; | ||
| 487 | register_reboot_notifier(&ehci->reboot_notifier); | ||
| 488 | |||
| 489 | return 0; | 498 | return 0; |
| 490 | } | 499 | } |
| 491 | 500 | ||
| @@ -499,7 +508,6 @@ static int ehci_run (struct usb_hcd *hcd) | |||
| 499 | 508 | ||
| 500 | /* EHCI spec section 4.1 */ | 509 | /* EHCI spec section 4.1 */ |
| 501 | if ((retval = ehci_reset(ehci)) != 0) { | 510 | if ((retval = ehci_reset(ehci)) != 0) { |
| 502 | unregister_reboot_notifier(&ehci->reboot_notifier); | ||
| 503 | ehci_mem_cleanup(ehci); | 511 | ehci_mem_cleanup(ehci); |
| 504 | return retval; | 512 | return retval; |
| 505 | } | 513 | } |
| @@ -611,7 +619,7 @@ static irqreturn_t ehci_irq (struct usb_hcd *hcd, struct pt_regs *regs) | |||
| 611 | /* complete the unlinking of some qh [4.15.2.3] */ | 619 | /* complete the unlinking of some qh [4.15.2.3] */ |
| 612 | if (status & STS_IAA) { | 620 | if (status & STS_IAA) { |
| 613 | COUNT (ehci->stats.reclaim); | 621 | COUNT (ehci->stats.reclaim); |
| 614 | ehci->reclaim_ready = 1; | 622 | end_unlink_async (ehci, regs); |
| 615 | bh = 1; | 623 | bh = 1; |
| 616 | } | 624 | } |
| 617 | 625 | ||
| @@ -715,10 +723,14 @@ static int ehci_urb_enqueue ( | |||
| 715 | 723 | ||
| 716 | static void unlink_async (struct ehci_hcd *ehci, struct ehci_qh *qh) | 724 | static void unlink_async (struct ehci_hcd *ehci, struct ehci_qh *qh) |
| 717 | { | 725 | { |
| 718 | /* if we need to use IAA and it's busy, defer */ | 726 | // BUG_ON(qh->qh_state != QH_STATE_LINKED); |
| 719 | if (qh->qh_state == QH_STATE_LINKED | 727 | |
| 720 | && ehci->reclaim | 728 | /* failfast */ |
| 721 | && HC_IS_RUNNING (ehci_to_hcd(ehci)->state)) { | 729 | if (!HC_IS_RUNNING (ehci_to_hcd(ehci)->state)) |
| 730 | end_unlink_async (ehci, NULL); | ||
| 731 | |||
| 732 | /* defer till later if busy */ | ||
| 733 | else if (ehci->reclaim) { | ||
| 722 | struct ehci_qh *last; | 734 | struct ehci_qh *last; |
| 723 | 735 | ||
| 724 | for (last = ehci->reclaim; | 736 | for (last = ehci->reclaim; |
| @@ -728,12 +740,8 @@ static void unlink_async (struct ehci_hcd *ehci, struct ehci_qh *qh) | |||
| 728 | qh->qh_state = QH_STATE_UNLINK_WAIT; | 740 | qh->qh_state = QH_STATE_UNLINK_WAIT; |
| 729 | last->reclaim = qh; | 741 | last->reclaim = qh; |
| 730 | 742 | ||
| 731 | /* bypass IAA if the hc can't care */ | 743 | /* start IAA cycle */ |
| 732 | } else if (!HC_IS_RUNNING (ehci_to_hcd(ehci)->state) && ehci->reclaim) | 744 | } else |
| 733 | end_unlink_async (ehci, NULL); | ||
| 734 | |||
| 735 | /* something else might have unlinked the qh by now */ | ||
| 736 | if (qh->qh_state == QH_STATE_LINKED) | ||
| 737 | start_unlink_async (ehci, qh); | 745 | start_unlink_async (ehci, qh); |
| 738 | } | 746 | } |
| 739 | 747 | ||
| @@ -755,7 +763,19 @@ static int ehci_urb_dequeue (struct usb_hcd *hcd, struct urb *urb) | |||
| 755 | qh = (struct ehci_qh *) urb->hcpriv; | 763 | qh = (struct ehci_qh *) urb->hcpriv; |
| 756 | if (!qh) | 764 | if (!qh) |
| 757 | break; | 765 | break; |
| 758 | unlink_async (ehci, qh); | 766 | switch (qh->qh_state) { |
| 767 | case QH_STATE_LINKED: | ||
| 768 | case QH_STATE_COMPLETING: | ||
| 769 | unlink_async (ehci, qh); | ||
| 770 | break; | ||
| 771 | case QH_STATE_UNLINK: | ||
| 772 | case QH_STATE_UNLINK_WAIT: | ||
| 773 | /* already started */ | ||
| 774 | break; | ||
| 775 | case QH_STATE_IDLE: | ||
| 776 | WARN_ON(1); | ||
| 777 | break; | ||
| 778 | } | ||
| 759 | break; | 779 | break; |
| 760 | 780 | ||
| 761 | case PIPE_INTERRUPT: | 781 | case PIPE_INTERRUPT: |
| @@ -847,6 +867,7 @@ rescan: | |||
| 847 | unlink_async (ehci, qh); | 867 | unlink_async (ehci, qh); |
| 848 | /* FALL THROUGH */ | 868 | /* FALL THROUGH */ |
| 849 | case QH_STATE_UNLINK: /* wait for hw to finish? */ | 869 | case QH_STATE_UNLINK: /* wait for hw to finish? */ |
| 870 | case QH_STATE_UNLINK_WAIT: | ||
| 850 | idle_timeout: | 871 | idle_timeout: |
| 851 | spin_unlock_irqrestore (&ehci->lock, flags); | 872 | spin_unlock_irqrestore (&ehci->lock, flags); |
| 852 | schedule_timeout_uninterruptible(1); | 873 | schedule_timeout_uninterruptible(1); |
diff --git a/drivers/usb/host/ehci-hub.c b/drivers/usb/host/ehci-hub.c index d03e3cad5ca8..b2ee13c58517 100644 --- a/drivers/usb/host/ehci-hub.c +++ b/drivers/usb/host/ehci-hub.c | |||
| @@ -1,6 +1,6 @@ | |||
| 1 | /* | 1 | /* |
| 2 | * Copyright (C) 2001-2004 by David Brownell | 2 | * Copyright (C) 2001-2004 by David Brownell |
| 3 | * | 3 | * |
| 4 | * This program is free software; you can redistribute it and/or modify it | 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 | 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 | 6 | * Free Software Foundation; either version 2 of the License, or (at your |
| @@ -48,7 +48,7 @@ static int ehci_bus_suspend (struct usb_hcd *hcd) | |||
| 48 | } | 48 | } |
| 49 | ehci->command = readl (&ehci->regs->command); | 49 | ehci->command = readl (&ehci->regs->command); |
| 50 | if (ehci->reclaim) | 50 | if (ehci->reclaim) |
| 51 | ehci->reclaim_ready = 1; | 51 | end_unlink_async (ehci, NULL); |
| 52 | ehci_work(ehci, NULL); | 52 | ehci_work(ehci, NULL); |
| 53 | 53 | ||
| 54 | /* suspend any active/unsuspended ports, maybe allow wakeup */ | 54 | /* suspend any active/unsuspended ports, maybe allow wakeup */ |
| @@ -103,10 +103,10 @@ static int ehci_bus_resume (struct usb_hcd *hcd) | |||
| 103 | 103 | ||
| 104 | /* re-init operational registers in case we lost power */ | 104 | /* re-init operational registers in case we lost power */ |
| 105 | if (readl (&ehci->regs->intr_enable) == 0) { | 105 | if (readl (&ehci->regs->intr_enable) == 0) { |
| 106 | /* at least some APM implementations will try to deliver | 106 | /* at least some APM implementations will try to deliver |
| 107 | * IRQs right away, so delay them until we're ready. | 107 | * IRQs right away, so delay them until we're ready. |
| 108 | */ | 108 | */ |
| 109 | intr_enable = 1; | 109 | intr_enable = 1; |
| 110 | writel (0, &ehci->regs->segment); | 110 | writel (0, &ehci->regs->segment); |
| 111 | writel (ehci->periodic_dma, &ehci->regs->frame_list); | 111 | writel (ehci->periodic_dma, &ehci->regs->frame_list); |
| 112 | writel ((u32)ehci->async->qh_dma, &ehci->regs->async_next); | 112 | writel ((u32)ehci->async->qh_dma, &ehci->regs->async_next); |
| @@ -232,7 +232,7 @@ ehci_hub_status_data (struct usb_hcd *hcd, char *buf) | |||
| 232 | buf [1] = 0; | 232 | buf [1] = 0; |
| 233 | retval++; | 233 | retval++; |
| 234 | } | 234 | } |
| 235 | 235 | ||
| 236 | /* no hub change reports (bit 0) for now (power, ...) */ | 236 | /* no hub change reports (bit 0) for now (power, ...) */ |
| 237 | 237 | ||
| 238 | /* port N changes (bit N)? */ | 238 | /* port N changes (bit N)? */ |
| @@ -304,7 +304,7 @@ ehci_hub_descriptor ( | |||
| 304 | 304 | ||
| 305 | /*-------------------------------------------------------------------------*/ | 305 | /*-------------------------------------------------------------------------*/ |
| 306 | 306 | ||
| 307 | #define PORT_WAKE_BITS (PORT_WKOC_E|PORT_WKDISC_E|PORT_WKCONN_E) | 307 | #define PORT_WAKE_BITS (PORT_WKOC_E|PORT_WKDISC_E|PORT_WKCONN_E) |
| 308 | 308 | ||
| 309 | static int ehci_hub_control ( | 309 | static int ehci_hub_control ( |
| 310 | struct usb_hcd *hcd, | 310 | struct usb_hcd *hcd, |
diff --git a/drivers/usb/host/ehci-mem.c b/drivers/usb/host/ehci-mem.c index 766061e0260a..a8ba2e1497a4 100644 --- a/drivers/usb/host/ehci-mem.c +++ b/drivers/usb/host/ehci-mem.c | |||
| @@ -1,6 +1,6 @@ | |||
| 1 | /* | 1 | /* |
| 2 | * Copyright (c) 2001 by David Brownell | 2 | * Copyright (c) 2001 by David Brownell |
| 3 | * | 3 | * |
| 4 | * This program is free software; you can redistribute it and/or modify it | 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 | 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 | 6 | * Free Software Foundation; either version 2 of the License, or (at your |
| @@ -25,7 +25,7 @@ | |||
| 25 | * - data used only by the HCD ... kmalloc is fine | 25 | * - data used only by the HCD ... kmalloc is fine |
| 26 | * - async and periodic schedules, shared by HC and HCD ... these | 26 | * - async and periodic schedules, shared by HC and HCD ... these |
| 27 | * need to use dma_pool or dma_alloc_coherent | 27 | * need to use dma_pool or dma_alloc_coherent |
| 28 | * - driver buffers, read/written by HC ... single shot DMA mapped | 28 | * - driver buffers, read/written by HC ... single shot DMA mapped |
| 29 | * | 29 | * |
| 30 | * There's also PCI "register" data, which is memory mapped. | 30 | * There's also PCI "register" data, which is memory mapped. |
| 31 | * No memory seen by this driver is pageable. | 31 | * No memory seen by this driver is pageable. |
| @@ -119,7 +119,7 @@ static inline void qh_put (struct ehci_qh *qh) | |||
| 119 | 119 | ||
| 120 | /*-------------------------------------------------------------------------*/ | 120 | /*-------------------------------------------------------------------------*/ |
| 121 | 121 | ||
| 122 | /* The queue heads and transfer descriptors are managed from pools tied | 122 | /* The queue heads and transfer descriptors are managed from pools tied |
| 123 | * to each of the "per device" structures. | 123 | * to each of the "per device" structures. |
| 124 | * This is the initialisation and cleanup code. | 124 | * This is the initialisation and cleanup code. |
| 125 | */ | 125 | */ |
| @@ -165,7 +165,7 @@ static int ehci_mem_init (struct ehci_hcd *ehci, gfp_t flags) | |||
| 165 | int i; | 165 | int i; |
| 166 | 166 | ||
| 167 | /* QTDs for control/bulk/intr transfers */ | 167 | /* QTDs for control/bulk/intr transfers */ |
| 168 | ehci->qtd_pool = dma_pool_create ("ehci_qtd", | 168 | ehci->qtd_pool = dma_pool_create ("ehci_qtd", |
| 169 | ehci_to_hcd(ehci)->self.controller, | 169 | ehci_to_hcd(ehci)->self.controller, |
| 170 | sizeof (struct ehci_qtd), | 170 | sizeof (struct ehci_qtd), |
| 171 | 32 /* byte alignment (for hw parts) */, | 171 | 32 /* byte alignment (for hw parts) */, |
| @@ -175,7 +175,7 @@ static int ehci_mem_init (struct ehci_hcd *ehci, gfp_t flags) | |||
| 175 | } | 175 | } |
| 176 | 176 | ||
| 177 | /* QHs for control/bulk/intr transfers */ | 177 | /* QHs for control/bulk/intr transfers */ |
| 178 | ehci->qh_pool = dma_pool_create ("ehci_qh", | 178 | ehci->qh_pool = dma_pool_create ("ehci_qh", |
| 179 | ehci_to_hcd(ehci)->self.controller, | 179 | ehci_to_hcd(ehci)->self.controller, |
| 180 | sizeof (struct ehci_qh), | 180 | sizeof (struct ehci_qh), |
| 181 | 32 /* byte alignment (for hw parts) */, | 181 | 32 /* byte alignment (for hw parts) */, |
| @@ -189,7 +189,7 @@ static int ehci_mem_init (struct ehci_hcd *ehci, gfp_t flags) | |||
| 189 | } | 189 | } |
| 190 | 190 | ||
| 191 | /* ITD for high speed ISO transfers */ | 191 | /* ITD for high speed ISO transfers */ |
| 192 | ehci->itd_pool = dma_pool_create ("ehci_itd", | 192 | ehci->itd_pool = dma_pool_create ("ehci_itd", |
| 193 | ehci_to_hcd(ehci)->self.controller, | 193 | ehci_to_hcd(ehci)->self.controller, |
| 194 | sizeof (struct ehci_itd), | 194 | sizeof (struct ehci_itd), |
| 195 | 32 /* byte alignment (for hw parts) */, | 195 | 32 /* byte alignment (for hw parts) */, |
| @@ -199,7 +199,7 @@ static int ehci_mem_init (struct ehci_hcd *ehci, gfp_t flags) | |||
| 199 | } | 199 | } |
| 200 | 200 | ||
| 201 | /* SITD for full/low speed split ISO transfers */ | 201 | /* SITD for full/low speed split ISO transfers */ |
| 202 | ehci->sitd_pool = dma_pool_create ("ehci_sitd", | 202 | ehci->sitd_pool = dma_pool_create ("ehci_sitd", |
| 203 | ehci_to_hcd(ehci)->self.controller, | 203 | ehci_to_hcd(ehci)->self.controller, |
| 204 | sizeof (struct ehci_sitd), | 204 | sizeof (struct ehci_sitd), |
| 205 | 32 /* byte alignment (for hw parts) */, | 205 | 32 /* byte alignment (for hw parts) */, |
diff --git a/drivers/usb/host/ehci-pci.c b/drivers/usb/host/ehci-pci.c index cadffacd945b..08d0472d4f57 100644 --- a/drivers/usb/host/ehci-pci.c +++ b/drivers/usb/host/ehci-pci.c | |||
| @@ -238,6 +238,12 @@ static int ehci_pci_suspend(struct usb_hcd *hcd, pm_message_t message) | |||
| 238 | writel (0, &ehci->regs->intr_enable); | 238 | writel (0, &ehci->regs->intr_enable); |
| 239 | (void)readl(&ehci->regs->intr_enable); | 239 | (void)readl(&ehci->regs->intr_enable); |
| 240 | 240 | ||
| 241 | /* make sure snapshot being resumed re-enumerates everything */ | ||
| 242 | if (message.event == PM_EVENT_PRETHAW) { | ||
| 243 | ehci_halt(ehci); | ||
| 244 | ehci_reset(ehci); | ||
| 245 | } | ||
| 246 | |||
| 241 | clear_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags); | 247 | clear_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags); |
| 242 | bail: | 248 | bail: |
| 243 | spin_unlock_irqrestore (&ehci->lock, flags); | 249 | spin_unlock_irqrestore (&ehci->lock, flags); |
| @@ -297,7 +303,7 @@ restart: | |||
| 297 | /* emptying the schedule aborts any urbs */ | 303 | /* emptying the schedule aborts any urbs */ |
| 298 | spin_lock_irq(&ehci->lock); | 304 | spin_lock_irq(&ehci->lock); |
| 299 | if (ehci->reclaim) | 305 | if (ehci->reclaim) |
| 300 | ehci->reclaim_ready = 1; | 306 | end_unlink_async (ehci, NULL); |
| 301 | ehci_work(ehci, NULL); | 307 | ehci_work(ehci, NULL); |
| 302 | spin_unlock_irq(&ehci->lock); | 308 | spin_unlock_irq(&ehci->lock); |
| 303 | 309 | ||
| @@ -332,6 +338,7 @@ static const struct hc_driver ehci_pci_hc_driver = { | |||
| 332 | .resume = ehci_pci_resume, | 338 | .resume = ehci_pci_resume, |
| 333 | #endif | 339 | #endif |
| 334 | .stop = ehci_stop, | 340 | .stop = ehci_stop, |
| 341 | .shutdown = ehci_shutdown, | ||
| 335 | 342 | ||
| 336 | /* | 343 | /* |
| 337 | * managing i/o requests and associated device resources | 344 | * managing i/o requests and associated device resources |
| @@ -378,4 +385,5 @@ static struct pci_driver ehci_pci_driver = { | |||
| 378 | .suspend = usb_hcd_pci_suspend, | 385 | .suspend = usb_hcd_pci_suspend, |
| 379 | .resume = usb_hcd_pci_resume, | 386 | .resume = usb_hcd_pci_resume, |
| 380 | #endif | 387 | #endif |
| 388 | .shutdown = usb_hcd_pci_shutdown, | ||
| 381 | }; | 389 | }; |
diff --git a/drivers/usb/host/ehci-q.c b/drivers/usb/host/ehci-q.c index e469221e7ec3..7fc25b6bd7d2 100644 --- a/drivers/usb/host/ehci-q.c +++ b/drivers/usb/host/ehci-q.c | |||
| @@ -1,6 +1,6 @@ | |||
| 1 | /* | 1 | /* |
| 2 | * Copyright (C) 2001-2004 by David Brownell | 2 | * Copyright (C) 2001-2004 by David Brownell |
| 3 | * | 3 | * |
| 4 | * This program is free software; you can redistribute it and/or modify it | 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 | 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 | 6 | * Free Software Foundation; either version 2 of the License, or (at your |
| @@ -31,7 +31,7 @@ | |||
| 31 | * ISO traffic uses "ISO TD" (itd, and sitd) records, and (along with | 31 | * ISO traffic uses "ISO TD" (itd, and sitd) records, and (along with |
| 32 | * interrupts) needs careful scheduling. Performance improvements can be | 32 | * interrupts) needs careful scheduling. Performance improvements can be |
| 33 | * an ongoing challenge. That's in "ehci-sched.c". | 33 | * an ongoing challenge. That's in "ehci-sched.c". |
| 34 | * | 34 | * |
| 35 | * USB 1.1 devices are handled (a) by "companion" OHCI or UHCI root hubs, | 35 | * USB 1.1 devices are handled (a) by "companion" OHCI or UHCI root hubs, |
| 36 | * or otherwise through transaction translators (TTs) in USB 2.0 hubs using | 36 | * or otherwise through transaction translators (TTs) in USB 2.0 hubs using |
| 37 | * (b) special fields in qh entries or (c) split iso entries. TTs will | 37 | * (b) special fields in qh entries or (c) split iso entries. TTs will |
| @@ -199,7 +199,7 @@ static void qtd_copy_status ( | |||
| 199 | && ((token & QTD_STS_MMF) != 0 | 199 | && ((token & QTD_STS_MMF) != 0 |
| 200 | || QTD_CERR(token) == 0) | 200 | || QTD_CERR(token) == 0) |
| 201 | && (!ehci_is_TDI(ehci) | 201 | && (!ehci_is_TDI(ehci) |
| 202 | || urb->dev->tt->hub != | 202 | || urb->dev->tt->hub != |
| 203 | ehci_to_hcd(ehci)->self.root_hub)) { | 203 | ehci_to_hcd(ehci)->self.root_hub)) { |
| 204 | #ifdef DEBUG | 204 | #ifdef DEBUG |
| 205 | struct usb_device *tt = urb->dev->tt->hub; | 205 | struct usb_device *tt = urb->dev->tt->hub; |
| @@ -364,7 +364,7 @@ qh_completions (struct ehci_hcd *ehci, struct ehci_qh *qh, struct pt_regs *regs) | |||
| 364 | */ | 364 | */ |
| 365 | if (likely (urb->status == -EINPROGRESS)) | 365 | if (likely (urb->status == -EINPROGRESS)) |
| 366 | continue; | 366 | continue; |
| 367 | 367 | ||
| 368 | /* issue status after short control reads */ | 368 | /* issue status after short control reads */ |
| 369 | if (unlikely (do_status != 0) | 369 | if (unlikely (do_status != 0) |
| 370 | && QTD_PID (token) == 0 /* OUT */) { | 370 | && QTD_PID (token) == 0 /* OUT */) { |
| @@ -388,7 +388,7 @@ halt: | |||
| 388 | wmb (); | 388 | wmb (); |
| 389 | } | 389 | } |
| 390 | } | 390 | } |
| 391 | 391 | ||
| 392 | /* remove it from the queue */ | 392 | /* remove it from the queue */ |
| 393 | spin_lock (&urb->lock); | 393 | spin_lock (&urb->lock); |
| 394 | qtd_copy_status (ehci, urb, qtd->length, token); | 394 | qtd_copy_status (ehci, urb, qtd->length, token); |
| @@ -518,7 +518,7 @@ qh_urb_transaction ( | |||
| 518 | /* for zero length DATA stages, STATUS is always IN */ | 518 | /* for zero length DATA stages, STATUS is always IN */ |
| 519 | if (len == 0) | 519 | if (len == 0) |
| 520 | token |= (1 /* "in" */ << 8); | 520 | token |= (1 /* "in" */ << 8); |
| 521 | } | 521 | } |
| 522 | 522 | ||
| 523 | /* | 523 | /* |
| 524 | * data transfer stage: buffer setup | 524 | * data transfer stage: buffer setup |
| @@ -759,7 +759,7 @@ qh_make ( | |||
| 759 | } | 759 | } |
| 760 | break; | 760 | break; |
| 761 | default: | 761 | default: |
| 762 | dbg ("bogus dev %p speed %d", urb->dev, urb->dev->speed); | 762 | dbg ("bogus dev %p speed %d", urb->dev, urb->dev->speed); |
| 763 | done: | 763 | done: |
| 764 | qh_put (qh); | 764 | qh_put (qh); |
| 765 | return NULL; | 765 | return NULL; |
| @@ -967,17 +967,16 @@ static void end_unlink_async (struct ehci_hcd *ehci, struct pt_regs *regs) | |||
| 967 | struct ehci_qh *qh = ehci->reclaim; | 967 | struct ehci_qh *qh = ehci->reclaim; |
| 968 | struct ehci_qh *next; | 968 | struct ehci_qh *next; |
| 969 | 969 | ||
| 970 | timer_action_done (ehci, TIMER_IAA_WATCHDOG); | 970 | iaa_watchdog_done (ehci); |
| 971 | 971 | ||
| 972 | // qh->hw_next = cpu_to_le32 (qh->qh_dma); | 972 | // qh->hw_next = cpu_to_le32 (qh->qh_dma); |
| 973 | qh->qh_state = QH_STATE_IDLE; | 973 | qh->qh_state = QH_STATE_IDLE; |
| 974 | qh->qh_next.qh = NULL; | 974 | qh->qh_next.qh = NULL; |
| 975 | qh_put (qh); // refcount from reclaim | 975 | qh_put (qh); // refcount from reclaim |
| 976 | 976 | ||
| 977 | /* other unlink(s) may be pending (in QH_STATE_UNLINK_WAIT) */ | 977 | /* other unlink(s) may be pending (in QH_STATE_UNLINK_WAIT) */ |
| 978 | next = qh->reclaim; | 978 | next = qh->reclaim; |
| 979 | ehci->reclaim = next; | 979 | ehci->reclaim = next; |
| 980 | ehci->reclaim_ready = 0; | ||
| 981 | qh->reclaim = NULL; | 980 | qh->reclaim = NULL; |
| 982 | 981 | ||
| 983 | qh_completions (ehci, qh, regs); | 982 | qh_completions (ehci, qh, regs); |
| @@ -1031,7 +1030,7 @@ static void start_unlink_async (struct ehci_hcd *ehci, struct ehci_qh *qh) | |||
| 1031 | timer_action_done (ehci, TIMER_ASYNC_OFF); | 1030 | timer_action_done (ehci, TIMER_ASYNC_OFF); |
| 1032 | } | 1031 | } |
| 1033 | return; | 1032 | return; |
| 1034 | } | 1033 | } |
| 1035 | 1034 | ||
| 1036 | qh->qh_state = QH_STATE_UNLINK; | 1035 | qh->qh_state = QH_STATE_UNLINK; |
| 1037 | ehci->reclaim = qh = qh_get (qh); | 1036 | ehci->reclaim = qh = qh_get (qh); |
| @@ -1046,17 +1045,16 @@ static void start_unlink_async (struct ehci_hcd *ehci, struct ehci_qh *qh) | |||
| 1046 | 1045 | ||
| 1047 | if (unlikely (ehci_to_hcd(ehci)->state == HC_STATE_HALT)) { | 1046 | if (unlikely (ehci_to_hcd(ehci)->state == HC_STATE_HALT)) { |
| 1048 | /* if (unlikely (qh->reclaim != 0)) | 1047 | /* if (unlikely (qh->reclaim != 0)) |
| 1049 | * this will recurse, probably not much | 1048 | * this will recurse, probably not much |
| 1050 | */ | 1049 | */ |
| 1051 | end_unlink_async (ehci, NULL); | 1050 | end_unlink_async (ehci, NULL); |
| 1052 | return; | 1051 | return; |
| 1053 | } | 1052 | } |
| 1054 | 1053 | ||
| 1055 | ehci->reclaim_ready = 0; | ||
| 1056 | cmd |= CMD_IAAD; | 1054 | cmd |= CMD_IAAD; |
| 1057 | writel (cmd, &ehci->regs->command); | 1055 | writel (cmd, &ehci->regs->command); |
| 1058 | (void) readl (&ehci->regs->command); | 1056 | (void) readl (&ehci->regs->command); |
| 1059 | timer_action (ehci, TIMER_IAA_WATCHDOG); | 1057 | iaa_watchdog_start (ehci); |
| 1060 | } | 1058 | } |
| 1061 | 1059 | ||
| 1062 | /*-------------------------------------------------------------------------*/ | 1060 | /*-------------------------------------------------------------------------*/ |
diff --git a/drivers/usb/host/ehci-sched.c b/drivers/usb/host/ehci-sched.c index 4859900bd135..e5e9c653c907 100644 --- a/drivers/usb/host/ehci-sched.c +++ b/drivers/usb/host/ehci-sched.c | |||
| @@ -1,7 +1,7 @@ | |||
| 1 | /* | 1 | /* |
| 2 | * Copyright (c) 2001-2004 by David Brownell | 2 | * Copyright (c) 2001-2004 by David Brownell |
| 3 | * Copyright (c) 2003 Michal Sojka, for high-speed iso transfers | 3 | * Copyright (c) 2003 Michal Sojka, for high-speed iso transfers |
| 4 | * | 4 | * |
| 5 | * This program is free software; you can redistribute it and/or modify it | 5 | * This program is free software; you can redistribute it and/or modify it |
| 6 | * under the terms of the GNU General Public License as published by the | 6 | * under the terms of the GNU General Public License as published by the |
| 7 | * Free Software Foundation; either version 2 of the License, or (at your | 7 | * Free Software Foundation; either version 2 of the License, or (at your |
| @@ -613,7 +613,7 @@ static void intr_deschedule (struct ehci_hcd *ehci, struct ehci_qh *qh) | |||
| 613 | /*-------------------------------------------------------------------------*/ | 613 | /*-------------------------------------------------------------------------*/ |
| 614 | 614 | ||
| 615 | static int check_period ( | 615 | static int check_period ( |
| 616 | struct ehci_hcd *ehci, | 616 | struct ehci_hcd *ehci, |
| 617 | unsigned frame, | 617 | unsigned frame, |
| 618 | unsigned uframe, | 618 | unsigned uframe, |
| 619 | unsigned period, | 619 | unsigned period, |
| @@ -629,7 +629,7 @@ static int check_period ( | |||
| 629 | 629 | ||
| 630 | /* | 630 | /* |
| 631 | * 80% periodic == 100 usec/uframe available | 631 | * 80% periodic == 100 usec/uframe available |
| 632 | * convert "usecs we need" to "max already claimed" | 632 | * convert "usecs we need" to "max already claimed" |
| 633 | */ | 633 | */ |
| 634 | usecs = 100 - usecs; | 634 | usecs = 100 - usecs; |
| 635 | 635 | ||
| @@ -659,14 +659,14 @@ static int check_period ( | |||
| 659 | } | 659 | } |
| 660 | 660 | ||
| 661 | static int check_intr_schedule ( | 661 | static int check_intr_schedule ( |
| 662 | struct ehci_hcd *ehci, | 662 | struct ehci_hcd *ehci, |
| 663 | unsigned frame, | 663 | unsigned frame, |
| 664 | unsigned uframe, | 664 | unsigned uframe, |
| 665 | const struct ehci_qh *qh, | 665 | const struct ehci_qh *qh, |
| 666 | __le32 *c_maskp | 666 | __le32 *c_maskp |
| 667 | ) | 667 | ) |
| 668 | { | 668 | { |
| 669 | int retval = -ENOSPC; | 669 | int retval = -ENOSPC; |
| 670 | u8 mask = 0; | 670 | u8 mask = 0; |
| 671 | 671 | ||
| 672 | if (qh->c_usecs && uframe >= 6) /* FSTN territory? */ | 672 | if (qh->c_usecs && uframe >= 6) /* FSTN territory? */ |
| @@ -701,7 +701,7 @@ static int check_intr_schedule ( | |||
| 701 | /* Make sure this tt's buffer is also available for CSPLITs. | 701 | /* Make sure this tt's buffer is also available for CSPLITs. |
| 702 | * We pessimize a bit; probably the typical full speed case | 702 | * We pessimize a bit; probably the typical full speed case |
| 703 | * doesn't need the second CSPLIT. | 703 | * doesn't need the second CSPLIT. |
| 704 | * | 704 | * |
| 705 | * NOTE: both SPLIT and CSPLIT could be checked in just | 705 | * NOTE: both SPLIT and CSPLIT could be checked in just |
| 706 | * one smart pass... | 706 | * one smart pass... |
| 707 | */ | 707 | */ |
| @@ -728,7 +728,7 @@ done: | |||
| 728 | */ | 728 | */ |
| 729 | static int qh_schedule (struct ehci_hcd *ehci, struct ehci_qh *qh) | 729 | static int qh_schedule (struct ehci_hcd *ehci, struct ehci_qh *qh) |
| 730 | { | 730 | { |
| 731 | int status; | 731 | int status; |
| 732 | unsigned uframe; | 732 | unsigned uframe; |
| 733 | __le32 c_mask; | 733 | __le32 c_mask; |
| 734 | unsigned frame; /* 0..(qh->period - 1), or NO_FRAME */ | 734 | unsigned frame; /* 0..(qh->period - 1), or NO_FRAME */ |
| @@ -784,7 +784,7 @@ static int qh_schedule (struct ehci_hcd *ehci, struct ehci_qh *qh) | |||
| 784 | ehci_dbg (ehci, "reused qh %p schedule\n", qh); | 784 | ehci_dbg (ehci, "reused qh %p schedule\n", qh); |
| 785 | 785 | ||
| 786 | /* stuff into the periodic schedule */ | 786 | /* stuff into the periodic schedule */ |
| 787 | status = qh_link_periodic (ehci, qh); | 787 | status = qh_link_periodic (ehci, qh); |
| 788 | done: | 788 | done: |
| 789 | return status; | 789 | return status; |
| 790 | } | 790 | } |
| @@ -1681,7 +1681,7 @@ static int itd_submit (struct ehci_hcd *ehci, struct urb *urb, | |||
| 1681 | status = -ESHUTDOWN; | 1681 | status = -ESHUTDOWN; |
| 1682 | else | 1682 | else |
| 1683 | status = iso_stream_schedule (ehci, urb, stream); | 1683 | status = iso_stream_schedule (ehci, urb, stream); |
| 1684 | if (likely (status == 0)) | 1684 | if (likely (status == 0)) |
| 1685 | itd_link_urb (ehci, urb, ehci->periodic_size << 3, stream); | 1685 | itd_link_urb (ehci, urb, ehci->periodic_size << 3, stream); |
| 1686 | spin_unlock_irqrestore (&ehci->lock, flags); | 1686 | spin_unlock_irqrestore (&ehci->lock, flags); |
| 1687 | 1687 | ||
| @@ -1738,7 +1738,7 @@ sitd_sched_init ( | |||
| 1738 | if (packet->buf1 != (buf & ~(u64)0x0fff)) | 1738 | if (packet->buf1 != (buf & ~(u64)0x0fff)) |
| 1739 | packet->cross = 1; | 1739 | packet->cross = 1; |
| 1740 | 1740 | ||
| 1741 | /* OUT uses multiple start-splits */ | 1741 | /* OUT uses multiple start-splits */ |
| 1742 | if (stream->bEndpointAddress & USB_DIR_IN) | 1742 | if (stream->bEndpointAddress & USB_DIR_IN) |
| 1743 | continue; | 1743 | continue; |
| 1744 | length = (length + 187) / 188; | 1744 | length = (length + 187) / 188; |
| @@ -1925,7 +1925,7 @@ sitd_link_urb ( | |||
| 1925 | /*-------------------------------------------------------------------------*/ | 1925 | /*-------------------------------------------------------------------------*/ |
| 1926 | 1926 | ||
| 1927 | #define SITD_ERRS (SITD_STS_ERR | SITD_STS_DBE | SITD_STS_BABBLE \ | 1927 | #define SITD_ERRS (SITD_STS_ERR | SITD_STS_DBE | SITD_STS_BABBLE \ |
| 1928 | | SITD_STS_XACT | SITD_STS_MMF) | 1928 | | SITD_STS_XACT | SITD_STS_MMF) |
| 1929 | 1929 | ||
| 1930 | static unsigned | 1930 | static unsigned |
| 1931 | sitd_complete ( | 1931 | sitd_complete ( |
| @@ -2043,7 +2043,7 @@ static int sitd_submit (struct ehci_hcd *ehci, struct urb *urb, | |||
| 2043 | status = -ESHUTDOWN; | 2043 | status = -ESHUTDOWN; |
| 2044 | else | 2044 | else |
| 2045 | status = iso_stream_schedule (ehci, urb, stream); | 2045 | status = iso_stream_schedule (ehci, urb, stream); |
| 2046 | if (status == 0) | 2046 | if (status == 0) |
| 2047 | sitd_link_urb (ehci, urb, ehci->periodic_size << 3, stream); | 2047 | sitd_link_urb (ehci, urb, ehci->periodic_size << 3, stream); |
| 2048 | spin_unlock_irqrestore (&ehci->lock, flags); | 2048 | spin_unlock_irqrestore (&ehci->lock, flags); |
| 2049 | 2049 | ||
| @@ -2226,5 +2226,5 @@ restart: | |||
| 2226 | now_uframe++; | 2226 | now_uframe++; |
| 2227 | now_uframe %= mod; | 2227 | now_uframe %= mod; |
| 2228 | } | 2228 | } |
| 2229 | } | 2229 | } |
| 2230 | } | 2230 | } |
diff --git a/drivers/usb/host/ehci.h b/drivers/usb/host/ehci.h index 679c1cdcc915..6aac39f50e07 100644 --- a/drivers/usb/host/ehci.h +++ b/drivers/usb/host/ehci.h | |||
| @@ -1,6 +1,6 @@ | |||
| 1 | /* | 1 | /* |
| 2 | * Copyright (c) 2001-2002 by David Brownell | 2 | * Copyright (c) 2001-2002 by David Brownell |
| 3 | * | 3 | * |
| 4 | * This program is free software; you can redistribute it and/or modify it | 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 | 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 | 6 | * Free Software Foundation; either version 2 of the License, or (at your |
| @@ -58,7 +58,6 @@ struct ehci_hcd { /* one per controller */ | |||
| 58 | /* async schedule support */ | 58 | /* async schedule support */ |
| 59 | struct ehci_qh *async; | 59 | struct ehci_qh *async; |
| 60 | struct ehci_qh *reclaim; | 60 | struct ehci_qh *reclaim; |
| 61 | unsigned reclaim_ready : 1; | ||
| 62 | unsigned scanning : 1; | 61 | unsigned scanning : 1; |
| 63 | 62 | ||
| 64 | /* periodic schedule support */ | 63 | /* periodic schedule support */ |
| @@ -81,8 +80,8 @@ struct ehci_hcd { /* one per controller */ | |||
| 81 | struct dma_pool *itd_pool; /* itd per iso urb */ | 80 | struct dma_pool *itd_pool; /* itd per iso urb */ |
| 82 | struct dma_pool *sitd_pool; /* sitd per split iso urb */ | 81 | struct dma_pool *sitd_pool; /* sitd per split iso urb */ |
| 83 | 82 | ||
| 83 | struct timer_list iaa_watchdog; | ||
| 84 | struct timer_list watchdog; | 84 | struct timer_list watchdog; |
| 85 | struct notifier_block reboot_notifier; | ||
| 86 | unsigned long actions; | 85 | unsigned long actions; |
| 87 | unsigned stamp; | 86 | unsigned stamp; |
| 88 | unsigned long next_statechange; | 87 | unsigned long next_statechange; |
| @@ -104,7 +103,7 @@ struct ehci_hcd { /* one per controller */ | |||
| 104 | #endif | 103 | #endif |
| 105 | }; | 104 | }; |
| 106 | 105 | ||
| 107 | /* convert between an HCD pointer and the corresponding EHCI_HCD */ | 106 | /* convert between an HCD pointer and the corresponding EHCI_HCD */ |
| 108 | static inline struct ehci_hcd *hcd_to_ehci (struct usb_hcd *hcd) | 107 | static inline struct ehci_hcd *hcd_to_ehci (struct usb_hcd *hcd) |
| 109 | { | 108 | { |
| 110 | return (struct ehci_hcd *) (hcd->hcd_priv); | 109 | return (struct ehci_hcd *) (hcd->hcd_priv); |
| @@ -115,9 +114,21 @@ static inline struct usb_hcd *ehci_to_hcd (struct ehci_hcd *ehci) | |||
| 115 | } | 114 | } |
| 116 | 115 | ||
| 117 | 116 | ||
| 117 | static inline void | ||
| 118 | iaa_watchdog_start (struct ehci_hcd *ehci) | ||
| 119 | { | ||
| 120 | WARN_ON(timer_pending(&ehci->iaa_watchdog)); | ||
| 121 | mod_timer (&ehci->iaa_watchdog, | ||
| 122 | jiffies + msecs_to_jiffies(EHCI_IAA_MSECS)); | ||
| 123 | } | ||
| 124 | |||
| 125 | static inline void iaa_watchdog_done (struct ehci_hcd *ehci) | ||
| 126 | { | ||
| 127 | del_timer (&ehci->iaa_watchdog); | ||
| 128 | } | ||
| 129 | |||
| 118 | enum ehci_timer_action { | 130 | enum ehci_timer_action { |
| 119 | TIMER_IO_WATCHDOG, | 131 | TIMER_IO_WATCHDOG, |
| 120 | TIMER_IAA_WATCHDOG, | ||
| 121 | TIMER_ASYNC_SHRINK, | 132 | TIMER_ASYNC_SHRINK, |
| 122 | TIMER_ASYNC_OFF, | 133 | TIMER_ASYNC_OFF, |
| 123 | }; | 134 | }; |
| @@ -135,9 +146,6 @@ timer_action (struct ehci_hcd *ehci, enum ehci_timer_action action) | |||
| 135 | unsigned long t; | 146 | unsigned long t; |
| 136 | 147 | ||
| 137 | switch (action) { | 148 | switch (action) { |
| 138 | case TIMER_IAA_WATCHDOG: | ||
| 139 | t = EHCI_IAA_JIFFIES; | ||
| 140 | break; | ||
| 141 | case TIMER_IO_WATCHDOG: | 149 | case TIMER_IO_WATCHDOG: |
| 142 | t = EHCI_IO_JIFFIES; | 150 | t = EHCI_IO_JIFFIES; |
| 143 | break; | 151 | break; |
| @@ -154,8 +162,7 @@ timer_action (struct ehci_hcd *ehci, enum ehci_timer_action action) | |||
| 154 | // async queue SHRINK often precedes IAA. while it's ready | 162 | // async queue SHRINK often precedes IAA. while it's ready |
| 155 | // to go OFF neither can matter, and afterwards the IO | 163 | // to go OFF neither can matter, and afterwards the IO |
| 156 | // watchdog stops unless there's still periodic traffic. | 164 | // watchdog stops unless there's still periodic traffic. |
| 157 | if (action != TIMER_IAA_WATCHDOG | 165 | if (time_before_eq(t, ehci->watchdog.expires) |
| 158 | && t > ehci->watchdog.expires | ||
| 159 | && timer_pending (&ehci->watchdog)) | 166 | && timer_pending (&ehci->watchdog)) |
| 160 | return; | 167 | return; |
| 161 | mod_timer (&ehci->watchdog, t); | 168 | mod_timer (&ehci->watchdog, t); |
| @@ -179,8 +186,8 @@ struct ehci_caps { | |||
| 179 | #define HCS_INDICATOR(p) ((p)&(1 << 16)) /* true: has port indicators */ | 186 | #define HCS_INDICATOR(p) ((p)&(1 << 16)) /* true: has port indicators */ |
| 180 | #define HCS_N_CC(p) (((p)>>12)&0xf) /* bits 15:12, #companion HCs */ | 187 | #define HCS_N_CC(p) (((p)>>12)&0xf) /* bits 15:12, #companion HCs */ |
| 181 | #define HCS_N_PCC(p) (((p)>>8)&0xf) /* bits 11:8, ports per CC */ | 188 | #define HCS_N_PCC(p) (((p)>>8)&0xf) /* bits 11:8, ports per CC */ |
| 182 | #define HCS_PORTROUTED(p) ((p)&(1 << 7)) /* true: port routing */ | 189 | #define HCS_PORTROUTED(p) ((p)&(1 << 7)) /* true: port routing */ |
| 183 | #define HCS_PPC(p) ((p)&(1 << 4)) /* true: port power control */ | 190 | #define HCS_PPC(p) ((p)&(1 << 4)) /* true: port power control */ |
| 184 | #define HCS_N_PORTS(p) (((p)>>0)&0xf) /* bits 3:0, ports on HC */ | 191 | #define HCS_N_PORTS(p) (((p)>>0)&0xf) /* bits 3:0, ports on HC */ |
| 185 | 192 | ||
| 186 | u32 hcc_params; /* HCCPARAMS - offset 0x8 */ | 193 | u32 hcc_params; /* HCCPARAMS - offset 0x8 */ |
| @@ -205,7 +212,7 @@ struct ehci_regs { | |||
| 205 | #define CMD_LRESET (1<<7) /* partial reset (no ports, etc) */ | 212 | #define CMD_LRESET (1<<7) /* partial reset (no ports, etc) */ |
| 206 | #define CMD_IAAD (1<<6) /* "doorbell" interrupt async advance */ | 213 | #define CMD_IAAD (1<<6) /* "doorbell" interrupt async advance */ |
| 207 | #define CMD_ASE (1<<5) /* async schedule enable */ | 214 | #define CMD_ASE (1<<5) /* async schedule enable */ |
| 208 | #define CMD_PSE (1<<4) /* periodic schedule enable */ | 215 | #define CMD_PSE (1<<4) /* periodic schedule enable */ |
| 209 | /* 3:2 is periodic frame list size */ | 216 | /* 3:2 is periodic frame list size */ |
| 210 | #define CMD_RESET (1<<1) /* reset HC not bus */ | 217 | #define CMD_RESET (1<<1) /* reset HC not bus */ |
| 211 | #define CMD_RUN (1<<0) /* start/stop HC */ | 218 | #define CMD_RUN (1<<0) /* start/stop HC */ |
| @@ -231,9 +238,9 @@ struct ehci_regs { | |||
| 231 | /* FRINDEX: offset 0x0C */ | 238 | /* FRINDEX: offset 0x0C */ |
| 232 | u32 frame_index; /* current microframe number */ | 239 | u32 frame_index; /* current microframe number */ |
| 233 | /* CTRLDSSEGMENT: offset 0x10 */ | 240 | /* CTRLDSSEGMENT: offset 0x10 */ |
| 234 | u32 segment; /* address bits 63:32 if needed */ | 241 | u32 segment; /* address bits 63:32 if needed */ |
| 235 | /* PERIODICLISTBASE: offset 0x14 */ | 242 | /* PERIODICLISTBASE: offset 0x14 */ |
| 236 | u32 frame_list; /* points to periodic list */ | 243 | u32 frame_list; /* points to periodic list */ |
| 237 | /* ASYNCLISTADDR: offset 0x18 */ | 244 | /* ASYNCLISTADDR: offset 0x18 */ |
| 238 | u32 async_next; /* address of next async queue head */ | 245 | u32 async_next; /* address of next async queue head */ |
| 239 | 246 | ||
| @@ -302,7 +309,7 @@ struct ehci_dbg_port { | |||
| 302 | 309 | ||
| 303 | /* | 310 | /* |
| 304 | * EHCI Specification 0.95 Section 3.5 | 311 | * EHCI Specification 0.95 Section 3.5 |
| 305 | * QTD: describe data transfer components (buffer, direction, ...) | 312 | * QTD: describe data transfer components (buffer, direction, ...) |
| 306 | * See Fig 3-6 "Queue Element Transfer Descriptor Block Diagram". | 313 | * See Fig 3-6 "Queue Element Transfer Descriptor Block Diagram". |
| 307 | * | 314 | * |
| 308 | * These are associated only with "QH" (Queue Head) structures, | 315 | * These are associated only with "QH" (Queue Head) structures, |
| @@ -312,7 +319,7 @@ struct ehci_qtd { | |||
| 312 | /* first part defined by EHCI spec */ | 319 | /* first part defined by EHCI spec */ |
| 313 | __le32 hw_next; /* see EHCI 3.5.1 */ | 320 | __le32 hw_next; /* see EHCI 3.5.1 */ |
| 314 | __le32 hw_alt_next; /* see EHCI 3.5.2 */ | 321 | __le32 hw_alt_next; /* see EHCI 3.5.2 */ |
| 315 | __le32 hw_token; /* see EHCI 3.5.3 */ | 322 | __le32 hw_token; /* see EHCI 3.5.3 */ |
| 316 | #define QTD_TOGGLE (1 << 31) /* data toggle */ | 323 | #define QTD_TOGGLE (1 << 31) /* data toggle */ |
| 317 | #define QTD_LENGTH(tok) (((tok)>>16) & 0x7fff) | 324 | #define QTD_LENGTH(tok) (((tok)>>16) & 0x7fff) |
| 318 | #define QTD_IOC (1 << 15) /* interrupt on complete */ | 325 | #define QTD_IOC (1 << 15) /* interrupt on complete */ |
| @@ -349,8 +356,8 @@ struct ehci_qtd { | |||
| 349 | /* values for that type tag */ | 356 | /* values for that type tag */ |
| 350 | #define Q_TYPE_ITD __constant_cpu_to_le32 (0 << 1) | 357 | #define Q_TYPE_ITD __constant_cpu_to_le32 (0 << 1) |
| 351 | #define Q_TYPE_QH __constant_cpu_to_le32 (1 << 1) | 358 | #define Q_TYPE_QH __constant_cpu_to_le32 (1 << 1) |
| 352 | #define Q_TYPE_SITD __constant_cpu_to_le32 (2 << 1) | 359 | #define Q_TYPE_SITD __constant_cpu_to_le32 (2 << 1) |
| 353 | #define Q_TYPE_FSTN __constant_cpu_to_le32 (3 << 1) | 360 | #define Q_TYPE_FSTN __constant_cpu_to_le32 (3 << 1) |
| 354 | 361 | ||
| 355 | /* next async queue entry, or pointer to interrupt/periodic QH */ | 362 | /* next async queue entry, or pointer to interrupt/periodic QH */ |
| 356 | #define QH_NEXT(dma) (cpu_to_le32(((u32)dma)&~0x01f)|Q_TYPE_QH) | 363 | #define QH_NEXT(dma) (cpu_to_le32(((u32)dma)&~0x01f)|Q_TYPE_QH) |
| @@ -367,7 +374,7 @@ struct ehci_qtd { | |||
| 367 | * For entries in the async schedule, the type tag always says "qh". | 374 | * For entries in the async schedule, the type tag always says "qh". |
| 368 | */ | 375 | */ |
| 369 | union ehci_shadow { | 376 | union ehci_shadow { |
| 370 | struct ehci_qh *qh; /* Q_TYPE_QH */ | 377 | struct ehci_qh *qh; /* Q_TYPE_QH */ |
| 371 | struct ehci_itd *itd; /* Q_TYPE_ITD */ | 378 | struct ehci_itd *itd; /* Q_TYPE_ITD */ |
| 372 | struct ehci_sitd *sitd; /* Q_TYPE_SITD */ | 379 | struct ehci_sitd *sitd; /* Q_TYPE_SITD */ |
| 373 | struct ehci_fstn *fstn; /* Q_TYPE_FSTN */ | 380 | struct ehci_fstn *fstn; /* Q_TYPE_FSTN */ |
| @@ -397,7 +404,7 @@ struct ehci_qh { | |||
| 397 | #define QH_HUBPORT 0x3f800000 | 404 | #define QH_HUBPORT 0x3f800000 |
| 398 | #define QH_MULT 0xc0000000 | 405 | #define QH_MULT 0xc0000000 |
| 399 | __le32 hw_current; /* qtd list - see EHCI 3.6.4 */ | 406 | __le32 hw_current; /* qtd list - see EHCI 3.6.4 */ |
| 400 | 407 | ||
| 401 | /* qtd overlay (hardware parts of a struct ehci_qtd) */ | 408 | /* qtd overlay (hardware parts of a struct ehci_qtd) */ |
| 402 | __le32 hw_qtd_next; | 409 | __le32 hw_qtd_next; |
| 403 | __le32 hw_alt_next; | 410 | __le32 hw_alt_next; |
| @@ -472,7 +479,7 @@ struct ehci_iso_stream { | |||
| 472 | struct list_head td_list; /* queued itds/sitds */ | 479 | struct list_head td_list; /* queued itds/sitds */ |
| 473 | struct list_head free_list; /* list of unused itds/sitds */ | 480 | struct list_head free_list; /* list of unused itds/sitds */ |
| 474 | struct usb_device *udev; | 481 | struct usb_device *udev; |
| 475 | struct usb_host_endpoint *ep; | 482 | struct usb_host_endpoint *ep; |
| 476 | 483 | ||
| 477 | /* output of (re)scheduling */ | 484 | /* output of (re)scheduling */ |
| 478 | unsigned long start; /* jiffies */ | 485 | unsigned long start; /* jiffies */ |
| @@ -492,8 +499,8 @@ struct ehci_iso_stream { | |||
| 492 | unsigned bandwidth; | 499 | unsigned bandwidth; |
| 493 | 500 | ||
| 494 | /* This is used to initialize iTD's hw_bufp fields */ | 501 | /* This is used to initialize iTD's hw_bufp fields */ |
| 495 | __le32 buf0; | 502 | __le32 buf0; |
| 496 | __le32 buf1; | 503 | __le32 buf1; |
| 497 | __le32 buf2; | 504 | __le32 buf2; |
| 498 | 505 | ||
| 499 | /* this is used to initialize sITD's tt info */ | 506 | /* this is used to initialize sITD's tt info */ |
| @@ -521,7 +528,7 @@ struct ehci_itd { | |||
| 521 | 528 | ||
| 522 | #define ITD_ACTIVE __constant_cpu_to_le32(EHCI_ISOC_ACTIVE) | 529 | #define ITD_ACTIVE __constant_cpu_to_le32(EHCI_ISOC_ACTIVE) |
| 523 | 530 | ||
| 524 | __le32 hw_bufp [7]; /* see EHCI 3.3.3 */ | 531 | __le32 hw_bufp [7]; /* see EHCI 3.3.3 */ |
| 525 | __le32 hw_bufp_hi [7]; /* Appendix B */ | 532 | __le32 hw_bufp_hi [7]; /* Appendix B */ |
| 526 | 533 | ||
| 527 | /* the rest is HCD-private */ | 534 | /* the rest is HCD-private */ |
| @@ -542,7 +549,7 @@ struct ehci_itd { | |||
| 542 | /*-------------------------------------------------------------------------*/ | 549 | /*-------------------------------------------------------------------------*/ |
| 543 | 550 | ||
| 544 | /* | 551 | /* |
| 545 | * EHCI Specification 0.95 Section 3.4 | 552 | * EHCI Specification 0.95 Section 3.4 |
| 546 | * siTD, aka split-transaction isochronous Transfer Descriptor | 553 | * siTD, aka split-transaction isochronous Transfer Descriptor |
| 547 | * ... describe full speed iso xfers through TT in hubs | 554 | * ... describe full speed iso xfers through TT in hubs |
| 548 | * see Figure 3-5 "Split-transaction Isochronous Transaction Descriptor (siTD) | 555 | * see Figure 3-5 "Split-transaction Isochronous Transaction Descriptor (siTD) |
diff --git a/drivers/usb/host/isp116x-hcd.c b/drivers/usb/host/isp116x-hcd.c index 5147ed4a6662..a72e041df8e7 100644 --- a/drivers/usb/host/isp116x-hcd.c +++ b/drivers/usb/host/isp116x-hcd.c | |||
| @@ -1204,10 +1204,10 @@ static int isp116x_show_dbg(struct seq_file *s, void *unused) | |||
| 1204 | 1204 | ||
| 1205 | static int isp116x_open_seq(struct inode *inode, struct file *file) | 1205 | static int isp116x_open_seq(struct inode *inode, struct file *file) |
| 1206 | { | 1206 | { |
| 1207 | return single_open(file, isp116x_show_dbg, inode->u.generic_ip); | 1207 | return single_open(file, isp116x_show_dbg, inode->i_private); |
| 1208 | } | 1208 | } |
| 1209 | 1209 | ||
| 1210 | static struct file_operations isp116x_debug_fops = { | 1210 | static const struct file_operations isp116x_debug_fops = { |
| 1211 | .open = isp116x_open_seq, | 1211 | .open = isp116x_open_seq, |
| 1212 | .read = seq_read, | 1212 | .read = seq_read, |
| 1213 | .llseek = seq_lseek, | 1213 | .llseek = seq_lseek, |
diff --git a/drivers/usb/host/isp116x.h b/drivers/usb/host/isp116x.h index a1b7c3813d3a..b91e2edd9c5c 100644 --- a/drivers/usb/host/isp116x.h +++ b/drivers/usb/host/isp116x.h | |||
| @@ -233,7 +233,7 @@ static const int cc_to_error[16] = { | |||
| 233 | /* Bit Stuff */ -EPROTO, | 233 | /* Bit Stuff */ -EPROTO, |
| 234 | /* Data Togg */ -EILSEQ, | 234 | /* Data Togg */ -EILSEQ, |
| 235 | /* Stall */ -EPIPE, | 235 | /* Stall */ -EPIPE, |
| 236 | /* DevNotResp */ -ETIMEDOUT, | 236 | /* DevNotResp */ -ETIME, |
| 237 | /* PIDCheck */ -EPROTO, | 237 | /* PIDCheck */ -EPROTO, |
| 238 | /* UnExpPID */ -EPROTO, | 238 | /* UnExpPID */ -EPROTO, |
| 239 | /* DataOver */ -EOVERFLOW, | 239 | /* DataOver */ -EOVERFLOW, |
diff --git a/drivers/usb/host/ohci-at91.c b/drivers/usb/host/ohci-at91.c index 85cc059705a6..b466581beb4a 100644 --- a/drivers/usb/host/ohci-at91.c +++ b/drivers/usb/host/ohci-at91.c | |||
| @@ -193,7 +193,7 @@ ohci_at91_start (struct usb_hcd *hcd) | |||
| 193 | if ((ret = ohci_init(ohci)) < 0) | 193 | if ((ret = ohci_init(ohci)) < 0) |
| 194 | return ret; | 194 | return ret; |
| 195 | 195 | ||
| 196 | root->maxchild = board->ports; | 196 | ohci->num_ports = board->ports; |
| 197 | 197 | ||
| 198 | if ((ret = ohci_run(ohci)) < 0) { | 198 | if ((ret = ohci_run(ohci)) < 0) { |
| 199 | err("can't start %s", hcd->self.bus_name); | 199 | err("can't start %s", hcd->self.bus_name); |
| @@ -221,6 +221,7 @@ static const struct hc_driver ohci_at91_hc_driver = { | |||
| 221 | */ | 221 | */ |
| 222 | .start = ohci_at91_start, | 222 | .start = ohci_at91_start, |
| 223 | .stop = ohci_stop, | 223 | .stop = ohci_stop, |
| 224 | .shutdown = ohci_shutdown, | ||
| 224 | 225 | ||
| 225 | /* | 226 | /* |
| 226 | * managing i/o requests and associated device resources | 227 | * managing i/o requests and associated device resources |
| @@ -239,7 +240,7 @@ static const struct hc_driver ohci_at91_hc_driver = { | |||
| 239 | */ | 240 | */ |
| 240 | .hub_status_data = ohci_hub_status_data, | 241 | .hub_status_data = ohci_hub_status_data, |
| 241 | .hub_control = ohci_hub_control, | 242 | .hub_control = ohci_hub_control, |
| 242 | 243 | .hub_irq_enable = ohci_rhsc_enable, | |
| 243 | #ifdef CONFIG_PM | 244 | #ifdef CONFIG_PM |
| 244 | .bus_suspend = ohci_bus_suspend, | 245 | .bus_suspend = ohci_bus_suspend, |
| 245 | .bus_resume = ohci_bus_resume, | 246 | .bus_resume = ohci_bus_resume, |
| @@ -296,6 +297,7 @@ static int ohci_hcd_at91_drv_resume(struct platform_device *pdev) | |||
| 296 | if (!clocked) { | 297 | if (!clocked) { |
| 297 | clk_enable(iclk); | 298 | clk_enable(iclk); |
| 298 | clk_enable(fclk); | 299 | clk_enable(fclk); |
| 300 | clocked = 1; | ||
| 299 | } | 301 | } |
| 300 | 302 | ||
| 301 | return 0; | 303 | return 0; |
| @@ -310,6 +312,7 @@ MODULE_ALIAS("at91_ohci"); | |||
| 310 | static struct platform_driver ohci_hcd_at91_driver = { | 312 | static struct platform_driver ohci_hcd_at91_driver = { |
| 311 | .probe = ohci_hcd_at91_drv_probe, | 313 | .probe = ohci_hcd_at91_drv_probe, |
| 312 | .remove = ohci_hcd_at91_drv_remove, | 314 | .remove = ohci_hcd_at91_drv_remove, |
| 315 | .shutdown = usb_hcd_platform_shutdown, | ||
| 313 | .suspend = ohci_hcd_at91_drv_suspend, | 316 | .suspend = ohci_hcd_at91_drv_suspend, |
| 314 | .resume = ohci_hcd_at91_drv_resume, | 317 | .resume = ohci_hcd_at91_drv_resume, |
| 315 | .driver = { | 318 | .driver = { |
diff --git a/drivers/usb/host/ohci-au1xxx.c b/drivers/usb/host/ohci-au1xxx.c index f7a975d5db09..24e23c5783d8 100644 --- a/drivers/usb/host/ohci-au1xxx.c +++ b/drivers/usb/host/ohci-au1xxx.c | |||
| @@ -268,11 +268,8 @@ static const struct hc_driver ohci_au1xxx_hc_driver = { | |||
| 268 | * basic lifecycle operations | 268 | * basic lifecycle operations |
| 269 | */ | 269 | */ |
| 270 | .start = ohci_au1xxx_start, | 270 | .start = ohci_au1xxx_start, |
| 271 | #ifdef CONFIG_PM | ||
| 272 | /* suspend: ohci_au1xxx_suspend, -- tbd */ | ||
| 273 | /* resume: ohci_au1xxx_resume, -- tbd */ | ||
| 274 | #endif /*CONFIG_PM*/ | ||
| 275 | .stop = ohci_stop, | 271 | .stop = ohci_stop, |
| 272 | .shutdown = ohci_shutdown, | ||
| 276 | 273 | ||
| 277 | /* | 274 | /* |
| 278 | * managing i/o requests and associated device resources | 275 | * managing i/o requests and associated device resources |
| @@ -291,6 +288,7 @@ static const struct hc_driver ohci_au1xxx_hc_driver = { | |||
| 291 | */ | 288 | */ |
| 292 | .hub_status_data = ohci_hub_status_data, | 289 | .hub_status_data = ohci_hub_status_data, |
| 293 | .hub_control = ohci_hub_control, | 290 | .hub_control = ohci_hub_control, |
| 291 | .hub_irq_enable = ohci_rhsc_enable, | ||
| 294 | #ifdef CONFIG_PM | 292 | #ifdef CONFIG_PM |
| 295 | .bus_suspend = ohci_bus_suspend, | 293 | .bus_suspend = ohci_bus_suspend, |
| 296 | .bus_resume = ohci_bus_resume, | 294 | .bus_resume = ohci_bus_resume, |
| @@ -338,6 +336,7 @@ static int ohci_hcd_au1xxx_drv_resume(struct platform_device *dev) | |||
| 338 | static struct platform_driver ohci_hcd_au1xxx_driver = { | 336 | static struct platform_driver ohci_hcd_au1xxx_driver = { |
| 339 | .probe = ohci_hcd_au1xxx_drv_probe, | 337 | .probe = ohci_hcd_au1xxx_drv_probe, |
| 340 | .remove = ohci_hcd_au1xxx_drv_remove, | 338 | .remove = ohci_hcd_au1xxx_drv_remove, |
| 339 | .shutdown = usb_hcd_platform_shutdown, | ||
| 341 | /*.suspend = ohci_hcd_au1xxx_drv_suspend, */ | 340 | /*.suspend = ohci_hcd_au1xxx_drv_suspend, */ |
| 342 | /*.resume = ohci_hcd_au1xxx_drv_resume, */ | 341 | /*.resume = ohci_hcd_au1xxx_drv_resume, */ |
| 343 | .driver = { | 342 | .driver = { |
diff --git a/drivers/usb/host/ohci-dbg.c b/drivers/usb/host/ohci-dbg.c index 7bfffcbbd226..8293c1d4be3f 100644 --- a/drivers/usb/host/ohci-dbg.c +++ b/drivers/usb/host/ohci-dbg.c | |||
| @@ -477,7 +477,7 @@ show_async (struct class_device *class_dev, char *buf) | |||
| 477 | unsigned long flags; | 477 | unsigned long flags; |
| 478 | 478 | ||
| 479 | bus = class_get_devdata(class_dev); | 479 | bus = class_get_devdata(class_dev); |
| 480 | hcd = bus->hcpriv; | 480 | hcd = bus_to_hcd(bus); |
| 481 | ohci = hcd_to_ohci(hcd); | 481 | ohci = hcd_to_ohci(hcd); |
| 482 | 482 | ||
| 483 | /* display control and bulk lists together, for simplicity */ | 483 | /* display control and bulk lists together, for simplicity */ |
| @@ -510,7 +510,7 @@ show_periodic (struct class_device *class_dev, char *buf) | |||
| 510 | seen_count = 0; | 510 | seen_count = 0; |
| 511 | 511 | ||
| 512 | bus = class_get_devdata(class_dev); | 512 | bus = class_get_devdata(class_dev); |
| 513 | hcd = bus->hcpriv; | 513 | hcd = bus_to_hcd(bus); |
| 514 | ohci = hcd_to_ohci(hcd); | 514 | ohci = hcd_to_ohci(hcd); |
| 515 | next = buf; | 515 | next = buf; |
| 516 | size = PAGE_SIZE; | 516 | size = PAGE_SIZE; |
| @@ -607,7 +607,7 @@ show_registers (struct class_device *class_dev, char *buf) | |||
| 607 | u32 rdata; | 607 | u32 rdata; |
| 608 | 608 | ||
| 609 | bus = class_get_devdata(class_dev); | 609 | bus = class_get_devdata(class_dev); |
| 610 | hcd = bus->hcpriv; | 610 | hcd = bus_to_hcd(bus); |
| 611 | ohci = hcd_to_ohci(hcd); | 611 | ohci = hcd_to_ohci(hcd); |
| 612 | regs = ohci->regs; | 612 | regs = ohci->regs; |
| 613 | next = buf; | 613 | next = buf; |
| @@ -667,6 +667,11 @@ show_registers (struct class_device *class_dev, char *buf) | |||
| 667 | size -= temp; | 667 | size -= temp; |
| 668 | next += temp; | 668 | next += temp; |
| 669 | 669 | ||
| 670 | temp = scnprintf (next, size, "hub poll timer %s\n", | ||
| 671 | ohci_to_hcd(ohci)->poll_rh ? "ON" : "off"); | ||
| 672 | size -= temp; | ||
| 673 | next += temp; | ||
| 674 | |||
| 670 | /* roothub */ | 675 | /* roothub */ |
| 671 | ohci_dump_roothub (ohci, 1, &next, &size); | 676 | ohci_dump_roothub (ohci, 1, &next, &size); |
| 672 | 677 | ||
| @@ -680,10 +685,11 @@ static CLASS_DEVICE_ATTR (registers, S_IRUGO, show_registers, NULL); | |||
| 680 | static inline void create_debug_files (struct ohci_hcd *ohci) | 685 | static inline void create_debug_files (struct ohci_hcd *ohci) |
| 681 | { | 686 | { |
| 682 | struct class_device *cldev = ohci_to_hcd(ohci)->self.class_dev; | 687 | struct class_device *cldev = ohci_to_hcd(ohci)->self.class_dev; |
| 688 | int retval; | ||
| 683 | 689 | ||
| 684 | class_device_create_file(cldev, &class_device_attr_async); | 690 | retval = class_device_create_file(cldev, &class_device_attr_async); |
| 685 | class_device_create_file(cldev, &class_device_attr_periodic); | 691 | retval = class_device_create_file(cldev, &class_device_attr_periodic); |
| 686 | class_device_create_file(cldev, &class_device_attr_registers); | 692 | retval = class_device_create_file(cldev, &class_device_attr_registers); |
| 687 | ohci_dbg (ohci, "created debug files\n"); | 693 | ohci_dbg (ohci, "created debug files\n"); |
| 688 | } | 694 | } |
| 689 | 695 | ||
diff --git a/drivers/usb/host/ohci-ep93xx.c b/drivers/usb/host/ohci-ep93xx.c index 6531c4d26527..1bf5e7a4e735 100644 --- a/drivers/usb/host/ohci-ep93xx.c +++ b/drivers/usb/host/ohci-ep93xx.c | |||
| @@ -128,12 +128,14 @@ static struct hc_driver ohci_ep93xx_hc_driver = { | |||
| 128 | .flags = HCD_USB11 | HCD_MEMORY, | 128 | .flags = HCD_USB11 | HCD_MEMORY, |
| 129 | .start = ohci_ep93xx_start, | 129 | .start = ohci_ep93xx_start, |
| 130 | .stop = ohci_stop, | 130 | .stop = ohci_stop, |
| 131 | .shutdown = ohci_shutdown, | ||
| 131 | .urb_enqueue = ohci_urb_enqueue, | 132 | .urb_enqueue = ohci_urb_enqueue, |
| 132 | .urb_dequeue = ohci_urb_dequeue, | 133 | .urb_dequeue = ohci_urb_dequeue, |
| 133 | .endpoint_disable = ohci_endpoint_disable, | 134 | .endpoint_disable = ohci_endpoint_disable, |
| 134 | .get_frame_number = ohci_get_frame, | 135 | .get_frame_number = ohci_get_frame, |
| 135 | .hub_status_data = ohci_hub_status_data, | 136 | .hub_status_data = ohci_hub_status_data, |
| 136 | .hub_control = ohci_hub_control, | 137 | .hub_control = ohci_hub_control, |
| 138 | .hub_irq_enable = ohci_rhsc_enable, | ||
| 137 | #ifdef CONFIG_PM | 139 | #ifdef CONFIG_PM |
| 138 | .bus_suspend = ohci_bus_suspend, | 140 | .bus_suspend = ohci_bus_suspend, |
| 139 | .bus_resume = ohci_bus_resume, | 141 | .bus_resume = ohci_bus_resume, |
| @@ -202,6 +204,7 @@ static int ohci_hcd_ep93xx_drv_resume(struct platform_device *pdev) | |||
| 202 | static struct platform_driver ohci_hcd_ep93xx_driver = { | 204 | static struct platform_driver ohci_hcd_ep93xx_driver = { |
| 203 | .probe = ohci_hcd_ep93xx_drv_probe, | 205 | .probe = ohci_hcd_ep93xx_drv_probe, |
| 204 | .remove = ohci_hcd_ep93xx_drv_remove, | 206 | .remove = ohci_hcd_ep93xx_drv_remove, |
| 207 | .shutdown = usb_hcd_platform_shutdown, | ||
| 205 | #ifdef CONFIG_PM | 208 | #ifdef CONFIG_PM |
| 206 | .suspend = ohci_hcd_ep93xx_drv_suspend, | 209 | .suspend = ohci_hcd_ep93xx_drv_suspend, |
| 207 | .resume = ohci_hcd_ep93xx_drv_resume, | 210 | .resume = ohci_hcd_ep93xx_drv_resume, |
diff --git a/drivers/usb/host/ohci-hcd.c b/drivers/usb/host/ohci-hcd.c index 94d8cf4b36c1..1027aa04583d 100644 --- a/drivers/usb/host/ohci-hcd.c +++ b/drivers/usb/host/ohci-hcd.c | |||
| @@ -88,7 +88,7 @@ | |||
| 88 | #include <linux/timer.h> | 88 | #include <linux/timer.h> |
| 89 | #include <linux/list.h> | 89 | #include <linux/list.h> |
| 90 | #include <linux/usb.h> | 90 | #include <linux/usb.h> |
| 91 | #include <linux/usb_otg.h> | 91 | #include <linux/usb/otg.h> |
| 92 | #include <linux/dma-mapping.h> | 92 | #include <linux/dma-mapping.h> |
| 93 | #include <linux/dmapool.h> | 93 | #include <linux/dmapool.h> |
| 94 | #include <linux/reboot.h> | 94 | #include <linux/reboot.h> |
| @@ -101,7 +101,7 @@ | |||
| 101 | 101 | ||
| 102 | #include "../core/hcd.h" | 102 | #include "../core/hcd.h" |
| 103 | 103 | ||
| 104 | #define DRIVER_VERSION "2005 April 22" | 104 | #define DRIVER_VERSION "2006 August 04" |
| 105 | #define DRIVER_AUTHOR "Roman Weissgaerber, David Brownell" | 105 | #define DRIVER_AUTHOR "Roman Weissgaerber, David Brownell" |
| 106 | #define DRIVER_DESC "USB 1.1 'Open' Host Controller (OHCI) Driver" | 106 | #define DRIVER_DESC "USB 1.1 'Open' Host Controller (OHCI) Driver" |
| 107 | 107 | ||
| @@ -110,9 +110,10 @@ | |||
| 110 | #undef OHCI_VERBOSE_DEBUG /* not always helpful */ | 110 | #undef OHCI_VERBOSE_DEBUG /* not always helpful */ |
| 111 | 111 | ||
| 112 | /* For initializing controller (mask in an HCFS mode too) */ | 112 | /* For initializing controller (mask in an HCFS mode too) */ |
| 113 | #define OHCI_CONTROL_INIT OHCI_CTRL_CBSR | 113 | #define OHCI_CONTROL_INIT OHCI_CTRL_CBSR |
| 114 | #define OHCI_INTR_INIT \ | 114 | #define OHCI_INTR_INIT \ |
| 115 | (OHCI_INTR_MIE | OHCI_INTR_UE | OHCI_INTR_RD | OHCI_INTR_WDH) | 115 | (OHCI_INTR_MIE | OHCI_INTR_RHSC | OHCI_INTR_UE \ |
| 116 | | OHCI_INTR_RD | OHCI_INTR_WDH) | ||
| 116 | 117 | ||
| 117 | #ifdef __hppa__ | 118 | #ifdef __hppa__ |
| 118 | /* On PA-RISC, PDC can leave IR set incorrectly; ignore it there. */ | 119 | /* On PA-RISC, PDC can leave IR set incorrectly; ignore it there. */ |
| @@ -128,12 +129,13 @@ | |||
| 128 | 129 | ||
| 129 | static const char hcd_name [] = "ohci_hcd"; | 130 | static const char hcd_name [] = "ohci_hcd"; |
| 130 | 131 | ||
| 132 | #define STATECHANGE_DELAY msecs_to_jiffies(300) | ||
| 133 | |||
| 131 | #include "ohci.h" | 134 | #include "ohci.h" |
| 132 | 135 | ||
| 133 | static void ohci_dump (struct ohci_hcd *ohci, int verbose); | 136 | static void ohci_dump (struct ohci_hcd *ohci, int verbose); |
| 134 | static int ohci_init (struct ohci_hcd *ohci); | 137 | static int ohci_init (struct ohci_hcd *ohci); |
| 135 | static void ohci_stop (struct usb_hcd *hcd); | 138 | static void ohci_stop (struct usb_hcd *hcd); |
| 136 | static int ohci_reboot (struct notifier_block *, unsigned long , void *); | ||
| 137 | 139 | ||
| 138 | #include "ohci-hub.c" | 140 | #include "ohci-hub.c" |
| 139 | #include "ohci-dbg.c" | 141 | #include "ohci-dbg.c" |
| @@ -416,21 +418,20 @@ static void ohci_usb_reset (struct ohci_hcd *ohci) | |||
| 416 | ohci_writel (ohci, ohci->hc_control, &ohci->regs->control); | 418 | ohci_writel (ohci, ohci->hc_control, &ohci->regs->control); |
| 417 | } | 419 | } |
| 418 | 420 | ||
| 419 | /* reboot notifier forcibly disables IRQs and DMA, helping kexec and | 421 | /* ohci_shutdown forcibly disables IRQs and DMA, helping kexec and |
| 420 | * other cases where the next software may expect clean state from the | 422 | * other cases where the next software may expect clean state from the |
| 421 | * "firmware". this is bus-neutral, unlike shutdown() methods. | 423 | * "firmware". this is bus-neutral, unlike shutdown() methods. |
| 422 | */ | 424 | */ |
| 423 | static int | 425 | static void |
| 424 | ohci_reboot (struct notifier_block *block, unsigned long code, void *null) | 426 | ohci_shutdown (struct usb_hcd *hcd) |
| 425 | { | 427 | { |
| 426 | struct ohci_hcd *ohci; | 428 | struct ohci_hcd *ohci; |
| 427 | 429 | ||
| 428 | ohci = container_of (block, struct ohci_hcd, reboot_notifier); | 430 | ohci = hcd_to_ohci (hcd); |
| 429 | ohci_writel (ohci, OHCI_INTR_MIE, &ohci->regs->intrdisable); | 431 | ohci_writel (ohci, OHCI_INTR_MIE, &ohci->regs->intrdisable); |
| 430 | ohci_usb_reset (ohci); | 432 | ohci_usb_reset (ohci); |
| 431 | /* flush the writes */ | 433 | /* flush the writes */ |
| 432 | (void) ohci_readl (ohci, &ohci->regs->control); | 434 | (void) ohci_readl (ohci, &ohci->regs->control); |
| 433 | return 0; | ||
| 434 | } | 435 | } |
| 435 | 436 | ||
| 436 | /*-------------------------------------------------------------------------* | 437 | /*-------------------------------------------------------------------------* |
| @@ -446,7 +447,6 @@ static int ohci_init (struct ohci_hcd *ohci) | |||
| 446 | 447 | ||
| 447 | disable (ohci); | 448 | disable (ohci); |
| 448 | ohci->regs = hcd->regs; | 449 | ohci->regs = hcd->regs; |
| 449 | ohci->next_statechange = jiffies; | ||
| 450 | 450 | ||
| 451 | /* REVISIT this BIOS handshake is now moved into PCI "quirks", and | 451 | /* REVISIT this BIOS handshake is now moved into PCI "quirks", and |
| 452 | * was never needed for most non-PCI systems ... remove the code? | 452 | * was never needed for most non-PCI systems ... remove the code? |
| @@ -502,7 +502,6 @@ static int ohci_init (struct ohci_hcd *ohci) | |||
| 502 | if ((ret = ohci_mem_init (ohci)) < 0) | 502 | if ((ret = ohci_mem_init (ohci)) < 0) |
| 503 | ohci_stop (hcd); | 503 | ohci_stop (hcd); |
| 504 | else { | 504 | else { |
| 505 | register_reboot_notifier (&ohci->reboot_notifier); | ||
| 506 | create_debug_files (ohci); | 505 | create_debug_files (ohci); |
| 507 | } | 506 | } |
| 508 | 507 | ||
| @@ -637,10 +636,14 @@ retry: | |||
| 637 | return -EOVERFLOW; | 636 | return -EOVERFLOW; |
| 638 | } | 637 | } |
| 639 | 638 | ||
| 640 | /* start controller operations */ | 639 | /* use rhsc irqs after khubd is fully initialized */ |
| 640 | hcd->poll_rh = 1; | ||
| 641 | hcd->uses_new_polling = 1; | ||
| 642 | |||
| 643 | /* start controller operations */ | ||
| 641 | ohci->hc_control &= OHCI_CTRL_RWC; | 644 | ohci->hc_control &= OHCI_CTRL_RWC; |
| 642 | ohci->hc_control |= OHCI_CONTROL_INIT | OHCI_USB_OPER; | 645 | ohci->hc_control |= OHCI_CONTROL_INIT | OHCI_USB_OPER; |
| 643 | ohci_writel (ohci, ohci->hc_control, &ohci->regs->control); | 646 | ohci_writel (ohci, ohci->hc_control, &ohci->regs->control); |
| 644 | hcd->state = HC_STATE_RUNNING; | 647 | hcd->state = HC_STATE_RUNNING; |
| 645 | 648 | ||
| 646 | /* wake on ConnectStatusChange, matching external hubs */ | 649 | /* wake on ConnectStatusChange, matching external hubs */ |
| @@ -648,7 +651,7 @@ retry: | |||
| 648 | 651 | ||
| 649 | /* Choose the interrupts we care about now, others later on demand */ | 652 | /* Choose the interrupts we care about now, others later on demand */ |
| 650 | mask = OHCI_INTR_INIT; | 653 | mask = OHCI_INTR_INIT; |
| 651 | ohci_writel (ohci, mask, &ohci->regs->intrstatus); | 654 | ohci_writel (ohci, ~0, &ohci->regs->intrstatus); |
| 652 | ohci_writel (ohci, mask, &ohci->regs->intrenable); | 655 | ohci_writel (ohci, mask, &ohci->regs->intrenable); |
| 653 | 656 | ||
| 654 | /* handle root hub init quirks ... */ | 657 | /* handle root hub init quirks ... */ |
| @@ -672,6 +675,7 @@ retry: | |||
| 672 | // flush those writes | 675 | // flush those writes |
| 673 | (void) ohci_readl (ohci, &ohci->regs->control); | 676 | (void) ohci_readl (ohci, &ohci->regs->control); |
| 674 | 677 | ||
| 678 | ohci->next_statechange = jiffies + STATECHANGE_DELAY; | ||
| 675 | spin_unlock_irq (&ohci->lock); | 679 | spin_unlock_irq (&ohci->lock); |
| 676 | 680 | ||
| 677 | // POTPGT delay is bits 24-31, in 2 ms units. | 681 | // POTPGT delay is bits 24-31, in 2 ms units. |
| @@ -709,7 +713,23 @@ static irqreturn_t ohci_irq (struct usb_hcd *hcd, struct pt_regs *ptregs) | |||
| 709 | /* interrupt for some other device? */ | 713 | /* interrupt for some other device? */ |
| 710 | } else if ((ints &= ohci_readl (ohci, ®s->intrenable)) == 0) { | 714 | } else if ((ints &= ohci_readl (ohci, ®s->intrenable)) == 0) { |
| 711 | return IRQ_NOTMINE; | 715 | return IRQ_NOTMINE; |
| 712 | } | 716 | } |
| 717 | |||
| 718 | /* NOTE: vendors didn't always make the same implementation | ||
| 719 | * choices for RHSC. Sometimes it triggers on an edge (like | ||
| 720 | * setting and maybe clearing a port status change bit); and | ||
| 721 | * it's level-triggered on other silicon, active until khubd | ||
| 722 | * clears all active port status change bits. Poll by timer | ||
| 723 | * til it's fully debounced and the difference won't matter. | ||
| 724 | */ | ||
| 725 | if (ints & OHCI_INTR_RHSC) { | ||
| 726 | ohci_vdbg (ohci, "rhsc\n"); | ||
| 727 | ohci_writel (ohci, OHCI_INTR_RHSC, ®s->intrdisable); | ||
| 728 | hcd->poll_rh = 1; | ||
| 729 | ohci->next_statechange = jiffies + STATECHANGE_DELAY; | ||
| 730 | ohci_writel (ohci, OHCI_INTR_RHSC, ®s->intrstatus); | ||
| 731 | usb_hcd_poll_rh_status(hcd); | ||
| 732 | } | ||
| 713 | 733 | ||
| 714 | if (ints & OHCI_INTR_UE) { | 734 | if (ints & OHCI_INTR_UE) { |
| 715 | disable (ohci); | 735 | disable (ohci); |
| @@ -775,9 +795,10 @@ static void ohci_stop (struct usb_hcd *hcd) | |||
| 775 | 795 | ||
| 776 | ohci_usb_reset (ohci); | 796 | ohci_usb_reset (ohci); |
| 777 | ohci_writel (ohci, OHCI_INTR_MIE, &ohci->regs->intrdisable); | 797 | ohci_writel (ohci, OHCI_INTR_MIE, &ohci->regs->intrdisable); |
| 778 | 798 | free_irq(hcd->irq, hcd); | |
| 799 | hcd->irq = -1; | ||
| 800 | |||
| 779 | remove_debug_files (ohci); | 801 | remove_debug_files (ohci); |
| 780 | unregister_reboot_notifier (&ohci->reboot_notifier); | ||
| 781 | ohci_mem_cleanup (ohci); | 802 | ohci_mem_cleanup (ohci); |
| 782 | if (ohci->hcca) { | 803 | if (ohci->hcca) { |
| 783 | dma_free_coherent (hcd->self.controller, | 804 | dma_free_coherent (hcd->self.controller, |
| @@ -917,6 +938,10 @@ MODULE_LICENSE ("GPL"); | |||
| 917 | #include "ohci-at91.c" | 938 | #include "ohci-at91.c" |
| 918 | #endif | 939 | #endif |
| 919 | 940 | ||
| 941 | #ifdef CONFIG_ARCH_PNX4008 | ||
| 942 | #include "ohci-pnx4008.c" | ||
| 943 | #endif | ||
| 944 | |||
| 920 | #if !(defined(CONFIG_PCI) \ | 945 | #if !(defined(CONFIG_PCI) \ |
| 921 | || defined(CONFIG_SA1111) \ | 946 | || defined(CONFIG_SA1111) \ |
| 922 | || defined(CONFIG_ARCH_S3C2410) \ | 947 | || defined(CONFIG_ARCH_S3C2410) \ |
| @@ -928,6 +953,7 @@ MODULE_LICENSE ("GPL"); | |||
| 928 | || defined (CONFIG_USB_OHCI_HCD_PPC_SOC) \ | 953 | || defined (CONFIG_USB_OHCI_HCD_PPC_SOC) \ |
| 929 | || defined (CONFIG_ARCH_AT91RM9200) \ | 954 | || defined (CONFIG_ARCH_AT91RM9200) \ |
| 930 | || defined (CONFIG_ARCH_AT91SAM9261) \ | 955 | || defined (CONFIG_ARCH_AT91SAM9261) \ |
| 956 | || defined (CONFIG_ARCH_PNX4008) \ | ||
| 931 | ) | 957 | ) |
| 932 | #error "missing bus glue for ohci-hcd" | 958 | #error "missing bus glue for ohci-hcd" |
| 933 | #endif | 959 | #endif |
diff --git a/drivers/usb/host/ohci-hub.c b/drivers/usb/host/ohci-hub.c index 5b0a23fd798b..0b899339cac8 100644 --- a/drivers/usb/host/ohci-hub.c +++ b/drivers/usb/host/ohci-hub.c | |||
| @@ -36,6 +36,14 @@ | |||
| 36 | 36 | ||
| 37 | /*-------------------------------------------------------------------------*/ | 37 | /*-------------------------------------------------------------------------*/ |
| 38 | 38 | ||
| 39 | /* hcd->hub_irq_enable() */ | ||
| 40 | static void ohci_rhsc_enable (struct usb_hcd *hcd) | ||
| 41 | { | ||
| 42 | struct ohci_hcd *ohci = hcd_to_ohci (hcd); | ||
| 43 | |||
| 44 | ohci_writel (ohci, OHCI_INTR_RHSC, &ohci->regs->intrenable); | ||
| 45 | } | ||
| 46 | |||
| 39 | #ifdef CONFIG_PM | 47 | #ifdef CONFIG_PM |
| 40 | 48 | ||
| 41 | #define OHCI_SCHED_ENABLES \ | 49 | #define OHCI_SCHED_ENABLES \ |
| @@ -123,10 +131,10 @@ static int ohci_bus_suspend (struct usb_hcd *hcd) | |||
| 123 | /* no resumes until devices finish suspending */ | 131 | /* no resumes until devices finish suspending */ |
| 124 | ohci->next_statechange = jiffies + msecs_to_jiffies (5); | 132 | ohci->next_statechange = jiffies + msecs_to_jiffies (5); |
| 125 | 133 | ||
| 134 | /* no timer polling */ | ||
| 135 | hcd->poll_rh = 0; | ||
| 136 | |||
| 126 | done: | 137 | done: |
| 127 | /* external suspend vs self autosuspend ... same effect */ | ||
| 128 | if (status == 0) | ||
| 129 | usb_hcd_suspend_root_hub(hcd); | ||
| 130 | spin_unlock_irqrestore (&ohci->lock, flags); | 138 | spin_unlock_irqrestore (&ohci->lock, flags); |
| 131 | return status; | 139 | return status; |
| 132 | } | 140 | } |
| @@ -256,8 +264,8 @@ static int ohci_bus_resume (struct usb_hcd *hcd) | |||
| 256 | /* TRSMRCY */ | 264 | /* TRSMRCY */ |
| 257 | msleep (10); | 265 | msleep (10); |
| 258 | 266 | ||
| 259 | /* keep it alive for ~5x suspend + resume costs */ | 267 | /* keep it alive for more than ~5x suspend + resume costs */ |
| 260 | ohci->next_statechange = jiffies + msecs_to_jiffies (250); | 268 | ohci->next_statechange = jiffies + STATECHANGE_DELAY; |
| 261 | 269 | ||
| 262 | /* maybe turn schedules back on */ | 270 | /* maybe turn schedules back on */ |
| 263 | enables = 0; | 271 | enables = 0; |
| @@ -302,9 +310,10 @@ ohci_hub_status_data (struct usb_hcd *hcd, char *buf) | |||
| 302 | { | 310 | { |
| 303 | struct ohci_hcd *ohci = hcd_to_ohci (hcd); | 311 | struct ohci_hcd *ohci = hcd_to_ohci (hcd); |
| 304 | int i, changed = 0, length = 1; | 312 | int i, changed = 0, length = 1; |
| 305 | int can_suspend = device_may_wakeup(&hcd->self.root_hub->dev); | 313 | int can_suspend; |
| 306 | unsigned long flags; | 314 | unsigned long flags; |
| 307 | 315 | ||
| 316 | can_suspend = device_may_wakeup(&hcd->self.root_hub->dev); | ||
| 308 | spin_lock_irqsave (&ohci->lock, flags); | 317 | spin_lock_irqsave (&ohci->lock, flags); |
| 309 | 318 | ||
| 310 | /* handle autosuspended root: finish resuming before | 319 | /* handle autosuspended root: finish resuming before |
| @@ -339,6 +348,10 @@ ohci_hub_status_data (struct usb_hcd *hcd, char *buf) | |||
| 339 | for (i = 0; i < ohci->num_ports; i++) { | 348 | for (i = 0; i < ohci->num_ports; i++) { |
| 340 | u32 status = roothub_portstatus (ohci, i); | 349 | u32 status = roothub_portstatus (ohci, i); |
| 341 | 350 | ||
| 351 | /* can't autosuspend with active ports */ | ||
| 352 | if ((status & RH_PS_PES) && !(status & RH_PS_PSS)) | ||
| 353 | can_suspend = 0; | ||
| 354 | |||
| 342 | if (status & (RH_PS_CSC | RH_PS_PESC | RH_PS_PSSC | 355 | if (status & (RH_PS_CSC | RH_PS_PESC | RH_PS_PSSC |
| 343 | | RH_PS_OCIC | RH_PS_PRSC)) { | 356 | | RH_PS_OCIC | RH_PS_PRSC)) { |
| 344 | changed = 1; | 357 | changed = 1; |
| @@ -348,32 +361,41 @@ ohci_hub_status_data (struct usb_hcd *hcd, char *buf) | |||
| 348 | buf [1] |= 1 << (i - 7); | 361 | buf [1] |= 1 << (i - 7); |
| 349 | continue; | 362 | continue; |
| 350 | } | 363 | } |
| 364 | } | ||
| 351 | 365 | ||
| 352 | /* can suspend if no ports are enabled; or if all all | 366 | /* after root hub changes, stop polling after debouncing |
| 353 | * enabled ports are suspended AND remote wakeup is on. | 367 | * for a while and maybe kicking in autosuspend |
| 354 | */ | 368 | */ |
| 355 | if (!(status & RH_PS_CCS)) | 369 | if (changed) { |
| 356 | continue; | 370 | ohci->next_statechange = jiffies + STATECHANGE_DELAY; |
| 357 | if ((status & RH_PS_PSS) && can_suspend) | ||
| 358 | continue; | ||
| 359 | can_suspend = 0; | 371 | can_suspend = 0; |
| 372 | } else if (time_before (jiffies, ohci->next_statechange)) { | ||
| 373 | can_suspend = 0; | ||
| 374 | } else { | ||
| 375 | #ifdef CONFIG_PM | ||
| 376 | can_suspend = can_suspend | ||
| 377 | && !ohci->ed_rm_list | ||
| 378 | && ((OHCI_CTRL_HCFS | OHCI_SCHED_ENABLES) | ||
| 379 | & ohci->hc_control) | ||
| 380 | == OHCI_USB_OPER; | ||
| 381 | #endif | ||
| 382 | if (hcd->uses_new_polling) { | ||
| 383 | hcd->poll_rh = 0; | ||
| 384 | /* use INTR_RHSC iff INTR_RD won't apply */ | ||
| 385 | if (!can_suspend) | ||
| 386 | ohci_writel (ohci, OHCI_INTR_RHSC, | ||
| 387 | &ohci->regs->intrenable); | ||
| 388 | } | ||
| 360 | } | 389 | } |
| 390 | |||
| 361 | done: | 391 | done: |
| 362 | spin_unlock_irqrestore (&ohci->lock, flags); | 392 | spin_unlock_irqrestore (&ohci->lock, flags); |
| 363 | 393 | ||
| 364 | #ifdef CONFIG_PM | 394 | #ifdef CONFIG_PM |
| 365 | /* save power by suspending idle root hubs; | 395 | /* save power by autosuspending idle root hubs; |
| 366 | * INTR_RD wakes us when there's work | 396 | * INTR_RD wakes us when there's work |
| 367 | */ | 397 | */ |
| 368 | if (can_suspend | 398 | if (can_suspend && usb_trylock_device (hcd->self.root_hub) == 0) { |
| 369 | && !changed | ||
| 370 | && !ohci->ed_rm_list | ||
| 371 | && ((OHCI_CTRL_HCFS | OHCI_SCHED_ENABLES) | ||
| 372 | & ohci->hc_control) | ||
| 373 | == OHCI_USB_OPER | ||
| 374 | && time_after (jiffies, ohci->next_statechange) | ||
| 375 | && usb_trylock_device (hcd->self.root_hub) == 0 | ||
| 376 | ) { | ||
| 377 | ohci_vdbg (ohci, "autosuspend\n"); | 399 | ohci_vdbg (ohci, "autosuspend\n"); |
| 378 | (void) ohci_bus_suspend (hcd); | 400 | (void) ohci_bus_suspend (hcd); |
| 379 | usb_unlock_device (hcd->self.root_hub); | 401 | usb_unlock_device (hcd->self.root_hub); |
diff --git a/drivers/usb/host/ohci-lh7a404.c b/drivers/usb/host/ohci-lh7a404.c index 5602da9bd52c..e121d97ed91c 100644 --- a/drivers/usb/host/ohci-lh7a404.c +++ b/drivers/usb/host/ohci-lh7a404.c | |||
| @@ -173,11 +173,8 @@ static const struct hc_driver ohci_lh7a404_hc_driver = { | |||
| 173 | * basic lifecycle operations | 173 | * basic lifecycle operations |
| 174 | */ | 174 | */ |
| 175 | .start = ohci_lh7a404_start, | 175 | .start = ohci_lh7a404_start, |
| 176 | #ifdef CONFIG_PM | ||
| 177 | /* suspend: ohci_lh7a404_suspend, -- tbd */ | ||
| 178 | /* resume: ohci_lh7a404_resume, -- tbd */ | ||
| 179 | #endif /*CONFIG_PM*/ | ||
| 180 | .stop = ohci_stop, | 176 | .stop = ohci_stop, |
| 177 | .shutdown = ohci_shutdown, | ||
| 181 | 178 | ||
| 182 | /* | 179 | /* |
| 183 | * managing i/o requests and associated device resources | 180 | * managing i/o requests and associated device resources |
| @@ -196,6 +193,7 @@ static const struct hc_driver ohci_lh7a404_hc_driver = { | |||
| 196 | */ | 193 | */ |
| 197 | .hub_status_data = ohci_hub_status_data, | 194 | .hub_status_data = ohci_hub_status_data, |
| 198 | .hub_control = ohci_hub_control, | 195 | .hub_control = ohci_hub_control, |
| 196 | .hub_irq_enable = ohci_rhsc_enable, | ||
| 199 | #ifdef CONFIG_PM | 197 | #ifdef CONFIG_PM |
| 200 | .bus_suspend = ohci_bus_suspend, | 198 | .bus_suspend = ohci_bus_suspend, |
| 201 | .bus_resume = ohci_bus_resume, | 199 | .bus_resume = ohci_bus_resume, |
| @@ -244,6 +242,7 @@ static int ohci_hcd_lh7a404_drv_resume(struct platform_device *dev) | |||
| 244 | static struct platform_driver ohci_hcd_lh7a404_driver = { | 242 | static struct platform_driver ohci_hcd_lh7a404_driver = { |
| 245 | .probe = ohci_hcd_lh7a404_drv_probe, | 243 | .probe = ohci_hcd_lh7a404_drv_probe, |
| 246 | .remove = ohci_hcd_lh7a404_drv_remove, | 244 | .remove = ohci_hcd_lh7a404_drv_remove, |
| 245 | .shutdown = usb_hcd_platform_shutdown, | ||
| 247 | /*.suspend = ohci_hcd_lh7a404_drv_suspend, */ | 246 | /*.suspend = ohci_hcd_lh7a404_drv_suspend, */ |
| 248 | /*.resume = ohci_hcd_lh7a404_drv_resume, */ | 247 | /*.resume = ohci_hcd_lh7a404_drv_resume, */ |
| 249 | .driver = { | 248 | .driver = { |
diff --git a/drivers/usb/host/ohci-mem.c b/drivers/usb/host/ohci-mem.c index bfbe328a4788..d976614eebd3 100644 --- a/drivers/usb/host/ohci-mem.c +++ b/drivers/usb/host/ohci-mem.c | |||
| @@ -28,7 +28,6 @@ static void ohci_hcd_init (struct ohci_hcd *ohci) | |||
| 28 | ohci->next_statechange = jiffies; | 28 | ohci->next_statechange = jiffies; |
| 29 | spin_lock_init (&ohci->lock); | 29 | spin_lock_init (&ohci->lock); |
| 30 | INIT_LIST_HEAD (&ohci->pending); | 30 | INIT_LIST_HEAD (&ohci->pending); |
| 31 | ohci->reboot_notifier.notifier_call = ohci_reboot; | ||
| 32 | } | 31 | } |
| 33 | 32 | ||
| 34 | /*-------------------------------------------------------------------------*/ | 33 | /*-------------------------------------------------------------------------*/ |
diff --git a/drivers/usb/host/ohci-omap.c b/drivers/usb/host/ohci-omap.c index c4c4babd4767..9c02177de50a 100644 --- a/drivers/usb/host/ohci-omap.c +++ b/drivers/usb/host/ohci-omap.c | |||
| @@ -4,7 +4,7 @@ | |||
| 4 | * (C) Copyright 1999 Roman Weissgaerber <weissg@vienna.at> | 4 | * (C) Copyright 1999 Roman Weissgaerber <weissg@vienna.at> |
| 5 | * (C) Copyright 2000-2005 David Brownell | 5 | * (C) Copyright 2000-2005 David Brownell |
| 6 | * (C) Copyright 2002 Hewlett-Packard Company | 6 | * (C) Copyright 2002 Hewlett-Packard Company |
| 7 | * | 7 | * |
| 8 | * OMAP Bus Glue | 8 | * OMAP Bus Glue |
| 9 | * | 9 | * |
| 10 | * Modified for OMAP by Tony Lindgren <tony@atomide.com> | 10 | * Modified for OMAP by Tony Lindgren <tony@atomide.com> |
| @@ -66,15 +66,20 @@ extern int usb_disabled(void); | |||
| 66 | extern int ocpi_enable(void); | 66 | extern int ocpi_enable(void); |
| 67 | 67 | ||
| 68 | static struct clk *usb_host_ck; | 68 | static struct clk *usb_host_ck; |
| 69 | static struct clk *usb_dc_ck; | ||
| 70 | static int host_enabled; | ||
| 71 | static int host_initialized; | ||
| 69 | 72 | ||
| 70 | static void omap_ohci_clock_power(int on) | 73 | static void omap_ohci_clock_power(int on) |
| 71 | { | 74 | { |
| 72 | if (on) { | 75 | if (on) { |
| 76 | clk_enable(usb_dc_ck); | ||
| 73 | clk_enable(usb_host_ck); | 77 | clk_enable(usb_host_ck); |
| 74 | /* guesstimate for T5 == 1x 32K clock + APLL lock time */ | 78 | /* guesstimate for T5 == 1x 32K clock + APLL lock time */ |
| 75 | udelay(100); | 79 | udelay(100); |
| 76 | } else { | 80 | } else { |
| 77 | clk_disable(usb_host_ck); | 81 | clk_disable(usb_host_ck); |
| 82 | clk_disable(usb_dc_ck); | ||
| 78 | } | 83 | } |
| 79 | } | 84 | } |
| 80 | 85 | ||
| @@ -87,14 +92,14 @@ static int omap_ohci_transceiver_power(int on) | |||
| 87 | if (on) { | 92 | if (on) { |
| 88 | if (machine_is_omap_innovator() && cpu_is_omap1510()) | 93 | if (machine_is_omap_innovator() && cpu_is_omap1510()) |
| 89 | fpga_write(fpga_read(INNOVATOR_FPGA_CAM_USB_CONTROL) | 94 | fpga_write(fpga_read(INNOVATOR_FPGA_CAM_USB_CONTROL) |
| 90 | | ((1 << 5/*usb1*/) | (1 << 3/*usb2*/)), | 95 | | ((1 << 5/*usb1*/) | (1 << 3/*usb2*/)), |
| 91 | INNOVATOR_FPGA_CAM_USB_CONTROL); | 96 | INNOVATOR_FPGA_CAM_USB_CONTROL); |
| 92 | else if (machine_is_omap_osk()) | 97 | else if (machine_is_omap_osk()) |
| 93 | tps65010_set_gpio_out_value(GPIO1, LOW); | 98 | tps65010_set_gpio_out_value(GPIO1, LOW); |
| 94 | } else { | 99 | } else { |
| 95 | if (machine_is_omap_innovator() && cpu_is_omap1510()) | 100 | if (machine_is_omap_innovator() && cpu_is_omap1510()) |
| 96 | fpga_write(fpga_read(INNOVATOR_FPGA_CAM_USB_CONTROL) | 101 | fpga_write(fpga_read(INNOVATOR_FPGA_CAM_USB_CONTROL) |
| 97 | & ~((1 << 5/*usb1*/) | (1 << 3/*usb2*/)), | 102 | & ~((1 << 5/*usb1*/) | (1 << 3/*usb2*/)), |
| 98 | INNOVATOR_FPGA_CAM_USB_CONTROL); | 103 | INNOVATOR_FPGA_CAM_USB_CONTROL); |
| 99 | else if (machine_is_omap_osk()) | 104 | else if (machine_is_omap_osk()) |
| 100 | tps65010_set_gpio_out_value(GPIO1, HIGH); | 105 | tps65010_set_gpio_out_value(GPIO1, HIGH); |
| @@ -103,6 +108,7 @@ static int omap_ohci_transceiver_power(int on) | |||
| 103 | return 0; | 108 | return 0; |
| 104 | } | 109 | } |
| 105 | 110 | ||
| 111 | #ifdef CONFIG_ARCH_OMAP15XX | ||
| 106 | /* | 112 | /* |
| 107 | * OMAP-1510 specific Local Bus clock on/off | 113 | * OMAP-1510 specific Local Bus clock on/off |
| 108 | */ | 114 | */ |
| @@ -121,8 +127,8 @@ static int omap_1510_local_bus_power(int on) | |||
| 121 | /* | 127 | /* |
| 122 | * OMAP-1510 specific Local Bus initialization | 128 | * OMAP-1510 specific Local Bus initialization |
| 123 | * NOTE: This assumes 32MB memory size in OMAP1510LB_MEMSIZE. | 129 | * NOTE: This assumes 32MB memory size in OMAP1510LB_MEMSIZE. |
| 124 | * See also arch/mach-omap/memory.h for __virt_to_dma() and | 130 | * See also arch/mach-omap/memory.h for __virt_to_dma() and |
| 125 | * __dma_to_virt() which need to match with the physical | 131 | * __dma_to_virt() which need to match with the physical |
| 126 | * Local Bus address below. | 132 | * Local Bus address below. |
| 127 | */ | 133 | */ |
| 128 | static int omap_1510_local_bus_init(void) | 134 | static int omap_1510_local_bus_init(void) |
| @@ -130,7 +136,7 @@ static int omap_1510_local_bus_init(void) | |||
| 130 | unsigned int tlb; | 136 | unsigned int tlb; |
| 131 | unsigned long lbaddr, physaddr; | 137 | unsigned long lbaddr, physaddr; |
| 132 | 138 | ||
| 133 | omap_writel((omap_readl(OMAP1510_LB_CLOCK_DIV) & 0xfffffff8) | 0x4, | 139 | omap_writel((omap_readl(OMAP1510_LB_CLOCK_DIV) & 0xfffffff8) | 0x4, |
| 134 | OMAP1510_LB_CLOCK_DIV); | 140 | OMAP1510_LB_CLOCK_DIV); |
| 135 | 141 | ||
| 136 | /* Configure the Local Bus MMU table */ | 142 | /* Configure the Local Bus MMU table */ |
| @@ -138,7 +144,7 @@ static int omap_1510_local_bus_init(void) | |||
| 138 | lbaddr = tlb * 0x00100000 + OMAP1510_LB_OFFSET; | 144 | lbaddr = tlb * 0x00100000 + OMAP1510_LB_OFFSET; |
| 139 | physaddr = tlb * 0x00100000 + PHYS_OFFSET; | 145 | physaddr = tlb * 0x00100000 + PHYS_OFFSET; |
| 140 | omap_writel((lbaddr & 0x0fffffff) >> 22, OMAP1510_LB_MMU_CAM_H); | 146 | omap_writel((lbaddr & 0x0fffffff) >> 22, OMAP1510_LB_MMU_CAM_H); |
| 141 | omap_writel(((lbaddr & 0x003ffc00) >> 6) | 0xc, | 147 | omap_writel(((lbaddr & 0x003ffc00) >> 6) | 0xc, |
| 142 | OMAP1510_LB_MMU_CAM_L); | 148 | OMAP1510_LB_MMU_CAM_L); |
| 143 | omap_writel(physaddr >> 16, OMAP1510_LB_MMU_RAM_H); | 149 | omap_writel(physaddr >> 16, OMAP1510_LB_MMU_RAM_H); |
| 144 | omap_writel((physaddr & 0x0000fc00) | 0x300, OMAP1510_LB_MMU_RAM_L); | 150 | omap_writel((physaddr & 0x0000fc00) | 0x300, OMAP1510_LB_MMU_RAM_L); |
| @@ -152,6 +158,10 @@ static int omap_1510_local_bus_init(void) | |||
| 152 | 158 | ||
| 153 | return 0; | 159 | return 0; |
| 154 | } | 160 | } |
| 161 | #else | ||
| 162 | #define omap_1510_local_bus_power(x) {} | ||
| 163 | #define omap_1510_local_bus_init() {} | ||
| 164 | #endif | ||
| 155 | 165 | ||
| 156 | #ifdef CONFIG_USB_OTG | 166 | #ifdef CONFIG_USB_OTG |
| 157 | 167 | ||
| @@ -173,13 +183,14 @@ static void start_hnp(struct ohci_hcd *ohci) | |||
| 173 | 183 | ||
| 174 | /*-------------------------------------------------------------------------*/ | 184 | /*-------------------------------------------------------------------------*/ |
| 175 | 185 | ||
| 176 | static int omap_start_hc(struct ohci_hcd *ohci, struct platform_device *pdev) | 186 | static int ohci_omap_init(struct usb_hcd *hcd) |
| 177 | { | 187 | { |
| 178 | struct omap_usb_config *config = pdev->dev.platform_data; | 188 | struct ohci_hcd *ohci = hcd_to_ohci(hcd); |
| 189 | struct omap_usb_config *config = hcd->self.controller->platform_data; | ||
| 179 | int need_transceiver = (config->otg != 0); | 190 | int need_transceiver = (config->otg != 0); |
| 180 | int ret; | 191 | int ret; |
| 181 | 192 | ||
| 182 | dev_dbg(&pdev->dev, "starting USB Controller\n"); | 193 | dev_dbg(hcd->self.controller, "starting USB Controller\n"); |
| 183 | 194 | ||
| 184 | if (config->otg) { | 195 | if (config->otg) { |
| 185 | ohci_to_hcd(ohci)->self.otg_port = config->otg; | 196 | ohci_to_hcd(ohci)->self.otg_port = config->otg; |
| @@ -200,7 +211,7 @@ static int omap_start_hc(struct ohci_hcd *ohci, struct platform_device *pdev) | |||
| 200 | if (ohci->transceiver) { | 211 | if (ohci->transceiver) { |
| 201 | int status = otg_set_host(ohci->transceiver, | 212 | int status = otg_set_host(ohci->transceiver, |
| 202 | &ohci_to_hcd(ohci)->self); | 213 | &ohci_to_hcd(ohci)->self); |
| 203 | dev_dbg(&pdev->dev, "init %s transceiver, status %d\n", | 214 | dev_dbg(hcd->self.controller, "init %s transceiver, status %d\n", |
| 204 | ohci->transceiver->label, status); | 215 | ohci->transceiver->label, status); |
| 205 | if (status) { | 216 | if (status) { |
| 206 | if (ohci->transceiver) | 217 | if (ohci->transceiver) |
| @@ -208,7 +219,7 @@ static int omap_start_hc(struct ohci_hcd *ohci, struct platform_device *pdev) | |||
| 208 | return status; | 219 | return status; |
| 209 | } | 220 | } |
| 210 | } else { | 221 | } else { |
| 211 | dev_err(&pdev->dev, "can't find transceiver\n"); | 222 | dev_err(hcd->self.controller, "can't find transceiver\n"); |
| 212 | return -ENODEV; | 223 | return -ENODEV; |
| 213 | } | 224 | } |
| 214 | } | 225 | } |
| @@ -247,6 +258,10 @@ static int omap_start_hc(struct ohci_hcd *ohci, struct platform_device *pdev) | |||
| 247 | } | 258 | } |
| 248 | ohci_writel(ohci, rh, &ohci->regs->roothub.a); | 259 | ohci_writel(ohci, rh, &ohci->regs->roothub.a); |
| 249 | distrust_firmware = 0; | 260 | distrust_firmware = 0; |
| 261 | } else if (machine_is_nokia770()) { | ||
| 262 | /* We require a self-powered hub, which should have | ||
| 263 | * plenty of power. */ | ||
| 264 | ohci_to_hcd(ohci)->power_budget = 0; | ||
| 250 | } | 265 | } |
| 251 | 266 | ||
| 252 | /* FIXME khubd hub requests should manage power switching */ | 267 | /* FIXME khubd hub requests should manage power switching */ |
| @@ -260,21 +275,15 @@ static int omap_start_hc(struct ohci_hcd *ohci, struct platform_device *pdev) | |||
| 260 | return 0; | 275 | return 0; |
| 261 | } | 276 | } |
| 262 | 277 | ||
| 263 | static void omap_stop_hc(struct platform_device *pdev) | 278 | static void ohci_omap_stop(struct usb_hcd *hcd) |
| 264 | { | 279 | { |
| 265 | dev_dbg(&pdev->dev, "stopping USB Controller\n"); | 280 | dev_dbg(hcd->self.controller, "stopping USB Controller\n"); |
| 266 | omap_ohci_clock_power(0); | 281 | omap_ohci_clock_power(0); |
| 267 | } | 282 | } |
| 268 | 283 | ||
| 269 | 284 | ||
| 270 | /*-------------------------------------------------------------------------*/ | 285 | /*-------------------------------------------------------------------------*/ |
| 271 | 286 | ||
| 272 | void usb_hcd_omap_remove (struct usb_hcd *, struct platform_device *); | ||
| 273 | |||
| 274 | /* configure so an HC device and id are always provided */ | ||
| 275 | /* always called with process context; sleeping is OK */ | ||
| 276 | |||
| 277 | |||
| 278 | /** | 287 | /** |
| 279 | * usb_hcd_omap_probe - initialize OMAP-based HCDs | 288 | * usb_hcd_omap_probe - initialize OMAP-based HCDs |
| 280 | * Context: !in_interrupt() | 289 | * Context: !in_interrupt() |
| @@ -283,7 +292,7 @@ void usb_hcd_omap_remove (struct usb_hcd *, struct platform_device *); | |||
| 283 | * then invokes the start() method for the HCD associated with it | 292 | * then invokes the start() method for the HCD associated with it |
| 284 | * through the hotplug entry's driver_data. | 293 | * through the hotplug entry's driver_data. |
| 285 | */ | 294 | */ |
| 286 | int usb_hcd_omap_probe (const struct hc_driver *driver, | 295 | static int usb_hcd_omap_probe (const struct hc_driver *driver, |
| 287 | struct platform_device *pdev) | 296 | struct platform_device *pdev) |
| 288 | { | 297 | { |
| 289 | int retval, irq; | 298 | int retval, irq; |
| @@ -291,12 +300,12 @@ int usb_hcd_omap_probe (const struct hc_driver *driver, | |||
| 291 | struct ohci_hcd *ohci; | 300 | struct ohci_hcd *ohci; |
| 292 | 301 | ||
| 293 | if (pdev->num_resources != 2) { | 302 | if (pdev->num_resources != 2) { |
| 294 | printk(KERN_ERR "hcd probe: invalid num_resources: %i\n", | 303 | printk(KERN_ERR "hcd probe: invalid num_resources: %i\n", |
| 295 | pdev->num_resources); | 304 | pdev->num_resources); |
| 296 | return -ENODEV; | 305 | return -ENODEV; |
| 297 | } | 306 | } |
| 298 | 307 | ||
| 299 | if (pdev->resource[0].flags != IORESOURCE_MEM | 308 | if (pdev->resource[0].flags != IORESOURCE_MEM |
| 300 | || pdev->resource[1].flags != IORESOURCE_IRQ) { | 309 | || pdev->resource[1].flags != IORESOURCE_IRQ) { |
| 301 | printk(KERN_ERR "hcd probe: invalid resource type\n"); | 310 | printk(KERN_ERR "hcd probe: invalid resource type\n"); |
| 302 | return -ENODEV; | 311 | return -ENODEV; |
| @@ -306,6 +315,17 @@ int usb_hcd_omap_probe (const struct hc_driver *driver, | |||
| 306 | if (IS_ERR(usb_host_ck)) | 315 | if (IS_ERR(usb_host_ck)) |
| 307 | return PTR_ERR(usb_host_ck); | 316 | return PTR_ERR(usb_host_ck); |
| 308 | 317 | ||
| 318 | if (!cpu_is_omap1510()) | ||
| 319 | usb_dc_ck = clk_get(0, "usb_dc_ck"); | ||
| 320 | else | ||
| 321 | usb_dc_ck = clk_get(0, "lb_ck"); | ||
| 322 | |||
| 323 | if (IS_ERR(usb_dc_ck)) { | ||
| 324 | clk_put(usb_host_ck); | ||
| 325 | return PTR_ERR(usb_dc_ck); | ||
| 326 | } | ||
| 327 | |||
| 328 | |||
| 309 | hcd = usb_create_hcd (driver, &pdev->dev, pdev->dev.bus_id); | 329 | hcd = usb_create_hcd (driver, &pdev->dev, pdev->dev.bus_id); |
| 310 | if (!hcd) { | 330 | if (!hcd) { |
| 311 | retval = -ENOMEM; | 331 | retval = -ENOMEM; |
| @@ -325,9 +345,8 @@ int usb_hcd_omap_probe (const struct hc_driver *driver, | |||
| 325 | ohci = hcd_to_ohci(hcd); | 345 | ohci = hcd_to_ohci(hcd); |
| 326 | ohci_hcd_init(ohci); | 346 | ohci_hcd_init(ohci); |
| 327 | 347 | ||
| 328 | retval = omap_start_hc(ohci, pdev); | 348 | host_initialized = 0; |
| 329 | if (retval < 0) | 349 | host_enabled = 1; |
| 330 | goto err2; | ||
| 331 | 350 | ||
| 332 | irq = platform_get_irq(pdev, 0); | 351 | irq = platform_get_irq(pdev, 0); |
| 333 | if (irq < 0) { | 352 | if (irq < 0) { |
| @@ -335,15 +354,21 @@ int usb_hcd_omap_probe (const struct hc_driver *driver, | |||
| 335 | goto err2; | 354 | goto err2; |
| 336 | } | 355 | } |
| 337 | retval = usb_add_hcd(hcd, irq, IRQF_DISABLED); | 356 | retval = usb_add_hcd(hcd, irq, IRQF_DISABLED); |
| 338 | if (retval == 0) | 357 | if (retval) |
| 339 | return retval; | 358 | goto err2; |
| 359 | |||
| 360 | host_initialized = 1; | ||
| 361 | |||
| 362 | if (!host_enabled) | ||
| 363 | omap_ohci_clock_power(0); | ||
| 340 | 364 | ||
| 341 | omap_stop_hc(pdev); | 365 | return 0; |
| 342 | err2: | 366 | err2: |
| 343 | release_mem_region(hcd->rsrc_start, hcd->rsrc_len); | 367 | release_mem_region(hcd->rsrc_start, hcd->rsrc_len); |
| 344 | err1: | 368 | err1: |
| 345 | usb_put_hcd(hcd); | 369 | usb_put_hcd(hcd); |
| 346 | err0: | 370 | err0: |
| 371 | clk_put(usb_dc_ck); | ||
| 347 | clk_put(usb_host_ck); | 372 | clk_put(usb_host_ck); |
| 348 | return retval; | 373 | return retval; |
| 349 | } | 374 | } |
| @@ -359,31 +384,41 @@ err0: | |||
| 359 | * Reverses the effect of usb_hcd_omap_probe(), first invoking | 384 | * Reverses the effect of usb_hcd_omap_probe(), first invoking |
| 360 | * the HCD's stop() method. It is always called from a thread | 385 | * the HCD's stop() method. It is always called from a thread |
| 361 | * context, normally "rmmod", "apmd", or something similar. | 386 | * context, normally "rmmod", "apmd", or something similar. |
| 362 | * | ||
| 363 | */ | 387 | */ |
| 364 | void usb_hcd_omap_remove (struct usb_hcd *hcd, struct platform_device *pdev) | 388 | static inline void |
| 389 | usb_hcd_omap_remove (struct usb_hcd *hcd, struct platform_device *pdev) | ||
| 365 | { | 390 | { |
| 391 | struct ohci_hcd *ohci = hcd_to_ohci (hcd); | ||
| 392 | |||
| 366 | usb_remove_hcd(hcd); | 393 | usb_remove_hcd(hcd); |
| 394 | if (ohci->transceiver) { | ||
| 395 | (void) otg_set_host(ohci->transceiver, 0); | ||
| 396 | put_device(ohci->transceiver->dev); | ||
| 397 | } | ||
| 367 | if (machine_is_omap_osk()) | 398 | if (machine_is_omap_osk()) |
| 368 | omap_free_gpio(9); | 399 | omap_free_gpio(9); |
| 369 | omap_stop_hc(pdev); | ||
| 370 | release_mem_region(hcd->rsrc_start, hcd->rsrc_len); | 400 | release_mem_region(hcd->rsrc_start, hcd->rsrc_len); |
| 371 | usb_put_hcd(hcd); | 401 | usb_put_hcd(hcd); |
| 402 | clk_put(usb_dc_ck); | ||
| 372 | clk_put(usb_host_ck); | 403 | clk_put(usb_host_ck); |
| 373 | } | 404 | } |
| 374 | 405 | ||
| 375 | /*-------------------------------------------------------------------------*/ | 406 | /*-------------------------------------------------------------------------*/ |
| 376 | 407 | ||
| 377 | static int __devinit | 408 | static int |
| 378 | ohci_omap_start (struct usb_hcd *hcd) | 409 | ohci_omap_start (struct usb_hcd *hcd) |
| 379 | { | 410 | { |
| 380 | struct omap_usb_config *config; | 411 | struct omap_usb_config *config; |
| 381 | struct ohci_hcd *ohci = hcd_to_ohci (hcd); | 412 | struct ohci_hcd *ohci = hcd_to_ohci (hcd); |
| 382 | int ret; | 413 | int ret; |
| 383 | 414 | ||
| 415 | if (!host_enabled) | ||
| 416 | return 0; | ||
| 384 | config = hcd->self.controller->platform_data; | 417 | config = hcd->self.controller->platform_data; |
| 385 | if (config->otg || config->rwc) | 418 | if (config->otg || config->rwc) { |
| 419 | ohci->hc_control = OHCI_CTRL_RWC; | ||
| 386 | writel(OHCI_CTRL_RWC, &ohci->regs->control); | 420 | writel(OHCI_CTRL_RWC, &ohci->regs->control); |
| 421 | } | ||
| 387 | 422 | ||
| 388 | if ((ret = ohci_run (ohci)) < 0) { | 423 | if ((ret = ohci_run (ohci)) < 0) { |
| 389 | dev_err(hcd->self.controller, "can't start\n"); | 424 | dev_err(hcd->self.controller, "can't start\n"); |
| @@ -409,8 +444,10 @@ static const struct hc_driver ohci_omap_hc_driver = { | |||
| 409 | /* | 444 | /* |
| 410 | * basic lifecycle operations | 445 | * basic lifecycle operations |
| 411 | */ | 446 | */ |
| 447 | .reset = ohci_omap_init, | ||
| 412 | .start = ohci_omap_start, | 448 | .start = ohci_omap_start, |
| 413 | .stop = ohci_stop, | 449 | .stop = ohci_omap_stop, |
| 450 | .shutdown = ohci_shutdown, | ||
| 414 | 451 | ||
| 415 | /* | 452 | /* |
| 416 | * managing i/o requests and associated device resources | 453 | * managing i/o requests and associated device resources |
| @@ -429,6 +466,7 @@ static const struct hc_driver ohci_omap_hc_driver = { | |||
| 429 | */ | 466 | */ |
| 430 | .hub_status_data = ohci_hub_status_data, | 467 | .hub_status_data = ohci_hub_status_data, |
| 431 | .hub_control = ohci_hub_control, | 468 | .hub_control = ohci_hub_control, |
| 469 | .hub_irq_enable = ohci_rhsc_enable, | ||
| 432 | #ifdef CONFIG_PM | 470 | #ifdef CONFIG_PM |
| 433 | .bus_suspend = ohci_bus_suspend, | 471 | .bus_suspend = ohci_bus_suspend, |
| 434 | .bus_resume = ohci_bus_resume, | 472 | .bus_resume = ohci_bus_resume, |
| @@ -446,13 +484,8 @@ static int ohci_hcd_omap_drv_probe(struct platform_device *dev) | |||
| 446 | static int ohci_hcd_omap_drv_remove(struct platform_device *dev) | 484 | static int ohci_hcd_omap_drv_remove(struct platform_device *dev) |
| 447 | { | 485 | { |
| 448 | struct usb_hcd *hcd = platform_get_drvdata(dev); | 486 | struct usb_hcd *hcd = platform_get_drvdata(dev); |
| 449 | struct ohci_hcd *ohci = hcd_to_ohci (hcd); | ||
| 450 | 487 | ||
| 451 | usb_hcd_omap_remove(hcd, dev); | 488 | usb_hcd_omap_remove(hcd, dev); |
| 452 | if (ohci->transceiver) { | ||
| 453 | (void) otg_set_host(ohci->transceiver, 0); | ||
| 454 | put_device(ohci->transceiver->dev); | ||
| 455 | } | ||
| 456 | platform_set_drvdata(dev, NULL); | 489 | platform_set_drvdata(dev, NULL); |
| 457 | 490 | ||
| 458 | return 0; | 491 | return 0; |
| @@ -472,7 +505,7 @@ static int ohci_omap_suspend(struct platform_device *dev, pm_message_t message) | |||
| 472 | 505 | ||
| 473 | omap_ohci_clock_power(0); | 506 | omap_ohci_clock_power(0); |
| 474 | ohci_to_hcd(ohci)->state = HC_STATE_SUSPENDED; | 507 | ohci_to_hcd(ohci)->state = HC_STATE_SUSPENDED; |
| 475 | dev->power.power_state = PMSG_SUSPEND; | 508 | dev->dev.power.power_state = PMSG_SUSPEND; |
| 476 | return 0; | 509 | return 0; |
| 477 | } | 510 | } |
| 478 | 511 | ||
| @@ -485,8 +518,8 @@ static int ohci_omap_resume(struct platform_device *dev) | |||
| 485 | ohci->next_statechange = jiffies; | 518 | ohci->next_statechange = jiffies; |
| 486 | 519 | ||
| 487 | omap_ohci_clock_power(1); | 520 | omap_ohci_clock_power(1); |
| 488 | dev->power.power_state = PMSG_ON; | 521 | dev->dev.power.power_state = PMSG_ON; |
| 489 | usb_hcd_resume_root_hub(dev_get_drvdata(dev)); | 522 | usb_hcd_resume_root_hub(platform_get_drvdata(dev)); |
| 490 | return 0; | 523 | return 0; |
| 491 | } | 524 | } |
| 492 | 525 | ||
| @@ -500,6 +533,7 @@ static int ohci_omap_resume(struct platform_device *dev) | |||
| 500 | static struct platform_driver ohci_hcd_omap_driver = { | 533 | static struct platform_driver ohci_hcd_omap_driver = { |
| 501 | .probe = ohci_hcd_omap_drv_probe, | 534 | .probe = ohci_hcd_omap_drv_probe, |
| 502 | .remove = ohci_hcd_omap_drv_remove, | 535 | .remove = ohci_hcd_omap_drv_remove, |
| 536 | .shutdown = usb_hcd_platform_shutdown, | ||
| 503 | #ifdef CONFIG_PM | 537 | #ifdef CONFIG_PM |
| 504 | .suspend = ohci_omap_suspend, | 538 | .suspend = ohci_omap_suspend, |
| 505 | .resume = ohci_omap_resume, | 539 | .resume = ohci_omap_resume, |
diff --git a/drivers/usb/host/ohci-pci.c b/drivers/usb/host/ohci-pci.c index b268537e389e..3732db7d68eb 100644 --- a/drivers/usb/host/ohci-pci.c +++ b/drivers/usb/host/ohci-pci.c | |||
| @@ -135,6 +135,11 @@ static int ohci_pci_suspend (struct usb_hcd *hcd, pm_message_t message) | |||
| 135 | } | 135 | } |
| 136 | ohci_writel(ohci, OHCI_INTR_MIE, &ohci->regs->intrdisable); | 136 | ohci_writel(ohci, OHCI_INTR_MIE, &ohci->regs->intrdisable); |
| 137 | (void)ohci_readl(ohci, &ohci->regs->intrdisable); | 137 | (void)ohci_readl(ohci, &ohci->regs->intrdisable); |
| 138 | |||
| 139 | /* make sure snapshot being resumed re-enumerates everything */ | ||
| 140 | if (message.event == PM_EVENT_PRETHAW) | ||
| 141 | ohci_usb_reset(ohci); | ||
| 142 | |||
| 138 | clear_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags); | 143 | clear_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags); |
| 139 | bail: | 144 | bail: |
| 140 | spin_unlock_irqrestore (&ohci->lock, flags); | 145 | spin_unlock_irqrestore (&ohci->lock, flags); |
| @@ -171,11 +176,14 @@ static const struct hc_driver ohci_pci_hc_driver = { | |||
| 171 | */ | 176 | */ |
| 172 | .reset = ohci_pci_reset, | 177 | .reset = ohci_pci_reset, |
| 173 | .start = ohci_pci_start, | 178 | .start = ohci_pci_start, |
| 179 | .stop = ohci_stop, | ||
| 180 | .shutdown = ohci_shutdown, | ||
| 181 | |||
| 174 | #ifdef CONFIG_PM | 182 | #ifdef CONFIG_PM |
| 183 | /* these suspend/resume entries are for upstream PCI glue ONLY */ | ||
| 175 | .suspend = ohci_pci_suspend, | 184 | .suspend = ohci_pci_suspend, |
| 176 | .resume = ohci_pci_resume, | 185 | .resume = ohci_pci_resume, |
| 177 | #endif | 186 | #endif |
| 178 | .stop = ohci_stop, | ||
| 179 | 187 | ||
| 180 | /* | 188 | /* |
| 181 | * managing i/o requests and associated device resources | 189 | * managing i/o requests and associated device resources |
| @@ -194,6 +202,7 @@ static const struct hc_driver ohci_pci_hc_driver = { | |||
| 194 | */ | 202 | */ |
| 195 | .hub_status_data = ohci_hub_status_data, | 203 | .hub_status_data = ohci_hub_status_data, |
| 196 | .hub_control = ohci_hub_control, | 204 | .hub_control = ohci_hub_control, |
| 205 | .hub_irq_enable = ohci_rhsc_enable, | ||
| 197 | #ifdef CONFIG_PM | 206 | #ifdef CONFIG_PM |
| 198 | .bus_suspend = ohci_bus_suspend, | 207 | .bus_suspend = ohci_bus_suspend, |
| 199 | .bus_resume = ohci_bus_resume, | 208 | .bus_resume = ohci_bus_resume, |
| @@ -224,6 +233,8 @@ static struct pci_driver ohci_pci_driver = { | |||
| 224 | .suspend = usb_hcd_pci_suspend, | 233 | .suspend = usb_hcd_pci_suspend, |
| 225 | .resume = usb_hcd_pci_resume, | 234 | .resume = usb_hcd_pci_resume, |
| 226 | #endif | 235 | #endif |
| 236 | |||
| 237 | .shutdown = usb_hcd_pci_shutdown, | ||
| 227 | }; | 238 | }; |
| 228 | 239 | ||
| 229 | 240 | ||
diff --git a/drivers/usb/host/ohci-pnx4008.c b/drivers/usb/host/ohci-pnx4008.c new file mode 100644 index 000000000000..82cb22f002e7 --- /dev/null +++ b/drivers/usb/host/ohci-pnx4008.c | |||
| @@ -0,0 +1,476 @@ | |||
| 1 | /* | ||
| 2 | * drivers/usb/host/ohci-pnx4008.c | ||
| 3 | * | ||
| 4 | * driver for Philips PNX4008 USB Host | ||
| 5 | * | ||
| 6 | * Authors: Dmitry Chigirev <source@mvista.com> | ||
| 7 | * Vitaly Wool <vitalywool@gmail.com> | ||
| 8 | * | ||
| 9 | * register initialization is based on code examples provided by Philips | ||
| 10 | * Copyright (c) 2005 Koninklijke Philips Electronics N.V. | ||
| 11 | * | ||
| 12 | * NOTE: This driver does not have suspend/resume functionality | ||
| 13 | * This driver is intended for engineering development purposes only | ||
| 14 | * | ||
| 15 | * 2005-2006 (c) MontaVista Software, Inc. This file is licensed under | ||
| 16 | * the terms of the GNU General Public License version 2. This program | ||
| 17 | * is licensed "as is" without any warranty of any kind, whether express | ||
| 18 | * or implied. | ||
| 19 | */ | ||
| 20 | #include <linux/clk.h> | ||
| 21 | #include <linux/platform_device.h> | ||
| 22 | #include <linux/i2c.h> | ||
| 23 | |||
| 24 | #include <asm/hardware.h> | ||
| 25 | #include <asm/io.h> | ||
| 26 | #include <asm/mach-types.h> | ||
| 27 | |||
| 28 | #include <asm/arch/platform.h> | ||
| 29 | #include <asm/arch/irqs.h> | ||
| 30 | #include <asm/arch/gpio.h> | ||
| 31 | |||
| 32 | #define USB_CTRL IO_ADDRESS(PNX4008_PWRMAN_BASE + 0x64) | ||
| 33 | |||
| 34 | /* USB_CTRL bit defines */ | ||
| 35 | #define USB_SLAVE_HCLK_EN (1 << 24) | ||
| 36 | #define USB_HOST_NEED_CLK_EN (1 << 21) | ||
| 37 | |||
| 38 | #define USB_OTG_CLK_CTRL IO_ADDRESS(PNX4008_USB_CONFIG_BASE + 0xFF4) | ||
| 39 | #define USB_OTG_CLK_STAT IO_ADDRESS(PNX4008_USB_CONFIG_BASE + 0xFF8) | ||
| 40 | |||
| 41 | /* USB_OTG_CLK_CTRL bit defines */ | ||
| 42 | #define AHB_M_CLOCK_ON (1 << 4) | ||
| 43 | #define OTG_CLOCK_ON (1 << 3) | ||
| 44 | #define I2C_CLOCK_ON (1 << 2) | ||
| 45 | #define DEV_CLOCK_ON (1 << 1) | ||
| 46 | #define HOST_CLOCK_ON (1 << 0) | ||
| 47 | |||
| 48 | #define USB_OTG_STAT_CONTROL IO_ADDRESS(PNX4008_USB_CONFIG_BASE + 0x110) | ||
| 49 | |||
| 50 | /* USB_OTG_STAT_CONTROL bit defines */ | ||
| 51 | #define TRANSPARENT_I2C_EN (1 << 7) | ||
| 52 | #define HOST_EN (1 << 0) | ||
| 53 | |||
| 54 | /* ISP1301 USB transceiver I2C registers */ | ||
| 55 | #define ISP1301_MODE_CONTROL_1 0x04 /* u8 read, set, +1 clear */ | ||
| 56 | |||
| 57 | #define MC1_SPEED_REG (1 << 0) | ||
| 58 | #define MC1_SUSPEND_REG (1 << 1) | ||
| 59 | #define MC1_DAT_SE0 (1 << 2) | ||
| 60 | #define MC1_TRANSPARENT (1 << 3) | ||
| 61 | #define MC1_BDIS_ACON_EN (1 << 4) | ||
| 62 | #define MC1_OE_INT_EN (1 << 5) | ||
| 63 | #define MC1_UART_EN (1 << 6) | ||
| 64 | #define MC1_MASK 0x7f | ||
| 65 | |||
| 66 | #define ISP1301_MODE_CONTROL_2 0x12 /* u8 read, set, +1 clear */ | ||
| 67 | |||
| 68 | #define MC2_GLOBAL_PWR_DN (1 << 0) | ||
| 69 | #define MC2_SPD_SUSP_CTRL (1 << 1) | ||
| 70 | #define MC2_BI_DI (1 << 2) | ||
| 71 | #define MC2_TRANSP_BDIR0 (1 << 3) | ||
| 72 | #define MC2_TRANSP_BDIR1 (1 << 4) | ||
| 73 | #define MC2_AUDIO_EN (1 << 5) | ||
| 74 | #define MC2_PSW_EN (1 << 6) | ||
| 75 | #define MC2_EN2V7 (1 << 7) | ||
| 76 | |||
| 77 | #define ISP1301_OTG_CONTROL_1 0x06 /* u8 read, set, +1 clear */ | ||
| 78 | # define OTG1_DP_PULLUP (1 << 0) | ||
| 79 | # define OTG1_DM_PULLUP (1 << 1) | ||
| 80 | # define OTG1_DP_PULLDOWN (1 << 2) | ||
| 81 | # define OTG1_DM_PULLDOWN (1 << 3) | ||
| 82 | # define OTG1_ID_PULLDOWN (1 << 4) | ||
| 83 | # define OTG1_VBUS_DRV (1 << 5) | ||
| 84 | # define OTG1_VBUS_DISCHRG (1 << 6) | ||
| 85 | # define OTG1_VBUS_CHRG (1 << 7) | ||
| 86 | #define ISP1301_OTG_STATUS 0x10 /* u8 readonly */ | ||
| 87 | # define OTG_B_SESS_END (1 << 6) | ||
| 88 | # define OTG_B_SESS_VLD (1 << 7) | ||
| 89 | |||
| 90 | #define ISP1301_I2C_ADDR 0x2C | ||
| 91 | |||
| 92 | #define ISP1301_I2C_MODE_CONTROL_1 0x4 | ||
| 93 | #define ISP1301_I2C_MODE_CONTROL_2 0x12 | ||
| 94 | #define ISP1301_I2C_OTG_CONTROL_1 0x6 | ||
| 95 | #define ISP1301_I2C_OTG_CONTROL_2 0x10 | ||
| 96 | #define ISP1301_I2C_INTERRUPT_SOURCE 0x8 | ||
| 97 | #define ISP1301_I2C_INTERRUPT_LATCH 0xA | ||
| 98 | #define ISP1301_I2C_INTERRUPT_FALLING 0xC | ||
| 99 | #define ISP1301_I2C_INTERRUPT_RISING 0xE | ||
| 100 | #define ISP1301_I2C_REG_CLEAR_ADDR 1 | ||
| 101 | |||
| 102 | struct i2c_driver isp1301_driver; | ||
| 103 | struct i2c_client *isp1301_i2c_client; | ||
| 104 | |||
| 105 | extern int usb_disabled(void); | ||
| 106 | extern int ocpi_enable(void); | ||
| 107 | |||
| 108 | static struct clk *usb_clk; | ||
| 109 | |||
| 110 | static int isp1301_probe(struct i2c_adapter *adap); | ||
| 111 | static int isp1301_detach(struct i2c_client *client); | ||
| 112 | static int isp1301_command(struct i2c_client *client, unsigned int cmd, | ||
| 113 | void *arg); | ||
| 114 | |||
| 115 | static unsigned short normal_i2c[] = | ||
| 116 | { ISP1301_I2C_ADDR, ISP1301_I2C_ADDR + 1, I2C_CLIENT_END }; | ||
| 117 | static unsigned short dummy_i2c_addrlist[] = { I2C_CLIENT_END }; | ||
| 118 | |||
| 119 | static struct i2c_client_address_data addr_data = { | ||
| 120 | .normal_i2c = normal_i2c, | ||
| 121 | .probe = dummy_i2c_addrlist, | ||
| 122 | .ignore = dummy_i2c_addrlist, | ||
| 123 | }; | ||
| 124 | |||
| 125 | struct i2c_driver isp1301_driver = { | ||
| 126 | .id = I2C_DRIVERID_I2CDEV, /* Fake Id */ | ||
| 127 | .class = I2C_CLASS_HWMON, | ||
| 128 | .attach_adapter = isp1301_probe, | ||
| 129 | .detach_client = isp1301_detach, | ||
| 130 | .command = isp1301_command | ||
| 131 | }; | ||
| 132 | |||
| 133 | static int isp1301_attach(struct i2c_adapter *adap, int addr, int kind) | ||
| 134 | { | ||
| 135 | struct i2c_client *c; | ||
| 136 | |||
| 137 | c = (struct i2c_client *)kzalloc(sizeof(*c), SLAB_KERNEL); | ||
| 138 | |||
| 139 | if (!c) | ||
| 140 | return -ENOMEM; | ||
| 141 | |||
| 142 | strcpy(c->name, "isp1301"); | ||
| 143 | c->flags = 0; | ||
| 144 | c->addr = addr; | ||
| 145 | c->adapter = adap; | ||
| 146 | c->driver = &isp1301_driver; | ||
| 147 | |||
| 148 | isp1301_i2c_client = c; | ||
| 149 | |||
| 150 | return i2c_attach_client(c); | ||
| 151 | } | ||
| 152 | |||
| 153 | static int isp1301_probe(struct i2c_adapter *adap) | ||
| 154 | { | ||
| 155 | return i2c_probe(adap, &addr_data, isp1301_attach); | ||
| 156 | } | ||
| 157 | |||
| 158 | static int isp1301_detach(struct i2c_client *client) | ||
| 159 | { | ||
| 160 | i2c_detach_client(client); | ||
| 161 | kfree(isp1301_i2c_client); | ||
| 162 | return 0; | ||
| 163 | } | ||
| 164 | |||
| 165 | /* No commands defined */ | ||
| 166 | static int isp1301_command(struct i2c_client *client, unsigned int cmd, | ||
| 167 | void *arg) | ||
| 168 | { | ||
| 169 | return 0; | ||
| 170 | } | ||
| 171 | |||
| 172 | static void i2c_write(u8 buf, u8 subaddr) | ||
| 173 | { | ||
| 174 | char tmpbuf[2]; | ||
| 175 | |||
| 176 | tmpbuf[0] = subaddr; /*register number */ | ||
| 177 | tmpbuf[1] = buf; /*register data */ | ||
| 178 | i2c_master_send(isp1301_i2c_client, &tmpbuf[0], 2); | ||
| 179 | } | ||
| 180 | |||
| 181 | static void isp1301_configure(void) | ||
| 182 | { | ||
| 183 | /* PNX4008 only supports DAT_SE0 USB mode */ | ||
| 184 | /* PNX4008 R2A requires setting the MAX603 to output 3.6V */ | ||
| 185 | /* Power up externel charge-pump */ | ||
| 186 | |||
| 187 | i2c_write(MC1_DAT_SE0 | MC1_SPEED_REG, ISP1301_I2C_MODE_CONTROL_1); | ||
| 188 | i2c_write(~(MC1_DAT_SE0 | MC1_SPEED_REG), | ||
| 189 | ISP1301_I2C_MODE_CONTROL_1 | ISP1301_I2C_REG_CLEAR_ADDR); | ||
| 190 | i2c_write(MC2_BI_DI | MC2_PSW_EN | MC2_SPD_SUSP_CTRL, | ||
| 191 | ISP1301_I2C_MODE_CONTROL_2); | ||
| 192 | i2c_write(~(MC2_BI_DI | MC2_PSW_EN | MC2_SPD_SUSP_CTRL), | ||
| 193 | ISP1301_I2C_MODE_CONTROL_2 | ISP1301_I2C_REG_CLEAR_ADDR); | ||
| 194 | i2c_write(OTG1_DM_PULLDOWN | OTG1_DP_PULLDOWN, | ||
| 195 | ISP1301_I2C_OTG_CONTROL_1); | ||
| 196 | i2c_write(~(OTG1_DM_PULLDOWN | OTG1_DP_PULLDOWN), | ||
| 197 | ISP1301_I2C_OTG_CONTROL_1 | ISP1301_I2C_REG_CLEAR_ADDR); | ||
| 198 | i2c_write(0xFF, | ||
| 199 | ISP1301_I2C_INTERRUPT_LATCH | ISP1301_I2C_REG_CLEAR_ADDR); | ||
| 200 | i2c_write(0xFF, | ||
| 201 | ISP1301_I2C_INTERRUPT_FALLING | ISP1301_I2C_REG_CLEAR_ADDR); | ||
| 202 | i2c_write(0xFF, | ||
| 203 | ISP1301_I2C_INTERRUPT_RISING | ISP1301_I2C_REG_CLEAR_ADDR); | ||
| 204 | |||
| 205 | } | ||
| 206 | |||
| 207 | static inline void isp1301_vbus_on(void) | ||
| 208 | { | ||
| 209 | i2c_write(OTG1_VBUS_DRV, ISP1301_I2C_OTG_CONTROL_1); | ||
| 210 | } | ||
| 211 | |||
| 212 | static inline void isp1301_vbus_off(void) | ||
| 213 | { | ||
| 214 | i2c_write(OTG1_VBUS_DRV, | ||
| 215 | ISP1301_I2C_OTG_CONTROL_1 | ISP1301_I2C_REG_CLEAR_ADDR); | ||
| 216 | } | ||
| 217 | |||
| 218 | static void pnx4008_start_hc(void) | ||
| 219 | { | ||
| 220 | unsigned long tmp = __raw_readl(USB_OTG_STAT_CONTROL) | HOST_EN; | ||
| 221 | __raw_writel(tmp, USB_OTG_STAT_CONTROL); | ||
| 222 | isp1301_vbus_on(); | ||
| 223 | } | ||
| 224 | |||
| 225 | static void pnx4008_stop_hc(void) | ||
| 226 | { | ||
| 227 | unsigned long tmp; | ||
| 228 | isp1301_vbus_off(); | ||
| 229 | tmp = __raw_readl(USB_OTG_STAT_CONTROL) & ~HOST_EN; | ||
| 230 | __raw_writel(tmp, USB_OTG_STAT_CONTROL); | ||
| 231 | } | ||
| 232 | |||
| 233 | static int __devinit ohci_pnx4008_start(struct usb_hcd *hcd) | ||
| 234 | { | ||
| 235 | struct ohci_hcd *ohci = hcd_to_ohci(hcd); | ||
| 236 | int ret; | ||
| 237 | |||
| 238 | if ((ret = ohci_init(ohci)) < 0) | ||
| 239 | return ret; | ||
| 240 | |||
| 241 | if ((ret = ohci_run(ohci)) < 0) { | ||
| 242 | dev_err(hcd->self.controller, "can't start\n"); | ||
| 243 | ohci_stop(hcd); | ||
| 244 | return ret; | ||
| 245 | } | ||
| 246 | return 0; | ||
| 247 | } | ||
| 248 | |||
| 249 | static const struct hc_driver ohci_pnx4008_hc_driver = { | ||
| 250 | .description = hcd_name, | ||
| 251 | .product_desc = "pnx4008 OHCI", | ||
| 252 | |||
| 253 | /* | ||
| 254 | * generic hardware linkage | ||
| 255 | */ | ||
| 256 | .irq = ohci_irq, | ||
| 257 | .flags = HCD_USB11 | HCD_MEMORY, | ||
| 258 | |||
| 259 | .hcd_priv_size = sizeof(struct ohci_hcd), | ||
| 260 | /* | ||
| 261 | * basic lifecycle operations | ||
| 262 | */ | ||
| 263 | .start = ohci_pnx4008_start, | ||
| 264 | .stop = ohci_stop, | ||
| 265 | |||
| 266 | /* | ||
| 267 | * managing i/o requests and associated device resources | ||
| 268 | */ | ||
| 269 | .urb_enqueue = ohci_urb_enqueue, | ||
| 270 | .urb_dequeue = ohci_urb_dequeue, | ||
| 271 | .endpoint_disable = ohci_endpoint_disable, | ||
| 272 | |||
| 273 | /* | ||
| 274 | * scheduling support | ||
| 275 | */ | ||
| 276 | .get_frame_number = ohci_get_frame, | ||
| 277 | |||
| 278 | /* | ||
| 279 | * root hub support | ||
| 280 | */ | ||
| 281 | .hub_status_data = ohci_hub_status_data, | ||
| 282 | .hub_control = ohci_hub_control, | ||
| 283 | |||
| 284 | .start_port_reset = ohci_start_port_reset, | ||
| 285 | }; | ||
| 286 | |||
| 287 | #define USB_CLOCK_MASK (AHB_M_CLOCK_ON| OTG_CLOCK_ON | HOST_CLOCK_ON | I2C_CLOCK_ON) | ||
| 288 | |||
| 289 | static void pnx4008_set_usb_bits(void) | ||
| 290 | { | ||
| 291 | start_int_set_falling_edge(SE_USB_OTG_ATX_INT_N); | ||
| 292 | start_int_ack(SE_USB_OTG_ATX_INT_N); | ||
| 293 | start_int_umask(SE_USB_OTG_ATX_INT_N); | ||
| 294 | |||
| 295 | start_int_set_rising_edge(SE_USB_OTG_TIMER_INT); | ||
| 296 | start_int_ack(SE_USB_OTG_TIMER_INT); | ||
| 297 | start_int_umask(SE_USB_OTG_TIMER_INT); | ||
| 298 | |||
| 299 | start_int_set_rising_edge(SE_USB_I2C_INT); | ||
| 300 | start_int_ack(SE_USB_I2C_INT); | ||
| 301 | start_int_umask(SE_USB_I2C_INT); | ||
| 302 | |||
| 303 | start_int_set_rising_edge(SE_USB_INT); | ||
| 304 | start_int_ack(SE_USB_INT); | ||
| 305 | start_int_umask(SE_USB_INT); | ||
| 306 | |||
| 307 | start_int_set_rising_edge(SE_USB_NEED_CLK_INT); | ||
| 308 | start_int_ack(SE_USB_NEED_CLK_INT); | ||
| 309 | start_int_umask(SE_USB_NEED_CLK_INT); | ||
| 310 | |||
| 311 | start_int_set_rising_edge(SE_USB_AHB_NEED_CLK_INT); | ||
| 312 | start_int_ack(SE_USB_AHB_NEED_CLK_INT); | ||
| 313 | start_int_umask(SE_USB_AHB_NEED_CLK_INT); | ||
| 314 | } | ||
| 315 | |||
| 316 | static void pnx4008_unset_usb_bits(void) | ||
| 317 | { | ||
| 318 | start_int_mask(SE_USB_OTG_ATX_INT_N); | ||
| 319 | start_int_mask(SE_USB_OTG_TIMER_INT); | ||
| 320 | start_int_mask(SE_USB_I2C_INT); | ||
| 321 | start_int_mask(SE_USB_INT); | ||
| 322 | start_int_mask(SE_USB_NEED_CLK_INT); | ||
| 323 | start_int_mask(SE_USB_AHB_NEED_CLK_INT); | ||
| 324 | } | ||
| 325 | |||
| 326 | static int __devinit usb_hcd_pnx4008_probe(struct platform_device *pdev) | ||
| 327 | { | ||
| 328 | struct usb_hcd *hcd = 0; | ||
| 329 | struct ohci_hcd *ohci; | ||
| 330 | const struct hc_driver *driver = &ohci_pnx4008_hc_driver; | ||
| 331 | |||
| 332 | int ret = 0, irq; | ||
| 333 | |||
| 334 | dev_dbg(&pdev->dev, "%s: " DRIVER_INFO " (pnx4008)\n", hcd_name); | ||
| 335 | if (usb_disabled()) { | ||
| 336 | err("USB is disabled"); | ||
| 337 | ret = -ENODEV; | ||
| 338 | goto out; | ||
| 339 | } | ||
| 340 | |||
| 341 | if (pdev->num_resources != 2 | ||
| 342 | || pdev->resource[0].flags != IORESOURCE_MEM | ||
| 343 | || pdev->resource[1].flags != IORESOURCE_IRQ) { | ||
| 344 | err("Invalid resource configuration"); | ||
| 345 | ret = -ENODEV; | ||
| 346 | goto out; | ||
| 347 | } | ||
| 348 | |||
| 349 | /* Enable AHB slave USB clock, needed for further USB clock control */ | ||
| 350 | __raw_writel(USB_SLAVE_HCLK_EN | (1 << 19), USB_CTRL); | ||
| 351 | |||
| 352 | ret = i2c_add_driver(&isp1301_driver); | ||
| 353 | if (ret < 0) { | ||
| 354 | err("failed to connect I2C to ISP1301 USB Transceiver"); | ||
| 355 | goto out; | ||
| 356 | } | ||
| 357 | |||
| 358 | isp1301_configure(); | ||
| 359 | |||
| 360 | /* Enable USB PLL */ | ||
| 361 | usb_clk = clk_get(&pdev->dev, "ck_pll5"); | ||
| 362 | if (IS_ERR(usb_clk)) { | ||
| 363 | err("failed to acquire USB PLL"); | ||
| 364 | ret = PTR_ERR(usb_clk); | ||
| 365 | goto out1; | ||
| 366 | } | ||
| 367 | |||
| 368 | ret = clk_enable(usb_clk); | ||
| 369 | if (ret < 0) { | ||
| 370 | err("failed to start USB PLL"); | ||
| 371 | goto out2; | ||
| 372 | } | ||
| 373 | |||
| 374 | ret = clk_set_rate(usb_clk, 48000); | ||
| 375 | if (ret < 0) { | ||
| 376 | err("failed to set USB clock rate"); | ||
| 377 | goto out3; | ||
| 378 | } | ||
| 379 | |||
| 380 | __raw_writel(__raw_readl(USB_CTRL) | USB_HOST_NEED_CLK_EN, USB_CTRL); | ||
| 381 | |||
| 382 | /* Set to enable all needed USB clocks */ | ||
| 383 | __raw_writel(USB_CLOCK_MASK, USB_OTG_CLK_CTRL); | ||
| 384 | |||
| 385 | while ((__raw_readl(USB_OTG_CLK_STAT) & USB_CLOCK_MASK) != | ||
| 386 | USB_CLOCK_MASK) ; | ||
| 387 | |||
| 388 | hcd = usb_create_hcd (driver, &pdev->dev, pdev->dev.bus_id); | ||
| 389 | if (!hcd) { | ||
| 390 | err("Failed to allocate HC buffer"); | ||
| 391 | ret = -ENOMEM; | ||
| 392 | goto out3; | ||
| 393 | } | ||
| 394 | |||
| 395 | /* Set all USB bits in the Start Enable register */ | ||
| 396 | pnx4008_set_usb_bits(); | ||
| 397 | |||
| 398 | hcd->rsrc_start = pdev->resource[0].start; | ||
| 399 | hcd->rsrc_len = pdev->resource[0].end - pdev->resource[0].start + 1; | ||
| 400 | if (!request_mem_region(hcd->rsrc_start, hcd->rsrc_len, hcd_name)) { | ||
| 401 | dev_dbg(&pdev->dev, "request_mem_region failed\n"); | ||
| 402 | ret = -ENOMEM; | ||
| 403 | goto out4; | ||
| 404 | } | ||
| 405 | hcd->regs = (void __iomem *)pdev->resource[0].start; | ||
| 406 | |||
| 407 | irq = platform_get_irq(pdev, 0); | ||
| 408 | if (irq < 0) { | ||
| 409 | ret = -ENXIO; | ||
| 410 | goto out4; | ||
| 411 | } | ||
| 412 | |||
| 413 | hcd->self.hcpriv = (void *)hcd; | ||
| 414 | |||
| 415 | pnx4008_start_hc(); | ||
| 416 | platform_set_drvdata(pdev, hcd); | ||
| 417 | ohci = hcd_to_ohci(hcd); | ||
| 418 | ohci_hcd_init(ohci); | ||
| 419 | |||
| 420 | dev_info(&pdev->dev, "at 0x%p, irq %d\n", hcd->regs, hcd->irq); | ||
| 421 | ret = usb_add_hcd(hcd, irq, SA_INTERRUPT); | ||
| 422 | if (ret == 0) | ||
| 423 | return ret; | ||
| 424 | |||
| 425 | pnx4008_stop_hc(); | ||
| 426 | out4: | ||
| 427 | pnx4008_unset_usb_bits(); | ||
| 428 | usb_put_hcd(hcd); | ||
| 429 | out3: | ||
| 430 | clk_disable(usb_clk); | ||
| 431 | out2: | ||
| 432 | clk_put(usb_clk); | ||
| 433 | out1: | ||
| 434 | i2c_del_driver(&isp1301_driver); | ||
| 435 | out: | ||
| 436 | return ret; | ||
| 437 | } | ||
| 438 | |||
| 439 | static int usb_hcd_pnx4008_remove(struct platform_device *pdev) | ||
| 440 | { | ||
| 441 | struct usb_hcd *hcd = platform_get_drvdata(pdev); | ||
| 442 | |||
| 443 | usb_remove_hcd(hcd); | ||
| 444 | pnx4008_stop_hc(); | ||
| 445 | release_mem_region(hcd->rsrc_start, hcd->rsrc_len); | ||
| 446 | usb_put_hcd(hcd); | ||
| 447 | pnx4008_unset_usb_bits(); | ||
| 448 | clk_disable(usb_clk); | ||
| 449 | clk_put(usb_clk); | ||
| 450 | i2c_del_driver(&isp1301_driver); | ||
| 451 | |||
| 452 | platform_set_drvdata(pdev, NULL); | ||
| 453 | |||
| 454 | return 0; | ||
| 455 | } | ||
| 456 | |||
| 457 | static struct platform_driver usb_hcd_pnx4008_driver = { | ||
| 458 | .driver = { | ||
| 459 | .name = "usb-ohci", | ||
| 460 | }, | ||
| 461 | .probe = usb_hcd_pnx4008_probe, | ||
| 462 | .remove = usb_hcd_pnx4008_remove, | ||
| 463 | }; | ||
| 464 | |||
| 465 | static int __init usb_hcd_pnx4008_init(void) | ||
| 466 | { | ||
| 467 | return platform_driver_register(&usb_hcd_pnx4008_driver); | ||
| 468 | } | ||
| 469 | |||
| 470 | static void __exit usb_hcd_pnx4008_cleanup(void) | ||
| 471 | { | ||
| 472 | return platform_driver_unregister(&usb_hcd_pnx4008_driver); | ||
| 473 | } | ||
| 474 | |||
| 475 | module_init(usb_hcd_pnx4008_init); | ||
| 476 | module_exit(usb_hcd_pnx4008_cleanup); | ||
diff --git a/drivers/usb/host/ohci-ppc-soc.c b/drivers/usb/host/ohci-ppc-soc.c index 9fe56ff1615d..d9d1ae236bd5 100644 --- a/drivers/usb/host/ohci-ppc-soc.c +++ b/drivers/usb/host/ohci-ppc-soc.c | |||
| @@ -148,6 +148,7 @@ static const struct hc_driver ohci_ppc_soc_hc_driver = { | |||
| 148 | */ | 148 | */ |
| 149 | .start = ohci_ppc_soc_start, | 149 | .start = ohci_ppc_soc_start, |
| 150 | .stop = ohci_stop, | 150 | .stop = ohci_stop, |
| 151 | .shutdown = ohci_shutdown, | ||
| 151 | 152 | ||
| 152 | /* | 153 | /* |
| 153 | * managing i/o requests and associated device resources | 154 | * managing i/o requests and associated device resources |
| @@ -166,6 +167,7 @@ static const struct hc_driver ohci_ppc_soc_hc_driver = { | |||
| 166 | */ | 167 | */ |
| 167 | .hub_status_data = ohci_hub_status_data, | 168 | .hub_status_data = ohci_hub_status_data, |
| 168 | .hub_control = ohci_hub_control, | 169 | .hub_control = ohci_hub_control, |
| 170 | .hub_irq_enable = ohci_rhsc_enable, | ||
| 169 | #ifdef CONFIG_PM | 171 | #ifdef CONFIG_PM |
| 170 | .bus_suspend = ohci_bus_suspend, | 172 | .bus_suspend = ohci_bus_suspend, |
| 171 | .bus_resume = ohci_bus_resume, | 173 | .bus_resume = ohci_bus_resume, |
| @@ -195,6 +197,7 @@ static int ohci_hcd_ppc_soc_drv_remove(struct platform_device *pdev) | |||
| 195 | static struct platform_driver ohci_hcd_ppc_soc_driver = { | 197 | static struct platform_driver ohci_hcd_ppc_soc_driver = { |
| 196 | .probe = ohci_hcd_ppc_soc_drv_probe, | 198 | .probe = ohci_hcd_ppc_soc_drv_probe, |
| 197 | .remove = ohci_hcd_ppc_soc_drv_remove, | 199 | .remove = ohci_hcd_ppc_soc_drv_remove, |
| 200 | .shutdown = usb_hcd_platform_shutdown, | ||
| 198 | #ifdef CONFIG_PM | 201 | #ifdef CONFIG_PM |
| 199 | /*.suspend = ohci_hcd_ppc_soc_drv_suspend,*/ | 202 | /*.suspend = ohci_hcd_ppc_soc_drv_suspend,*/ |
| 200 | /*.resume = ohci_hcd_ppc_soc_drv_resume,*/ | 203 | /*.resume = ohci_hcd_ppc_soc_drv_resume,*/ |
diff --git a/drivers/usb/host/ohci-pxa27x.c b/drivers/usb/host/ohci-pxa27x.c index 6f559e102789..e176b04d7aeb 100644 --- a/drivers/usb/host/ohci-pxa27x.c +++ b/drivers/usb/host/ohci-pxa27x.c | |||
| @@ -270,6 +270,7 @@ static const struct hc_driver ohci_pxa27x_hc_driver = { | |||
| 270 | */ | 270 | */ |
| 271 | .start = ohci_pxa27x_start, | 271 | .start = ohci_pxa27x_start, |
| 272 | .stop = ohci_stop, | 272 | .stop = ohci_stop, |
| 273 | .shutdown = ohci_shutdown, | ||
| 273 | 274 | ||
| 274 | /* | 275 | /* |
| 275 | * managing i/o requests and associated device resources | 276 | * managing i/o requests and associated device resources |
| @@ -288,6 +289,7 @@ static const struct hc_driver ohci_pxa27x_hc_driver = { | |||
| 288 | */ | 289 | */ |
| 289 | .hub_status_data = ohci_hub_status_data, | 290 | .hub_status_data = ohci_hub_status_data, |
| 290 | .hub_control = ohci_hub_control, | 291 | .hub_control = ohci_hub_control, |
| 292 | .hub_irq_enable = ohci_rhsc_enable, | ||
| 291 | #ifdef CONFIG_PM | 293 | #ifdef CONFIG_PM |
| 292 | .bus_suspend = ohci_bus_suspend, | 294 | .bus_suspend = ohci_bus_suspend, |
| 293 | .bus_resume = ohci_bus_resume, | 295 | .bus_resume = ohci_bus_resume, |
| @@ -357,6 +359,7 @@ static int ohci_hcd_pxa27x_drv_resume(struct platform_device *pdev) | |||
| 357 | static struct platform_driver ohci_hcd_pxa27x_driver = { | 359 | static struct platform_driver ohci_hcd_pxa27x_driver = { |
| 358 | .probe = ohci_hcd_pxa27x_drv_probe, | 360 | .probe = ohci_hcd_pxa27x_drv_probe, |
| 359 | .remove = ohci_hcd_pxa27x_drv_remove, | 361 | .remove = ohci_hcd_pxa27x_drv_remove, |
| 362 | .shutdown = usb_hcd_platform_shutdown, | ||
| 360 | #ifdef CONFIG_PM | 363 | #ifdef CONFIG_PM |
| 361 | .suspend = ohci_hcd_pxa27x_drv_suspend, | 364 | .suspend = ohci_hcd_pxa27x_drv_suspend, |
| 362 | .resume = ohci_hcd_pxa27x_drv_resume, | 365 | .resume = ohci_hcd_pxa27x_drv_resume, |
diff --git a/drivers/usb/host/ohci-s3c2410.c b/drivers/usb/host/ohci-s3c2410.c index d2fc6969a9f7..59e436424d41 100644 --- a/drivers/usb/host/ohci-s3c2410.c +++ b/drivers/usb/host/ohci-s3c2410.c | |||
| @@ -370,7 +370,7 @@ static int usb_hcd_s3c2410_probe (const struct hc_driver *driver, | |||
| 370 | goto err_mem; | 370 | goto err_mem; |
| 371 | } | 371 | } |
| 372 | 372 | ||
| 373 | usb_clk = clk_get(&dev->dev, "upll"); | 373 | usb_clk = clk_get(&dev->dev, "usb-bus-host"); |
| 374 | if (IS_ERR(usb_clk)) { | 374 | if (IS_ERR(usb_clk)) { |
| 375 | dev_err(&dev->dev, "cannot get usb-host clock\n"); | 375 | dev_err(&dev->dev, "cannot get usb-host clock\n"); |
| 376 | retval = -ENOENT; | 376 | retval = -ENOENT; |
| @@ -447,6 +447,7 @@ static const struct hc_driver ohci_s3c2410_hc_driver = { | |||
| 447 | */ | 447 | */ |
| 448 | .start = ohci_s3c2410_start, | 448 | .start = ohci_s3c2410_start, |
| 449 | .stop = ohci_stop, | 449 | .stop = ohci_stop, |
| 450 | .shutdown = ohci_shutdown, | ||
| 450 | 451 | ||
| 451 | /* | 452 | /* |
| 452 | * managing i/o requests and associated device resources | 453 | * managing i/o requests and associated device resources |
| @@ -465,6 +466,7 @@ static const struct hc_driver ohci_s3c2410_hc_driver = { | |||
| 465 | */ | 466 | */ |
| 466 | .hub_status_data = ohci_s3c2410_hub_status_data, | 467 | .hub_status_data = ohci_s3c2410_hub_status_data, |
| 467 | .hub_control = ohci_s3c2410_hub_control, | 468 | .hub_control = ohci_s3c2410_hub_control, |
| 469 | .hub_irq_enable = ohci_rhsc_enable, | ||
| 468 | #ifdef CONFIG_PM | 470 | #ifdef CONFIG_PM |
| 469 | .bus_suspend = ohci_bus_suspend, | 471 | .bus_suspend = ohci_bus_suspend, |
| 470 | .bus_resume = ohci_bus_resume, | 472 | .bus_resume = ohci_bus_resume, |
| @@ -490,6 +492,7 @@ static int ohci_hcd_s3c2410_drv_remove(struct platform_device *pdev) | |||
| 490 | static struct platform_driver ohci_hcd_s3c2410_driver = { | 492 | static struct platform_driver ohci_hcd_s3c2410_driver = { |
| 491 | .probe = ohci_hcd_s3c2410_drv_probe, | 493 | .probe = ohci_hcd_s3c2410_drv_probe, |
| 492 | .remove = ohci_hcd_s3c2410_drv_remove, | 494 | .remove = ohci_hcd_s3c2410_drv_remove, |
| 495 | .shutdown = usb_hcd_platform_shutdown, | ||
| 493 | /*.suspend = ohci_hcd_s3c2410_drv_suspend, */ | 496 | /*.suspend = ohci_hcd_s3c2410_drv_suspend, */ |
| 494 | /*.resume = ohci_hcd_s3c2410_drv_resume, */ | 497 | /*.resume = ohci_hcd_s3c2410_drv_resume, */ |
| 495 | .driver = { | 498 | .driver = { |
diff --git a/drivers/usb/host/ohci-sa1111.c b/drivers/usb/host/ohci-sa1111.c index ce3de106cadc..71371de32ada 100644 --- a/drivers/usb/host/ohci-sa1111.c +++ b/drivers/usb/host/ohci-sa1111.c | |||
| @@ -212,10 +212,6 @@ static const struct hc_driver ohci_sa1111_hc_driver = { | |||
| 212 | * basic lifecycle operations | 212 | * basic lifecycle operations |
| 213 | */ | 213 | */ |
| 214 | .start = ohci_sa1111_start, | 214 | .start = ohci_sa1111_start, |
| 215 | #ifdef CONFIG_PM | ||
| 216 | /* suspend: ohci_sa1111_suspend, -- tbd */ | ||
| 217 | /* resume: ohci_sa1111_resume, -- tbd */ | ||
| 218 | #endif | ||
| 219 | .stop = ohci_stop, | 215 | .stop = ohci_stop, |
| 220 | 216 | ||
| 221 | /* | 217 | /* |
| @@ -235,6 +231,7 @@ static const struct hc_driver ohci_sa1111_hc_driver = { | |||
| 235 | */ | 231 | */ |
| 236 | .hub_status_data = ohci_hub_status_data, | 232 | .hub_status_data = ohci_hub_status_data, |
| 237 | .hub_control = ohci_hub_control, | 233 | .hub_control = ohci_hub_control, |
| 234 | .hub_irq_enable = ohci_rhsc_enable, | ||
| 238 | #ifdef CONFIG_PM | 235 | #ifdef CONFIG_PM |
| 239 | .bus_suspend = ohci_bus_suspend, | 236 | .bus_suspend = ohci_bus_suspend, |
| 240 | .bus_resume = ohci_bus_resume, | 237 | .bus_resume = ohci_bus_resume, |
diff --git a/drivers/usb/host/ohci.h b/drivers/usb/host/ohci.h index caacf14371f5..93fdc3c35341 100644 --- a/drivers/usb/host/ohci.h +++ b/drivers/usb/host/ohci.h | |||
| @@ -159,7 +159,7 @@ static const int cc_to_error [16] = { | |||
| 159 | /* Bit Stuff */ -EPROTO, | 159 | /* Bit Stuff */ -EPROTO, |
| 160 | /* Data Togg */ -EILSEQ, | 160 | /* Data Togg */ -EILSEQ, |
| 161 | /* Stall */ -EPIPE, | 161 | /* Stall */ -EPIPE, |
| 162 | /* DevNotResp */ -ETIMEDOUT, | 162 | /* DevNotResp */ -ETIME, |
| 163 | /* PIDCheck */ -EPROTO, | 163 | /* PIDCheck */ -EPROTO, |
| 164 | /* UnExpPID */ -EPROTO, | 164 | /* UnExpPID */ -EPROTO, |
| 165 | /* DataOver */ -EOVERFLOW, | 165 | /* DataOver */ -EOVERFLOW, |
| @@ -389,8 +389,6 @@ struct ohci_hcd { | |||
| 389 | unsigned long next_statechange; /* suspend/resume */ | 389 | unsigned long next_statechange; /* suspend/resume */ |
| 390 | u32 fminterval; /* saved register */ | 390 | u32 fminterval; /* saved register */ |
| 391 | 391 | ||
| 392 | struct notifier_block reboot_notifier; | ||
| 393 | |||
| 394 | unsigned long flags; /* for HC bugs */ | 392 | unsigned long flags; /* for HC bugs */ |
| 395 | #define OHCI_QUIRK_AMD756 0x01 /* erratum #4 */ | 393 | #define OHCI_QUIRK_AMD756 0x01 /* erratum #4 */ |
| 396 | #define OHCI_QUIRK_SUPERIO 0x02 /* natsemi */ | 394 | #define OHCI_QUIRK_SUPERIO 0x02 /* natsemi */ |
diff --git a/drivers/usb/host/sl811-hcd.c b/drivers/usb/host/sl811-hcd.c index fa34092bbcde..3a586aab3939 100644 --- a/drivers/usb/host/sl811-hcd.c +++ b/drivers/usb/host/sl811-hcd.c | |||
| @@ -597,7 +597,7 @@ done(struct sl811 *sl811, struct sl811h_ep *ep, u8 bank, struct pt_regs *regs) | |||
| 597 | /* error? retry, until "3 strikes" */ | 597 | /* error? retry, until "3 strikes" */ |
| 598 | } else if (++ep->error_count >= 3) { | 598 | } else if (++ep->error_count >= 3) { |
| 599 | if (status & SL11H_STATMASK_TMOUT) | 599 | if (status & SL11H_STATMASK_TMOUT) |
| 600 | urbstat = -ETIMEDOUT; | 600 | urbstat = -ETIME; |
| 601 | else if (status & SL11H_STATMASK_OVF) | 601 | else if (status & SL11H_STATMASK_OVF) |
| 602 | urbstat = -EOVERFLOW; | 602 | urbstat = -EOVERFLOW; |
| 603 | else | 603 | else |
| @@ -1517,7 +1517,7 @@ static int proc_sl811h_open(struct inode *inode, struct file *file) | |||
| 1517 | return single_open(file, proc_sl811h_show, PDE(inode)->data); | 1517 | return single_open(file, proc_sl811h_show, PDE(inode)->data); |
| 1518 | } | 1518 | } |
| 1519 | 1519 | ||
| 1520 | static struct file_operations proc_ops = { | 1520 | static const struct file_operations proc_ops = { |
| 1521 | .open = proc_sl811h_open, | 1521 | .open = proc_sl811h_open, |
| 1522 | .read = seq_read, | 1522 | .read = seq_read, |
| 1523 | .llseek = seq_lseek, | 1523 | .llseek = seq_lseek, |
| @@ -1783,10 +1783,15 @@ sl811h_suspend(struct platform_device *dev, pm_message_t state) | |||
| 1783 | struct sl811 *sl811 = hcd_to_sl811(hcd); | 1783 | struct sl811 *sl811 = hcd_to_sl811(hcd); |
| 1784 | int retval = 0; | 1784 | int retval = 0; |
| 1785 | 1785 | ||
| 1786 | if (state.event == PM_EVENT_FREEZE) | 1786 | switch (state.event) { |
| 1787 | case PM_EVENT_FREEZE: | ||
| 1787 | retval = sl811h_bus_suspend(hcd); | 1788 | retval = sl811h_bus_suspend(hcd); |
| 1788 | else if (state.event == PM_EVENT_SUSPEND) | 1789 | break; |
| 1790 | case PM_EVENT_SUSPEND: | ||
| 1791 | case PM_EVENT_PRETHAW: /* explicitly discard hw state */ | ||
| 1789 | port_power(sl811, 0); | 1792 | port_power(sl811, 0); |
| 1793 | break; | ||
| 1794 | } | ||
| 1790 | if (retval == 0) | 1795 | if (retval == 0) |
| 1791 | dev->dev.power.power_state = state; | 1796 | dev->dev.power.power_state = state; |
| 1792 | return retval; | 1797 | return retval; |
diff --git a/drivers/usb/host/u132-hcd.c b/drivers/usb/host/u132-hcd.c new file mode 100644 index 000000000000..cb2e2a604d1b --- /dev/null +++ b/drivers/usb/host/u132-hcd.c | |||
| @@ -0,0 +1,3295 @@ | |||
| 1 | /* | ||
| 2 | * Host Controller Driver for the Elan Digital Systems U132 adapter | ||
| 3 | * | ||
| 4 | * Copyright(C) 2006 Elan Digital Systems Limited | ||
| 5 | * http://www.elandigitalsystems.com | ||
| 6 | * | ||
| 7 | * Author and Maintainer - Tony Olech - Elan Digital Systems | ||
| 8 | * tony.olech@elandigitalsystems.com | ||
| 9 | * | ||
| 10 | * This program is free software;you can redistribute it and/or | ||
| 11 | * modify it under the terms of the GNU General Public License as | ||
| 12 | * published by the Free Software Foundation, version 2. | ||
| 13 | * | ||
| 14 | * | ||
| 15 | * This driver was written by Tony Olech(tony.olech@elandigitalsystems.com) | ||
| 16 | * based on various USB host drivers in the 2.6.15 linux kernel | ||
| 17 | * with constant reference to the 3rd Edition of Linux Device Drivers | ||
| 18 | * published by O'Reilly | ||
| 19 | * | ||
| 20 | * The U132 adapter is a USB to CardBus adapter specifically designed | ||
| 21 | * for PC cards that contain an OHCI host controller. Typical PC cards | ||
| 22 | * are the Orange Mobile 3G Option GlobeTrotter Fusion card. | ||
| 23 | * | ||
| 24 | * The U132 adapter will *NOT *work with PC cards that do not contain | ||
| 25 | * an OHCI controller. A simple way to test whether a PC card has an | ||
| 26 | * OHCI controller as an interface is to insert the PC card directly | ||
| 27 | * into a laptop(or desktop) with a CardBus slot and if "lspci" shows | ||
| 28 | * a new USB controller and "lsusb -v" shows a new OHCI Host Controller | ||
| 29 | * then there is a good chance that the U132 adapter will support the | ||
| 30 | * PC card.(you also need the specific client driver for the PC card) | ||
| 31 | * | ||
| 32 | * Please inform the Author and Maintainer about any PC cards that | ||
| 33 | * contain OHCI Host Controller and work when directly connected to | ||
| 34 | * an embedded CardBus slot but do not work when they are connected | ||
| 35 | * via an ELAN U132 adapter. | ||
| 36 | * | ||
| 37 | */ | ||
| 38 | #include <linux/config.h> | ||
| 39 | #include <linux/kernel.h> | ||
| 40 | #include <linux/module.h> | ||
| 41 | #include <linux/moduleparam.h> | ||
| 42 | #include <linux/delay.h> | ||
| 43 | #include <linux/ioport.h> | ||
| 44 | #include <linux/sched.h> | ||
| 45 | #include <linux/slab.h> | ||
| 46 | #include <linux/smp_lock.h> | ||
| 47 | #include <linux/errno.h> | ||
| 48 | #include <linux/init.h> | ||
| 49 | #include <linux/timer.h> | ||
| 50 | #include <linux/list.h> | ||
| 51 | #include <linux/interrupt.h> | ||
| 52 | #include <linux/usb.h> | ||
| 53 | #include <linux/workqueue.h> | ||
| 54 | #include <linux/platform_device.h> | ||
| 55 | #include <linux/pci_ids.h> | ||
| 56 | #include <asm/io.h> | ||
| 57 | #include <asm/irq.h> | ||
| 58 | #include <asm/system.h> | ||
| 59 | #include <asm/byteorder.h> | ||
| 60 | #include "../core/hcd.h" | ||
| 61 | #include "ohci.h" | ||
| 62 | #define OHCI_CONTROL_INIT OHCI_CTRL_CBSR | ||
| 63 | #define OHCI_INTR_INIT (OHCI_INTR_MIE | OHCI_INTR_UE | OHCI_INTR_RD | \ | ||
| 64 | OHCI_INTR_WDH) | ||
| 65 | MODULE_AUTHOR("Tony Olech - Elan Digital Systems Limited"); | ||
| 66 | MODULE_DESCRIPTION("U132 USB Host Controller Driver"); | ||
| 67 | MODULE_LICENSE("GPL"); | ||
| 68 | #define INT_MODULE_PARM(n, v) static int n = v;module_param(n, int, 0444) | ||
| 69 | INT_MODULE_PARM(testing, 0); | ||
| 70 | /* Some boards misreport power switching/overcurrent*/ | ||
| 71 | static int distrust_firmware = 1; | ||
| 72 | module_param(distrust_firmware, bool, 0); | ||
| 73 | MODULE_PARM_DESC(distrust_firmware, "true to distrust firmware power/overcurren" | ||
| 74 | "t setup"); | ||
| 75 | DECLARE_WAIT_QUEUE_HEAD(u132_hcd_wait); | ||
| 76 | /* | ||
| 77 | * u132_module_lock exists to protect access to global variables | ||
| 78 | * | ||
| 79 | */ | ||
| 80 | static struct semaphore u132_module_lock; | ||
| 81 | static int u132_exiting = 0; | ||
| 82 | static int u132_instances = 0; | ||
| 83 | static struct list_head u132_static_list; | ||
| 84 | /* | ||
| 85 | * end of the global variables protected by u132_module_lock | ||
| 86 | */ | ||
| 87 | static struct workqueue_struct *workqueue; | ||
| 88 | #define MAX_U132_PORTS 7 | ||
| 89 | #define MAX_U132_ADDRS 128 | ||
| 90 | #define MAX_U132_UDEVS 4 | ||
| 91 | #define MAX_U132_ENDPS 100 | ||
| 92 | #define MAX_U132_RINGS 4 | ||
| 93 | static const char *cc_to_text[16] = { | ||
| 94 | "No Error ", | ||
| 95 | "CRC Error ", | ||
| 96 | "Bit Stuff ", | ||
| 97 | "Data Togg ", | ||
| 98 | "Stall ", | ||
| 99 | "DevNotResp ", | ||
| 100 | "PIDCheck ", | ||
| 101 | "UnExpPID ", | ||
| 102 | "DataOver ", | ||
| 103 | "DataUnder ", | ||
| 104 | "(for hw) ", | ||
| 105 | "(for hw) ", | ||
| 106 | "BufferOver ", | ||
| 107 | "BuffUnder ", | ||
| 108 | "(for HCD) ", | ||
| 109 | "(for HCD) " | ||
| 110 | }; | ||
| 111 | struct u132_port { | ||
| 112 | struct u132 *u132; | ||
| 113 | int reset; | ||
| 114 | int enable; | ||
| 115 | int power; | ||
| 116 | int Status; | ||
| 117 | }; | ||
| 118 | struct u132_addr { | ||
| 119 | u8 address; | ||
| 120 | }; | ||
| 121 | struct u132_udev { | ||
| 122 | struct kref kref; | ||
| 123 | struct usb_device *usb_device; | ||
| 124 | u8 enumeration; | ||
| 125 | u8 udev_number; | ||
| 126 | u8 usb_addr; | ||
| 127 | u8 portnumber; | ||
| 128 | u8 endp_number_in[16]; | ||
| 129 | u8 endp_number_out[16]; | ||
| 130 | }; | ||
| 131 | #define ENDP_QUEUE_SHIFT 3 | ||
| 132 | #define ENDP_QUEUE_SIZE (1<<ENDP_QUEUE_SHIFT) | ||
| 133 | #define ENDP_QUEUE_MASK (ENDP_QUEUE_SIZE-1) | ||
| 134 | struct u132_urbq { | ||
| 135 | struct list_head urb_more; | ||
| 136 | struct urb *urb; | ||
| 137 | }; | ||
| 138 | struct u132_spin { | ||
| 139 | spinlock_t slock; | ||
| 140 | }; | ||
| 141 | struct u132_endp { | ||
| 142 | struct kref kref; | ||
| 143 | u8 udev_number; | ||
| 144 | u8 endp_number; | ||
| 145 | u8 usb_addr; | ||
| 146 | u8 usb_endp; | ||
| 147 | struct u132 *u132; | ||
| 148 | struct list_head endp_ring; | ||
| 149 | struct u132_ring *ring; | ||
| 150 | unsigned toggle_bits:2; | ||
| 151 | unsigned active:1; | ||
| 152 | unsigned delayed:1; | ||
| 153 | unsigned input:1; | ||
| 154 | unsigned output:1; | ||
| 155 | unsigned pipetype:2; | ||
| 156 | unsigned dequeueing:1; | ||
| 157 | unsigned edset_flush:1; | ||
| 158 | unsigned spare_bits:14; | ||
| 159 | unsigned long jiffies; | ||
| 160 | struct usb_host_endpoint *hep; | ||
| 161 | struct u132_spin queue_lock; | ||
| 162 | u16 queue_size; | ||
| 163 | u16 queue_last; | ||
| 164 | u16 queue_next; | ||
| 165 | struct urb *urb_list[ENDP_QUEUE_SIZE]; | ||
| 166 | struct list_head urb_more; | ||
| 167 | struct work_struct scheduler; | ||
| 168 | }; | ||
| 169 | struct u132_ring { | ||
| 170 | unsigned in_use:1; | ||
| 171 | unsigned length:7; | ||
| 172 | u8 number; | ||
| 173 | struct u132 *u132; | ||
| 174 | struct u132_endp *curr_endp; | ||
| 175 | struct work_struct scheduler; | ||
| 176 | }; | ||
| 177 | #define OHCI_QUIRK_AMD756 0x01 | ||
| 178 | #define OHCI_QUIRK_SUPERIO 0x02 | ||
| 179 | #define OHCI_QUIRK_INITRESET 0x04 | ||
| 180 | #define OHCI_BIG_ENDIAN 0x08 | ||
| 181 | #define OHCI_QUIRK_ZFMICRO 0x10 | ||
| 182 | struct u132 { | ||
| 183 | struct kref kref; | ||
| 184 | struct list_head u132_list; | ||
| 185 | struct semaphore sw_lock; | ||
| 186 | struct semaphore scheduler_lock; | ||
| 187 | struct u132_platform_data *board; | ||
| 188 | struct platform_device *platform_dev; | ||
| 189 | struct u132_ring ring[MAX_U132_RINGS]; | ||
| 190 | int sequence_num; | ||
| 191 | int going; | ||
| 192 | int power; | ||
| 193 | int reset; | ||
| 194 | int num_ports; | ||
| 195 | u32 hc_control; | ||
| 196 | u32 hc_fminterval; | ||
| 197 | u32 hc_roothub_status; | ||
| 198 | u32 hc_roothub_a; | ||
| 199 | u32 hc_roothub_portstatus[MAX_ROOT_PORTS]; | ||
| 200 | int flags; | ||
| 201 | unsigned long next_statechange; | ||
| 202 | struct work_struct monitor; | ||
| 203 | int num_endpoints; | ||
| 204 | struct u132_addr addr[MAX_U132_ADDRS]; | ||
| 205 | struct u132_udev udev[MAX_U132_UDEVS]; | ||
| 206 | struct u132_port port[MAX_U132_PORTS]; | ||
| 207 | struct u132_endp *endp[MAX_U132_ENDPS]; | ||
| 208 | }; | ||
| 209 | int usb_ftdi_elan_read_reg(struct platform_device *pdev, u32 *data); | ||
| 210 | int usb_ftdi_elan_read_pcimem(struct platform_device *pdev, u8 addressofs, | ||
| 211 | u8 width, u32 *data); | ||
| 212 | int usb_ftdi_elan_write_pcimem(struct platform_device *pdev, u8 addressofs, | ||
| 213 | u8 width, u32 data); | ||
| 214 | /* | ||
| 215 | * these can not be inlines because we need the structure offset!! | ||
| 216 | * Does anyone have a better way????? | ||
| 217 | */ | ||
| 218 | #define u132_read_pcimem(u132, member, data) \ | ||
| 219 | usb_ftdi_elan_read_pcimem(u132->platform_dev, offsetof(struct \ | ||
| 220 | ohci_regs, member), 0, data); | ||
| 221 | #define u132_write_pcimem(u132, member, data) \ | ||
| 222 | usb_ftdi_elan_write_pcimem(u132->platform_dev, offsetof(struct \ | ||
| 223 | ohci_regs, member), 0, data); | ||
| 224 | #define u132_write_pcimem_byte(u132, member, data) \ | ||
| 225 | usb_ftdi_elan_write_pcimem(u132->platform_dev, offsetof(struct \ | ||
| 226 | ohci_regs, member), 0x0e, data); | ||
| 227 | static inline struct u132 *udev_to_u132(struct u132_udev *udev) | ||
| 228 | { | ||
| 229 | u8 udev_number = udev->udev_number; | ||
| 230 | return container_of(udev, struct u132, udev[udev_number]); | ||
| 231 | } | ||
| 232 | |||
| 233 | static inline struct u132 *hcd_to_u132(struct usb_hcd *hcd) | ||
| 234 | { | ||
| 235 | return (struct u132 *)(hcd->hcd_priv); | ||
| 236 | } | ||
| 237 | |||
| 238 | static inline struct usb_hcd *u132_to_hcd(struct u132 *u132) | ||
| 239 | { | ||
| 240 | return container_of((void *)u132, struct usb_hcd, hcd_priv); | ||
| 241 | } | ||
| 242 | |||
| 243 | static inline void u132_disable(struct u132 *u132) | ||
| 244 | { | ||
| 245 | u132_to_hcd(u132)->state = HC_STATE_HALT; | ||
| 246 | } | ||
| 247 | |||
| 248 | |||
| 249 | #define kref_to_u132(d) container_of(d, struct u132, kref) | ||
| 250 | #define kref_to_u132_endp(d) container_of(d, struct u132_endp, kref) | ||
| 251 | #define kref_to_u132_udev(d) container_of(d, struct u132_udev, kref) | ||
| 252 | #include "../misc/usb_u132.h" | ||
| 253 | static const char hcd_name[] = "u132_hcd"; | ||
| 254 | #define PORT_C_MASK ((USB_PORT_STAT_C_CONNECTION | USB_PORT_STAT_C_ENABLE | \ | ||
| 255 | USB_PORT_STAT_C_SUSPEND | USB_PORT_STAT_C_OVERCURRENT | \ | ||
| 256 | USB_PORT_STAT_C_RESET) << 16) | ||
| 257 | static void u132_hcd_delete(struct kref *kref) | ||
| 258 | { | ||
| 259 | struct u132 *u132 = kref_to_u132(kref); | ||
| 260 | struct platform_device *pdev = u132->platform_dev; | ||
| 261 | struct usb_hcd *hcd = u132_to_hcd(u132); | ||
| 262 | u132->going += 1; | ||
| 263 | down(&u132_module_lock); | ||
| 264 | list_del_init(&u132->u132_list); | ||
| 265 | u132_instances -= 1; | ||
| 266 | up(&u132_module_lock); | ||
| 267 | dev_warn(&u132->platform_dev->dev, "FREEING the hcd=%p and thus the u13" | ||
| 268 | "2=%p going=%d pdev=%p\n", hcd, u132, u132->going, pdev); | ||
| 269 | usb_put_hcd(hcd); | ||
| 270 | } | ||
| 271 | |||
| 272 | static inline void u132_u132_put_kref(struct u132 *u132) | ||
| 273 | { | ||
| 274 | kref_put(&u132->kref, u132_hcd_delete); | ||
| 275 | } | ||
| 276 | |||
| 277 | static inline void u132_u132_init_kref(struct u132 *u132) | ||
| 278 | { | ||
| 279 | kref_init(&u132->kref); | ||
| 280 | } | ||
| 281 | |||
| 282 | static void u132_udev_delete(struct kref *kref) | ||
| 283 | { | ||
| 284 | struct u132_udev *udev = kref_to_u132_udev(kref); | ||
| 285 | udev->udev_number = 0; | ||
| 286 | udev->usb_device = NULL; | ||
| 287 | udev->usb_addr = 0; | ||
| 288 | udev->enumeration = 0; | ||
| 289 | } | ||
| 290 | |||
| 291 | static inline void u132_udev_put_kref(struct u132 *u132, struct u132_udev *udev) | ||
| 292 | { | ||
| 293 | kref_put(&udev->kref, u132_udev_delete); | ||
| 294 | } | ||
| 295 | |||
| 296 | static inline void u132_udev_get_kref(struct u132 *u132, struct u132_udev *udev) | ||
| 297 | { | ||
| 298 | kref_get(&udev->kref); | ||
| 299 | } | ||
| 300 | |||
| 301 | static inline void u132_udev_init_kref(struct u132 *u132, | ||
| 302 | struct u132_udev *udev) | ||
| 303 | { | ||
| 304 | kref_init(&udev->kref); | ||
| 305 | } | ||
| 306 | |||
| 307 | static inline void u132_ring_put_kref(struct u132 *u132, struct u132_ring *ring) | ||
| 308 | { | ||
| 309 | kref_put(&u132->kref, u132_hcd_delete); | ||
| 310 | } | ||
| 311 | |||
| 312 | static void u132_ring_requeue_work(struct u132 *u132, struct u132_ring *ring, | ||
| 313 | unsigned int delta) | ||
| 314 | { | ||
| 315 | if (delta > 0) { | ||
| 316 | if (queue_delayed_work(workqueue, &ring->scheduler, delta)) | ||
| 317 | return; | ||
| 318 | } else if (queue_work(workqueue, &ring->scheduler)) | ||
| 319 | return; | ||
| 320 | kref_put(&u132->kref, u132_hcd_delete); | ||
| 321 | return; | ||
| 322 | } | ||
| 323 | |||
| 324 | static void u132_ring_queue_work(struct u132 *u132, struct u132_ring *ring, | ||
| 325 | unsigned int delta) | ||
| 326 | { | ||
| 327 | kref_get(&u132->kref); | ||
| 328 | u132_ring_requeue_work(u132, ring, delta); | ||
| 329 | return; | ||
| 330 | } | ||
| 331 | |||
| 332 | static void u132_ring_cancel_work(struct u132 *u132, struct u132_ring *ring) | ||
| 333 | { | ||
| 334 | if (cancel_delayed_work(&ring->scheduler)) { | ||
| 335 | kref_put(&u132->kref, u132_hcd_delete); | ||
| 336 | } | ||
| 337 | } | ||
| 338 | |||
| 339 | static void u132_endp_delete(struct kref *kref) | ||
| 340 | { | ||
| 341 | struct u132_endp *endp = kref_to_u132_endp(kref); | ||
| 342 | struct u132 *u132 = endp->u132; | ||
| 343 | u8 usb_addr = endp->usb_addr; | ||
| 344 | u8 usb_endp = endp->usb_endp; | ||
| 345 | u8 address = u132->addr[usb_addr].address; | ||
| 346 | struct u132_udev *udev = &u132->udev[address]; | ||
| 347 | u8 endp_number = endp->endp_number; | ||
| 348 | struct usb_host_endpoint *hep = endp->hep; | ||
| 349 | struct u132_ring *ring = endp->ring; | ||
| 350 | struct list_head *head = &endp->endp_ring; | ||
| 351 | ring->length -= 1; | ||
| 352 | if (endp == ring->curr_endp) { | ||
| 353 | if (list_empty(head)) { | ||
| 354 | ring->curr_endp = NULL; | ||
| 355 | list_del(head); | ||
| 356 | } else { | ||
| 357 | struct u132_endp *next_endp = list_entry(head->next, | ||
| 358 | struct u132_endp, endp_ring); | ||
| 359 | ring->curr_endp = next_endp; | ||
| 360 | list_del(head); | ||
| 361 | }} else | ||
| 362 | list_del(head); | ||
| 363 | if (endp->input) { | ||
| 364 | udev->endp_number_in[usb_endp] = 0; | ||
| 365 | u132_udev_put_kref(u132, udev); | ||
| 366 | } | ||
| 367 | if (endp->output) { | ||
| 368 | udev->endp_number_out[usb_endp] = 0; | ||
| 369 | u132_udev_put_kref(u132, udev); | ||
| 370 | } | ||
| 371 | u132->endp[endp_number - 1] = NULL; | ||
| 372 | hep->hcpriv = NULL; | ||
| 373 | kfree(endp); | ||
| 374 | u132_u132_put_kref(u132); | ||
| 375 | } | ||
| 376 | |||
| 377 | static inline void u132_endp_put_kref(struct u132 *u132, struct u132_endp *endp) | ||
| 378 | { | ||
| 379 | kref_put(&endp->kref, u132_endp_delete); | ||
| 380 | } | ||
| 381 | |||
| 382 | static inline void u132_endp_get_kref(struct u132 *u132, struct u132_endp *endp) | ||
| 383 | { | ||
| 384 | kref_get(&endp->kref); | ||
| 385 | } | ||
| 386 | |||
| 387 | static inline void u132_endp_init_kref(struct u132 *u132, | ||
| 388 | struct u132_endp *endp) | ||
| 389 | { | ||
| 390 | kref_init(&endp->kref); | ||
| 391 | kref_get(&u132->kref); | ||
| 392 | } | ||
| 393 | |||
| 394 | static void u132_endp_queue_work(struct u132 *u132, struct u132_endp *endp, | ||
| 395 | unsigned int delta) | ||
| 396 | { | ||
| 397 | if (delta > 0) { | ||
| 398 | if (queue_delayed_work(workqueue, &endp->scheduler, delta)) | ||
| 399 | kref_get(&endp->kref); | ||
| 400 | } else if (queue_work(workqueue, &endp->scheduler)) | ||
| 401 | kref_get(&endp->kref); | ||
| 402 | return; | ||
| 403 | } | ||
| 404 | |||
| 405 | static void u132_endp_cancel_work(struct u132 *u132, struct u132_endp *endp) | ||
| 406 | { | ||
| 407 | if (cancel_delayed_work(&endp->scheduler)) | ||
| 408 | kref_put(&endp->kref, u132_endp_delete); | ||
| 409 | } | ||
| 410 | |||
| 411 | static inline void u132_monitor_put_kref(struct u132 *u132) | ||
| 412 | { | ||
| 413 | kref_put(&u132->kref, u132_hcd_delete); | ||
| 414 | } | ||
| 415 | |||
| 416 | static void u132_monitor_queue_work(struct u132 *u132, unsigned int delta) | ||
| 417 | { | ||
| 418 | if (delta > 0) { | ||
| 419 | if (queue_delayed_work(workqueue, &u132->monitor, delta)) { | ||
| 420 | kref_get(&u132->kref); | ||
| 421 | } | ||
| 422 | } else if (queue_work(workqueue, &u132->monitor)) | ||
| 423 | kref_get(&u132->kref); | ||
| 424 | return; | ||
| 425 | } | ||
| 426 | |||
| 427 | static void u132_monitor_requeue_work(struct u132 *u132, unsigned int delta) | ||
| 428 | { | ||
| 429 | if (delta > 0) { | ||
| 430 | if (queue_delayed_work(workqueue, &u132->monitor, delta)) | ||
| 431 | return; | ||
| 432 | } else if (queue_work(workqueue, &u132->monitor)) | ||
| 433 | return; | ||
| 434 | kref_put(&u132->kref, u132_hcd_delete); | ||
| 435 | return; | ||
| 436 | } | ||
| 437 | |||
| 438 | static void u132_monitor_cancel_work(struct u132 *u132) | ||
| 439 | { | ||
| 440 | if (cancel_delayed_work(&u132->monitor)) | ||
| 441 | kref_put(&u132->kref, u132_hcd_delete); | ||
| 442 | } | ||
| 443 | |||
| 444 | static int read_roothub_info(struct u132 *u132) | ||
| 445 | { | ||
| 446 | u32 revision; | ||
| 447 | int retval; | ||
| 448 | retval = u132_read_pcimem(u132, revision, &revision); | ||
| 449 | if (retval) { | ||
| 450 | dev_err(&u132->platform_dev->dev, "error %d accessing device co" | ||
| 451 | "ntrol\n", retval); | ||
| 452 | return retval; | ||
| 453 | } else if ((revision & 0xFF) == 0x10) { | ||
| 454 | } else if ((revision & 0xFF) == 0x11) { | ||
| 455 | } else { | ||
| 456 | dev_err(&u132->platform_dev->dev, "device revision is not valid" | ||
| 457 | " %08X\n", revision); | ||
| 458 | return -ENODEV; | ||
| 459 | } | ||
| 460 | retval = u132_read_pcimem(u132, control, &u132->hc_control); | ||
| 461 | if (retval) { | ||
| 462 | dev_err(&u132->platform_dev->dev, "error %d accessing device co" | ||
| 463 | "ntrol\n", retval); | ||
| 464 | return retval; | ||
| 465 | } | ||
| 466 | retval = u132_read_pcimem(u132, roothub.status, | ||
| 467 | &u132->hc_roothub_status); | ||
| 468 | if (retval) { | ||
| 469 | dev_err(&u132->platform_dev->dev, "error %d accessing device re" | ||
| 470 | "g roothub.status\n", retval); | ||
| 471 | return retval; | ||
| 472 | } | ||
| 473 | retval = u132_read_pcimem(u132, roothub.a, &u132->hc_roothub_a); | ||
| 474 | if (retval) { | ||
| 475 | dev_err(&u132->platform_dev->dev, "error %d accessing device re" | ||
| 476 | "g roothub.a\n", retval); | ||
| 477 | return retval; | ||
| 478 | } | ||
| 479 | { | ||
| 480 | int I = u132->num_ports; | ||
| 481 | int i = 0; | ||
| 482 | while (I-- > 0) { | ||
| 483 | retval = u132_read_pcimem(u132, roothub.portstatus[i], | ||
| 484 | &u132->hc_roothub_portstatus[i]); | ||
| 485 | if (retval) { | ||
| 486 | dev_err(&u132->platform_dev->dev, "error %d acc" | ||
| 487 | "essing device roothub.portstatus[%d]\n" | ||
| 488 | , retval, i); | ||
| 489 | return retval; | ||
| 490 | } else | ||
| 491 | i += 1; | ||
| 492 | } | ||
| 493 | } | ||
| 494 | return 0; | ||
| 495 | } | ||
| 496 | |||
| 497 | static void u132_hcd_monitor_work(void *data) | ||
| 498 | { | ||
| 499 | struct u132 *u132 = data; | ||
| 500 | if (u132->going > 1) { | ||
| 501 | dev_err(&u132->platform_dev->dev, "device has been removed %d\n" | ||
| 502 | , u132->going); | ||
| 503 | u132_monitor_put_kref(u132); | ||
| 504 | return; | ||
| 505 | } else if (u132->going > 0) { | ||
| 506 | dev_err(&u132->platform_dev->dev, "device is being removed\n"); | ||
| 507 | u132_monitor_put_kref(u132); | ||
| 508 | return; | ||
| 509 | } else { | ||
| 510 | int retval; | ||
| 511 | down(&u132->sw_lock); | ||
| 512 | retval = read_roothub_info(u132); | ||
| 513 | if (retval) { | ||
| 514 | struct usb_hcd *hcd = u132_to_hcd(u132); | ||
| 515 | u132_disable(u132); | ||
| 516 | u132->going = 1; | ||
| 517 | up(&u132->sw_lock); | ||
| 518 | usb_hc_died(hcd); | ||
| 519 | ftdi_elan_gone_away(u132->platform_dev); | ||
| 520 | u132_monitor_put_kref(u132); | ||
| 521 | return; | ||
| 522 | } else { | ||
| 523 | u132_monitor_requeue_work(u132, 500); | ||
| 524 | up(&u132->sw_lock); | ||
| 525 | return; | ||
| 526 | } | ||
| 527 | } | ||
| 528 | } | ||
| 529 | |||
| 530 | static void u132_hcd_giveback_urb(struct u132 *u132, struct u132_endp *endp, | ||
| 531 | struct urb *urb, int status) | ||
| 532 | { | ||
| 533 | struct u132_ring *ring; | ||
| 534 | unsigned long irqs; | ||
| 535 | struct usb_hcd *hcd = u132_to_hcd(u132); | ||
| 536 | urb->error_count = 0; | ||
| 537 | urb->status = status; | ||
| 538 | urb->hcpriv = NULL; | ||
| 539 | spin_lock_irqsave(&endp->queue_lock.slock, irqs); | ||
| 540 | endp->queue_next += 1; | ||
| 541 | if (ENDP_QUEUE_SIZE > --endp->queue_size) { | ||
| 542 | endp->active = 0; | ||
| 543 | spin_unlock_irqrestore(&endp->queue_lock.slock, irqs); | ||
| 544 | } else { | ||
| 545 | struct list_head *next = endp->urb_more.next; | ||
| 546 | struct u132_urbq *urbq = list_entry(next, struct u132_urbq, | ||
| 547 | urb_more); | ||
| 548 | list_del(next); | ||
| 549 | endp->urb_list[ENDP_QUEUE_MASK & endp->queue_last++] = | ||
| 550 | urbq->urb; | ||
| 551 | endp->active = 0; | ||
| 552 | spin_unlock_irqrestore(&endp->queue_lock.slock, irqs); | ||
| 553 | kfree(urbq); | ||
| 554 | } down(&u132->scheduler_lock); | ||
| 555 | ring = endp->ring; | ||
| 556 | ring->in_use = 0; | ||
| 557 | u132_ring_cancel_work(u132, ring); | ||
| 558 | u132_ring_queue_work(u132, ring, 0); | ||
| 559 | up(&u132->scheduler_lock); | ||
| 560 | u132_endp_put_kref(u132, endp); | ||
| 561 | usb_hcd_giveback_urb(hcd, urb, NULL); | ||
| 562 | return; | ||
| 563 | } | ||
| 564 | |||
| 565 | static void u132_hcd_forget_urb(struct u132 *u132, struct u132_endp *endp, | ||
| 566 | struct urb *urb, int status) | ||
| 567 | { | ||
| 568 | u132_endp_put_kref(u132, endp); | ||
| 569 | } | ||
| 570 | |||
| 571 | static void u132_hcd_abandon_urb(struct u132 *u132, struct u132_endp *endp, | ||
| 572 | struct urb *urb, int status) | ||
| 573 | { | ||
| 574 | unsigned long irqs; | ||
| 575 | struct usb_hcd *hcd = u132_to_hcd(u132); | ||
| 576 | urb->error_count = 0; | ||
| 577 | urb->status = status; | ||
| 578 | urb->hcpriv = NULL; | ||
| 579 | spin_lock_irqsave(&endp->queue_lock.slock, irqs); | ||
| 580 | endp->queue_next += 1; | ||
| 581 | if (ENDP_QUEUE_SIZE > --endp->queue_size) { | ||
| 582 | endp->active = 0; | ||
| 583 | spin_unlock_irqrestore(&endp->queue_lock.slock, irqs); | ||
| 584 | } else { | ||
| 585 | struct list_head *next = endp->urb_more.next; | ||
| 586 | struct u132_urbq *urbq = list_entry(next, struct u132_urbq, | ||
| 587 | urb_more); | ||
| 588 | list_del(next); | ||
| 589 | endp->urb_list[ENDP_QUEUE_MASK & endp->queue_last++] = | ||
| 590 | urbq->urb; | ||
| 591 | endp->active = 0; | ||
| 592 | spin_unlock_irqrestore(&endp->queue_lock.slock, irqs); | ||
| 593 | kfree(urbq); | ||
| 594 | } usb_hcd_giveback_urb(hcd, urb, NULL); | ||
| 595 | return; | ||
| 596 | } | ||
| 597 | |||
| 598 | static inline int edset_input(struct u132 *u132, struct u132_ring *ring, | ||
| 599 | struct u132_endp *endp, struct urb *urb, u8 address, u8 toggle_bits, | ||
| 600 | void (*callback) (void *endp, struct urb *urb, u8 *buf, int len, | ||
| 601 | int toggle_bits, int error_count, int condition_code, int repeat_number, | ||
| 602 | int halted, int skipped, int actual, int non_null)) | ||
| 603 | { | ||
| 604 | return usb_ftdi_elan_edset_input(u132->platform_dev, ring->number, endp, | ||
| 605 | urb, address, endp->usb_endp, toggle_bits, callback); | ||
| 606 | } | ||
| 607 | |||
| 608 | static inline int edset_setup(struct u132 *u132, struct u132_ring *ring, | ||
| 609 | struct u132_endp *endp, struct urb *urb, u8 address, u8 toggle_bits, | ||
| 610 | void (*callback) (void *endp, struct urb *urb, u8 *buf, int len, | ||
| 611 | int toggle_bits, int error_count, int condition_code, int repeat_number, | ||
| 612 | int halted, int skipped, int actual, int non_null)) | ||
| 613 | { | ||
| 614 | return usb_ftdi_elan_edset_setup(u132->platform_dev, ring->number, endp, | ||
| 615 | urb, address, endp->usb_endp, toggle_bits, callback); | ||
| 616 | } | ||
| 617 | |||
| 618 | static inline int edset_single(struct u132 *u132, struct u132_ring *ring, | ||
| 619 | struct u132_endp *endp, struct urb *urb, u8 address, u8 toggle_bits, | ||
| 620 | void (*callback) (void *endp, struct urb *urb, u8 *buf, int len, | ||
| 621 | int toggle_bits, int error_count, int condition_code, int repeat_number, | ||
| 622 | int halted, int skipped, int actual, int non_null)) | ||
| 623 | { | ||
| 624 | return usb_ftdi_elan_edset_single(u132->platform_dev, ring->number, | ||
| 625 | endp, urb, address, endp->usb_endp, toggle_bits, callback); | ||
| 626 | } | ||
| 627 | |||
| 628 | static inline int edset_output(struct u132 *u132, struct u132_ring *ring, | ||
| 629 | struct u132_endp *endp, struct urb *urb, u8 address, u8 toggle_bits, | ||
| 630 | void (*callback) (void *endp, struct urb *urb, u8 *buf, int len, | ||
| 631 | int toggle_bits, int error_count, int condition_code, int repeat_number, | ||
| 632 | int halted, int skipped, int actual, int non_null)) | ||
| 633 | { | ||
| 634 | return usb_ftdi_elan_edset_output(u132->platform_dev, ring->number, | ||
| 635 | endp, urb, address, endp->usb_endp, toggle_bits, callback); | ||
| 636 | } | ||
| 637 | |||
| 638 | |||
| 639 | /* | ||
| 640 | * must not LOCK sw_lock | ||
| 641 | * | ||
| 642 | */ | ||
| 643 | static void u132_hcd_interrupt_recv(void *data, struct urb *urb, u8 *buf, | ||
| 644 | int len, int toggle_bits, int error_count, int condition_code, | ||
| 645 | int repeat_number, int halted, int skipped, int actual, int non_null) | ||
| 646 | { | ||
| 647 | struct u132_endp *endp = data; | ||
| 648 | struct u132 *u132 = endp->u132; | ||
| 649 | u8 address = u132->addr[endp->usb_addr].address; | ||
| 650 | struct u132_udev *udev = &u132->udev[address]; | ||
| 651 | down(&u132->scheduler_lock); | ||
| 652 | if (u132->going > 1) { | ||
| 653 | dev_err(&u132->platform_dev->dev, "device has been removed %d\n" | ||
| 654 | , u132->going); | ||
| 655 | up(&u132->scheduler_lock); | ||
| 656 | u132_hcd_forget_urb(u132, endp, urb, -ENODEV); | ||
| 657 | return; | ||
| 658 | } else if (endp->dequeueing) { | ||
| 659 | endp->dequeueing = 0; | ||
| 660 | up(&u132->scheduler_lock); | ||
| 661 | u132_hcd_giveback_urb(u132, endp, urb, -EINTR); | ||
| 662 | return; | ||
| 663 | } else if (u132->going > 0) { | ||
| 664 | dev_err(&u132->platform_dev->dev, "device is being removed urb=" | ||
| 665 | "%p status=%d\n", urb, urb->status); | ||
| 666 | up(&u132->scheduler_lock); | ||
| 667 | u132_hcd_giveback_urb(u132, endp, urb, -ENODEV); | ||
| 668 | return; | ||
| 669 | } else if (urb->status == -EINPROGRESS) { | ||
| 670 | struct u132_ring *ring = endp->ring; | ||
| 671 | u8 *u = urb->transfer_buffer + urb->actual_length; | ||
| 672 | u8 *b = buf; | ||
| 673 | int L = len; | ||
| 674 | while (L-- > 0) { | ||
| 675 | *u++ = *b++; | ||
| 676 | } | ||
| 677 | urb->actual_length += len; | ||
| 678 | if ((condition_code == TD_CC_NOERROR) && | ||
| 679 | (urb->transfer_buffer_length > urb->actual_length)) { | ||
| 680 | endp->toggle_bits = toggle_bits; | ||
| 681 | usb_settoggle(udev->usb_device, endp->usb_endp, 0, | ||
| 682 | 1 & toggle_bits); | ||
| 683 | if (urb->actual_length > 0) { | ||
| 684 | int retval; | ||
| 685 | up(&u132->scheduler_lock); | ||
| 686 | retval = edset_single(u132, ring, endp, urb, | ||
| 687 | address, endp->toggle_bits, | ||
| 688 | u132_hcd_interrupt_recv); | ||
| 689 | if (retval == 0) { | ||
| 690 | } else | ||
| 691 | u132_hcd_giveback_urb(u132, endp, urb, | ||
| 692 | retval); | ||
| 693 | } else { | ||
| 694 | ring->in_use = 0; | ||
| 695 | endp->active = 0; | ||
| 696 | endp->jiffies = jiffies + | ||
| 697 | msecs_to_jiffies(urb->interval); | ||
| 698 | u132_ring_cancel_work(u132, ring); | ||
| 699 | u132_ring_queue_work(u132, ring, 0); | ||
| 700 | up(&u132->scheduler_lock); | ||
| 701 | u132_endp_put_kref(u132, endp); | ||
| 702 | } | ||
| 703 | return; | ||
| 704 | } else if ((condition_code == TD_DATAUNDERRUN) && | ||
| 705 | ((urb->transfer_flags & URB_SHORT_NOT_OK) == 0)) { | ||
| 706 | endp->toggle_bits = toggle_bits; | ||
| 707 | usb_settoggle(udev->usb_device, endp->usb_endp, 0, | ||
| 708 | 1 & toggle_bits); | ||
| 709 | up(&u132->scheduler_lock); | ||
| 710 | u132_hcd_giveback_urb(u132, endp, urb, 0); | ||
| 711 | return; | ||
| 712 | } else { | ||
| 713 | if (condition_code == TD_CC_NOERROR) { | ||
| 714 | endp->toggle_bits = toggle_bits; | ||
| 715 | usb_settoggle(udev->usb_device, endp->usb_endp, | ||
| 716 | 0, 1 & toggle_bits); | ||
| 717 | } else if (condition_code == TD_CC_STALL) { | ||
| 718 | endp->toggle_bits = 0x2; | ||
| 719 | usb_settoggle(udev->usb_device, endp->usb_endp, | ||
| 720 | 0, 0); | ||
| 721 | } else { | ||
| 722 | endp->toggle_bits = 0x2; | ||
| 723 | usb_settoggle(udev->usb_device, endp->usb_endp, | ||
| 724 | 0, 0); | ||
| 725 | dev_err(&u132->platform_dev->dev, "urb=%p givin" | ||
| 726 | "g back INTERRUPT %s\n", urb, | ||
| 727 | cc_to_text[condition_code]); | ||
| 728 | } | ||
| 729 | up(&u132->scheduler_lock); | ||
| 730 | u132_hcd_giveback_urb(u132, endp, urb, | ||
| 731 | cc_to_error[condition_code]); | ||
| 732 | return; | ||
| 733 | } | ||
| 734 | } else { | ||
| 735 | dev_err(&u132->platform_dev->dev, "CALLBACK called urb=%p statu" | ||
| 736 | "s=%d\n", urb, urb->status); | ||
| 737 | up(&u132->scheduler_lock); | ||
| 738 | u132_hcd_giveback_urb(u132, endp, urb, urb->status); | ||
| 739 | return; | ||
| 740 | } | ||
| 741 | } | ||
| 742 | |||
| 743 | static void u132_hcd_bulk_output_sent(void *data, struct urb *urb, u8 *buf, | ||
| 744 | int len, int toggle_bits, int error_count, int condition_code, | ||
| 745 | int repeat_number, int halted, int skipped, int actual, int non_null) | ||
| 746 | { | ||
| 747 | struct u132_endp *endp = data; | ||
| 748 | struct u132 *u132 = endp->u132; | ||
| 749 | u8 address = u132->addr[endp->usb_addr].address; | ||
| 750 | down(&u132->scheduler_lock); | ||
| 751 | if (u132->going > 1) { | ||
| 752 | dev_err(&u132->platform_dev->dev, "device has been removed %d\n" | ||
| 753 | , u132->going); | ||
| 754 | up(&u132->scheduler_lock); | ||
| 755 | u132_hcd_forget_urb(u132, endp, urb, -ENODEV); | ||
| 756 | return; | ||
| 757 | } else if (endp->dequeueing) { | ||
| 758 | endp->dequeueing = 0; | ||
| 759 | up(&u132->scheduler_lock); | ||
| 760 | u132_hcd_giveback_urb(u132, endp, urb, -EINTR); | ||
| 761 | return; | ||
| 762 | } else if (u132->going > 0) { | ||
| 763 | dev_err(&u132->platform_dev->dev, "device is being removed urb=" | ||
| 764 | "%p status=%d\n", urb, urb->status); | ||
| 765 | up(&u132->scheduler_lock); | ||
| 766 | u132_hcd_giveback_urb(u132, endp, urb, -ENODEV); | ||
| 767 | return; | ||
| 768 | } else if (urb->status == -EINPROGRESS) { | ||
| 769 | struct u132_ring *ring = endp->ring; | ||
| 770 | urb->actual_length += len; | ||
| 771 | endp->toggle_bits = toggle_bits; | ||
| 772 | if (urb->transfer_buffer_length > urb->actual_length) { | ||
| 773 | int retval; | ||
| 774 | up(&u132->scheduler_lock); | ||
| 775 | retval = edset_output(u132, ring, endp, urb, address, | ||
| 776 | endp->toggle_bits, u132_hcd_bulk_output_sent); | ||
| 777 | if (retval == 0) { | ||
| 778 | } else | ||
| 779 | u132_hcd_giveback_urb(u132, endp, urb, retval); | ||
| 780 | return; | ||
| 781 | } else { | ||
| 782 | up(&u132->scheduler_lock); | ||
| 783 | u132_hcd_giveback_urb(u132, endp, urb, 0); | ||
| 784 | return; | ||
| 785 | } | ||
| 786 | } else { | ||
| 787 | dev_err(&u132->platform_dev->dev, "CALLBACK called urb=%p statu" | ||
| 788 | "s=%d\n", urb, urb->status); | ||
| 789 | up(&u132->scheduler_lock); | ||
| 790 | u132_hcd_giveback_urb(u132, endp, urb, urb->status); | ||
| 791 | return; | ||
| 792 | } | ||
| 793 | } | ||
| 794 | |||
| 795 | static void u132_hcd_bulk_input_recv(void *data, struct urb *urb, u8 *buf, | ||
| 796 | int len, int toggle_bits, int error_count, int condition_code, | ||
| 797 | int repeat_number, int halted, int skipped, int actual, int non_null) | ||
| 798 | { | ||
| 799 | struct u132_endp *endp = data; | ||
| 800 | struct u132 *u132 = endp->u132; | ||
| 801 | u8 address = u132->addr[endp->usb_addr].address; | ||
| 802 | struct u132_udev *udev = &u132->udev[address]; | ||
| 803 | down(&u132->scheduler_lock); | ||
| 804 | if (u132->going > 1) { | ||
| 805 | dev_err(&u132->platform_dev->dev, "device has been removed %d\n" | ||
| 806 | , u132->going); | ||
| 807 | up(&u132->scheduler_lock); | ||
| 808 | u132_hcd_forget_urb(u132, endp, urb, -ENODEV); | ||
| 809 | return; | ||
| 810 | } else if (endp->dequeueing) { | ||
| 811 | endp->dequeueing = 0; | ||
| 812 | up(&u132->scheduler_lock); | ||
| 813 | u132_hcd_giveback_urb(u132, endp, urb, -EINTR); | ||
| 814 | return; | ||
| 815 | } else if (u132->going > 0) { | ||
| 816 | dev_err(&u132->platform_dev->dev, "device is being removed urb=" | ||
| 817 | "%p status=%d\n", urb, urb->status); | ||
| 818 | up(&u132->scheduler_lock); | ||
| 819 | u132_hcd_giveback_urb(u132, endp, urb, -ENODEV); | ||
| 820 | return; | ||
| 821 | } else if (urb->status == -EINPROGRESS) { | ||
| 822 | struct u132_ring *ring = endp->ring; | ||
| 823 | u8 *u = urb->transfer_buffer + urb->actual_length; | ||
| 824 | u8 *b = buf; | ||
| 825 | int L = len; | ||
| 826 | while (L-- > 0) { | ||
| 827 | *u++ = *b++; | ||
| 828 | } | ||
| 829 | urb->actual_length += len; | ||
| 830 | if ((condition_code == TD_CC_NOERROR) && | ||
| 831 | (urb->transfer_buffer_length > urb->actual_length)) { | ||
| 832 | int retval; | ||
| 833 | endp->toggle_bits = toggle_bits; | ||
| 834 | usb_settoggle(udev->usb_device, endp->usb_endp, 0, | ||
| 835 | 1 & toggle_bits); | ||
| 836 | up(&u132->scheduler_lock); | ||
| 837 | retval = usb_ftdi_elan_edset_input(u132->platform_dev, | ||
| 838 | ring->number, endp, urb, address, | ||
| 839 | endp->usb_endp, endp->toggle_bits, | ||
| 840 | u132_hcd_bulk_input_recv); | ||
| 841 | if (retval == 0) { | ||
| 842 | } else | ||
| 843 | u132_hcd_giveback_urb(u132, endp, urb, retval); | ||
| 844 | return; | ||
| 845 | } else if (condition_code == TD_CC_NOERROR) { | ||
| 846 | endp->toggle_bits = toggle_bits; | ||
| 847 | usb_settoggle(udev->usb_device, endp->usb_endp, 0, | ||
| 848 | 1 & toggle_bits); | ||
| 849 | up(&u132->scheduler_lock); | ||
| 850 | u132_hcd_giveback_urb(u132, endp, urb, | ||
| 851 | cc_to_error[condition_code]); | ||
| 852 | return; | ||
| 853 | } else if ((condition_code == TD_DATAUNDERRUN) && | ||
| 854 | ((urb->transfer_flags & URB_SHORT_NOT_OK) == 0)) { | ||
| 855 | endp->toggle_bits = toggle_bits; | ||
| 856 | usb_settoggle(udev->usb_device, endp->usb_endp, 0, | ||
| 857 | 1 & toggle_bits); | ||
| 858 | up(&u132->scheduler_lock); | ||
| 859 | u132_hcd_giveback_urb(u132, endp, urb, 0); | ||
| 860 | return; | ||
| 861 | } else if (condition_code == TD_DATAUNDERRUN) { | ||
| 862 | endp->toggle_bits = toggle_bits; | ||
| 863 | usb_settoggle(udev->usb_device, endp->usb_endp, 0, | ||
| 864 | 1 & toggle_bits); | ||
| 865 | dev_warn(&u132->platform_dev->dev, "urb=%p(SHORT NOT OK" | ||
| 866 | ") giving back BULK IN %s\n", urb, | ||
| 867 | cc_to_text[condition_code]); | ||
| 868 | up(&u132->scheduler_lock); | ||
| 869 | u132_hcd_giveback_urb(u132, endp, urb, 0); | ||
| 870 | return; | ||
| 871 | } else if (condition_code == TD_CC_STALL) { | ||
| 872 | endp->toggle_bits = 0x2; | ||
| 873 | usb_settoggle(udev->usb_device, endp->usb_endp, 0, 0); | ||
| 874 | up(&u132->scheduler_lock); | ||
| 875 | u132_hcd_giveback_urb(u132, endp, urb, | ||
| 876 | cc_to_error[condition_code]); | ||
| 877 | return; | ||
| 878 | } else { | ||
| 879 | endp->toggle_bits = 0x2; | ||
| 880 | usb_settoggle(udev->usb_device, endp->usb_endp, 0, 0); | ||
| 881 | dev_err(&u132->platform_dev->dev, "urb=%p giving back B" | ||
| 882 | "ULK IN code=%d %s\n", urb, condition_code, | ||
| 883 | cc_to_text[condition_code]); | ||
| 884 | up(&u132->scheduler_lock); | ||
| 885 | u132_hcd_giveback_urb(u132, endp, urb, | ||
| 886 | cc_to_error[condition_code]); | ||
| 887 | return; | ||
| 888 | } | ||
| 889 | } else { | ||
| 890 | dev_err(&u132->platform_dev->dev, "CALLBACK called urb=%p statu" | ||
| 891 | "s=%d\n", urb, urb->status); | ||
| 892 | up(&u132->scheduler_lock); | ||
| 893 | u132_hcd_giveback_urb(u132, endp, urb, urb->status); | ||
| 894 | return; | ||
| 895 | } | ||
| 896 | } | ||
| 897 | |||
| 898 | static void u132_hcd_configure_empty_sent(void *data, struct urb *urb, u8 *buf, | ||
| 899 | int len, int toggle_bits, int error_count, int condition_code, | ||
| 900 | int repeat_number, int halted, int skipped, int actual, int non_null) | ||
| 901 | { | ||
| 902 | struct u132_endp *endp = data; | ||
| 903 | struct u132 *u132 = endp->u132; | ||
| 904 | down(&u132->scheduler_lock); | ||
| 905 | if (u132->going > 1) { | ||
| 906 | dev_err(&u132->platform_dev->dev, "device has been removed %d\n" | ||
| 907 | , u132->going); | ||
| 908 | up(&u132->scheduler_lock); | ||
| 909 | u132_hcd_forget_urb(u132, endp, urb, -ENODEV); | ||
| 910 | return; | ||
| 911 | } else if (endp->dequeueing) { | ||
| 912 | endp->dequeueing = 0; | ||
| 913 | up(&u132->scheduler_lock); | ||
| 914 | u132_hcd_giveback_urb(u132, endp, urb, -EINTR); | ||
| 915 | return; | ||
| 916 | } else if (u132->going > 0) { | ||
| 917 | dev_err(&u132->platform_dev->dev, "device is being removed urb=" | ||
| 918 | "%p status=%d\n", urb, urb->status); | ||
| 919 | up(&u132->scheduler_lock); | ||
| 920 | u132_hcd_giveback_urb(u132, endp, urb, -ENODEV); | ||
| 921 | return; | ||
| 922 | } else if (urb->status == -EINPROGRESS) { | ||
| 923 | up(&u132->scheduler_lock); | ||
| 924 | u132_hcd_giveback_urb(u132, endp, urb, 0); | ||
| 925 | return; | ||
| 926 | } else { | ||
| 927 | dev_err(&u132->platform_dev->dev, "CALLBACK called urb=%p statu" | ||
| 928 | "s=%d\n", urb, urb->status); | ||
| 929 | up(&u132->scheduler_lock); | ||
| 930 | u132_hcd_giveback_urb(u132, endp, urb, urb->status); | ||
| 931 | return; | ||
| 932 | } | ||
| 933 | } | ||
| 934 | |||
| 935 | static void u132_hcd_configure_input_recv(void *data, struct urb *urb, u8 *buf, | ||
| 936 | int len, int toggle_bits, int error_count, int condition_code, | ||
| 937 | int repeat_number, int halted, int skipped, int actual, int non_null) | ||
| 938 | { | ||
| 939 | struct u132_endp *endp = data; | ||
| 940 | struct u132 *u132 = endp->u132; | ||
| 941 | u8 address = u132->addr[endp->usb_addr].address; | ||
| 942 | down(&u132->scheduler_lock); | ||
| 943 | if (u132->going > 1) { | ||
| 944 | dev_err(&u132->platform_dev->dev, "device has been removed %d\n" | ||
| 945 | , u132->going); | ||
| 946 | up(&u132->scheduler_lock); | ||
| 947 | u132_hcd_forget_urb(u132, endp, urb, -ENODEV); | ||
| 948 | return; | ||
| 949 | } else if (endp->dequeueing) { | ||
| 950 | endp->dequeueing = 0; | ||
| 951 | up(&u132->scheduler_lock); | ||
| 952 | u132_hcd_giveback_urb(u132, endp, urb, -EINTR); | ||
| 953 | return; | ||
| 954 | } else if (u132->going > 0) { | ||
| 955 | dev_err(&u132->platform_dev->dev, "device is being removed urb=" | ||
| 956 | "%p status=%d\n", urb, urb->status); | ||
| 957 | up(&u132->scheduler_lock); | ||
| 958 | u132_hcd_giveback_urb(u132, endp, urb, -ENODEV); | ||
| 959 | return; | ||
| 960 | } else if (urb->status == -EINPROGRESS) { | ||
| 961 | struct u132_ring *ring = endp->ring; | ||
| 962 | u8 *u = urb->transfer_buffer; | ||
| 963 | u8 *b = buf; | ||
| 964 | int L = len; | ||
| 965 | while (L-- > 0) { | ||
| 966 | *u++ = *b++; | ||
| 967 | } | ||
| 968 | urb->actual_length = len; | ||
| 969 | if ((condition_code == TD_CC_NOERROR) || ((condition_code == | ||
| 970 | TD_DATAUNDERRUN) && ((urb->transfer_flags & | ||
| 971 | URB_SHORT_NOT_OK) == 0))) { | ||
| 972 | int retval; | ||
| 973 | up(&u132->scheduler_lock); | ||
| 974 | retval = usb_ftdi_elan_edset_empty(u132->platform_dev, | ||
| 975 | ring->number, endp, urb, address, | ||
| 976 | endp->usb_endp, 0x3, | ||
| 977 | u132_hcd_configure_empty_sent); | ||
| 978 | if (retval == 0) { | ||
| 979 | } else | ||
| 980 | u132_hcd_giveback_urb(u132, endp, urb, retval); | ||
| 981 | return; | ||
| 982 | } else if (condition_code == TD_CC_STALL) { | ||
| 983 | up(&u132->scheduler_lock); | ||
| 984 | dev_warn(&u132->platform_dev->dev, "giving back SETUP I" | ||
| 985 | "NPUT STALL urb %p\n", urb); | ||
| 986 | u132_hcd_giveback_urb(u132, endp, urb, | ||
| 987 | cc_to_error[condition_code]); | ||
| 988 | return; | ||
| 989 | } else { | ||
| 990 | up(&u132->scheduler_lock); | ||
| 991 | dev_err(&u132->platform_dev->dev, "giving back SETUP IN" | ||
| 992 | "PUT %s urb %p\n", cc_to_text[condition_code], | ||
| 993 | urb); | ||
| 994 | u132_hcd_giveback_urb(u132, endp, urb, | ||
| 995 | cc_to_error[condition_code]); | ||
| 996 | return; | ||
| 997 | } | ||
| 998 | } else { | ||
| 999 | dev_err(&u132->platform_dev->dev, "CALLBACK called urb=%p statu" | ||
| 1000 | "s=%d\n", urb, urb->status); | ||
| 1001 | up(&u132->scheduler_lock); | ||
| 1002 | u132_hcd_giveback_urb(u132, endp, urb, urb->status); | ||
| 1003 | return; | ||
| 1004 | } | ||
| 1005 | } | ||
| 1006 | |||
| 1007 | static void u132_hcd_configure_empty_recv(void *data, struct urb *urb, u8 *buf, | ||
| 1008 | int len, int toggle_bits, int error_count, int condition_code, | ||
| 1009 | int repeat_number, int halted, int skipped, int actual, int non_null) | ||
| 1010 | { | ||
| 1011 | struct u132_endp *endp = data; | ||
| 1012 | struct u132 *u132 = endp->u132; | ||
| 1013 | down(&u132->scheduler_lock); | ||
| 1014 | if (u132->going > 1) { | ||
| 1015 | dev_err(&u132->platform_dev->dev, "device has been removed %d\n" | ||
| 1016 | , u132->going); | ||
| 1017 | up(&u132->scheduler_lock); | ||
| 1018 | u132_hcd_forget_urb(u132, endp, urb, -ENODEV); | ||
| 1019 | return; | ||
| 1020 | } else if (endp->dequeueing) { | ||
| 1021 | endp->dequeueing = 0; | ||
| 1022 | up(&u132->scheduler_lock); | ||
| 1023 | u132_hcd_giveback_urb(u132, endp, urb, -EINTR); | ||
| 1024 | return; | ||
| 1025 | } else if (u132->going > 0) { | ||
| 1026 | dev_err(&u132->platform_dev->dev, "device is being removed urb=" | ||
| 1027 | "%p status=%d\n", urb, urb->status); | ||
| 1028 | up(&u132->scheduler_lock); | ||
| 1029 | u132_hcd_giveback_urb(u132, endp, urb, -ENODEV); | ||
| 1030 | return; | ||
| 1031 | } else if (urb->status == -EINPROGRESS) { | ||
| 1032 | up(&u132->scheduler_lock); | ||
| 1033 | u132_hcd_giveback_urb(u132, endp, urb, 0); | ||
| 1034 | return; | ||
| 1035 | } else { | ||
| 1036 | dev_err(&u132->platform_dev->dev, "CALLBACK called urb=%p statu" | ||
| 1037 | "s=%d\n", urb, urb->status); | ||
| 1038 | up(&u132->scheduler_lock); | ||
| 1039 | u132_hcd_giveback_urb(u132, endp, urb, urb->status); | ||
| 1040 | return; | ||
| 1041 | } | ||
| 1042 | } | ||
| 1043 | |||
| 1044 | static void u132_hcd_configure_setup_sent(void *data, struct urb *urb, u8 *buf, | ||
| 1045 | int len, int toggle_bits, int error_count, int condition_code, | ||
| 1046 | int repeat_number, int halted, int skipped, int actual, int non_null) | ||
| 1047 | { | ||
| 1048 | struct u132_endp *endp = data; | ||
| 1049 | struct u132 *u132 = endp->u132; | ||
| 1050 | u8 address = u132->addr[endp->usb_addr].address; | ||
| 1051 | down(&u132->scheduler_lock); | ||
| 1052 | if (u132->going > 1) { | ||
| 1053 | dev_err(&u132->platform_dev->dev, "device has been removed %d\n" | ||
| 1054 | , u132->going); | ||
| 1055 | up(&u132->scheduler_lock); | ||
| 1056 | u132_hcd_forget_urb(u132, endp, urb, -ENODEV); | ||
| 1057 | return; | ||
| 1058 | } else if (endp->dequeueing) { | ||
| 1059 | endp->dequeueing = 0; | ||
| 1060 | up(&u132->scheduler_lock); | ||
| 1061 | u132_hcd_giveback_urb(u132, endp, urb, -EINTR); | ||
| 1062 | return; | ||
| 1063 | } else if (u132->going > 0) { | ||
| 1064 | dev_err(&u132->platform_dev->dev, "device is being removed urb=" | ||
| 1065 | "%p status=%d\n", urb, urb->status); | ||
| 1066 | up(&u132->scheduler_lock); | ||
| 1067 | u132_hcd_giveback_urb(u132, endp, urb, -ENODEV); | ||
| 1068 | return; | ||
| 1069 | } else if (urb->status == -EINPROGRESS) { | ||
| 1070 | if (usb_pipein(urb->pipe)) { | ||
| 1071 | int retval; | ||
| 1072 | struct u132_ring *ring = endp->ring; | ||
| 1073 | up(&u132->scheduler_lock); | ||
| 1074 | retval = usb_ftdi_elan_edset_input(u132->platform_dev, | ||
| 1075 | ring->number, endp, urb, address, | ||
| 1076 | endp->usb_endp, 0, | ||
| 1077 | u132_hcd_configure_input_recv); | ||
| 1078 | if (retval == 0) { | ||
| 1079 | } else | ||
| 1080 | u132_hcd_giveback_urb(u132, endp, urb, retval); | ||
| 1081 | return; | ||
| 1082 | } else { | ||
| 1083 | int retval; | ||
| 1084 | struct u132_ring *ring = endp->ring; | ||
| 1085 | up(&u132->scheduler_lock); | ||
| 1086 | retval = usb_ftdi_elan_edset_input(u132->platform_dev, | ||
| 1087 | ring->number, endp, urb, address, | ||
| 1088 | endp->usb_endp, 0, | ||
| 1089 | u132_hcd_configure_empty_recv); | ||
| 1090 | if (retval == 0) { | ||
| 1091 | } else | ||
| 1092 | u132_hcd_giveback_urb(u132, endp, urb, retval); | ||
| 1093 | return; | ||
| 1094 | } | ||
| 1095 | } else { | ||
| 1096 | dev_err(&u132->platform_dev->dev, "CALLBACK called urb=%p statu" | ||
| 1097 | "s=%d\n", urb, urb->status); | ||
| 1098 | up(&u132->scheduler_lock); | ||
| 1099 | u132_hcd_giveback_urb(u132, endp, urb, urb->status); | ||
| 1100 | return; | ||
| 1101 | } | ||
| 1102 | } | ||
| 1103 | |||
| 1104 | static void u132_hcd_enumeration_empty_recv(void *data, struct urb *urb, | ||
| 1105 | u8 *buf, int len, int toggle_bits, int error_count, int condition_code, | ||
| 1106 | int repeat_number, int halted, int skipped, int actual, int non_null) | ||
| 1107 | { | ||
| 1108 | struct u132_endp *endp = data; | ||
| 1109 | struct u132 *u132 = endp->u132; | ||
| 1110 | u8 address = u132->addr[endp->usb_addr].address; | ||
| 1111 | struct u132_udev *udev = &u132->udev[address]; | ||
| 1112 | down(&u132->scheduler_lock); | ||
| 1113 | if (u132->going > 1) { | ||
| 1114 | dev_err(&u132->platform_dev->dev, "device has been removed %d\n" | ||
| 1115 | , u132->going); | ||
| 1116 | up(&u132->scheduler_lock); | ||
| 1117 | u132_hcd_forget_urb(u132, endp, urb, -ENODEV); | ||
| 1118 | return; | ||
| 1119 | } else if (endp->dequeueing) { | ||
| 1120 | endp->dequeueing = 0; | ||
| 1121 | up(&u132->scheduler_lock); | ||
| 1122 | u132_hcd_giveback_urb(u132, endp, urb, -EINTR); | ||
| 1123 | return; | ||
| 1124 | } else if (u132->going > 0) { | ||
| 1125 | dev_err(&u132->platform_dev->dev, "device is being removed urb=" | ||
| 1126 | "%p status=%d\n", urb, urb->status); | ||
| 1127 | up(&u132->scheduler_lock); | ||
| 1128 | u132_hcd_giveback_urb(u132, endp, urb, -ENODEV); | ||
| 1129 | return; | ||
| 1130 | } else if (urb->status == -EINPROGRESS) { | ||
| 1131 | u132->addr[0].address = 0; | ||
| 1132 | endp->usb_addr = udev->usb_addr; | ||
| 1133 | up(&u132->scheduler_lock); | ||
| 1134 | u132_hcd_giveback_urb(u132, endp, urb, 0); | ||
| 1135 | return; | ||
| 1136 | } else { | ||
| 1137 | dev_err(&u132->platform_dev->dev, "CALLBACK called urb=%p statu" | ||
| 1138 | "s=%d\n", urb, urb->status); | ||
| 1139 | up(&u132->scheduler_lock); | ||
| 1140 | u132_hcd_giveback_urb(u132, endp, urb, urb->status); | ||
| 1141 | return; | ||
| 1142 | } | ||
| 1143 | } | ||
| 1144 | |||
| 1145 | static void u132_hcd_enumeration_address_sent(void *data, struct urb *urb, | ||
| 1146 | u8 *buf, int len, int toggle_bits, int error_count, int condition_code, | ||
| 1147 | int repeat_number, int halted, int skipped, int actual, int non_null) | ||
| 1148 | { | ||
| 1149 | struct u132_endp *endp = data; | ||
| 1150 | struct u132 *u132 = endp->u132; | ||
| 1151 | down(&u132->scheduler_lock); | ||
| 1152 | if (u132->going > 1) { | ||
| 1153 | dev_err(&u132->platform_dev->dev, "device has been removed %d\n" | ||
| 1154 | , u132->going); | ||
| 1155 | up(&u132->scheduler_lock); | ||
| 1156 | u132_hcd_forget_urb(u132, endp, urb, -ENODEV); | ||
| 1157 | return; | ||
| 1158 | } else if (endp->dequeueing) { | ||
| 1159 | endp->dequeueing = 0; | ||
| 1160 | up(&u132->scheduler_lock); | ||
| 1161 | u132_hcd_giveback_urb(u132, endp, urb, -EINTR); | ||
| 1162 | return; | ||
| 1163 | } else if (u132->going > 0) { | ||
| 1164 | dev_err(&u132->platform_dev->dev, "device is being removed urb=" | ||
| 1165 | "%p status=%d\n", urb, urb->status); | ||
| 1166 | up(&u132->scheduler_lock); | ||
| 1167 | u132_hcd_giveback_urb(u132, endp, urb, -ENODEV); | ||
| 1168 | return; | ||
| 1169 | } else if (urb->status == -EINPROGRESS) { | ||
| 1170 | int retval; | ||
| 1171 | struct u132_ring *ring = endp->ring; | ||
| 1172 | up(&u132->scheduler_lock); | ||
| 1173 | retval = usb_ftdi_elan_edset_input(u132->platform_dev, | ||
| 1174 | ring->number, endp, urb, 0, endp->usb_endp, 0, | ||
| 1175 | u132_hcd_enumeration_empty_recv); | ||
| 1176 | if (retval == 0) { | ||
| 1177 | } else | ||
| 1178 | u132_hcd_giveback_urb(u132, endp, urb, retval); | ||
| 1179 | return; | ||
| 1180 | } else { | ||
| 1181 | dev_err(&u132->platform_dev->dev, "CALLBACK called urb=%p statu" | ||
| 1182 | "s=%d\n", urb, urb->status); | ||
| 1183 | up(&u132->scheduler_lock); | ||
| 1184 | u132_hcd_giveback_urb(u132, endp, urb, urb->status); | ||
| 1185 | return; | ||
| 1186 | } | ||
| 1187 | } | ||
| 1188 | |||
| 1189 | static void u132_hcd_initial_empty_sent(void *data, struct urb *urb, u8 *buf, | ||
| 1190 | int len, int toggle_bits, int error_count, int condition_code, | ||
| 1191 | int repeat_number, int halted, int skipped, int actual, int non_null) | ||
| 1192 | { | ||
| 1193 | struct u132_endp *endp = data; | ||
| 1194 | struct u132 *u132 = endp->u132; | ||
| 1195 | down(&u132->scheduler_lock); | ||
| 1196 | if (u132->going > 1) { | ||
| 1197 | dev_err(&u132->platform_dev->dev, "device has been removed %d\n" | ||
| 1198 | , u132->going); | ||
| 1199 | up(&u132->scheduler_lock); | ||
| 1200 | u132_hcd_forget_urb(u132, endp, urb, -ENODEV); | ||
| 1201 | return; | ||
| 1202 | } else if (endp->dequeueing) { | ||
| 1203 | endp->dequeueing = 0; | ||
| 1204 | up(&u132->scheduler_lock); | ||
| 1205 | u132_hcd_giveback_urb(u132, endp, urb, -EINTR); | ||
| 1206 | return; | ||
| 1207 | } else if (u132->going > 0) { | ||
| 1208 | dev_err(&u132->platform_dev->dev, "device is being removed urb=" | ||
| 1209 | "%p status=%d\n", urb, urb->status); | ||
| 1210 | up(&u132->scheduler_lock); | ||
| 1211 | u132_hcd_giveback_urb(u132, endp, urb, -ENODEV); | ||
| 1212 | return; | ||
| 1213 | } else if (urb->status == -EINPROGRESS) { | ||
| 1214 | up(&u132->scheduler_lock); | ||
| 1215 | u132_hcd_giveback_urb(u132, endp, urb, 0); | ||
| 1216 | return; | ||
| 1217 | } else { | ||
| 1218 | dev_err(&u132->platform_dev->dev, "CALLBACK called urb=%p statu" | ||
| 1219 | "s=%d\n", urb, urb->status); | ||
| 1220 | up(&u132->scheduler_lock); | ||
| 1221 | u132_hcd_giveback_urb(u132, endp, urb, urb->status); | ||
| 1222 | return; | ||
| 1223 | } | ||
| 1224 | } | ||
| 1225 | |||
| 1226 | static void u132_hcd_initial_input_recv(void *data, struct urb *urb, u8 *buf, | ||
| 1227 | int len, int toggle_bits, int error_count, int condition_code, | ||
| 1228 | int repeat_number, int halted, int skipped, int actual, int non_null) | ||
| 1229 | { | ||
| 1230 | struct u132_endp *endp = data; | ||
| 1231 | struct u132 *u132 = endp->u132; | ||
| 1232 | u8 address = u132->addr[endp->usb_addr].address; | ||
| 1233 | down(&u132->scheduler_lock); | ||
| 1234 | if (u132->going > 1) { | ||
| 1235 | dev_err(&u132->platform_dev->dev, "device has been removed %d\n" | ||
| 1236 | , u132->going); | ||
| 1237 | up(&u132->scheduler_lock); | ||
| 1238 | u132_hcd_forget_urb(u132, endp, urb, -ENODEV); | ||
| 1239 | return; | ||
| 1240 | } else if (endp->dequeueing) { | ||
| 1241 | endp->dequeueing = 0; | ||
| 1242 | up(&u132->scheduler_lock); | ||
| 1243 | u132_hcd_giveback_urb(u132, endp, urb, -EINTR); | ||
| 1244 | return; | ||
| 1245 | } else if (u132->going > 0) { | ||
| 1246 | dev_err(&u132->platform_dev->dev, "device is being removed urb=" | ||
| 1247 | "%p status=%d\n", urb, urb->status); | ||
| 1248 | up(&u132->scheduler_lock); | ||
| 1249 | u132_hcd_giveback_urb(u132, endp, urb, -ENODEV); | ||
| 1250 | return; | ||
| 1251 | } else if (urb->status == -EINPROGRESS) { | ||
| 1252 | int retval; | ||
| 1253 | struct u132_ring *ring = endp->ring; | ||
| 1254 | u8 *u = urb->transfer_buffer; | ||
| 1255 | u8 *b = buf; | ||
| 1256 | int L = len; | ||
| 1257 | while (L-- > 0) { | ||
| 1258 | *u++ = *b++; | ||
| 1259 | } | ||
| 1260 | urb->actual_length = len; | ||
| 1261 | up(&u132->scheduler_lock); | ||
| 1262 | retval = usb_ftdi_elan_edset_empty(u132->platform_dev, | ||
| 1263 | ring->number, endp, urb, address, endp->usb_endp, 0x3, | ||
| 1264 | u132_hcd_initial_empty_sent); | ||
| 1265 | if (retval == 0) { | ||
| 1266 | } else | ||
| 1267 | u132_hcd_giveback_urb(u132, endp, urb, retval); | ||
| 1268 | return; | ||
| 1269 | } else { | ||
| 1270 | dev_err(&u132->platform_dev->dev, "CALLBACK called urb=%p statu" | ||
| 1271 | "s=%d\n", urb, urb->status); | ||
| 1272 | up(&u132->scheduler_lock); | ||
| 1273 | u132_hcd_giveback_urb(u132, endp, urb, urb->status); | ||
| 1274 | return; | ||
| 1275 | } | ||
| 1276 | } | ||
| 1277 | |||
| 1278 | static void u132_hcd_initial_setup_sent(void *data, struct urb *urb, u8 *buf, | ||
| 1279 | int len, int toggle_bits, int error_count, int condition_code, | ||
| 1280 | int repeat_number, int halted, int skipped, int actual, int non_null) | ||
| 1281 | { | ||
| 1282 | struct u132_endp *endp = data; | ||
| 1283 | struct u132 *u132 = endp->u132; | ||
| 1284 | u8 address = u132->addr[endp->usb_addr].address; | ||
| 1285 | down(&u132->scheduler_lock); | ||
| 1286 | if (u132->going > 1) { | ||
| 1287 | dev_err(&u132->platform_dev->dev, "device has been removed %d\n" | ||
| 1288 | , u132->going); | ||
| 1289 | up(&u132->scheduler_lock); | ||
| 1290 | u132_hcd_forget_urb(u132, endp, urb, -ENODEV); | ||
| 1291 | return; | ||
| 1292 | } else if (endp->dequeueing) { | ||
| 1293 | endp->dequeueing = 0; | ||
| 1294 | up(&u132->scheduler_lock); | ||
| 1295 | u132_hcd_giveback_urb(u132, endp, urb, -EINTR); | ||
| 1296 | return; | ||
| 1297 | } else if (u132->going > 0) { | ||
| 1298 | dev_err(&u132->platform_dev->dev, "device is being removed urb=" | ||
| 1299 | "%p status=%d\n", urb, urb->status); | ||
| 1300 | up(&u132->scheduler_lock); | ||
| 1301 | u132_hcd_giveback_urb(u132, endp, urb, -ENODEV); | ||
| 1302 | return; | ||
| 1303 | } else if (urb->status == -EINPROGRESS) { | ||
| 1304 | int retval; | ||
| 1305 | struct u132_ring *ring = endp->ring; | ||
| 1306 | up(&u132->scheduler_lock); | ||
| 1307 | retval = usb_ftdi_elan_edset_input(u132->platform_dev, | ||
| 1308 | ring->number, endp, urb, address, endp->usb_endp, 0, | ||
| 1309 | u132_hcd_initial_input_recv); | ||
| 1310 | if (retval == 0) { | ||
| 1311 | } else | ||
| 1312 | u132_hcd_giveback_urb(u132, endp, urb, retval); | ||
| 1313 | return; | ||
| 1314 | } else { | ||
| 1315 | dev_err(&u132->platform_dev->dev, "CALLBACK called urb=%p statu" | ||
| 1316 | "s=%d\n", urb, urb->status); | ||
| 1317 | up(&u132->scheduler_lock); | ||
| 1318 | u132_hcd_giveback_urb(u132, endp, urb, urb->status); | ||
| 1319 | return; | ||
| 1320 | } | ||
| 1321 | } | ||
| 1322 | |||
| 1323 | static void u132_hcd_ring_work_scheduler(void *data); | ||
| 1324 | static void u132_hcd_endp_work_scheduler(void *data); | ||
| 1325 | /* | ||
| 1326 | * this work function is only executed from the work queue | ||
| 1327 | * | ||
| 1328 | */ | ||
| 1329 | static void u132_hcd_ring_work_scheduler(void *data) | ||
| 1330 | { | ||
| 1331 | struct u132_ring *ring = data; | ||
| 1332 | struct u132 *u132 = ring->u132; | ||
| 1333 | down(&u132->scheduler_lock); | ||
| 1334 | if (ring->in_use) { | ||
| 1335 | up(&u132->scheduler_lock); | ||
| 1336 | u132_ring_put_kref(u132, ring); | ||
| 1337 | return; | ||
| 1338 | } else if (ring->curr_endp) { | ||
| 1339 | struct u132_endp *last_endp = ring->curr_endp; | ||
| 1340 | struct list_head *scan; | ||
| 1341 | struct list_head *head = &last_endp->endp_ring; | ||
| 1342 | unsigned long wakeup = 0; | ||
| 1343 | list_for_each(scan, head) { | ||
| 1344 | struct u132_endp *endp = list_entry(scan, | ||
| 1345 | struct u132_endp, endp_ring); | ||
| 1346 | if (endp->queue_next == endp->queue_last) { | ||
| 1347 | } else if ((endp->delayed == 0) | ||
| 1348 | || time_after_eq(jiffies, endp->jiffies)) { | ||
| 1349 | ring->curr_endp = endp; | ||
| 1350 | u132_endp_cancel_work(u132, last_endp); | ||
| 1351 | u132_endp_queue_work(u132, last_endp, 0); | ||
| 1352 | up(&u132->scheduler_lock); | ||
| 1353 | u132_ring_put_kref(u132, ring); | ||
| 1354 | return; | ||
| 1355 | } else { | ||
| 1356 | unsigned long delta = endp->jiffies - jiffies; | ||
| 1357 | if (delta > wakeup) | ||
| 1358 | wakeup = delta; | ||
| 1359 | } | ||
| 1360 | } | ||
| 1361 | if (last_endp->queue_next == last_endp->queue_last) { | ||
| 1362 | } else if ((last_endp->delayed == 0) || time_after_eq(jiffies, | ||
| 1363 | last_endp->jiffies)) { | ||
| 1364 | u132_endp_cancel_work(u132, last_endp); | ||
| 1365 | u132_endp_queue_work(u132, last_endp, 0); | ||
| 1366 | up(&u132->scheduler_lock); | ||
| 1367 | u132_ring_put_kref(u132, ring); | ||
| 1368 | return; | ||
| 1369 | } else { | ||
| 1370 | unsigned long delta = last_endp->jiffies - jiffies; | ||
| 1371 | if (delta > wakeup) | ||
| 1372 | wakeup = delta; | ||
| 1373 | } | ||
| 1374 | if (wakeup > 0) { | ||
| 1375 | u132_ring_requeue_work(u132, ring, wakeup); | ||
| 1376 | up(&u132->scheduler_lock); | ||
| 1377 | return; | ||
| 1378 | } else { | ||
| 1379 | up(&u132->scheduler_lock); | ||
| 1380 | u132_ring_put_kref(u132, ring); | ||
| 1381 | return; | ||
| 1382 | } | ||
| 1383 | } else { | ||
| 1384 | up(&u132->scheduler_lock); | ||
| 1385 | u132_ring_put_kref(u132, ring); | ||
| 1386 | return; | ||
| 1387 | } | ||
| 1388 | } | ||
| 1389 | |||
| 1390 | static void u132_hcd_endp_work_scheduler(void *data) | ||
| 1391 | { | ||
| 1392 | struct u132_ring *ring; | ||
| 1393 | struct u132_endp *endp = data; | ||
| 1394 | struct u132 *u132 = endp->u132; | ||
| 1395 | down(&u132->scheduler_lock); | ||
| 1396 | ring = endp->ring; | ||
| 1397 | if (endp->edset_flush) { | ||
| 1398 | endp->edset_flush = 0; | ||
| 1399 | if (endp->dequeueing) | ||
| 1400 | usb_ftdi_elan_edset_flush(u132->platform_dev, | ||
| 1401 | ring->number, endp); | ||
| 1402 | up(&u132->scheduler_lock); | ||
| 1403 | u132_endp_put_kref(u132, endp); | ||
| 1404 | return; | ||
| 1405 | } else if (endp->active) { | ||
| 1406 | up(&u132->scheduler_lock); | ||
| 1407 | u132_endp_put_kref(u132, endp); | ||
| 1408 | return; | ||
| 1409 | } else if (ring->in_use) { | ||
| 1410 | up(&u132->scheduler_lock); | ||
| 1411 | u132_endp_put_kref(u132, endp); | ||
| 1412 | return; | ||
| 1413 | } else if (endp->queue_next == endp->queue_last) { | ||
| 1414 | up(&u132->scheduler_lock); | ||
| 1415 | u132_endp_put_kref(u132, endp); | ||
| 1416 | return; | ||
| 1417 | } else if (endp->pipetype == PIPE_INTERRUPT) { | ||
| 1418 | u8 address = u132->addr[endp->usb_addr].address; | ||
| 1419 | if (ring->in_use) { | ||
| 1420 | up(&u132->scheduler_lock); | ||
| 1421 | u132_endp_put_kref(u132, endp); | ||
| 1422 | return; | ||
| 1423 | } else { | ||
| 1424 | int retval; | ||
| 1425 | struct urb *urb = endp->urb_list[ENDP_QUEUE_MASK & | ||
| 1426 | endp->queue_next]; | ||
| 1427 | endp->active = 1; | ||
| 1428 | ring->curr_endp = endp; | ||
| 1429 | ring->in_use = 1; | ||
| 1430 | up(&u132->scheduler_lock); | ||
| 1431 | retval = edset_single(u132, ring, endp, urb, address, | ||
| 1432 | endp->toggle_bits, u132_hcd_interrupt_recv); | ||
| 1433 | if (retval == 0) { | ||
| 1434 | } else | ||
| 1435 | u132_hcd_giveback_urb(u132, endp, urb, retval); | ||
| 1436 | return; | ||
| 1437 | } | ||
| 1438 | } else if (endp->pipetype == PIPE_CONTROL) { | ||
| 1439 | u8 address = u132->addr[endp->usb_addr].address; | ||
| 1440 | if (ring->in_use) { | ||
| 1441 | up(&u132->scheduler_lock); | ||
| 1442 | u132_endp_put_kref(u132, endp); | ||
| 1443 | return; | ||
| 1444 | } else if (address == 0) { | ||
| 1445 | int retval; | ||
| 1446 | struct urb *urb = endp->urb_list[ENDP_QUEUE_MASK & | ||
| 1447 | endp->queue_next]; | ||
| 1448 | endp->active = 1; | ||
| 1449 | ring->curr_endp = endp; | ||
| 1450 | ring->in_use = 1; | ||
| 1451 | up(&u132->scheduler_lock); | ||
| 1452 | retval = edset_setup(u132, ring, endp, urb, address, | ||
| 1453 | 0x2, u132_hcd_initial_setup_sent); | ||
| 1454 | if (retval == 0) { | ||
| 1455 | } else | ||
| 1456 | u132_hcd_giveback_urb(u132, endp, urb, retval); | ||
| 1457 | return; | ||
| 1458 | } else if (endp->usb_addr == 0) { | ||
| 1459 | int retval; | ||
| 1460 | struct urb *urb = endp->urb_list[ENDP_QUEUE_MASK & | ||
| 1461 | endp->queue_next]; | ||
| 1462 | endp->active = 1; | ||
| 1463 | ring->curr_endp = endp; | ||
| 1464 | ring->in_use = 1; | ||
| 1465 | up(&u132->scheduler_lock); | ||
| 1466 | retval = edset_setup(u132, ring, endp, urb, 0, 0x2, | ||
| 1467 | u132_hcd_enumeration_address_sent); | ||
| 1468 | if (retval == 0) { | ||
| 1469 | } else | ||
| 1470 | u132_hcd_giveback_urb(u132, endp, urb, retval); | ||
| 1471 | return; | ||
| 1472 | } else { | ||
| 1473 | int retval; | ||
| 1474 | u8 address = u132->addr[endp->usb_addr].address; | ||
| 1475 | struct urb *urb = endp->urb_list[ENDP_QUEUE_MASK & | ||
| 1476 | endp->queue_next]; | ||
| 1477 | endp->active = 1; | ||
| 1478 | ring->curr_endp = endp; | ||
| 1479 | ring->in_use = 1; | ||
| 1480 | up(&u132->scheduler_lock); | ||
| 1481 | retval = edset_setup(u132, ring, endp, urb, address, | ||
| 1482 | 0x2, u132_hcd_configure_setup_sent); | ||
| 1483 | if (retval == 0) { | ||
| 1484 | } else | ||
| 1485 | u132_hcd_giveback_urb(u132, endp, urb, retval); | ||
| 1486 | return; | ||
| 1487 | } | ||
| 1488 | } else { | ||
| 1489 | if (endp->input) { | ||
| 1490 | u8 address = u132->addr[endp->usb_addr].address; | ||
| 1491 | if (ring->in_use) { | ||
| 1492 | up(&u132->scheduler_lock); | ||
| 1493 | u132_endp_put_kref(u132, endp); | ||
| 1494 | return; | ||
| 1495 | } else { | ||
| 1496 | int retval; | ||
| 1497 | struct urb *urb = endp->urb_list[ | ||
| 1498 | ENDP_QUEUE_MASK & endp->queue_next]; | ||
| 1499 | endp->active = 1; | ||
| 1500 | ring->curr_endp = endp; | ||
| 1501 | ring->in_use = 1; | ||
| 1502 | up(&u132->scheduler_lock); | ||
| 1503 | retval = edset_input(u132, ring, endp, urb, | ||
| 1504 | address, endp->toggle_bits, | ||
| 1505 | u132_hcd_bulk_input_recv); | ||
| 1506 | if (retval == 0) { | ||
| 1507 | } else | ||
| 1508 | u132_hcd_giveback_urb(u132, endp, urb, | ||
| 1509 | retval); | ||
| 1510 | return; | ||
| 1511 | } | ||
| 1512 | } else { /* output pipe */ | ||
| 1513 | u8 address = u132->addr[endp->usb_addr].address; | ||
| 1514 | if (ring->in_use) { | ||
| 1515 | up(&u132->scheduler_lock); | ||
| 1516 | u132_endp_put_kref(u132, endp); | ||
| 1517 | return; | ||
| 1518 | } else { | ||
| 1519 | int retval; | ||
| 1520 | struct urb *urb = endp->urb_list[ | ||
| 1521 | ENDP_QUEUE_MASK & endp->queue_next]; | ||
| 1522 | endp->active = 1; | ||
| 1523 | ring->curr_endp = endp; | ||
| 1524 | ring->in_use = 1; | ||
| 1525 | up(&u132->scheduler_lock); | ||
| 1526 | retval = edset_output(u132, ring, endp, urb, | ||
| 1527 | address, endp->toggle_bits, | ||
| 1528 | u132_hcd_bulk_output_sent); | ||
| 1529 | if (retval == 0) { | ||
| 1530 | } else | ||
| 1531 | u132_hcd_giveback_urb(u132, endp, urb, | ||
| 1532 | retval); | ||
| 1533 | return; | ||
| 1534 | } | ||
| 1535 | } | ||
| 1536 | } | ||
| 1537 | } | ||
| 1538 | |||
| 1539 | static void port_power(struct u132 *u132, int pn, int is_on) | ||
| 1540 | { | ||
| 1541 | u132->port[pn].power = is_on; | ||
| 1542 | } | ||
| 1543 | |||
| 1544 | static void u132_power(struct u132 *u132, int is_on) | ||
| 1545 | { | ||
| 1546 | struct usb_hcd *hcd = u132_to_hcd(u132) | ||
| 1547 | ; /* hub is inactive unless the port is powered */ | ||
| 1548 | if (is_on) { | ||
| 1549 | if (u132->power) | ||
| 1550 | return; | ||
| 1551 | u132->power = 1; | ||
| 1552 | hcd->self.controller->power.power_state = PMSG_ON; | ||
| 1553 | } else { | ||
| 1554 | u132->power = 0; | ||
| 1555 | hcd->state = HC_STATE_HALT; | ||
| 1556 | hcd->self.controller->power.power_state = PMSG_SUSPEND; | ||
| 1557 | } | ||
| 1558 | } | ||
| 1559 | |||
| 1560 | static int u132_periodic_reinit(struct u132 *u132) | ||
| 1561 | { | ||
| 1562 | int retval; | ||
| 1563 | u32 fi = u132->hc_fminterval & 0x03fff; | ||
| 1564 | u32 fit; | ||
| 1565 | u32 fminterval; | ||
| 1566 | retval = u132_read_pcimem(u132, fminterval, &fminterval); | ||
| 1567 | if (retval) | ||
| 1568 | return retval; | ||
| 1569 | fit = fminterval & FIT; | ||
| 1570 | retval = u132_write_pcimem(u132, fminterval, | ||
| 1571 | (fit ^ FIT) | u132->hc_fminterval); | ||
| 1572 | if (retval) | ||
| 1573 | return retval; | ||
| 1574 | retval = u132_write_pcimem(u132, periodicstart, | ||
| 1575 | ((9 *fi) / 10) & 0x3fff); | ||
| 1576 | if (retval) | ||
| 1577 | return retval; | ||
| 1578 | return 0; | ||
| 1579 | } | ||
| 1580 | |||
| 1581 | static char *hcfs2string(int state) | ||
| 1582 | { | ||
| 1583 | switch (state) { | ||
| 1584 | case OHCI_USB_RESET: | ||
| 1585 | return "reset"; | ||
| 1586 | case OHCI_USB_RESUME: | ||
| 1587 | return "resume"; | ||
| 1588 | case OHCI_USB_OPER: | ||
| 1589 | return "operational"; | ||
| 1590 | case OHCI_USB_SUSPEND: | ||
| 1591 | return "suspend"; | ||
| 1592 | } | ||
| 1593 | return "?"; | ||
| 1594 | } | ||
| 1595 | |||
| 1596 | static int u132_usb_reset(struct u132 *u132) | ||
| 1597 | { | ||
| 1598 | int retval; | ||
| 1599 | retval = u132_read_pcimem(u132, control, &u132->hc_control); | ||
| 1600 | if (retval) | ||
| 1601 | return retval; | ||
| 1602 | u132->hc_control &= OHCI_CTRL_RWC; | ||
| 1603 | retval = u132_write_pcimem(u132, control, u132->hc_control); | ||
| 1604 | if (retval) | ||
| 1605 | return retval; | ||
| 1606 | return 0; | ||
| 1607 | } | ||
| 1608 | |||
| 1609 | static int u132_init(struct u132 *u132) | ||
| 1610 | { | ||
| 1611 | int retval; | ||
| 1612 | u32 control; | ||
| 1613 | u132_disable(u132); | ||
| 1614 | u132->next_statechange = | ||
| 1615 | jiffies; /* SMM owns the HC? not for long! */ { | ||
| 1616 | u32 control; | ||
| 1617 | retval = u132_read_pcimem(u132, control, &control); | ||
| 1618 | if (retval) | ||
| 1619 | return retval; | ||
| 1620 | if (control & OHCI_CTRL_IR) { | ||
| 1621 | u32 temp = 50; | ||
| 1622 | retval = u132_write_pcimem(u132, intrenable, | ||
| 1623 | OHCI_INTR_OC); | ||
| 1624 | if (retval) | ||
| 1625 | return retval; | ||
| 1626 | retval = u132_write_pcimem_byte(u132, cmdstatus, | ||
| 1627 | OHCI_OCR); | ||
| 1628 | if (retval) | ||
| 1629 | return retval; | ||
| 1630 | check:{ | ||
| 1631 | retval = u132_read_pcimem(u132, control, | ||
| 1632 | &control); | ||
| 1633 | if (retval) | ||
| 1634 | return retval; | ||
| 1635 | } | ||
| 1636 | if (control & OHCI_CTRL_IR) { | ||
| 1637 | msleep(10); | ||
| 1638 | if (--temp == 0) { | ||
| 1639 | dev_err(&u132->platform_dev->dev, "USB " | ||
| 1640 | "HC takeover failed!(BIOS/SMM b" | ||
| 1641 | "ug) control=%08X\n", control); | ||
| 1642 | return -EBUSY; | ||
| 1643 | } | ||
| 1644 | goto check; | ||
| 1645 | } | ||
| 1646 | u132_usb_reset(u132); | ||
| 1647 | } | ||
| 1648 | } | ||
| 1649 | retval = u132_write_pcimem(u132, intrdisable, OHCI_INTR_MIE); | ||
| 1650 | if (retval) | ||
| 1651 | return retval; | ||
| 1652 | retval = u132_read_pcimem(u132, control, &control); | ||
| 1653 | if (retval) | ||
| 1654 | return retval; | ||
| 1655 | if (u132->num_ports == 0) { | ||
| 1656 | u32 rh_a = -1; | ||
| 1657 | retval = u132_read_pcimem(u132, roothub.a, &rh_a); | ||
| 1658 | if (retval) | ||
| 1659 | return retval; | ||
| 1660 | u132->num_ports = rh_a & RH_A_NDP; | ||
| 1661 | retval = read_roothub_info(u132); | ||
| 1662 | if (retval) | ||
| 1663 | return retval; | ||
| 1664 | } | ||
| 1665 | if (u132->num_ports > MAX_U132_PORTS) { | ||
| 1666 | return -EINVAL; | ||
| 1667 | } | ||
| 1668 | return 0; | ||
| 1669 | } | ||
| 1670 | |||
| 1671 | |||
| 1672 | /* Start an OHCI controller, set the BUS operational | ||
| 1673 | * resets USB and controller | ||
| 1674 | * enable interrupts | ||
| 1675 | */ | ||
| 1676 | static int u132_run(struct u132 *u132) | ||
| 1677 | { | ||
| 1678 | int retval; | ||
| 1679 | u32 control; | ||
| 1680 | u32 status; | ||
| 1681 | u32 fminterval; | ||
| 1682 | u32 periodicstart; | ||
| 1683 | u32 cmdstatus; | ||
| 1684 | u32 roothub_a; | ||
| 1685 | int mask = OHCI_INTR_INIT; | ||
| 1686 | int first = u132->hc_fminterval == 0; | ||
| 1687 | int sleep_time = 0; | ||
| 1688 | int reset_timeout = 30; /* ... allow extra time */ | ||
| 1689 | u132_disable(u132); | ||
| 1690 | if (first) { | ||
| 1691 | u32 temp; | ||
| 1692 | retval = u132_read_pcimem(u132, fminterval, &temp); | ||
| 1693 | if (retval) | ||
| 1694 | return retval; | ||
| 1695 | u132->hc_fminterval = temp & 0x3fff; | ||
| 1696 | if (u132->hc_fminterval != FI) { | ||
| 1697 | } | ||
| 1698 | u132->hc_fminterval |= FSMP(u132->hc_fminterval) << 16; | ||
| 1699 | } | ||
| 1700 | retval = u132_read_pcimem(u132, control, &u132->hc_control); | ||
| 1701 | if (retval) | ||
| 1702 | return retval; | ||
| 1703 | dev_info(&u132->platform_dev->dev, "resetting from state '%s', control " | ||
| 1704 | "= %08X\n", hcfs2string(u132->hc_control & OHCI_CTRL_HCFS), | ||
| 1705 | u132->hc_control); | ||
| 1706 | switch (u132->hc_control & OHCI_CTRL_HCFS) { | ||
| 1707 | case OHCI_USB_OPER: | ||
| 1708 | sleep_time = 0; | ||
| 1709 | break; | ||
| 1710 | case OHCI_USB_SUSPEND: | ||
| 1711 | case OHCI_USB_RESUME: | ||
| 1712 | u132->hc_control &= OHCI_CTRL_RWC; | ||
| 1713 | u132->hc_control |= OHCI_USB_RESUME; | ||
| 1714 | sleep_time = 10; | ||
| 1715 | break; | ||
| 1716 | default: | ||
| 1717 | u132->hc_control &= OHCI_CTRL_RWC; | ||
| 1718 | u132->hc_control |= OHCI_USB_RESET; | ||
| 1719 | sleep_time = 50; | ||
| 1720 | break; | ||
| 1721 | } | ||
| 1722 | retval = u132_write_pcimem(u132, control, u132->hc_control); | ||
| 1723 | if (retval) | ||
| 1724 | return retval; | ||
| 1725 | retval = u132_read_pcimem(u132, control, &control); | ||
| 1726 | if (retval) | ||
| 1727 | return retval; | ||
| 1728 | msleep(sleep_time); | ||
| 1729 | retval = u132_read_pcimem(u132, roothub.a, &roothub_a); | ||
| 1730 | if (retval) | ||
| 1731 | return retval; | ||
| 1732 | if (!(roothub_a & RH_A_NPS)) { | ||
| 1733 | int temp; /* power down each port */ | ||
| 1734 | for (temp = 0; temp < u132->num_ports; temp++) { | ||
| 1735 | retval = u132_write_pcimem(u132, | ||
| 1736 | roothub.portstatus[temp], RH_PS_LSDA); | ||
| 1737 | if (retval) | ||
| 1738 | return retval; | ||
| 1739 | } | ||
| 1740 | } | ||
| 1741 | retval = u132_read_pcimem(u132, control, &control); | ||
| 1742 | if (retval) | ||
| 1743 | return retval; | ||
| 1744 | retry:retval = u132_read_pcimem(u132, cmdstatus, &status); | ||
| 1745 | if (retval) | ||
| 1746 | return retval; | ||
| 1747 | retval = u132_write_pcimem_byte(u132, cmdstatus, OHCI_HCR); | ||
| 1748 | if (retval) | ||
| 1749 | return retval; | ||
| 1750 | extra:{ | ||
| 1751 | retval = u132_read_pcimem(u132, cmdstatus, &status); | ||
| 1752 | if (retval) | ||
| 1753 | return retval; | ||
| 1754 | if (0 != (status & OHCI_HCR)) { | ||
| 1755 | if (--reset_timeout == 0) { | ||
| 1756 | dev_err(&u132->platform_dev->dev, "USB HC reset" | ||
| 1757 | " timed out!\n"); | ||
| 1758 | return -ENODEV; | ||
| 1759 | } else { | ||
| 1760 | msleep(5); | ||
| 1761 | goto extra; | ||
| 1762 | } | ||
| 1763 | } | ||
| 1764 | } | ||
| 1765 | if (u132->flags & OHCI_QUIRK_INITRESET) { | ||
| 1766 | retval = u132_write_pcimem(u132, control, u132->hc_control); | ||
| 1767 | if (retval) | ||
| 1768 | return retval; | ||
| 1769 | retval = u132_read_pcimem(u132, control, &control); | ||
| 1770 | if (retval) | ||
| 1771 | return retval; | ||
| 1772 | } | ||
| 1773 | retval = u132_write_pcimem(u132, ed_controlhead, 0x00000000); | ||
| 1774 | if (retval) | ||
| 1775 | return retval; | ||
| 1776 | retval = u132_write_pcimem(u132, ed_bulkhead, 0x11000000); | ||
| 1777 | if (retval) | ||
| 1778 | return retval; | ||
| 1779 | retval = u132_write_pcimem(u132, hcca, 0x00000000); | ||
| 1780 | if (retval) | ||
| 1781 | return retval; | ||
| 1782 | retval = u132_periodic_reinit(u132); | ||
| 1783 | if (retval) | ||
| 1784 | return retval; | ||
| 1785 | retval = u132_read_pcimem(u132, fminterval, &fminterval); | ||
| 1786 | if (retval) | ||
| 1787 | return retval; | ||
| 1788 | retval = u132_read_pcimem(u132, periodicstart, &periodicstart); | ||
| 1789 | if (retval) | ||
| 1790 | return retval; | ||
| 1791 | if (0 == (fminterval & 0x3fff0000) || 0 == periodicstart) { | ||
| 1792 | if (!(u132->flags & OHCI_QUIRK_INITRESET)) { | ||
| 1793 | u132->flags |= OHCI_QUIRK_INITRESET; | ||
| 1794 | goto retry; | ||
| 1795 | } else | ||
| 1796 | dev_err(&u132->platform_dev->dev, "init err(%08x %04x)" | ||
| 1797 | "\n", fminterval, periodicstart); | ||
| 1798 | } /* start controller operations */ | ||
| 1799 | u132->hc_control &= OHCI_CTRL_RWC; | ||
| 1800 | u132->hc_control |= OHCI_CONTROL_INIT | OHCI_CTRL_BLE | OHCI_USB_OPER; | ||
| 1801 | retval = u132_write_pcimem(u132, control, u132->hc_control); | ||
| 1802 | if (retval) | ||
| 1803 | return retval; | ||
| 1804 | retval = u132_write_pcimem_byte(u132, cmdstatus, OHCI_BLF); | ||
| 1805 | if (retval) | ||
| 1806 | return retval; | ||
| 1807 | retval = u132_read_pcimem(u132, cmdstatus, &cmdstatus); | ||
| 1808 | if (retval) | ||
| 1809 | return retval; | ||
| 1810 | retval = u132_read_pcimem(u132, control, &control); | ||
| 1811 | if (retval) | ||
| 1812 | return retval; | ||
| 1813 | u132_to_hcd(u132)->state = HC_STATE_RUNNING; | ||
| 1814 | retval = u132_write_pcimem(u132, roothub.status, RH_HS_DRWE); | ||
| 1815 | if (retval) | ||
| 1816 | return retval; | ||
| 1817 | retval = u132_write_pcimem(u132, intrstatus, mask); | ||
| 1818 | if (retval) | ||
| 1819 | return retval; | ||
| 1820 | retval = u132_write_pcimem(u132, intrdisable, | ||
| 1821 | OHCI_INTR_MIE | OHCI_INTR_OC | OHCI_INTR_RHSC | OHCI_INTR_FNO | | ||
| 1822 | OHCI_INTR_UE | OHCI_INTR_RD | OHCI_INTR_SF | OHCI_INTR_WDH | | ||
| 1823 | OHCI_INTR_SO); | ||
| 1824 | if (retval) | ||
| 1825 | return retval; /* handle root hub init quirks ... */ | ||
| 1826 | retval = u132_read_pcimem(u132, roothub.a, &roothub_a); | ||
| 1827 | if (retval) | ||
| 1828 | return retval; | ||
| 1829 | roothub_a &= ~(RH_A_PSM | RH_A_OCPM); | ||
| 1830 | if (u132->flags & OHCI_QUIRK_SUPERIO) { | ||
| 1831 | roothub_a |= RH_A_NOCP; | ||
| 1832 | roothub_a &= ~(RH_A_POTPGT | RH_A_NPS); | ||
| 1833 | retval = u132_write_pcimem(u132, roothub.a, roothub_a); | ||
| 1834 | if (retval) | ||
| 1835 | return retval; | ||
| 1836 | } else if ((u132->flags & OHCI_QUIRK_AMD756) || distrust_firmware) { | ||
| 1837 | roothub_a |= RH_A_NPS; | ||
| 1838 | retval = u132_write_pcimem(u132, roothub.a, roothub_a); | ||
| 1839 | if (retval) | ||
| 1840 | return retval; | ||
| 1841 | } | ||
| 1842 | retval = u132_write_pcimem(u132, roothub.status, RH_HS_LPSC); | ||
| 1843 | if (retval) | ||
| 1844 | return retval; | ||
| 1845 | retval = u132_write_pcimem(u132, roothub.b, | ||
| 1846 | (roothub_a & RH_A_NPS) ? 0 : RH_B_PPCM); | ||
| 1847 | if (retval) | ||
| 1848 | return retval; | ||
| 1849 | retval = u132_read_pcimem(u132, control, &control); | ||
| 1850 | if (retval) | ||
| 1851 | return retval; | ||
| 1852 | mdelay((roothub_a >> 23) & 0x1fe); | ||
| 1853 | u132_to_hcd(u132)->state = HC_STATE_RUNNING; | ||
| 1854 | return 0; | ||
| 1855 | } | ||
| 1856 | |||
| 1857 | static void u132_hcd_stop(struct usb_hcd *hcd) | ||
| 1858 | { | ||
| 1859 | struct u132 *u132 = hcd_to_u132(hcd); | ||
| 1860 | if (u132->going > 1) { | ||
| 1861 | dev_err(&u132->platform_dev->dev, "device has been removed %d\n" | ||
| 1862 | , u132->going); | ||
| 1863 | } else if (u132->going > 0) { | ||
| 1864 | dev_err(&u132->platform_dev->dev, "device hcd=%p is being remov" | ||
| 1865 | "ed\n", hcd); | ||
| 1866 | } else { | ||
| 1867 | down(&u132->sw_lock); | ||
| 1868 | msleep(100); | ||
| 1869 | u132_power(u132, 0); | ||
| 1870 | up(&u132->sw_lock); | ||
| 1871 | } | ||
| 1872 | } | ||
| 1873 | |||
| 1874 | static int u132_hcd_start(struct usb_hcd *hcd) | ||
| 1875 | { | ||
| 1876 | struct u132 *u132 = hcd_to_u132(hcd); | ||
| 1877 | if (u132->going > 1) { | ||
| 1878 | dev_err(&u132->platform_dev->dev, "device has been removed %d\n" | ||
| 1879 | , u132->going); | ||
| 1880 | return -ENODEV; | ||
| 1881 | } else if (u132->going > 0) { | ||
| 1882 | dev_err(&u132->platform_dev->dev, "device is being removed\n"); | ||
| 1883 | return -ESHUTDOWN; | ||
| 1884 | } else if (hcd->self.controller) { | ||
| 1885 | int retval; | ||
| 1886 | struct platform_device *pdev = | ||
| 1887 | to_platform_device(hcd->self.controller); | ||
| 1888 | u16 vendor = ((struct u132_platform_data *) | ||
| 1889 | (pdev->dev.platform_data))->vendor; | ||
| 1890 | u16 device = ((struct u132_platform_data *) | ||
| 1891 | (pdev->dev.platform_data))->device; | ||
| 1892 | down(&u132->sw_lock); | ||
| 1893 | msleep(10); | ||
| 1894 | if (vendor == PCI_VENDOR_ID_AMD && device == 0x740c) { | ||
| 1895 | u132->flags = OHCI_QUIRK_AMD756; | ||
| 1896 | } else if (vendor == PCI_VENDOR_ID_OPTI && device == 0xc861) { | ||
| 1897 | dev_err(&u132->platform_dev->dev, "WARNING: OPTi workar" | ||
| 1898 | "ounds unavailable\n"); | ||
| 1899 | } else if (vendor == PCI_VENDOR_ID_COMPAQ && device == 0xa0f8) | ||
| 1900 | u132->flags |= OHCI_QUIRK_ZFMICRO; | ||
| 1901 | retval = u132_run(u132); | ||
| 1902 | if (retval) { | ||
| 1903 | u132_disable(u132); | ||
| 1904 | u132->going = 1; | ||
| 1905 | } | ||
| 1906 | msleep(100); | ||
| 1907 | up(&u132->sw_lock); | ||
| 1908 | return retval; | ||
| 1909 | } else { | ||
| 1910 | dev_err(&u132->platform_dev->dev, "platform_device missing\n"); | ||
| 1911 | return -ENODEV; | ||
| 1912 | } | ||
| 1913 | } | ||
| 1914 | |||
| 1915 | static int u132_hcd_reset(struct usb_hcd *hcd) | ||
| 1916 | { | ||
| 1917 | struct u132 *u132 = hcd_to_u132(hcd); | ||
| 1918 | if (u132->going > 1) { | ||
| 1919 | dev_err(&u132->platform_dev->dev, "device has been removed %d\n" | ||
| 1920 | , u132->going); | ||
| 1921 | return -ENODEV; | ||
| 1922 | } else if (u132->going > 0) { | ||
| 1923 | dev_err(&u132->platform_dev->dev, "device is being removed\n"); | ||
| 1924 | return -ESHUTDOWN; | ||
| 1925 | } else { | ||
| 1926 | int retval; | ||
| 1927 | down(&u132->sw_lock); | ||
| 1928 | retval = u132_init(u132); | ||
| 1929 | if (retval) { | ||
| 1930 | u132_disable(u132); | ||
| 1931 | u132->going = 1; | ||
| 1932 | } | ||
| 1933 | up(&u132->sw_lock); | ||
| 1934 | return retval; | ||
| 1935 | } | ||
| 1936 | } | ||
| 1937 | |||
| 1938 | static int create_endpoint_and_queue_int(struct u132 *u132, | ||
| 1939 | struct u132_udev *udev, struct usb_host_endpoint *hep, struct urb *urb, | ||
| 1940 | struct usb_device *usb_dev, u8 usb_addr, u8 usb_endp, u8 address, | ||
| 1941 | gfp_t mem_flags) | ||
| 1942 | { | ||
| 1943 | struct u132_ring *ring; | ||
| 1944 | unsigned long irqs; | ||
| 1945 | u8 endp_number = ++u132->num_endpoints; | ||
| 1946 | struct u132_endp *endp = hep->hcpriv = u132->endp[endp_number - 1] = | ||
| 1947 | kmalloc(sizeof(struct u132_endp), mem_flags); | ||
| 1948 | if (!endp) { | ||
| 1949 | return -ENOMEM; | ||
| 1950 | } | ||
| 1951 | INIT_WORK(&endp->scheduler, u132_hcd_endp_work_scheduler, (void *)endp); | ||
| 1952 | spin_lock_init(&endp->queue_lock.slock); | ||
| 1953 | INIT_LIST_HEAD(&endp->urb_more); | ||
| 1954 | ring = endp->ring = &u132->ring[0]; | ||
| 1955 | if (ring->curr_endp) { | ||
| 1956 | list_add_tail(&endp->endp_ring, &ring->curr_endp->endp_ring); | ||
| 1957 | } else { | ||
| 1958 | INIT_LIST_HEAD(&endp->endp_ring); | ||
| 1959 | ring->curr_endp = endp; | ||
| 1960 | } | ||
| 1961 | ring->length += 1; | ||
| 1962 | endp->dequeueing = 0; | ||
| 1963 | endp->edset_flush = 0; | ||
| 1964 | endp->active = 0; | ||
| 1965 | endp->delayed = 0; | ||
| 1966 | endp->endp_number = endp_number; | ||
| 1967 | endp->u132 = u132; | ||
| 1968 | endp->hep = hep; | ||
| 1969 | endp->pipetype = usb_pipetype(urb->pipe); | ||
| 1970 | u132_endp_init_kref(u132, endp); | ||
| 1971 | if (usb_pipein(urb->pipe)) { | ||
| 1972 | endp->toggle_bits = 0x2; | ||
| 1973 | usb_settoggle(udev->usb_device, usb_endp, 0, 0); | ||
| 1974 | endp->input = 1; | ||
| 1975 | endp->output = 0; | ||
| 1976 | udev->endp_number_in[usb_endp] = endp_number; | ||
| 1977 | u132_udev_get_kref(u132, udev); | ||
| 1978 | } else { | ||
| 1979 | endp->toggle_bits = 0x2; | ||
| 1980 | usb_settoggle(udev->usb_device, usb_endp, 1, 0); | ||
| 1981 | endp->input = 0; | ||
| 1982 | endp->output = 1; | ||
| 1983 | udev->endp_number_out[usb_endp] = endp_number; | ||
| 1984 | u132_udev_get_kref(u132, udev); | ||
| 1985 | } | ||
| 1986 | urb->hcpriv = u132; | ||
| 1987 | spin_lock_irqsave(&endp->queue_lock.slock, irqs); | ||
| 1988 | endp->delayed = 1; | ||
| 1989 | endp->jiffies = jiffies + msecs_to_jiffies(urb->interval); | ||
| 1990 | endp->udev_number = address; | ||
| 1991 | endp->usb_addr = usb_addr; | ||
| 1992 | endp->usb_endp = usb_endp; | ||
| 1993 | endp->queue_size = 1; | ||
| 1994 | endp->queue_last = 0; | ||
| 1995 | endp->queue_next = 0; | ||
| 1996 | endp->urb_list[ENDP_QUEUE_MASK & endp->queue_last++] = urb; | ||
| 1997 | spin_unlock_irqrestore(&endp->queue_lock.slock, irqs); | ||
| 1998 | u132_endp_queue_work(u132, endp, msecs_to_jiffies(urb->interval)); | ||
| 1999 | return 0; | ||
| 2000 | } | ||
| 2001 | |||
| 2002 | static int queue_int_on_old_endpoint(struct u132 *u132, struct u132_udev *udev, | ||
| 2003 | struct usb_host_endpoint *hep, struct urb *urb, | ||
| 2004 | struct usb_device *usb_dev, struct u132_endp *endp, u8 usb_addr, | ||
| 2005 | u8 usb_endp, u8 address) | ||
| 2006 | { | ||
| 2007 | urb->hcpriv = u132; | ||
| 2008 | endp->delayed = 1; | ||
| 2009 | endp->jiffies = jiffies + msecs_to_jiffies(urb->interval); | ||
| 2010 | if (endp->queue_size++ < ENDP_QUEUE_SIZE) { | ||
| 2011 | endp->urb_list[ENDP_QUEUE_MASK & endp->queue_last++] = urb; | ||
| 2012 | } else { | ||
| 2013 | struct u132_urbq *urbq = kmalloc(sizeof(struct u132_urbq), | ||
| 2014 | GFP_ATOMIC); | ||
| 2015 | if (urbq == NULL) { | ||
| 2016 | endp->queue_size -= 1; | ||
| 2017 | return -ENOMEM; | ||
| 2018 | } else { | ||
| 2019 | list_add_tail(&urbq->urb_more, &endp->urb_more); | ||
| 2020 | urbq->urb = urb; | ||
| 2021 | } | ||
| 2022 | } | ||
| 2023 | return 0; | ||
| 2024 | } | ||
| 2025 | |||
| 2026 | static int create_endpoint_and_queue_bulk(struct u132 *u132, | ||
| 2027 | struct u132_udev *udev, struct usb_host_endpoint *hep, struct urb *urb, | ||
| 2028 | struct usb_device *usb_dev, u8 usb_addr, u8 usb_endp, u8 address, | ||
| 2029 | gfp_t mem_flags) | ||
| 2030 | { | ||
| 2031 | int ring_number; | ||
| 2032 | struct u132_ring *ring; | ||
| 2033 | unsigned long irqs; | ||
| 2034 | u8 endp_number = ++u132->num_endpoints; | ||
| 2035 | struct u132_endp *endp = hep->hcpriv = u132->endp[endp_number - 1] = | ||
| 2036 | kmalloc(sizeof(struct u132_endp), mem_flags); | ||
| 2037 | if (!endp) { | ||
| 2038 | return -ENOMEM; | ||
| 2039 | } | ||
| 2040 | INIT_WORK(&endp->scheduler, u132_hcd_endp_work_scheduler, (void *)endp); | ||
| 2041 | spin_lock_init(&endp->queue_lock.slock); | ||
| 2042 | INIT_LIST_HEAD(&endp->urb_more); | ||
| 2043 | endp->dequeueing = 0; | ||
| 2044 | endp->edset_flush = 0; | ||
| 2045 | endp->active = 0; | ||
| 2046 | endp->delayed = 0; | ||
| 2047 | endp->endp_number = endp_number; | ||
| 2048 | endp->u132 = u132; | ||
| 2049 | endp->hep = hep; | ||
| 2050 | endp->pipetype = usb_pipetype(urb->pipe); | ||
| 2051 | u132_endp_init_kref(u132, endp); | ||
| 2052 | if (usb_pipein(urb->pipe)) { | ||
| 2053 | endp->toggle_bits = 0x2; | ||
| 2054 | usb_settoggle(udev->usb_device, usb_endp, 0, 0); | ||
| 2055 | ring_number = 3; | ||
| 2056 | endp->input = 1; | ||
| 2057 | endp->output = 0; | ||
| 2058 | udev->endp_number_in[usb_endp] = endp_number; | ||
| 2059 | u132_udev_get_kref(u132, udev); | ||
| 2060 | } else { | ||
| 2061 | endp->toggle_bits = 0x2; | ||
| 2062 | usb_settoggle(udev->usb_device, usb_endp, 1, 0); | ||
| 2063 | ring_number = 2; | ||
| 2064 | endp->input = 0; | ||
| 2065 | endp->output = 1; | ||
| 2066 | udev->endp_number_out[usb_endp] = endp_number; | ||
| 2067 | u132_udev_get_kref(u132, udev); | ||
| 2068 | } | ||
| 2069 | ring = endp->ring = &u132->ring[ring_number - 1]; | ||
| 2070 | if (ring->curr_endp) { | ||
| 2071 | list_add_tail(&endp->endp_ring, &ring->curr_endp->endp_ring); | ||
| 2072 | } else { | ||
| 2073 | INIT_LIST_HEAD(&endp->endp_ring); | ||
| 2074 | ring->curr_endp = endp; | ||
| 2075 | } | ||
| 2076 | ring->length += 1; | ||
| 2077 | urb->hcpriv = u132; | ||
| 2078 | spin_lock_irqsave(&endp->queue_lock.slock, irqs); | ||
| 2079 | endp->udev_number = address; | ||
| 2080 | endp->usb_addr = usb_addr; | ||
| 2081 | endp->usb_endp = usb_endp; | ||
| 2082 | endp->queue_size = 1; | ||
| 2083 | endp->queue_last = 0; | ||
| 2084 | endp->queue_next = 0; | ||
| 2085 | endp->urb_list[ENDP_QUEUE_MASK & endp->queue_last++] = urb; | ||
| 2086 | spin_unlock_irqrestore(&endp->queue_lock.slock, irqs); | ||
| 2087 | u132_endp_queue_work(u132, endp, 0); | ||
| 2088 | return 0; | ||
| 2089 | } | ||
| 2090 | |||
| 2091 | static int queue_bulk_on_old_endpoint(struct u132 *u132, struct u132_udev *udev, | ||
| 2092 | struct usb_host_endpoint *hep, struct urb *urb, | ||
| 2093 | struct usb_device *usb_dev, struct u132_endp *endp, u8 usb_addr, | ||
| 2094 | u8 usb_endp, u8 address) | ||
| 2095 | { | ||
| 2096 | urb->hcpriv = u132; | ||
| 2097 | if (endp->queue_size++ < ENDP_QUEUE_SIZE) { | ||
| 2098 | endp->urb_list[ENDP_QUEUE_MASK & endp->queue_last++] = urb; | ||
| 2099 | } else { | ||
| 2100 | struct u132_urbq *urbq = kmalloc(sizeof(struct u132_urbq), | ||
| 2101 | GFP_ATOMIC); | ||
| 2102 | if (urbq == NULL) { | ||
| 2103 | endp->queue_size -= 1; | ||
| 2104 | return -ENOMEM; | ||
| 2105 | } else { | ||
| 2106 | list_add_tail(&urbq->urb_more, &endp->urb_more); | ||
| 2107 | urbq->urb = urb; | ||
| 2108 | } | ||
| 2109 | } | ||
| 2110 | return 0; | ||
| 2111 | } | ||
| 2112 | |||
| 2113 | static int create_endpoint_and_queue_control(struct u132 *u132, | ||
| 2114 | struct usb_host_endpoint *hep, struct urb *urb, | ||
| 2115 | struct usb_device *usb_dev, u8 usb_addr, u8 usb_endp, | ||
| 2116 | gfp_t mem_flags) | ||
| 2117 | { | ||
| 2118 | struct u132_ring *ring; | ||
| 2119 | u8 endp_number = ++u132->num_endpoints; | ||
| 2120 | struct u132_endp *endp = hep->hcpriv = u132->endp[endp_number - 1] = | ||
| 2121 | kmalloc(sizeof(struct u132_endp), mem_flags); | ||
| 2122 | if (!endp) { | ||
| 2123 | return -ENOMEM; | ||
| 2124 | } | ||
| 2125 | INIT_WORK(&endp->scheduler, u132_hcd_endp_work_scheduler, (void *)endp); | ||
| 2126 | spin_lock_init(&endp->queue_lock.slock); | ||
| 2127 | INIT_LIST_HEAD(&endp->urb_more); | ||
| 2128 | ring = endp->ring = &u132->ring[0]; | ||
| 2129 | if (ring->curr_endp) { | ||
| 2130 | list_add_tail(&endp->endp_ring, &ring->curr_endp->endp_ring); | ||
| 2131 | } else { | ||
| 2132 | INIT_LIST_HEAD(&endp->endp_ring); | ||
| 2133 | ring->curr_endp = endp; | ||
| 2134 | } | ||
| 2135 | ring->length += 1; | ||
| 2136 | endp->dequeueing = 0; | ||
| 2137 | endp->edset_flush = 0; | ||
| 2138 | endp->active = 0; | ||
| 2139 | endp->delayed = 0; | ||
| 2140 | endp->endp_number = endp_number; | ||
| 2141 | endp->u132 = u132; | ||
| 2142 | endp->hep = hep; | ||
| 2143 | u132_endp_init_kref(u132, endp); | ||
| 2144 | u132_endp_get_kref(u132, endp); | ||
| 2145 | if (usb_addr == 0) { | ||
| 2146 | unsigned long irqs; | ||
| 2147 | u8 address = u132->addr[usb_addr].address; | ||
| 2148 | struct u132_udev *udev = &u132->udev[address]; | ||
| 2149 | endp->udev_number = address; | ||
| 2150 | endp->usb_addr = usb_addr; | ||
| 2151 | endp->usb_endp = usb_endp; | ||
| 2152 | endp->input = 1; | ||
| 2153 | endp->output = 1; | ||
| 2154 | endp->pipetype = usb_pipetype(urb->pipe); | ||
| 2155 | u132_udev_init_kref(u132, udev); | ||
| 2156 | u132_udev_get_kref(u132, udev); | ||
| 2157 | udev->endp_number_in[usb_endp] = endp_number; | ||
| 2158 | udev->endp_number_out[usb_endp] = endp_number; | ||
| 2159 | urb->hcpriv = u132; | ||
| 2160 | spin_lock_irqsave(&endp->queue_lock.slock, irqs); | ||
| 2161 | endp->queue_size = 1; | ||
| 2162 | endp->queue_last = 0; | ||
| 2163 | endp->queue_next = 0; | ||
| 2164 | endp->urb_list[ENDP_QUEUE_MASK & endp->queue_last++] = urb; | ||
| 2165 | spin_unlock_irqrestore(&endp->queue_lock.slock, irqs); | ||
| 2166 | u132_endp_queue_work(u132, endp, 0); | ||
| 2167 | return 0; | ||
| 2168 | } else { /*(usb_addr > 0) */ | ||
| 2169 | unsigned long irqs; | ||
| 2170 | u8 address = u132->addr[usb_addr].address; | ||
| 2171 | struct u132_udev *udev = &u132->udev[address]; | ||
| 2172 | endp->udev_number = address; | ||
| 2173 | endp->usb_addr = usb_addr; | ||
| 2174 | endp->usb_endp = usb_endp; | ||
| 2175 | endp->input = 1; | ||
| 2176 | endp->output = 1; | ||
| 2177 | endp->pipetype = usb_pipetype(urb->pipe); | ||
| 2178 | u132_udev_get_kref(u132, udev); | ||
| 2179 | udev->enumeration = 2; | ||
| 2180 | udev->endp_number_in[usb_endp] = endp_number; | ||
| 2181 | udev->endp_number_out[usb_endp] = endp_number; | ||
| 2182 | urb->hcpriv = u132; | ||
| 2183 | spin_lock_irqsave(&endp->queue_lock.slock, irqs); | ||
| 2184 | endp->queue_size = 1; | ||
| 2185 | endp->queue_last = 0; | ||
| 2186 | endp->queue_next = 0; | ||
| 2187 | endp->urb_list[ENDP_QUEUE_MASK & endp->queue_last++] = urb; | ||
| 2188 | spin_unlock_irqrestore(&endp->queue_lock.slock, irqs); | ||
| 2189 | u132_endp_queue_work(u132, endp, 0); | ||
| 2190 | return 0; | ||
| 2191 | } | ||
| 2192 | } | ||
| 2193 | |||
| 2194 | static int queue_control_on_old_endpoint(struct u132 *u132, | ||
| 2195 | struct usb_host_endpoint *hep, struct urb *urb, | ||
| 2196 | struct usb_device *usb_dev, struct u132_endp *endp, u8 usb_addr, | ||
| 2197 | u8 usb_endp) | ||
| 2198 | { | ||
| 2199 | if (usb_addr == 0) { | ||
| 2200 | if (usb_pipein(urb->pipe)) { | ||
| 2201 | urb->hcpriv = u132; | ||
| 2202 | if (endp->queue_size++ < ENDP_QUEUE_SIZE) { | ||
| 2203 | endp->urb_list[ENDP_QUEUE_MASK & | ||
| 2204 | endp->queue_last++] = urb; | ||
| 2205 | } else { | ||
| 2206 | struct u132_urbq *urbq = | ||
| 2207 | kmalloc(sizeof(struct u132_urbq), | ||
| 2208 | GFP_ATOMIC); | ||
| 2209 | if (urbq == NULL) { | ||
| 2210 | endp->queue_size -= 1; | ||
| 2211 | return -ENOMEM; | ||
| 2212 | } else { | ||
| 2213 | list_add_tail(&urbq->urb_more, | ||
| 2214 | &endp->urb_more); | ||
| 2215 | urbq->urb = urb; | ||
| 2216 | } | ||
| 2217 | } | ||
| 2218 | return 0; | ||
| 2219 | } else { /* usb_pipeout(urb->pipe) */ | ||
| 2220 | struct u132_addr *addr = &u132->addr[usb_dev->devnum]; | ||
| 2221 | int I = MAX_U132_UDEVS; | ||
| 2222 | int i = 0; | ||
| 2223 | while (--I > 0) { | ||
| 2224 | struct u132_udev *udev = &u132->udev[++i]; | ||
| 2225 | if (udev->usb_device) { | ||
| 2226 | continue; | ||
| 2227 | } else { | ||
| 2228 | udev->enumeration = 1; | ||
| 2229 | u132->addr[0].address = i; | ||
| 2230 | endp->udev_number = i; | ||
| 2231 | udev->udev_number = i; | ||
| 2232 | udev->usb_addr = usb_dev->devnum; | ||
| 2233 | u132_udev_init_kref(u132, udev); | ||
| 2234 | udev->endp_number_in[usb_endp] = | ||
| 2235 | endp->endp_number; | ||
| 2236 | u132_udev_get_kref(u132, udev); | ||
| 2237 | udev->endp_number_out[usb_endp] = | ||
| 2238 | endp->endp_number; | ||
| 2239 | udev->usb_device = usb_dev; | ||
| 2240 | ((u8 *) (urb->setup_packet))[2] = | ||
| 2241 | addr->address = i; | ||
| 2242 | u132_udev_get_kref(u132, udev); | ||
| 2243 | break; | ||
| 2244 | } | ||
| 2245 | } | ||
| 2246 | if (I == 0) { | ||
| 2247 | dev_err(&u132->platform_dev->dev, "run out of d" | ||
| 2248 | "evice space\n"); | ||
| 2249 | return -EINVAL; | ||
| 2250 | } | ||
| 2251 | urb->hcpriv = u132; | ||
| 2252 | if (endp->queue_size++ < ENDP_QUEUE_SIZE) { | ||
| 2253 | endp->urb_list[ENDP_QUEUE_MASK & | ||
| 2254 | endp->queue_last++] = urb; | ||
| 2255 | } else { | ||
| 2256 | struct u132_urbq *urbq = | ||
| 2257 | kmalloc(sizeof(struct u132_urbq), | ||
| 2258 | GFP_ATOMIC); | ||
| 2259 | if (urbq == NULL) { | ||
| 2260 | endp->queue_size -= 1; | ||
| 2261 | return -ENOMEM; | ||
| 2262 | } else { | ||
| 2263 | list_add_tail(&urbq->urb_more, | ||
| 2264 | &endp->urb_more); | ||
| 2265 | urbq->urb = urb; | ||
| 2266 | } | ||
| 2267 | } | ||
| 2268 | return 0; | ||
| 2269 | } | ||
| 2270 | } else { /*(usb_addr > 0) */ | ||
| 2271 | u8 address = u132->addr[usb_addr].address; | ||
| 2272 | struct u132_udev *udev = &u132->udev[address]; | ||
| 2273 | urb->hcpriv = u132; | ||
| 2274 | if (udev->enumeration == 2) { | ||
| 2275 | } else | ||
| 2276 | udev->enumeration = 2; | ||
| 2277 | if (endp->queue_size++ < ENDP_QUEUE_SIZE) { | ||
| 2278 | endp->urb_list[ENDP_QUEUE_MASK & endp->queue_last++] = | ||
| 2279 | urb; | ||
| 2280 | } else { | ||
| 2281 | struct u132_urbq *urbq = | ||
| 2282 | kmalloc(sizeof(struct u132_urbq), GFP_ATOMIC); | ||
| 2283 | if (urbq == NULL) { | ||
| 2284 | endp->queue_size -= 1; | ||
| 2285 | return -ENOMEM; | ||
| 2286 | } else { | ||
| 2287 | list_add_tail(&urbq->urb_more, &endp->urb_more); | ||
| 2288 | urbq->urb = urb; | ||
| 2289 | } | ||
| 2290 | } | ||
| 2291 | return 0; | ||
| 2292 | } | ||
| 2293 | } | ||
| 2294 | |||
| 2295 | static int u132_urb_enqueue(struct usb_hcd *hcd, struct usb_host_endpoint *hep, | ||
| 2296 | struct urb *urb, gfp_t mem_flags) | ||
| 2297 | { | ||
| 2298 | struct u132 *u132 = hcd_to_u132(hcd); | ||
| 2299 | if (irqs_disabled()) { | ||
| 2300 | if (__GFP_WAIT & mem_flags) { | ||
| 2301 | printk(KERN_ERR "invalid context for function that migh" | ||
| 2302 | "t sleep\n"); | ||
| 2303 | return -EINVAL; | ||
| 2304 | } | ||
| 2305 | } | ||
| 2306 | if (u132->going > 1) { | ||
| 2307 | dev_err(&u132->platform_dev->dev, "device has been removed %d\n" | ||
| 2308 | , u132->going); | ||
| 2309 | return -ENODEV; | ||
| 2310 | } else if (u132->going > 0) { | ||
| 2311 | dev_err(&u132->platform_dev->dev, "device is being removed urb=" | ||
| 2312 | "%p status=%d\n", urb, urb->status); | ||
| 2313 | return -ESHUTDOWN; | ||
| 2314 | } else { | ||
| 2315 | u8 usb_addr = usb_pipedevice(urb->pipe); | ||
| 2316 | u8 usb_endp = usb_pipeendpoint(urb->pipe); | ||
| 2317 | struct usb_device *usb_dev = urb->dev; | ||
| 2318 | if (usb_pipetype(urb->pipe) == PIPE_INTERRUPT) { | ||
| 2319 | u8 address = u132->addr[usb_addr].address; | ||
| 2320 | struct u132_udev *udev = &u132->udev[address]; | ||
| 2321 | struct u132_endp *endp = hep->hcpriv; | ||
| 2322 | urb->actual_length = 0; | ||
| 2323 | if (endp) { | ||
| 2324 | unsigned long irqs; | ||
| 2325 | int retval; | ||
| 2326 | spin_lock_irqsave(&endp->queue_lock.slock, | ||
| 2327 | irqs); | ||
| 2328 | retval = queue_int_on_old_endpoint(u132, udev, | ||
| 2329 | hep, urb, usb_dev, endp, usb_addr, | ||
| 2330 | usb_endp, address); | ||
| 2331 | spin_unlock_irqrestore(&endp->queue_lock.slock, | ||
| 2332 | irqs); | ||
| 2333 | if (retval) { | ||
| 2334 | return retval; | ||
| 2335 | } else { | ||
| 2336 | u132_endp_queue_work(u132, endp, | ||
| 2337 | msecs_to_jiffies(urb->interval)) | ||
| 2338 | ; | ||
| 2339 | return 0; | ||
| 2340 | } | ||
| 2341 | } else if (u132->num_endpoints == MAX_U132_ENDPS) { | ||
| 2342 | return -EINVAL; | ||
| 2343 | } else { /*(endp == NULL) */ | ||
| 2344 | return create_endpoint_and_queue_int(u132, udev, | ||
| 2345 | hep, urb, usb_dev, usb_addr, usb_endp, | ||
| 2346 | address, mem_flags); | ||
| 2347 | } | ||
| 2348 | } else if (usb_pipetype(urb->pipe) == PIPE_ISOCHRONOUS) { | ||
| 2349 | dev_err(&u132->platform_dev->dev, "the hardware does no" | ||
| 2350 | "t support PIPE_ISOCHRONOUS\n"); | ||
| 2351 | return -EINVAL; | ||
| 2352 | } else if (usb_pipetype(urb->pipe) == PIPE_BULK) { | ||
| 2353 | u8 address = u132->addr[usb_addr].address; | ||
| 2354 | struct u132_udev *udev = &u132->udev[address]; | ||
| 2355 | struct u132_endp *endp = hep->hcpriv; | ||
| 2356 | urb->actual_length = 0; | ||
| 2357 | if (endp) { | ||
| 2358 | unsigned long irqs; | ||
| 2359 | int retval; | ||
| 2360 | spin_lock_irqsave(&endp->queue_lock.slock, | ||
| 2361 | irqs); | ||
| 2362 | retval = queue_bulk_on_old_endpoint(u132, udev, | ||
| 2363 | hep, urb, usb_dev, endp, usb_addr, | ||
| 2364 | usb_endp, address); | ||
| 2365 | spin_unlock_irqrestore(&endp->queue_lock.slock, | ||
| 2366 | irqs); | ||
| 2367 | if (retval) { | ||
| 2368 | return retval; | ||
| 2369 | } else { | ||
| 2370 | u132_endp_queue_work(u132, endp, 0); | ||
| 2371 | return 0; | ||
| 2372 | } | ||
| 2373 | } else if (u132->num_endpoints == MAX_U132_ENDPS) { | ||
| 2374 | return -EINVAL; | ||
| 2375 | } else | ||
| 2376 | return create_endpoint_and_queue_bulk(u132, | ||
| 2377 | udev, hep, urb, usb_dev, usb_addr, | ||
| 2378 | usb_endp, address, mem_flags); | ||
| 2379 | } else { | ||
| 2380 | struct u132_endp *endp = hep->hcpriv; | ||
| 2381 | u16 urb_size = 8; | ||
| 2382 | u8 *b = urb->setup_packet; | ||
| 2383 | int i = 0; | ||
| 2384 | char data[30 *3 + 4]; | ||
| 2385 | char *d = data; | ||
| 2386 | int m = (sizeof(data) - 1) / 3; | ||
| 2387 | int l = 0; | ||
| 2388 | data[0] = 0; | ||
| 2389 | while (urb_size-- > 0) { | ||
| 2390 | if (i > m) { | ||
| 2391 | } else if (i++ < m) { | ||
| 2392 | int w = sprintf(d, " %02X", *b++); | ||
| 2393 | d += w; | ||
| 2394 | l += w; | ||
| 2395 | } else | ||
| 2396 | d += sprintf(d, " .."); | ||
| 2397 | } | ||
| 2398 | if (endp) { | ||
| 2399 | unsigned long irqs; | ||
| 2400 | int retval; | ||
| 2401 | spin_lock_irqsave(&endp->queue_lock.slock, | ||
| 2402 | irqs); | ||
| 2403 | retval = queue_control_on_old_endpoint(u132, | ||
| 2404 | hep, urb, usb_dev, endp, usb_addr, | ||
| 2405 | usb_endp); | ||
| 2406 | spin_unlock_irqrestore(&endp->queue_lock.slock, | ||
| 2407 | irqs); | ||
| 2408 | if (retval) { | ||
| 2409 | return retval; | ||
| 2410 | } else { | ||
| 2411 | u132_endp_queue_work(u132, endp, 0); | ||
| 2412 | return 0; | ||
| 2413 | } | ||
| 2414 | } else if (u132->num_endpoints == MAX_U132_ENDPS) { | ||
| 2415 | return -EINVAL; | ||
| 2416 | } else | ||
| 2417 | return create_endpoint_and_queue_control(u132, | ||
| 2418 | hep, urb, usb_dev, usb_addr, usb_endp, | ||
| 2419 | mem_flags); | ||
| 2420 | } | ||
| 2421 | } | ||
| 2422 | } | ||
| 2423 | |||
| 2424 | static int dequeue_from_overflow_chain(struct u132 *u132, | ||
| 2425 | struct u132_endp *endp, struct urb *urb) | ||
| 2426 | { | ||
| 2427 | struct list_head *scan; | ||
| 2428 | struct list_head *head = &endp->urb_more; | ||
| 2429 | list_for_each(scan, head) { | ||
| 2430 | struct u132_urbq *urbq = list_entry(scan, struct u132_urbq, | ||
| 2431 | urb_more); | ||
| 2432 | if (urbq->urb == urb) { | ||
| 2433 | struct usb_hcd *hcd = u132_to_hcd(u132); | ||
| 2434 | list_del(scan); | ||
| 2435 | endp->queue_size -= 1; | ||
| 2436 | urb->error_count = 0; | ||
| 2437 | urb->hcpriv = NULL; | ||
| 2438 | usb_hcd_giveback_urb(hcd, urb, NULL); | ||
| 2439 | return 0; | ||
| 2440 | } else | ||
| 2441 | continue; | ||
| 2442 | } | ||
| 2443 | dev_err(&u132->platform_dev->dev, "urb=%p not found in endp[%d]=%p ring" | ||
| 2444 | "[%d] %c%c usb_endp=%d usb_addr=%d size=%d next=%04X last=%04X" | ||
| 2445 | "\n", urb, endp->endp_number, endp, endp->ring->number, | ||
| 2446 | endp->input ? 'I' : ' ', endp->output ? 'O' : ' ', | ||
| 2447 | endp->usb_endp, endp->usb_addr, endp->queue_size, | ||
| 2448 | endp->queue_next, endp->queue_last); | ||
| 2449 | return -EINVAL; | ||
| 2450 | } | ||
| 2451 | |||
| 2452 | static int u132_endp_urb_dequeue(struct u132 *u132, struct u132_endp *endp, | ||
| 2453 | struct urb *urb) | ||
| 2454 | { | ||
| 2455 | unsigned long irqs; | ||
| 2456 | spin_lock_irqsave(&endp->queue_lock.slock, irqs); | ||
| 2457 | if (endp->queue_size == 0) { | ||
| 2458 | dev_err(&u132->platform_dev->dev, "urb=%p not found in endp[%d]" | ||
| 2459 | "=%p ring[%d] %c%c usb_endp=%d usb_addr=%d\n", urb, | ||
| 2460 | endp->endp_number, endp, endp->ring->number, | ||
| 2461 | endp->input ? 'I' : ' ', endp->output ? 'O' : ' ', | ||
| 2462 | endp->usb_endp, endp->usb_addr); | ||
| 2463 | spin_unlock_irqrestore(&endp->queue_lock.slock, irqs); | ||
| 2464 | return -EINVAL; | ||
| 2465 | } | ||
| 2466 | if (urb == endp->urb_list[ENDP_QUEUE_MASK & endp->queue_next]) { | ||
| 2467 | if (endp->active) { | ||
| 2468 | endp->dequeueing = 1; | ||
| 2469 | endp->edset_flush = 1; | ||
| 2470 | u132_endp_queue_work(u132, endp, 0); | ||
| 2471 | spin_unlock_irqrestore(&endp->queue_lock.slock, irqs); | ||
| 2472 | urb->hcpriv = NULL; | ||
| 2473 | return 0; | ||
| 2474 | } else { | ||
| 2475 | spin_unlock_irqrestore(&endp->queue_lock.slock, irqs); | ||
| 2476 | u132_hcd_abandon_urb(u132, endp, urb, urb->status); | ||
| 2477 | return 0; | ||
| 2478 | } | ||
| 2479 | } else { | ||
| 2480 | u16 queue_list = 0; | ||
| 2481 | u16 queue_size = endp->queue_size; | ||
| 2482 | u16 queue_scan = endp->queue_next; | ||
| 2483 | struct urb **urb_slot = NULL; | ||
| 2484 | while (++queue_list < ENDP_QUEUE_SIZE && --queue_size > 0) { | ||
| 2485 | if (urb == endp->urb_list[ENDP_QUEUE_MASK & | ||
| 2486 | ++queue_scan]) { | ||
| 2487 | urb_slot = &endp->urb_list[ENDP_QUEUE_MASK & | ||
| 2488 | queue_scan]; | ||
| 2489 | break; | ||
| 2490 | } else | ||
| 2491 | continue; | ||
| 2492 | } | ||
| 2493 | while (++queue_list < ENDP_QUEUE_SIZE && --queue_size > 0) { | ||
| 2494 | *urb_slot = endp->urb_list[ENDP_QUEUE_MASK & | ||
| 2495 | ++queue_scan]; | ||
| 2496 | urb_slot = &endp->urb_list[ENDP_QUEUE_MASK & | ||
| 2497 | queue_scan]; | ||
| 2498 | } | ||
| 2499 | if (urb_slot) { | ||
| 2500 | struct usb_hcd *hcd = u132_to_hcd(u132); | ||
| 2501 | endp->queue_size -= 1; | ||
| 2502 | if (list_empty(&endp->urb_more)) { | ||
| 2503 | spin_unlock_irqrestore(&endp->queue_lock.slock, | ||
| 2504 | irqs); | ||
| 2505 | } else { | ||
| 2506 | struct list_head *next = endp->urb_more.next; | ||
| 2507 | struct u132_urbq *urbq = list_entry(next, | ||
| 2508 | struct u132_urbq, urb_more); | ||
| 2509 | list_del(next); | ||
| 2510 | *urb_slot = urbq->urb; | ||
| 2511 | spin_unlock_irqrestore(&endp->queue_lock.slock, | ||
| 2512 | irqs); | ||
| 2513 | kfree(urbq); | ||
| 2514 | } urb->error_count = 0; | ||
| 2515 | urb->hcpriv = NULL; | ||
| 2516 | usb_hcd_giveback_urb(hcd, urb, NULL); | ||
| 2517 | return 0; | ||
| 2518 | } else if (list_empty(&endp->urb_more)) { | ||
| 2519 | dev_err(&u132->platform_dev->dev, "urb=%p not found in " | ||
| 2520 | "endp[%d]=%p ring[%d] %c%c usb_endp=%d usb_addr" | ||
| 2521 | "=%d size=%d next=%04X last=%04X\n", urb, | ||
| 2522 | endp->endp_number, endp, endp->ring->number, | ||
| 2523 | endp->input ? 'I' : ' ', | ||
| 2524 | endp->output ? 'O' : ' ', endp->usb_endp, | ||
| 2525 | endp->usb_addr, endp->queue_size, | ||
| 2526 | endp->queue_next, endp->queue_last); | ||
| 2527 | spin_unlock_irqrestore(&endp->queue_lock.slock, irqs); | ||
| 2528 | return -EINVAL; | ||
| 2529 | } else { | ||
| 2530 | int retval = dequeue_from_overflow_chain(u132, endp, | ||
| 2531 | urb); | ||
| 2532 | spin_unlock_irqrestore(&endp->queue_lock.slock, irqs); | ||
| 2533 | return retval; | ||
| 2534 | } | ||
| 2535 | } | ||
| 2536 | } | ||
| 2537 | |||
| 2538 | static int u132_urb_dequeue(struct usb_hcd *hcd, struct urb *urb) | ||
| 2539 | { | ||
| 2540 | struct u132 *u132 = hcd_to_u132(hcd); | ||
| 2541 | if (u132->going > 2) { | ||
| 2542 | dev_err(&u132->platform_dev->dev, "device has been removed %d\n" | ||
| 2543 | , u132->going); | ||
| 2544 | return -ENODEV; | ||
| 2545 | } else { | ||
| 2546 | u8 usb_addr = usb_pipedevice(urb->pipe); | ||
| 2547 | u8 usb_endp = usb_pipeendpoint(urb->pipe); | ||
| 2548 | u8 address = u132->addr[usb_addr].address; | ||
| 2549 | struct u132_udev *udev = &u132->udev[address]; | ||
| 2550 | if (usb_pipein(urb->pipe)) { | ||
| 2551 | u8 endp_number = udev->endp_number_in[usb_endp]; | ||
| 2552 | struct u132_endp *endp = u132->endp[endp_number - 1]; | ||
| 2553 | return u132_endp_urb_dequeue(u132, endp, urb); | ||
| 2554 | } else { | ||
| 2555 | u8 endp_number = udev->endp_number_out[usb_endp]; | ||
| 2556 | struct u132_endp *endp = u132->endp[endp_number - 1]; | ||
| 2557 | return u132_endp_urb_dequeue(u132, endp, urb); | ||
| 2558 | } | ||
| 2559 | } | ||
| 2560 | } | ||
| 2561 | |||
| 2562 | static void u132_endpoint_disable(struct usb_hcd *hcd, | ||
| 2563 | struct usb_host_endpoint *hep) | ||
| 2564 | { | ||
| 2565 | struct u132 *u132 = hcd_to_u132(hcd); | ||
| 2566 | if (u132->going > 2) { | ||
| 2567 | dev_err(&u132->platform_dev->dev, "device has been removed %d\n" | ||
| 2568 | , u132->going); | ||
| 2569 | } else { | ||
| 2570 | struct u132_endp *endp = hep->hcpriv; | ||
| 2571 | if (endp) | ||
| 2572 | u132_endp_put_kref(u132, endp); | ||
| 2573 | } | ||
| 2574 | } | ||
| 2575 | |||
| 2576 | static int u132_get_frame(struct usb_hcd *hcd) | ||
| 2577 | { | ||
| 2578 | struct u132 *u132 = hcd_to_u132(hcd); | ||
| 2579 | if (u132->going > 1) { | ||
| 2580 | dev_err(&u132->platform_dev->dev, "device has been removed %d\n" | ||
| 2581 | , u132->going); | ||
| 2582 | return -ENODEV; | ||
| 2583 | } else if (u132->going > 0) { | ||
| 2584 | dev_err(&u132->platform_dev->dev, "device is being removed\n"); | ||
| 2585 | return -ESHUTDOWN; | ||
| 2586 | } else { | ||
| 2587 | int frame = 0; | ||
| 2588 | dev_err(&u132->platform_dev->dev, "TODO: u132_get_frame\n"); | ||
| 2589 | msleep(100); | ||
| 2590 | return frame; | ||
| 2591 | } | ||
| 2592 | } | ||
| 2593 | |||
| 2594 | static int u132_roothub_descriptor(struct u132 *u132, | ||
| 2595 | struct usb_hub_descriptor *desc) | ||
| 2596 | { | ||
| 2597 | int retval; | ||
| 2598 | u16 temp; | ||
| 2599 | u32 rh_a = -1; | ||
| 2600 | u32 rh_b = -1; | ||
| 2601 | retval = u132_read_pcimem(u132, roothub.a, &rh_a); | ||
| 2602 | if (retval) | ||
| 2603 | return retval; | ||
| 2604 | desc->bDescriptorType = 0x29; | ||
| 2605 | desc->bPwrOn2PwrGood = (rh_a & RH_A_POTPGT) >> 24; | ||
| 2606 | desc->bHubContrCurrent = 0; | ||
| 2607 | desc->bNbrPorts = u132->num_ports; | ||
| 2608 | temp = 1 + (u132->num_ports / 8); | ||
| 2609 | desc->bDescLength = 7 + 2 *temp; | ||
| 2610 | temp = 0; | ||
| 2611 | if (rh_a & RH_A_NPS) | ||
| 2612 | temp |= 0x0002; | ||
| 2613 | if (rh_a & RH_A_PSM) | ||
| 2614 | temp |= 0x0001; | ||
| 2615 | if (rh_a & RH_A_NOCP) { | ||
| 2616 | temp |= 0x0010; | ||
| 2617 | } else if (rh_a & RH_A_OCPM) | ||
| 2618 | temp |= 0x0008; | ||
| 2619 | desc->wHubCharacteristics = cpu_to_le16(temp); | ||
| 2620 | retval = u132_read_pcimem(u132, roothub.b, &rh_b); | ||
| 2621 | if (retval) | ||
| 2622 | return retval; | ||
| 2623 | memset(desc->bitmap, 0xff, sizeof(desc->bitmap)); | ||
| 2624 | desc->bitmap[0] = rh_b & RH_B_DR; | ||
| 2625 | if (u132->num_ports > 7) { | ||
| 2626 | desc->bitmap[1] = (rh_b & RH_B_DR) >> 8; | ||
| 2627 | desc->bitmap[2] = 0xff; | ||
| 2628 | } else | ||
| 2629 | desc->bitmap[1] = 0xff; | ||
| 2630 | return 0; | ||
| 2631 | } | ||
| 2632 | |||
| 2633 | static int u132_roothub_status(struct u132 *u132, __le32 *desc) | ||
| 2634 | { | ||
| 2635 | u32 rh_status = -1; | ||
| 2636 | int ret_status = u132_read_pcimem(u132, roothub.status, &rh_status); | ||
| 2637 | *desc = cpu_to_le32(rh_status); | ||
| 2638 | return ret_status; | ||
| 2639 | } | ||
| 2640 | |||
| 2641 | static int u132_roothub_portstatus(struct u132 *u132, __le32 *desc, u16 wIndex) | ||
| 2642 | { | ||
| 2643 | if (wIndex == 0 || wIndex > u132->num_ports) { | ||
| 2644 | return -EINVAL; | ||
| 2645 | } else { | ||
| 2646 | int port = wIndex - 1; | ||
| 2647 | u32 rh_portstatus = -1; | ||
| 2648 | int ret_portstatus = u132_read_pcimem(u132, | ||
| 2649 | roothub.portstatus[port], &rh_portstatus); | ||
| 2650 | *desc = cpu_to_le32(rh_portstatus); | ||
| 2651 | if (*(u16 *) (desc + 2)) { | ||
| 2652 | dev_info(&u132->platform_dev->dev, "Port %d Status Chan" | ||
| 2653 | "ge = %08X\n", port, *desc); | ||
| 2654 | } | ||
| 2655 | return ret_portstatus; | ||
| 2656 | } | ||
| 2657 | } | ||
| 2658 | |||
| 2659 | |||
| 2660 | /* this timer value might be vendor-specific ... */ | ||
| 2661 | #define PORT_RESET_HW_MSEC 10 | ||
| 2662 | #define PORT_RESET_MSEC 10 | ||
| 2663 | /* wrap-aware logic morphed from <linux/jiffies.h> */ | ||
| 2664 | #define tick_before(t1, t2) ((s16)(((s16)(t1))-((s16)(t2))) < 0) | ||
| 2665 | static int u132_roothub_portreset(struct u132 *u132, int port_index) | ||
| 2666 | { | ||
| 2667 | int retval; | ||
| 2668 | u32 fmnumber; | ||
| 2669 | u16 now; | ||
| 2670 | u16 reset_done; | ||
| 2671 | retval = u132_read_pcimem(u132, fmnumber, &fmnumber); | ||
| 2672 | if (retval) | ||
| 2673 | return retval; | ||
| 2674 | now = fmnumber; | ||
| 2675 | reset_done = now + PORT_RESET_MSEC; | ||
| 2676 | do { | ||
| 2677 | u32 portstat; | ||
| 2678 | do { | ||
| 2679 | retval = u132_read_pcimem(u132, | ||
| 2680 | roothub.portstatus[port_index], &portstat); | ||
| 2681 | if (retval) | ||
| 2682 | return retval; | ||
| 2683 | if (RH_PS_PRS & portstat) { | ||
| 2684 | continue; | ||
| 2685 | } else | ||
| 2686 | break; | ||
| 2687 | } while (tick_before(now, reset_done)); | ||
| 2688 | if (RH_PS_PRS & portstat) | ||
| 2689 | return -ENODEV; | ||
| 2690 | if (RH_PS_CCS & portstat) { | ||
| 2691 | if (RH_PS_PRSC & portstat) { | ||
| 2692 | retval = u132_write_pcimem(u132, | ||
| 2693 | roothub.portstatus[port_index], | ||
| 2694 | RH_PS_PRSC); | ||
| 2695 | if (retval) | ||
| 2696 | return retval; | ||
| 2697 | } | ||
| 2698 | } else | ||
| 2699 | break; /* start the next reset, | ||
| 2700 | sleep till it's probably done */ | ||
| 2701 | retval = u132_write_pcimem(u132, roothub.portstatus[port_index], | ||
| 2702 | RH_PS_PRS); | ||
| 2703 | if (retval) | ||
| 2704 | return retval; | ||
| 2705 | msleep(PORT_RESET_HW_MSEC); | ||
| 2706 | retval = u132_read_pcimem(u132, fmnumber, &fmnumber); | ||
| 2707 | if (retval) | ||
| 2708 | return retval; | ||
| 2709 | now = fmnumber; | ||
| 2710 | } while (tick_before(now, reset_done)); | ||
| 2711 | return 0; | ||
| 2712 | } | ||
| 2713 | |||
| 2714 | static int u132_roothub_setportfeature(struct u132 *u132, u16 wValue, | ||
| 2715 | u16 wIndex) | ||
| 2716 | { | ||
| 2717 | if (wIndex == 0 || wIndex > u132->num_ports) { | ||
| 2718 | return -EINVAL; | ||
| 2719 | } else { | ||
| 2720 | int retval; | ||
| 2721 | int port_index = wIndex - 1; | ||
| 2722 | struct u132_port *port = &u132->port[port_index]; | ||
| 2723 | port->Status &= ~(1 << wValue); | ||
| 2724 | switch (wValue) { | ||
| 2725 | case USB_PORT_FEAT_SUSPEND: | ||
| 2726 | retval = u132_write_pcimem(u132, | ||
| 2727 | roothub.portstatus[port_index], RH_PS_PSS); | ||
| 2728 | if (retval) | ||
| 2729 | return retval; | ||
| 2730 | return 0; | ||
| 2731 | case USB_PORT_FEAT_POWER: | ||
| 2732 | retval = u132_write_pcimem(u132, | ||
| 2733 | roothub.portstatus[port_index], RH_PS_PPS); | ||
| 2734 | if (retval) | ||
| 2735 | return retval; | ||
| 2736 | return 0; | ||
| 2737 | case USB_PORT_FEAT_RESET: | ||
| 2738 | retval = u132_roothub_portreset(u132, port_index); | ||
| 2739 | if (retval) | ||
| 2740 | return retval; | ||
| 2741 | return 0; | ||
| 2742 | default: | ||
| 2743 | return -EPIPE; | ||
| 2744 | } | ||
| 2745 | } | ||
| 2746 | } | ||
| 2747 | |||
| 2748 | static int u132_roothub_clearportfeature(struct u132 *u132, u16 wValue, | ||
| 2749 | u16 wIndex) | ||
| 2750 | { | ||
| 2751 | if (wIndex == 0 || wIndex > u132->num_ports) { | ||
| 2752 | return -EINVAL; | ||
| 2753 | } else { | ||
| 2754 | int port_index = wIndex - 1; | ||
| 2755 | u32 temp; | ||
| 2756 | int retval; | ||
| 2757 | struct u132_port *port = &u132->port[port_index]; | ||
| 2758 | port->Status &= ~(1 << wValue); | ||
| 2759 | switch (wValue) { | ||
| 2760 | case USB_PORT_FEAT_ENABLE: | ||
| 2761 | temp = RH_PS_CCS; | ||
| 2762 | break; | ||
| 2763 | case USB_PORT_FEAT_C_ENABLE: | ||
| 2764 | temp = RH_PS_PESC; | ||
| 2765 | break; | ||
| 2766 | case USB_PORT_FEAT_SUSPEND: | ||
| 2767 | temp = RH_PS_POCI; | ||
| 2768 | if ((u132->hc_control & OHCI_CTRL_HCFS) | ||
| 2769 | != OHCI_USB_OPER) { | ||
| 2770 | dev_err(&u132->platform_dev->dev, "TODO resume_" | ||
| 2771 | "root_hub\n"); | ||
| 2772 | } | ||
| 2773 | break; | ||
| 2774 | case USB_PORT_FEAT_C_SUSPEND: | ||
| 2775 | temp = RH_PS_PSSC; | ||
| 2776 | break; | ||
| 2777 | case USB_PORT_FEAT_POWER: | ||
| 2778 | temp = RH_PS_LSDA; | ||
| 2779 | break; | ||
| 2780 | case USB_PORT_FEAT_C_CONNECTION: | ||
| 2781 | temp = RH_PS_CSC; | ||
| 2782 | break; | ||
| 2783 | case USB_PORT_FEAT_C_OVER_CURRENT: | ||
| 2784 | temp = RH_PS_OCIC; | ||
| 2785 | break; | ||
| 2786 | case USB_PORT_FEAT_C_RESET: | ||
| 2787 | temp = RH_PS_PRSC; | ||
| 2788 | break; | ||
| 2789 | default: | ||
| 2790 | return -EPIPE; | ||
| 2791 | } | ||
| 2792 | retval = u132_write_pcimem(u132, roothub.portstatus[port_index], | ||
| 2793 | temp); | ||
| 2794 | if (retval) | ||
| 2795 | return retval; | ||
| 2796 | return 0; | ||
| 2797 | } | ||
| 2798 | } | ||
| 2799 | |||
| 2800 | |||
| 2801 | /* the virtual root hub timer IRQ checks for hub status*/ | ||
| 2802 | static int u132_hub_status_data(struct usb_hcd *hcd, char *buf) | ||
| 2803 | { | ||
| 2804 | struct u132 *u132 = hcd_to_u132(hcd); | ||
| 2805 | if (u132->going > 1) { | ||
| 2806 | dev_err(&u132->platform_dev->dev, "device hcd=%p has been remov" | ||
| 2807 | "ed %d\n", hcd, u132->going); | ||
| 2808 | return -ENODEV; | ||
| 2809 | } else if (u132->going > 0) { | ||
| 2810 | dev_err(&u132->platform_dev->dev, "device hcd=%p is being remov" | ||
| 2811 | "ed\n", hcd); | ||
| 2812 | dump_stack(); | ||
| 2813 | return -ESHUTDOWN; | ||
| 2814 | } else { | ||
| 2815 | int i, changed = 0, length = 1; | ||
| 2816 | if (u132->flags & OHCI_QUIRK_AMD756) { | ||
| 2817 | if ((u132->hc_roothub_a & RH_A_NDP) > MAX_ROOT_PORTS) { | ||
| 2818 | dev_err(&u132->platform_dev->dev, "bogus NDP, r" | ||
| 2819 | "ereads as NDP=%d\n", | ||
| 2820 | u132->hc_roothub_a & RH_A_NDP); | ||
| 2821 | goto done; | ||
| 2822 | } | ||
| 2823 | } | ||
| 2824 | if (u132->hc_roothub_status & (RH_HS_LPSC | RH_HS_OCIC)) { | ||
| 2825 | buf[0] = changed = 1; | ||
| 2826 | } else | ||
| 2827 | buf[0] = 0; | ||
| 2828 | if (u132->num_ports > 7) { | ||
| 2829 | buf[1] = 0; | ||
| 2830 | length++; | ||
| 2831 | } | ||
| 2832 | for (i = 0; i < u132->num_ports; i++) { | ||
| 2833 | if (u132->hc_roothub_portstatus[i] & (RH_PS_CSC | | ||
| 2834 | RH_PS_PESC | RH_PS_PSSC | RH_PS_OCIC | | ||
| 2835 | RH_PS_PRSC)) { | ||
| 2836 | changed = 1; | ||
| 2837 | if (i < 7) { | ||
| 2838 | buf[0] |= 1 << (i + 1); | ||
| 2839 | } else | ||
| 2840 | buf[1] |= 1 << (i - 7); | ||
| 2841 | continue; | ||
| 2842 | } | ||
| 2843 | if (!(u132->hc_roothub_portstatus[i] & RH_PS_CCS)) { | ||
| 2844 | continue; | ||
| 2845 | } | ||
| 2846 | if ((u132->hc_roothub_portstatus[i] & RH_PS_PSS)) { | ||
| 2847 | continue; | ||
| 2848 | } | ||
| 2849 | } | ||
| 2850 | done:return changed ? length : 0; | ||
| 2851 | } | ||
| 2852 | } | ||
| 2853 | |||
| 2854 | static int u132_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue, | ||
| 2855 | u16 wIndex, char *buf, u16 wLength) | ||
| 2856 | { | ||
| 2857 | struct u132 *u132 = hcd_to_u132(hcd); | ||
| 2858 | if (u132->going > 1) { | ||
| 2859 | dev_err(&u132->platform_dev->dev, "device has been removed %d\n" | ||
| 2860 | , u132->going); | ||
| 2861 | return -ENODEV; | ||
| 2862 | } else if (u132->going > 0) { | ||
| 2863 | dev_err(&u132->platform_dev->dev, "device is being removed\n"); | ||
| 2864 | return -ESHUTDOWN; | ||
| 2865 | } else { | ||
| 2866 | int retval = 0; | ||
| 2867 | down(&u132->sw_lock); | ||
| 2868 | switch (typeReq) { | ||
| 2869 | case ClearHubFeature: | ||
| 2870 | switch (wValue) { | ||
| 2871 | case C_HUB_OVER_CURRENT: | ||
| 2872 | case C_HUB_LOCAL_POWER: | ||
| 2873 | break; | ||
| 2874 | default: | ||
| 2875 | goto stall; | ||
| 2876 | } | ||
| 2877 | break; | ||
| 2878 | case SetHubFeature: | ||
| 2879 | switch (wValue) { | ||
| 2880 | case C_HUB_OVER_CURRENT: | ||
| 2881 | case C_HUB_LOCAL_POWER: | ||
| 2882 | break; | ||
| 2883 | default: | ||
| 2884 | goto stall; | ||
| 2885 | } | ||
| 2886 | break; | ||
| 2887 | case ClearPortFeature:{ | ||
| 2888 | retval = u132_roothub_clearportfeature(u132, | ||
| 2889 | wValue, wIndex); | ||
| 2890 | if (retval) | ||
| 2891 | goto error; | ||
| 2892 | break; | ||
| 2893 | } | ||
| 2894 | case GetHubDescriptor:{ | ||
| 2895 | retval = u132_roothub_descriptor(u132, | ||
| 2896 | (struct usb_hub_descriptor *)buf); | ||
| 2897 | if (retval) | ||
| 2898 | goto error; | ||
| 2899 | break; | ||
| 2900 | } | ||
| 2901 | case GetHubStatus:{ | ||
| 2902 | retval = u132_roothub_status(u132, | ||
| 2903 | (__le32 *) buf); | ||
| 2904 | if (retval) | ||
| 2905 | goto error; | ||
| 2906 | break; | ||
| 2907 | } | ||
| 2908 | case GetPortStatus:{ | ||
| 2909 | retval = u132_roothub_portstatus(u132, | ||
| 2910 | (__le32 *) buf, wIndex); | ||
| 2911 | if (retval) | ||
| 2912 | goto error; | ||
| 2913 | break; | ||
| 2914 | } | ||
| 2915 | case SetPortFeature:{ | ||
| 2916 | retval = u132_roothub_setportfeature(u132, | ||
| 2917 | wValue, wIndex); | ||
| 2918 | if (retval) | ||
| 2919 | goto error; | ||
| 2920 | break; | ||
| 2921 | } | ||
| 2922 | default: | ||
| 2923 | goto stall; | ||
| 2924 | error:u132_disable(u132); | ||
| 2925 | u132->going = 1; | ||
| 2926 | break; | ||
| 2927 | stall:retval = -EPIPE; | ||
| 2928 | break; | ||
| 2929 | } | ||
| 2930 | up(&u132->sw_lock); | ||
| 2931 | return retval; | ||
| 2932 | } | ||
| 2933 | } | ||
| 2934 | |||
| 2935 | static int u132_start_port_reset(struct usb_hcd *hcd, unsigned port_num) | ||
| 2936 | { | ||
| 2937 | struct u132 *u132 = hcd_to_u132(hcd); | ||
| 2938 | if (u132->going > 1) { | ||
| 2939 | dev_err(&u132->platform_dev->dev, "device has been removed %d\n" | ||
| 2940 | , u132->going); | ||
| 2941 | return -ENODEV; | ||
| 2942 | } else if (u132->going > 0) { | ||
| 2943 | dev_err(&u132->platform_dev->dev, "device is being removed\n"); | ||
| 2944 | return -ESHUTDOWN; | ||
| 2945 | } else | ||
| 2946 | return 0; | ||
| 2947 | } | ||
| 2948 | |||
| 2949 | static void u132_hub_irq_enable(struct usb_hcd *hcd) | ||
| 2950 | { | ||
| 2951 | struct u132 *u132 = hcd_to_u132(hcd); | ||
| 2952 | if (u132->going > 1) { | ||
| 2953 | dev_err(&u132->platform_dev->dev, "device has been removed %d\n" | ||
| 2954 | , u132->going); | ||
| 2955 | } else if (u132->going > 0) | ||
| 2956 | dev_err(&u132->platform_dev->dev, "device is being removed\n"); | ||
| 2957 | } | ||
| 2958 | |||
| 2959 | |||
| 2960 | #ifdef CONFIG_PM | ||
| 2961 | static int u132_hcd_suspend(struct usb_hcd *hcd, pm_message_t message) | ||
| 2962 | { | ||
| 2963 | struct u132 *u132 = hcd_to_u132(hcd); | ||
| 2964 | if (u132->going > 1) { | ||
| 2965 | dev_err(&u132->platform_dev->dev, "device has been removed %d\n" | ||
| 2966 | , u132->going); | ||
| 2967 | return -ENODEV; | ||
| 2968 | } else if (u132->going > 0) { | ||
| 2969 | dev_err(&u132->platform_dev->dev, "device is being removed\n"); | ||
| 2970 | return -ESHUTDOWN; | ||
| 2971 | } else | ||
| 2972 | return 0; | ||
| 2973 | } | ||
| 2974 | |||
| 2975 | static int u132_hcd_resume(struct usb_hcd *hcd) | ||
| 2976 | { | ||
| 2977 | struct u132 *u132 = hcd_to_u132(hcd); | ||
| 2978 | if (u132->going > 1) { | ||
| 2979 | dev_err(&u132->platform_dev->dev, "device has been removed %d\n" | ||
| 2980 | , u132->going); | ||
| 2981 | return -ENODEV; | ||
| 2982 | } else if (u132->going > 0) { | ||
| 2983 | dev_err(&u132->platform_dev->dev, "device is being removed\n"); | ||
| 2984 | return -ESHUTDOWN; | ||
| 2985 | } else | ||
| 2986 | return 0; | ||
| 2987 | } | ||
| 2988 | |||
| 2989 | static int u132_bus_suspend(struct usb_hcd *hcd) | ||
| 2990 | { | ||
| 2991 | struct u132 *u132 = hcd_to_u132(hcd); | ||
| 2992 | if (u132->going > 1) { | ||
| 2993 | dev_err(&u132->platform_dev->dev, "device has been removed %d\n" | ||
| 2994 | , u132->going); | ||
| 2995 | return -ENODEV; | ||
| 2996 | } else if (u132->going > 0) { | ||
| 2997 | dev_err(&u132->platform_dev->dev, "device is being removed\n"); | ||
| 2998 | return -ESHUTDOWN; | ||
| 2999 | } else | ||
| 3000 | return 0; | ||
| 3001 | } | ||
| 3002 | |||
| 3003 | static int u132_bus_resume(struct usb_hcd *hcd) | ||
| 3004 | { | ||
| 3005 | struct u132 *u132 = hcd_to_u132(hcd); | ||
| 3006 | if (u132->going > 1) { | ||
| 3007 | dev_err(&u132->platform_dev->dev, "device has been removed %d\n" | ||
| 3008 | , u132->going); | ||
| 3009 | return -ENODEV; | ||
| 3010 | } else if (u132->going > 0) { | ||
| 3011 | dev_err(&u132->platform_dev->dev, "device is being removed\n"); | ||
| 3012 | return -ESHUTDOWN; | ||
| 3013 | } else | ||
| 3014 | return 0; | ||
| 3015 | } | ||
| 3016 | |||
| 3017 | #else | ||
| 3018 | #define u132_hcd_suspend NULL | ||
| 3019 | #define u132_hcd_resume NULL | ||
| 3020 | #define u132_bus_suspend NULL | ||
| 3021 | #define u132_bus_resume NULL | ||
| 3022 | #endif | ||
| 3023 | static struct hc_driver u132_hc_driver = { | ||
| 3024 | .description = hcd_name, | ||
| 3025 | .hcd_priv_size = sizeof(struct u132), | ||
| 3026 | .irq = NULL, | ||
| 3027 | .flags = HCD_USB11 | HCD_MEMORY, | ||
| 3028 | .reset = u132_hcd_reset, | ||
| 3029 | .start = u132_hcd_start, | ||
| 3030 | .suspend = u132_hcd_suspend, | ||
| 3031 | .resume = u132_hcd_resume, | ||
| 3032 | .stop = u132_hcd_stop, | ||
| 3033 | .urb_enqueue = u132_urb_enqueue, | ||
| 3034 | .urb_dequeue = u132_urb_dequeue, | ||
| 3035 | .endpoint_disable = u132_endpoint_disable, | ||
| 3036 | .get_frame_number = u132_get_frame, | ||
| 3037 | .hub_status_data = u132_hub_status_data, | ||
| 3038 | .hub_control = u132_hub_control, | ||
| 3039 | .bus_suspend = u132_bus_suspend, | ||
| 3040 | .bus_resume = u132_bus_resume, | ||
| 3041 | .start_port_reset = u132_start_port_reset, | ||
| 3042 | .hub_irq_enable = u132_hub_irq_enable, | ||
| 3043 | }; | ||
| 3044 | |||
| 3045 | /* | ||
| 3046 | * This function may be called by the USB core whilst the "usb_all_devices_rwsem" | ||
| 3047 | * is held for writing, thus this module must not call usb_remove_hcd() | ||
| 3048 | * synchronously - but instead should immediately stop activity to the | ||
| 3049 | * device and ansynchronously call usb_remove_hcd() | ||
| 3050 | */ | ||
| 3051 | static int __devexit u132_remove(struct platform_device *pdev) | ||
| 3052 | { | ||
| 3053 | struct usb_hcd *hcd = platform_get_drvdata(pdev); | ||
| 3054 | if (hcd) { | ||
| 3055 | struct u132 *u132 = hcd_to_u132(hcd); | ||
| 3056 | dump_stack(); | ||
| 3057 | if (u132->going++ > 1) { | ||
| 3058 | return -ENODEV; | ||
| 3059 | } else { | ||
| 3060 | int rings = MAX_U132_RINGS; | ||
| 3061 | int endps = MAX_U132_ENDPS; | ||
| 3062 | msleep(100); | ||
| 3063 | down(&u132->sw_lock); | ||
| 3064 | u132_monitor_cancel_work(u132); | ||
| 3065 | while (rings-- > 0) { | ||
| 3066 | struct u132_ring *ring = &u132->ring[rings]; | ||
| 3067 | u132_ring_cancel_work(u132, ring); | ||
| 3068 | } while (endps-- > 0) { | ||
| 3069 | struct u132_endp *endp = u132->endp[endps]; | ||
| 3070 | if (endp) | ||
| 3071 | u132_endp_cancel_work(u132, endp); | ||
| 3072 | } | ||
| 3073 | u132->going += 1; | ||
| 3074 | printk(KERN_INFO "removing device u132.%d\n", | ||
| 3075 | u132->sequence_num); | ||
| 3076 | up(&u132->sw_lock); | ||
| 3077 | usb_remove_hcd(hcd); | ||
| 3078 | u132_u132_put_kref(u132); | ||
| 3079 | return 0; | ||
| 3080 | } | ||
| 3081 | } else | ||
| 3082 | return 0; | ||
| 3083 | } | ||
| 3084 | |||
| 3085 | static void u132_initialise(struct u132 *u132, struct platform_device *pdev) | ||
| 3086 | { | ||
| 3087 | int rings = MAX_U132_RINGS; | ||
| 3088 | int ports = MAX_U132_PORTS; | ||
| 3089 | int addrs = MAX_U132_ADDRS; | ||
| 3090 | int udevs = MAX_U132_UDEVS; | ||
| 3091 | int endps = MAX_U132_ENDPS; | ||
| 3092 | u132->board = pdev->dev.platform_data; | ||
| 3093 | u132->platform_dev = pdev; | ||
| 3094 | u132->power = 0; | ||
| 3095 | u132->reset = 0; | ||
| 3096 | init_MUTEX(&u132->sw_lock); | ||
| 3097 | init_MUTEX(&u132->scheduler_lock); | ||
| 3098 | while (rings-- > 0) { | ||
| 3099 | struct u132_ring *ring = &u132->ring[rings]; | ||
| 3100 | ring->u132 = u132; | ||
| 3101 | ring->number = rings + 1; | ||
| 3102 | ring->length = 0; | ||
| 3103 | ring->curr_endp = NULL; | ||
| 3104 | INIT_WORK(&ring->scheduler, u132_hcd_ring_work_scheduler, | ||
| 3105 | (void *)ring); | ||
| 3106 | } down(&u132->sw_lock); | ||
| 3107 | INIT_WORK(&u132->monitor, u132_hcd_monitor_work, (void *)u132); | ||
| 3108 | while (ports-- > 0) { | ||
| 3109 | struct u132_port *port = &u132->port[ports]; | ||
| 3110 | port->u132 = u132; | ||
| 3111 | port->reset = 0; | ||
| 3112 | port->enable = 0; | ||
| 3113 | port->power = 0; | ||
| 3114 | port->Status = 0; | ||
| 3115 | } while (addrs-- > 0) { | ||
| 3116 | struct u132_addr *addr = &u132->addr[addrs]; | ||
| 3117 | addr->address = 0; | ||
| 3118 | } while (udevs-- > 0) { | ||
| 3119 | struct u132_udev *udev = &u132->udev[udevs]; | ||
| 3120 | int i = ARRAY_SIZE(udev->endp_number_in); | ||
| 3121 | int o = ARRAY_SIZE(udev->endp_number_out); | ||
| 3122 | udev->usb_device = NULL; | ||
| 3123 | udev->udev_number = 0; | ||
| 3124 | udev->usb_addr = 0; | ||
| 3125 | udev->portnumber = 0; | ||
| 3126 | while (i-- > 0) { | ||
| 3127 | udev->endp_number_in[i] = 0; | ||
| 3128 | } | ||
| 3129 | while (o-- > 0) { | ||
| 3130 | udev->endp_number_out[o] = 0; | ||
| 3131 | } | ||
| 3132 | } | ||
| 3133 | while (endps-- > 0) { | ||
| 3134 | u132->endp[endps] = NULL; | ||
| 3135 | } | ||
| 3136 | up(&u132->sw_lock); | ||
| 3137 | return; | ||
| 3138 | } | ||
| 3139 | |||
| 3140 | static int __devinit u132_probe(struct platform_device *pdev) | ||
| 3141 | { | ||
| 3142 | struct usb_hcd *hcd; | ||
| 3143 | msleep(100); | ||
| 3144 | if (u132_exiting > 0) { | ||
| 3145 | return -ENODEV; | ||
| 3146 | } /* refuse to confuse usbcore */ | ||
| 3147 | if (pdev->dev.dma_mask) { | ||
| 3148 | return -EINVAL; | ||
| 3149 | } | ||
| 3150 | hcd = usb_create_hcd(&u132_hc_driver, &pdev->dev, pdev->dev.bus_id); | ||
| 3151 | if (!hcd) { | ||
| 3152 | printk(KERN_ERR "failed to create the usb hcd struct for U132\n" | ||
| 3153 | ); | ||
| 3154 | ftdi_elan_gone_away(pdev); | ||
| 3155 | return -ENOMEM; | ||
| 3156 | } else { | ||
| 3157 | int retval = 0; | ||
| 3158 | struct u132 *u132 = hcd_to_u132(hcd); | ||
| 3159 | hcd->rsrc_start = 0; | ||
| 3160 | down(&u132_module_lock); | ||
| 3161 | list_add_tail(&u132->u132_list, &u132_static_list); | ||
| 3162 | u132->sequence_num = ++u132_instances; | ||
| 3163 | up(&u132_module_lock); | ||
| 3164 | u132_u132_init_kref(u132); | ||
| 3165 | u132_initialise(u132, pdev); | ||
| 3166 | hcd->product_desc = "ELAN U132 Host Controller"; | ||
| 3167 | retval = usb_add_hcd(hcd, 0, 0); | ||
| 3168 | if (retval != 0) { | ||
| 3169 | dev_err(&u132->platform_dev->dev, "init error %d\n", | ||
| 3170 | retval); | ||
| 3171 | u132_u132_put_kref(u132); | ||
| 3172 | return retval; | ||
| 3173 | } else { | ||
| 3174 | u132_monitor_queue_work(u132, 100); | ||
| 3175 | return 0; | ||
| 3176 | } | ||
| 3177 | } | ||
| 3178 | } | ||
| 3179 | |||
| 3180 | |||
| 3181 | #ifdef CONFIG_PM | ||
| 3182 | /* for this device there's no useful distinction between the controller | ||
| 3183 | * and its root hub, except that the root hub only gets direct PM calls | ||
| 3184 | * when CONFIG_USB_SUSPEND is enabled. | ||
| 3185 | */ | ||
| 3186 | static int u132_suspend(struct platform_device *pdev, pm_message_t state) | ||
| 3187 | { | ||
| 3188 | struct usb_hcd *hcd = platform_get_drvdata(pdev); | ||
| 3189 | struct u132 *u132 = hcd_to_u132(hcd); | ||
| 3190 | if (u132->going > 1) { | ||
| 3191 | dev_err(&u132->platform_dev->dev, "device has been removed %d\n" | ||
| 3192 | , u132->going); | ||
| 3193 | return -ENODEV; | ||
| 3194 | } else if (u132->going > 0) { | ||
| 3195 | dev_err(&u132->platform_dev->dev, "device is being removed\n"); | ||
| 3196 | return -ESHUTDOWN; | ||
| 3197 | } else { | ||
| 3198 | int retval = 0; | ||
| 3199 | if (state.event == PM_EVENT_FREEZE) { | ||
| 3200 | retval = u132_bus_suspend(hcd); | ||
| 3201 | } else if (state.event == PM_EVENT_SUSPEND) { | ||
| 3202 | int ports = MAX_U132_PORTS; | ||
| 3203 | while (ports-- > 0) { | ||
| 3204 | port_power(u132, ports, 0); | ||
| 3205 | } | ||
| 3206 | } | ||
| 3207 | if (retval == 0) | ||
| 3208 | pdev->dev.power.power_state = state; | ||
| 3209 | return retval; | ||
| 3210 | } | ||
| 3211 | } | ||
| 3212 | |||
| 3213 | static int u132_resume(struct platform_device *pdev) | ||
| 3214 | { | ||
| 3215 | struct usb_hcd *hcd = platform_get_drvdata(pdev); | ||
| 3216 | struct u132 *u132 = hcd_to_u132(hcd); | ||
| 3217 | if (u132->going > 1) { | ||
| 3218 | dev_err(&u132->platform_dev->dev, "device has been removed %d\n" | ||
| 3219 | , u132->going); | ||
| 3220 | return -ENODEV; | ||
| 3221 | } else if (u132->going > 0) { | ||
| 3222 | dev_err(&u132->platform_dev->dev, "device is being removed\n"); | ||
| 3223 | return -ESHUTDOWN; | ||
| 3224 | } else { | ||
| 3225 | int retval = 0; | ||
| 3226 | if (pdev->dev.power.power_state.event == PM_EVENT_SUSPEND) { | ||
| 3227 | int ports = MAX_U132_PORTS; | ||
| 3228 | while (ports-- > 0) { | ||
| 3229 | port_power(u132, ports, 1); | ||
| 3230 | } | ||
| 3231 | retval = 0; | ||
| 3232 | } else { | ||
| 3233 | pdev->dev.power.power_state = PMSG_ON; | ||
| 3234 | retval = u132_bus_resume(hcd); | ||
| 3235 | } | ||
| 3236 | return retval; | ||
| 3237 | } | ||
| 3238 | } | ||
| 3239 | |||
| 3240 | #else | ||
| 3241 | #define u132_suspend NULL | ||
| 3242 | #define u132_resume NULL | ||
| 3243 | #endif | ||
| 3244 | /* | ||
| 3245 | * this driver is loaded explicitely by ftdi_u132 | ||
| 3246 | * | ||
| 3247 | * the platform_driver struct is static because it is per type of module | ||
| 3248 | */ | ||
| 3249 | static struct platform_driver u132_platform_driver = { | ||
| 3250 | .probe = u132_probe, | ||
| 3251 | .remove = __devexit_p(u132_remove), | ||
| 3252 | .suspend = u132_suspend, | ||
| 3253 | .resume = u132_resume, | ||
| 3254 | .driver = { | ||
| 3255 | .name = (char *)hcd_name, | ||
| 3256 | .owner = THIS_MODULE, | ||
| 3257 | }, | ||
| 3258 | }; | ||
| 3259 | static int __init u132_hcd_init(void) | ||
| 3260 | { | ||
| 3261 | int retval; | ||
| 3262 | INIT_LIST_HEAD(&u132_static_list); | ||
| 3263 | u132_instances = 0; | ||
| 3264 | u132_exiting = 0; | ||
| 3265 | init_MUTEX(&u132_module_lock); | ||
| 3266 | if (usb_disabled()) | ||
| 3267 | return -ENODEV; | ||
| 3268 | printk(KERN_INFO "driver %s built at %s on %s\n", hcd_name, __TIME__, | ||
| 3269 | __DATE__); | ||
| 3270 | workqueue = create_singlethread_workqueue("u132"); | ||
| 3271 | retval = platform_driver_register(&u132_platform_driver); | ||
| 3272 | return retval; | ||
| 3273 | } | ||
| 3274 | |||
| 3275 | |||
| 3276 | module_init(u132_hcd_init); | ||
| 3277 | static void __exit u132_hcd_exit(void) | ||
| 3278 | { | ||
| 3279 | struct u132 *u132; | ||
| 3280 | struct u132 *temp; | ||
| 3281 | down(&u132_module_lock); | ||
| 3282 | u132_exiting += 1; | ||
| 3283 | up(&u132_module_lock); | ||
| 3284 | list_for_each_entry_safe(u132, temp, &u132_static_list, u132_list) { | ||
| 3285 | platform_device_unregister(u132->platform_dev); | ||
| 3286 | } platform_driver_unregister(&u132_platform_driver); | ||
| 3287 | printk(KERN_INFO "u132-hcd driver deregistered\n"); | ||
| 3288 | wait_event(u132_hcd_wait, u132_instances == 0); | ||
| 3289 | flush_workqueue(workqueue); | ||
| 3290 | destroy_workqueue(workqueue); | ||
| 3291 | } | ||
| 3292 | |||
| 3293 | |||
| 3294 | module_exit(u132_hcd_exit); | ||
| 3295 | MODULE_LICENSE("GPL"); | ||
diff --git a/drivers/usb/host/uhci-debug.c b/drivers/usb/host/uhci-debug.c index dc286a48cafd..e345f15b7d87 100644 --- a/drivers/usb/host/uhci-debug.c +++ b/drivers/usb/host/uhci-debug.c | |||
| @@ -16,7 +16,7 @@ | |||
| 16 | 16 | ||
| 17 | #include "uhci-hcd.h" | 17 | #include "uhci-hcd.h" |
| 18 | 18 | ||
| 19 | #define uhci_debug_operations (* (struct file_operations *) NULL) | 19 | #define uhci_debug_operations (* (const struct file_operations *) NULL) |
| 20 | static struct dentry *uhci_debugfs_root; | 20 | static struct dentry *uhci_debugfs_root; |
| 21 | 21 | ||
| 22 | #ifdef DEBUG | 22 | #ifdef DEBUG |
| @@ -428,7 +428,7 @@ struct uhci_debug { | |||
| 428 | 428 | ||
| 429 | static int uhci_debug_open(struct inode *inode, struct file *file) | 429 | static int uhci_debug_open(struct inode *inode, struct file *file) |
| 430 | { | 430 | { |
| 431 | struct uhci_hcd *uhci = inode->u.generic_ip; | 431 | struct uhci_hcd *uhci = inode->i_private; |
| 432 | struct uhci_debug *up; | 432 | struct uhci_debug *up; |
| 433 | int ret = -ENOMEM; | 433 | int ret = -ENOMEM; |
| 434 | unsigned long flags; | 434 | unsigned long flags; |
| @@ -500,7 +500,7 @@ static int uhci_debug_release(struct inode *inode, struct file *file) | |||
| 500 | } | 500 | } |
| 501 | 501 | ||
| 502 | #undef uhci_debug_operations | 502 | #undef uhci_debug_operations |
| 503 | static struct file_operations uhci_debug_operations = { | 503 | static const struct file_operations uhci_debug_operations = { |
| 504 | .owner = THIS_MODULE, | 504 | .owner = THIS_MODULE, |
| 505 | .open = uhci_debug_open, | 505 | .open = uhci_debug_open, |
| 506 | .llseek = uhci_debug_lseek, | 506 | .llseek = uhci_debug_lseek, |
diff --git a/drivers/usb/host/uhci-hcd.c b/drivers/usb/host/uhci-hcd.c index 4151f618602d..eb4eab98e8bf 100644 --- a/drivers/usb/host/uhci-hcd.c +++ b/drivers/usb/host/uhci-hcd.c | |||
| @@ -734,6 +734,10 @@ static int uhci_suspend(struct usb_hcd *hcd, pm_message_t message) | |||
| 734 | 734 | ||
| 735 | /* FIXME: Enable non-PME# remote wakeup? */ | 735 | /* FIXME: Enable non-PME# remote wakeup? */ |
| 736 | 736 | ||
| 737 | /* make sure snapshot being resumed re-enumerates everything */ | ||
| 738 | if (message.event == PM_EVENT_PRETHAW) | ||
| 739 | uhci_hc_died(uhci); | ||
| 740 | |||
| 737 | done_okay: | 741 | done_okay: |
| 738 | clear_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags); | 742 | clear_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags); |
| 739 | done: | 743 | done: |
| @@ -909,8 +913,7 @@ static int __init uhci_hcd_init(void) | |||
| 909 | return 0; | 913 | return 0; |
| 910 | 914 | ||
| 911 | init_failed: | 915 | init_failed: |
| 912 | if (kmem_cache_destroy(uhci_up_cachep)) | 916 | kmem_cache_destroy(uhci_up_cachep); |
| 913 | warn("not all urb_privs were freed!"); | ||
| 914 | 917 | ||
| 915 | up_failed: | 918 | up_failed: |
| 916 | debugfs_remove(uhci_debugfs_root); | 919 | debugfs_remove(uhci_debugfs_root); |
| @@ -926,10 +929,7 @@ errbuf_failed: | |||
| 926 | static void __exit uhci_hcd_cleanup(void) | 929 | static void __exit uhci_hcd_cleanup(void) |
| 927 | { | 930 | { |
| 928 | pci_unregister_driver(&uhci_pci_driver); | 931 | pci_unregister_driver(&uhci_pci_driver); |
| 929 | 932 | kmem_cache_destroy(uhci_up_cachep); | |
| 930 | if (kmem_cache_destroy(uhci_up_cachep)) | ||
| 931 | warn("not all urb_privs were freed!"); | ||
| 932 | |||
| 933 | debugfs_remove(uhci_debugfs_root); | 933 | debugfs_remove(uhci_debugfs_root); |
| 934 | kfree(errbuf); | 934 | kfree(errbuf); |
| 935 | } | 935 | } |
diff --git a/drivers/usb/host/uhci-hub.c b/drivers/usb/host/uhci-hub.c index c545ef92fe29..16fb72eb6fc9 100644 --- a/drivers/usb/host/uhci-hub.c +++ b/drivers/usb/host/uhci-hub.c | |||
| @@ -84,6 +84,7 @@ static void uhci_finish_suspend(struct uhci_hcd *uhci, int port, | |||
| 84 | unsigned long port_addr) | 84 | unsigned long port_addr) |
| 85 | { | 85 | { |
| 86 | int status; | 86 | int status; |
| 87 | int i; | ||
| 87 | 88 | ||
| 88 | if (inw(port_addr) & (USBPORTSC_SUSP | USBPORTSC_RD)) { | 89 | if (inw(port_addr) & (USBPORTSC_SUSP | USBPORTSC_RD)) { |
| 89 | CLR_RH_PORTSTAT(USBPORTSC_SUSP | USBPORTSC_RD); | 90 | CLR_RH_PORTSTAT(USBPORTSC_SUSP | USBPORTSC_RD); |
| @@ -92,9 +93,14 @@ static void uhci_finish_suspend(struct uhci_hcd *uhci, int port, | |||
| 92 | 93 | ||
| 93 | /* The controller won't actually turn off the RD bit until | 94 | /* The controller won't actually turn off the RD bit until |
| 94 | * it has had a chance to send a low-speed EOP sequence, | 95 | * it has had a chance to send a low-speed EOP sequence, |
| 95 | * which takes 3 bit times (= 2 microseconds). We'll delay | 96 | * which is supposed to take 3 bit times (= 2 microseconds). |
| 96 | * slightly longer for good luck. */ | 97 | * Experiments show that some controllers take longer, so |
| 97 | udelay(4); | 98 | * we'll poll for completion. */ |
| 99 | for (i = 0; i < 10; ++i) { | ||
| 100 | if (!(inw(port_addr) & USBPORTSC_RD)) | ||
| 101 | break; | ||
| 102 | udelay(1); | ||
| 103 | } | ||
| 98 | } | 104 | } |
| 99 | clear_bit(port, &uhci->resuming_ports); | 105 | clear_bit(port, &uhci->resuming_ports); |
| 100 | } | 106 | } |
