aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/host
diff options
context:
space:
mode:
authorAlan Stern <stern@rowland.harvard.edu>2012-10-10 15:07:39 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2012-10-24 17:45:17 -0400
commitacc08503406f97ce6582c92fd8c8139f1e871a96 (patch)
tree29fff5e0ba8e5bd14c96864ea5475ab6c957c5b4 /drivers/usb/host
parentd6064aca824b81fbb788fd230c88976d84b651b1 (diff)
USB: EHCI: make ehci_read_frame_index platform independent
In preparation for splitting the ehci-hcd driver into a core library and separate platform-specific driver modules, this patch (as1617) changes the way ehci_read_frame_index() is handled. Since the same core library will have to work with both PCI and non-PCI platforms, the quirk handler routine will be compiled unconditionally. The decision about whether to call it or simply to read the frame index register is made at run time, based on whether the frame_index_bug quirk flag is set. Signed-off-by: Alan Stern <stern@rowland.harvard.edu> Acked-by: Felipe Balbi <balbi@ti.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/usb/host')
-rw-r--r--drivers/usb/host/ehci-hcd.c27
-rw-r--r--drivers/usb/host/ehci-sched.c23
-rw-r--r--drivers/usb/host/ehci.h16
3 files changed, 26 insertions, 40 deletions
diff --git a/drivers/usb/host/ehci-hcd.c b/drivers/usb/host/ehci-hcd.c
index 28fb5ddaf78..9c2afb516fe 100644
--- a/drivers/usb/host/ehci-hcd.c
+++ b/drivers/usb/host/ehci-hcd.c
@@ -118,9 +118,34 @@ MODULE_PARM_DESC(hird, "host initiated resume duration, +1 for each 75us");
118/*-------------------------------------------------------------------------*/ 118/*-------------------------------------------------------------------------*/
119 119
120#include "ehci.h" 120#include "ehci.h"
121#include "ehci-dbg.c"
122#include "pci-quirks.h" 121#include "pci-quirks.h"
123 122
123/*
124 * The MosChip MCS9990 controller updates its microframe counter
125 * a little before the frame counter, and occasionally we will read
126 * the invalid intermediate value. Avoid problems by checking the
127 * microframe number (the low-order 3 bits); if they are 0 then
128 * re-read the register to get the correct value.
129 */
130static unsigned ehci_moschip_read_frame_index(struct ehci_hcd *ehci)
131{
132 unsigned uf;
133
134 uf = ehci_readl(ehci, &ehci->regs->frame_index);
135 if (unlikely((uf & 7) == 0))
136 uf = ehci_readl(ehci, &ehci->regs->frame_index);
137 return uf;
138}
139
140static inline unsigned ehci_read_frame_index(struct ehci_hcd *ehci)
141{
142 if (ehci->frame_index_bug)
143 return ehci_moschip_read_frame_index(ehci);
144 return ehci_readl(ehci, &ehci->regs->frame_index);
145}
146
147#include "ehci-dbg.c"
148
124/*-------------------------------------------------------------------------*/ 149/*-------------------------------------------------------------------------*/
125 150
126/* 151/*
diff --git a/drivers/usb/host/ehci-sched.c b/drivers/usb/host/ehci-sched.c
index b538a4d62d5..2e14714b359 100644
--- a/drivers/usb/host/ehci-sched.c
+++ b/drivers/usb/host/ehci-sched.c
@@ -36,29 +36,6 @@
36 36
37static int ehci_get_frame (struct usb_hcd *hcd); 37static int ehci_get_frame (struct usb_hcd *hcd);
38 38
39#ifdef CONFIG_PCI
40
41static unsigned ehci_read_frame_index(struct ehci_hcd *ehci)
42{
43 unsigned uf;
44
45 /*
46 * The MosChip MCS9990 controller updates its microframe counter
47 * a little before the frame counter, and occasionally we will read
48 * the invalid intermediate value. Avoid problems by checking the
49 * microframe number (the low-order 3 bits); if they are 0 then
50 * re-read the register to get the correct value.
51 */
52 uf = ehci_readl(ehci, &ehci->regs->frame_index);
53 if (unlikely(ehci->frame_index_bug && ((uf & 7) == 0)))
54 uf = ehci_readl(ehci, &ehci->regs->frame_index);
55 return uf;
56}
57
58#endif
59
60/*-------------------------------------------------------------------------*/
61
62/* 39/*
63 * periodic_next_shadow - return "next" pointer on shadow list 40 * periodic_next_shadow - return "next" pointer on shadow list
64 * @periodic: host pointer to qh/itd/sitd 41 * @periodic: host pointer to qh/itd/sitd
diff --git a/drivers/usb/host/ehci.h b/drivers/usb/host/ehci.h
index 9b8cbb4b3e2..ec948c3b1ce 100644
--- a/drivers/usb/host/ehci.h
+++ b/drivers/usb/host/ehci.h
@@ -776,22 +776,6 @@ static inline u32 hc32_to_cpup (const struct ehci_hcd *ehci, const __hc32 *x)
776 static inline void ehci_vdbg(struct ehci_hcd *ehci, ...) {} 776 static inline void ehci_vdbg(struct ehci_hcd *ehci, ...) {}
777#endif 777#endif
778 778
779#ifdef CONFIG_PCI
780
781/* For working around the MosChip frame-index-register bug */
782static unsigned ehci_read_frame_index(struct ehci_hcd *ehci);
783
784#else
785
786static inline unsigned ehci_read_frame_index(struct ehci_hcd *ehci)
787{
788 return ehci_readl(ehci, &ehci->regs->frame_index);
789}
790
791#endif
792
793/*-------------------------------------------------------------------------*/
794
795#ifndef DEBUG 779#ifndef DEBUG
796#define STUB_DEBUG_FILES 780#define STUB_DEBUG_FILES
797#endif /* DEBUG */ 781#endif /* DEBUG */