aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/host/ohci-hcd.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/usb/host/ohci-hcd.c')
-rw-r--r--drivers/usb/host/ohci-hcd.c110
1 files changed, 29 insertions, 81 deletions
diff --git a/drivers/usb/host/ohci-hcd.c b/drivers/usb/host/ohci-hcd.c
index b28a9b602066..c1c1d871aba4 100644
--- a/drivers/usb/host/ohci-hcd.c
+++ b/drivers/usb/host/ohci-hcd.c
@@ -3,77 +3,21 @@
3 * 3 *
4 * (C) Copyright 1999 Roman Weissgaerber <weissg@vienna.at> 4 * (C) Copyright 1999 Roman Weissgaerber <weissg@vienna.at>
5 * (C) Copyright 2000-2004 David Brownell <dbrownell@users.sourceforge.net> 5 * (C) Copyright 2000-2004 David Brownell <dbrownell@users.sourceforge.net>
6 * 6 *
7 * [ Initialisation is based on Linus' ] 7 * [ Initialisation is based on Linus' ]
8 * [ uhci code and gregs ohci fragments ] 8 * [ uhci code and gregs ohci fragments ]
9 * [ (C) Copyright 1999 Linus Torvalds ] 9 * [ (C) Copyright 1999 Linus Torvalds ]
10 * [ (C) Copyright 1999 Gregory P. Smith] 10 * [ (C) Copyright 1999 Gregory P. Smith]
11 * 11 *
12 * 12 *
13 * OHCI is the main "non-Intel/VIA" standard for USB 1.1 host controller 13 * OHCI is the main "non-Intel/VIA" standard for USB 1.1 host controller
14 * interfaces (though some non-x86 Intel chips use it). It supports 14 * interfaces (though some non-x86 Intel chips use it). It supports
15 * smarter hardware than UHCI. A download link for the spec available 15 * smarter hardware than UHCI. A download link for the spec available
16 * through the http://www.usb.org website. 16 * through the http://www.usb.org website.
17 * 17 *
18 * History:
19 *
20 * 2004/03/24 LH7A404 support (Durgesh Pattamatta & Marc Singer)
21 * 2004/02/04 use generic dma_* functions instead of pci_* (dsaxena@plexity.net)
22 * 2003/02/24 show registers in sysfs (Kevin Brosius)
23 *
24 * 2002/09/03 get rid of ed hashtables, rework periodic scheduling and
25 * bandwidth accounting; if debugging, show schedules in driverfs
26 * 2002/07/19 fixes to management of ED and schedule state.
27 * 2002/06/09 SA-1111 support (Christopher Hoover)
28 * 2002/06/01 remember frame when HC won't see EDs any more; use that info
29 * to fix urb unlink races caused by interrupt latency assumptions;
30 * minor ED field and function naming updates
31 * 2002/01/18 package as a patch for 2.5.3; this should match the
32 * 2.4.17 kernel modulo some bugs being fixed.
33 *
34 * 2001/10/18 merge pmac cleanup (Benjamin Herrenschmidt) and bugfixes
35 * from post-2.4.5 patches.
36 * 2001/09/20 URB_ZERO_PACKET support; hcca_dma portability, OPTi warning
37 * 2001/09/07 match PCI PM changes, errnos from Linus' tree
38 * 2001/05/05 fork 2.4.5 version into "hcd" framework, cleanup, simplify;
39 * pbook pci quirks gone (please fix pbook pci sw!) (db)
40 *
41 * 2001/04/08 Identify version on module load (gb)
42 * 2001/03/24 td/ed hashing to remove bus_to_virt (Steve Longerbeam);
43 pci_map_single (db)
44 * 2001/03/21 td and dev/ed allocation uses new pci_pool API (db)
45 * 2001/03/07 hcca allocation uses pci_alloc_consistent (Steve Longerbeam)
46 *
47 * 2000/09/26 fixed races in removing the private portion of the urb
48 * 2000/09/07 disable bulk and control lists when unlinking the last
49 * endpoint descriptor in order to avoid unrecoverable errors on
50 * the Lucent chips. (rwc@sgi)
51 * 2000/08/29 use bandwidth claiming hooks (thanks Randy!), fix some
52 * urb unlink probs, indentation fixes
53 * 2000/08/11 various oops fixes mostly affecting iso and cleanup from
54 * device unplugs.
55 * 2000/06/28 use PCI hotplug framework, for better power management
56 * and for Cardbus support (David Brownell)
57 * 2000/earlier: fixes for NEC/Lucent chips; suspend/resume handling
58 * when the controller loses power; handle UE; cleanup; ...
59 *
60 * v5.2 1999/12/07 URB 3rd preview,
61 * v5.1 1999/11/30 URB 2nd preview, cpia, (usb-scsi)
62 * v5.0 1999/11/22 URB Technical preview, Paul Mackerras powerbook susp/resume
63 * i386: HUB, Keyboard, Mouse, Printer
64 *
65 * v4.3 1999/10/27 multiple HCs, bulk_request
66 * v4.2 1999/09/05 ISO API alpha, new dev alloc, neg Error-codes
67 * v4.1 1999/08/27 Randy Dunlap's - ISO API first impl.
68 * v4.0 1999/08/18
69 * v3.0 1999/06/25
70 * v2.1 1999/05/09 code clean up
71 * v2.0 1999/05/04
72 * v1.0 1999/04/27 initial release
73 *
74 * This file is licenced under the GPL. 18 * This file is licenced under the GPL.
75 */ 19 */
76 20
77#include <linux/module.h> 21#include <linux/module.h>
78#include <linux/moduleparam.h> 22#include <linux/moduleparam.h>
79#include <linux/pci.h> 23#include <linux/pci.h>
@@ -89,7 +33,7 @@
89#include <linux/list.h> 33#include <linux/list.h>
90#include <linux/usb.h> 34#include <linux/usb.h>
91#include <linux/usb/otg.h> 35#include <linux/usb/otg.h>
92#include <linux/dma-mapping.h> 36#include <linux/dma-mapping.h>
93#include <linux/dmapool.h> 37#include <linux/dmapool.h>
94#include <linux/reboot.h> 38#include <linux/reboot.h>
95 39
@@ -183,11 +127,11 @@ static int ohci_urb_enqueue (
183 int i, size = 0; 127 int i, size = 0;
184 unsigned long flags; 128 unsigned long flags;
185 int retval = 0; 129 int retval = 0;
186 130
187#ifdef OHCI_VERBOSE_DEBUG 131#ifdef OHCI_VERBOSE_DEBUG
188 urb_print (urb, "SUB", usb_pipein (pipe)); 132 urb_print (urb, "SUB", usb_pipein (pipe));
189#endif 133#endif
190 134
191 /* every endpoint has a ed, locate and maybe (re)initialize it */ 135 /* every endpoint has a ed, locate and maybe (re)initialize it */
192 if (! (ed = ed_get (ohci, ep, urb->dev, pipe, urb->interval))) 136 if (! (ed = ed_get (ohci, ep, urb->dev, pipe, urb->interval)))
193 return -ENOMEM; 137 return -ENOMEM;
@@ -232,7 +176,7 @@ static int ohci_urb_enqueue (
232 memset (urb_priv, 0, sizeof (urb_priv_t) + size * sizeof (struct td *)); 176 memset (urb_priv, 0, sizeof (urb_priv_t) + size * sizeof (struct td *));
233 INIT_LIST_HEAD (&urb_priv->pending); 177 INIT_LIST_HEAD (&urb_priv->pending);
234 urb_priv->length = size; 178 urb_priv->length = size;
235 urb_priv->ed = ed; 179 urb_priv->ed = ed;
236 180
237 /* allocate the TDs (deferring hash chain updates) */ 181 /* allocate the TDs (deferring hash chain updates) */
238 for (i = 0; i < size; i++) { 182 for (i = 0; i < size; i++) {
@@ -242,7 +186,7 @@ static int ohci_urb_enqueue (
242 urb_free_priv (ohci, urb_priv); 186 urb_free_priv (ohci, urb_priv);
243 return -ENOMEM; 187 return -ENOMEM;
244 } 188 }
245 } 189 }
246 190
247 spin_lock_irqsave (&ohci->lock, flags); 191 spin_lock_irqsave (&ohci->lock, flags);
248 192
@@ -313,13 +257,13 @@ static int ohci_urb_dequeue (struct usb_hcd *hcd, struct urb *urb)
313{ 257{
314 struct ohci_hcd *ohci = hcd_to_ohci (hcd); 258 struct ohci_hcd *ohci = hcd_to_ohci (hcd);
315 unsigned long flags; 259 unsigned long flags;
316 260
317#ifdef OHCI_VERBOSE_DEBUG 261#ifdef OHCI_VERBOSE_DEBUG
318 urb_print (urb, "UNLINK", 1); 262 urb_print (urb, "UNLINK", 1);
319#endif 263#endif
320 264
321 spin_lock_irqsave (&ohci->lock, flags); 265 spin_lock_irqsave (&ohci->lock, flags);
322 if (HC_IS_RUNNING(hcd->state)) { 266 if (HC_IS_RUNNING(hcd->state)) {
323 urb_priv_t *urb_priv; 267 urb_priv_t *urb_priv;
324 268
325 /* Unless an IRQ completed the unlink while it was being 269 /* Unless an IRQ completed the unlink while it was being
@@ -512,11 +456,11 @@ static int ohci_init (struct ohci_hcd *ohci)
512 456
513/* Start an OHCI controller, set the BUS operational 457/* Start an OHCI controller, set the BUS operational
514 * resets USB and controller 458 * resets USB and controller
515 * enable interrupts 459 * enable interrupts
516 */ 460 */
517static int ohci_run (struct ohci_hcd *ohci) 461static int ohci_run (struct ohci_hcd *ohci)
518{ 462{
519 u32 mask, temp; 463 u32 mask, temp;
520 int first = ohci->fminterval == 0; 464 int first = ohci->fminterval == 0;
521 struct usb_hcd *hcd = ohci_to_hcd(ohci); 465 struct usb_hcd *hcd = ohci_to_hcd(ohci);
522 466
@@ -534,7 +478,7 @@ static int ohci_run (struct ohci_hcd *ohci)
534 /* also: power/overcurrent flags in roothub.a */ 478 /* also: power/overcurrent flags in roothub.a */
535 } 479 }
536 480
537 /* Reset USB nearly "by the book". RemoteWakeupConnected was 481 /* Reset USB nearly "by the book". RemoteWakeupConnected was
538 * saved if boot firmware (BIOS/SMM/...) told us it's connected, 482 * saved if boot firmware (BIOS/SMM/...) told us it's connected,
539 * or if bus glue did the same (e.g. for PCI add-in cards with 483 * or if bus glue did the same (e.g. for PCI add-in cards with
540 * PCI PM support). 484 * PCI PM support).
@@ -765,9 +709,9 @@ static irqreturn_t ohci_irq (struct usb_hcd *hcd)
765 dl_done_list (ohci); 709 dl_done_list (ohci);
766 spin_unlock (&ohci->lock); 710 spin_unlock (&ohci->lock);
767 if (HC_IS_RUNNING(hcd->state)) 711 if (HC_IS_RUNNING(hcd->state))
768 ohci_writel (ohci, OHCI_INTR_WDH, &regs->intrenable); 712 ohci_writel (ohci, OHCI_INTR_WDH, &regs->intrenable);
769 } 713 }
770 714
771 /* could track INTR_SO to reduce available PCI/... bandwidth */ 715 /* could track INTR_SO to reduce available PCI/... bandwidth */
772 716
773 /* handle any pending URB/ED unlinks, leaving INTR_SF enabled 717 /* handle any pending URB/ED unlinks, leaving INTR_SF enabled
@@ -778,12 +722,12 @@ static irqreturn_t ohci_irq (struct usb_hcd *hcd)
778 finish_unlinks (ohci, ohci_frame_no(ohci)); 722 finish_unlinks (ohci, ohci_frame_no(ohci));
779 if ((ints & OHCI_INTR_SF) != 0 && !ohci->ed_rm_list 723 if ((ints & OHCI_INTR_SF) != 0 && !ohci->ed_rm_list
780 && HC_IS_RUNNING(hcd->state)) 724 && HC_IS_RUNNING(hcd->state))
781 ohci_writel (ohci, OHCI_INTR_SF, &regs->intrdisable); 725 ohci_writel (ohci, OHCI_INTR_SF, &regs->intrdisable);
782 spin_unlock (&ohci->lock); 726 spin_unlock (&ohci->lock);
783 727
784 if (HC_IS_RUNNING(hcd->state)) { 728 if (HC_IS_RUNNING(hcd->state)) {
785 ohci_writel (ohci, ints, &regs->intrstatus); 729 ohci_writel (ohci, ints, &regs->intrstatus);
786 ohci_writel (ohci, OHCI_INTR_MIE, &regs->intrenable); 730 ohci_writel (ohci, OHCI_INTR_MIE, &regs->intrenable);
787 // flush those writes 731 // flush those writes
788 (void) ohci_readl (ohci, &ohci->regs->control); 732 (void) ohci_readl (ohci, &ohci->regs->control);
789 } 733 }
@@ -794,7 +738,7 @@ static irqreturn_t ohci_irq (struct usb_hcd *hcd)
794/*-------------------------------------------------------------------------*/ 738/*-------------------------------------------------------------------------*/
795 739
796static void ohci_stop (struct usb_hcd *hcd) 740static void ohci_stop (struct usb_hcd *hcd)
797{ 741{
798 struct ohci_hcd *ohci = hcd_to_ohci (hcd); 742 struct ohci_hcd *ohci = hcd_to_ohci (hcd);
799 743
800 ohci_dbg (ohci, "stop %s controller (state 0x%02x)\n", 744 ohci_dbg (ohci, "stop %s controller (state 0x%02x)\n",
@@ -812,8 +756,8 @@ static void ohci_stop (struct usb_hcd *hcd)
812 remove_debug_files (ohci); 756 remove_debug_files (ohci);
813 ohci_mem_cleanup (ohci); 757 ohci_mem_cleanup (ohci);
814 if (ohci->hcca) { 758 if (ohci->hcca) {
815 dma_free_coherent (hcd->self.controller, 759 dma_free_coherent (hcd->self.controller,
816 sizeof *ohci->hcca, 760 sizeof *ohci->hcca,
817 ohci->hcca, ohci->hcca_dma); 761 ohci->hcca, ohci->hcca_dma);
818 ohci->hcca = NULL; 762 ohci->hcca = NULL;
819 ohci->hcca_dma = 0; 763 ohci->hcca_dma = 0;
@@ -836,7 +780,7 @@ static int ohci_restart (struct ohci_hcd *ohci)
836 * recycle any "live" eds/tds (and urbs) right away. 780 * recycle any "live" eds/tds (and urbs) right away.
837 * later, khubd disconnect processing will recycle the other state, 781 * later, khubd disconnect processing will recycle the other state,
838 * (either as disconnect/reconnect, or maybe someday as a reset). 782 * (either as disconnect/reconnect, or maybe someday as a reset).
839 */ 783 */
840 spin_lock_irq(&ohci->lock); 784 spin_lock_irq(&ohci->lock);
841 disable (ohci); 785 disable (ohci);
842 usb_root_hub_lost_power(ohci_to_hcd(ohci)->self.root_hub); 786 usb_root_hub_lost_power(ohci_to_hcd(ohci)->self.root_hub);
@@ -875,11 +819,11 @@ static int ohci_restart (struct ohci_hcd *ohci)
875 /* empty the interrupt branches */ 819 /* empty the interrupt branches */
876 for (i = 0; i < NUM_INTS; i++) ohci->load [i] = 0; 820 for (i = 0; i < NUM_INTS; i++) ohci->load [i] = 0;
877 for (i = 0; i < NUM_INTS; i++) ohci->hcca->int_table [i] = 0; 821 for (i = 0; i < NUM_INTS; i++) ohci->hcca->int_table [i] = 0;
878 822
879 /* no EDs to remove */ 823 /* no EDs to remove */
880 ohci->ed_rm_list = NULL; 824 ohci->ed_rm_list = NULL;
881 825
882 /* empty control and bulk lists */ 826 /* empty control and bulk lists */
883 ohci->ed_controltail = NULL; 827 ohci->ed_controltail = NULL;
884 ohci->ed_bulktail = NULL; 828 ohci->ed_bulktail = NULL;
885 829
@@ -941,6 +885,10 @@ MODULE_LICENSE ("GPL");
941#include "ohci-au1xxx.c" 885#include "ohci-au1xxx.c"
942#endif 886#endif
943 887
888#ifdef CONFIG_PNX8550
889#include "ohci-pnx8550.c"
890#endif
891
944#ifdef CONFIG_USB_OHCI_HCD_PPC_SOC 892#ifdef CONFIG_USB_OHCI_HCD_PPC_SOC
945#include "ohci-ppc-soc.c" 893#include "ohci-ppc-soc.c"
946#endif 894#endif