aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/host
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/usb/host')
-rw-r--r--drivers/usb/host/Kconfig35
-rw-r--r--drivers/usb/host/Makefile4
-rw-r--r--drivers/usb/host/alchemy-common.c614
-rw-r--r--drivers/usb/host/ehci-atmel.c9
-rw-r--r--drivers/usb/host/ehci-au1xxx.c184
-rw-r--r--drivers/usb/host/ehci-cns3xxx.c155
-rw-r--r--drivers/usb/host/ehci-dbg.c112
-rw-r--r--drivers/usb/host/ehci-fsl.c1
-rw-r--r--drivers/usb/host/ehci-grlib.c18
-rw-r--r--drivers/usb/host/ehci-hcd.c204
-rw-r--r--drivers/usb/host/ehci-hub.c47
-rw-r--r--drivers/usb/host/ehci-ixp4xx.c139
-rw-r--r--drivers/usb/host/ehci-lpm.c84
-rw-r--r--drivers/usb/host/ehci-ls1x.c147
-rw-r--r--drivers/usb/host/ehci-msm.c1
-rw-r--r--drivers/usb/host/ehci-mxc.c10
-rw-r--r--drivers/usb/host/ehci-octeon.c3
-rw-r--r--drivers/usb/host/ehci-omap.c3
-rw-r--r--drivers/usb/host/ehci-orion.c16
-rw-r--r--drivers/usb/host/ehci-pci.c129
-rw-r--r--drivers/usb/host/ehci-platform.c96
-rw-r--r--drivers/usb/host/ehci-pmcmsp.c1
-rw-r--r--drivers/usb/host/ehci-q.c12
-rw-r--r--drivers/usb/host/ehci-s5p.c10
-rw-r--r--drivers/usb/host/ehci-sched.c136
-rw-r--r--drivers/usb/host/ehci-sh.c9
-rw-r--r--drivers/usb/host/ehci-spear.c57
-rw-r--r--drivers/usb/host/ehci-tegra.c16
-rw-r--r--drivers/usb/host/ehci-vt8500.c21
-rw-r--r--drivers/usb/host/ehci-w90x900.c2
-rw-r--r--drivers/usb/host/ehci-xls.c142
-rw-r--r--drivers/usb/host/ehci.h45
-rw-r--r--drivers/usb/host/isp1760-if.c7
-rw-r--r--drivers/usb/host/ohci-at91.c2
-rw-r--r--drivers/usb/host/ohci-au1xxx.c234
-rw-r--r--drivers/usb/host/ohci-cns3xxx.c166
-rw-r--r--drivers/usb/host/ohci-ep93xx.c2
-rw-r--r--drivers/usb/host/ohci-exynos.c32
-rw-r--r--drivers/usb/host/ohci-hcd.c139
-rw-r--r--drivers/usb/host/ohci-hub.c42
-rw-r--r--drivers/usb/host/ohci-omap.c2
-rw-r--r--drivers/usb/host/ohci-pci.c47
-rw-r--r--drivers/usb/host/ohci-platform.c28
-rw-r--r--drivers/usb/host/ohci-pnx8550.c243
-rw-r--r--drivers/usb/host/ohci-ppc-soc.c216
-rw-r--r--drivers/usb/host/ohci-pxa27x.c2
-rw-r--r--drivers/usb/host/ohci-q.c4
-rw-r--r--drivers/usb/host/ohci-s3c2410.c35
-rw-r--r--drivers/usb/host/ohci-sh.c141
-rw-r--r--drivers/usb/host/ohci-sm501.c2
-rw-r--r--drivers/usb/host/ohci-spear.c46
-rw-r--r--drivers/usb/host/ohci-tmio.c2
-rw-r--r--drivers/usb/host/ohci-xls.c152
-rw-r--r--drivers/usb/host/r8a66597-hcd.c6
-rw-r--r--drivers/usb/host/uhci-q.c73
-rw-r--r--drivers/usb/host/xhci-mem.c9
-rw-r--r--drivers/usb/host/xhci-pci.c16
-rw-r--r--drivers/usb/host/xhci-ring.c34
-rw-r--r--drivers/usb/host/xhci.c32
-rw-r--r--drivers/usb/host/xhci.h2
60 files changed, 628 insertions, 3550 deletions
diff --git a/drivers/usb/host/Kconfig b/drivers/usb/host/Kconfig
index 3f1431d37e1c..d6bb128ce21e 100644
--- a/drivers/usb/host/Kconfig
+++ b/drivers/usb/host/Kconfig
@@ -95,6 +95,11 @@ config USB_EHCI_TT_NEWSCHED
95 95
96 If unsure, say Y. 96 If unsure, say Y.
97 97
98config USB_EHCI_PCI
99 tristate
100 depends on USB_EHCI_HCD && PCI
101 default y
102
98config USB_EHCI_HCD_PMC_MSP 103config USB_EHCI_HCD_PMC_MSP
99 tristate "EHCI support for on-chip PMC MSP71xx USB controller" 104 tristate "EHCI support for on-chip PMC MSP71xx USB controller"
100 depends on USB_EHCI_HCD && MSP_HAS_USB 105 depends on USB_EHCI_HCD && MSP_HAS_USB
@@ -215,9 +220,13 @@ config USB_W90X900_EHCI
215 Enables support for the W90X900 USB controller 220 Enables support for the W90X900 USB controller
216 221
217config USB_CNS3XXX_EHCI 222config USB_CNS3XXX_EHCI
218 bool "Cavium CNS3XXX EHCI Module" 223 bool "Cavium CNS3XXX EHCI Module (DEPRECATED)"
219 depends on USB_EHCI_HCD && ARCH_CNS3XXX 224 depends on USB_EHCI_HCD && ARCH_CNS3XXX
225 select USB_EHCI_HCD_PLATFORM
220 ---help--- 226 ---help---
227 This option is deprecated now and the driver was removed, use
228 USB_EHCI_HCD_PLATFORM instead.
229
221 Enable support for the CNS3XXX SOC's on-chip EHCI controller. 230 Enable support for the CNS3XXX SOC's on-chip EHCI controller.
222 It is needed for high-speed (480Mbit/sec) USB 2.0 device 231 It is needed for high-speed (480Mbit/sec) USB 2.0 device
223 support. 232 support.
@@ -333,16 +342,6 @@ config USB_OHCI_ATH79
333 Enables support for the built-in OHCI controller present on the 342 Enables support for the built-in OHCI controller present on the
334 Atheros AR71XX/AR7240 SoCs. 343 Atheros AR71XX/AR7240 SoCs.
335 344
336config USB_OHCI_HCD_PPC_SOC
337 bool "OHCI support for on-chip PPC USB controller"
338 depends on USB_OHCI_HCD && (STB03xxx || PPC_MPC52xx)
339 default y
340 select USB_OHCI_BIG_ENDIAN_DESC
341 select USB_OHCI_BIG_ENDIAN_MMIO
342 ---help---
343 Enables support for the USB controller on the MPC52xx or
344 STB03xxx processor chip. If unsure, say Y.
345
346config USB_OHCI_HCD_PPC_OF_BE 345config USB_OHCI_HCD_PPC_OF_BE
347 bool "OHCI support for OF platform bus (big endian)" 346 bool "OHCI support for OF platform bus (big endian)"
348 depends on USB_OHCI_HCD && PPC_OF 347 depends on USB_OHCI_HCD && PPC_OF
@@ -393,9 +392,13 @@ config USB_OHCI_HCD_SSB
393 If unsure, say N. 392 If unsure, say N.
394 393
395config USB_OHCI_SH 394config USB_OHCI_SH
396 bool "OHCI support for SuperH USB controller" 395 bool "OHCI support for SuperH USB controller (DEPRECATED)"
397 depends on USB_OHCI_HCD && SUPERH 396 depends on USB_OHCI_HCD && SUPERH
397 select USB_OHCI_HCD_PLATFORM
398 ---help--- 398 ---help---
399 This option is deprecated now and the driver was removed, use
400 USB_OHCI_HCD_PLATFORM instead.
401
399 Enables support for the on-chip OHCI controller on the SuperH. 402 Enables support for the on-chip OHCI controller on the SuperH.
400 If you use the PCI OHCI controller, this option is not necessary. 403 If you use the PCI OHCI controller, this option is not necessary.
401 404
@@ -406,9 +409,13 @@ config USB_OHCI_EXYNOS
406 Enable support for the Samsung Exynos SOC's on-chip OHCI controller. 409 Enable support for the Samsung Exynos SOC's on-chip OHCI controller.
407 410
408config USB_CNS3XXX_OHCI 411config USB_CNS3XXX_OHCI
409 bool "Cavium CNS3XXX OHCI Module" 412 bool "Cavium CNS3XXX OHCI Module (DEPRECATED)"
410 depends on USB_OHCI_HCD && ARCH_CNS3XXX 413 depends on USB_OHCI_HCD && ARCH_CNS3XXX
414 select USB_OHCI_HCD_PLATFORM
411 ---help--- 415 ---help---
416 This option is deprecated now and the driver was removed, use
417 USB_OHCI_HCD_PLATFORM instead.
418
412 Enable support for the CNS3XXX SOC's on-chip OHCI controller. 419 Enable support for the CNS3XXX SOC's on-chip OHCI controller.
413 It is needed for low-speed USB 1.0 device support. 420 It is needed for low-speed USB 1.0 device support.
414 421
@@ -423,7 +430,7 @@ config USB_OHCI_HCD_PLATFORM
423 If unsure, say N. 430 If unsure, say N.
424 431
425config USB_EHCI_HCD_PLATFORM 432config USB_EHCI_HCD_PLATFORM
426 bool "Generic EHCI driver for a platform device" 433 tristate "Generic EHCI driver for a platform device"
427 depends on USB_EHCI_HCD 434 depends on USB_EHCI_HCD
428 default n 435 default n
429 ---help--- 436 ---help---
diff --git a/drivers/usb/host/Makefile b/drivers/usb/host/Makefile
index 9e0a89ced15c..1eb4c3006e9e 100644
--- a/drivers/usb/host/Makefile
+++ b/drivers/usb/host/Makefile
@@ -24,6 +24,9 @@ obj-$(CONFIG_USB_WHCI_HCD) += whci/
24obj-$(CONFIG_PCI) += pci-quirks.o 24obj-$(CONFIG_PCI) += pci-quirks.o
25 25
26obj-$(CONFIG_USB_EHCI_HCD) += ehci-hcd.o 26obj-$(CONFIG_USB_EHCI_HCD) += ehci-hcd.o
27obj-$(CONFIG_USB_EHCI_PCI) += ehci-pci.o
28obj-$(CONFIG_USB_EHCI_HCD_PLATFORM) += ehci-platform.o
29
27obj-$(CONFIG_USB_OXU210HP_HCD) += oxu210hp-hcd.o 30obj-$(CONFIG_USB_OXU210HP_HCD) += oxu210hp-hcd.o
28obj-$(CONFIG_USB_ISP116X_HCD) += isp116x-hcd.o 31obj-$(CONFIG_USB_ISP116X_HCD) += isp116x-hcd.o
29obj-$(CONFIG_USB_ISP1362_HCD) += isp1362-hcd.o 32obj-$(CONFIG_USB_ISP1362_HCD) += isp1362-hcd.o
@@ -40,6 +43,5 @@ obj-$(CONFIG_USB_HWA_HCD) += hwa-hc.o
40obj-$(CONFIG_USB_IMX21_HCD) += imx21-hcd.o 43obj-$(CONFIG_USB_IMX21_HCD) += imx21-hcd.o
41obj-$(CONFIG_USB_FSL_MPH_DR_OF) += fsl-mph-dr-of.o 44obj-$(CONFIG_USB_FSL_MPH_DR_OF) += fsl-mph-dr-of.o
42obj-$(CONFIG_USB_OCTEON2_COMMON) += octeon2-common.o 45obj-$(CONFIG_USB_OCTEON2_COMMON) += octeon2-common.o
43obj-$(CONFIG_MIPS_ALCHEMY) += alchemy-common.o
44obj-$(CONFIG_USB_HCD_BCMA) += bcma-hcd.o 46obj-$(CONFIG_USB_HCD_BCMA) += bcma-hcd.o
45obj-$(CONFIG_USB_HCD_SSB) += ssb-hcd.o 47obj-$(CONFIG_USB_HCD_SSB) += ssb-hcd.o
diff --git a/drivers/usb/host/alchemy-common.c b/drivers/usb/host/alchemy-common.c
deleted file mode 100644
index 936af8359fb2..000000000000
--- a/drivers/usb/host/alchemy-common.c
+++ /dev/null
@@ -1,614 +0,0 @@
1/*
2 * USB block power/access management abstraction.
3 *
4 * Au1000+: The OHCI block control register is at the far end of the OHCI memory
5 * area. Au1550 has OHCI on different base address. No need to handle
6 * UDC here.
7 * Au1200: one register to control access and clocks to O/EHCI, UDC and OTG
8 * as well as the PHY for EHCI and UDC.
9 *
10 */
11
12#include <linux/init.h>
13#include <linux/io.h>
14#include <linux/module.h>
15#include <linux/spinlock.h>
16#include <linux/syscore_ops.h>
17#include <asm/mach-au1x00/au1000.h>
18
19/* control register offsets */
20#define AU1000_OHCICFG 0x7fffc
21#define AU1550_OHCICFG 0x07ffc
22#define AU1200_USBCFG 0x04
23
24/* Au1000 USB block config bits */
25#define USBHEN_RD (1 << 4) /* OHCI reset-done indicator */
26#define USBHEN_CE (1 << 3) /* OHCI block clock enable */
27#define USBHEN_E (1 << 2) /* OHCI block enable */
28#define USBHEN_C (1 << 1) /* OHCI block coherency bit */
29#define USBHEN_BE (1 << 0) /* OHCI Big-Endian */
30
31/* Au1200 USB config bits */
32#define USBCFG_PFEN (1 << 31) /* prefetch enable (undoc) */
33#define USBCFG_RDCOMB (1 << 30) /* read combining (undoc) */
34#define USBCFG_UNKNOWN (5 << 20) /* unknown, leave this way */
35#define USBCFG_SSD (1 << 23) /* serial short detect en */
36#define USBCFG_PPE (1 << 19) /* HS PHY PLL */
37#define USBCFG_UCE (1 << 18) /* UDC clock enable */
38#define USBCFG_ECE (1 << 17) /* EHCI clock enable */
39#define USBCFG_OCE (1 << 16) /* OHCI clock enable */
40#define USBCFG_FLA(x) (((x) & 0x3f) << 8)
41#define USBCFG_UCAM (1 << 7) /* coherent access (undoc) */
42#define USBCFG_GME (1 << 6) /* OTG mem access */
43#define USBCFG_DBE (1 << 5) /* UDC busmaster enable */
44#define USBCFG_DME (1 << 4) /* UDC mem enable */
45#define USBCFG_EBE (1 << 3) /* EHCI busmaster enable */
46#define USBCFG_EME (1 << 2) /* EHCI mem enable */
47#define USBCFG_OBE (1 << 1) /* OHCI busmaster enable */
48#define USBCFG_OME (1 << 0) /* OHCI mem enable */
49#define USBCFG_INIT_AU1200 (USBCFG_PFEN | USBCFG_RDCOMB | USBCFG_UNKNOWN |\
50 USBCFG_SSD | USBCFG_FLA(0x20) | USBCFG_UCAM | \
51 USBCFG_GME | USBCFG_DBE | USBCFG_DME | \
52 USBCFG_EBE | USBCFG_EME | USBCFG_OBE | \
53 USBCFG_OME)
54
55/* Au1300 USB config registers */
56#define USB_DWC_CTRL1 0x00
57#define USB_DWC_CTRL2 0x04
58#define USB_VBUS_TIMER 0x10
59#define USB_SBUS_CTRL 0x14
60#define USB_MSR_ERR 0x18
61#define USB_DWC_CTRL3 0x1C
62#define USB_DWC_CTRL4 0x20
63#define USB_OTG_STATUS 0x28
64#define USB_DWC_CTRL5 0x2C
65#define USB_DWC_CTRL6 0x30
66#define USB_DWC_CTRL7 0x34
67#define USB_PHY_STATUS 0xC0
68#define USB_INT_STATUS 0xC4
69#define USB_INT_ENABLE 0xC8
70
71#define USB_DWC_CTRL1_OTGD 0x04 /* set to DISable OTG */
72#define USB_DWC_CTRL1_HSTRS 0x02 /* set to ENable EHCI */
73#define USB_DWC_CTRL1_DCRS 0x01 /* set to ENable UDC */
74
75#define USB_DWC_CTRL2_PHY1RS 0x04 /* set to enable PHY1 */
76#define USB_DWC_CTRL2_PHY0RS 0x02 /* set to enable PHY0 */
77#define USB_DWC_CTRL2_PHYRS 0x01 /* set to enable PHY */
78
79#define USB_DWC_CTRL3_OHCI1_CKEN (1 << 19)
80#define USB_DWC_CTRL3_OHCI0_CKEN (1 << 18)
81#define USB_DWC_CTRL3_EHCI0_CKEN (1 << 17)
82#define USB_DWC_CTRL3_OTG0_CKEN (1 << 16)
83
84#define USB_SBUS_CTRL_SBCA 0x04 /* coherent access */
85
86#define USB_INTEN_FORCE 0x20
87#define USB_INTEN_PHY 0x10
88#define USB_INTEN_UDC 0x08
89#define USB_INTEN_EHCI 0x04
90#define USB_INTEN_OHCI1 0x02
91#define USB_INTEN_OHCI0 0x01
92
93static DEFINE_SPINLOCK(alchemy_usb_lock);
94
95static inline void __au1300_usb_phyctl(void __iomem *base, int enable)
96{
97 unsigned long r, s;
98
99 r = __raw_readl(base + USB_DWC_CTRL2);
100 s = __raw_readl(base + USB_DWC_CTRL3);
101
102 s &= USB_DWC_CTRL3_OHCI1_CKEN | USB_DWC_CTRL3_OHCI0_CKEN |
103 USB_DWC_CTRL3_EHCI0_CKEN | USB_DWC_CTRL3_OTG0_CKEN;
104
105 if (enable) {
106 /* simply enable all PHYs */
107 r |= USB_DWC_CTRL2_PHY1RS | USB_DWC_CTRL2_PHY0RS |
108 USB_DWC_CTRL2_PHYRS;
109 __raw_writel(r, base + USB_DWC_CTRL2);
110 wmb();
111 } else if (!s) {
112 /* no USB block active, do disable all PHYs */
113 r &= ~(USB_DWC_CTRL2_PHY1RS | USB_DWC_CTRL2_PHY0RS |
114 USB_DWC_CTRL2_PHYRS);
115 __raw_writel(r, base + USB_DWC_CTRL2);
116 wmb();
117 }
118}
119
120static inline void __au1300_ohci_control(void __iomem *base, int enable, int id)
121{
122 unsigned long r;
123
124 if (enable) {
125 __raw_writel(1, base + USB_DWC_CTRL7); /* start OHCI clock */
126 wmb();
127
128 r = __raw_readl(base + USB_DWC_CTRL3); /* enable OHCI block */
129 r |= (id == 0) ? USB_DWC_CTRL3_OHCI0_CKEN
130 : USB_DWC_CTRL3_OHCI1_CKEN;
131 __raw_writel(r, base + USB_DWC_CTRL3);
132 wmb();
133
134 __au1300_usb_phyctl(base, enable); /* power up the PHYs */
135
136 r = __raw_readl(base + USB_INT_ENABLE);
137 r |= (id == 0) ? USB_INTEN_OHCI0 : USB_INTEN_OHCI1;
138 __raw_writel(r, base + USB_INT_ENABLE);
139 wmb();
140
141 /* reset the OHCI start clock bit */
142 __raw_writel(0, base + USB_DWC_CTRL7);
143 wmb();
144 } else {
145 r = __raw_readl(base + USB_INT_ENABLE);
146 r &= ~((id == 0) ? USB_INTEN_OHCI0 : USB_INTEN_OHCI1);
147 __raw_writel(r, base + USB_INT_ENABLE);
148 wmb();
149
150 r = __raw_readl(base + USB_DWC_CTRL3);
151 r &= ~((id == 0) ? USB_DWC_CTRL3_OHCI0_CKEN
152 : USB_DWC_CTRL3_OHCI1_CKEN);
153 __raw_writel(r, base + USB_DWC_CTRL3);
154 wmb();
155
156 __au1300_usb_phyctl(base, enable);
157 }
158}
159
160static inline void __au1300_ehci_control(void __iomem *base, int enable)
161{
162 unsigned long r;
163
164 if (enable) {
165 r = __raw_readl(base + USB_DWC_CTRL3);
166 r |= USB_DWC_CTRL3_EHCI0_CKEN;
167 __raw_writel(r, base + USB_DWC_CTRL3);
168 wmb();
169
170 r = __raw_readl(base + USB_DWC_CTRL1);
171 r |= USB_DWC_CTRL1_HSTRS;
172 __raw_writel(r, base + USB_DWC_CTRL1);
173 wmb();
174
175 __au1300_usb_phyctl(base, enable);
176
177 r = __raw_readl(base + USB_INT_ENABLE);
178 r |= USB_INTEN_EHCI;
179 __raw_writel(r, base + USB_INT_ENABLE);
180 wmb();
181 } else {
182 r = __raw_readl(base + USB_INT_ENABLE);
183 r &= ~USB_INTEN_EHCI;
184 __raw_writel(r, base + USB_INT_ENABLE);
185 wmb();
186
187 r = __raw_readl(base + USB_DWC_CTRL1);
188 r &= ~USB_DWC_CTRL1_HSTRS;
189 __raw_writel(r, base + USB_DWC_CTRL1);
190 wmb();
191
192 r = __raw_readl(base + USB_DWC_CTRL3);
193 r &= ~USB_DWC_CTRL3_EHCI0_CKEN;
194 __raw_writel(r, base + USB_DWC_CTRL3);
195 wmb();
196
197 __au1300_usb_phyctl(base, enable);
198 }
199}
200
201static inline void __au1300_udc_control(void __iomem *base, int enable)
202{
203 unsigned long r;
204
205 if (enable) {
206 r = __raw_readl(base + USB_DWC_CTRL1);
207 r |= USB_DWC_CTRL1_DCRS;
208 __raw_writel(r, base + USB_DWC_CTRL1);
209 wmb();
210
211 __au1300_usb_phyctl(base, enable);
212
213 r = __raw_readl(base + USB_INT_ENABLE);
214 r |= USB_INTEN_UDC;
215 __raw_writel(r, base + USB_INT_ENABLE);
216 wmb();
217 } else {
218 r = __raw_readl(base + USB_INT_ENABLE);
219 r &= ~USB_INTEN_UDC;
220 __raw_writel(r, base + USB_INT_ENABLE);
221 wmb();
222
223 r = __raw_readl(base + USB_DWC_CTRL1);
224 r &= ~USB_DWC_CTRL1_DCRS;
225 __raw_writel(r, base + USB_DWC_CTRL1);
226 wmb();
227
228 __au1300_usb_phyctl(base, enable);
229 }
230}
231
232static inline void __au1300_otg_control(void __iomem *base, int enable)
233{
234 unsigned long r;
235 if (enable) {
236 r = __raw_readl(base + USB_DWC_CTRL3);
237 r |= USB_DWC_CTRL3_OTG0_CKEN;
238 __raw_writel(r, base + USB_DWC_CTRL3);
239 wmb();
240
241 r = __raw_readl(base + USB_DWC_CTRL1);
242 r &= ~USB_DWC_CTRL1_OTGD;
243 __raw_writel(r, base + USB_DWC_CTRL1);
244 wmb();
245
246 __au1300_usb_phyctl(base, enable);
247 } else {
248 r = __raw_readl(base + USB_DWC_CTRL1);
249 r |= USB_DWC_CTRL1_OTGD;
250 __raw_writel(r, base + USB_DWC_CTRL1);
251 wmb();
252
253 r = __raw_readl(base + USB_DWC_CTRL3);
254 r &= ~USB_DWC_CTRL3_OTG0_CKEN;
255 __raw_writel(r, base + USB_DWC_CTRL3);
256 wmb();
257
258 __au1300_usb_phyctl(base, enable);
259 }
260}
261
262static inline int au1300_usb_control(int block, int enable)
263{
264 void __iomem *base =
265 (void __iomem *)KSEG1ADDR(AU1300_USB_CTL_PHYS_ADDR);
266 int ret = 0;
267
268 switch (block) {
269 case ALCHEMY_USB_OHCI0:
270 __au1300_ohci_control(base, enable, 0);
271 break;
272 case ALCHEMY_USB_OHCI1:
273 __au1300_ohci_control(base, enable, 1);
274 break;
275 case ALCHEMY_USB_EHCI0:
276 __au1300_ehci_control(base, enable);
277 break;
278 case ALCHEMY_USB_UDC0:
279 __au1300_udc_control(base, enable);
280 break;
281 case ALCHEMY_USB_OTG0:
282 __au1300_otg_control(base, enable);
283 break;
284 default:
285 ret = -ENODEV;
286 }
287 return ret;
288}
289
290static inline void au1300_usb_init(void)
291{
292 void __iomem *base =
293 (void __iomem *)KSEG1ADDR(AU1300_USB_CTL_PHYS_ADDR);
294
295 /* set some sane defaults. Note: we don't fiddle with DWC_CTRL4
296 * here at all: Port 2 routing (EHCI or UDC) must be set either
297 * by boot firmware or platform init code; I can't autodetect
298 * a sane setting.
299 */
300 __raw_writel(0, base + USB_INT_ENABLE); /* disable all USB irqs */
301 wmb();
302 __raw_writel(0, base + USB_DWC_CTRL3); /* disable all clocks */
303 wmb();
304 __raw_writel(~0, base + USB_MSR_ERR); /* clear all errors */
305 wmb();
306 __raw_writel(~0, base + USB_INT_STATUS); /* clear int status */
307 wmb();
308 /* set coherent access bit */
309 __raw_writel(USB_SBUS_CTRL_SBCA, base + USB_SBUS_CTRL);
310 wmb();
311}
312
313static inline void __au1200_ohci_control(void __iomem *base, int enable)
314{
315 unsigned long r = __raw_readl(base + AU1200_USBCFG);
316 if (enable) {
317 __raw_writel(r | USBCFG_OCE, base + AU1200_USBCFG);
318 wmb();
319 udelay(2000);
320 } else {
321 __raw_writel(r & ~USBCFG_OCE, base + AU1200_USBCFG);
322 wmb();
323 udelay(1000);
324 }
325}
326
327static inline void __au1200_ehci_control(void __iomem *base, int enable)
328{
329 unsigned long r = __raw_readl(base + AU1200_USBCFG);
330 if (enable) {
331 __raw_writel(r | USBCFG_ECE | USBCFG_PPE, base + AU1200_USBCFG);
332 wmb();
333 udelay(1000);
334 } else {
335 if (!(r & USBCFG_UCE)) /* UDC also off? */
336 r &= ~USBCFG_PPE; /* yes: disable HS PHY PLL */
337 __raw_writel(r & ~USBCFG_ECE, base + AU1200_USBCFG);
338 wmb();
339 udelay(1000);
340 }
341}
342
343static inline void __au1200_udc_control(void __iomem *base, int enable)
344{
345 unsigned long r = __raw_readl(base + AU1200_USBCFG);
346 if (enable) {
347 __raw_writel(r | USBCFG_UCE | USBCFG_PPE, base + AU1200_USBCFG);
348 wmb();
349 } else {
350 if (!(r & USBCFG_ECE)) /* EHCI also off? */
351 r &= ~USBCFG_PPE; /* yes: disable HS PHY PLL */
352 __raw_writel(r & ~USBCFG_UCE, base + AU1200_USBCFG);
353 wmb();
354 }
355}
356
357static inline int au1200_coherency_bug(void)
358{
359#if defined(CONFIG_DMA_COHERENT)
360 /* Au1200 AB USB does not support coherent memory */
361 if (!(read_c0_prid() & 0xff)) {
362 printk(KERN_INFO "Au1200 USB: this is chip revision AB !!\n");
363 printk(KERN_INFO "Au1200 USB: update your board or re-configure"
364 " the kernel\n");
365 return -ENODEV;
366 }
367#endif
368 return 0;
369}
370
371static inline int au1200_usb_control(int block, int enable)
372{
373 void __iomem *base =
374 (void __iomem *)KSEG1ADDR(AU1200_USB_CTL_PHYS_ADDR);
375 int ret = 0;
376
377 switch (block) {
378 case ALCHEMY_USB_OHCI0:
379 ret = au1200_coherency_bug();
380 if (ret && enable)
381 goto out;
382 __au1200_ohci_control(base, enable);
383 break;
384 case ALCHEMY_USB_UDC0:
385 __au1200_udc_control(base, enable);
386 break;
387 case ALCHEMY_USB_EHCI0:
388 ret = au1200_coherency_bug();
389 if (ret && enable)
390 goto out;
391 __au1200_ehci_control(base, enable);
392 break;
393 default:
394 ret = -ENODEV;
395 }
396out:
397 return ret;
398}
399
400
401/* initialize USB block(s) to a known working state */
402static inline void au1200_usb_init(void)
403{
404 void __iomem *base =
405 (void __iomem *)KSEG1ADDR(AU1200_USB_CTL_PHYS_ADDR);
406 __raw_writel(USBCFG_INIT_AU1200, base + AU1200_USBCFG);
407 wmb();
408 udelay(1000);
409}
410
411static inline void au1000_usb_init(unsigned long rb, int reg)
412{
413 void __iomem *base = (void __iomem *)KSEG1ADDR(rb + reg);
414 unsigned long r = __raw_readl(base);
415
416#if defined(__BIG_ENDIAN)
417 r |= USBHEN_BE;
418#endif
419 r |= USBHEN_C;
420
421 __raw_writel(r, base);
422 wmb();
423 udelay(1000);
424}
425
426
427static inline void __au1xx0_ohci_control(int enable, unsigned long rb, int creg)
428{
429 void __iomem *base = (void __iomem *)KSEG1ADDR(rb);
430 unsigned long r = __raw_readl(base + creg);
431
432 if (enable) {
433 __raw_writel(r | USBHEN_CE, base + creg);
434 wmb();
435 udelay(1000);
436 __raw_writel(r | USBHEN_CE | USBHEN_E, base + creg);
437 wmb();
438 udelay(1000);
439
440 /* wait for reset complete (read reg twice: au1500 erratum) */
441 while (__raw_readl(base + creg),
442 !(__raw_readl(base + creg) & USBHEN_RD))
443 udelay(1000);
444 } else {
445 __raw_writel(r & ~(USBHEN_CE | USBHEN_E), base + creg);
446 wmb();
447 }
448}
449
450static inline int au1000_usb_control(int block, int enable, unsigned long rb,
451 int creg)
452{
453 int ret = 0;
454
455 switch (block) {
456 case ALCHEMY_USB_OHCI0:
457 __au1xx0_ohci_control(enable, rb, creg);
458 break;
459 default:
460 ret = -ENODEV;
461 }
462 return ret;
463}
464
465/*
466 * alchemy_usb_control - control Alchemy on-chip USB blocks
467 * @block: USB block to target
468 * @enable: set 1 to enable a block, 0 to disable
469 */
470int alchemy_usb_control(int block, int enable)
471{
472 unsigned long flags;
473 int ret;
474
475 spin_lock_irqsave(&alchemy_usb_lock, flags);
476 switch (alchemy_get_cputype()) {
477 case ALCHEMY_CPU_AU1000:
478 case ALCHEMY_CPU_AU1500:
479 case ALCHEMY_CPU_AU1100:
480 ret = au1000_usb_control(block, enable,
481 AU1000_USB_OHCI_PHYS_ADDR, AU1000_OHCICFG);
482 break;
483 case ALCHEMY_CPU_AU1550:
484 ret = au1000_usb_control(block, enable,
485 AU1550_USB_OHCI_PHYS_ADDR, AU1550_OHCICFG);
486 break;
487 case ALCHEMY_CPU_AU1200:
488 ret = au1200_usb_control(block, enable);
489 break;
490 case ALCHEMY_CPU_AU1300:
491 ret = au1300_usb_control(block, enable);
492 break;
493 default:
494 ret = -ENODEV;
495 }
496 spin_unlock_irqrestore(&alchemy_usb_lock, flags);
497 return ret;
498}
499EXPORT_SYMBOL_GPL(alchemy_usb_control);
500
501
502static unsigned long alchemy_usb_pmdata[2];
503
504static void au1000_usb_pm(unsigned long br, int creg, int susp)
505{
506 void __iomem *base = (void __iomem *)KSEG1ADDR(br);
507
508 if (susp) {
509 alchemy_usb_pmdata[0] = __raw_readl(base + creg);
510 /* There appears to be some undocumented reset register.... */
511 __raw_writel(0, base + 0x04);
512 wmb();
513 __raw_writel(0, base + creg);
514 wmb();
515 } else {
516 __raw_writel(alchemy_usb_pmdata[0], base + creg);
517 wmb();
518 }
519}
520
521static void au1200_usb_pm(int susp)
522{
523 void __iomem *base =
524 (void __iomem *)KSEG1ADDR(AU1200_USB_OTG_PHYS_ADDR);
525 if (susp) {
526 /* save OTG_CAP/MUX registers which indicate port routing */
527 /* FIXME: write an OTG driver to do that */
528 alchemy_usb_pmdata[0] = __raw_readl(base + 0x00);
529 alchemy_usb_pmdata[1] = __raw_readl(base + 0x04);
530 } else {
531 /* restore access to all MMIO areas */
532 au1200_usb_init();
533
534 /* restore OTG_CAP/MUX registers */
535 __raw_writel(alchemy_usb_pmdata[0], base + 0x00);
536 __raw_writel(alchemy_usb_pmdata[1], base + 0x04);
537 wmb();
538 }
539}
540
541static void au1300_usb_pm(int susp)
542{
543 void __iomem *base =
544 (void __iomem *)KSEG1ADDR(AU1300_USB_CTL_PHYS_ADDR);
545 /* remember Port2 routing */
546 if (susp) {
547 alchemy_usb_pmdata[0] = __raw_readl(base + USB_DWC_CTRL4);
548 } else {
549 au1300_usb_init();
550 __raw_writel(alchemy_usb_pmdata[0], base + USB_DWC_CTRL4);
551 wmb();
552 }
553}
554
555static void alchemy_usb_pm(int susp)
556{
557 switch (alchemy_get_cputype()) {
558 case ALCHEMY_CPU_AU1000:
559 case ALCHEMY_CPU_AU1500:
560 case ALCHEMY_CPU_AU1100:
561 au1000_usb_pm(AU1000_USB_OHCI_PHYS_ADDR, AU1000_OHCICFG, susp);
562 break;
563 case ALCHEMY_CPU_AU1550:
564 au1000_usb_pm(AU1550_USB_OHCI_PHYS_ADDR, AU1550_OHCICFG, susp);
565 break;
566 case ALCHEMY_CPU_AU1200:
567 au1200_usb_pm(susp);
568 break;
569 case ALCHEMY_CPU_AU1300:
570 au1300_usb_pm(susp);
571 break;
572 }
573}
574
575static int alchemy_usb_suspend(void)
576{
577 alchemy_usb_pm(1);
578 return 0;
579}
580
581static void alchemy_usb_resume(void)
582{
583 alchemy_usb_pm(0);
584}
585
586static struct syscore_ops alchemy_usb_pm_ops = {
587 .suspend = alchemy_usb_suspend,
588 .resume = alchemy_usb_resume,
589};
590
591static int __init alchemy_usb_init(void)
592{
593 switch (alchemy_get_cputype()) {
594 case ALCHEMY_CPU_AU1000:
595 case ALCHEMY_CPU_AU1500:
596 case ALCHEMY_CPU_AU1100:
597 au1000_usb_init(AU1000_USB_OHCI_PHYS_ADDR, AU1000_OHCICFG);
598 break;
599 case ALCHEMY_CPU_AU1550:
600 au1000_usb_init(AU1550_USB_OHCI_PHYS_ADDR, AU1550_OHCICFG);
601 break;
602 case ALCHEMY_CPU_AU1200:
603 au1200_usb_init();
604 break;
605 case ALCHEMY_CPU_AU1300:
606 au1300_usb_init();
607 break;
608 }
609
610 register_syscore_ops(&alchemy_usb_pm_ops);
611
612 return 0;
613}
614arch_initcall(alchemy_usb_init);
diff --git a/drivers/usb/host/ehci-atmel.c b/drivers/usb/host/ehci-atmel.c
index 411bb74152eb..d23321ec0e46 100644
--- a/drivers/usb/host/ehci-atmel.c
+++ b/drivers/usb/host/ehci-atmel.c
@@ -53,18 +53,11 @@ static void atmel_stop_ehci(struct platform_device *pdev)
53static int ehci_atmel_setup(struct usb_hcd *hcd) 53static int ehci_atmel_setup(struct usb_hcd *hcd)
54{ 54{
55 struct ehci_hcd *ehci = hcd_to_ehci(hcd); 55 struct ehci_hcd *ehci = hcd_to_ehci(hcd);
56 int retval;
57 56
58 /* registers start at offset 0x0 */ 57 /* registers start at offset 0x0 */
59 ehci->caps = hcd->regs; 58 ehci->caps = hcd->regs;
60 59
61 retval = ehci_setup(hcd); 60 return ehci_setup(hcd);
62 if (retval)
63 return retval;
64
65 ehci_port_power(ehci, 0);
66
67 return retval;
68} 61}
69 62
70static const struct hc_driver ehci_atmel_hc_driver = { 63static const struct hc_driver ehci_atmel_hc_driver = {
diff --git a/drivers/usb/host/ehci-au1xxx.c b/drivers/usb/host/ehci-au1xxx.c
deleted file mode 100644
index 65c945eb4144..000000000000
--- a/drivers/usb/host/ehci-au1xxx.c
+++ /dev/null
@@ -1,184 +0,0 @@
1/*
2 * EHCI HCD (Host Controller Driver) for USB.
3 *
4 * Bus Glue for AMD Alchemy Au1xxx
5 *
6 * Based on "ohci-au1xxx.c" by Matt Porter <mporter@kernel.crashing.org>
7 *
8 * Modified for AMD Alchemy Au1200 EHC
9 * by K.Boge <karsten.boge@amd.com>
10 *
11 * This file is licenced under the GPL.
12 */
13
14#include <linux/platform_device.h>
15#include <asm/mach-au1x00/au1000.h>
16
17
18extern int usb_disabled(void);
19
20static int au1xxx_ehci_setup(struct usb_hcd *hcd)
21{
22 struct ehci_hcd *ehci = hcd_to_ehci(hcd);
23 int ret;
24
25 ehci->caps = hcd->regs;
26 ret = ehci_setup(hcd);
27
28 ehci->need_io_watchdog = 0;
29 return ret;
30}
31
32static const struct hc_driver ehci_au1xxx_hc_driver = {
33 .description = hcd_name,
34 .product_desc = "Au1xxx EHCI",
35 .hcd_priv_size = sizeof(struct ehci_hcd),
36
37 /*
38 * generic hardware linkage
39 */
40 .irq = ehci_irq,
41 .flags = HCD_MEMORY | HCD_USB2,
42
43 /*
44 * basic lifecycle operations
45 *
46 * FIXME -- ehci_init() doesn't do enough here.
47 * See ehci-ppc-soc for a complete implementation.
48 */
49 .reset = au1xxx_ehci_setup,
50 .start = ehci_run,
51 .stop = ehci_stop,
52 .shutdown = ehci_shutdown,
53
54 /*
55 * managing i/o requests and associated device resources
56 */
57 .urb_enqueue = ehci_urb_enqueue,
58 .urb_dequeue = ehci_urb_dequeue,
59 .endpoint_disable = ehci_endpoint_disable,
60 .endpoint_reset = ehci_endpoint_reset,
61
62 /*
63 * scheduling support
64 */
65 .get_frame_number = ehci_get_frame,
66
67 /*
68 * root hub support
69 */
70 .hub_status_data = ehci_hub_status_data,
71 .hub_control = ehci_hub_control,
72 .bus_suspend = ehci_bus_suspend,
73 .bus_resume = ehci_bus_resume,
74 .relinquish_port = ehci_relinquish_port,
75 .port_handed_over = ehci_port_handed_over,
76
77 .clear_tt_buffer_complete = ehci_clear_tt_buffer_complete,
78};
79
80static int ehci_hcd_au1xxx_drv_probe(struct platform_device *pdev)
81{
82 struct usb_hcd *hcd;
83 struct resource *res;
84 int ret;
85
86 if (usb_disabled())
87 return -ENODEV;
88
89 if (pdev->resource[1].flags != IORESOURCE_IRQ) {
90 pr_debug("resource[1] is not IORESOURCE_IRQ");
91 return -ENOMEM;
92 }
93 hcd = usb_create_hcd(&ehci_au1xxx_hc_driver, &pdev->dev, "Au1xxx");
94 if (!hcd)
95 return -ENOMEM;
96
97 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
98 hcd->rsrc_start = res->start;
99 hcd->rsrc_len = resource_size(res);
100
101 hcd->regs = devm_request_and_ioremap(&pdev->dev, res);
102 if (!hcd->regs) {
103 pr_debug("devm_request_and_ioremap failed");
104 ret = -ENOMEM;
105 goto err1;
106 }
107
108 if (alchemy_usb_control(ALCHEMY_USB_EHCI0, 1)) {
109 printk(KERN_INFO "%s: controller init failed!\n", pdev->name);
110 ret = -ENODEV;
111 goto err1;
112 }
113
114 ret = usb_add_hcd(hcd, pdev->resource[1].start,
115 IRQF_SHARED);
116 if (ret == 0) {
117 platform_set_drvdata(pdev, hcd);
118 return ret;
119 }
120
121 alchemy_usb_control(ALCHEMY_USB_EHCI0, 0);
122err1:
123 usb_put_hcd(hcd);
124 return ret;
125}
126
127static int ehci_hcd_au1xxx_drv_remove(struct platform_device *pdev)
128{
129 struct usb_hcd *hcd = platform_get_drvdata(pdev);
130
131 usb_remove_hcd(hcd);
132 alchemy_usb_control(ALCHEMY_USB_EHCI0, 0);
133 usb_put_hcd(hcd);
134 platform_set_drvdata(pdev, NULL);
135
136 return 0;
137}
138
139#ifdef CONFIG_PM
140static int ehci_hcd_au1xxx_drv_suspend(struct device *dev)
141{
142 struct usb_hcd *hcd = dev_get_drvdata(dev);
143 bool do_wakeup = device_may_wakeup(dev);
144 int rc;
145
146 rc = ehci_suspend(hcd, do_wakeup);
147 alchemy_usb_control(ALCHEMY_USB_EHCI0, 0);
148
149 return rc;
150}
151
152static int ehci_hcd_au1xxx_drv_resume(struct device *dev)
153{
154 struct usb_hcd *hcd = dev_get_drvdata(dev);
155
156 alchemy_usb_control(ALCHEMY_USB_EHCI0, 1);
157 ehci_resume(hcd, false);
158
159 return 0;
160}
161
162static const struct dev_pm_ops au1xxx_ehci_pmops = {
163 .suspend = ehci_hcd_au1xxx_drv_suspend,
164 .resume = ehci_hcd_au1xxx_drv_resume,
165};
166
167#define AU1XXX_EHCI_PMOPS &au1xxx_ehci_pmops
168
169#else
170#define AU1XXX_EHCI_PMOPS NULL
171#endif
172
173static struct platform_driver ehci_hcd_au1xxx_driver = {
174 .probe = ehci_hcd_au1xxx_drv_probe,
175 .remove = ehci_hcd_au1xxx_drv_remove,
176 .shutdown = usb_hcd_platform_shutdown,
177 .driver = {
178 .name = "au1xxx-ehci",
179 .owner = THIS_MODULE,
180 .pm = AU1XXX_EHCI_PMOPS,
181 }
182};
183
184MODULE_ALIAS("platform:au1xxx-ehci");
diff --git a/drivers/usb/host/ehci-cns3xxx.c b/drivers/usb/host/ehci-cns3xxx.c
deleted file mode 100644
index d91708d2e729..000000000000
--- a/drivers/usb/host/ehci-cns3xxx.c
+++ /dev/null
@@ -1,155 +0,0 @@
1/*
2 * Copyright 2008 Cavium Networks
3 *
4 * This file is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License, Version 2, as
6 * published by the Free Software Foundation.
7 */
8
9#include <linux/platform_device.h>
10#include <linux/atomic.h>
11#include <mach/cns3xxx.h>
12#include <mach/pm.h>
13
14static int cns3xxx_ehci_init(struct usb_hcd *hcd)
15{
16 struct ehci_hcd *ehci = hcd_to_ehci(hcd);
17 int retval;
18
19 /*
20 * EHCI and OHCI share the same clock and power,
21 * resetting twice would cause the 1st controller been reset.
22 * Therefore only do power up at the first up device, and
23 * power down at the last down device.
24 *
25 * Set USB AHB INCR length to 16
26 */
27 if (atomic_inc_return(&usb_pwr_ref) == 1) {
28 cns3xxx_pwr_power_up(1 << PM_PLL_HM_PD_CTRL_REG_OFFSET_PLL_USB);
29 cns3xxx_pwr_clk_en(1 << PM_CLK_GATE_REG_OFFSET_USB_HOST);
30 cns3xxx_pwr_soft_rst(1 << PM_SOFT_RST_REG_OFFST_USB_HOST);
31 __raw_writel((__raw_readl(MISC_CHIP_CONFIG_REG) | (0X2 << 24)),
32 MISC_CHIP_CONFIG_REG);
33 }
34
35 ehci->caps = hcd->regs;
36
37 hcd->has_tt = 0;
38
39 retval = ehci_setup(hcd);
40 if (retval)
41 return retval;
42
43 ehci_port_power(ehci, 0);
44
45 return retval;
46}
47
48static const struct hc_driver cns3xxx_ehci_hc_driver = {
49 .description = hcd_name,
50 .product_desc = "CNS3XXX EHCI Host Controller",
51 .hcd_priv_size = sizeof(struct ehci_hcd),
52 .irq = ehci_irq,
53 .flags = HCD_MEMORY | HCD_USB2,
54 .reset = cns3xxx_ehci_init,
55 .start = ehci_run,
56 .stop = ehci_stop,
57 .shutdown = ehci_shutdown,
58 .urb_enqueue = ehci_urb_enqueue,
59 .urb_dequeue = ehci_urb_dequeue,
60 .endpoint_disable = ehci_endpoint_disable,
61 .endpoint_reset = ehci_endpoint_reset,
62 .get_frame_number = ehci_get_frame,
63 .hub_status_data = ehci_hub_status_data,
64 .hub_control = ehci_hub_control,
65#ifdef CONFIG_PM
66 .bus_suspend = ehci_bus_suspend,
67 .bus_resume = ehci_bus_resume,
68#endif
69 .relinquish_port = ehci_relinquish_port,
70 .port_handed_over = ehci_port_handed_over,
71
72 .clear_tt_buffer_complete = ehci_clear_tt_buffer_complete,
73};
74
75static int cns3xxx_ehci_probe(struct platform_device *pdev)
76{
77 struct device *dev = &pdev->dev;
78 struct usb_hcd *hcd;
79 const struct hc_driver *driver = &cns3xxx_ehci_hc_driver;
80 struct resource *res;
81 int irq;
82 int retval;
83
84 if (usb_disabled())
85 return -ENODEV;
86
87 res = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
88 if (!res) {
89 dev_err(dev, "Found HC with no IRQ.\n");
90 return -ENODEV;
91 }
92 irq = res->start;
93
94 hcd = usb_create_hcd(driver, &pdev->dev, dev_name(&pdev->dev));
95 if (!hcd)
96 return -ENOMEM;
97
98 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
99 if (!res) {
100 dev_err(dev, "Found HC with no register addr.\n");
101 retval = -ENODEV;
102 goto err1;
103 }
104
105 hcd->rsrc_start = res->start;
106 hcd->rsrc_len = resource_size(res);
107
108 hcd->regs = devm_request_and_ioremap(&pdev->dev, res);
109 if (hcd->regs == NULL) {
110 dev_dbg(dev, "error mapping memory\n");
111 retval = -EFAULT;
112 goto err1;
113 }
114
115 retval = usb_add_hcd(hcd, irq, IRQF_SHARED);
116 if (retval == 0)
117 return retval;
118
119err1:
120 usb_put_hcd(hcd);
121
122 return retval;
123}
124
125static int cns3xxx_ehci_remove(struct platform_device *pdev)
126{
127 struct usb_hcd *hcd = platform_get_drvdata(pdev);
128
129 usb_remove_hcd(hcd);
130
131 /*
132 * EHCI and OHCI share the same clock and power,
133 * resetting twice would cause the 1st controller been reset.
134 * Therefore only do power up at the first up device, and
135 * power down at the last down device.
136 */
137 if (atomic_dec_return(&usb_pwr_ref) == 0)
138 cns3xxx_pwr_clk_dis(1 << PM_CLK_GATE_REG_OFFSET_USB_HOST);
139
140 usb_put_hcd(hcd);
141
142 platform_set_drvdata(pdev, NULL);
143
144 return 0;
145}
146
147MODULE_ALIAS("platform:cns3xxx-ehci");
148
149static struct platform_driver cns3xxx_ehci_driver = {
150 .probe = cns3xxx_ehci_probe,
151 .remove = cns3xxx_ehci_remove,
152 .driver = {
153 .name = "cns3xxx-ehci",
154 },
155};
diff --git a/drivers/usb/host/ehci-dbg.c b/drivers/usb/host/ehci-dbg.c
index 1599806e3d47..70b496dc18a0 100644
--- a/drivers/usb/host/ehci-dbg.c
+++ b/drivers/usb/host/ehci-dbg.c
@@ -18,21 +18,6 @@
18 18
19/* this file is part of ehci-hcd.c */ 19/* this file is part of ehci-hcd.c */
20 20
21#define ehci_dbg(ehci, fmt, args...) \
22 dev_dbg (ehci_to_hcd(ehci)->self.controller , fmt , ## args )
23#define ehci_err(ehci, fmt, args...) \
24 dev_err (ehci_to_hcd(ehci)->self.controller , fmt , ## args )
25#define ehci_info(ehci, fmt, args...) \
26 dev_info (ehci_to_hcd(ehci)->self.controller , fmt , ## args )
27#define ehci_warn(ehci, fmt, args...) \
28 dev_warn (ehci_to_hcd(ehci)->self.controller , fmt , ## args )
29
30#ifdef VERBOSE_DEBUG
31# define ehci_vdbg ehci_dbg
32#else
33 static inline void ehci_vdbg(struct ehci_hcd *ehci, ...) {}
34#endif
35
36#ifdef DEBUG 21#ifdef DEBUG
37 22
38/* check the values in the HCSPARAMS register 23/* check the values in the HCSPARAMS register
@@ -352,11 +337,6 @@ static int debug_async_open(struct inode *, struct file *);
352static int debug_periodic_open(struct inode *, struct file *); 337static int debug_periodic_open(struct inode *, struct file *);
353static int debug_registers_open(struct inode *, struct file *); 338static int debug_registers_open(struct inode *, struct file *);
354static int debug_async_open(struct inode *, struct file *); 339static int debug_async_open(struct inode *, struct file *);
355static ssize_t debug_lpm_read(struct file *file, char __user *user_buf,
356 size_t count, loff_t *ppos);
357static ssize_t debug_lpm_write(struct file *file, const char __user *buffer,
358 size_t count, loff_t *ppos);
359static int debug_lpm_close(struct inode *inode, struct file *file);
360 340
361static ssize_t debug_output(struct file*, char __user*, size_t, loff_t*); 341static ssize_t debug_output(struct file*, char __user*, size_t, loff_t*);
362static int debug_close(struct inode *, struct file *); 342static int debug_close(struct inode *, struct file *);
@@ -382,14 +362,6 @@ static const struct file_operations debug_registers_fops = {
382 .release = debug_close, 362 .release = debug_close,
383 .llseek = default_llseek, 363 .llseek = default_llseek,
384}; 364};
385static const struct file_operations debug_lpm_fops = {
386 .owner = THIS_MODULE,
387 .open = simple_open,
388 .read = debug_lpm_read,
389 .write = debug_lpm_write,
390 .release = debug_lpm_close,
391 .llseek = noop_llseek,
392};
393 365
394static struct dentry *ehci_debug_root; 366static struct dentry *ehci_debug_root;
395 367
@@ -971,86 +943,6 @@ static int debug_registers_open(struct inode *inode, struct file *file)
971 return file->private_data ? 0 : -ENOMEM; 943 return file->private_data ? 0 : -ENOMEM;
972} 944}
973 945
974static int debug_lpm_close(struct inode *inode, struct file *file)
975{
976 return 0;
977}
978
979static ssize_t debug_lpm_read(struct file *file, char __user *user_buf,
980 size_t count, loff_t *ppos)
981{
982 /* TODO: show lpm stats */
983 return 0;
984}
985
986static ssize_t debug_lpm_write(struct file *file, const char __user *user_buf,
987 size_t count, loff_t *ppos)
988{
989 struct usb_hcd *hcd;
990 struct ehci_hcd *ehci;
991 char buf[50];
992 size_t len;
993 u32 temp;
994 unsigned long port;
995 u32 __iomem *portsc ;
996 u32 params;
997
998 hcd = bus_to_hcd(file->private_data);
999 ehci = hcd_to_ehci(hcd);
1000
1001 len = min(count, sizeof(buf) - 1);
1002 if (copy_from_user(buf, user_buf, len))
1003 return -EFAULT;
1004 buf[len] = '\0';
1005 if (len > 0 && buf[len - 1] == '\n')
1006 buf[len - 1] = '\0';
1007
1008 if (strncmp(buf, "enable", 5) == 0) {
1009 if (strict_strtoul(buf + 7, 10, &port))
1010 return -EINVAL;
1011 params = ehci_readl(ehci, &ehci->caps->hcs_params);
1012 if (port > HCS_N_PORTS(params)) {
1013 ehci_dbg(ehci, "ERR: LPM on bad port %lu\n", port);
1014 return -ENODEV;
1015 }
1016 portsc = &ehci->regs->port_status[port-1];
1017 temp = ehci_readl(ehci, portsc);
1018 if (!(temp & PORT_DEV_ADDR)) {
1019 ehci_dbg(ehci, "LPM: no device attached\n");
1020 return -ENODEV;
1021 }
1022 temp |= PORT_LPM;
1023 ehci_writel(ehci, temp, portsc);
1024 printk(KERN_INFO "force enable LPM for port %lu\n", port);
1025 } else if (strncmp(buf, "hird=", 5) == 0) {
1026 unsigned long hird;
1027 if (strict_strtoul(buf + 5, 16, &hird))
1028 return -EINVAL;
1029 printk(KERN_INFO "setting hird %s %lu\n", buf + 6, hird);
1030 ehci->command = (ehci->command & ~CMD_HIRD) | (hird << 24);
1031 ehci_writel(ehci, ehci->command, &ehci->regs->command);
1032 } else if (strncmp(buf, "disable", 7) == 0) {
1033 if (strict_strtoul(buf + 8, 10, &port))
1034 return -EINVAL;
1035 params = ehci_readl(ehci, &ehci->caps->hcs_params);
1036 if (port > HCS_N_PORTS(params)) {
1037 ehci_dbg(ehci, "ERR: LPM off bad port %lu\n", port);
1038 return -ENODEV;
1039 }
1040 portsc = &ehci->regs->port_status[port-1];
1041 temp = ehci_readl(ehci, portsc);
1042 if (!(temp & PORT_DEV_ADDR)) {
1043 ehci_dbg(ehci, "ERR: no device attached\n");
1044 return -ENODEV;
1045 }
1046 temp &= ~PORT_LPM;
1047 ehci_writel(ehci, temp, portsc);
1048 printk(KERN_INFO "disabled LPM for port %lu\n", port);
1049 } else
1050 return -EOPNOTSUPP;
1051 return count;
1052}
1053
1054static inline void create_debug_files (struct ehci_hcd *ehci) 946static inline void create_debug_files (struct ehci_hcd *ehci)
1055{ 947{
1056 struct usb_bus *bus = &ehci_to_hcd(ehci)->self; 948 struct usb_bus *bus = &ehci_to_hcd(ehci)->self;
@@ -1071,10 +963,6 @@ static inline void create_debug_files (struct ehci_hcd *ehci)
1071 &debug_registers_fops)) 963 &debug_registers_fops))
1072 goto file_error; 964 goto file_error;
1073 965
1074 if (!debugfs_create_file("lpm", S_IRUGO|S_IWUSR, ehci->debug_dir, bus,
1075 &debug_lpm_fops))
1076 goto file_error;
1077
1078 return; 966 return;
1079 967
1080file_error: 968file_error:
diff --git a/drivers/usb/host/ehci-fsl.c b/drivers/usb/host/ehci-fsl.c
index 0d2f35ca93f1..fd9b5424b860 100644
--- a/drivers/usb/host/ehci-fsl.c
+++ b/drivers/usb/host/ehci-fsl.c
@@ -349,7 +349,6 @@ static int ehci_fsl_reinit(struct ehci_hcd *ehci)
349{ 349{
350 if (ehci_fsl_usb_setup(ehci)) 350 if (ehci_fsl_usb_setup(ehci))
351 return -EINVAL; 351 return -EINVAL;
352 ehci_port_power(ehci, 0);
353 352
354 return 0; 353 return 0;
355} 354}
diff --git a/drivers/usb/host/ehci-grlib.c b/drivers/usb/host/ehci-grlib.c
index 3180cb3624d9..da4269550fba 100644
--- a/drivers/usb/host/ehci-grlib.c
+++ b/drivers/usb/host/ehci-grlib.c
@@ -34,22 +34,6 @@
34 34
35#define GRUSBHC_HCIVERSION 0x0100 /* Known value of cap. reg. HCIVERSION */ 35#define GRUSBHC_HCIVERSION 0x0100 /* Known value of cap. reg. HCIVERSION */
36 36
37/* called during probe() after chip reset completes */
38static int ehci_grlib_setup(struct usb_hcd *hcd)
39{
40 struct ehci_hcd *ehci = hcd_to_ehci(hcd);
41 int retval;
42
43 retval = ehci_setup(hcd);
44 if (retval)
45 return retval;
46
47 ehci_port_power(ehci, 1);
48
49 return retval;
50}
51
52
53static const struct hc_driver ehci_grlib_hc_driver = { 37static const struct hc_driver ehci_grlib_hc_driver = {
54 .description = hcd_name, 38 .description = hcd_name,
55 .product_desc = "GRLIB GRUSBHC EHCI", 39 .product_desc = "GRLIB GRUSBHC EHCI",
@@ -64,7 +48,7 @@ static const struct hc_driver ehci_grlib_hc_driver = {
64 /* 48 /*
65 * basic lifecycle operations 49 * basic lifecycle operations
66 */ 50 */
67 .reset = ehci_grlib_setup, 51 .reset = ehci_setup,
68 .start = ehci_run, 52 .start = ehci_run,
69 .stop = ehci_stop, 53 .stop = ehci_stop,
70 .shutdown = ehci_shutdown, 54 .shutdown = ehci_shutdown,
diff --git a/drivers/usb/host/ehci-hcd.c b/drivers/usb/host/ehci-hcd.c
index 6bf6c42481e8..c97503bb0b0e 100644
--- a/drivers/usb/host/ehci-hcd.c
+++ b/drivers/usb/host/ehci-hcd.c
@@ -39,7 +39,6 @@
39#include <linux/dma-mapping.h> 39#include <linux/dma-mapping.h>
40#include <linux/debugfs.h> 40#include <linux/debugfs.h>
41#include <linux/slab.h> 41#include <linux/slab.h>
42#include <linux/uaccess.h>
43 42
44#include <asm/byteorder.h> 43#include <asm/byteorder.h>
45#include <asm/io.h> 44#include <asm/io.h>
@@ -108,19 +107,39 @@ static bool ignore_oc = 0;
108module_param (ignore_oc, bool, S_IRUGO); 107module_param (ignore_oc, bool, S_IRUGO);
109MODULE_PARM_DESC (ignore_oc, "ignore bogus hardware overcurrent indications"); 108MODULE_PARM_DESC (ignore_oc, "ignore bogus hardware overcurrent indications");
110 109
111/* for link power management(LPM) feature */
112static unsigned int hird;
113module_param(hird, int, S_IRUGO);
114MODULE_PARM_DESC(hird, "host initiated resume duration, +1 for each 75us");
115
116#define INTR_MASK (STS_IAA | STS_FATAL | STS_PCD | STS_ERR | STS_INT) 110#define INTR_MASK (STS_IAA | STS_FATAL | STS_PCD | STS_ERR | STS_INT)
117 111
118/*-------------------------------------------------------------------------*/ 112/*-------------------------------------------------------------------------*/
119 113
120#include "ehci.h" 114#include "ehci.h"
121#include "ehci-dbg.c"
122#include "pci-quirks.h" 115#include "pci-quirks.h"
123 116
117/*
118 * The MosChip MCS9990 controller updates its microframe counter
119 * a little before the frame counter, and occasionally we will read
120 * the invalid intermediate value. Avoid problems by checking the
121 * microframe number (the low-order 3 bits); if they are 0 then
122 * re-read the register to get the correct value.
123 */
124static unsigned ehci_moschip_read_frame_index(struct ehci_hcd *ehci)
125{
126 unsigned uf;
127
128 uf = ehci_readl(ehci, &ehci->regs->frame_index);
129 if (unlikely((uf & 7) == 0))
130 uf = ehci_readl(ehci, &ehci->regs->frame_index);
131 return uf;
132}
133
134static inline unsigned ehci_read_frame_index(struct ehci_hcd *ehci)
135{
136 if (ehci->frame_index_bug)
137 return ehci_moschip_read_frame_index(ehci);
138 return ehci_readl(ehci, &ehci->regs->frame_index);
139}
140
141#include "ehci-dbg.c"
142
124/*-------------------------------------------------------------------------*/ 143/*-------------------------------------------------------------------------*/
125 144
126/* 145/*
@@ -293,7 +312,6 @@ static void end_unlink_intr(struct ehci_hcd *ehci, struct ehci_qh *qh);
293 312
294#include "ehci-timer.c" 313#include "ehci-timer.c"
295#include "ehci-hub.c" 314#include "ehci-hub.c"
296#include "ehci-lpm.c"
297#include "ehci-mem.c" 315#include "ehci-mem.c"
298#include "ehci-q.c" 316#include "ehci-q.c"
299#include "ehci-sched.c" 317#include "ehci-sched.c"
@@ -353,24 +371,6 @@ static void ehci_shutdown(struct usb_hcd *hcd)
353 hrtimer_cancel(&ehci->hrtimer); 371 hrtimer_cancel(&ehci->hrtimer);
354} 372}
355 373
356static void ehci_port_power (struct ehci_hcd *ehci, int is_on)
357{
358 unsigned port;
359
360 if (!HCS_PPC (ehci->hcs_params))
361 return;
362
363 ehci_dbg (ehci, "...power%s ports...\n", is_on ? "up" : "down");
364 for (port = HCS_N_PORTS (ehci->hcs_params); port > 0; )
365 (void) ehci_hub_control(ehci_to_hcd(ehci),
366 is_on ? SetPortFeature : ClearPortFeature,
367 USB_PORT_FEAT_POWER,
368 port--, NULL, 0);
369 /* Flush those writes */
370 ehci_readl(ehci, &ehci->regs->command);
371 msleep(20);
372}
373
374/*-------------------------------------------------------------------------*/ 374/*-------------------------------------------------------------------------*/
375 375
376/* 376/*
@@ -503,7 +503,7 @@ static int ehci_init(struct usb_hcd *hcd)
503 503
504 /* controllers may cache some of the periodic schedule ... */ 504 /* controllers may cache some of the periodic schedule ... */
505 if (HCC_ISOC_CACHE(hcc_params)) // full frame cache 505 if (HCC_ISOC_CACHE(hcc_params)) // full frame cache
506 ehci->i_thresh = 2 + 8; 506 ehci->i_thresh = 0;
507 else // N microframes cached 507 else // N microframes cached
508 ehci->i_thresh = 2 + HCC_ISOC_THRES(hcc_params); 508 ehci->i_thresh = 2 + HCC_ISOC_THRES(hcc_params);
509 509
@@ -555,17 +555,6 @@ static int ehci_init(struct usb_hcd *hcd)
555 temp &= ~(3 << 2); 555 temp &= ~(3 << 2);
556 temp |= (EHCI_TUNE_FLS << 2); 556 temp |= (EHCI_TUNE_FLS << 2);
557 } 557 }
558 if (HCC_LPM(hcc_params)) {
559 /* support link power management EHCI 1.1 addendum */
560 ehci_dbg(ehci, "support lpm\n");
561 ehci->has_lpm = 1;
562 if (hird > 0xf) {
563 ehci_dbg(ehci, "hird %d invalid, use default 0",
564 hird);
565 hird = 0;
566 }
567 temp |= hird << 24;
568 }
569 ehci->command = temp; 558 ehci->command = temp;
570 559
571 /* Accept arbitrarily long scatter-gather lists */ 560 /* Accept arbitrarily long scatter-gather lists */
@@ -660,7 +649,7 @@ static int ehci_run (struct usb_hcd *hcd)
660 return 0; 649 return 0;
661} 650}
662 651
663static int ehci_setup(struct usb_hcd *hcd) 652int ehci_setup(struct usb_hcd *hcd)
664{ 653{
665 struct ehci_hcd *ehci = hcd_to_ehci(hcd); 654 struct ehci_hcd *ehci = hcd_to_ehci(hcd);
666 int retval; 655 int retval;
@@ -691,6 +680,7 @@ static int ehci_setup(struct usb_hcd *hcd)
691 680
692 return 0; 681 return 0;
693} 682}
683EXPORT_SYMBOL_GPL(ehci_setup);
694 684
695/*-------------------------------------------------------------------------*/ 685/*-------------------------------------------------------------------------*/
696 686
@@ -1096,7 +1086,7 @@ static int ehci_get_frame (struct usb_hcd *hcd)
1096 1086
1097/* These routines handle the generic parts of controller suspend/resume */ 1087/* These routines handle the generic parts of controller suspend/resume */
1098 1088
1099static int __maybe_unused ehci_suspend(struct usb_hcd *hcd, bool do_wakeup) 1089int ehci_suspend(struct usb_hcd *hcd, bool do_wakeup)
1100{ 1090{
1101 struct ehci_hcd *ehci = hcd_to_ehci(hcd); 1091 struct ehci_hcd *ehci = hcd_to_ehci(hcd);
1102 1092
@@ -1119,9 +1109,10 @@ static int __maybe_unused ehci_suspend(struct usb_hcd *hcd, bool do_wakeup)
1119 1109
1120 return 0; 1110 return 0;
1121} 1111}
1112EXPORT_SYMBOL_GPL(ehci_suspend);
1122 1113
1123/* Returns 0 if power was preserved, 1 if power was lost */ 1114/* Returns 0 if power was preserved, 1 if power was lost */
1124static int __maybe_unused ehci_resume(struct usb_hcd *hcd, bool hibernated) 1115int ehci_resume(struct usb_hcd *hcd, bool hibernated)
1125{ 1116{
1126 struct ehci_hcd *ehci = hcd_to_ehci(hcd); 1117 struct ehci_hcd *ehci = hcd_to_ehci(hcd);
1127 1118
@@ -1177,33 +1168,83 @@ static int __maybe_unused ehci_resume(struct usb_hcd *hcd, bool hibernated)
1177 ehci->rh_state = EHCI_RH_SUSPENDED; 1168 ehci->rh_state = EHCI_RH_SUSPENDED;
1178 spin_unlock_irq(&ehci->lock); 1169 spin_unlock_irq(&ehci->lock);
1179 1170
1180 /* here we "know" root ports should always stay powered */
1181 ehci_port_power(ehci, 1);
1182
1183 return 1; 1171 return 1;
1184} 1172}
1173EXPORT_SYMBOL_GPL(ehci_resume);
1185 1174
1186#endif 1175#endif
1187 1176
1188/*-------------------------------------------------------------------------*/ 1177/*-------------------------------------------------------------------------*/
1189 1178
1190/* 1179/*
1191 * The EHCI in ChipIdea HDRC cannot be a separate module or device, 1180 * Generic structure: This gets copied for platform drivers so that
1192 * because its registers (and irq) are shared between host/gadget/otg 1181 * individual entries can be overridden as needed.
1193 * functions and in order to facilitate role switching we cannot
1194 * give the ehci driver exclusive access to those.
1195 */ 1182 */
1196#ifndef CHIPIDEA_EHCI 1183
1184static const struct hc_driver ehci_hc_driver = {
1185 .description = hcd_name,
1186 .product_desc = "EHCI Host Controller",
1187 .hcd_priv_size = sizeof(struct ehci_hcd),
1188
1189 /*
1190 * generic hardware linkage
1191 */
1192 .irq = ehci_irq,
1193 .flags = HCD_MEMORY | HCD_USB2,
1194
1195 /*
1196 * basic lifecycle operations
1197 */
1198 .reset = ehci_setup,
1199 .start = ehci_run,
1200 .stop = ehci_stop,
1201 .shutdown = ehci_shutdown,
1202
1203 /*
1204 * managing i/o requests and associated device resources
1205 */
1206 .urb_enqueue = ehci_urb_enqueue,
1207 .urb_dequeue = ehci_urb_dequeue,
1208 .endpoint_disable = ehci_endpoint_disable,
1209 .endpoint_reset = ehci_endpoint_reset,
1210 .clear_tt_buffer_complete = ehci_clear_tt_buffer_complete,
1211
1212 /*
1213 * scheduling support
1214 */
1215 .get_frame_number = ehci_get_frame,
1216
1217 /*
1218 * root hub support
1219 */
1220 .hub_status_data = ehci_hub_status_data,
1221 .hub_control = ehci_hub_control,
1222 .bus_suspend = ehci_bus_suspend,
1223 .bus_resume = ehci_bus_resume,
1224 .relinquish_port = ehci_relinquish_port,
1225 .port_handed_over = ehci_port_handed_over,
1226};
1227
1228void ehci_init_driver(struct hc_driver *drv,
1229 const struct ehci_driver_overrides *over)
1230{
1231 /* Copy the generic table to drv and then apply the overrides */
1232 *drv = ehci_hc_driver;
1233
1234 if (over) {
1235 drv->hcd_priv_size += over->extra_priv_size;
1236 if (over->reset)
1237 drv->reset = over->reset;
1238 }
1239}
1240EXPORT_SYMBOL_GPL(ehci_init_driver);
1241
1242/*-------------------------------------------------------------------------*/
1197 1243
1198MODULE_DESCRIPTION(DRIVER_DESC); 1244MODULE_DESCRIPTION(DRIVER_DESC);
1199MODULE_AUTHOR (DRIVER_AUTHOR); 1245MODULE_AUTHOR (DRIVER_AUTHOR);
1200MODULE_LICENSE ("GPL"); 1246MODULE_LICENSE ("GPL");
1201 1247
1202#ifdef CONFIG_PCI
1203#include "ehci-pci.c"
1204#define PCI_DRIVER ehci_pci_driver
1205#endif
1206
1207#ifdef CONFIG_USB_EHCI_FSL 1248#ifdef CONFIG_USB_EHCI_FSL
1208#include "ehci-fsl.c" 1249#include "ehci-fsl.c"
1209#define PLATFORM_DRIVER ehci_fsl_driver 1250#define PLATFORM_DRIVER ehci_fsl_driver
@@ -1219,11 +1260,6 @@ MODULE_LICENSE ("GPL");
1219#define PLATFORM_DRIVER ehci_hcd_sh_driver 1260#define PLATFORM_DRIVER ehci_hcd_sh_driver
1220#endif 1261#endif
1221 1262
1222#ifdef CONFIG_MIPS_ALCHEMY
1223#include "ehci-au1xxx.c"
1224#define PLATFORM_DRIVER ehci_hcd_au1xxx_driver
1225#endif
1226
1227#ifdef CONFIG_USB_EHCI_HCD_OMAP 1263#ifdef CONFIG_USB_EHCI_HCD_OMAP
1228#include "ehci-omap.c" 1264#include "ehci-omap.c"
1229#define PLATFORM_DRIVER ehci_hcd_omap_driver 1265#define PLATFORM_DRIVER ehci_hcd_omap_driver
@@ -1249,11 +1285,6 @@ MODULE_LICENSE ("GPL");
1249#define PLATFORM_DRIVER ehci_orion_driver 1285#define PLATFORM_DRIVER ehci_orion_driver
1250#endif 1286#endif
1251 1287
1252#ifdef CONFIG_ARCH_IXP4XX
1253#include "ehci-ixp4xx.c"
1254#define PLATFORM_DRIVER ixp4xx_ehci_driver
1255#endif
1256
1257#ifdef CONFIG_USB_W90X900_EHCI 1288#ifdef CONFIG_USB_W90X900_EHCI
1258#include "ehci-w90x900.c" 1289#include "ehci-w90x900.c"
1259#define PLATFORM_DRIVER ehci_hcd_w90x900_driver 1290#define PLATFORM_DRIVER ehci_hcd_w90x900_driver
@@ -1269,11 +1300,6 @@ MODULE_LICENSE ("GPL");
1269#define PLATFORM_DRIVER ehci_octeon_driver 1300#define PLATFORM_DRIVER ehci_octeon_driver
1270#endif 1301#endif
1271 1302
1272#ifdef CONFIG_USB_CNS3XXX_EHCI
1273#include "ehci-cns3xxx.c"
1274#define PLATFORM_DRIVER cns3xxx_ehci_driver
1275#endif
1276
1277#ifdef CONFIG_ARCH_VT8500 1303#ifdef CONFIG_ARCH_VT8500
1278#include "ehci-vt8500.c" 1304#include "ehci-vt8500.c"
1279#define PLATFORM_DRIVER vt8500_ehci_driver 1305#define PLATFORM_DRIVER vt8500_ehci_driver
@@ -1314,34 +1340,23 @@ MODULE_LICENSE ("GPL");
1314#define PLATFORM_DRIVER ehci_grlib_driver 1340#define PLATFORM_DRIVER ehci_grlib_driver
1315#endif 1341#endif
1316 1342
1317#ifdef CONFIG_CPU_XLR
1318#include "ehci-xls.c"
1319#define PLATFORM_DRIVER ehci_xls_driver
1320#endif
1321
1322#ifdef CONFIG_USB_EHCI_MV 1343#ifdef CONFIG_USB_EHCI_MV
1323#include "ehci-mv.c" 1344#include "ehci-mv.c"
1324#define PLATFORM_DRIVER ehci_mv_driver 1345#define PLATFORM_DRIVER ehci_mv_driver
1325#endif 1346#endif
1326 1347
1327#ifdef CONFIG_MACH_LOONGSON1
1328#include "ehci-ls1x.c"
1329#define PLATFORM_DRIVER ehci_ls1x_driver
1330#endif
1331
1332#ifdef CONFIG_MIPS_SEAD3 1348#ifdef CONFIG_MIPS_SEAD3
1333#include "ehci-sead3.c" 1349#include "ehci-sead3.c"
1334#define PLATFORM_DRIVER ehci_hcd_sead3_driver 1350#define PLATFORM_DRIVER ehci_hcd_sead3_driver
1335#endif 1351#endif
1336 1352
1337#ifdef CONFIG_USB_EHCI_HCD_PLATFORM 1353#if !IS_ENABLED(CONFIG_USB_EHCI_PCI) && \
1338#include "ehci-platform.c" 1354 !IS_ENABLED(CONFIG_USB_EHCI_HCD_PLATFORM) && \
1339#define PLATFORM_DRIVER ehci_platform_driver 1355 !defined(CONFIG_USB_CHIPIDEA_HOST) && \
1340#endif 1356 !defined(PLATFORM_DRIVER) && \
1341 1357 !defined(PS3_SYSTEM_BUS_DRIVER) && \
1342#if !defined(PCI_DRIVER) && !defined(PLATFORM_DRIVER) && \ 1358 !defined(OF_PLATFORM_DRIVER) && \
1343 !defined(PS3_SYSTEM_BUS_DRIVER) && !defined(OF_PLATFORM_DRIVER) && \ 1359 !defined(XILINX_OF_PLATFORM_DRIVER)
1344 !defined(XILINX_OF_PLATFORM_DRIVER)
1345#error "missing bus glue for ehci-hcd" 1360#error "missing bus glue for ehci-hcd"
1346#endif 1361#endif
1347 1362
@@ -1378,12 +1393,6 @@ static int __init ehci_hcd_init(void)
1378 goto clean0; 1393 goto clean0;
1379#endif 1394#endif
1380 1395
1381#ifdef PCI_DRIVER
1382 retval = pci_register_driver(&PCI_DRIVER);
1383 if (retval < 0)
1384 goto clean1;
1385#endif
1386
1387#ifdef PS3_SYSTEM_BUS_DRIVER 1396#ifdef PS3_SYSTEM_BUS_DRIVER
1388 retval = ps3_ehci_driver_register(&PS3_SYSTEM_BUS_DRIVER); 1397 retval = ps3_ehci_driver_register(&PS3_SYSTEM_BUS_DRIVER);
1389 if (retval < 0) 1398 if (retval < 0)
@@ -1415,10 +1424,6 @@ clean3:
1415 ps3_ehci_driver_unregister(&PS3_SYSTEM_BUS_DRIVER); 1424 ps3_ehci_driver_unregister(&PS3_SYSTEM_BUS_DRIVER);
1416clean2: 1425clean2:
1417#endif 1426#endif
1418#ifdef PCI_DRIVER
1419 pci_unregister_driver(&PCI_DRIVER);
1420clean1:
1421#endif
1422#ifdef PLATFORM_DRIVER 1427#ifdef PLATFORM_DRIVER
1423 platform_driver_unregister(&PLATFORM_DRIVER); 1428 platform_driver_unregister(&PLATFORM_DRIVER);
1424clean0: 1429clean0:
@@ -1444,9 +1449,6 @@ static void __exit ehci_hcd_cleanup(void)
1444#ifdef PLATFORM_DRIVER 1449#ifdef PLATFORM_DRIVER
1445 platform_driver_unregister(&PLATFORM_DRIVER); 1450 platform_driver_unregister(&PLATFORM_DRIVER);
1446#endif 1451#endif
1447#ifdef PCI_DRIVER
1448 pci_unregister_driver(&PCI_DRIVER);
1449#endif
1450#ifdef PS3_SYSTEM_BUS_DRIVER 1452#ifdef PS3_SYSTEM_BUS_DRIVER
1451 ps3_ehci_driver_unregister(&PS3_SYSTEM_BUS_DRIVER); 1453 ps3_ehci_driver_unregister(&PS3_SYSTEM_BUS_DRIVER);
1452#endif 1454#endif
@@ -1456,5 +1458,3 @@ static void __exit ehci_hcd_cleanup(void)
1456 clear_bit(USB_EHCI_LOADED, &usb_hcds_loaded); 1458 clear_bit(USB_EHCI_LOADED, &usb_hcds_loaded);
1457} 1459}
1458module_exit(ehci_hcd_cleanup); 1460module_exit(ehci_hcd_cleanup);
1459
1460#endif /* CHIPIDEA_EHCI */
diff --git a/drivers/usb/host/ehci-hub.c b/drivers/usb/host/ehci-hub.c
index 914ce9370e70..4ccb97c0678f 100644
--- a/drivers/usb/host/ehci-hub.c
+++ b/drivers/usb/host/ehci-hub.c
@@ -56,6 +56,19 @@ static void ehci_handover_companion_ports(struct ehci_hcd *ehci)
56 if (!ehci->owned_ports) 56 if (!ehci->owned_ports)
57 return; 57 return;
58 58
59 /* Make sure the ports are powered */
60 port = HCS_N_PORTS(ehci->hcs_params);
61 while (port--) {
62 if (test_bit(port, &ehci->owned_ports)) {
63 reg = &ehci->regs->port_status[port];
64 status = ehci_readl(ehci, reg) & ~PORT_RWC_BITS;
65 if (!(status & PORT_POWER)) {
66 status |= PORT_POWER;
67 ehci_writel(ehci, status, reg);
68 }
69 }
70 }
71
59 /* Give the connections some time to appear */ 72 /* Give the connections some time to appear */
60 msleep(20); 73 msleep(20);
61 74
@@ -384,11 +397,24 @@ static int ehci_bus_resume (struct usb_hcd *hcd)
384 ehci_writel(ehci, ehci->command, &ehci->regs->command); 397 ehci_writel(ehci, ehci->command, &ehci->regs->command);
385 ehci->rh_state = EHCI_RH_RUNNING; 398 ehci->rh_state = EHCI_RH_RUNNING;
386 399
387 /* Some controller/firmware combinations need a delay during which 400 /*
388 * they set up the port statuses. See Bugzilla #8190. */ 401 * According to Bugzilla #8190, the port status for some controllers
389 spin_unlock_irq(&ehci->lock); 402 * will be wrong without a delay. At their wrong status, the port
390 msleep(8); 403 * is enabled, but not suspended neither resumed.
391 spin_lock_irq(&ehci->lock); 404 */
405 i = HCS_N_PORTS(ehci->hcs_params);
406 while (i--) {
407 temp = ehci_readl(ehci, &ehci->regs->port_status[i]);
408 if ((temp & PORT_PE) &&
409 !(temp & (PORT_SUSPEND | PORT_RESUME))) {
410 ehci_dbg(ehci, "Port status(0x%x) is wrong\n", temp);
411 spin_unlock_irq(&ehci->lock);
412 msleep(8);
413 spin_lock_irq(&ehci->lock);
414 break;
415 }
416 }
417
392 if (ehci->shutdown) 418 if (ehci->shutdown)
393 goto shutdown; 419 goto shutdown;
394 420
@@ -764,11 +790,6 @@ static int ehci_hub_control (
764 status_reg); 790 status_reg);
765 break; 791 break;
766 case USB_PORT_FEAT_C_CONNECTION: 792 case USB_PORT_FEAT_C_CONNECTION:
767 if (ehci->has_lpm) {
768 /* clear PORTSC bits on disconnect */
769 temp &= ~PORT_LPM;
770 temp &= ~PORT_DEV_ADDR;
771 }
772 ehci_writel(ehci, temp | PORT_CSC, status_reg); 793 ehci_writel(ehci, temp | PORT_CSC, status_reg);
773 break; 794 break;
774 case USB_PORT_FEAT_C_OVER_CURRENT: 795 case USB_PORT_FEAT_C_OVER_CURRENT:
@@ -1088,8 +1109,7 @@ error_exit:
1088 return retval; 1109 return retval;
1089} 1110}
1090 1111
1091static void __maybe_unused ehci_relinquish_port(struct usb_hcd *hcd, 1112static void ehci_relinquish_port(struct usb_hcd *hcd, int portnum)
1092 int portnum)
1093{ 1113{
1094 struct ehci_hcd *ehci = hcd_to_ehci(hcd); 1114 struct ehci_hcd *ehci = hcd_to_ehci(hcd);
1095 1115
@@ -1098,8 +1118,7 @@ static void __maybe_unused ehci_relinquish_port(struct usb_hcd *hcd,
1098 set_owner(ehci, --portnum, PORT_OWNER); 1118 set_owner(ehci, --portnum, PORT_OWNER);
1099} 1119}
1100 1120
1101static int __maybe_unused ehci_port_handed_over(struct usb_hcd *hcd, 1121static int ehci_port_handed_over(struct usb_hcd *hcd, int portnum)
1102 int portnum)
1103{ 1122{
1104 struct ehci_hcd *ehci = hcd_to_ehci(hcd); 1123 struct ehci_hcd *ehci = hcd_to_ehci(hcd);
1105 u32 __iomem *reg; 1124 u32 __iomem *reg;
diff --git a/drivers/usb/host/ehci-ixp4xx.c b/drivers/usb/host/ehci-ixp4xx.c
deleted file mode 100644
index f224c0a48bed..000000000000
--- a/drivers/usb/host/ehci-ixp4xx.c
+++ /dev/null
@@ -1,139 +0,0 @@
1/*
2 * IXP4XX EHCI Host Controller Driver
3 *
4 * Author: Vladimir Barinov <vbarinov@embeddedalley.com>
5 *
6 * Based on "ehci-fsl.c" by Randy Vinson <rvinson@mvista.com>
7 *
8 * 2007 (c) MontaVista Software, Inc. This file is licensed under
9 * the terms of the GNU General Public License version 2. This program
10 * is licensed "as is" without any warranty of any kind, whether express
11 * or implied.
12 */
13
14#include <linux/platform_device.h>
15
16static int ixp4xx_ehci_init(struct usb_hcd *hcd)
17{
18 struct ehci_hcd *ehci = hcd_to_ehci(hcd);
19 int retval = 0;
20
21 ehci->big_endian_desc = 1;
22 ehci->big_endian_mmio = 1;
23
24 ehci->caps = hcd->regs + 0x100;
25
26 hcd->has_tt = 1;
27
28 retval = ehci_setup(hcd);
29 if (retval)
30 return retval;
31
32 ehci_port_power(ehci, 0);
33
34 return retval;
35}
36
37static const struct hc_driver ixp4xx_ehci_hc_driver = {
38 .description = hcd_name,
39 .product_desc = "IXP4XX EHCI Host Controller",
40 .hcd_priv_size = sizeof(struct ehci_hcd),
41 .irq = ehci_irq,
42 .flags = HCD_MEMORY | HCD_USB2,
43 .reset = ixp4xx_ehci_init,
44 .start = ehci_run,
45 .stop = ehci_stop,
46 .shutdown = ehci_shutdown,
47 .urb_enqueue = ehci_urb_enqueue,
48 .urb_dequeue = ehci_urb_dequeue,
49 .endpoint_disable = ehci_endpoint_disable,
50 .endpoint_reset = ehci_endpoint_reset,
51 .get_frame_number = ehci_get_frame,
52 .hub_status_data = ehci_hub_status_data,
53 .hub_control = ehci_hub_control,
54#if defined(CONFIG_PM)
55 .bus_suspend = ehci_bus_suspend,
56 .bus_resume = ehci_bus_resume,
57#endif
58 .relinquish_port = ehci_relinquish_port,
59 .port_handed_over = ehci_port_handed_over,
60
61 .clear_tt_buffer_complete = ehci_clear_tt_buffer_complete,
62};
63
64static int ixp4xx_ehci_probe(struct platform_device *pdev)
65{
66 struct usb_hcd *hcd;
67 const struct hc_driver *driver = &ixp4xx_ehci_hc_driver;
68 struct resource *res;
69 int irq;
70 int retval;
71
72 if (usb_disabled())
73 return -ENODEV;
74
75 res = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
76 if (!res) {
77 dev_err(&pdev->dev,
78 "Found HC with no IRQ. Check %s setup!\n",
79 dev_name(&pdev->dev));
80 return -ENODEV;
81 }
82 irq = res->start;
83
84 hcd = usb_create_hcd(driver, &pdev->dev, dev_name(&pdev->dev));
85 if (!hcd) {
86 retval = -ENOMEM;
87 goto fail_create_hcd;
88 }
89
90 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
91 if (!res) {
92 dev_err(&pdev->dev,
93 "Found HC with no register addr. Check %s setup!\n",
94 dev_name(&pdev->dev));
95 retval = -ENODEV;
96 goto fail_request_resource;
97 }
98 hcd->rsrc_start = res->start;
99 hcd->rsrc_len = resource_size(res);
100
101 hcd->regs = devm_request_and_ioremap(&pdev->dev, res);
102 if (hcd->regs == NULL) {
103 dev_dbg(&pdev->dev, "error mapping memory\n");
104 retval = -EFAULT;
105 goto fail_request_resource;
106 }
107
108 retval = usb_add_hcd(hcd, irq, IRQF_SHARED);
109 if (retval)
110 goto fail_request_resource;
111
112 return retval;
113
114fail_request_resource:
115 usb_put_hcd(hcd);
116fail_create_hcd:
117 dev_err(&pdev->dev, "init %s fail, %d\n", dev_name(&pdev->dev), retval);
118 return retval;
119}
120
121static int ixp4xx_ehci_remove(struct platform_device *pdev)
122{
123 struct usb_hcd *hcd = platform_get_drvdata(pdev);
124
125 usb_remove_hcd(hcd);
126 usb_put_hcd(hcd);
127
128 return 0;
129}
130
131MODULE_ALIAS("platform:ixp4xx-ehci");
132
133static struct platform_driver ixp4xx_ehci_driver = {
134 .probe = ixp4xx_ehci_probe,
135 .remove = ixp4xx_ehci_remove,
136 .driver = {
137 .name = "ixp4xx-ehci",
138 },
139};
diff --git a/drivers/usb/host/ehci-lpm.c b/drivers/usb/host/ehci-lpm.c
deleted file mode 100644
index 2111627a19de..000000000000
--- a/drivers/usb/host/ehci-lpm.c
+++ /dev/null
@@ -1,84 +0,0 @@
1/* ehci-lpm.c EHCI HCD LPM support code
2 * Copyright (c) 2008 - 2010, Intel Corporation.
3 * Author: Jacob Pan <jacob.jun.pan@intel.com>
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 2 as
7 * published by the Free Software Foundation.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
17*/
18
19/* this file is part of ehci-hcd.c */
20static int __maybe_unused ehci_lpm_set_da(struct ehci_hcd *ehci,
21 int dev_addr, int port_num)
22{
23 u32 __iomem portsc;
24
25 ehci_dbg(ehci, "set dev address %d for port %d\n", dev_addr, port_num);
26 if (port_num > HCS_N_PORTS(ehci->hcs_params)) {
27 ehci_dbg(ehci, "invalid port number %d\n", port_num);
28 return -ENODEV;
29 }
30 portsc = ehci_readl(ehci, &ehci->regs->port_status[port_num-1]);
31 portsc &= ~PORT_DEV_ADDR;
32 portsc |= dev_addr<<25;
33 ehci_writel(ehci, portsc, &ehci->regs->port_status[port_num-1]);
34 return 0;
35}
36
37/*
38 * this function is used to check if the device support LPM
39 * if yes, mark the PORTSC register with PORT_LPM bit
40 */
41static int __maybe_unused ehci_lpm_check(struct ehci_hcd *ehci, int port)
42{
43 u32 __iomem *portsc ;
44 u32 val32;
45 int retval;
46
47 portsc = &ehci->regs->port_status[port-1];
48 val32 = ehci_readl(ehci, portsc);
49 if (!(val32 & PORT_DEV_ADDR)) {
50 ehci_dbg(ehci, "LPM: no device attached\n");
51 return -ENODEV;
52 }
53 val32 |= PORT_LPM;
54 ehci_writel(ehci, val32, portsc);
55 msleep(5);
56 val32 |= PORT_SUSPEND;
57 ehci_dbg(ehci, "Sending LPM 0x%08x to port %d\n", val32, port);
58 ehci_writel(ehci, val32, portsc);
59 /* wait for ACK */
60 msleep(10);
61 retval = handshake(ehci, &ehci->regs->port_status[port-1], PORT_SSTS,
62 PORTSC_SUSPEND_STS_ACK, 125);
63 dbg_port(ehci, "LPM", port, val32);
64 if (retval != -ETIMEDOUT) {
65 ehci_dbg(ehci, "LPM: device ACK for LPM\n");
66 val32 |= PORT_LPM;
67 /*
68 * now device should be in L1 sleep, let's wake up the device
69 * so that we can complete enumeration.
70 */
71 ehci_writel(ehci, val32, portsc);
72 msleep(10);
73 val32 |= PORT_RESUME;
74 ehci_writel(ehci, val32, portsc);
75 } else {
76 ehci_dbg(ehci, "LPM: device does not ACK, disable LPM %d\n",
77 retval);
78 val32 &= ~PORT_LPM;
79 retval = -ETIMEDOUT;
80 ehci_writel(ehci, val32, portsc);
81 }
82
83 return retval;
84}
diff --git a/drivers/usb/host/ehci-ls1x.c b/drivers/usb/host/ehci-ls1x.c
deleted file mode 100644
index aa0f328922df..000000000000
--- a/drivers/usb/host/ehci-ls1x.c
+++ /dev/null
@@ -1,147 +0,0 @@
1/*
2 * Bus Glue for Loongson LS1X built-in EHCI controller.
3 *
4 * Copyright (c) 2012 Zhang, Keguang <keguang.zhang@gmail.com>
5 *
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License version 2 as published
8 * by the Free Software Foundation.
9 */
10
11
12#include <linux/platform_device.h>
13
14static int ehci_ls1x_reset(struct usb_hcd *hcd)
15{
16 struct ehci_hcd *ehci = hcd_to_ehci(hcd);
17 int ret;
18
19 ehci->caps = hcd->regs;
20
21 ret = ehci_setup(hcd);
22 if (ret)
23 return ret;
24
25 ehci_port_power(ehci, 0);
26
27 return 0;
28}
29
30static const struct hc_driver ehci_ls1x_hc_driver = {
31 .description = hcd_name,
32 .product_desc = "LOONGSON1 EHCI",
33 .hcd_priv_size = sizeof(struct ehci_hcd),
34
35 /*
36 * generic hardware linkage
37 */
38 .irq = ehci_irq,
39 .flags = HCD_MEMORY | HCD_USB2,
40
41 /*
42 * basic lifecycle operations
43 */
44 .reset = ehci_ls1x_reset,
45 .start = ehci_run,
46 .stop = ehci_stop,
47 .shutdown = ehci_shutdown,
48
49 /*
50 * managing i/o requests and associated device resources
51 */
52 .urb_enqueue = ehci_urb_enqueue,
53 .urb_dequeue = ehci_urb_dequeue,
54 .endpoint_disable = ehci_endpoint_disable,
55 .endpoint_reset = ehci_endpoint_reset,
56
57 /*
58 * scheduling support
59 */
60 .get_frame_number = ehci_get_frame,
61
62 /*
63 * root hub support
64 */
65 .hub_status_data = ehci_hub_status_data,
66 .hub_control = ehci_hub_control,
67 .relinquish_port = ehci_relinquish_port,
68 .port_handed_over = ehci_port_handed_over,
69
70 .clear_tt_buffer_complete = ehci_clear_tt_buffer_complete,
71};
72
73static int ehci_hcd_ls1x_probe(struct platform_device *pdev)
74{
75 struct usb_hcd *hcd;
76 struct resource *res;
77 int irq;
78 int ret;
79
80 pr_debug("initializing loongson1 ehci USB Controller\n");
81
82 if (usb_disabled())
83 return -ENODEV;
84
85 res = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
86 if (!res) {
87 dev_err(&pdev->dev,
88 "Found HC with no IRQ. Check %s setup!\n",
89 dev_name(&pdev->dev));
90 return -ENODEV;
91 }
92 irq = res->start;
93
94 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
95 if (!res) {
96 dev_err(&pdev->dev,
97 "Found HC with no register addr. Check %s setup!\n",
98 dev_name(&pdev->dev));
99 return -ENODEV;
100 }
101
102 hcd = usb_create_hcd(&ehci_ls1x_hc_driver, &pdev->dev,
103 dev_name(&pdev->dev));
104 if (!hcd)
105 return -ENOMEM;
106 hcd->rsrc_start = res->start;
107 hcd->rsrc_len = resource_size(res);
108
109 hcd->regs = devm_request_and_ioremap(&pdev->dev, res);
110 if (hcd->regs == NULL) {
111 dev_dbg(&pdev->dev, "error mapping memory\n");
112 ret = -EFAULT;
113 goto err_put_hcd;
114 }
115
116 ret = usb_add_hcd(hcd, irq, IRQF_DISABLED | IRQF_SHARED);
117 if (ret)
118 goto err_put_hcd;
119
120 return ret;
121
122err_put_hcd:
123 usb_put_hcd(hcd);
124 return ret;
125}
126
127static int ehci_hcd_ls1x_remove(struct platform_device *pdev)
128{
129 struct usb_hcd *hcd = platform_get_drvdata(pdev);
130
131 usb_remove_hcd(hcd);
132 usb_put_hcd(hcd);
133
134 return 0;
135}
136
137static struct platform_driver ehci_ls1x_driver = {
138 .probe = ehci_hcd_ls1x_probe,
139 .remove = ehci_hcd_ls1x_remove,
140 .shutdown = usb_hcd_platform_shutdown,
141 .driver = {
142 .name = "ls1x-ehci",
143 .owner = THIS_MODULE,
144 },
145};
146
147MODULE_ALIAS(PLATFORM_MODULE_PREFIX "ls1x-ehci");
diff --git a/drivers/usb/host/ehci-msm.c b/drivers/usb/host/ehci-msm.c
index 4af4dc5b618c..7fa1ba4de789 100644
--- a/drivers/usb/host/ehci-msm.c
+++ b/drivers/usb/host/ehci-msm.c
@@ -53,7 +53,6 @@ static int ehci_msm_reset(struct usb_hcd *hcd)
53 /* Disable streaming mode and select host mode */ 53 /* Disable streaming mode and select host mode */
54 writel(0x13, USB_USBMODE); 54 writel(0x13, USB_USBMODE);
55 55
56 ehci_port_power(ehci, 1);
57 return 0; 56 return 0;
58} 57}
59 58
diff --git a/drivers/usb/host/ehci-mxc.c b/drivers/usb/host/ehci-mxc.c
index 4a08fc0b27c9..8804f74689d7 100644
--- a/drivers/usb/host/ehci-mxc.c
+++ b/drivers/usb/host/ehci-mxc.c
@@ -39,17 +39,9 @@ struct ehci_mxc_priv {
39/* called during probe() after chip reset completes */ 39/* called during probe() after chip reset completes */
40static int ehci_mxc_setup(struct usb_hcd *hcd) 40static int ehci_mxc_setup(struct usb_hcd *hcd)
41{ 41{
42 struct ehci_hcd *ehci = hcd_to_ehci(hcd);
43 int retval;
44
45 hcd->has_tt = 1; 42 hcd->has_tt = 1;
46 43
47 retval = ehci_setup(hcd); 44 return ehci_setup(hcd);
48 if (retval)
49 return retval;
50
51 ehci_port_power(ehci, 0);
52 return 0;
53} 45}
54 46
55static const struct hc_driver ehci_mxc_hc_driver = { 47static const struct hc_driver ehci_mxc_hc_driver = {
diff --git a/drivers/usb/host/ehci-octeon.c b/drivers/usb/host/ehci-octeon.c
index ba26957abf46..a89750fff4ff 100644
--- a/drivers/usb/host/ehci-octeon.c
+++ b/drivers/usb/host/ehci-octeon.c
@@ -159,9 +159,6 @@ static int ehci_octeon_drv_probe(struct platform_device *pdev)
159 159
160 platform_set_drvdata(pdev, hcd); 160 platform_set_drvdata(pdev, hcd);
161 161
162 /* root ports should always stay powered */
163 ehci_port_power(ehci, 1);
164
165 return 0; 162 return 0;
166err3: 163err3:
167 ehci_octeon_stop(); 164 ehci_octeon_stop();
diff --git a/drivers/usb/host/ehci-omap.c b/drivers/usb/host/ehci-omap.c
index d7fe287d0678..44e7d0f638e8 100644
--- a/drivers/usb/host/ehci-omap.c
+++ b/drivers/usb/host/ehci-omap.c
@@ -146,9 +146,6 @@ static int omap_ehci_init(struct usb_hcd *hcd)
146 gpio_set_value_cansleep(pdata->reset_gpio_port[1], 1); 146 gpio_set_value_cansleep(pdata->reset_gpio_port[1], 1);
147 } 147 }
148 148
149 /* root ports should always stay powered */
150 ehci_port_power(ehci, 1);
151
152 return rc; 149 return rc;
153} 150}
154 151
diff --git a/drivers/usb/host/ehci-orion.c b/drivers/usb/host/ehci-orion.c
index 9c2717d66730..96da679becef 100644
--- a/drivers/usb/host/ehci-orion.c
+++ b/drivers/usb/host/ehci-orion.c
@@ -101,20 +101,6 @@ static void orion_usb_phy_v1_setup(struct usb_hcd *hcd)
101 wrl(USB_MODE, 0x13); 101 wrl(USB_MODE, 0x13);
102} 102}
103 103
104static int ehci_orion_setup(struct usb_hcd *hcd)
105{
106 struct ehci_hcd *ehci = hcd_to_ehci(hcd);
107 int retval;
108
109 retval = ehci_setup(hcd);
110 if (retval)
111 return retval;
112
113 ehci_port_power(ehci, 0);
114
115 return retval;
116}
117
118static const struct hc_driver ehci_orion_hc_driver = { 104static const struct hc_driver ehci_orion_hc_driver = {
119 .description = hcd_name, 105 .description = hcd_name,
120 .product_desc = "Marvell Orion EHCI", 106 .product_desc = "Marvell Orion EHCI",
@@ -129,7 +115,7 @@ static const struct hc_driver ehci_orion_hc_driver = {
129 /* 115 /*
130 * basic lifecycle operations 116 * basic lifecycle operations
131 */ 117 */
132 .reset = ehci_orion_setup, 118 .reset = ehci_setup,
133 .start = ehci_run, 119 .start = ehci_run,
134 .stop = ehci_stop, 120 .stop = ehci_stop,
135 .shutdown = ehci_shutdown, 121 .shutdown = ehci_shutdown,
diff --git a/drivers/usb/host/ehci-pci.c b/drivers/usb/host/ehci-pci.c
index 2cb7d370c4ef..3fb76ca61848 100644
--- a/drivers/usb/host/ehci-pci.c
+++ b/drivers/usb/host/ehci-pci.c
@@ -18,9 +18,18 @@
18 * Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 18 * Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19 */ 19 */
20 20
21#ifndef CONFIG_PCI 21#include <linux/kernel.h>
22#error "This file is PCI bus glue. CONFIG_PCI must be defined." 22#include <linux/module.h>
23#endif 23#include <linux/pci.h>
24#include <linux/usb.h>
25#include <linux/usb/hcd.h>
26
27#include "ehci.h"
28#include "pci-quirks.h"
29
30#define DRIVER_DESC "EHCI PCI platform driver"
31
32static const char hcd_name[] = "ehci-pci";
24 33
25/* defined here to avoid adding to pci_ids.h for single instance use */ 34/* defined here to avoid adding to pci_ids.h for single instance use */
26#define PCI_DEVICE_ID_INTEL_CE4100_USB 0x2e70 35#define PCI_DEVICE_ID_INTEL_CE4100_USB 0x2e70
@@ -103,7 +112,6 @@ static int ehci_pci_setup(struct usb_hcd *hcd)
103 } 112 }
104 break; 113 break;
105 case PCI_VENDOR_ID_INTEL: 114 case PCI_VENDOR_ID_INTEL:
106 ehci->fs_i_thresh = 1;
107 if (pdev->device == PCI_DEVICE_ID_INTEL_CE4100_USB) 115 if (pdev->device == PCI_DEVICE_ID_INTEL_CE4100_USB)
108 hcd->has_tt = 1; 116 hcd->has_tt = 1;
109 break; 117 break;
@@ -203,11 +211,6 @@ static int ehci_pci_setup(struct usb_hcd *hcd)
203 break; 211 break;
204 case PCI_VENDOR_ID_INTEL: 212 case PCI_VENDOR_ID_INTEL:
205 ehci->need_io_watchdog = 0; 213 ehci->need_io_watchdog = 0;
206 if (pdev->device == 0x0806 || pdev->device == 0x0811
207 || pdev->device == 0x0829) {
208 ehci_info(ehci, "disable lpm for langwell/penwell\n");
209 ehci->has_lpm = 0;
210 }
211 break; 214 break;
212 case PCI_VENDOR_ID_NVIDIA: 215 case PCI_VENDOR_ID_NVIDIA:
213 switch (pdev->device) { 216 switch (pdev->device) {
@@ -217,8 +220,7 @@ static int ehci_pci_setup(struct usb_hcd *hcd)
217 * devices with PPCD enabled. 220 * devices with PPCD enabled.
218 */ 221 */
219 case 0x0d9d: 222 case 0x0d9d:
220 ehci_info(ehci, "disable lpm/ppcd for nvidia mcp89"); 223 ehci_info(ehci, "disable ppcd for nvidia mcp89\n");
221 ehci->has_lpm = 0;
222 ehci->has_ppcd = 0; 224 ehci->has_ppcd = 0;
223 ehci->command &= ~CMD_PPCEE; 225 ehci->command &= ~CMD_PPCEE;
224 break; 226 break;
@@ -304,7 +306,6 @@ static int ehci_pci_setup(struct usb_hcd *hcd)
304 ehci_warn(ehci, "selective suspend/wakeup unavailable\n"); 306 ehci_warn(ehci, "selective suspend/wakeup unavailable\n");
305#endif 307#endif
306 308
307 ehci_port_power(ehci, 1);
308 retval = ehci_pci_reinit(ehci, pdev); 309 retval = ehci_pci_reinit(ehci, pdev);
309done: 310done:
310 return retval; 311 return retval;
@@ -323,11 +324,6 @@ done:
323 * Also they depend on separate root hub suspend/resume. 324 * Also they depend on separate root hub suspend/resume.
324 */ 325 */
325 326
326static int ehci_pci_suspend(struct usb_hcd *hcd, bool do_wakeup)
327{
328 return ehci_suspend(hcd, do_wakeup);
329}
330
331static bool usb_is_intel_switchable_ehci(struct pci_dev *pdev) 327static bool usb_is_intel_switchable_ehci(struct pci_dev *pdev)
332{ 328{
333 return pdev->class == PCI_CLASS_SERIAL_USB_EHCI && 329 return pdev->class == PCI_CLASS_SERIAL_USB_EHCI &&
@@ -378,76 +374,17 @@ static int ehci_pci_resume(struct usb_hcd *hcd, bool hibernated)
378 (void) ehci_pci_reinit(ehci, pdev); 374 (void) ehci_pci_reinit(ehci, pdev);
379 return 0; 375 return 0;
380} 376}
381#endif
382 377
383static int ehci_update_device(struct usb_hcd *hcd, struct usb_device *udev) 378#else
384{
385 struct ehci_hcd *ehci = hcd_to_ehci(hcd);
386 int rc = 0;
387
388 if (!udev->parent) /* udev is root hub itself, impossible */
389 rc = -1;
390 /* we only support lpm device connected to root hub yet */
391 if (ehci->has_lpm && !udev->parent->parent) {
392 rc = ehci_lpm_set_da(ehci, udev->devnum, udev->portnum);
393 if (!rc)
394 rc = ehci_lpm_check(ehci, udev->portnum);
395 }
396 return rc;
397}
398 379
399static const struct hc_driver ehci_pci_hc_driver = { 380#define ehci_suspend NULL
400 .description = hcd_name, 381#define ehci_pci_resume NULL
401 .product_desc = "EHCI Host Controller", 382#endif /* CONFIG_PM */
402 .hcd_priv_size = sizeof(struct ehci_hcd),
403 383
404 /* 384static struct hc_driver __read_mostly ehci_pci_hc_driver;
405 * generic hardware linkage
406 */
407 .irq = ehci_irq,
408 .flags = HCD_MEMORY | HCD_USB2,
409 385
410 /* 386static const struct ehci_driver_overrides pci_overrides __initdata = {
411 * basic lifecycle operations
412 */
413 .reset = ehci_pci_setup, 387 .reset = ehci_pci_setup,
414 .start = ehci_run,
415#ifdef CONFIG_PM
416 .pci_suspend = ehci_pci_suspend,
417 .pci_resume = ehci_pci_resume,
418#endif
419 .stop = ehci_stop,
420 .shutdown = ehci_shutdown,
421
422 /*
423 * managing i/o requests and associated device resources
424 */
425 .urb_enqueue = ehci_urb_enqueue,
426 .urb_dequeue = ehci_urb_dequeue,
427 .endpoint_disable = ehci_endpoint_disable,
428 .endpoint_reset = ehci_endpoint_reset,
429
430 /*
431 * scheduling support
432 */
433 .get_frame_number = ehci_get_frame,
434
435 /*
436 * root hub support
437 */
438 .hub_status_data = ehci_hub_status_data,
439 .hub_control = ehci_hub_control,
440 .bus_suspend = ehci_bus_suspend,
441 .bus_resume = ehci_bus_resume,
442 .relinquish_port = ehci_relinquish_port,
443 .port_handed_over = ehci_port_handed_over,
444
445 /*
446 * call back when device connected and addressed
447 */
448 .update_device = ehci_update_device,
449
450 .clear_tt_buffer_complete = ehci_clear_tt_buffer_complete,
451}; 388};
452 389
453/*-------------------------------------------------------------------------*/ 390/*-------------------------------------------------------------------------*/
@@ -480,3 +417,31 @@ static struct pci_driver ehci_pci_driver = {
480 }, 417 },
481#endif 418#endif
482}; 419};
420
421static int __init ehci_pci_init(void)
422{
423 if (usb_disabled())
424 return -ENODEV;
425
426 pr_info("%s: " DRIVER_DESC "\n", hcd_name);
427
428 ehci_init_driver(&ehci_pci_hc_driver, &pci_overrides);
429
430 /* Entries for the PCI suspend/resume callbacks are special */
431 ehci_pci_hc_driver.pci_suspend = ehci_suspend;
432 ehci_pci_hc_driver.pci_resume = ehci_pci_resume;
433
434 return pci_register_driver(&ehci_pci_driver);
435}
436module_init(ehci_pci_init);
437
438static void __exit ehci_pci_cleanup(void)
439{
440 pci_unregister_driver(&ehci_pci_driver);
441}
442module_exit(ehci_pci_cleanup);
443
444MODULE_DESCRIPTION(DRIVER_DESC);
445MODULE_AUTHOR("David Brownell");
446MODULE_AUTHOR("Alan Stern");
447MODULE_LICENSE("GPL");
diff --git a/drivers/usb/host/ehci-platform.c b/drivers/usb/host/ehci-platform.c
index 764e0100b6f4..f14c542b142f 100644
--- a/drivers/usb/host/ehci-platform.c
+++ b/drivers/usb/host/ehci-platform.c
@@ -18,9 +18,21 @@
18 * 18 *
19 * Licensed under the GNU/GPL. See COPYING for details. 19 * Licensed under the GNU/GPL. See COPYING for details.
20 */ 20 */
21#include <linux/kernel.h>
22#include <linux/hrtimer.h>
23#include <linux/io.h>
24#include <linux/module.h>
21#include <linux/platform_device.h> 25#include <linux/platform_device.h>
26#include <linux/usb.h>
27#include <linux/usb/hcd.h>
22#include <linux/usb/ehci_pdriver.h> 28#include <linux/usb/ehci_pdriver.h>
23 29
30#include "ehci.h"
31
32#define DRIVER_DESC "EHCI generic platform driver"
33
34static const char hcd_name[] = "ehci-platform";
35
24static int ehci_platform_reset(struct usb_hcd *hcd) 36static int ehci_platform_reset(struct usb_hcd *hcd)
25{ 37{
26 struct platform_device *pdev = to_platform_device(hcd->self.controller); 38 struct platform_device *pdev = to_platform_device(hcd->self.controller);
@@ -38,44 +50,15 @@ static int ehci_platform_reset(struct usb_hcd *hcd)
38 if (retval) 50 if (retval)
39 return retval; 51 return retval;
40 52
41 if (pdata->port_power_on) 53 if (pdata->no_io_watchdog)
42 ehci_port_power(ehci, 1); 54 ehci->need_io_watchdog = 0;
43 if (pdata->port_power_off)
44 ehci_port_power(ehci, 0);
45
46 return 0; 55 return 0;
47} 56}
48 57
49static const struct hc_driver ehci_platform_hc_driver = { 58static struct hc_driver __read_mostly ehci_platform_hc_driver;
50 .description = hcd_name,
51 .product_desc = "Generic Platform EHCI Controller",
52 .hcd_priv_size = sizeof(struct ehci_hcd),
53
54 .irq = ehci_irq,
55 .flags = HCD_MEMORY | HCD_USB2,
56
57 .reset = ehci_platform_reset,
58 .start = ehci_run,
59 .stop = ehci_stop,
60 .shutdown = ehci_shutdown,
61
62 .urb_enqueue = ehci_urb_enqueue,
63 .urb_dequeue = ehci_urb_dequeue,
64 .endpoint_disable = ehci_endpoint_disable,
65 .endpoint_reset = ehci_endpoint_reset,
66 59
67 .get_frame_number = ehci_get_frame, 60static const struct ehci_driver_overrides platform_overrides __initdata = {
68 61 .reset = ehci_platform_reset,
69 .hub_status_data = ehci_hub_status_data,
70 .hub_control = ehci_hub_control,
71#if defined(CONFIG_PM)
72 .bus_suspend = ehci_bus_suspend,
73 .bus_resume = ehci_bus_resume,
74#endif
75 .relinquish_port = ehci_relinquish_port,
76 .port_handed_over = ehci_port_handed_over,
77
78 .clear_tt_buffer_complete = ehci_clear_tt_buffer_complete,
79}; 62};
80 63
81static int __devinit ehci_platform_probe(struct platform_device *dev) 64static int __devinit ehci_platform_probe(struct platform_device *dev)
@@ -96,12 +79,12 @@ static int __devinit ehci_platform_probe(struct platform_device *dev)
96 79
97 irq = platform_get_irq(dev, 0); 80 irq = platform_get_irq(dev, 0);
98 if (irq < 0) { 81 if (irq < 0) {
99 pr_err("no irq provided"); 82 dev_err(&dev->dev, "no irq provided");
100 return irq; 83 return irq;
101 } 84 }
102 res_mem = platform_get_resource(dev, IORESOURCE_MEM, 0); 85 res_mem = platform_get_resource(dev, IORESOURCE_MEM, 0);
103 if (!res_mem) { 86 if (!res_mem) {
104 pr_err("no memory recourse provided"); 87 dev_err(&dev->dev, "no memory resource provided");
105 return -ENXIO; 88 return -ENXIO;
106 } 89 }
107 90
@@ -121,29 +104,19 @@ static int __devinit ehci_platform_probe(struct platform_device *dev)
121 hcd->rsrc_start = res_mem->start; 104 hcd->rsrc_start = res_mem->start;
122 hcd->rsrc_len = resource_size(res_mem); 105 hcd->rsrc_len = resource_size(res_mem);
123 106
124 if (!request_mem_region(hcd->rsrc_start, hcd->rsrc_len, hcd_name)) { 107 hcd->regs = devm_request_and_ioremap(&dev->dev, res_mem);
125 pr_err("controller already in use");
126 err = -EBUSY;
127 goto err_put_hcd;
128 }
129
130 hcd->regs = ioremap_nocache(hcd->rsrc_start, hcd->rsrc_len);
131 if (!hcd->regs) { 108 if (!hcd->regs) {
132 err = -ENOMEM; 109 err = -ENOMEM;
133 goto err_release_region; 110 goto err_put_hcd;
134 } 111 }
135 err = usb_add_hcd(hcd, irq, IRQF_SHARED); 112 err = usb_add_hcd(hcd, irq, IRQF_SHARED);
136 if (err) 113 if (err)
137 goto err_iounmap; 114 goto err_put_hcd;
138 115
139 platform_set_drvdata(dev, hcd); 116 platform_set_drvdata(dev, hcd);
140 117
141 return err; 118 return err;
142 119
143err_iounmap:
144 iounmap(hcd->regs);
145err_release_region:
146 release_mem_region(hcd->rsrc_start, hcd->rsrc_len);
147err_put_hcd: 120err_put_hcd:
148 usb_put_hcd(hcd); 121 usb_put_hcd(hcd);
149err_power: 122err_power:
@@ -159,8 +132,6 @@ static int __devexit ehci_platform_remove(struct platform_device *dev)
159 struct usb_ehci_pdata *pdata = dev->dev.platform_data; 132 struct usb_ehci_pdata *pdata = dev->dev.platform_data;
160 133
161 usb_remove_hcd(hcd); 134 usb_remove_hcd(hcd);
162 iounmap(hcd->regs);
163 release_mem_region(hcd->rsrc_start, hcd->rsrc_len);
164 usb_put_hcd(hcd); 135 usb_put_hcd(hcd);
165 platform_set_drvdata(dev, NULL); 136 platform_set_drvdata(dev, NULL);
166 137
@@ -233,3 +204,26 @@ static struct platform_driver ehci_platform_driver = {
233 .pm = &ehci_platform_pm_ops, 204 .pm = &ehci_platform_pm_ops,
234 } 205 }
235}; 206};
207
208static int __init ehci_platform_init(void)
209{
210 if (usb_disabled())
211 return -ENODEV;
212
213 pr_info("%s: " DRIVER_DESC "\n", hcd_name);
214
215 ehci_init_driver(&ehci_platform_hc_driver, &platform_overrides);
216 return platform_driver_register(&ehci_platform_driver);
217}
218module_init(ehci_platform_init);
219
220static void __exit ehci_platform_cleanup(void)
221{
222 platform_driver_unregister(&ehci_platform_driver);
223}
224module_exit(ehci_platform_cleanup);
225
226MODULE_DESCRIPTION(DRIVER_DESC);
227MODULE_AUTHOR("Hauke Mehrtens");
228MODULE_AUTHOR("Alan Stern");
229MODULE_LICENSE("GPL");
diff --git a/drivers/usb/host/ehci-pmcmsp.c b/drivers/usb/host/ehci-pmcmsp.c
index 087aee2a904f..363890ee41d2 100644
--- a/drivers/usb/host/ehci-pmcmsp.c
+++ b/drivers/usb/host/ehci-pmcmsp.c
@@ -90,7 +90,6 @@ static int ehci_msp_setup(struct usb_hcd *hcd)
90 return retval; 90 return retval;
91 91
92 usb_hcd_tdi_set_mode(ehci); 92 usb_hcd_tdi_set_mode(ehci);
93 ehci_port_power(ehci, 0);
94 93
95 return retval; 94 return retval;
96} 95}
diff --git a/drivers/usb/host/ehci-q.c b/drivers/usb/host/ehci-q.c
index 4b66374bdc8e..3d989028c836 100644
--- a/drivers/usb/host/ehci-q.c
+++ b/drivers/usb/host/ehci-q.c
@@ -264,15 +264,9 @@ ehci_urb_done(struct ehci_hcd *ehci, struct urb *urb, int status)
264__releases(ehci->lock) 264__releases(ehci->lock)
265__acquires(ehci->lock) 265__acquires(ehci->lock)
266{ 266{
267 if (likely (urb->hcpriv != NULL)) { 267 if (usb_pipetype(urb->pipe) == PIPE_INTERRUPT) {
268 struct ehci_qh *qh = (struct ehci_qh *) urb->hcpriv; 268 /* ... update hc-wide periodic stats */
269 269 ehci_to_hcd(ehci)->self.bandwidth_int_reqs--;
270 /* S-mask in a QH means it's an interrupt urb */
271 if ((qh->hw->hw_info2 & cpu_to_hc32(ehci, QH_SMASK)) != 0) {
272
273 /* ... update hc-wide periodic stats (for usbfs) */
274 ehci_to_hcd(ehci)->self.bandwidth_int_reqs--;
275 }
276 } 270 }
277 271
278 if (unlikely(urb->unlinked)) { 272 if (unlikely(urb->unlinked)) {
diff --git a/drivers/usb/host/ehci-s5p.c b/drivers/usb/host/ehci-s5p.c
index 85b74be202eb..abc178d21fe4 100644
--- a/drivers/usb/host/ehci-s5p.c
+++ b/drivers/usb/host/ehci-s5p.c
@@ -136,7 +136,7 @@ static int __devinit s5p_ehci_probe(struct platform_device *pdev)
136 goto fail_clk; 136 goto fail_clk;
137 } 137 }
138 138
139 err = clk_enable(s5p_ehci->clk); 139 err = clk_prepare_enable(s5p_ehci->clk);
140 if (err) 140 if (err)
141 goto fail_clk; 141 goto fail_clk;
142 142
@@ -183,7 +183,7 @@ static int __devinit s5p_ehci_probe(struct platform_device *pdev)
183 return 0; 183 return 0;
184 184
185fail_io: 185fail_io:
186 clk_disable(s5p_ehci->clk); 186 clk_disable_unprepare(s5p_ehci->clk);
187fail_clk: 187fail_clk:
188 usb_put_hcd(hcd); 188 usb_put_hcd(hcd);
189 return err; 189 return err;
@@ -200,7 +200,7 @@ static int __devexit s5p_ehci_remove(struct platform_device *pdev)
200 if (pdata && pdata->phy_exit) 200 if (pdata && pdata->phy_exit)
201 pdata->phy_exit(pdev, S5P_USB_PHY_HOST); 201 pdata->phy_exit(pdev, S5P_USB_PHY_HOST);
202 202
203 clk_disable(s5p_ehci->clk); 203 clk_disable_unprepare(s5p_ehci->clk);
204 204
205 usb_put_hcd(hcd); 205 usb_put_hcd(hcd);
206 206
@@ -231,7 +231,7 @@ static int s5p_ehci_suspend(struct device *dev)
231 if (pdata && pdata->phy_exit) 231 if (pdata && pdata->phy_exit)
232 pdata->phy_exit(pdev, S5P_USB_PHY_HOST); 232 pdata->phy_exit(pdev, S5P_USB_PHY_HOST);
233 233
234 clk_disable(s5p_ehci->clk); 234 clk_disable_unprepare(s5p_ehci->clk);
235 235
236 return rc; 236 return rc;
237} 237}
@@ -243,7 +243,7 @@ static int s5p_ehci_resume(struct device *dev)
243 struct platform_device *pdev = to_platform_device(dev); 243 struct platform_device *pdev = to_platform_device(dev);
244 struct s5p_ehci_platdata *pdata = pdev->dev.platform_data; 244 struct s5p_ehci_platdata *pdata = pdev->dev.platform_data;
245 245
246 clk_enable(s5p_ehci->clk); 246 clk_prepare_enable(s5p_ehci->clk);
247 247
248 if (pdata && pdata->phy_init) 248 if (pdata && pdata->phy_init)
249 pdata->phy_init(pdev, S5P_USB_PHY_HOST); 249 pdata->phy_init(pdev, S5P_USB_PHY_HOST);
diff --git a/drivers/usb/host/ehci-sched.c b/drivers/usb/host/ehci-sched.c
index 7cf3da7babf0..69ebee73c0c1 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
@@ -1361,7 +1338,7 @@ sitd_slot_ok (
1361 * given EHCI_TUNE_FLS and the slop). Or, write a smarter scheduler! 1338 * given EHCI_TUNE_FLS and the slop). Or, write a smarter scheduler!
1362 */ 1339 */
1363 1340
1364#define SCHEDULE_SLOP 80 /* microframes */ 1341#define SCHEDULING_DELAY 40 /* microframes */
1365 1342
1366static int 1343static int
1367iso_stream_schedule ( 1344iso_stream_schedule (
@@ -1370,7 +1347,7 @@ iso_stream_schedule (
1370 struct ehci_iso_stream *stream 1347 struct ehci_iso_stream *stream
1371) 1348)
1372{ 1349{
1373 u32 now, next, start, period, span; 1350 u32 now, base, next, start, period, span;
1374 int status; 1351 int status;
1375 unsigned mod = ehci->periodic_size << 3; 1352 unsigned mod = ehci->periodic_size << 3;
1376 struct ehci_iso_sched *sched = urb->hcpriv; 1353 struct ehci_iso_sched *sched = urb->hcpriv;
@@ -1382,62 +1359,72 @@ iso_stream_schedule (
1382 span <<= 3; 1359 span <<= 3;
1383 } 1360 }
1384 1361
1385 if (span > mod - SCHEDULE_SLOP) {
1386 ehci_dbg (ehci, "iso request %p too long\n", urb);
1387 status = -EFBIG;
1388 goto fail;
1389 }
1390
1391 now = ehci_read_frame_index(ehci) & (mod - 1); 1362 now = ehci_read_frame_index(ehci) & (mod - 1);
1392 1363
1393 /* Typical case: reuse current schedule, stream is still active. 1364 /* Typical case: reuse current schedule, stream is still active.
1394 * Hopefully there are no gaps from the host falling behind 1365 * Hopefully there are no gaps from the host falling behind
1395 * (irq delays etc), but if there are we'll take the next 1366 * (irq delays etc). If there are, the behavior depends on
1396 * slot in the schedule, implicitly assuming URB_ISO_ASAP. 1367 * whether URB_ISO_ASAP is set.
1397 */ 1368 */
1398 if (likely (!list_empty (&stream->td_list))) { 1369 if (likely (!list_empty (&stream->td_list))) {
1399 u32 excess;
1400 1370
1401 /* For high speed devices, allow scheduling within the 1371 /* Take the isochronous scheduling threshold into account */
1402 * isochronous scheduling threshold. For full speed devices 1372 if (ehci->i_thresh)
1403 * and Intel PCI-based controllers, don't (work around for 1373 next = now + ehci->i_thresh; /* uframe cache */
1404 * Intel ICH9 bug).
1405 */
1406 if (!stream->highspeed && ehci->fs_i_thresh)
1407 next = now + ehci->i_thresh;
1408 else 1374 else
1409 next = now; 1375 next = (now + 2 + 7) & ~0x07; /* full frame cache */
1410 1376
1411 /* Fell behind (by up to twice the slop amount)? 1377 /*
1412 * We decide based on the time of the last currently-scheduled 1378 * Use ehci->last_iso_frame as the base. There can't be any
1413 * slot, not the time of the next available slot. 1379 * TDs scheduled for earlier than that.
1414 */ 1380 */
1415 excess = (stream->next_uframe - period - next) & (mod - 1); 1381 base = ehci->last_iso_frame << 3;
1416 if (excess >= mod - 2 * SCHEDULE_SLOP) 1382 next = (next - base) & (mod - 1);
1417 start = next + excess - mod + period * 1383 start = (stream->next_uframe - base) & (mod - 1);
1418 DIV_ROUND_UP(mod - excess, period); 1384
1419 else 1385 /* Is the schedule already full? */
1420 start = next + excess + period; 1386 if (unlikely(start < period)) {
1421 if (start - now >= mod) { 1387 ehci_dbg(ehci, "iso sched full %p (%u-%u < %u mod %u)\n",
1422 ehci_dbg(ehci, "request %p would overflow (%d+%d >= %d)\n", 1388 urb, stream->next_uframe, base,
1423 urb, start - now - period, period, 1389 period, mod);
1424 mod); 1390 status = -ENOSPC;
1425 status = -EFBIG;
1426 goto fail; 1391 goto fail;
1427 } 1392 }
1393
1394 /* Behind the scheduling threshold? */
1395 if (unlikely(start < next)) {
1396
1397 /* USB_ISO_ASAP: Round up to the first available slot */
1398 if (urb->transfer_flags & URB_ISO_ASAP)
1399 start += (next - start + period - 1) & -period;
1400
1401 /*
1402 * Not ASAP: Use the next slot in the stream. If
1403 * the entire URB falls before the threshold, fail.
1404 */
1405 else if (start + span - period < next) {
1406 ehci_dbg(ehci, "iso urb late %p (%u+%u < %u)\n",
1407 urb, start + base,
1408 span - period, next + base);
1409 status = -EXDEV;
1410 goto fail;
1411 }
1412 }
1413
1414 start += base;
1428 } 1415 }
1429 1416
1430 /* need to schedule; when's the next (u)frame we could start? 1417 /* need to schedule; when's the next (u)frame we could start?
1431 * this is bigger than ehci->i_thresh allows; scheduling itself 1418 * this is bigger than ehci->i_thresh allows; scheduling itself
1432 * isn't free, the slop should handle reasonably slow cpus. it 1419 * isn't free, the delay should handle reasonably slow cpus. it
1433 * can also help high bandwidth if the dma and irq loads don't 1420 * can also help high bandwidth if the dma and irq loads don't
1434 * jump until after the queue is primed. 1421 * jump until after the queue is primed.
1435 */ 1422 */
1436 else { 1423 else {
1437 int done = 0; 1424 int done = 0;
1438 start = SCHEDULE_SLOP + (now & ~0x07);
1439 1425
1440 /* NOTE: assumes URB_ISO_ASAP, to limit complexity/bugs */ 1426 base = now & ~0x07;
1427 start = base + SCHEDULING_DELAY;
1441 1428
1442 /* find a uframe slot with enough bandwidth. 1429 /* find a uframe slot with enough bandwidth.
1443 * Early uframes are more precious because full-speed 1430 * Early uframes are more precious because full-speed
@@ -1464,19 +1451,16 @@ iso_stream_schedule (
1464 1451
1465 /* no room in the schedule */ 1452 /* no room in the schedule */
1466 if (!done) { 1453 if (!done) {
1467 ehci_dbg(ehci, "iso resched full %p (now %d max %d)\n", 1454 ehci_dbg(ehci, "iso sched full %p", urb);
1468 urb, now, now + mod);
1469 status = -ENOSPC; 1455 status = -ENOSPC;
1470 goto fail; 1456 goto fail;
1471 } 1457 }
1472 } 1458 }
1473 1459
1474 /* Tried to schedule too far into the future? */ 1460 /* Tried to schedule too far into the future? */
1475 if (unlikely(start - now + span - period 1461 if (unlikely(start - base + span - period >= mod)) {
1476 >= mod - 2 * SCHEDULE_SLOP)) { 1462 ehci_dbg(ehci, "request %p would overflow (%u+%u >= %u)\n",
1477 ehci_dbg(ehci, "request %p would overflow (%d+%d >= %d)\n", 1463 urb, start - base, span - period, mod);
1478 urb, start - now, span - period,
1479 mod - 2 * SCHEDULE_SLOP);
1480 status = -EFBIG; 1464 status = -EFBIG;
1481 goto fail; 1465 goto fail;
1482 } 1466 }
@@ -1490,7 +1474,7 @@ iso_stream_schedule (
1490 1474
1491 /* Make sure scan_isoc() sees these */ 1475 /* Make sure scan_isoc() sees these */
1492 if (ehci->isoc_count == 0) 1476 if (ehci->isoc_count == 0)
1493 ehci->next_frame = now >> 3; 1477 ehci->last_iso_frame = now >> 3;
1494 return 0; 1478 return 0;
1495 1479
1496 fail: 1480 fail:
@@ -1646,7 +1630,7 @@ static void itd_link_urb(
1646 1630
1647 /* don't need that schedule data any more */ 1631 /* don't need that schedule data any more */
1648 iso_sched_free (stream, iso_sched); 1632 iso_sched_free (stream, iso_sched);
1649 urb->hcpriv = NULL; 1633 urb->hcpriv = stream;
1650 1634
1651 ++ehci->isoc_count; 1635 ++ehci->isoc_count;
1652 enable_periodic(ehci); 1636 enable_periodic(ehci);
@@ -1708,7 +1692,7 @@ static bool itd_complete(struct ehci_hcd *ehci, struct ehci_itd *itd)
1708 urb->actual_length += desc->actual_length; 1692 urb->actual_length += desc->actual_length;
1709 } else { 1693 } else {
1710 /* URB was too late */ 1694 /* URB was too late */
1711 desc->status = -EXDEV; 1695 urb->error_count++;
1712 } 1696 }
1713 } 1697 }
1714 1698
@@ -2045,7 +2029,7 @@ static void sitd_link_urb(
2045 2029
2046 /* don't need that schedule data any more */ 2030 /* don't need that schedule data any more */
2047 iso_sched_free (stream, sched); 2031 iso_sched_free (stream, sched);
2048 urb->hcpriv = NULL; 2032 urb->hcpriv = stream;
2049 2033
2050 ++ehci->isoc_count; 2034 ++ehci->isoc_count;
2051 enable_periodic(ehci); 2035 enable_periodic(ehci);
@@ -2081,7 +2065,7 @@ static bool sitd_complete(struct ehci_hcd *ehci, struct ehci_sitd *sitd)
2081 t = hc32_to_cpup(ehci, &sitd->hw_results); 2065 t = hc32_to_cpup(ehci, &sitd->hw_results);
2082 2066
2083 /* report transfer status */ 2067 /* report transfer status */
2084 if (t & SITD_ERRS) { 2068 if (unlikely(t & SITD_ERRS)) {
2085 urb->error_count++; 2069 urb->error_count++;
2086 if (t & SITD_STS_DBE) 2070 if (t & SITD_STS_DBE)
2087 desc->status = usb_pipein (urb->pipe) 2071 desc->status = usb_pipein (urb->pipe)
@@ -2091,6 +2075,9 @@ static bool sitd_complete(struct ehci_hcd *ehci, struct ehci_sitd *sitd)
2091 desc->status = -EOVERFLOW; 2075 desc->status = -EOVERFLOW;
2092 else /* XACT, MMF, etc */ 2076 else /* XACT, MMF, etc */
2093 desc->status = -EPROTO; 2077 desc->status = -EPROTO;
2078 } else if (unlikely(t & SITD_STS_ACTIVE)) {
2079 /* URB was too late */
2080 urb->error_count++;
2094 } else { 2081 } else {
2095 desc->status = 0; 2082 desc->status = 0;
2096 desc->actual_length = desc->length - SITD_LENGTH(t); 2083 desc->actual_length = desc->length - SITD_LENGTH(t);
@@ -2220,16 +2207,16 @@ static void scan_isoc(struct ehci_hcd *ehci)
2220 now_frame = (uf >> 3) & fmask; 2207 now_frame = (uf >> 3) & fmask;
2221 live = true; 2208 live = true;
2222 } else { 2209 } else {
2223 now_frame = (ehci->next_frame - 1) & fmask; 2210 now_frame = (ehci->last_iso_frame - 1) & fmask;
2224 live = false; 2211 live = false;
2225 } 2212 }
2226 ehci->now_frame = now_frame; 2213 ehci->now_frame = now_frame;
2227 2214
2228 frame = ehci->next_frame;
2229 for (;;) { 2215 for (;;) {
2230 union ehci_shadow q, *q_p; 2216 union ehci_shadow q, *q_p;
2231 __hc32 type, *hw_p; 2217 __hc32 type, *hw_p;
2232 2218
2219 frame = ehci->last_iso_frame;
2233restart: 2220restart:
2234 /* scan each element in frame's queue for completions */ 2221 /* scan each element in frame's queue for completions */
2235 q_p = &ehci->pshadow [frame]; 2222 q_p = &ehci->pshadow [frame];
@@ -2334,7 +2321,6 @@ restart:
2334 /* Stop when we have reached the current frame */ 2321 /* Stop when we have reached the current frame */
2335 if (frame == now_frame) 2322 if (frame == now_frame)
2336 break; 2323 break;
2337 frame = (frame + 1) & fmask; 2324 ehci->last_iso_frame = (frame + 1) & fmask;
2338 } 2325 }
2339 ehci->next_frame = now_frame;
2340} 2326}
diff --git a/drivers/usb/host/ehci-sh.c b/drivers/usb/host/ehci-sh.c
index 6081e1ed3ac9..0c90a24fa989 100644
--- a/drivers/usb/host/ehci-sh.c
+++ b/drivers/usb/host/ehci-sh.c
@@ -21,17 +21,10 @@ struct ehci_sh_priv {
21static int ehci_sh_reset(struct usb_hcd *hcd) 21static int ehci_sh_reset(struct usb_hcd *hcd)
22{ 22{
23 struct ehci_hcd *ehci = hcd_to_ehci(hcd); 23 struct ehci_hcd *ehci = hcd_to_ehci(hcd);
24 int ret;
25 24
26 ehci->caps = hcd->regs; 25 ehci->caps = hcd->regs;
27 26
28 ret = ehci_setup(hcd); 27 return ehci_setup(hcd);
29 if (unlikely(ret))
30 return ret;
31
32 ehci_port_power(ehci, 0);
33
34 return ret;
35} 28}
36 29
37static const struct hc_driver ehci_sh_hc_driver = { 30static const struct hc_driver ehci_sh_hc_driver = {
diff --git a/drivers/usb/host/ehci-spear.c b/drivers/usb/host/ehci-spear.c
index c718a065e154..3fadff8f8d30 100644
--- a/drivers/usb/host/ehci-spear.c
+++ b/drivers/usb/host/ehci-spear.c
@@ -37,18 +37,11 @@ static void spear_stop_ehci(struct spear_ehci *ehci)
37static int ehci_spear_setup(struct usb_hcd *hcd) 37static int ehci_spear_setup(struct usb_hcd *hcd)
38{ 38{
39 struct ehci_hcd *ehci = hcd_to_ehci(hcd); 39 struct ehci_hcd *ehci = hcd_to_ehci(hcd);
40 int retval = 0;
41 40
42 /* registers start at offset 0x0 */ 41 /* registers start at offset 0x0 */
43 ehci->caps = hcd->regs; 42 ehci->caps = hcd->regs;
44 43
45 retval = ehci_setup(hcd); 44 return ehci_setup(hcd);
46 if (retval)
47 return retval;
48
49 ehci_port_power(ehci, 0);
50
51 return retval;
52} 45}
53 46
54static const struct hc_driver ehci_spear_hc_driver = { 47static const struct hc_driver ehci_spear_hc_driver = {
@@ -116,8 +109,6 @@ static int spear_ehci_hcd_drv_probe(struct platform_device *pdev)
116 struct clk *usbh_clk; 109 struct clk *usbh_clk;
117 const struct hc_driver *driver = &ehci_spear_hc_driver; 110 const struct hc_driver *driver = &ehci_spear_hc_driver;
118 int irq, retval; 111 int irq, retval;
119 char clk_name[20] = "usbh_clk";
120 static int instance = -1;
121 112
122 if (usb_disabled()) 113 if (usb_disabled())
123 return -ENODEV; 114 return -ENODEV;
@@ -125,7 +116,7 @@ static int spear_ehci_hcd_drv_probe(struct platform_device *pdev)
125 irq = platform_get_irq(pdev, 0); 116 irq = platform_get_irq(pdev, 0);
126 if (irq < 0) { 117 if (irq < 0) {
127 retval = irq; 118 retval = irq;
128 goto fail_irq_get; 119 goto fail;
129 } 120 }
130 121
131 /* 122 /*
@@ -136,47 +127,38 @@ static int spear_ehci_hcd_drv_probe(struct platform_device *pdev)
136 if (!pdev->dev.dma_mask) 127 if (!pdev->dev.dma_mask)
137 pdev->dev.dma_mask = &spear_ehci_dma_mask; 128 pdev->dev.dma_mask = &spear_ehci_dma_mask;
138 129
139 /* 130 usbh_clk = devm_clk_get(&pdev->dev, NULL);
140 * Increment the device instance, when probing via device-tree
141 */
142 if (pdev->id < 0)
143 instance++;
144 else
145 instance = pdev->id;
146 sprintf(clk_name, "usbh.%01d_clk", instance);
147
148 usbh_clk = clk_get(NULL, clk_name);
149 if (IS_ERR(usbh_clk)) { 131 if (IS_ERR(usbh_clk)) {
150 dev_err(&pdev->dev, "Error getting interface clock\n"); 132 dev_err(&pdev->dev, "Error getting interface clock\n");
151 retval = PTR_ERR(usbh_clk); 133 retval = PTR_ERR(usbh_clk);
152 goto fail_get_usbh_clk; 134 goto fail;
153 } 135 }
154 136
155 hcd = usb_create_hcd(driver, &pdev->dev, dev_name(&pdev->dev)); 137 hcd = usb_create_hcd(driver, &pdev->dev, dev_name(&pdev->dev));
156 if (!hcd) { 138 if (!hcd) {
157 retval = -ENOMEM; 139 retval = -ENOMEM;
158 goto fail_create_hcd; 140 goto fail;
159 } 141 }
160 142
161 res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 143 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
162 if (!res) { 144 if (!res) {
163 retval = -ENODEV; 145 retval = -ENODEV;
164 goto fail_request_resource; 146 goto err_put_hcd;
165 } 147 }
166 148
167 hcd->rsrc_start = res->start; 149 hcd->rsrc_start = res->start;
168 hcd->rsrc_len = resource_size(res); 150 hcd->rsrc_len = resource_size(res);
169 if (!request_mem_region(hcd->rsrc_start, hcd->rsrc_len, 151 if (!devm_request_mem_region(&pdev->dev, hcd->rsrc_start, hcd->rsrc_len,
170 driver->description)) { 152 driver->description)) {
171 retval = -EBUSY; 153 retval = -EBUSY;
172 goto fail_request_resource; 154 goto err_put_hcd;
173 } 155 }
174 156
175 hcd->regs = ioremap(hcd->rsrc_start, hcd->rsrc_len); 157 hcd->regs = devm_ioremap(&pdev->dev, hcd->rsrc_start, hcd->rsrc_len);
176 if (hcd->regs == NULL) { 158 if (hcd->regs == NULL) {
177 dev_dbg(&pdev->dev, "error mapping memory\n"); 159 dev_dbg(&pdev->dev, "error mapping memory\n");
178 retval = -ENOMEM; 160 retval = -ENOMEM;
179 goto fail_ioremap; 161 goto err_put_hcd;
180 } 162 }
181 163
182 ehci = (struct spear_ehci *)hcd_to_ehci(hcd); 164 ehci = (struct spear_ehci *)hcd_to_ehci(hcd);
@@ -185,21 +167,15 @@ static int spear_ehci_hcd_drv_probe(struct platform_device *pdev)
185 spear_start_ehci(ehci); 167 spear_start_ehci(ehci);
186 retval = usb_add_hcd(hcd, irq, IRQF_SHARED); 168 retval = usb_add_hcd(hcd, irq, IRQF_SHARED);
187 if (retval) 169 if (retval)
188 goto fail_add_hcd; 170 goto err_stop_ehci;
189 171
190 return retval; 172 return retval;
191 173
192fail_add_hcd: 174err_stop_ehci:
193 spear_stop_ehci(ehci); 175 spear_stop_ehci(ehci);
194 iounmap(hcd->regs); 176err_put_hcd:
195fail_ioremap:
196 release_mem_region(hcd->rsrc_start, hcd->rsrc_len);
197fail_request_resource:
198 usb_put_hcd(hcd); 177 usb_put_hcd(hcd);
199fail_create_hcd: 178fail:
200 clk_put(usbh_clk);
201fail_get_usbh_clk:
202fail_irq_get:
203 dev_err(&pdev->dev, "init fail, %d\n", retval); 179 dev_err(&pdev->dev, "init fail, %d\n", retval);
204 180
205 return retval ; 181 return retval ;
@@ -218,13 +194,8 @@ static int spear_ehci_hcd_drv_remove(struct platform_device *pdev)
218 194
219 if (ehci_p->clk) 195 if (ehci_p->clk)
220 spear_stop_ehci(ehci_p); 196 spear_stop_ehci(ehci_p);
221 iounmap(hcd->regs);
222 release_mem_region(hcd->rsrc_start, hcd->rsrc_len);
223 usb_put_hcd(hcd); 197 usb_put_hcd(hcd);
224 198
225 if (ehci_p->clk)
226 clk_put(ehci_p->clk);
227
228 return 0; 199 return 0;
229} 200}
230 201
diff --git a/drivers/usb/host/ehci-tegra.c b/drivers/usb/host/ehci-tegra.c
index 6223d1757848..ef0a6ef7875b 100644
--- a/drivers/usb/host/ehci-tegra.c
+++ b/drivers/usb/host/ehci-tegra.c
@@ -28,7 +28,10 @@
28#include <linux/pm_runtime.h> 28#include <linux/pm_runtime.h>
29 29
30#include <linux/usb/tegra_usb_phy.h> 30#include <linux/usb/tegra_usb_phy.h>
31#include <mach/iomap.h> 31
32#define TEGRA_USB_BASE 0xC5000000
33#define TEGRA_USB2_BASE 0xC5004000
34#define TEGRA_USB3_BASE 0xC5008000
32 35
33#define TEGRA_USB_DMA_ALIGN 32 36#define TEGRA_USB_DMA_ALIGN 32
34 37
@@ -277,7 +280,6 @@ static void tegra_ehci_shutdown(struct usb_hcd *hcd)
277static int tegra_ehci_setup(struct usb_hcd *hcd) 280static int tegra_ehci_setup(struct usb_hcd *hcd)
278{ 281{
279 struct ehci_hcd *ehci = hcd_to_ehci(hcd); 282 struct ehci_hcd *ehci = hcd_to_ehci(hcd);
280 int retval;
281 283
282 /* EHCI registers start at offset 0x100 */ 284 /* EHCI registers start at offset 0x100 */
283 ehci->caps = hcd->regs + 0x100; 285 ehci->caps = hcd->regs + 0x100;
@@ -285,12 +287,7 @@ static int tegra_ehci_setup(struct usb_hcd *hcd)
285 /* switch to host mode */ 287 /* switch to host mode */
286 hcd->has_tt = 1; 288 hcd->has_tt = 1;
287 289
288 retval = ehci_setup(hcd); 290 return ehci_setup(hcd);
289 if (retval)
290 return retval;
291
292 ehci_port_power(ehci, 1);
293 return retval;
294} 291}
295 292
296struct dma_aligned_buffer { 293struct dma_aligned_buffer {
@@ -778,9 +775,6 @@ static int tegra_ehci_remove(struct platform_device *pdev)
778 struct tegra_ehci_hcd *tegra = platform_get_drvdata(pdev); 775 struct tegra_ehci_hcd *tegra = platform_get_drvdata(pdev);
779 struct usb_hcd *hcd = ehci_to_hcd(tegra->ehci); 776 struct usb_hcd *hcd = ehci_to_hcd(tegra->ehci);
780 777
781 if (tegra == NULL || hcd == NULL)
782 return -EINVAL;
783
784 pm_runtime_get_sync(&pdev->dev); 778 pm_runtime_get_sync(&pdev->dev);
785 pm_runtime_disable(&pdev->dev); 779 pm_runtime_disable(&pdev->dev);
786 pm_runtime_put_noidle(&pdev->dev); 780 pm_runtime_put_noidle(&pdev->dev);
diff --git a/drivers/usb/host/ehci-vt8500.c b/drivers/usb/host/ehci-vt8500.c
index d3c9a3e397b9..11695d5b9d86 100644
--- a/drivers/usb/host/ehci-vt8500.c
+++ b/drivers/usb/host/ehci-vt8500.c
@@ -19,22 +19,6 @@
19#include <linux/of.h> 19#include <linux/of.h>
20#include <linux/platform_device.h> 20#include <linux/platform_device.h>
21 21
22static int ehci_update_device(struct usb_hcd *hcd, struct usb_device *udev)
23{
24 struct ehci_hcd *ehci = hcd_to_ehci(hcd);
25 int rc = 0;
26
27 if (!udev->parent) /* udev is root hub itself, impossible */
28 rc = -1;
29 /* we only support lpm device connected to root hub yet */
30 if (ehci->has_lpm && !udev->parent->parent) {
31 rc = ehci_lpm_set_da(ehci, udev->devnum, udev->portnum);
32 if (!rc)
33 rc = ehci_lpm_check(ehci, udev->portnum);
34 }
35 return rc;
36}
37
38static const struct hc_driver vt8500_ehci_hc_driver = { 22static const struct hc_driver vt8500_ehci_hc_driver = {
39 .description = hcd_name, 23 .description = hcd_name,
40 .product_desc = "VT8500 EHCI", 24 .product_desc = "VT8500 EHCI",
@@ -77,11 +61,6 @@ static const struct hc_driver vt8500_ehci_hc_driver = {
77 .relinquish_port = ehci_relinquish_port, 61 .relinquish_port = ehci_relinquish_port,
78 .port_handed_over = ehci_port_handed_over, 62 .port_handed_over = ehci_port_handed_over,
79 63
80 /*
81 * call back when device connected and addressed
82 */
83 .update_device = ehci_update_device,
84
85 .clear_tt_buffer_complete = ehci_clear_tt_buffer_complete, 64 .clear_tt_buffer_complete = ehci_clear_tt_buffer_complete,
86}; 65};
87 66
diff --git a/drivers/usb/host/ehci-w90x900.c b/drivers/usb/host/ehci-w90x900.c
index ec598082c14b..fdd7c4873cf2 100644
--- a/drivers/usb/host/ehci-w90x900.c
+++ b/drivers/usb/host/ehci-w90x900.c
@@ -13,7 +13,7 @@
13 13
14#include <linux/platform_device.h> 14#include <linux/platform_device.h>
15 15
16/*ebable phy0 and phy1 for w90p910*/ 16/* enable phy0 and phy1 for w90p910 */
17#define ENPHY (0x01<<8) 17#define ENPHY (0x01<<8)
18#define PHY0_CTR (0xA4) 18#define PHY0_CTR (0xA4)
19#define PHY1_CTR (0xA8) 19#define PHY1_CTR (0xA8)
diff --git a/drivers/usb/host/ehci-xls.c b/drivers/usb/host/ehci-xls.c
deleted file mode 100644
index 8dc6a22d90b8..000000000000
--- a/drivers/usb/host/ehci-xls.c
+++ /dev/null
@@ -1,142 +0,0 @@
1/*
2 * EHCI HCD for Netlogic XLS processors.
3 *
4 * (C) Copyright 2011 Netlogic Microsystems Inc.
5 *
6 * Based on various ehci-*.c drivers
7 *
8 * This file is subject to the terms and conditions of the GNU General Public
9 * License. See the file COPYING in the main directory of this archive for
10 * more details.
11 */
12
13#include <linux/platform_device.h>
14
15static int ehci_xls_setup(struct usb_hcd *hcd)
16{
17 struct ehci_hcd *ehci = hcd_to_ehci(hcd);
18
19 ehci->caps = hcd->regs;
20
21 return ehci_setup(hcd);
22}
23
24int ehci_xls_probe_internal(const struct hc_driver *driver,
25 struct platform_device *pdev)
26{
27 struct usb_hcd *hcd;
28 struct resource *res;
29 int retval, irq;
30
31 /* Get our IRQ from an earlier registered Platform Resource */
32 irq = platform_get_irq(pdev, 0);
33 if (irq < 0) {
34 dev_err(&pdev->dev, "Found HC with no IRQ. Check %s setup!\n",
35 dev_name(&pdev->dev));
36 return -ENODEV;
37 }
38
39 /* Get our Memory Handle */
40 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
41 if (!res) {
42 dev_err(&pdev->dev, "Error: MMIO Handle %s setup!\n",
43 dev_name(&pdev->dev));
44 return -ENODEV;
45 }
46 hcd = usb_create_hcd(driver, &pdev->dev, dev_name(&pdev->dev));
47 if (!hcd) {
48 retval = -ENOMEM;
49 goto err1;
50 }
51
52 hcd->rsrc_start = res->start;
53 hcd->rsrc_len = resource_size(res);
54
55 if (!request_mem_region(hcd->rsrc_start, hcd->rsrc_len,
56 driver->description)) {
57 dev_dbg(&pdev->dev, "controller already in use\n");
58 retval = -EBUSY;
59 goto err2;
60 }
61 hcd->regs = ioremap_nocache(hcd->rsrc_start, hcd->rsrc_len);
62
63 if (hcd->regs == NULL) {
64 dev_dbg(&pdev->dev, "error mapping memory\n");
65 retval = -EFAULT;
66 goto err3;
67 }
68
69 retval = usb_add_hcd(hcd, irq, IRQF_SHARED);
70 if (retval != 0)
71 goto err4;
72 return retval;
73
74err4:
75 iounmap(hcd->regs);
76err3:
77 release_mem_region(hcd->rsrc_start, hcd->rsrc_len);
78err2:
79 usb_put_hcd(hcd);
80err1:
81 dev_err(&pdev->dev, "init %s fail, %d\n", dev_name(&pdev->dev),
82 retval);
83 return retval;
84}
85
86static struct hc_driver ehci_xls_hc_driver = {
87 .description = hcd_name,
88 .product_desc = "XLS EHCI Host Controller",
89 .hcd_priv_size = sizeof(struct ehci_hcd),
90 .irq = ehci_irq,
91 .flags = HCD_USB2 | HCD_MEMORY,
92 .reset = ehci_xls_setup,
93 .start = ehci_run,
94 .stop = ehci_stop,
95 .shutdown = ehci_shutdown,
96
97 .urb_enqueue = ehci_urb_enqueue,
98 .urb_dequeue = ehci_urb_dequeue,
99 .endpoint_disable = ehci_endpoint_disable,
100 .endpoint_reset = ehci_endpoint_reset,
101
102 .get_frame_number = ehci_get_frame,
103
104 .hub_status_data = ehci_hub_status_data,
105 .hub_control = ehci_hub_control,
106 .bus_suspend = ehci_bus_suspend,
107 .bus_resume = ehci_bus_resume,
108 .relinquish_port = ehci_relinquish_port,
109 .port_handed_over = ehci_port_handed_over,
110
111 .clear_tt_buffer_complete = ehci_clear_tt_buffer_complete,
112};
113
114static int ehci_xls_probe(struct platform_device *pdev)
115{
116 if (usb_disabled())
117 return -ENODEV;
118
119 return ehci_xls_probe_internal(&ehci_xls_hc_driver, pdev);
120}
121
122static int ehci_xls_remove(struct platform_device *pdev)
123{
124 struct usb_hcd *hcd = platform_get_drvdata(pdev);
125
126 usb_remove_hcd(hcd);
127 iounmap(hcd->regs);
128 release_mem_region(hcd->rsrc_start, hcd->rsrc_len);
129 usb_put_hcd(hcd);
130 return 0;
131}
132
133MODULE_ALIAS("ehci-xls");
134
135static struct platform_driver ehci_xls_driver = {
136 .probe = ehci_xls_probe,
137 .remove = ehci_xls_remove,
138 .shutdown = usb_hcd_platform_shutdown,
139 .driver = {
140 .name = "ehci-xls",
141 },
142};
diff --git a/drivers/usb/host/ehci.h b/drivers/usb/host/ehci.h
index da07d98f7d1d..9dadc7118d68 100644
--- a/drivers/usb/host/ehci.h
+++ b/drivers/usb/host/ehci.h
@@ -143,7 +143,7 @@ struct ehci_hcd { /* one per controller */
143 struct ehci_qh *intr_unlink_last; 143 struct ehci_qh *intr_unlink_last;
144 unsigned intr_unlink_cycle; 144 unsigned intr_unlink_cycle;
145 unsigned now_frame; /* frame from HC hardware */ 145 unsigned now_frame; /* frame from HC hardware */
146 unsigned next_frame; /* scan periodic, start here */ 146 unsigned last_iso_frame; /* last frame scanned for iso */
147 unsigned intr_count; /* intr activity count */ 147 unsigned intr_count; /* intr activity count */
148 unsigned isoc_count; /* isoc activity count */ 148 unsigned isoc_count; /* isoc activity count */
149 unsigned periodic_count; /* periodic activity count */ 149 unsigned periodic_count; /* periodic activity count */
@@ -193,7 +193,6 @@ struct ehci_hcd { /* one per controller */
193 unsigned has_amcc_usb23:1; 193 unsigned has_amcc_usb23:1;
194 unsigned need_io_watchdog:1; 194 unsigned need_io_watchdog:1;
195 unsigned amd_pll_fix:1; 195 unsigned amd_pll_fix:1;
196 unsigned fs_i_thresh:1; /* Intel iso scheduling */
197 unsigned use_dummy_qh:1; /* AMD Frame List table quirk*/ 196 unsigned use_dummy_qh:1; /* AMD Frame List table quirk*/
198 unsigned has_synopsys_hc_bug:1; /* Synopsys HC */ 197 unsigned has_synopsys_hc_bug:1; /* Synopsys HC */
199 unsigned frame_index_bug:1; /* MosChip (AKA NetMos) */ 198 unsigned frame_index_bug:1; /* MosChip (AKA NetMos) */
@@ -207,7 +206,6 @@ struct ehci_hcd { /* one per controller */
207 #define OHCI_HCCTRL_LEN 0x4 206 #define OHCI_HCCTRL_LEN 0x4
208 __hc32 *ohci_hcctrl_reg; 207 __hc32 *ohci_hcctrl_reg;
209 unsigned has_hostpc:1; 208 unsigned has_hostpc:1;
210 unsigned has_lpm:1; /* support link power management */
211 unsigned has_ppcd:1; /* support per-port change bits */ 209 unsigned has_ppcd:1; /* support per-port change bits */
212 u8 sbrn; /* packed release number */ 210 u8 sbrn; /* packed release number */
213 211
@@ -762,26 +760,41 @@ static inline u32 hc32_to_cpup (const struct ehci_hcd *ehci, const __hc32 *x)
762 760
763/*-------------------------------------------------------------------------*/ 761/*-------------------------------------------------------------------------*/
764 762
765#ifdef CONFIG_PCI 763#define ehci_dbg(ehci, fmt, args...) \
766 764 dev_dbg(ehci_to_hcd(ehci)->self.controller , fmt , ## args)
767/* For working around the MosChip frame-index-register bug */ 765#define ehci_err(ehci, fmt, args...) \
768static unsigned ehci_read_frame_index(struct ehci_hcd *ehci); 766 dev_err(ehci_to_hcd(ehci)->self.controller , fmt , ## args)
769 767#define ehci_info(ehci, fmt, args...) \
768 dev_info(ehci_to_hcd(ehci)->self.controller , fmt , ## args)
769#define ehci_warn(ehci, fmt, args...) \
770 dev_warn(ehci_to_hcd(ehci)->self.controller , fmt , ## args)
771
772#ifdef VERBOSE_DEBUG
773# define ehci_vdbg ehci_dbg
770#else 774#else
771 775 static inline void ehci_vdbg(struct ehci_hcd *ehci, ...) {}
772static inline unsigned ehci_read_frame_index(struct ehci_hcd *ehci)
773{
774 return ehci_readl(ehci, &ehci->regs->frame_index);
775}
776
777#endif 776#endif
778 777
779/*-------------------------------------------------------------------------*/
780
781#ifndef DEBUG 778#ifndef DEBUG
782#define STUB_DEBUG_FILES 779#define STUB_DEBUG_FILES
783#endif /* DEBUG */ 780#endif /* DEBUG */
784 781
785/*-------------------------------------------------------------------------*/ 782/*-------------------------------------------------------------------------*/
786 783
784/* Declarations of things exported for use by ehci platform drivers */
785
786struct ehci_driver_overrides {
787 size_t extra_priv_size;
788 int (*reset)(struct usb_hcd *hcd);
789};
790
791extern void ehci_init_driver(struct hc_driver *drv,
792 const struct ehci_driver_overrides *over);
793extern int ehci_setup(struct usb_hcd *hcd);
794
795#ifdef CONFIG_PM
796extern int ehci_suspend(struct usb_hcd *hcd, bool do_wakeup);
797extern int ehci_resume(struct usb_hcd *hcd, bool hibernated);
798#endif /* CONFIG_PM */
799
787#endif /* __LINUX_EHCI_HCD_H */ 800#endif /* __LINUX_EHCI_HCD_H */
diff --git a/drivers/usb/host/isp1760-if.c b/drivers/usb/host/isp1760-if.c
index fff114fd5461..958379f9de79 100644
--- a/drivers/usb/host/isp1760-if.c
+++ b/drivers/usb/host/isp1760-if.c
@@ -43,7 +43,6 @@ static int of_isp1760_probe(struct platform_device *dev)
43 struct device_node *dp = dev->dev.of_node; 43 struct device_node *dp = dev->dev.of_node;
44 struct resource *res; 44 struct resource *res;
45 struct resource memory; 45 struct resource memory;
46 struct of_irq oirq;
47 int virq; 46 int virq;
48 resource_size_t res_len; 47 resource_size_t res_len;
49 int ret; 48 int ret;
@@ -69,14 +68,12 @@ static int of_isp1760_probe(struct platform_device *dev)
69 goto free_data; 68 goto free_data;
70 } 69 }
71 70
72 if (of_irq_map_one(dp, 0, &oirq)) { 71 virq = irq_of_parse_and_map(dp, 0);
72 if (!virq) {
73 ret = -ENODEV; 73 ret = -ENODEV;
74 goto release_reg; 74 goto release_reg;
75 } 75 }
76 76
77 virq = irq_create_of_mapping(oirq.controller, oirq.specifier,
78 oirq.size);
79
80 if (of_device_is_compatible(dp, "nxp,usb-isp1761")) 77 if (of_device_is_compatible(dp, "nxp,usb-isp1761"))
81 devflags |= ISP1760_FLAG_ISP1761; 78 devflags |= ISP1760_FLAG_ISP1761;
82 79
diff --git a/drivers/usb/host/ohci-at91.c b/drivers/usb/host/ohci-at91.c
index 0bf72f943b00..908d84af1dd7 100644
--- a/drivers/usb/host/ohci-at91.c
+++ b/drivers/usb/host/ohci-at91.c
@@ -705,7 +705,7 @@ static int ohci_hcd_at91_drv_resume(struct platform_device *pdev)
705 if (!clocked) 705 if (!clocked)
706 at91_start_clock(); 706 at91_start_clock();
707 707
708 ohci_finish_controller_resume(hcd); 708 ohci_resume(hcd, false);
709 return 0; 709 return 0;
710} 710}
711#else 711#else
diff --git a/drivers/usb/host/ohci-au1xxx.c b/drivers/usb/host/ohci-au1xxx.c
deleted file mode 100644
index c611699b4aa6..000000000000
--- a/drivers/usb/host/ohci-au1xxx.c
+++ /dev/null
@@ -1,234 +0,0 @@
1/*
2 * OHCI HCD (Host Controller Driver) for USB.
3 *
4 * (C) Copyright 1999 Roman Weissgaerber <weissg@vienna.at>
5 * (C) Copyright 2000-2002 David Brownell <dbrownell@users.sourceforge.net>
6 * (C) Copyright 2002 Hewlett-Packard Company
7 *
8 * Bus Glue for AMD Alchemy Au1xxx
9 *
10 * Written by Christopher Hoover <ch@hpl.hp.com>
11 * Based on fragments of previous driver by Russell King et al.
12 *
13 * Modified for LH7A404 from ohci-sa1111.c
14 * by Durgesh Pattamatta <pattamattad@sharpsec.com>
15 * Modified for AMD Alchemy Au1xxx
16 * by Matt Porter <mporter@kernel.crashing.org>
17 *
18 * This file is licenced under the GPL.
19 */
20
21#include <linux/platform_device.h>
22#include <linux/signal.h>
23
24#include <asm/mach-au1x00/au1000.h>
25
26
27extern int usb_disabled(void);
28
29static int __devinit ohci_au1xxx_start(struct usb_hcd *hcd)
30{
31 struct ohci_hcd *ohci = hcd_to_ohci(hcd);
32 int ret;
33
34 ohci_dbg(ohci, "ohci_au1xxx_start, ohci:%p", ohci);
35
36 if ((ret = ohci_init(ohci)) < 0)
37 return ret;
38
39 if ((ret = ohci_run(ohci)) < 0) {
40 dev_err(hcd->self.controller, "can't start %s",
41 hcd->self.bus_name);
42 ohci_stop(hcd);
43 return ret;
44 }
45
46 return 0;
47}
48
49static const struct hc_driver ohci_au1xxx_hc_driver = {
50 .description = hcd_name,
51 .product_desc = "Au1xxx OHCI",
52 .hcd_priv_size = sizeof(struct ohci_hcd),
53
54 /*
55 * generic hardware linkage
56 */
57 .irq = ohci_irq,
58 .flags = HCD_USB11 | HCD_MEMORY,
59
60 /*
61 * basic lifecycle operations
62 */
63 .start = ohci_au1xxx_start,
64 .stop = ohci_stop,
65 .shutdown = ohci_shutdown,
66
67 /*
68 * managing i/o requests and associated device resources
69 */
70 .urb_enqueue = ohci_urb_enqueue,
71 .urb_dequeue = ohci_urb_dequeue,
72 .endpoint_disable = ohci_endpoint_disable,
73
74 /*
75 * scheduling support
76 */
77 .get_frame_number = ohci_get_frame,
78
79 /*
80 * root hub support
81 */
82 .hub_status_data = ohci_hub_status_data,
83 .hub_control = ohci_hub_control,
84#ifdef CONFIG_PM
85 .bus_suspend = ohci_bus_suspend,
86 .bus_resume = ohci_bus_resume,
87#endif
88 .start_port_reset = ohci_start_port_reset,
89};
90
91static int ohci_hcd_au1xxx_drv_probe(struct platform_device *pdev)
92{
93 int ret, unit;
94 struct usb_hcd *hcd;
95
96 if (usb_disabled())
97 return -ENODEV;
98
99 if (pdev->resource[1].flags != IORESOURCE_IRQ) {
100 pr_debug("resource[1] is not IORESOURCE_IRQ\n");
101 return -ENOMEM;
102 }
103
104 hcd = usb_create_hcd(&ohci_au1xxx_hc_driver, &pdev->dev, "au1xxx");
105 if (!hcd)
106 return -ENOMEM;
107
108 hcd->rsrc_start = pdev->resource[0].start;
109 hcd->rsrc_len = pdev->resource[0].end - pdev->resource[0].start + 1;
110
111 if (!request_mem_region(hcd->rsrc_start, hcd->rsrc_len, hcd_name)) {
112 pr_debug("request_mem_region failed\n");
113 ret = -EBUSY;
114 goto err1;
115 }
116
117 hcd->regs = ioremap(hcd->rsrc_start, hcd->rsrc_len);
118 if (!hcd->regs) {
119 pr_debug("ioremap failed\n");
120 ret = -ENOMEM;
121 goto err2;
122 }
123
124 unit = (hcd->rsrc_start == AU1300_USB_OHCI1_PHYS_ADDR) ?
125 ALCHEMY_USB_OHCI1 : ALCHEMY_USB_OHCI0;
126 if (alchemy_usb_control(unit, 1)) {
127 printk(KERN_INFO "%s: controller init failed!\n", pdev->name);
128 ret = -ENODEV;
129 goto err3;
130 }
131
132 ohci_hcd_init(hcd_to_ohci(hcd));
133
134 ret = usb_add_hcd(hcd, pdev->resource[1].start,
135 IRQF_SHARED);
136 if (ret == 0) {
137 platform_set_drvdata(pdev, hcd);
138 return ret;
139 }
140
141 alchemy_usb_control(unit, 0);
142err3:
143 iounmap(hcd->regs);
144err2:
145 release_mem_region(hcd->rsrc_start, hcd->rsrc_len);
146err1:
147 usb_put_hcd(hcd);
148 return ret;
149}
150
151static int ohci_hcd_au1xxx_drv_remove(struct platform_device *pdev)
152{
153 struct usb_hcd *hcd = platform_get_drvdata(pdev);
154 int unit;
155
156 unit = (hcd->rsrc_start == AU1300_USB_OHCI1_PHYS_ADDR) ?
157 ALCHEMY_USB_OHCI1 : ALCHEMY_USB_OHCI0;
158 usb_remove_hcd(hcd);
159 alchemy_usb_control(unit, 0);
160 iounmap(hcd->regs);
161 release_mem_region(hcd->rsrc_start, hcd->rsrc_len);
162 usb_put_hcd(hcd);
163 platform_set_drvdata(pdev, NULL);
164
165 return 0;
166}
167
168#ifdef CONFIG_PM
169static int ohci_hcd_au1xxx_drv_suspend(struct device *dev)
170{
171 struct usb_hcd *hcd = dev_get_drvdata(dev);
172 struct ohci_hcd *ohci = hcd_to_ohci(hcd);
173 unsigned long flags;
174 int rc;
175
176 rc = 0;
177
178 /* Root hub was already suspended. Disable irq emission and
179 * mark HW unaccessible, bail out if RH has been resumed. Use
180 * the spinlock to properly synchronize with possible pending
181 * RH suspend or resume activity.
182 */
183 spin_lock_irqsave(&ohci->lock, flags);
184 if (ohci->rh_state != OHCI_RH_SUSPENDED) {
185 rc = -EINVAL;
186 goto bail;
187 }
188 ohci_writel(ohci, OHCI_INTR_MIE, &ohci->regs->intrdisable);
189 (void)ohci_readl(ohci, &ohci->regs->intrdisable);
190
191 clear_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags);
192
193 alchemy_usb_control(ALCHEMY_USB_OHCI0, 0);
194bail:
195 spin_unlock_irqrestore(&ohci->lock, flags);
196
197 return rc;
198}
199
200static int ohci_hcd_au1xxx_drv_resume(struct device *dev)
201{
202 struct usb_hcd *hcd = dev_get_drvdata(dev);
203
204 alchemy_usb_control(ALCHEMY_USB_OHCI0, 1);
205
206 set_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags);
207 ohci_finish_controller_resume(hcd);
208
209 return 0;
210}
211
212static const struct dev_pm_ops au1xxx_ohci_pmops = {
213 .suspend = ohci_hcd_au1xxx_drv_suspend,
214 .resume = ohci_hcd_au1xxx_drv_resume,
215};
216
217#define AU1XXX_OHCI_PMOPS &au1xxx_ohci_pmops
218
219#else
220#define AU1XXX_OHCI_PMOPS NULL
221#endif
222
223static struct platform_driver ohci_hcd_au1xxx_driver = {
224 .probe = ohci_hcd_au1xxx_drv_probe,
225 .remove = ohci_hcd_au1xxx_drv_remove,
226 .shutdown = usb_hcd_platform_shutdown,
227 .driver = {
228 .name = "au1xxx-ohci",
229 .owner = THIS_MODULE,
230 .pm = AU1XXX_OHCI_PMOPS,
231 },
232};
233
234MODULE_ALIAS("platform:au1xxx-ohci");
diff --git a/drivers/usb/host/ohci-cns3xxx.c b/drivers/usb/host/ohci-cns3xxx.c
deleted file mode 100644
index 2c9f233047be..000000000000
--- a/drivers/usb/host/ohci-cns3xxx.c
+++ /dev/null
@@ -1,166 +0,0 @@
1/*
2 * Copyright 2008 Cavium Networks
3 *
4 * This file is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License, Version 2, as
6 * published by the Free Software Foundation.
7 */
8
9#include <linux/platform_device.h>
10#include <linux/atomic.h>
11#include <mach/cns3xxx.h>
12#include <mach/pm.h>
13
14static int __devinit
15cns3xxx_ohci_start(struct usb_hcd *hcd)
16{
17 struct ohci_hcd *ohci = hcd_to_ohci(hcd);
18 int ret;
19
20 /*
21 * EHCI and OHCI share the same clock and power,
22 * resetting twice would cause the 1st controller been reset.
23 * Therefore only do power up at the first up device, and
24 * power down at the last down device.
25 *
26 * Set USB AHB INCR length to 16
27 */
28 if (atomic_inc_return(&usb_pwr_ref) == 1) {
29 cns3xxx_pwr_power_up(1 << PM_PLL_HM_PD_CTRL_REG_OFFSET_PLL_USB);
30 cns3xxx_pwr_clk_en(1 << PM_CLK_GATE_REG_OFFSET_USB_HOST);
31 cns3xxx_pwr_soft_rst(1 << PM_SOFT_RST_REG_OFFST_USB_HOST);
32 __raw_writel((__raw_readl(MISC_CHIP_CONFIG_REG) | (0X2 << 24)),
33 MISC_CHIP_CONFIG_REG);
34 }
35
36 ret = ohci_init(ohci);
37 if (ret < 0)
38 return ret;
39
40 ohci->num_ports = 1;
41
42 ret = ohci_run(ohci);
43 if (ret < 0) {
44 dev_err(hcd->self.controller, "can't start %s\n",
45 hcd->self.bus_name);
46 ohci_stop(hcd);
47 return ret;
48 }
49 return 0;
50}
51
52static const struct hc_driver cns3xxx_ohci_hc_driver = {
53 .description = hcd_name,
54 .product_desc = "CNS3XXX OHCI Host controller",
55 .hcd_priv_size = sizeof(struct ohci_hcd),
56 .irq = ohci_irq,
57 .flags = HCD_USB11 | HCD_MEMORY,
58 .start = cns3xxx_ohci_start,
59 .stop = ohci_stop,
60 .shutdown = ohci_shutdown,
61 .urb_enqueue = ohci_urb_enqueue,
62 .urb_dequeue = ohci_urb_dequeue,
63 .endpoint_disable = ohci_endpoint_disable,
64 .get_frame_number = ohci_get_frame,
65 .hub_status_data = ohci_hub_status_data,
66 .hub_control = ohci_hub_control,
67#ifdef CONFIG_PM
68 .bus_suspend = ohci_bus_suspend,
69 .bus_resume = ohci_bus_resume,
70#endif
71 .start_port_reset = ohci_start_port_reset,
72};
73
74static int cns3xxx_ohci_probe(struct platform_device *pdev)
75{
76 struct device *dev = &pdev->dev;
77 struct usb_hcd *hcd;
78 const struct hc_driver *driver = &cns3xxx_ohci_hc_driver;
79 struct resource *res;
80 int irq;
81 int retval;
82
83 if (usb_disabled())
84 return -ENODEV;
85
86 res = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
87 if (!res) {
88 dev_err(dev, "Found HC with no IRQ.\n");
89 return -ENODEV;
90 }
91 irq = res->start;
92
93 hcd = usb_create_hcd(driver, dev, dev_name(dev));
94 if (!hcd)
95 return -ENOMEM;
96
97 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
98 if (!res) {
99 dev_err(dev, "Found HC with no register addr.\n");
100 retval = -ENODEV;
101 goto err1;
102 }
103 hcd->rsrc_start = res->start;
104 hcd->rsrc_len = resource_size(res);
105
106 if (!request_mem_region(hcd->rsrc_start, hcd->rsrc_len,
107 driver->description)) {
108 dev_dbg(dev, "controller already in use\n");
109 retval = -EBUSY;
110 goto err1;
111 }
112
113 hcd->regs = ioremap(hcd->rsrc_start, hcd->rsrc_len);
114 if (!hcd->regs) {
115 dev_dbg(dev, "error mapping memory\n");
116 retval = -EFAULT;
117 goto err2;
118 }
119
120 ohci_hcd_init(hcd_to_ohci(hcd));
121
122 retval = usb_add_hcd(hcd, irq, IRQF_SHARED);
123 if (retval == 0)
124 return retval;
125
126 iounmap(hcd->regs);
127err2:
128 release_mem_region(hcd->rsrc_start, hcd->rsrc_len);
129err1:
130 usb_put_hcd(hcd);
131 return retval;
132}
133
134static int cns3xxx_ohci_remove(struct platform_device *pdev)
135{
136 struct usb_hcd *hcd = platform_get_drvdata(pdev);
137
138 usb_remove_hcd(hcd);
139 iounmap(hcd->regs);
140 release_mem_region(hcd->rsrc_start, hcd->rsrc_len);
141
142 /*
143 * EHCI and OHCI share the same clock and power,
144 * resetting twice would cause the 1st controller been reset.
145 * Therefore only do power up at the first up device, and
146 * power down at the last down device.
147 */
148 if (atomic_dec_return(&usb_pwr_ref) == 0)
149 cns3xxx_pwr_clk_dis(1 << PM_CLK_GATE_REG_OFFSET_USB_HOST);
150
151 usb_put_hcd(hcd);
152
153 platform_set_drvdata(pdev, NULL);
154
155 return 0;
156}
157
158MODULE_ALIAS("platform:cns3xxx-ohci");
159
160static struct platform_driver ohci_hcd_cns3xxx_driver = {
161 .probe = cns3xxx_ohci_probe,
162 .remove = cns3xxx_ohci_remove,
163 .driver = {
164 .name = "cns3xxx-ohci",
165 },
166};
diff --git a/drivers/usb/host/ohci-ep93xx.c b/drivers/usb/host/ohci-ep93xx.c
index dbfbd1dfd2e2..a982f04ed787 100644
--- a/drivers/usb/host/ohci-ep93xx.c
+++ b/drivers/usb/host/ohci-ep93xx.c
@@ -194,7 +194,7 @@ static int ohci_hcd_ep93xx_drv_resume(struct platform_device *pdev)
194 194
195 ep93xx_start_hc(&pdev->dev); 195 ep93xx_start_hc(&pdev->dev);
196 196
197 ohci_finish_controller_resume(hcd); 197 ohci_resume(hcd, false);
198 return 0; 198 return 0;
199} 199}
200#endif 200#endif
diff --git a/drivers/usb/host/ohci-exynos.c b/drivers/usb/host/ohci-exynos.c
index 20a50081f922..6a30fc5bec93 100644
--- a/drivers/usb/host/ohci-exynos.c
+++ b/drivers/usb/host/ohci-exynos.c
@@ -23,6 +23,11 @@ struct exynos_ohci_hcd {
23 struct clk *clk; 23 struct clk *clk;
24}; 24};
25 25
26static int ohci_exynos_reset(struct usb_hcd *hcd)
27{
28 return ohci_init(hcd_to_ohci(hcd));
29}
30
26static int ohci_exynos_start(struct usb_hcd *hcd) 31static int ohci_exynos_start(struct usb_hcd *hcd)
27{ 32{
28 struct ohci_hcd *ohci = hcd_to_ohci(hcd); 33 struct ohci_hcd *ohci = hcd_to_ohci(hcd);
@@ -30,10 +35,6 @@ static int ohci_exynos_start(struct usb_hcd *hcd)
30 35
31 ohci_dbg(ohci, "ohci_exynos_start, ohci:%p", ohci); 36 ohci_dbg(ohci, "ohci_exynos_start, ohci:%p", ohci);
32 37
33 ret = ohci_init(ohci);
34 if (ret < 0)
35 return ret;
36
37 ret = ohci_run(ohci); 38 ret = ohci_run(ohci);
38 if (ret < 0) { 39 if (ret < 0) {
39 dev_err(hcd->self.controller, "can't start %s\n", 40 dev_err(hcd->self.controller, "can't start %s\n",
@@ -53,6 +54,7 @@ static const struct hc_driver exynos_ohci_hc_driver = {
53 .irq = ohci_irq, 54 .irq = ohci_irq,
54 .flags = HCD_MEMORY|HCD_USB11, 55 .flags = HCD_MEMORY|HCD_USB11,
55 56
57 .reset = ohci_exynos_reset,
56 .start = ohci_exynos_start, 58 .start = ohci_exynos_start,
57 .stop = ohci_stop, 59 .stop = ohci_stop,
58 .shutdown = ohci_shutdown, 60 .shutdown = ohci_shutdown,
@@ -115,7 +117,7 @@ static int __devinit exynos_ohci_probe(struct platform_device *pdev)
115 } 117 }
116 118
117 exynos_ohci->hcd = hcd; 119 exynos_ohci->hcd = hcd;
118 exynos_ohci->clk = clk_get(&pdev->dev, "usbhost"); 120 exynos_ohci->clk = devm_clk_get(&pdev->dev, "usbhost");
119 121
120 if (IS_ERR(exynos_ohci->clk)) { 122 if (IS_ERR(exynos_ohci->clk)) {
121 dev_err(&pdev->dev, "Failed to get usbhost clock\n"); 123 dev_err(&pdev->dev, "Failed to get usbhost clock\n");
@@ -123,9 +125,9 @@ static int __devinit exynos_ohci_probe(struct platform_device *pdev)
123 goto fail_clk; 125 goto fail_clk;
124 } 126 }
125 127
126 err = clk_enable(exynos_ohci->clk); 128 err = clk_prepare_enable(exynos_ohci->clk);
127 if (err) 129 if (err)
128 goto fail_clken; 130 goto fail_clk;
129 131
130 res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 132 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
131 if (!res) { 133 if (!res) {
@@ -167,9 +169,7 @@ static int __devinit exynos_ohci_probe(struct platform_device *pdev)
167 return 0; 169 return 0;
168 170
169fail_io: 171fail_io:
170 clk_disable(exynos_ohci->clk); 172 clk_disable_unprepare(exynos_ohci->clk);
171fail_clken:
172 clk_put(exynos_ohci->clk);
173fail_clk: 173fail_clk:
174 usb_put_hcd(hcd); 174 usb_put_hcd(hcd);
175 return err; 175 return err;
@@ -186,8 +186,7 @@ static int __devexit exynos_ohci_remove(struct platform_device *pdev)
186 if (pdata && pdata->phy_exit) 186 if (pdata && pdata->phy_exit)
187 pdata->phy_exit(pdev, S5P_USB_PHY_HOST); 187 pdata->phy_exit(pdev, S5P_USB_PHY_HOST);
188 188
189 clk_disable(exynos_ohci->clk); 189 clk_disable_unprepare(exynos_ohci->clk);
190 clk_put(exynos_ohci->clk);
191 190
192 usb_put_hcd(hcd); 191 usb_put_hcd(hcd);
193 192
@@ -232,7 +231,7 @@ static int exynos_ohci_suspend(struct device *dev)
232 if (pdata && pdata->phy_exit) 231 if (pdata && pdata->phy_exit)
233 pdata->phy_exit(pdev, S5P_USB_PHY_HOST); 232 pdata->phy_exit(pdev, S5P_USB_PHY_HOST);
234 233
235 clk_disable(exynos_ohci->clk); 234 clk_disable_unprepare(exynos_ohci->clk);
236 235
237fail: 236fail:
238 spin_unlock_irqrestore(&ohci->lock, flags); 237 spin_unlock_irqrestore(&ohci->lock, flags);
@@ -247,15 +246,12 @@ static int exynos_ohci_resume(struct device *dev)
247 struct platform_device *pdev = to_platform_device(dev); 246 struct platform_device *pdev = to_platform_device(dev);
248 struct exynos4_ohci_platdata *pdata = pdev->dev.platform_data; 247 struct exynos4_ohci_platdata *pdata = pdev->dev.platform_data;
249 248
250 clk_enable(exynos_ohci->clk); 249 clk_prepare_enable(exynos_ohci->clk);
251 250
252 if (pdata && pdata->phy_init) 251 if (pdata && pdata->phy_init)
253 pdata->phy_init(pdev, S5P_USB_PHY_HOST); 252 pdata->phy_init(pdev, S5P_USB_PHY_HOST);
254 253
255 /* Mark hardware accessible again as we are out of D3 state by now */ 254 ohci_resume(hcd, false);
256 set_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags);
257
258 ohci_finish_controller_resume(hcd);
259 255
260 return 0; 256 return 0;
261} 257}
diff --git a/drivers/usb/host/ohci-hcd.c b/drivers/usb/host/ohci-hcd.c
index 4a1d64d92338..180a2b01db56 100644
--- a/drivers/usb/host/ohci-hcd.c
+++ b/drivers/usb/host/ohci-hcd.c
@@ -231,13 +231,41 @@ static int ohci_urb_enqueue (
231 frame &= ~(ed->interval - 1); 231 frame &= ~(ed->interval - 1);
232 frame |= ed->branch; 232 frame |= ed->branch;
233 urb->start_frame = frame; 233 urb->start_frame = frame;
234 }
235 } else if (ed->type == PIPE_ISOCHRONOUS) {
236 u16 next = ohci_frame_no(ohci) + 2;
237 u16 frame = ed->last_iso + ed->interval;
238
239 /* Behind the scheduling threshold? */
240 if (unlikely(tick_before(frame, next))) {
234 241
235 /* yes, only URB_ISO_ASAP is supported, and 242 /* USB_ISO_ASAP: Round up to the first available slot */
236 * urb->start_frame is never used as input. 243 if (urb->transfer_flags & URB_ISO_ASAP)
244 frame += (next - frame + ed->interval - 1) &
245 -ed->interval;
246
247 /*
248 * Not ASAP: Use the next slot in the stream. If
249 * the entire URB falls before the threshold, fail.
237 */ 250 */
251 else if (tick_before(frame + ed->interval *
252 (urb->number_of_packets - 1), next)) {
253 retval = -EXDEV;
254 usb_hcd_unlink_urb_from_ep(hcd, urb);
255 goto fail;
256 }
257
258 /*
259 * Some OHCI hardware doesn't handle late TDs
260 * correctly. After retiring them it proceeds to
261 * the next ED instead of the next TD. Therefore
262 * we have to omit the late TDs entirely.
263 */
264 urb_priv->td_cnt = DIV_ROUND_UP(next - frame,
265 ed->interval);
238 } 266 }
239 } else if (ed->type == PIPE_ISOCHRONOUS) 267 urb->start_frame = frame;
240 urb->start_frame = ed->last_iso + ed->interval; 268 }
241 269
242 /* fill the TDs and link them to the ed; and 270 /* fill the TDs and link them to the ed; and
243 * enable that part of the schedule, if needed 271 * enable that part of the schedule, if needed
@@ -983,6 +1011,79 @@ static int ohci_restart (struct ohci_hcd *ohci)
983 1011
984#endif 1012#endif
985 1013
1014#ifdef CONFIG_PM
1015
1016static int __maybe_unused ohci_suspend(struct usb_hcd *hcd, bool do_wakeup)
1017{
1018 struct ohci_hcd *ohci = hcd_to_ohci (hcd);
1019 unsigned long flags;
1020
1021 /* Disable irq emission and mark HW unaccessible. Use
1022 * the spinlock to properly synchronize with possible pending
1023 * RH suspend or resume activity.
1024 */
1025 spin_lock_irqsave (&ohci->lock, flags);
1026 ohci_writel(ohci, OHCI_INTR_MIE, &ohci->regs->intrdisable);
1027 (void)ohci_readl(ohci, &ohci->regs->intrdisable);
1028
1029 clear_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags);
1030 spin_unlock_irqrestore (&ohci->lock, flags);
1031
1032 return 0;
1033}
1034
1035
1036static int __maybe_unused ohci_resume(struct usb_hcd *hcd, bool hibernated)
1037{
1038 struct ohci_hcd *ohci = hcd_to_ohci(hcd);
1039 int port;
1040 bool need_reinit = false;
1041
1042 set_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags);
1043
1044 /* Make sure resume from hibernation re-enumerates everything */
1045 if (hibernated)
1046 ohci_usb_reset(ohci);
1047
1048 /* See if the controller is already running or has been reset */
1049 ohci->hc_control = ohci_readl(ohci, &ohci->regs->control);
1050 if (ohci->hc_control & (OHCI_CTRL_IR | OHCI_SCHED_ENABLES)) {
1051 need_reinit = true;
1052 } else {
1053 switch (ohci->hc_control & OHCI_CTRL_HCFS) {
1054 case OHCI_USB_OPER:
1055 case OHCI_USB_RESET:
1056 need_reinit = true;
1057 }
1058 }
1059
1060 /* If needed, reinitialize and suspend the root hub */
1061 if (need_reinit) {
1062 spin_lock_irq(&ohci->lock);
1063 ohci_rh_resume(ohci);
1064 ohci_rh_suspend(ohci, 0);
1065 spin_unlock_irq(&ohci->lock);
1066 }
1067
1068 /* Normally just turn on port power and enable interrupts */
1069 else {
1070 ohci_dbg(ohci, "powerup ports\n");
1071 for (port = 0; port < ohci->num_ports; port++)
1072 ohci_writel(ohci, RH_PS_PPS,
1073 &ohci->regs->roothub.portstatus[port]);
1074
1075 ohci_writel(ohci, OHCI_INTR_MIE, &ohci->regs->intrenable);
1076 ohci_readl(ohci, &ohci->regs->intrenable);
1077 msleep(20);
1078 }
1079
1080 usb_hcd_resume_root_hub(hcd);
1081
1082 return 0;
1083}
1084
1085#endif
1086
986/*-------------------------------------------------------------------------*/ 1087/*-------------------------------------------------------------------------*/
987 1088
988MODULE_AUTHOR (DRIVER_AUTHOR); 1089MODULE_AUTHOR (DRIVER_AUTHOR);
@@ -1029,21 +1130,6 @@ MODULE_LICENSE ("GPL");
1029#define PLATFORM_DRIVER ohci_hcd_ep93xx_driver 1130#define PLATFORM_DRIVER ohci_hcd_ep93xx_driver
1030#endif 1131#endif
1031 1132
1032#ifdef CONFIG_MIPS_ALCHEMY
1033#include "ohci-au1xxx.c"
1034#define PLATFORM_DRIVER ohci_hcd_au1xxx_driver
1035#endif
1036
1037#ifdef CONFIG_PNX8550
1038#include "ohci-pnx8550.c"
1039#define PLATFORM_DRIVER ohci_hcd_pnx8550_driver
1040#endif
1041
1042#ifdef CONFIG_USB_OHCI_HCD_PPC_SOC
1043#include "ohci-ppc-soc.c"
1044#define PLATFORM_DRIVER ohci_hcd_ppc_soc_driver
1045#endif
1046
1047#ifdef CONFIG_ARCH_AT91 1133#ifdef CONFIG_ARCH_AT91
1048#include "ohci-at91.c" 1134#include "ohci-at91.c"
1049#define PLATFORM_DRIVER ohci_hcd_at91_driver 1135#define PLATFORM_DRIVER ohci_hcd_at91_driver
@@ -1059,11 +1145,6 @@ MODULE_LICENSE ("GPL");
1059#define PLATFORM_DRIVER ohci_hcd_da8xx_driver 1145#define PLATFORM_DRIVER ohci_hcd_da8xx_driver
1060#endif 1146#endif
1061 1147
1062#ifdef CONFIG_USB_OHCI_SH
1063#include "ohci-sh.c"
1064#define PLATFORM_DRIVER ohci_hcd_sh_driver
1065#endif
1066
1067 1148
1068#ifdef CONFIG_USB_OHCI_HCD_PPC_OF 1149#ifdef CONFIG_USB_OHCI_HCD_PPC_OF
1069#include "ohci-ppc-of.c" 1150#include "ohci-ppc-of.c"
@@ -1105,16 +1186,6 @@ MODULE_LICENSE ("GPL");
1105#define PLATFORM_DRIVER ohci_hcd_tilegx_driver 1186#define PLATFORM_DRIVER ohci_hcd_tilegx_driver
1106#endif 1187#endif
1107 1188
1108#ifdef CONFIG_USB_CNS3XXX_OHCI
1109#include "ohci-cns3xxx.c"
1110#define PLATFORM_DRIVER ohci_hcd_cns3xxx_driver
1111#endif
1112
1113#ifdef CONFIG_CPU_XLR
1114#include "ohci-xls.c"
1115#define PLATFORM_DRIVER ohci_xls_driver
1116#endif
1117
1118#ifdef CONFIG_USB_OHCI_HCD_PLATFORM 1189#ifdef CONFIG_USB_OHCI_HCD_PLATFORM
1119#include "ohci-platform.c" 1190#include "ohci-platform.c"
1120#define PLATFORM_DRIVER ohci_platform_driver 1191#define PLATFORM_DRIVER ohci_platform_driver
diff --git a/drivers/usb/host/ohci-hub.c b/drivers/usb/host/ohci-hub.c
index 2f3619eefefa..db09dae7b557 100644
--- a/drivers/usb/host/ohci-hub.c
+++ b/drivers/usb/host/ohci-hub.c
@@ -316,48 +316,6 @@ static int ohci_bus_resume (struct usb_hcd *hcd)
316 return rc; 316 return rc;
317} 317}
318 318
319/* Carry out the final steps of resuming the controller device */
320static void __maybe_unused ohci_finish_controller_resume(struct usb_hcd *hcd)
321{
322 struct ohci_hcd *ohci = hcd_to_ohci(hcd);
323 int port;
324 bool need_reinit = false;
325
326 /* See if the controller is already running or has been reset */
327 ohci->hc_control = ohci_readl(ohci, &ohci->regs->control);
328 if (ohci->hc_control & (OHCI_CTRL_IR | OHCI_SCHED_ENABLES)) {
329 need_reinit = true;
330 } else {
331 switch (ohci->hc_control & OHCI_CTRL_HCFS) {
332 case OHCI_USB_OPER:
333 case OHCI_USB_RESET:
334 need_reinit = true;
335 }
336 }
337
338 /* If needed, reinitialize and suspend the root hub */
339 if (need_reinit) {
340 spin_lock_irq(&ohci->lock);
341 ohci_rh_resume(ohci);
342 ohci_rh_suspend(ohci, 0);
343 spin_unlock_irq(&ohci->lock);
344 }
345
346 /* Normally just turn on port power and enable interrupts */
347 else {
348 ohci_dbg(ohci, "powerup ports\n");
349 for (port = 0; port < ohci->num_ports; port++)
350 ohci_writel(ohci, RH_PS_PPS,
351 &ohci->regs->roothub.portstatus[port]);
352
353 ohci_writel(ohci, OHCI_INTR_MIE, &ohci->regs->intrenable);
354 ohci_readl(ohci, &ohci->regs->intrenable);
355 msleep(20);
356 }
357
358 usb_hcd_resume_root_hub(hcd);
359}
360
361/* Carry out polling-, autostop-, and autoresume-related state changes */ 319/* Carry out polling-, autostop-, and autoresume-related state changes */
362static int ohci_root_hub_state_changes(struct ohci_hcd *ohci, int changed, 320static int ohci_root_hub_state_changes(struct ohci_hcd *ohci, int changed,
363 int any_connected, int rhsc_status) 321 int any_connected, int rhsc_status)
diff --git a/drivers/usb/host/ohci-omap.c b/drivers/usb/host/ohci-omap.c
index 4531d03503c3..733c77c36355 100644
--- a/drivers/usb/host/ohci-omap.c
+++ b/drivers/usb/host/ohci-omap.c
@@ -530,7 +530,7 @@ static int ohci_omap_resume(struct platform_device *dev)
530 ohci->next_statechange = jiffies; 530 ohci->next_statechange = jiffies;
531 531
532 omap_ohci_clock_power(1); 532 omap_ohci_clock_power(1);
533 ohci_finish_controller_resume(hcd); 533 ohci_resume(hcd, false);
534 return 0; 534 return 0;
535} 535}
536 536
diff --git a/drivers/usb/host/ohci-pci.c b/drivers/usb/host/ohci-pci.c
index 1843bb68ac7c..6afa7dc4e4c3 100644
--- a/drivers/usb/host/ohci-pci.c
+++ b/drivers/usb/host/ohci-pci.c
@@ -296,49 +296,6 @@ static int __devinit ohci_pci_start (struct usb_hcd *hcd)
296 return ret; 296 return ret;
297} 297}
298 298
299#ifdef CONFIG_PM
300
301static int ohci_pci_suspend(struct usb_hcd *hcd, bool do_wakeup)
302{
303 struct ohci_hcd *ohci = hcd_to_ohci (hcd);
304 unsigned long flags;
305 int rc = 0;
306
307 /* Root hub was already suspended. Disable irq emission and
308 * mark HW unaccessible, bail out if RH has been resumed. Use
309 * the spinlock to properly synchronize with possible pending
310 * RH suspend or resume activity.
311 */
312 spin_lock_irqsave (&ohci->lock, flags);
313 if (ohci->rh_state != OHCI_RH_SUSPENDED) {
314 rc = -EINVAL;
315 goto bail;
316 }
317 ohci_writel(ohci, OHCI_INTR_MIE, &ohci->regs->intrdisable);
318 (void)ohci_readl(ohci, &ohci->regs->intrdisable);
319
320 clear_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags);
321 bail:
322 spin_unlock_irqrestore (&ohci->lock, flags);
323
324 return rc;
325}
326
327
328static int ohci_pci_resume(struct usb_hcd *hcd, bool hibernated)
329{
330 set_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags);
331
332 /* Make sure resume from hibernation re-enumerates everything */
333 if (hibernated)
334 ohci_usb_reset(hcd_to_ohci(hcd));
335
336 ohci_finish_controller_resume(hcd);
337 return 0;
338}
339
340#endif /* CONFIG_PM */
341
342 299
343/*-------------------------------------------------------------------------*/ 300/*-------------------------------------------------------------------------*/
344 301
@@ -362,8 +319,8 @@ static const struct hc_driver ohci_pci_hc_driver = {
362 .shutdown = ohci_shutdown, 319 .shutdown = ohci_shutdown,
363 320
364#ifdef CONFIG_PM 321#ifdef CONFIG_PM
365 .pci_suspend = ohci_pci_suspend, 322 .pci_suspend = ohci_suspend,
366 .pci_resume = ohci_pci_resume, 323 .pci_resume = ohci_resume,
367#endif 324#endif
368 325
369 /* 326 /*
diff --git a/drivers/usb/host/ohci-platform.c b/drivers/usb/host/ohci-platform.c
index e24ec9f79164..bda4e0bb8ab3 100644
--- a/drivers/usb/host/ohci-platform.c
+++ b/drivers/usb/host/ohci-platform.c
@@ -31,6 +31,10 @@ static int ohci_platform_reset(struct usb_hcd *hcd)
31 ohci->flags |= OHCI_QUIRK_FRAME_NO; 31 ohci->flags |= OHCI_QUIRK_FRAME_NO;
32 32
33 ohci_hcd_init(ohci); 33 ohci_hcd_init(ohci);
34
35 if (pdata->num_ports)
36 ohci->num_ports = pdata->num_ports;
37
34 err = ohci_init(ohci); 38 err = ohci_init(ohci);
35 39
36 return err; 40 return err;
@@ -97,13 +101,13 @@ static int __devinit ohci_platform_probe(struct platform_device *dev)
97 101
98 irq = platform_get_irq(dev, 0); 102 irq = platform_get_irq(dev, 0);
99 if (irq < 0) { 103 if (irq < 0) {
100 pr_err("no irq provided"); 104 dev_err(&dev->dev, "no irq provided");
101 return irq; 105 return irq;
102 } 106 }
103 107
104 res_mem = platform_get_resource(dev, IORESOURCE_MEM, 0); 108 res_mem = platform_get_resource(dev, IORESOURCE_MEM, 0);
105 if (!res_mem) { 109 if (!res_mem) {
106 pr_err("no memory recourse provided"); 110 dev_err(&dev->dev, "no memory resource provided");
107 return -ENXIO; 111 return -ENXIO;
108 } 112 }
109 113
@@ -123,29 +127,19 @@ static int __devinit ohci_platform_probe(struct platform_device *dev)
123 hcd->rsrc_start = res_mem->start; 127 hcd->rsrc_start = res_mem->start;
124 hcd->rsrc_len = resource_size(res_mem); 128 hcd->rsrc_len = resource_size(res_mem);
125 129
126 if (!request_mem_region(hcd->rsrc_start, hcd->rsrc_len, hcd_name)) { 130 hcd->regs = devm_request_and_ioremap(&dev->dev, res_mem);
127 pr_err("controller already in use");
128 err = -EBUSY;
129 goto err_put_hcd;
130 }
131
132 hcd->regs = ioremap_nocache(hcd->rsrc_start, hcd->rsrc_len);
133 if (!hcd->regs) { 131 if (!hcd->regs) {
134 err = -ENOMEM; 132 err = -ENOMEM;
135 goto err_release_region; 133 goto err_put_hcd;
136 } 134 }
137 err = usb_add_hcd(hcd, irq, IRQF_SHARED); 135 err = usb_add_hcd(hcd, irq, IRQF_SHARED);
138 if (err) 136 if (err)
139 goto err_iounmap; 137 goto err_put_hcd;
140 138
141 platform_set_drvdata(dev, hcd); 139 platform_set_drvdata(dev, hcd);
142 140
143 return err; 141 return err;
144 142
145err_iounmap:
146 iounmap(hcd->regs);
147err_release_region:
148 release_mem_region(hcd->rsrc_start, hcd->rsrc_len);
149err_put_hcd: 143err_put_hcd:
150 usb_put_hcd(hcd); 144 usb_put_hcd(hcd);
151err_power: 145err_power:
@@ -161,8 +155,6 @@ static int __devexit ohci_platform_remove(struct platform_device *dev)
161 struct usb_ohci_pdata *pdata = dev->dev.platform_data; 155 struct usb_ohci_pdata *pdata = dev->dev.platform_data;
162 156
163 usb_remove_hcd(hcd); 157 usb_remove_hcd(hcd);
164 iounmap(hcd->regs);
165 release_mem_region(hcd->rsrc_start, hcd->rsrc_len);
166 usb_put_hcd(hcd); 158 usb_put_hcd(hcd);
167 platform_set_drvdata(dev, NULL); 159 platform_set_drvdata(dev, NULL);
168 160
@@ -199,7 +191,7 @@ static int ohci_platform_resume(struct device *dev)
199 return err; 191 return err;
200 } 192 }
201 193
202 ohci_finish_controller_resume(hcd); 194 ohci_resume(hcd, false);
203 return 0; 195 return 0;
204} 196}
205 197
diff --git a/drivers/usb/host/ohci-pnx8550.c b/drivers/usb/host/ohci-pnx8550.c
deleted file mode 100644
index 148d27d6a67c..000000000000
--- a/drivers/usb/host/ohci-pnx8550.c
+++ /dev/null
@@ -1,243 +0,0 @@
1/*
2 * OHCI HCD (Host Controller Driver) for USB.
3 *
4 * (C) Copyright 1999 Roman Weissgaerber <weissg@vienna.at>
5 * (C) Copyright 2000-2002 David Brownell <dbrownell@users.sourceforge.net>
6 * (C) Copyright 2002 Hewlett-Packard Company
7 * (C) Copyright 2005 Embedded Alley Solutions, Inc.
8 *
9 * Bus Glue for PNX8550
10 *
11 * Written by Christopher Hoover <ch@hpl.hp.com>
12 * Based on fragments of previous driver by Russell King et al.
13 *
14 * Modified for LH7A404 from ohci-sa1111.c
15 * by Durgesh Pattamatta <pattamattad@sharpsec.com>
16 *
17 * Modified for PNX8550 from ohci-sa1111.c and sa-omap.c
18 * by Vitaly Wool <vitalywool@gmail.com>
19 *
20 * This file is licenced under the GPL.
21 */
22
23#include <linux/device.h>
24#include <linux/platform_device.h>
25#include <asm/mach-pnx8550/usb.h>
26#include <asm/mach-pnx8550/int.h>
27#include <asm/mach-pnx8550/pci.h>
28
29#ifndef CONFIG_PNX8550
30#error "This file is PNX8550 bus glue. CONFIG_PNX8550 must be defined."
31#endif
32
33extern int usb_disabled(void);
34
35/*-------------------------------------------------------------------------*/
36
37static void pnx8550_start_hc(struct platform_device *dev)
38{
39 /*
40 * Set register CLK48CTL to enable and 48MHz
41 */
42 outl(0x00000003, PCI_BASE | 0x0004770c);
43
44 /*
45 * Set register CLK12CTL to enable and 48MHz
46 */
47 outl(0x00000003, PCI_BASE | 0x00047710);
48
49 udelay(100);
50}
51
52static void pnx8550_stop_hc(struct platform_device *dev)
53{
54 udelay(10);
55}
56
57
58/*-------------------------------------------------------------------------*/
59
60/* configure so an HC device and id are always provided */
61/* always called with process context; sleeping is OK */
62
63
64/**
65 * usb_hcd_pnx8550_probe - initialize pnx8550-based HCDs
66 * Context: !in_interrupt()
67 *
68 * Allocates basic resources for this USB host controller, and
69 * then invokes the start() method for the HCD associated with it
70 * through the hotplug entry's driver_data.
71 *
72 */
73int usb_hcd_pnx8550_probe (const struct hc_driver *driver,
74 struct platform_device *dev)
75{
76 int retval;
77 struct usb_hcd *hcd;
78
79 if (dev->resource[0].flags != IORESOURCE_MEM ||
80 dev->resource[1].flags != IORESOURCE_IRQ) {
81 dev_err (&dev->dev,"invalid resource type\n");
82 return -ENOMEM;
83 }
84
85 hcd = usb_create_hcd (driver, &dev->dev, "pnx8550");
86 if (!hcd)
87 return -ENOMEM;
88 hcd->rsrc_start = dev->resource[0].start;
89 hcd->rsrc_len = dev->resource[0].end - dev->resource[0].start + 1;
90
91 if (!request_mem_region(hcd->rsrc_start, hcd->rsrc_len, hcd_name)) {
92 dev_err(&dev->dev, "request_mem_region [0x%08llx, 0x%08llx] "
93 "failed\n", hcd->rsrc_start, hcd->rsrc_len);
94 retval = -EBUSY;
95 goto err1;
96 }
97
98 hcd->regs = ioremap(hcd->rsrc_start, hcd->rsrc_len);
99 if (!hcd->regs) {
100 dev_err(&dev->dev, "ioremap [[0x%08llx, 0x%08llx] failed\n",
101 hcd->rsrc_start, hcd->rsrc_len);
102 retval = -ENOMEM;
103 goto err2;
104 }
105
106 pnx8550_start_hc(dev);
107
108 ohci_hcd_init(hcd_to_ohci(hcd));
109
110 retval = usb_add_hcd(hcd, dev->resource[1].start, 0);
111 if (retval == 0)
112 return retval;
113
114 pnx8550_stop_hc(dev);
115 iounmap(hcd->regs);
116 err2:
117 release_mem_region(hcd->rsrc_start, hcd->rsrc_len);
118 err1:
119 usb_put_hcd(hcd);
120 return retval;
121}
122
123
124/* may be called without controller electrically present */
125/* may be called with controller, bus, and devices active */
126
127/**
128 * usb_hcd_pnx8550_remove - shutdown processing for pnx8550-based HCDs
129 * @dev: USB Host Controller being removed
130 * Context: !in_interrupt()
131 *
132 * Reverses the effect of usb_hcd_pnx8550_probe(), first invoking
133 * the HCD's stop() method. It is always called from a thread
134 * context, normally "rmmod", "apmd", or something similar.
135 *
136 */
137void usb_hcd_pnx8550_remove (struct usb_hcd *hcd, struct platform_device *dev)
138{
139 usb_remove_hcd(hcd);
140 pnx8550_stop_hc(dev);
141 iounmap(hcd->regs);
142 release_mem_region(hcd->rsrc_start, hcd->rsrc_len);
143 usb_put_hcd(hcd);
144}
145
146/*-------------------------------------------------------------------------*/
147
148static int __devinit
149ohci_pnx8550_start (struct usb_hcd *hcd)
150{
151 struct ohci_hcd *ohci = hcd_to_ohci (hcd);
152 int ret;
153
154 ohci_dbg (ohci, "ohci_pnx8550_start, ohci:%p", ohci);
155
156 if ((ret = ohci_init(ohci)) < 0)
157 return ret;
158
159 if ((ret = ohci_run (ohci)) < 0) {
160 dev_err(hcd->self.controller, "can't start %s",
161 hcd->self.bus_name);
162 ohci_stop (hcd);
163 return ret;
164 }
165
166 return 0;
167}
168
169/*-------------------------------------------------------------------------*/
170
171static const struct hc_driver ohci_pnx8550_hc_driver = {
172 .description = hcd_name,
173 .product_desc = "PNX8550 OHCI",
174 .hcd_priv_size = sizeof(struct ohci_hcd),
175
176 /*
177 * generic hardware linkage
178 */
179 .irq = ohci_irq,
180 .flags = HCD_USB11 | HCD_MEMORY,
181
182 /*
183 * basic lifecycle operations
184 */
185 .start = ohci_pnx8550_start,
186 .stop = ohci_stop,
187
188 /*
189 * managing i/o requests and associated device resources
190 */
191 .urb_enqueue = ohci_urb_enqueue,
192 .urb_dequeue = ohci_urb_dequeue,
193 .endpoint_disable = ohci_endpoint_disable,
194
195 /*
196 * scheduling support
197 */
198 .get_frame_number = ohci_get_frame,
199
200 /*
201 * root hub support
202 */
203 .hub_status_data = ohci_hub_status_data,
204 .hub_control = ohci_hub_control,
205#ifdef CONFIG_PM
206 .bus_suspend = ohci_bus_suspend,
207 .bus_resume = ohci_bus_resume,
208#endif
209 .start_port_reset = ohci_start_port_reset,
210};
211
212/*-------------------------------------------------------------------------*/
213
214static int ohci_hcd_pnx8550_drv_probe(struct platform_device *pdev)
215{
216 int ret;
217
218 if (usb_disabled())
219 return -ENODEV;
220
221 ret = usb_hcd_pnx8550_probe(&ohci_pnx8550_hc_driver, pdev);
222 return ret;
223}
224
225static int ohci_hcd_pnx8550_drv_remove(struct platform_device *pdev)
226{
227 struct usb_hcd *hcd = platform_get_drvdata(pdev);
228
229 usb_hcd_pnx8550_remove(hcd, pdev);
230 return 0;
231}
232
233MODULE_ALIAS("platform:pnx8550-ohci");
234
235static struct platform_driver ohci_hcd_pnx8550_driver = {
236 .driver = {
237 .name = "pnx8550-ohci",
238 .owner = THIS_MODULE,
239 },
240 .probe = ohci_hcd_pnx8550_drv_probe,
241 .remove = ohci_hcd_pnx8550_drv_remove,
242};
243
diff --git a/drivers/usb/host/ohci-ppc-soc.c b/drivers/usb/host/ohci-ppc-soc.c
deleted file mode 100644
index 185c39ed81b7..000000000000
--- a/drivers/usb/host/ohci-ppc-soc.c
+++ /dev/null
@@ -1,216 +0,0 @@
1/*
2 * OHCI HCD (Host Controller Driver) for USB.
3 *
4 * (C) Copyright 1999 Roman Weissgaerber <weissg@vienna.at>
5 * (C) Copyright 2000-2002 David Brownell <dbrownell@users.sourceforge.net>
6 * (C) Copyright 2002 Hewlett-Packard Company
7 * (C) Copyright 2003-2005 MontaVista Software Inc.
8 *
9 * Bus Glue for PPC On-Chip OHCI driver
10 * Tested on Freescale MPC5200 and IBM STB04xxx
11 *
12 * Modified by Dale Farnsworth <dale@farnsworth.org> from ohci-sa1111.c
13 *
14 * This file is licenced under the GPL.
15 */
16
17#include <linux/platform_device.h>
18#include <linux/signal.h>
19
20/* configure so an HC device and id are always provided */
21/* always called with process context; sleeping is OK */
22
23/**
24 * usb_hcd_ppc_soc_probe - initialize On-Chip HCDs
25 * Context: !in_interrupt()
26 *
27 * Allocates basic resources for this USB host controller.
28 *
29 * Store this function in the HCD's struct pci_driver as probe().
30 */
31static int usb_hcd_ppc_soc_probe(const struct hc_driver *driver,
32 struct platform_device *pdev)
33{
34 int retval;
35 struct usb_hcd *hcd;
36 struct ohci_hcd *ohci;
37 struct resource *res;
38 int irq;
39
40 pr_debug("initializing PPC-SOC USB Controller\n");
41
42 res = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
43 if (!res) {
44 pr_debug("%s: no irq\n", __FILE__);
45 return -ENODEV;
46 }
47 irq = res->start;
48
49 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
50 if (!res) {
51 pr_debug("%s: no reg addr\n", __FILE__);
52 return -ENODEV;
53 }
54
55 hcd = usb_create_hcd(driver, &pdev->dev, "PPC-SOC USB");
56 if (!hcd)
57 return -ENOMEM;
58 hcd->rsrc_start = res->start;
59 hcd->rsrc_len = resource_size(res);
60
61 if (!request_mem_region(hcd->rsrc_start, hcd->rsrc_len, hcd_name)) {
62 pr_debug("%s: request_mem_region failed\n", __FILE__);
63 retval = -EBUSY;
64 goto err1;
65 }
66
67 hcd->regs = ioremap(hcd->rsrc_start, hcd->rsrc_len);
68 if (!hcd->regs) {
69 pr_debug("%s: ioremap failed\n", __FILE__);
70 retval = -ENOMEM;
71 goto err2;
72 }
73
74 ohci = hcd_to_ohci(hcd);
75 ohci->flags |= OHCI_QUIRK_BE_MMIO | OHCI_QUIRK_BE_DESC;
76
77#ifdef CONFIG_PPC_MPC52xx
78 /* MPC52xx doesn't need frame_no shift */
79 ohci->flags |= OHCI_QUIRK_FRAME_NO;
80#endif
81 ohci_hcd_init(ohci);
82
83 retval = usb_add_hcd(hcd, irq, 0);
84 if (retval == 0)
85 return retval;
86
87 pr_debug("Removing PPC-SOC USB Controller\n");
88
89 iounmap(hcd->regs);
90 err2:
91 release_mem_region(hcd->rsrc_start, hcd->rsrc_len);
92 err1:
93 usb_put_hcd(hcd);
94 return retval;
95}
96
97
98/* may be called without controller electrically present */
99/* may be called with controller, bus, and devices active */
100
101/**
102 * usb_hcd_ppc_soc_remove - shutdown processing for On-Chip HCDs
103 * @pdev: USB Host Controller being removed
104 * Context: !in_interrupt()
105 *
106 * Reverses the effect of usb_hcd_ppc_soc_probe().
107 * It is always called from a thread
108 * context, normally "rmmod", "apmd", or something similar.
109 *
110 */
111static void usb_hcd_ppc_soc_remove(struct usb_hcd *hcd,
112 struct platform_device *pdev)
113{
114 usb_remove_hcd(hcd);
115
116 pr_debug("stopping PPC-SOC USB Controller\n");
117
118 iounmap(hcd->regs);
119 release_mem_region(hcd->rsrc_start, hcd->rsrc_len);
120 usb_put_hcd(hcd);
121}
122
123static int __devinit
124ohci_ppc_soc_start(struct usb_hcd *hcd)
125{
126 struct ohci_hcd *ohci = hcd_to_ohci(hcd);
127 int ret;
128
129 if ((ret = ohci_init(ohci)) < 0)
130 return ret;
131
132 if ((ret = ohci_run(ohci)) < 0) {
133 dev_err(hcd->self.controller, "can't start %s\n",
134 hcd->self.bus_name);
135 ohci_stop(hcd);
136 return ret;
137 }
138
139 return 0;
140}
141
142static const struct hc_driver ohci_ppc_soc_hc_driver = {
143 .description = hcd_name,
144 .hcd_priv_size = sizeof(struct ohci_hcd),
145
146 /*
147 * generic hardware linkage
148 */
149 .irq = ohci_irq,
150 .flags = HCD_USB11 | HCD_MEMORY,
151
152 /*
153 * basic lifecycle operations
154 */
155 .start = ohci_ppc_soc_start,
156 .stop = ohci_stop,
157 .shutdown = ohci_shutdown,
158
159 /*
160 * managing i/o requests and associated device resources
161 */
162 .urb_enqueue = ohci_urb_enqueue,
163 .urb_dequeue = ohci_urb_dequeue,
164 .endpoint_disable = ohci_endpoint_disable,
165
166 /*
167 * scheduling support
168 */
169 .get_frame_number = ohci_get_frame,
170
171 /*
172 * root hub support
173 */
174 .hub_status_data = ohci_hub_status_data,
175 .hub_control = ohci_hub_control,
176#ifdef CONFIG_PM
177 .bus_suspend = ohci_bus_suspend,
178 .bus_resume = ohci_bus_resume,
179#endif
180 .start_port_reset = ohci_start_port_reset,
181};
182
183static int ohci_hcd_ppc_soc_drv_probe(struct platform_device *pdev)
184{
185 int ret;
186
187 if (usb_disabled())
188 return -ENODEV;
189
190 ret = usb_hcd_ppc_soc_probe(&ohci_ppc_soc_hc_driver, pdev);
191 return ret;
192}
193
194static int ohci_hcd_ppc_soc_drv_remove(struct platform_device *pdev)
195{
196 struct usb_hcd *hcd = platform_get_drvdata(pdev);
197
198 usb_hcd_ppc_soc_remove(hcd, pdev);
199 return 0;
200}
201
202static struct platform_driver ohci_hcd_ppc_soc_driver = {
203 .probe = ohci_hcd_ppc_soc_drv_probe,
204 .remove = ohci_hcd_ppc_soc_drv_remove,
205 .shutdown = usb_hcd_platform_shutdown,
206#ifdef CONFIG_PM
207 /*.suspend = ohci_hcd_ppc_soc_drv_suspend,*/
208 /*.resume = ohci_hcd_ppc_soc_drv_resume,*/
209#endif
210 .driver = {
211 .name = "ppc-soc-ohci",
212 .owner = THIS_MODULE,
213 },
214};
215
216MODULE_ALIAS("platform:ppc-soc-ohci");
diff --git a/drivers/usb/host/ohci-pxa27x.c b/drivers/usb/host/ohci-pxa27x.c
index 2bf11440b010..156d289d3bb5 100644
--- a/drivers/usb/host/ohci-pxa27x.c
+++ b/drivers/usb/host/ohci-pxa27x.c
@@ -591,7 +591,7 @@ static int ohci_hcd_pxa27x_drv_resume(struct device *dev)
591 /* Select Power Management Mode */ 591 /* Select Power Management Mode */
592 pxa27x_ohci_select_pmm(ohci, inf->port_mode); 592 pxa27x_ohci_select_pmm(ohci, inf->port_mode);
593 593
594 ohci_finish_controller_resume(hcd); 594 ohci_resume(hcd, false);
595 return 0; 595 return 0;
596} 596}
597 597
diff --git a/drivers/usb/host/ohci-q.c b/drivers/usb/host/ohci-q.c
index c5a1ea9145fa..177a213790d4 100644
--- a/drivers/usb/host/ohci-q.c
+++ b/drivers/usb/host/ohci-q.c
@@ -596,7 +596,6 @@ static void td_submit_urb (
596 urb_priv->ed->hwHeadP &= ~cpu_to_hc32 (ohci, ED_C); 596 urb_priv->ed->hwHeadP &= ~cpu_to_hc32 (ohci, ED_C);
597 } 597 }
598 598
599 urb_priv->td_cnt = 0;
600 list_add (&urb_priv->pending, &ohci->pending); 599 list_add (&urb_priv->pending, &ohci->pending);
601 600
602 if (data_len) 601 if (data_len)
@@ -672,7 +671,8 @@ static void td_submit_urb (
672 * we could often reduce the number of TDs here. 671 * we could often reduce the number of TDs here.
673 */ 672 */
674 case PIPE_ISOCHRONOUS: 673 case PIPE_ISOCHRONOUS:
675 for (cnt = 0; cnt < urb->number_of_packets; cnt++) { 674 for (cnt = urb_priv->td_cnt; cnt < urb->number_of_packets;
675 cnt++) {
676 int frame = urb->start_frame; 676 int frame = urb->start_frame;
677 677
678 // FIXME scheduling should handle frame counter 678 // FIXME scheduling should handle frame counter
diff --git a/drivers/usb/host/ohci-s3c2410.c b/drivers/usb/host/ohci-s3c2410.c
index 0d2309ca471e..e84190f25c6b 100644
--- a/drivers/usb/host/ohci-s3c2410.c
+++ b/drivers/usb/host/ohci-s3c2410.c
@@ -323,8 +323,6 @@ usb_hcd_s3c2410_remove(struct usb_hcd *hcd, struct platform_device *dev)
323{ 323{
324 usb_remove_hcd(hcd); 324 usb_remove_hcd(hcd);
325 s3c2410_stop_hc(dev); 325 s3c2410_stop_hc(dev);
326 iounmap(hcd->regs);
327 release_mem_region(hcd->rsrc_start, hcd->rsrc_len);
328 usb_put_hcd(hcd); 326 usb_put_hcd(hcd);
329} 327}
330 328
@@ -353,35 +351,29 @@ static int usb_hcd_s3c2410_probe(const struct hc_driver *driver,
353 hcd->rsrc_start = dev->resource[0].start; 351 hcd->rsrc_start = dev->resource[0].start;
354 hcd->rsrc_len = resource_size(&dev->resource[0]); 352 hcd->rsrc_len = resource_size(&dev->resource[0]);
355 353
356 if (!request_mem_region(hcd->rsrc_start, hcd->rsrc_len, hcd_name)) { 354 hcd->regs = devm_request_and_ioremap(&dev->dev, &dev->resource[0]);
357 dev_err(&dev->dev, "request_mem_region failed\n"); 355 if (!hcd->regs) {
358 retval = -EBUSY; 356 dev_err(&dev->dev, "devm_request_and_ioremap failed\n");
357 retval = -ENOMEM;
359 goto err_put; 358 goto err_put;
360 } 359 }
361 360
362 clk = clk_get(&dev->dev, "usb-host"); 361 clk = devm_clk_get(&dev->dev, "usb-host");
363 if (IS_ERR(clk)) { 362 if (IS_ERR(clk)) {
364 dev_err(&dev->dev, "cannot get usb-host clock\n"); 363 dev_err(&dev->dev, "cannot get usb-host clock\n");
365 retval = PTR_ERR(clk); 364 retval = PTR_ERR(clk);
366 goto err_mem; 365 goto err_put;
367 } 366 }
368 367
369 usb_clk = clk_get(&dev->dev, "usb-bus-host"); 368 usb_clk = devm_clk_get(&dev->dev, "usb-bus-host");
370 if (IS_ERR(usb_clk)) { 369 if (IS_ERR(usb_clk)) {
371 dev_err(&dev->dev, "cannot get usb-bus-host clock\n"); 370 dev_err(&dev->dev, "cannot get usb-bus-host clock\n");
372 retval = PTR_ERR(usb_clk); 371 retval = PTR_ERR(usb_clk);
373 goto err_clk; 372 goto err_put;
374 } 373 }
375 374
376 s3c2410_start_hc(dev, hcd); 375 s3c2410_start_hc(dev, hcd);
377 376
378 hcd->regs = ioremap(hcd->rsrc_start, hcd->rsrc_len);
379 if (!hcd->regs) {
380 dev_err(&dev->dev, "ioremap failed\n");
381 retval = -ENOMEM;
382 goto err_ioremap;
383 }
384
385 ohci_hcd_init(hcd_to_ohci(hcd)); 377 ohci_hcd_init(hcd_to_ohci(hcd));
386 378
387 retval = usb_add_hcd(hcd, dev->resource[1].start, 0); 379 retval = usb_add_hcd(hcd, dev->resource[1].start, 0);
@@ -392,14 +384,6 @@ static int usb_hcd_s3c2410_probe(const struct hc_driver *driver,
392 384
393 err_ioremap: 385 err_ioremap:
394 s3c2410_stop_hc(dev); 386 s3c2410_stop_hc(dev);
395 iounmap(hcd->regs);
396 clk_put(usb_clk);
397
398 err_clk:
399 clk_put(clk);
400
401 err_mem:
402 release_mem_region(hcd->rsrc_start, hcd->rsrc_len);
403 387
404 err_put: 388 err_put:
405 usb_put_hcd(hcd); 389 usb_put_hcd(hcd);
@@ -524,8 +508,7 @@ static int ohci_hcd_s3c2410_drv_resume(struct device *dev)
524 508
525 s3c2410_start_hc(pdev, hcd); 509 s3c2410_start_hc(pdev, hcd);
526 510
527 set_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags); 511 ohci_resume(hcd, false);
528 ohci_finish_controller_resume(hcd);
529 512
530 return 0; 513 return 0;
531} 514}
diff --git a/drivers/usb/host/ohci-sh.c b/drivers/usb/host/ohci-sh.c
deleted file mode 100644
index 76a20c278362..000000000000
--- a/drivers/usb/host/ohci-sh.c
+++ /dev/null
@@ -1,141 +0,0 @@
1/*
2 * OHCI HCD (Host Controller Driver) for USB.
3 *
4 * Copyright (C) 2008 Renesas Solutions Corp.
5 *
6 * Author : Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; version 2 of the License.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
20 *
21 */
22
23#include <linux/platform_device.h>
24
25static int ohci_sh_start(struct usb_hcd *hcd)
26{
27 struct ohci_hcd *ohci = hcd_to_ohci(hcd);
28
29 ohci_hcd_init(ohci);
30 ohci_init(ohci);
31 ohci_run(ohci);
32 return 0;
33}
34
35static const struct hc_driver ohci_sh_hc_driver = {
36 .description = hcd_name,
37 .product_desc = "SuperH OHCI",
38 .hcd_priv_size = sizeof(struct ohci_hcd),
39
40 /*
41 * generic hardware linkage
42 */
43 .irq = ohci_irq,
44 .flags = HCD_USB11 | HCD_MEMORY,
45
46 /*
47 * basic lifecycle operations
48 */
49 .start = ohci_sh_start,
50 .stop = ohci_stop,
51 .shutdown = ohci_shutdown,
52
53 /*
54 * managing i/o requests and associated device resources
55 */
56 .urb_enqueue = ohci_urb_enqueue,
57 .urb_dequeue = ohci_urb_dequeue,
58 .endpoint_disable = ohci_endpoint_disable,
59
60 /*
61 * scheduling support
62 */
63 .get_frame_number = ohci_get_frame,
64
65 /*
66 * root hub support
67 */
68 .hub_status_data = ohci_hub_status_data,
69 .hub_control = ohci_hub_control,
70#ifdef CONFIG_PM
71 .bus_suspend = ohci_bus_suspend,
72 .bus_resume = ohci_bus_resume,
73#endif
74 .start_port_reset = ohci_start_port_reset,
75};
76
77/*-------------------------------------------------------------------------*/
78
79static int ohci_hcd_sh_probe(struct platform_device *pdev)
80{
81 struct resource *res = NULL;
82 struct usb_hcd *hcd = NULL;
83 int irq = -1;
84 int ret;
85
86 if (usb_disabled())
87 return -ENODEV;
88
89 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
90 if (!res) {
91 dev_err(&pdev->dev, "platform_get_resource error.\n");
92 return -ENODEV;
93 }
94
95 irq = platform_get_irq(pdev, 0);
96 if (irq < 0) {
97 dev_err(&pdev->dev, "platform_get_irq error.\n");
98 return -ENODEV;
99 }
100
101 /* initialize hcd */
102 hcd = usb_create_hcd(&ohci_sh_hc_driver, &pdev->dev, (char *)hcd_name);
103 if (!hcd) {
104 dev_err(&pdev->dev, "Failed to create hcd\n");
105 return -ENOMEM;
106 }
107
108 hcd->regs = (void __iomem *)res->start;
109 hcd->rsrc_start = res->start;
110 hcd->rsrc_len = resource_size(res);
111 ret = usb_add_hcd(hcd, irq, IRQF_SHARED);
112 if (ret != 0) {
113 dev_err(&pdev->dev, "Failed to add hcd\n");
114 usb_put_hcd(hcd);
115 return ret;
116 }
117
118 return ret;
119}
120
121static int ohci_hcd_sh_remove(struct platform_device *pdev)
122{
123 struct usb_hcd *hcd = platform_get_drvdata(pdev);
124
125 usb_remove_hcd(hcd);
126 usb_put_hcd(hcd);
127
128 return 0;
129}
130
131static struct platform_driver ohci_hcd_sh_driver = {
132 .probe = ohci_hcd_sh_probe,
133 .remove = ohci_hcd_sh_remove,
134 .shutdown = usb_hcd_platform_shutdown,
135 .driver = {
136 .name = "sh_ohci",
137 .owner = THIS_MODULE,
138 },
139};
140
141MODULE_ALIAS("platform:sh_ohci");
diff --git a/drivers/usb/host/ohci-sm501.c b/drivers/usb/host/ohci-sm501.c
index 5596ac2ba1ca..3b5b908fd47b 100644
--- a/drivers/usb/host/ohci-sm501.c
+++ b/drivers/usb/host/ohci-sm501.c
@@ -238,7 +238,7 @@ static int ohci_sm501_resume(struct platform_device *pdev)
238 ohci->next_statechange = jiffies; 238 ohci->next_statechange = jiffies;
239 239
240 sm501_unit_power(dev->parent, SM501_GATE_USB_HOST, 1); 240 sm501_unit_power(dev->parent, SM501_GATE_USB_HOST, 1);
241 ohci_finish_controller_resume(hcd); 241 ohci_resume(hcd, false);
242 return 0; 242 return 0;
243} 243}
244#else 244#else
diff --git a/drivers/usb/host/ohci-spear.c b/drivers/usb/host/ohci-spear.c
index fc7305ee3c9c..c69725d9f0cd 100644
--- a/drivers/usb/host/ohci-spear.c
+++ b/drivers/usb/host/ohci-spear.c
@@ -101,13 +101,11 @@ static int spear_ohci_hcd_drv_probe(struct platform_device *pdev)
101 struct spear_ohci *ohci_p; 101 struct spear_ohci *ohci_p;
102 struct resource *res; 102 struct resource *res;
103 int retval, irq; 103 int retval, irq;
104 char clk_name[20] = "usbh_clk";
105 static int instance = -1;
106 104
107 irq = platform_get_irq(pdev, 0); 105 irq = platform_get_irq(pdev, 0);
108 if (irq < 0) { 106 if (irq < 0) {
109 retval = irq; 107 retval = irq;
110 goto fail_irq_get; 108 goto fail;
111 } 109 }
112 110
113 /* 111 /*
@@ -118,47 +116,39 @@ static int spear_ohci_hcd_drv_probe(struct platform_device *pdev)
118 if (!pdev->dev.dma_mask) 116 if (!pdev->dev.dma_mask)
119 pdev->dev.dma_mask = &spear_ohci_dma_mask; 117 pdev->dev.dma_mask = &spear_ohci_dma_mask;
120 118
121 /* 119 usbh_clk = devm_clk_get(&pdev->dev, NULL);
122 * Increment the device instance, when probing via device-tree
123 */
124 if (pdev->id < 0)
125 instance++;
126 else
127 instance = pdev->id;
128 sprintf(clk_name, "usbh.%01d_clk", instance);
129
130 usbh_clk = clk_get(NULL, clk_name);
131 if (IS_ERR(usbh_clk)) { 120 if (IS_ERR(usbh_clk)) {
132 dev_err(&pdev->dev, "Error getting interface clock\n"); 121 dev_err(&pdev->dev, "Error getting interface clock\n");
133 retval = PTR_ERR(usbh_clk); 122 retval = PTR_ERR(usbh_clk);
134 goto fail_get_usbh_clk; 123 goto fail;
135 } 124 }
136 125
137 hcd = usb_create_hcd(driver, &pdev->dev, dev_name(&pdev->dev)); 126 hcd = usb_create_hcd(driver, &pdev->dev, dev_name(&pdev->dev));
138 if (!hcd) { 127 if (!hcd) {
139 retval = -ENOMEM; 128 retval = -ENOMEM;
140 goto fail_create_hcd; 129 goto fail;
141 } 130 }
142 131
143 res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 132 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
144 if (!res) { 133 if (!res) {
145 retval = -ENODEV; 134 retval = -ENODEV;
146 goto fail_request_resource; 135 goto err_put_hcd;
147 } 136 }
148 137
149 hcd->rsrc_start = pdev->resource[0].start; 138 hcd->rsrc_start = pdev->resource[0].start;
150 hcd->rsrc_len = resource_size(res); 139 hcd->rsrc_len = resource_size(res);
151 if (!request_mem_region(hcd->rsrc_start, hcd->rsrc_len, hcd_name)) { 140 if (!devm_request_mem_region(&pdev->dev, hcd->rsrc_start, hcd->rsrc_len,
141 hcd_name)) {
152 dev_dbg(&pdev->dev, "request_mem_region failed\n"); 142 dev_dbg(&pdev->dev, "request_mem_region failed\n");
153 retval = -EBUSY; 143 retval = -EBUSY;
154 goto fail_request_resource; 144 goto err_put_hcd;
155 } 145 }
156 146
157 hcd->regs = ioremap(hcd->rsrc_start, hcd->rsrc_len); 147 hcd->regs = devm_ioremap(&pdev->dev, hcd->rsrc_start, hcd->rsrc_len);
158 if (!hcd->regs) { 148 if (!hcd->regs) {
159 dev_dbg(&pdev->dev, "ioremap failed\n"); 149 dev_dbg(&pdev->dev, "ioremap failed\n");
160 retval = -ENOMEM; 150 retval = -ENOMEM;
161 goto fail_ioremap; 151 goto err_put_hcd;
162 } 152 }
163 153
164 ohci_p = (struct spear_ohci *)hcd_to_ohci(hcd); 154 ohci_p = (struct spear_ohci *)hcd_to_ohci(hcd);
@@ -171,15 +161,9 @@ static int spear_ohci_hcd_drv_probe(struct platform_device *pdev)
171 return retval; 161 return retval;
172 162
173 spear_stop_ohci(ohci_p); 163 spear_stop_ohci(ohci_p);
174 iounmap(hcd->regs); 164err_put_hcd:
175fail_ioremap:
176 release_mem_region(hcd->rsrc_start, hcd->rsrc_len);
177fail_request_resource:
178 usb_put_hcd(hcd); 165 usb_put_hcd(hcd);
179fail_create_hcd: 166fail:
180 clk_put(usbh_clk);
181fail_get_usbh_clk:
182fail_irq_get:
183 dev_err(&pdev->dev, "init fail, %d\n", retval); 167 dev_err(&pdev->dev, "init fail, %d\n", retval);
184 168
185 return retval; 169 return retval;
@@ -194,12 +178,8 @@ static int spear_ohci_hcd_drv_remove(struct platform_device *pdev)
194 if (ohci_p->clk) 178 if (ohci_p->clk)
195 spear_stop_ohci(ohci_p); 179 spear_stop_ohci(ohci_p);
196 180
197 iounmap(hcd->regs);
198 release_mem_region(hcd->rsrc_start, hcd->rsrc_len);
199 usb_put_hcd(hcd); 181 usb_put_hcd(hcd);
200 182
201 if (ohci_p->clk)
202 clk_put(ohci_p->clk);
203 platform_set_drvdata(pdev, NULL); 183 platform_set_drvdata(pdev, NULL);
204 return 0; 184 return 0;
205} 185}
@@ -231,7 +211,7 @@ static int spear_ohci_hcd_drv_resume(struct platform_device *dev)
231 ohci->next_statechange = jiffies; 211 ohci->next_statechange = jiffies;
232 212
233 spear_start_ohci(ohci_p); 213 spear_start_ohci(ohci_p);
234 ohci_finish_controller_resume(hcd); 214 ohci_resume(hcd, false);
235 return 0; 215 return 0;
236} 216}
237#endif 217#endif
diff --git a/drivers/usb/host/ohci-tmio.c b/drivers/usb/host/ohci-tmio.c
index 60c2b0722f2e..2c9ab8f126d4 100644
--- a/drivers/usb/host/ohci-tmio.c
+++ b/drivers/usb/host/ohci-tmio.c
@@ -352,7 +352,7 @@ static int ohci_hcd_tmio_drv_resume(struct platform_device *dev)
352 352
353 spin_unlock_irqrestore(&tmio->lock, flags); 353 spin_unlock_irqrestore(&tmio->lock, flags);
354 354
355 ohci_finish_controller_resume(hcd); 355 ohci_resume(hcd, false);
356 356
357 return 0; 357 return 0;
358} 358}
diff --git a/drivers/usb/host/ohci-xls.c b/drivers/usb/host/ohci-xls.c
deleted file mode 100644
index 41e378f17c66..000000000000
--- a/drivers/usb/host/ohci-xls.c
+++ /dev/null
@@ -1,152 +0,0 @@
1/*
2 * OHCI HCD for Netlogic XLS processors.
3 *
4 * (C) Copyright 2011 Netlogic Microsystems Inc.
5 *
6 * Based on ohci-au1xxx.c, and other Linux OHCI drivers.
7 *
8 * This file is subject to the terms and conditions of the GNU General Public
9 * License. See the file COPYING in the main directory of this archive for
10 * more details.
11 */
12
13#include <linux/platform_device.h>
14#include <linux/signal.h>
15
16static int ohci_xls_probe_internal(const struct hc_driver *driver,
17 struct platform_device *dev)
18{
19 struct resource *res;
20 struct usb_hcd *hcd;
21 int retval, irq;
22
23 /* Get our IRQ from an earlier registered Platform Resource */
24 irq = platform_get_irq(dev, 0);
25 if (irq < 0) {
26 dev_err(&dev->dev, "Found HC with no IRQ\n");
27 return -ENODEV;
28 }
29
30 /* Get our Memory Handle */
31 res = platform_get_resource(dev, IORESOURCE_MEM, 0);
32 if (!res) {
33 dev_err(&dev->dev, "MMIO Handle incorrect!\n");
34 return -ENODEV;
35 }
36
37 hcd = usb_create_hcd(driver, &dev->dev, "XLS");
38 if (!hcd) {
39 retval = -ENOMEM;
40 goto err1;
41 }
42 hcd->rsrc_start = res->start;
43 hcd->rsrc_len = resource_size(res);
44
45 if (!request_mem_region(hcd->rsrc_start, hcd->rsrc_len,
46 driver->description)) {
47 dev_dbg(&dev->dev, "Controller already in use\n");
48 retval = -EBUSY;
49 goto err2;
50 }
51
52 hcd->regs = ioremap_nocache(hcd->rsrc_start, hcd->rsrc_len);
53 if (hcd->regs == NULL) {
54 dev_dbg(&dev->dev, "error mapping memory\n");
55 retval = -EFAULT;
56 goto err3;
57 }
58
59 retval = usb_add_hcd(hcd, irq, IRQF_DISABLED | IRQF_SHARED);
60 if (retval != 0)
61 goto err4;
62 return retval;
63
64err4:
65 iounmap(hcd->regs);
66err3:
67 release_mem_region(hcd->rsrc_start, hcd->rsrc_len);
68err2:
69 usb_put_hcd(hcd);
70err1:
71 dev_err(&dev->dev, "init fail, %d\n", retval);
72 return retval;
73}
74
75static int ohci_xls_reset(struct usb_hcd *hcd)
76{
77 struct ohci_hcd *ohci = hcd_to_ohci(hcd);
78
79 ohci_hcd_init(ohci);
80 return ohci_init(ohci);
81}
82
83static int __devinit ohci_xls_start(struct usb_hcd *hcd)
84{
85 struct ohci_hcd *ohci;
86 int ret;
87
88 ohci = hcd_to_ohci(hcd);
89 ret = ohci_run(ohci);
90 if (ret < 0) {
91 dev_err(hcd->self.controller, "can't start %s\n",
92 hcd->self.bus_name);
93 ohci_stop(hcd);
94 return ret;
95 }
96 return 0;
97}
98
99static struct hc_driver ohci_xls_hc_driver = {
100 .description = hcd_name,
101 .product_desc = "XLS OHCI Host Controller",
102 .hcd_priv_size = sizeof(struct ohci_hcd),
103 .irq = ohci_irq,
104 .flags = HCD_MEMORY | HCD_USB11,
105 .reset = ohci_xls_reset,
106 .start = ohci_xls_start,
107 .stop = ohci_stop,
108 .shutdown = ohci_shutdown,
109 .urb_enqueue = ohci_urb_enqueue,
110 .urb_dequeue = ohci_urb_dequeue,
111 .endpoint_disable = ohci_endpoint_disable,
112 .get_frame_number = ohci_get_frame,
113 .hub_status_data = ohci_hub_status_data,
114 .hub_control = ohci_hub_control,
115#ifdef CONFIG_PM
116 .bus_suspend = ohci_bus_suspend,
117 .bus_resume = ohci_bus_resume,
118#endif
119 .start_port_reset = ohci_start_port_reset,
120};
121
122static int ohci_xls_probe(struct platform_device *dev)
123{
124 int ret;
125
126 pr_debug("In ohci_xls_probe");
127 if (usb_disabled())
128 return -ENODEV;
129 ret = ohci_xls_probe_internal(&ohci_xls_hc_driver, dev);
130 return ret;
131}
132
133static int ohci_xls_remove(struct platform_device *dev)
134{
135 struct usb_hcd *hcd = platform_get_drvdata(dev);
136
137 usb_remove_hcd(hcd);
138 iounmap(hcd->regs);
139 release_mem_region(hcd->rsrc_start, hcd->rsrc_len);
140 usb_put_hcd(hcd);
141 return 0;
142}
143
144static struct platform_driver ohci_xls_driver = {
145 .probe = ohci_xls_probe,
146 .remove = ohci_xls_remove,
147 .shutdown = usb_hcd_platform_shutdown,
148 .driver = {
149 .name = "ohci-xls-0",
150 .owner = THIS_MODULE,
151 },
152};
diff --git a/drivers/usb/host/r8a66597-hcd.c b/drivers/usb/host/r8a66597-hcd.c
index fcc09e5ec0ad..b3eea0ba97a9 100644
--- a/drivers/usb/host/r8a66597-hcd.c
+++ b/drivers/usb/host/r8a66597-hcd.c
@@ -2036,10 +2036,8 @@ static void collect_usb_address_map(struct usb_device *udev, unsigned long *map)
2036 udev->parent->descriptor.bDeviceClass == USB_CLASS_HUB) 2036 udev->parent->descriptor.bDeviceClass == USB_CLASS_HUB)
2037 map[udev->devnum/32] |= (1 << (udev->devnum % 32)); 2037 map[udev->devnum/32] |= (1 << (udev->devnum % 32));
2038 2038
2039 usb_hub_for_each_child(udev, chix, childdev) { 2039 usb_hub_for_each_child(udev, chix, childdev)
2040 if (childdev) 2040 collect_usb_address_map(childdev, map);
2041 collect_usb_address_map(childdev, map);
2042 }
2043} 2041}
2044 2042
2045/* this function must be called with interrupt disabled */ 2043/* this function must be called with interrupt disabled */
diff --git a/drivers/usb/host/uhci-q.c b/drivers/usb/host/uhci-q.c
index d2c6f5ac4626..15921fd55048 100644
--- a/drivers/usb/host/uhci-q.c
+++ b/drivers/usb/host/uhci-q.c
@@ -1256,7 +1256,8 @@ static int uhci_submit_isochronous(struct uhci_hcd *uhci, struct urb *urb,
1256 struct uhci_qh *qh) 1256 struct uhci_qh *qh)
1257{ 1257{
1258 struct uhci_td *td = NULL; /* Since urb->number_of_packets > 0 */ 1258 struct uhci_td *td = NULL; /* Since urb->number_of_packets > 0 */
1259 int i, frame; 1259 int i;
1260 unsigned frame, next;
1260 unsigned long destination, status; 1261 unsigned long destination, status;
1261 struct urb_priv *urbp = (struct urb_priv *) urb->hcpriv; 1262 struct urb_priv *urbp = (struct urb_priv *) urb->hcpriv;
1262 1263
@@ -1265,37 +1266,29 @@ static int uhci_submit_isochronous(struct uhci_hcd *uhci, struct urb *urb,
1265 urb->number_of_packets >= UHCI_NUMFRAMES) 1266 urb->number_of_packets >= UHCI_NUMFRAMES)
1266 return -EFBIG; 1267 return -EFBIG;
1267 1268
1269 uhci_get_current_frame_number(uhci);
1270
1268 /* Check the period and figure out the starting frame number */ 1271 /* Check the period and figure out the starting frame number */
1269 if (!qh->bandwidth_reserved) { 1272 if (!qh->bandwidth_reserved) {
1270 qh->period = urb->interval; 1273 qh->period = urb->interval;
1271 if (urb->transfer_flags & URB_ISO_ASAP) { 1274 qh->phase = -1; /* Find the best phase */
1272 qh->phase = -1; /* Find the best phase */ 1275 i = uhci_check_bandwidth(uhci, qh);
1273 i = uhci_check_bandwidth(uhci, qh); 1276 if (i)
1274 if (i) 1277 return i;
1275 return i; 1278
1276 1279 /* Allow a little time to allocate the TDs */
1277 /* Allow a little time to allocate the TDs */ 1280 next = uhci->frame_number + 10;
1278 uhci_get_current_frame_number(uhci); 1281 frame = qh->phase;
1279 frame = uhci->frame_number + 10; 1282
1280 1283 /* Round up to the first available slot */
1281 /* Move forward to the first frame having the 1284 frame += (next - frame + qh->period - 1) & -qh->period;
1282 * correct phase */
1283 urb->start_frame = frame + ((qh->phase - frame) &
1284 (qh->period - 1));
1285 } else {
1286 i = urb->start_frame - uhci->last_iso_frame;
1287 if (i <= 0 || i >= UHCI_NUMFRAMES)
1288 return -EINVAL;
1289 qh->phase = urb->start_frame & (qh->period - 1);
1290 i = uhci_check_bandwidth(uhci, qh);
1291 if (i)
1292 return i;
1293 }
1294 1285
1295 } else if (qh->period != urb->interval) { 1286 } else if (qh->period != urb->interval) {
1296 return -EINVAL; /* Can't change the period */ 1287 return -EINVAL; /* Can't change the period */
1297 1288
1298 } else { 1289 } else {
1290 next = uhci->frame_number + 2;
1291
1299 /* Find the next unused frame */ 1292 /* Find the next unused frame */
1300 if (list_empty(&qh->queue)) { 1293 if (list_empty(&qh->queue)) {
1301 frame = qh->iso_frame; 1294 frame = qh->iso_frame;
@@ -1308,25 +1301,31 @@ static int uhci_submit_isochronous(struct uhci_hcd *uhci, struct urb *urb,
1308 lurb->number_of_packets * 1301 lurb->number_of_packets *
1309 lurb->interval; 1302 lurb->interval;
1310 } 1303 }
1311 if (urb->transfer_flags & URB_ISO_ASAP) { 1304
1312 /* Skip some frames if necessary to insure 1305 /* Fell behind? */
1313 * the start frame is in the future. 1306 if (uhci_frame_before_eq(frame, next)) {
1307
1308 /* USB_ISO_ASAP: Round up to the first available slot */
1309 if (urb->transfer_flags & URB_ISO_ASAP)
1310 frame += (next - frame + qh->period - 1) &
1311 -qh->period;
1312
1313 /*
1314 * Not ASAP: Use the next slot in the stream. If
1315 * the entire URB falls before the threshold, fail.
1314 */ 1316 */
1315 uhci_get_current_frame_number(uhci); 1317 else if (!uhci_frame_before_eq(next,
1316 if (uhci_frame_before_eq(frame, uhci->frame_number)) { 1318 frame + (urb->number_of_packets - 1) *
1317 frame = uhci->frame_number + 1; 1319 qh->period))
1318 frame += ((qh->phase - frame) & 1320 return -EXDEV;
1319 (qh->period - 1)); 1321 }
1320 }
1321 } /* Otherwise pick up where the last URB leaves off */
1322 urb->start_frame = frame;
1323 } 1322 }
1324 1323
1325 /* Make sure we won't have to go too far into the future */ 1324 /* Make sure we won't have to go too far into the future */
1326 if (uhci_frame_before_eq(uhci->last_iso_frame + UHCI_NUMFRAMES, 1325 if (uhci_frame_before_eq(uhci->last_iso_frame + UHCI_NUMFRAMES,
1327 urb->start_frame + urb->number_of_packets * 1326 frame + urb->number_of_packets * urb->interval))
1328 urb->interval))
1329 return -EFBIG; 1327 return -EFBIG;
1328 urb->start_frame = frame;
1330 1329
1331 status = TD_CTRL_ACTIVE | TD_CTRL_IOS; 1330 status = TD_CTRL_ACTIVE | TD_CTRL_IOS;
1332 destination = (urb->pipe & PIPE_DEVEP_MASK) | usb_packetid(urb->pipe); 1331 destination = (urb->pipe & PIPE_DEVEP_MASK) | usb_packetid(urb->pipe);
diff --git a/drivers/usb/host/xhci-mem.c b/drivers/usb/host/xhci-mem.c
index 487bc083dead..fb51c7085ad0 100644
--- a/drivers/usb/host/xhci-mem.c
+++ b/drivers/usb/host/xhci-mem.c
@@ -205,7 +205,12 @@ static int xhci_alloc_segments_for_ring(struct xhci_hcd *xhci,
205 205
206 next = xhci_segment_alloc(xhci, cycle_state, flags); 206 next = xhci_segment_alloc(xhci, cycle_state, flags);
207 if (!next) { 207 if (!next) {
208 xhci_free_segments_for_ring(xhci, *first); 208 prev = *first;
209 while (prev) {
210 next = prev->next;
211 xhci_segment_free(xhci, prev);
212 prev = next;
213 }
209 return -ENOMEM; 214 return -ENOMEM;
210 } 215 }
211 xhci_link_segments(xhci, prev, next, type); 216 xhci_link_segments(xhci, prev, next, type);
@@ -258,7 +263,7 @@ static struct xhci_ring *xhci_ring_alloc(struct xhci_hcd *xhci,
258 return ring; 263 return ring;
259 264
260fail: 265fail:
261 xhci_ring_free(xhci, ring); 266 kfree(ring);
262 return NULL; 267 return NULL;
263} 268}
264 269
diff --git a/drivers/usb/host/xhci-pci.c b/drivers/usb/host/xhci-pci.c
index 8345d7c23061..af259e0ec172 100644
--- a/drivers/usb/host/xhci-pci.c
+++ b/drivers/usb/host/xhci-pci.c
@@ -29,6 +29,7 @@
29/* Device for a quirk */ 29/* Device for a quirk */
30#define PCI_VENDOR_ID_FRESCO_LOGIC 0x1b73 30#define PCI_VENDOR_ID_FRESCO_LOGIC 0x1b73
31#define PCI_DEVICE_ID_FRESCO_LOGIC_PDK 0x1000 31#define PCI_DEVICE_ID_FRESCO_LOGIC_PDK 0x1000
32#define PCI_DEVICE_ID_FRESCO_LOGIC_FL1400 0x1400
32 33
33#define PCI_VENDOR_ID_ETRON 0x1b6f 34#define PCI_VENDOR_ID_ETRON 0x1b6f
34#define PCI_DEVICE_ID_ASROCK_P67 0x7023 35#define PCI_DEVICE_ID_ASROCK_P67 0x7023
@@ -58,8 +59,10 @@ static void xhci_pci_quirks(struct device *dev, struct xhci_hcd *xhci)
58 59
59 /* Look for vendor-specific quirks */ 60 /* Look for vendor-specific quirks */
60 if (pdev->vendor == PCI_VENDOR_ID_FRESCO_LOGIC && 61 if (pdev->vendor == PCI_VENDOR_ID_FRESCO_LOGIC &&
61 pdev->device == PCI_DEVICE_ID_FRESCO_LOGIC_PDK) { 62 (pdev->device == PCI_DEVICE_ID_FRESCO_LOGIC_PDK ||
62 if (pdev->revision == 0x0) { 63 pdev->device == PCI_DEVICE_ID_FRESCO_LOGIC_FL1400)) {
64 if (pdev->device == PCI_DEVICE_ID_FRESCO_LOGIC_PDK &&
65 pdev->revision == 0x0) {
63 xhci->quirks |= XHCI_RESET_EP_QUIRK; 66 xhci->quirks |= XHCI_RESET_EP_QUIRK;
64 xhci_dbg(xhci, "QUIRK: Fresco Logic xHC needs configure" 67 xhci_dbg(xhci, "QUIRK: Fresco Logic xHC needs configure"
65 " endpoint cmd after reset endpoint\n"); 68 " endpoint cmd after reset endpoint\n");
@@ -218,15 +221,8 @@ static void xhci_pci_remove(struct pci_dev *dev)
218static int xhci_pci_suspend(struct usb_hcd *hcd, bool do_wakeup) 221static int xhci_pci_suspend(struct usb_hcd *hcd, bool do_wakeup)
219{ 222{
220 struct xhci_hcd *xhci = hcd_to_xhci(hcd); 223 struct xhci_hcd *xhci = hcd_to_xhci(hcd);
221 int retval = 0;
222 224
223 if (hcd->state != HC_STATE_SUSPENDED || 225 return xhci_suspend(xhci);
224 xhci->shared_hcd->state != HC_STATE_SUSPENDED)
225 return -EINVAL;
226
227 retval = xhci_suspend(xhci);
228
229 return retval;
230} 226}
231 227
232static int xhci_pci_resume(struct usb_hcd *hcd, bool hibernated) 228static int xhci_pci_resume(struct usb_hcd *hcd, bool hibernated)
diff --git a/drivers/usb/host/xhci-ring.c b/drivers/usb/host/xhci-ring.c
index 4e1a8946b8d1..cbb44b7b9d65 100644
--- a/drivers/usb/host/xhci-ring.c
+++ b/drivers/usb/host/xhci-ring.c
@@ -318,7 +318,7 @@ static int xhci_abort_cmd_ring(struct xhci_hcd *xhci)
318 * seconds), then it should assume that the there are 318 * seconds), then it should assume that the there are
319 * larger problems with the xHC and assert HCRST. 319 * larger problems with the xHC and assert HCRST.
320 */ 320 */
321 ret = handshake(xhci, &xhci->op_regs->cmd_ring, 321 ret = xhci_handshake(xhci, &xhci->op_regs->cmd_ring,
322 CMD_RING_RUNNING, 0, 5 * 1000 * 1000); 322 CMD_RING_RUNNING, 0, 5 * 1000 * 1000);
323 if (ret < 0) { 323 if (ret < 0) {
324 xhci_err(xhci, "Stopped the command ring failed, " 324 xhci_err(xhci, "Stopped the command ring failed, "
@@ -3071,11 +3071,11 @@ static u32 xhci_td_remainder(unsigned int remainder)
3071} 3071}
3072 3072
3073/* 3073/*
3074 * For xHCI 1.0 host controllers, TD size is the number of packets remaining in 3074 * For xHCI 1.0 host controllers, TD size is the number of max packet sized
3075 * the TD (*not* including this TRB). 3075 * packets remaining in the TD (*not* including this TRB).
3076 * 3076 *
3077 * Total TD packet count = total_packet_count = 3077 * Total TD packet count = total_packet_count =
3078 * roundup(TD size in bytes / wMaxPacketSize) 3078 * DIV_ROUND_UP(TD size in bytes / wMaxPacketSize)
3079 * 3079 *
3080 * Packets transferred up to and including this TRB = packets_transferred = 3080 * Packets transferred up to and including this TRB = packets_transferred =
3081 * rounddown(total bytes transferred including this TRB / wMaxPacketSize) 3081 * rounddown(total bytes transferred including this TRB / wMaxPacketSize)
@@ -3083,15 +3083,16 @@ static u32 xhci_td_remainder(unsigned int remainder)
3083 * TD size = total_packet_count - packets_transferred 3083 * TD size = total_packet_count - packets_transferred
3084 * 3084 *
3085 * It must fit in bits 21:17, so it can't be bigger than 31. 3085 * It must fit in bits 21:17, so it can't be bigger than 31.
3086 * The last TRB in a TD must have the TD size set to zero.
3086 */ 3087 */
3087
3088static u32 xhci_v1_0_td_remainder(int running_total, int trb_buff_len, 3088static u32 xhci_v1_0_td_remainder(int running_total, int trb_buff_len,
3089 unsigned int total_packet_count, struct urb *urb) 3089 unsigned int total_packet_count, struct urb *urb,
3090 unsigned int num_trbs_left)
3090{ 3091{
3091 int packets_transferred; 3092 int packets_transferred;
3092 3093
3093 /* One TRB with a zero-length data packet. */ 3094 /* One TRB with a zero-length data packet. */
3094 if (running_total == 0 && trb_buff_len == 0) 3095 if (num_trbs_left == 0 || (running_total == 0 && trb_buff_len == 0))
3095 return 0; 3096 return 0;
3096 3097
3097 /* All the TRB queueing functions don't count the current TRB in 3098 /* All the TRB queueing functions don't count the current TRB in
@@ -3100,7 +3101,9 @@ static u32 xhci_v1_0_td_remainder(int running_total, int trb_buff_len,
3100 packets_transferred = (running_total + trb_buff_len) / 3101 packets_transferred = (running_total + trb_buff_len) /
3101 usb_endpoint_maxp(&urb->ep->desc); 3102 usb_endpoint_maxp(&urb->ep->desc);
3102 3103
3103 return xhci_td_remainder(total_packet_count - packets_transferred); 3104 if ((total_packet_count - packets_transferred) > 31)
3105 return 31 << 17;
3106 return (total_packet_count - packets_transferred) << 17;
3104} 3107}
3105 3108
3106static int queue_bulk_sg_tx(struct xhci_hcd *xhci, gfp_t mem_flags, 3109static int queue_bulk_sg_tx(struct xhci_hcd *xhci, gfp_t mem_flags,
@@ -3127,7 +3130,7 @@ static int queue_bulk_sg_tx(struct xhci_hcd *xhci, gfp_t mem_flags,
3127 3130
3128 num_trbs = count_sg_trbs_needed(xhci, urb); 3131 num_trbs = count_sg_trbs_needed(xhci, urb);
3129 num_sgs = urb->num_mapped_sgs; 3132 num_sgs = urb->num_mapped_sgs;
3130 total_packet_count = roundup(urb->transfer_buffer_length, 3133 total_packet_count = DIV_ROUND_UP(urb->transfer_buffer_length,
3131 usb_endpoint_maxp(&urb->ep->desc)); 3134 usb_endpoint_maxp(&urb->ep->desc));
3132 3135
3133 trb_buff_len = prepare_transfer(xhci, xhci->devs[slot_id], 3136 trb_buff_len = prepare_transfer(xhci, xhci->devs[slot_id],
@@ -3210,7 +3213,8 @@ static int queue_bulk_sg_tx(struct xhci_hcd *xhci, gfp_t mem_flags,
3210 running_total); 3213 running_total);
3211 } else { 3214 } else {
3212 remainder = xhci_v1_0_td_remainder(running_total, 3215 remainder = xhci_v1_0_td_remainder(running_total,
3213 trb_buff_len, total_packet_count, urb); 3216 trb_buff_len, total_packet_count, urb,
3217 num_trbs - 1);
3214 } 3218 }
3215 length_field = TRB_LEN(trb_buff_len) | 3219 length_field = TRB_LEN(trb_buff_len) |
3216 remainder | 3220 remainder |
@@ -3318,7 +3322,7 @@ int xhci_queue_bulk_tx(struct xhci_hcd *xhci, gfp_t mem_flags,
3318 start_cycle = ep_ring->cycle_state; 3322 start_cycle = ep_ring->cycle_state;
3319 3323
3320 running_total = 0; 3324 running_total = 0;
3321 total_packet_count = roundup(urb->transfer_buffer_length, 3325 total_packet_count = DIV_ROUND_UP(urb->transfer_buffer_length,
3322 usb_endpoint_maxp(&urb->ep->desc)); 3326 usb_endpoint_maxp(&urb->ep->desc));
3323 /* How much data is in the first TRB? */ 3327 /* How much data is in the first TRB? */
3324 addr = (u64) urb->transfer_dma; 3328 addr = (u64) urb->transfer_dma;
@@ -3364,7 +3368,8 @@ int xhci_queue_bulk_tx(struct xhci_hcd *xhci, gfp_t mem_flags,
3364 running_total); 3368 running_total);
3365 } else { 3369 } else {
3366 remainder = xhci_v1_0_td_remainder(running_total, 3370 remainder = xhci_v1_0_td_remainder(running_total,
3367 trb_buff_len, total_packet_count, urb); 3371 trb_buff_len, total_packet_count, urb,
3372 num_trbs - 1);
3368 } 3373 }
3369 length_field = TRB_LEN(trb_buff_len) | 3374 length_field = TRB_LEN(trb_buff_len) |
3370 remainder | 3375 remainder |
@@ -3627,7 +3632,7 @@ static int xhci_queue_isoc_tx(struct xhci_hcd *xhci, gfp_t mem_flags,
3627 addr = start_addr + urb->iso_frame_desc[i].offset; 3632 addr = start_addr + urb->iso_frame_desc[i].offset;
3628 td_len = urb->iso_frame_desc[i].length; 3633 td_len = urb->iso_frame_desc[i].length;
3629 td_remain_len = td_len; 3634 td_remain_len = td_len;
3630 total_packet_count = roundup(td_len, 3635 total_packet_count = DIV_ROUND_UP(td_len,
3631 usb_endpoint_maxp(&urb->ep->desc)); 3636 usb_endpoint_maxp(&urb->ep->desc));
3632 /* A zero-length transfer still involves at least one packet. */ 3637 /* A zero-length transfer still involves at least one packet. */
3633 if (total_packet_count == 0) 3638 if (total_packet_count == 0)
@@ -3706,7 +3711,8 @@ static int xhci_queue_isoc_tx(struct xhci_hcd *xhci, gfp_t mem_flags,
3706 } else { 3711 } else {
3707 remainder = xhci_v1_0_td_remainder( 3712 remainder = xhci_v1_0_td_remainder(
3708 running_total, trb_buff_len, 3713 running_total, trb_buff_len,
3709 total_packet_count, urb); 3714 total_packet_count, urb,
3715 (trbs_per_td - j - 1));
3710 } 3716 }
3711 length_field = TRB_LEN(trb_buff_len) | 3717 length_field = TRB_LEN(trb_buff_len) |
3712 remainder | 3718 remainder |
diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c
index c9e419f29b74..5c72c431bab1 100644
--- a/drivers/usb/host/xhci.c
+++ b/drivers/usb/host/xhci.c
@@ -40,7 +40,7 @@ MODULE_PARM_DESC(link_quirk, "Don't clear the chain bit on a link TRB");
40 40
41/* TODO: copied from ehci-hcd.c - can this be refactored? */ 41/* TODO: copied from ehci-hcd.c - can this be refactored? */
42/* 42/*
43 * handshake - spin reading hc until handshake completes or fails 43 * xhci_handshake - spin reading hc until handshake completes or fails
44 * @ptr: address of hc register to be read 44 * @ptr: address of hc register to be read
45 * @mask: bits to look at in result of read 45 * @mask: bits to look at in result of read
46 * @done: value of those bits when handshake succeeds 46 * @done: value of those bits when handshake succeeds
@@ -52,7 +52,7 @@ MODULE_PARM_DESC(link_quirk, "Don't clear the chain bit on a link TRB");
52 * handshake done). There are two failure modes: "usec" have passed (major 52 * handshake done). There are two failure modes: "usec" have passed (major
53 * hardware flakeout), or the register reads as all-ones (hardware removed). 53 * hardware flakeout), or the register reads as all-ones (hardware removed).
54 */ 54 */
55int handshake(struct xhci_hcd *xhci, void __iomem *ptr, 55int xhci_handshake(struct xhci_hcd *xhci, void __iomem *ptr,
56 u32 mask, u32 done, int usec) 56 u32 mask, u32 done, int usec)
57{ 57{
58 u32 result; 58 u32 result;
@@ -103,7 +103,7 @@ int xhci_halt(struct xhci_hcd *xhci)
103 xhci_dbg(xhci, "// Halt the HC\n"); 103 xhci_dbg(xhci, "// Halt the HC\n");
104 xhci_quiesce(xhci); 104 xhci_quiesce(xhci);
105 105
106 ret = handshake(xhci, &xhci->op_regs->status, 106 ret = xhci_handshake(xhci, &xhci->op_regs->status,
107 STS_HALT, STS_HALT, XHCI_MAX_HALT_USEC); 107 STS_HALT, STS_HALT, XHCI_MAX_HALT_USEC);
108 if (!ret) { 108 if (!ret) {
109 xhci->xhc_state |= XHCI_STATE_HALTED; 109 xhci->xhc_state |= XHCI_STATE_HALTED;
@@ -132,7 +132,7 @@ static int xhci_start(struct xhci_hcd *xhci)
132 * Wait for the HCHalted Status bit to be 0 to indicate the host is 132 * Wait for the HCHalted Status bit to be 0 to indicate the host is
133 * running. 133 * running.
134 */ 134 */
135 ret = handshake(xhci, &xhci->op_regs->status, 135 ret = xhci_handshake(xhci, &xhci->op_regs->status,
136 STS_HALT, 0, XHCI_MAX_HALT_USEC); 136 STS_HALT, 0, XHCI_MAX_HALT_USEC);
137 if (ret == -ETIMEDOUT) 137 if (ret == -ETIMEDOUT)
138 xhci_err(xhci, "Host took too long to start, " 138 xhci_err(xhci, "Host took too long to start, "
@@ -167,7 +167,7 @@ int xhci_reset(struct xhci_hcd *xhci)
167 command |= CMD_RESET; 167 command |= CMD_RESET;
168 xhci_writel(xhci, command, &xhci->op_regs->command); 168 xhci_writel(xhci, command, &xhci->op_regs->command);
169 169
170 ret = handshake(xhci, &xhci->op_regs->command, 170 ret = xhci_handshake(xhci, &xhci->op_regs->command,
171 CMD_RESET, 0, 10 * 1000 * 1000); 171 CMD_RESET, 0, 10 * 1000 * 1000);
172 if (ret) 172 if (ret)
173 return ret; 173 return ret;
@@ -177,7 +177,7 @@ int xhci_reset(struct xhci_hcd *xhci)
177 * xHCI cannot write to any doorbells or operational registers other 177 * xHCI cannot write to any doorbells or operational registers other
178 * than status until the "Controller Not Ready" flag is cleared. 178 * than status until the "Controller Not Ready" flag is cleared.
179 */ 179 */
180 ret = handshake(xhci, &xhci->op_regs->status, 180 ret = xhci_handshake(xhci, &xhci->op_regs->status,
181 STS_CNR, 0, 10 * 1000 * 1000); 181 STS_CNR, 0, 10 * 1000 * 1000);
182 182
183 for (i = 0; i < 2; ++i) { 183 for (i = 0; i < 2; ++i) {
@@ -480,7 +480,7 @@ static bool compliance_mode_recovery_timer_quirk_check(void)
480 if (strstr(dmi_product_name, "Z420") || 480 if (strstr(dmi_product_name, "Z420") ||
481 strstr(dmi_product_name, "Z620") || 481 strstr(dmi_product_name, "Z620") ||
482 strstr(dmi_product_name, "Z820") || 482 strstr(dmi_product_name, "Z820") ||
483 strstr(dmi_product_name, "Z1")) 483 strstr(dmi_product_name, "Z1 Workstation"))
484 return true; 484 return true;
485 485
486 return false; 486 return false;
@@ -880,6 +880,10 @@ int xhci_suspend(struct xhci_hcd *xhci)
880 struct usb_hcd *hcd = xhci_to_hcd(xhci); 880 struct usb_hcd *hcd = xhci_to_hcd(xhci);
881 u32 command; 881 u32 command;
882 882
883 if (hcd->state != HC_STATE_SUSPENDED ||
884 xhci->shared_hcd->state != HC_STATE_SUSPENDED)
885 return -EINVAL;
886
883 spin_lock_irq(&xhci->lock); 887 spin_lock_irq(&xhci->lock);
884 clear_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags); 888 clear_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags);
885 clear_bit(HCD_FLAG_HW_ACCESSIBLE, &xhci->shared_hcd->flags); 889 clear_bit(HCD_FLAG_HW_ACCESSIBLE, &xhci->shared_hcd->flags);
@@ -890,7 +894,7 @@ int xhci_suspend(struct xhci_hcd *xhci)
890 command = xhci_readl(xhci, &xhci->op_regs->command); 894 command = xhci_readl(xhci, &xhci->op_regs->command);
891 command &= ~CMD_RUN; 895 command &= ~CMD_RUN;
892 xhci_writel(xhci, command, &xhci->op_regs->command); 896 xhci_writel(xhci, command, &xhci->op_regs->command);
893 if (handshake(xhci, &xhci->op_regs->status, 897 if (xhci_handshake(xhci, &xhci->op_regs->status,
894 STS_HALT, STS_HALT, XHCI_MAX_HALT_USEC)) { 898 STS_HALT, STS_HALT, XHCI_MAX_HALT_USEC)) {
895 xhci_warn(xhci, "WARN: xHC CMD_RUN timeout\n"); 899 xhci_warn(xhci, "WARN: xHC CMD_RUN timeout\n");
896 spin_unlock_irq(&xhci->lock); 900 spin_unlock_irq(&xhci->lock);
@@ -905,7 +909,8 @@ int xhci_suspend(struct xhci_hcd *xhci)
905 command = xhci_readl(xhci, &xhci->op_regs->command); 909 command = xhci_readl(xhci, &xhci->op_regs->command);
906 command |= CMD_CSS; 910 command |= CMD_CSS;
907 xhci_writel(xhci, command, &xhci->op_regs->command); 911 xhci_writel(xhci, command, &xhci->op_regs->command);
908 if (handshake(xhci, &xhci->op_regs->status, STS_SAVE, 0, 10 * 1000)) { 912 if (xhci_handshake(xhci, &xhci->op_regs->status,
913 STS_SAVE, 0, 10 * 1000)) {
909 xhci_warn(xhci, "WARN: xHC save state timeout\n"); 914 xhci_warn(xhci, "WARN: xHC save state timeout\n");
910 spin_unlock_irq(&xhci->lock); 915 spin_unlock_irq(&xhci->lock);
911 return -ETIMEDOUT; 916 return -ETIMEDOUT;
@@ -967,7 +972,7 @@ int xhci_resume(struct xhci_hcd *xhci, bool hibernated)
967 command = xhci_readl(xhci, &xhci->op_regs->command); 972 command = xhci_readl(xhci, &xhci->op_regs->command);
968 command |= CMD_CRS; 973 command |= CMD_CRS;
969 xhci_writel(xhci, command, &xhci->op_regs->command); 974 xhci_writel(xhci, command, &xhci->op_regs->command);
970 if (handshake(xhci, &xhci->op_regs->status, 975 if (xhci_handshake(xhci, &xhci->op_regs->status,
971 STS_RESTORE, 0, 10 * 1000)) { 976 STS_RESTORE, 0, 10 * 1000)) {
972 xhci_warn(xhci, "WARN: xHC restore state timeout\n"); 977 xhci_warn(xhci, "WARN: xHC restore state timeout\n");
973 spin_unlock_irq(&xhci->lock); 978 spin_unlock_irq(&xhci->lock);
@@ -1035,7 +1040,7 @@ int xhci_resume(struct xhci_hcd *xhci, bool hibernated)
1035 command = xhci_readl(xhci, &xhci->op_regs->command); 1040 command = xhci_readl(xhci, &xhci->op_regs->command);
1036 command |= CMD_RUN; 1041 command |= CMD_RUN;
1037 xhci_writel(xhci, command, &xhci->op_regs->command); 1042 xhci_writel(xhci, command, &xhci->op_regs->command);
1038 handshake(xhci, &xhci->op_regs->status, STS_HALT, 1043 xhci_handshake(xhci, &xhci->op_regs->status, STS_HALT,
1039 0, 250 * 1000); 1044 0, 250 * 1000);
1040 1045
1041 /* step 5: walk topology and initialize portsc, 1046 /* step 5: walk topology and initialize portsc,
@@ -2254,7 +2259,7 @@ static bool xhci_is_async_ep(unsigned int ep_type)
2254 2259
2255static bool xhci_is_sync_in_ep(unsigned int ep_type) 2260static bool xhci_is_sync_in_ep(unsigned int ep_type)
2256{ 2261{
2257 return (ep_type == ISOC_IN_EP || ep_type != INT_IN_EP); 2262 return (ep_type == ISOC_IN_EP || ep_type == INT_IN_EP);
2258} 2263}
2259 2264
2260static unsigned int xhci_get_ss_bw_consumed(struct xhci_bw_info *ep_bw) 2265static unsigned int xhci_get_ss_bw_consumed(struct xhci_bw_info *ep_bw)
@@ -3874,7 +3879,8 @@ static int xhci_usb2_software_lpm_test(struct usb_hcd *hcd,
3874 spin_lock_irqsave(&xhci->lock, flags); 3879 spin_lock_irqsave(&xhci->lock, flags);
3875 3880
3876 /* Check L1 Status */ 3881 /* Check L1 Status */
3877 ret = handshake(xhci, pm_addr, PORT_L1S_MASK, PORT_L1S_SUCCESS, 125); 3882 ret = xhci_handshake(xhci, pm_addr,
3883 PORT_L1S_MASK, PORT_L1S_SUCCESS, 125);
3878 if (ret != -ETIMEDOUT) { 3884 if (ret != -ETIMEDOUT) {
3879 /* enter L1 successfully */ 3885 /* enter L1 successfully */
3880 temp = xhci_readl(xhci, addr); 3886 temp = xhci_readl(xhci, addr);
diff --git a/drivers/usb/host/xhci.h b/drivers/usb/host/xhci.h
index 53df4e70ca07..f791bd0aee6c 100644
--- a/drivers/usb/host/xhci.h
+++ b/drivers/usb/host/xhci.h
@@ -1720,7 +1720,7 @@ static inline void xhci_unregister_plat(void)
1720 1720
1721/* xHCI host controller glue */ 1721/* xHCI host controller glue */
1722typedef void (*xhci_get_quirks_t)(struct device *, struct xhci_hcd *); 1722typedef void (*xhci_get_quirks_t)(struct device *, struct xhci_hcd *);
1723int handshake(struct xhci_hcd *xhci, void __iomem *ptr, 1723int xhci_handshake(struct xhci_hcd *xhci, void __iomem *ptr,
1724 u32 mask, u32 done, int usec); 1724 u32 mask, u32 done, int usec);
1725void xhci_quiesce(struct xhci_hcd *xhci); 1725void xhci_quiesce(struct xhci_hcd *xhci);
1726int xhci_halt(struct xhci_hcd *xhci); 1726int xhci_halt(struct xhci_hcd *xhci);