aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/host
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2013-02-21 15:20:00 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2013-02-21 15:20:00 -0500
commit74e1a2a39355b2d3ae8c60c78d8add162c6d7183 (patch)
tree1ce09f285c505a774838a95cff7327a750dc85fc /drivers/usb/host
parentb5c78e04dd061b776978dad61dd85357081147b0 (diff)
parent6166805c3de539a41cfcae39026c5bc273d7c6aa (diff)
Merge tag 'usb-3.9-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb
Pull USB patches from Greg Kroah-Hartman: "Here's the big USB merge for 3.9-rc1 Nothing major, lots of gadget fixes, and of course, xhci stuff. All of this has been in linux-next for a while, with the exception of the last 3 patches, which were reverts of patches in the tree that caused problems, they went in yesterday." * tag 'usb-3.9-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb: (190 commits) Revert "USB: EHCI: make ehci-vt8500 a separate driver" Revert "USB: EHCI: make ehci-orion a separate driver" Revert "USB: update host controller Kconfig entries" USB: update host controller Kconfig entries USB: EHCI: make ehci-orion a separate driver USB: EHCI: make ehci-vt8500 a separate driver USB: usb-storage: unusual_devs update for Super TOP SATA bridge USB: ehci-omap: Fix autoloading of module USB: ehci-omap: Don't free gpios that we didn't request USB: option: add Huawei "ACM" devices using protocol = vendor USB: serial: fix null-pointer dereferences on disconnect USB: option: add Yota / Megafon M100-1 4g modem drivers/usb: add missing GENERIC_HARDIRQS dependencies USB: storage: properly handle the endian issues of idProduct testusb: remove all mentions of 'usbfs' usb: gadget: imx_udc: make it depend on BROKEN usb: omap_control_usb: fix compile warning ARM: OMAP: USB: Add phy binding information ARM: OMAP2: MUSB: Specify omap4 has mailbox ARM: OMAP: devices: create device for usb part of control module ...
Diffstat (limited to 'drivers/usb/host')
-rw-r--r--drivers/usb/host/Kconfig2
-rw-r--r--drivers/usb/host/ehci-mv.c1
-rw-r--r--drivers/usb/host/ehci-mxc.c20
-rw-r--r--drivers/usb/host/ehci-omap.c10
-rw-r--r--drivers/usb/host/ehci-s5p.c83
-rw-r--r--drivers/usb/host/isp1760-hcd.c4
-rw-r--r--drivers/usb/host/ohci-exynos.c87
-rw-r--r--drivers/usb/host/ohci-q.c1
-rw-r--r--drivers/usb/host/uhci-debug.c178
-rw-r--r--drivers/usb/host/uhci-hcd.c31
-rw-r--r--drivers/usb/host/uhci-hcd.h4
-rw-r--r--drivers/usb/host/uhci-hub.c4
-rw-r--r--drivers/usb/host/uhci-q.c2
-rw-r--r--drivers/usb/host/xhci-ring.c2
14 files changed, 269 insertions, 160 deletions
diff --git a/drivers/usb/host/Kconfig b/drivers/usb/host/Kconfig
index 3a21c5d683c0..c59a1126926f 100644
--- a/drivers/usb/host/Kconfig
+++ b/drivers/usb/host/Kconfig
@@ -246,7 +246,7 @@ config USB_EHCI_ATH79
246 246
247config USB_OXU210HP_HCD 247config USB_OXU210HP_HCD
248 tristate "OXU210HP HCD support" 248 tristate "OXU210HP HCD support"
249 depends on USB 249 depends on USB && GENERIC_HARDIRQS
250 ---help--- 250 ---help---
251 The OXU210HP is an USB host/OTG/device controller. Enable this 251 The OXU210HP is an USB host/OTG/device controller. Enable this
252 option if your board has this chip. If unsure, say N. 252 option if your board has this chip. If unsure, say N.
diff --git a/drivers/usb/host/ehci-mv.c b/drivers/usb/host/ehci-mv.c
index 6c56297ea16b..3065809546b1 100644
--- a/drivers/usb/host/ehci-mv.c
+++ b/drivers/usb/host/ehci-mv.c
@@ -302,7 +302,6 @@ static int mv_ehci_remove(struct platform_device *pdev)
302{ 302{
303 struct ehci_hcd_mv *ehci_mv = platform_get_drvdata(pdev); 303 struct ehci_hcd_mv *ehci_mv = platform_get_drvdata(pdev);
304 struct usb_hcd *hcd = ehci_mv->hcd; 304 struct usb_hcd *hcd = ehci_mv->hcd;
305 int clk_i;
306 305
307 if (hcd->rh_registered) 306 if (hcd->rh_registered)
308 usb_remove_hcd(hcd); 307 usb_remove_hcd(hcd);
diff --git a/drivers/usb/host/ehci-mxc.c b/drivers/usb/host/ehci-mxc.c
index e2004de6ad3d..e9301fb97eaa 100644
--- a/drivers/usb/host/ehci-mxc.c
+++ b/drivers/usb/host/ehci-mxc.c
@@ -57,7 +57,6 @@ static int ehci_mxc_drv_probe(struct platform_device *pdev)
57 struct usb_hcd *hcd; 57 struct usb_hcd *hcd;
58 struct resource *res; 58 struct resource *res;
59 int irq, ret; 59 int irq, ret;
60 unsigned int flags;
61 struct ehci_mxc_priv *priv; 60 struct ehci_mxc_priv *priv;
62 struct device *dev = &pdev->dev; 61 struct device *dev = &pdev->dev;
63 struct ehci_hcd *ehci; 62 struct ehci_hcd *ehci;
@@ -162,25 +161,6 @@ static int ehci_mxc_drv_probe(struct platform_device *pdev)
162 if (ret) 161 if (ret)
163 goto err_add; 162 goto err_add;
164 163
165 if (pdata->otg) {
166 /*
167 * efikamx and efikasb have some hardware bug which is
168 * preventing usb to work unless CHRGVBUS is set.
169 * It's in violation of USB specs
170 */
171 if (machine_is_mx51_efikamx() || machine_is_mx51_efikasb()) {
172 flags = usb_phy_io_read(pdata->otg,
173 ULPI_OTG_CTRL);
174 flags |= ULPI_OTG_CTRL_CHRGVBUS;
175 ret = usb_phy_io_write(pdata->otg, flags,
176 ULPI_OTG_CTRL);
177 if (ret) {
178 dev_err(dev, "unable to set CHRVBUS\n");
179 goto err_add;
180 }
181 }
182 }
183
184 return 0; 164 return 0;
185 165
186err_add: 166err_add:
diff --git a/drivers/usb/host/ehci-omap.c b/drivers/usb/host/ehci-omap.c
index ac17a7c3a0cd..99899e808c6a 100644
--- a/drivers/usb/host/ehci-omap.c
+++ b/drivers/usb/host/ehci-omap.c
@@ -288,7 +288,6 @@ static int ehci_hcd_omap_remove(struct platform_device *pdev)
288{ 288{
289 struct device *dev = &pdev->dev; 289 struct device *dev = &pdev->dev;
290 struct usb_hcd *hcd = dev_get_drvdata(dev); 290 struct usb_hcd *hcd = dev_get_drvdata(dev);
291 struct ehci_hcd_omap_platform_data *pdata = dev->platform_data;
292 291
293 usb_remove_hcd(hcd); 292 usb_remove_hcd(hcd);
294 disable_put_regulator(dev->platform_data); 293 disable_put_regulator(dev->platform_data);
@@ -298,13 +297,6 @@ static int ehci_hcd_omap_remove(struct platform_device *pdev)
298 pm_runtime_put_sync(dev); 297 pm_runtime_put_sync(dev);
299 pm_runtime_disable(dev); 298 pm_runtime_disable(dev);
300 299
301 if (pdata->phy_reset) {
302 if (gpio_is_valid(pdata->reset_gpio_port[0]))
303 gpio_free(pdata->reset_gpio_port[0]);
304
305 if (gpio_is_valid(pdata->reset_gpio_port[1]))
306 gpio_free(pdata->reset_gpio_port[1]);
307 }
308 return 0; 300 return 0;
309} 301}
310 302
@@ -372,7 +364,7 @@ static const struct hc_driver ehci_omap_hc_driver = {
372 .clear_tt_buffer_complete = ehci_clear_tt_buffer_complete, 364 .clear_tt_buffer_complete = ehci_clear_tt_buffer_complete,
373}; 365};
374 366
375MODULE_ALIAS("platform:omap-ehci"); 367MODULE_ALIAS("platform:ehci-omap");
376MODULE_AUTHOR("Texas Instruments, Inc."); 368MODULE_AUTHOR("Texas Instruments, Inc.");
377MODULE_AUTHOR("Felipe Balbi <felipe.balbi@nokia.com>"); 369MODULE_AUTHOR("Felipe Balbi <felipe.balbi@nokia.com>");
378 370
diff --git a/drivers/usb/host/ehci-s5p.c b/drivers/usb/host/ehci-s5p.c
index 319dcfaa8735..20ebf6a8b7f4 100644
--- a/drivers/usb/host/ehci-s5p.c
+++ b/drivers/usb/host/ehci-s5p.c
@@ -17,6 +17,8 @@
17#include <linux/platform_device.h> 17#include <linux/platform_device.h>
18#include <linux/of_gpio.h> 18#include <linux/of_gpio.h>
19#include <linux/platform_data/usb-ehci-s5p.h> 19#include <linux/platform_data/usb-ehci-s5p.h>
20#include <linux/usb/phy.h>
21#include <linux/usb/samsung_usb_phy.h>
20#include <plat/usb-phy.h> 22#include <plat/usb-phy.h>
21 23
22#define EHCI_INSNREG00(base) (base + 0x90) 24#define EHCI_INSNREG00(base) (base + 0x90)
@@ -32,6 +34,9 @@ struct s5p_ehci_hcd {
32 struct device *dev; 34 struct device *dev;
33 struct usb_hcd *hcd; 35 struct usb_hcd *hcd;
34 struct clk *clk; 36 struct clk *clk;
37 struct usb_phy *phy;
38 struct usb_otg *otg;
39 struct s5p_ehci_platdata *pdata;
35}; 40};
36 41
37static const struct hc_driver s5p_ehci_hc_driver = { 42static const struct hc_driver s5p_ehci_hc_driver = {
@@ -65,6 +70,26 @@ static const struct hc_driver s5p_ehci_hc_driver = {
65 .clear_tt_buffer_complete = ehci_clear_tt_buffer_complete, 70 .clear_tt_buffer_complete = ehci_clear_tt_buffer_complete,
66}; 71};
67 72
73static void s5p_ehci_phy_enable(struct s5p_ehci_hcd *s5p_ehci)
74{
75 struct platform_device *pdev = to_platform_device(s5p_ehci->dev);
76
77 if (s5p_ehci->phy)
78 usb_phy_init(s5p_ehci->phy);
79 else if (s5p_ehci->pdata->phy_init)
80 s5p_ehci->pdata->phy_init(pdev, USB_PHY_TYPE_HOST);
81}
82
83static void s5p_ehci_phy_disable(struct s5p_ehci_hcd *s5p_ehci)
84{
85 struct platform_device *pdev = to_platform_device(s5p_ehci->dev);
86
87 if (s5p_ehci->phy)
88 usb_phy_shutdown(s5p_ehci->phy);
89 else if (s5p_ehci->pdata->phy_exit)
90 s5p_ehci->pdata->phy_exit(pdev, USB_PHY_TYPE_HOST);
91}
92
68static void s5p_setup_vbus_gpio(struct platform_device *pdev) 93static void s5p_setup_vbus_gpio(struct platform_device *pdev)
69{ 94{
70 int err; 95 int err;
@@ -87,20 +112,15 @@ static u64 ehci_s5p_dma_mask = DMA_BIT_MASK(32);
87 112
88static int s5p_ehci_probe(struct platform_device *pdev) 113static int s5p_ehci_probe(struct platform_device *pdev)
89{ 114{
90 struct s5p_ehci_platdata *pdata; 115 struct s5p_ehci_platdata *pdata = pdev->dev.platform_data;
91 struct s5p_ehci_hcd *s5p_ehci; 116 struct s5p_ehci_hcd *s5p_ehci;
92 struct usb_hcd *hcd; 117 struct usb_hcd *hcd;
93 struct ehci_hcd *ehci; 118 struct ehci_hcd *ehci;
94 struct resource *res; 119 struct resource *res;
120 struct usb_phy *phy;
95 int irq; 121 int irq;
96 int err; 122 int err;
97 123
98 pdata = pdev->dev.platform_data;
99 if (!pdata) {
100 dev_err(&pdev->dev, "No platform data defined\n");
101 return -EINVAL;
102 }
103
104 /* 124 /*
105 * Right now device-tree probed devices don't get dma_mask set. 125 * Right now device-tree probed devices don't get dma_mask set.
106 * Since shared usb code relies on it, set it here for now. 126 * Since shared usb code relies on it, set it here for now.
@@ -118,6 +138,20 @@ static int s5p_ehci_probe(struct platform_device *pdev)
118 if (!s5p_ehci) 138 if (!s5p_ehci)
119 return -ENOMEM; 139 return -ENOMEM;
120 140
141 phy = devm_usb_get_phy(&pdev->dev, USB_PHY_TYPE_USB2);
142 if (IS_ERR_OR_NULL(phy)) {
143 /* Fallback to pdata */
144 if (!pdata) {
145 dev_warn(&pdev->dev, "no platform data or transceiver defined\n");
146 return -EPROBE_DEFER;
147 } else {
148 s5p_ehci->pdata = pdata;
149 }
150 } else {
151 s5p_ehci->phy = phy;
152 s5p_ehci->otg = phy->otg;
153 }
154
121 s5p_ehci->dev = &pdev->dev; 155 s5p_ehci->dev = &pdev->dev;
122 156
123 hcd = usb_create_hcd(&s5p_ehci_hc_driver, &pdev->dev, 157 hcd = usb_create_hcd(&s5p_ehci_hc_driver, &pdev->dev,
@@ -163,8 +197,10 @@ static int s5p_ehci_probe(struct platform_device *pdev)
163 goto fail_io; 197 goto fail_io;
164 } 198 }
165 199
166 if (pdata->phy_init) 200 if (s5p_ehci->otg)
167 pdata->phy_init(pdev, S5P_USB_PHY_HOST); 201 s5p_ehci->otg->set_host(s5p_ehci->otg, &s5p_ehci->hcd->self);
202
203 s5p_ehci_phy_enable(s5p_ehci);
168 204
169 ehci = hcd_to_ehci(hcd); 205 ehci = hcd_to_ehci(hcd);
170 ehci->caps = hcd->regs; 206 ehci->caps = hcd->regs;
@@ -175,13 +211,15 @@ static int s5p_ehci_probe(struct platform_device *pdev)
175 err = usb_add_hcd(hcd, irq, IRQF_SHARED); 211 err = usb_add_hcd(hcd, irq, IRQF_SHARED);
176 if (err) { 212 if (err) {
177 dev_err(&pdev->dev, "Failed to add USB HCD\n"); 213 dev_err(&pdev->dev, "Failed to add USB HCD\n");
178 goto fail_io; 214 goto fail_add_hcd;
179 } 215 }
180 216
181 platform_set_drvdata(pdev, s5p_ehci); 217 platform_set_drvdata(pdev, s5p_ehci);
182 218
183 return 0; 219 return 0;
184 220
221fail_add_hcd:
222 s5p_ehci_phy_disable(s5p_ehci);
185fail_io: 223fail_io:
186 clk_disable_unprepare(s5p_ehci->clk); 224 clk_disable_unprepare(s5p_ehci->clk);
187fail_clk: 225fail_clk:
@@ -191,14 +229,15 @@ fail_clk:
191 229
192static int s5p_ehci_remove(struct platform_device *pdev) 230static int s5p_ehci_remove(struct platform_device *pdev)
193{ 231{
194 struct s5p_ehci_platdata *pdata = pdev->dev.platform_data;
195 struct s5p_ehci_hcd *s5p_ehci = platform_get_drvdata(pdev); 232 struct s5p_ehci_hcd *s5p_ehci = platform_get_drvdata(pdev);
196 struct usb_hcd *hcd = s5p_ehci->hcd; 233 struct usb_hcd *hcd = s5p_ehci->hcd;
197 234
198 usb_remove_hcd(hcd); 235 usb_remove_hcd(hcd);
199 236
200 if (pdata && pdata->phy_exit) 237 if (s5p_ehci->otg)
201 pdata->phy_exit(pdev, S5P_USB_PHY_HOST); 238 s5p_ehci->otg->set_host(s5p_ehci->otg, &s5p_ehci->hcd->self);
239
240 s5p_ehci_phy_disable(s5p_ehci);
202 241
203 clk_disable_unprepare(s5p_ehci->clk); 242 clk_disable_unprepare(s5p_ehci->clk);
204 243
@@ -222,14 +261,14 @@ static int s5p_ehci_suspend(struct device *dev)
222 struct s5p_ehci_hcd *s5p_ehci = dev_get_drvdata(dev); 261 struct s5p_ehci_hcd *s5p_ehci = dev_get_drvdata(dev);
223 struct usb_hcd *hcd = s5p_ehci->hcd; 262 struct usb_hcd *hcd = s5p_ehci->hcd;
224 bool do_wakeup = device_may_wakeup(dev); 263 bool do_wakeup = device_may_wakeup(dev);
225 struct platform_device *pdev = to_platform_device(dev);
226 struct s5p_ehci_platdata *pdata = pdev->dev.platform_data;
227 int rc; 264 int rc;
228 265
229 rc = ehci_suspend(hcd, do_wakeup); 266 rc = ehci_suspend(hcd, do_wakeup);
230 267
231 if (pdata && pdata->phy_exit) 268 if (s5p_ehci->otg)
232 pdata->phy_exit(pdev, S5P_USB_PHY_HOST); 269 s5p_ehci->otg->set_host(s5p_ehci->otg, &s5p_ehci->hcd->self);
270
271 s5p_ehci_phy_disable(s5p_ehci);
233 272
234 clk_disable_unprepare(s5p_ehci->clk); 273 clk_disable_unprepare(s5p_ehci->clk);
235 274
@@ -240,13 +279,13 @@ static int s5p_ehci_resume(struct device *dev)
240{ 279{
241 struct s5p_ehci_hcd *s5p_ehci = dev_get_drvdata(dev); 280 struct s5p_ehci_hcd *s5p_ehci = dev_get_drvdata(dev);
242 struct usb_hcd *hcd = s5p_ehci->hcd; 281 struct usb_hcd *hcd = s5p_ehci->hcd;
243 struct platform_device *pdev = to_platform_device(dev);
244 struct s5p_ehci_platdata *pdata = pdev->dev.platform_data;
245 282
246 clk_prepare_enable(s5p_ehci->clk); 283 clk_prepare_enable(s5p_ehci->clk);
247 284
248 if (pdata && pdata->phy_init) 285 if (s5p_ehci->otg)
249 pdata->phy_init(pdev, S5P_USB_PHY_HOST); 286 s5p_ehci->otg->set_host(s5p_ehci->otg, &s5p_ehci->hcd->self);
287
288 s5p_ehci_phy_enable(s5p_ehci);
250 289
251 /* DMA burst Enable */ 290 /* DMA burst Enable */
252 writel(EHCI_INSNREG00_ENABLE_DMA_BURST, EHCI_INSNREG00(hcd->regs)); 291 writel(EHCI_INSNREG00_ENABLE_DMA_BURST, EHCI_INSNREG00(hcd->regs));
@@ -266,7 +305,7 @@ static const struct dev_pm_ops s5p_ehci_pm_ops = {
266 305
267#ifdef CONFIG_OF 306#ifdef CONFIG_OF
268static const struct of_device_id exynos_ehci_match[] = { 307static const struct of_device_id exynos_ehci_match[] = {
269 { .compatible = "samsung,exynos-ehci" }, 308 { .compatible = "samsung,exynos4210-ehci" },
270 {}, 309 {},
271}; 310};
272MODULE_DEVICE_TABLE(of, exynos_ehci_match); 311MODULE_DEVICE_TABLE(of, exynos_ehci_match);
diff --git a/drivers/usb/host/isp1760-hcd.c b/drivers/usb/host/isp1760-hcd.c
index a35bbddf8968..125e261f5bfc 100644
--- a/drivers/usb/host/isp1760-hcd.c
+++ b/drivers/usb/host/isp1760-hcd.c
@@ -932,7 +932,7 @@ static void enqueue_qtds(struct usb_hcd *hcd, struct isp1760_qh *qh)
932 } 932 }
933} 933}
934 934
935void schedule_ptds(struct usb_hcd *hcd) 935static void schedule_ptds(struct usb_hcd *hcd)
936{ 936{
937 struct isp1760_hcd *priv; 937 struct isp1760_hcd *priv;
938 struct isp1760_qh *qh, *qh_next; 938 struct isp1760_qh *qh, *qh_next;
@@ -1285,7 +1285,7 @@ leave:
1285#define SLOT_CHECK_PERIOD 200 1285#define SLOT_CHECK_PERIOD 200
1286static struct timer_list errata2_timer; 1286static struct timer_list errata2_timer;
1287 1287
1288void errata2_function(unsigned long data) 1288static void errata2_function(unsigned long data)
1289{ 1289{
1290 struct usb_hcd *hcd = (struct usb_hcd *) data; 1290 struct usb_hcd *hcd = (struct usb_hcd *) data;
1291 struct isp1760_hcd *priv = hcd_to_priv(hcd); 1291 struct isp1760_hcd *priv = hcd_to_priv(hcd);
diff --git a/drivers/usb/host/ohci-exynos.c b/drivers/usb/host/ohci-exynos.c
index aa3b8844bb9f..e3b7e85120e4 100644
--- a/drivers/usb/host/ohci-exynos.c
+++ b/drivers/usb/host/ohci-exynos.c
@@ -15,14 +15,39 @@
15#include <linux/of.h> 15#include <linux/of.h>
16#include <linux/platform_device.h> 16#include <linux/platform_device.h>
17#include <linux/platform_data/usb-exynos.h> 17#include <linux/platform_data/usb-exynos.h>
18#include <linux/usb/phy.h>
19#include <linux/usb/samsung_usb_phy.h>
18#include <plat/usb-phy.h> 20#include <plat/usb-phy.h>
19 21
20struct exynos_ohci_hcd { 22struct exynos_ohci_hcd {
21 struct device *dev; 23 struct device *dev;
22 struct usb_hcd *hcd; 24 struct usb_hcd *hcd;
23 struct clk *clk; 25 struct clk *clk;
26 struct usb_phy *phy;
27 struct usb_otg *otg;
28 struct exynos4_ohci_platdata *pdata;
24}; 29};
25 30
31static void exynos_ohci_phy_enable(struct exynos_ohci_hcd *exynos_ohci)
32{
33 struct platform_device *pdev = to_platform_device(exynos_ohci->dev);
34
35 if (exynos_ohci->phy)
36 usb_phy_init(exynos_ohci->phy);
37 else if (exynos_ohci->pdata->phy_init)
38 exynos_ohci->pdata->phy_init(pdev, USB_PHY_TYPE_HOST);
39}
40
41static void exynos_ohci_phy_disable(struct exynos_ohci_hcd *exynos_ohci)
42{
43 struct platform_device *pdev = to_platform_device(exynos_ohci->dev);
44
45 if (exynos_ohci->phy)
46 usb_phy_shutdown(exynos_ohci->phy);
47 else if (exynos_ohci->pdata->phy_exit)
48 exynos_ohci->pdata->phy_exit(pdev, USB_PHY_TYPE_HOST);
49}
50
26static int ohci_exynos_reset(struct usb_hcd *hcd) 51static int ohci_exynos_reset(struct usb_hcd *hcd)
27{ 52{
28 return ohci_init(hcd_to_ohci(hcd)); 53 return ohci_init(hcd_to_ohci(hcd));
@@ -78,20 +103,15 @@ static u64 ohci_exynos_dma_mask = DMA_BIT_MASK(32);
78 103
79static int exynos_ohci_probe(struct platform_device *pdev) 104static int exynos_ohci_probe(struct platform_device *pdev)
80{ 105{
81 struct exynos4_ohci_platdata *pdata; 106 struct exynos4_ohci_platdata *pdata = pdev->dev.platform_data;
82 struct exynos_ohci_hcd *exynos_ohci; 107 struct exynos_ohci_hcd *exynos_ohci;
83 struct usb_hcd *hcd; 108 struct usb_hcd *hcd;
84 struct ohci_hcd *ohci; 109 struct ohci_hcd *ohci;
85 struct resource *res; 110 struct resource *res;
111 struct usb_phy *phy;
86 int irq; 112 int irq;
87 int err; 113 int err;
88 114
89 pdata = pdev->dev.platform_data;
90 if (!pdata) {
91 dev_err(&pdev->dev, "No platform data defined\n");
92 return -EINVAL;
93 }
94
95 /* 115 /*
96 * Right now device-tree probed devices don't get dma_mask set. 116 * Right now device-tree probed devices don't get dma_mask set.
97 * Since shared usb code relies on it, set it here for now. 117 * Since shared usb code relies on it, set it here for now.
@@ -107,6 +127,20 @@ static int exynos_ohci_probe(struct platform_device *pdev)
107 if (!exynos_ohci) 127 if (!exynos_ohci)
108 return -ENOMEM; 128 return -ENOMEM;
109 129
130 phy = devm_usb_get_phy(&pdev->dev, USB_PHY_TYPE_USB2);
131 if (IS_ERR_OR_NULL(phy)) {
132 /* Fallback to pdata */
133 if (!pdata) {
134 dev_warn(&pdev->dev, "no platform data or transceiver defined\n");
135 return -EPROBE_DEFER;
136 } else {
137 exynos_ohci->pdata = pdata;
138 }
139 } else {
140 exynos_ohci->phy = phy;
141 exynos_ohci->otg = phy->otg;
142 }
143
110 exynos_ohci->dev = &pdev->dev; 144 exynos_ohci->dev = &pdev->dev;
111 145
112 hcd = usb_create_hcd(&exynos_ohci_hc_driver, &pdev->dev, 146 hcd = usb_create_hcd(&exynos_ohci_hc_driver, &pdev->dev,
@@ -152,8 +186,11 @@ static int exynos_ohci_probe(struct platform_device *pdev)
152 goto fail_io; 186 goto fail_io;
153 } 187 }
154 188
155 if (pdata->phy_init) 189 if (exynos_ohci->otg)
156 pdata->phy_init(pdev, S5P_USB_PHY_HOST); 190 exynos_ohci->otg->set_host(exynos_ohci->otg,
191 &exynos_ohci->hcd->self);
192
193 exynos_ohci_phy_enable(exynos_ohci);
157 194
158 ohci = hcd_to_ohci(hcd); 195 ohci = hcd_to_ohci(hcd);
159 ohci_hcd_init(ohci); 196 ohci_hcd_init(ohci);
@@ -161,13 +198,15 @@ static int exynos_ohci_probe(struct platform_device *pdev)
161 err = usb_add_hcd(hcd, irq, IRQF_SHARED); 198 err = usb_add_hcd(hcd, irq, IRQF_SHARED);
162 if (err) { 199 if (err) {
163 dev_err(&pdev->dev, "Failed to add USB HCD\n"); 200 dev_err(&pdev->dev, "Failed to add USB HCD\n");
164 goto fail_io; 201 goto fail_add_hcd;
165 } 202 }
166 203
167 platform_set_drvdata(pdev, exynos_ohci); 204 platform_set_drvdata(pdev, exynos_ohci);
168 205
169 return 0; 206 return 0;
170 207
208fail_add_hcd:
209 exynos_ohci_phy_disable(exynos_ohci);
171fail_io: 210fail_io:
172 clk_disable_unprepare(exynos_ohci->clk); 211 clk_disable_unprepare(exynos_ohci->clk);
173fail_clk: 212fail_clk:
@@ -177,14 +216,16 @@ fail_clk:
177 216
178static int exynos_ohci_remove(struct platform_device *pdev) 217static int exynos_ohci_remove(struct platform_device *pdev)
179{ 218{
180 struct exynos4_ohci_platdata *pdata = pdev->dev.platform_data;
181 struct exynos_ohci_hcd *exynos_ohci = platform_get_drvdata(pdev); 219 struct exynos_ohci_hcd *exynos_ohci = platform_get_drvdata(pdev);
182 struct usb_hcd *hcd = exynos_ohci->hcd; 220 struct usb_hcd *hcd = exynos_ohci->hcd;
183 221
184 usb_remove_hcd(hcd); 222 usb_remove_hcd(hcd);
185 223
186 if (pdata && pdata->phy_exit) 224 if (exynos_ohci->otg)
187 pdata->phy_exit(pdev, S5P_USB_PHY_HOST); 225 exynos_ohci->otg->set_host(exynos_ohci->otg,
226 &exynos_ohci->hcd->self);
227
228 exynos_ohci_phy_disable(exynos_ohci);
188 229
189 clk_disable_unprepare(exynos_ohci->clk); 230 clk_disable_unprepare(exynos_ohci->clk);
190 231
@@ -208,8 +249,6 @@ static int exynos_ohci_suspend(struct device *dev)
208 struct exynos_ohci_hcd *exynos_ohci = dev_get_drvdata(dev); 249 struct exynos_ohci_hcd *exynos_ohci = dev_get_drvdata(dev);
209 struct usb_hcd *hcd = exynos_ohci->hcd; 250 struct usb_hcd *hcd = exynos_ohci->hcd;
210 struct ohci_hcd *ohci = hcd_to_ohci(hcd); 251 struct ohci_hcd *ohci = hcd_to_ohci(hcd);
211 struct platform_device *pdev = to_platform_device(dev);
212 struct exynos4_ohci_platdata *pdata = pdev->dev.platform_data;
213 unsigned long flags; 252 unsigned long flags;
214 int rc = 0; 253 int rc = 0;
215 254
@@ -228,8 +267,11 @@ static int exynos_ohci_suspend(struct device *dev)
228 267
229 clear_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags); 268 clear_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags);
230 269
231 if (pdata && pdata->phy_exit) 270 if (exynos_ohci->otg)
232 pdata->phy_exit(pdev, S5P_USB_PHY_HOST); 271 exynos_ohci->otg->set_host(exynos_ohci->otg,
272 &exynos_ohci->hcd->self);
273
274 exynos_ohci_phy_disable(exynos_ohci);
233 275
234 clk_disable_unprepare(exynos_ohci->clk); 276 clk_disable_unprepare(exynos_ohci->clk);
235 277
@@ -243,13 +285,14 @@ static int exynos_ohci_resume(struct device *dev)
243{ 285{
244 struct exynos_ohci_hcd *exynos_ohci = dev_get_drvdata(dev); 286 struct exynos_ohci_hcd *exynos_ohci = dev_get_drvdata(dev);
245 struct usb_hcd *hcd = exynos_ohci->hcd; 287 struct usb_hcd *hcd = exynos_ohci->hcd;
246 struct platform_device *pdev = to_platform_device(dev);
247 struct exynos4_ohci_platdata *pdata = pdev->dev.platform_data;
248 288
249 clk_prepare_enable(exynos_ohci->clk); 289 clk_prepare_enable(exynos_ohci->clk);
250 290
251 if (pdata && pdata->phy_init) 291 if (exynos_ohci->otg)
252 pdata->phy_init(pdev, S5P_USB_PHY_HOST); 292 exynos_ohci->otg->set_host(exynos_ohci->otg,
293 &exynos_ohci->hcd->self);
294
295 exynos_ohci_phy_enable(exynos_ohci);
253 296
254 ohci_resume(hcd, false); 297 ohci_resume(hcd, false);
255 298
@@ -267,7 +310,7 @@ static const struct dev_pm_ops exynos_ohci_pm_ops = {
267 310
268#ifdef CONFIG_OF 311#ifdef CONFIG_OF
269static const struct of_device_id exynos_ohci_match[] = { 312static const struct of_device_id exynos_ohci_match[] = {
270 { .compatible = "samsung,exynos-ohci" }, 313 { .compatible = "samsung,exynos4210-ohci" },
271 {}, 314 {},
272}; 315};
273MODULE_DEVICE_TABLE(of, exynos_ohci_match); 316MODULE_DEVICE_TABLE(of, exynos_ohci_match);
diff --git a/drivers/usb/host/ohci-q.c b/drivers/usb/host/ohci-q.c
index 7482cfbe8c5e..88731b7c5f42 100644
--- a/drivers/usb/host/ohci-q.c
+++ b/drivers/usb/host/ohci-q.c
@@ -44,6 +44,7 @@ __acquires(ohci->lock)
44 // ASSERT (urb->hcpriv != 0); 44 // ASSERT (urb->hcpriv != 0);
45 45
46 urb_free_priv (ohci, urb->hcpriv); 46 urb_free_priv (ohci, urb->hcpriv);
47 urb->hcpriv = NULL;
47 if (likely(status == -EINPROGRESS)) 48 if (likely(status == -EINPROGRESS))
48 status = 0; 49 status = 0;
49 50
diff --git a/drivers/usb/host/uhci-debug.c b/drivers/usb/host/uhci-debug.c
index fc0b0daac93d..455737546525 100644
--- a/drivers/usb/host/uhci-debug.c
+++ b/drivers/usb/host/uhci-debug.c
@@ -16,6 +16,8 @@
16 16
17#include "uhci-hcd.h" 17#include "uhci-hcd.h"
18 18
19#define EXTRA_SPACE 1024
20
19static struct dentry *uhci_debugfs_root; 21static struct dentry *uhci_debugfs_root;
20 22
21#ifdef DEBUG 23#ifdef DEBUG
@@ -44,10 +46,6 @@ static int uhci_show_td(struct uhci_hcd *uhci, struct uhci_td *td, char *buf,
44 char *spid; 46 char *spid;
45 u32 status, token; 47 u32 status, token;
46 48
47 /* Try to make sure there's enough memory */
48 if (len < 160)
49 return 0;
50
51 status = td_status(uhci, td); 49 status = td_status(uhci, td);
52 out += sprintf(out, "%*s[%p] link (%08x) ", space, "", td, 50 out += sprintf(out, "%*s[%p] link (%08x) ", space, "", td,
53 hc32_to_cpu(uhci, td->link)); 51 hc32_to_cpu(uhci, td->link));
@@ -64,6 +62,8 @@ static int uhci_show_td(struct uhci_hcd *uhci, struct uhci_td *td, char *buf,
64 (status & TD_CTRL_CRCTIMEO) ? "CRC/Timeo " : "", 62 (status & TD_CTRL_CRCTIMEO) ? "CRC/Timeo " : "",
65 (status & TD_CTRL_BITSTUFF) ? "BitStuff " : "", 63 (status & TD_CTRL_BITSTUFF) ? "BitStuff " : "",
66 status & 0x7ff); 64 status & 0x7ff);
65 if (out - buf > len)
66 goto done;
67 67
68 token = td_token(uhci, td); 68 token = td_token(uhci, td);
69 switch (uhci_packetid(token)) { 69 switch (uhci_packetid(token)) {
@@ -90,6 +90,9 @@ static int uhci_show_td(struct uhci_hcd *uhci, struct uhci_td *td, char *buf,
90 spid); 90 spid);
91 out += sprintf(out, "(buf=%08x)\n", hc32_to_cpu(uhci, td->buffer)); 91 out += sprintf(out, "(buf=%08x)\n", hc32_to_cpu(uhci, td->buffer));
92 92
93done:
94 if (out - buf > len)
95 out += sprintf(out, " ...\n");
93 return out - buf; 96 return out - buf;
94} 97}
95 98
@@ -101,8 +104,6 @@ static int uhci_show_urbp(struct uhci_hcd *uhci, struct urb_priv *urbp,
101 int i, nactive, ninactive; 104 int i, nactive, ninactive;
102 char *ptype; 105 char *ptype;
103 106
104 if (len < 200)
105 return 0;
106 107
107 out += sprintf(out, "urb_priv [%p] ", urbp); 108 out += sprintf(out, "urb_priv [%p] ", urbp);
108 out += sprintf(out, "urb [%p] ", urbp->urb); 109 out += sprintf(out, "urb [%p] ", urbp->urb);
@@ -110,6 +111,8 @@ static int uhci_show_urbp(struct uhci_hcd *uhci, struct urb_priv *urbp,
110 out += sprintf(out, "Dev=%d ", usb_pipedevice(urbp->urb->pipe)); 111 out += sprintf(out, "Dev=%d ", usb_pipedevice(urbp->urb->pipe));
111 out += sprintf(out, "EP=%x(%s) ", usb_pipeendpoint(urbp->urb->pipe), 112 out += sprintf(out, "EP=%x(%s) ", usb_pipeendpoint(urbp->urb->pipe),
112 (usb_pipein(urbp->urb->pipe) ? "IN" : "OUT")); 113 (usb_pipein(urbp->urb->pipe) ? "IN" : "OUT"));
114 if (out - buf > len)
115 goto done;
113 116
114 switch (usb_pipetype(urbp->urb->pipe)) { 117 switch (usb_pipetype(urbp->urb->pipe)) {
115 case PIPE_ISOCHRONOUS: ptype = "ISO"; break; 118 case PIPE_ISOCHRONOUS: ptype = "ISO"; break;
@@ -128,6 +131,9 @@ static int uhci_show_urbp(struct uhci_hcd *uhci, struct urb_priv *urbp,
128 out += sprintf(out, " Unlinked=%d", urbp->urb->unlinked); 131 out += sprintf(out, " Unlinked=%d", urbp->urb->unlinked);
129 out += sprintf(out, "\n"); 132 out += sprintf(out, "\n");
130 133
134 if (out - buf > len)
135 goto done;
136
131 i = nactive = ninactive = 0; 137 i = nactive = ninactive = 0;
132 list_for_each_entry(td, &urbp->td_list, list) { 138 list_for_each_entry(td, &urbp->td_list, list) {
133 if (urbp->qh->type != USB_ENDPOINT_XFER_ISOC && 139 if (urbp->qh->type != USB_ENDPOINT_XFER_ISOC &&
@@ -135,6 +141,8 @@ static int uhci_show_urbp(struct uhci_hcd *uhci, struct urb_priv *urbp,
135 out += sprintf(out, "%*s%d: ", space + 2, "", i); 141 out += sprintf(out, "%*s%d: ", space + 2, "", i);
136 out += uhci_show_td(uhci, td, out, 142 out += uhci_show_td(uhci, td, out,
137 len - (out - buf), 0); 143 len - (out - buf), 0);
144 if (out - buf > len)
145 goto tail;
138 } else { 146 } else {
139 if (td_status(uhci, td) & TD_CTRL_ACTIVE) 147 if (td_status(uhci, td) & TD_CTRL_ACTIVE)
140 ++nactive; 148 ++nactive;
@@ -143,10 +151,13 @@ static int uhci_show_urbp(struct uhci_hcd *uhci, struct urb_priv *urbp,
143 } 151 }
144 } 152 }
145 if (nactive + ninactive > 0) 153 if (nactive + ninactive > 0)
146 out += sprintf(out, "%*s[skipped %d inactive and %d active " 154 out += sprintf(out,
147 "TDs]\n", 155 "%*s[skipped %d inactive and %d active TDs]\n",
148 space, "", ninactive, nactive); 156 space, "", ninactive, nactive);
149 157done:
158 if (out - buf > len)
159 out += sprintf(out, " ...\n");
160tail:
150 return out - buf; 161 return out - buf;
151} 162}
152 163
@@ -158,10 +169,6 @@ static int uhci_show_qh(struct uhci_hcd *uhci,
158 __hc32 element = qh_element(qh); 169 __hc32 element = qh_element(qh);
159 char *qtype; 170 char *qtype;
160 171
161 /* Try to make sure there's enough memory */
162 if (len < 80 * 7)
163 return 0;
164
165 switch (qh->type) { 172 switch (qh->type) {
166 case USB_ENDPOINT_XFER_ISOC: qtype = "ISO"; break; 173 case USB_ENDPOINT_XFER_ISOC: qtype = "ISO"; break;
167 case USB_ENDPOINT_XFER_INT: qtype = "INT"; break; 174 case USB_ENDPOINT_XFER_INT: qtype = "INT"; break;
@@ -175,13 +182,15 @@ static int uhci_show_qh(struct uhci_hcd *uhci,
175 hc32_to_cpu(uhci, qh->link), 182 hc32_to_cpu(uhci, qh->link),
176 hc32_to_cpu(uhci, element)); 183 hc32_to_cpu(uhci, element));
177 if (qh->type == USB_ENDPOINT_XFER_ISOC) 184 if (qh->type == USB_ENDPOINT_XFER_ISOC)
178 out += sprintf(out, "%*s period %d phase %d load %d us, " 185 out += sprintf(out,
179 "frame %x desc [%p]\n", 186 "%*s period %d phase %d load %d us, frame %x desc [%p]\n",
180 space, "", qh->period, qh->phase, qh->load, 187 space, "", qh->period, qh->phase, qh->load,
181 qh->iso_frame, qh->iso_packet_desc); 188 qh->iso_frame, qh->iso_packet_desc);
182 else if (qh->type == USB_ENDPOINT_XFER_INT) 189 else if (qh->type == USB_ENDPOINT_XFER_INT)
183 out += sprintf(out, "%*s period %d phase %d load %d us\n", 190 out += sprintf(out, "%*s period %d phase %d load %d us\n",
184 space, "", qh->period, qh->phase, qh->load); 191 space, "", qh->period, qh->phase, qh->load);
192 if (out - buf > len)
193 goto done;
185 194
186 if (element & UHCI_PTR_QH(uhci)) 195 if (element & UHCI_PTR_QH(uhci))
187 out += sprintf(out, "%*s Element points to QH (bug?)\n", space, ""); 196 out += sprintf(out, "%*s Element points to QH (bug?)\n", space, "");
@@ -195,11 +204,17 @@ static int uhci_show_qh(struct uhci_hcd *uhci,
195 if (!(element & ~(UHCI_PTR_QH(uhci) | UHCI_PTR_DEPTH(uhci)))) 204 if (!(element & ~(UHCI_PTR_QH(uhci) | UHCI_PTR_DEPTH(uhci))))
196 out += sprintf(out, "%*s Element is NULL (bug?)\n", space, ""); 205 out += sprintf(out, "%*s Element is NULL (bug?)\n", space, "");
197 206
207 if (out - buf > len)
208 goto done;
209
198 if (list_empty(&qh->queue)) { 210 if (list_empty(&qh->queue)) {
199 out += sprintf(out, "%*s queue is empty\n", space, ""); 211 out += sprintf(out, "%*s queue is empty\n", space, "");
200 if (qh == uhci->skel_async_qh) 212 if (qh == uhci->skel_async_qh) {
201 out += uhci_show_td(uhci, uhci->term_td, out, 213 out += uhci_show_td(uhci, uhci->term_td, out,
202 len - (out - buf), 0); 214 len - (out - buf), 0);
215 if (out - buf > len)
216 goto tail;
217 }
203 } else { 218 } else {
204 struct urb_priv *urbp = list_entry(qh->queue.next, 219 struct urb_priv *urbp = list_entry(qh->queue.next,
205 struct urb_priv, node); 220 struct urb_priv, node);
@@ -211,9 +226,12 @@ static int uhci_show_qh(struct uhci_hcd *uhci,
211 space, ""); 226 space, "");
212 i = nurbs = 0; 227 i = nurbs = 0;
213 list_for_each_entry(urbp, &qh->queue, node) { 228 list_for_each_entry(urbp, &qh->queue, node) {
214 if (++i <= 10) 229 if (++i <= 10) {
215 out += uhci_show_urbp(uhci, urbp, out, 230 out += uhci_show_urbp(uhci, urbp, out,
216 len - (out - buf), space + 2); 231 len - (out - buf), space + 2);
232 if (out - buf > len)
233 goto tail;
234 }
217 else 235 else
218 ++nurbs; 236 ++nurbs;
219 } 237 }
@@ -222,24 +240,27 @@ static int uhci_show_qh(struct uhci_hcd *uhci,
222 space, "", nurbs); 240 space, "", nurbs);
223 } 241 }
224 242
243 if (out - buf > len)
244 goto done;
245
225 if (qh->dummy_td) { 246 if (qh->dummy_td) {
226 out += sprintf(out, "%*s Dummy TD\n", space, ""); 247 out += sprintf(out, "%*s Dummy TD\n", space, "");
227 out += uhci_show_td(uhci, qh->dummy_td, out, 248 out += uhci_show_td(uhci, qh->dummy_td, out,
228 len - (out - buf), 0); 249 len - (out - buf), 0);
250 if (out - buf > len)
251 goto tail;
229 } 252 }
230 253
254done:
255 if (out - buf > len)
256 out += sprintf(out, " ...\n");
257tail:
231 return out - buf; 258 return out - buf;
232} 259}
233 260
234static int uhci_show_sc(int port, unsigned short status, char *buf, int len) 261static int uhci_show_sc(int port, unsigned short status, char *buf)
235{ 262{
236 char *out = buf; 263 return sprintf(buf, " stat%d = %04x %s%s%s%s%s%s%s%s%s%s\n",
237
238 /* Try to make sure there's enough memory */
239 if (len < 160)
240 return 0;
241
242 out += sprintf(out, " stat%d = %04x %s%s%s%s%s%s%s%s%s%s\n",
243 port, 264 port,
244 status, 265 status,
245 (status & USBPORTSC_SUSP) ? " Suspend" : "", 266 (status & USBPORTSC_SUSP) ? " Suspend" : "",
@@ -252,19 +273,12 @@ static int uhci_show_sc(int port, unsigned short status, char *buf, int len)
252 (status & USBPORTSC_PE) ? " Enabled" : "", 273 (status & USBPORTSC_PE) ? " Enabled" : "",
253 (status & USBPORTSC_CSC) ? " ConnectChange" : "", 274 (status & USBPORTSC_CSC) ? " ConnectChange" : "",
254 (status & USBPORTSC_CCS) ? " Connected" : ""); 275 (status & USBPORTSC_CCS) ? " Connected" : "");
255
256 return out - buf;
257} 276}
258 277
259static int uhci_show_root_hub_state(struct uhci_hcd *uhci, char *buf, int len) 278static int uhci_show_root_hub_state(struct uhci_hcd *uhci, char *buf)
260{ 279{
261 char *out = buf;
262 char *rh_state; 280 char *rh_state;
263 281
264 /* Try to make sure there's enough memory */
265 if (len < 60)
266 return 0;
267
268 switch (uhci->rh_state) { 282 switch (uhci->rh_state) {
269 case UHCI_RH_RESET: 283 case UHCI_RH_RESET:
270 rh_state = "reset"; break; 284 rh_state = "reset"; break;
@@ -283,9 +297,8 @@ static int uhci_show_root_hub_state(struct uhci_hcd *uhci, char *buf, int len)
283 default: 297 default:
284 rh_state = "?"; break; 298 rh_state = "?"; break;
285 } 299 }
286 out += sprintf(out, "Root-hub state: %s FSBR: %d\n", 300 return sprintf(buf, "Root-hub state: %s FSBR: %d\n",
287 rh_state, uhci->fsbr_is_on); 301 rh_state, uhci->fsbr_is_on);
288 return out - buf;
289} 302}
290 303
291static int uhci_show_status(struct uhci_hcd *uhci, char *buf, int len) 304static int uhci_show_status(struct uhci_hcd *uhci, char *buf, int len)
@@ -296,9 +309,6 @@ static int uhci_show_status(struct uhci_hcd *uhci, char *buf, int len)
296 unsigned char sof; 309 unsigned char sof;
297 unsigned short portsc1, portsc2; 310 unsigned short portsc1, portsc2;
298 311
299 /* Try to make sure there's enough memory */
300 if (len < 80 * 9)
301 return 0;
302 312
303 usbcmd = uhci_readw(uhci, 0); 313 usbcmd = uhci_readw(uhci, 0);
304 usbstat = uhci_readw(uhci, 2); 314 usbstat = uhci_readw(uhci, 2);
@@ -319,6 +329,8 @@ static int uhci_show_status(struct uhci_hcd *uhci, char *buf, int len)
319 (usbcmd & USBCMD_GRESET) ? "GRESET " : "", 329 (usbcmd & USBCMD_GRESET) ? "GRESET " : "",
320 (usbcmd & USBCMD_HCRESET) ? "HCRESET " : "", 330 (usbcmd & USBCMD_HCRESET) ? "HCRESET " : "",
321 (usbcmd & USBCMD_RS) ? "RS " : ""); 331 (usbcmd & USBCMD_RS) ? "RS " : "");
332 if (out - buf > len)
333 goto done;
322 334
323 out += sprintf(out, " usbstat = %04x %s%s%s%s%s%s\n", 335 out += sprintf(out, " usbstat = %04x %s%s%s%s%s%s\n",
324 usbstat, 336 usbstat,
@@ -328,19 +340,33 @@ static int uhci_show_status(struct uhci_hcd *uhci, char *buf, int len)
328 (usbstat & USBSTS_RD) ? "ResumeDetect " : "", 340 (usbstat & USBSTS_RD) ? "ResumeDetect " : "",
329 (usbstat & USBSTS_ERROR) ? "USBError " : "", 341 (usbstat & USBSTS_ERROR) ? "USBError " : "",
330 (usbstat & USBSTS_USBINT) ? "USBINT " : ""); 342 (usbstat & USBSTS_USBINT) ? "USBINT " : "");
343 if (out - buf > len)
344 goto done;
331 345
332 out += sprintf(out, " usbint = %04x\n", usbint); 346 out += sprintf(out, " usbint = %04x\n", usbint);
333 out += sprintf(out, " usbfrnum = (%d)%03x\n", (usbfrnum >> 10) & 1, 347 out += sprintf(out, " usbfrnum = (%d)%03x\n", (usbfrnum >> 10) & 1,
334 0xfff & (4*(unsigned int)usbfrnum)); 348 0xfff & (4*(unsigned int)usbfrnum));
335 out += sprintf(out, " flbaseadd = %08x\n", flbaseadd); 349 out += sprintf(out, " flbaseadd = %08x\n", flbaseadd);
336 out += sprintf(out, " sof = %02x\n", sof); 350 out += sprintf(out, " sof = %02x\n", sof);
337 out += uhci_show_sc(1, portsc1, out, len - (out - buf)); 351 if (out - buf > len)
338 out += uhci_show_sc(2, portsc2, out, len - (out - buf)); 352 goto done;
339 out += sprintf(out, "Most recent frame: %x (%d) " 353
340 "Last ISO frame: %x (%d)\n", 354 out += uhci_show_sc(1, portsc1, out);
355 if (out - buf > len)
356 goto done;
357
358 out += uhci_show_sc(2, portsc2, out);
359 if (out - buf > len)
360 goto done;
361
362 out += sprintf(out,
363 "Most recent frame: %x (%d) Last ISO frame: %x (%d)\n",
341 uhci->frame_number, uhci->frame_number & 1023, 364 uhci->frame_number, uhci->frame_number & 1023,
342 uhci->last_iso_frame, uhci->last_iso_frame & 1023); 365 uhci->last_iso_frame, uhci->last_iso_frame & 1023);
343 366
367done:
368 if (out - buf > len)
369 out += sprintf(out, " ...\n");
344 return out - buf; 370 return out - buf;
345} 371}
346 372
@@ -360,9 +386,13 @@ static int uhci_sprint_schedule(struct uhci_hcd *uhci, char *buf, int len)
360 "int8", "int4", "int2", "async", "term" 386 "int8", "int4", "int2", "async", "term"
361 }; 387 };
362 388
363 out += uhci_show_root_hub_state(uhci, out, len - (out - buf)); 389 out += uhci_show_root_hub_state(uhci, out);
390 if (out - buf > len)
391 goto done;
364 out += sprintf(out, "HC status\n"); 392 out += sprintf(out, "HC status\n");
365 out += uhci_show_status(uhci, out, len - (out - buf)); 393 out += uhci_show_status(uhci, out, len - (out - buf));
394 if (out - buf > len)
395 goto tail;
366 396
367 out += sprintf(out, "Periodic load table\n"); 397 out += sprintf(out, "Periodic load table\n");
368 for (i = 0; i < MAX_PHASE; ++i) { 398 for (i = 0; i < MAX_PHASE; ++i) {
@@ -375,7 +405,7 @@ static int uhci_sprint_schedule(struct uhci_hcd *uhci, char *buf, int len)
375 uhci_to_hcd(uhci)->self.bandwidth_int_reqs, 405 uhci_to_hcd(uhci)->self.bandwidth_int_reqs,
376 uhci_to_hcd(uhci)->self.bandwidth_isoc_reqs); 406 uhci_to_hcd(uhci)->self.bandwidth_isoc_reqs);
377 if (debug <= 1) 407 if (debug <= 1)
378 return out - buf; 408 goto tail;
379 409
380 out += sprintf(out, "Frame List\n"); 410 out += sprintf(out, "Frame List\n");
381 nframes = 10; 411 nframes = 10;
@@ -383,6 +413,8 @@ static int uhci_sprint_schedule(struct uhci_hcd *uhci, char *buf, int len)
383 for (i = 0; i < UHCI_NUMFRAMES; ++i) { 413 for (i = 0; i < UHCI_NUMFRAMES; ++i) {
384 __hc32 qh_dma; 414 __hc32 qh_dma;
385 415
416 if (out - buf > len)
417 goto done;
386 j = 0; 418 j = 0;
387 td = uhci->frame_cpu[i]; 419 td = uhci->frame_cpu[i];
388 link = uhci->frame[i]; 420 link = uhci->frame[i];
@@ -401,15 +433,20 @@ static int uhci_sprint_schedule(struct uhci_hcd *uhci, char *buf, int len)
401 td = list_entry(tmp, struct uhci_td, fl_list); 433 td = list_entry(tmp, struct uhci_td, fl_list);
402 tmp = tmp->next; 434 tmp = tmp->next;
403 if (link != LINK_TO_TD(uhci, td)) { 435 if (link != LINK_TO_TD(uhci, td)) {
404 if (nframes > 0) 436 if (nframes > 0) {
405 out += sprintf(out, " link does " 437 out += sprintf(out,
406 "not match list entry!\n"); 438 " link does not match list entry!\n");
407 else 439 if (out - buf > len)
440 goto done;
441 } else
408 ++nerrs; 442 ++nerrs;
409 } 443 }
410 if (nframes > 0) 444 if (nframes > 0) {
411 out += uhci_show_td(uhci, td, out, 445 out += uhci_show_td(uhci, td, out,
412 len - (out - buf), 4); 446 len - (out - buf), 4);
447 if (out - buf > len)
448 goto tail;
449 }
413 link = td->link; 450 link = td->link;
414 } while (tmp != head); 451 } while (tmp != head);
415 452
@@ -423,9 +460,11 @@ check_link:
423 i, hc32_to_cpu(uhci, link)); 460 i, hc32_to_cpu(uhci, link));
424 j = 1; 461 j = 1;
425 } 462 }
426 out += sprintf(out, " link does not match " 463 out += sprintf(out,
427 "QH (%08x)!\n", 464 " link does not match QH (%08x)!\n",
428 hc32_to_cpu(uhci, qh_dma)); 465 hc32_to_cpu(uhci, qh_dma));
466 if (out - buf > len)
467 goto done;
429 } else 468 } else
430 ++nerrs; 469 ++nerrs;
431 } 470 }
@@ -436,18 +475,27 @@ check_link:
436 475
437 out += sprintf(out, "Skeleton QHs\n"); 476 out += sprintf(out, "Skeleton QHs\n");
438 477
478 if (out - buf > len)
479 goto done;
480
439 fsbr_link = 0; 481 fsbr_link = 0;
440 for (i = 0; i < UHCI_NUM_SKELQH; ++i) { 482 for (i = 0; i < UHCI_NUM_SKELQH; ++i) {
441 int cnt = 0; 483 int cnt = 0;
442 484
443 qh = uhci->skelqh[i]; 485 qh = uhci->skelqh[i];
444 out += sprintf(out, "- skel_%s_qh\n", qh_names[i]); \ 486 out += sprintf(out, "- skel_%s_qh\n", qh_names[i]);
445 out += uhci_show_qh(uhci, qh, out, len - (out - buf), 4); 487 out += uhci_show_qh(uhci, qh, out, len - (out - buf), 4);
488 if (out - buf > len)
489 goto tail;
446 490
447 /* Last QH is the Terminating QH, it's different */ 491 /* Last QH is the Terminating QH, it's different */
448 if (i == SKEL_TERM) { 492 if (i == SKEL_TERM) {
449 if (qh_element(qh) != LINK_TO_TD(uhci, uhci->term_td)) 493 if (qh_element(qh) != LINK_TO_TD(uhci, uhci->term_td)) {
450 out += sprintf(out, " skel_term_qh element is not set to term_td!\n"); 494 out += sprintf(out,
495 " skel_term_qh element is not set to term_td!\n");
496 if (out - buf > len)
497 goto done;
498 }
451 link = fsbr_link; 499 link = fsbr_link;
452 if (!link) 500 if (!link)
453 link = LINK_TO_QH(uhci, uhci->skel_term_qh); 501 link = LINK_TO_QH(uhci, uhci->skel_term_qh);
@@ -460,9 +508,12 @@ check_link:
460 while (tmp != head) { 508 while (tmp != head) {
461 qh = list_entry(tmp, struct uhci_qh, node); 509 qh = list_entry(tmp, struct uhci_qh, node);
462 tmp = tmp->next; 510 tmp = tmp->next;
463 if (++cnt <= 10) 511 if (++cnt <= 10) {
464 out += uhci_show_qh(uhci, qh, out, 512 out += uhci_show_qh(uhci, qh, out,
465 len - (out - buf), 4); 513 len - (out - buf), 4);
514 if (out - buf > len)
515 goto tail;
516 }
466 if (!fsbr_link && qh->skel >= SKEL_FSBR) 517 if (!fsbr_link && qh->skel >= SKEL_FSBR)
467 fsbr_link = LINK_TO_QH(uhci, qh); 518 fsbr_link = LINK_TO_QH(uhci, qh);
468 } 519 }
@@ -480,9 +531,17 @@ check_link:
480 link = LINK_TO_QH(uhci, uhci->skel_term_qh); 531 link = LINK_TO_QH(uhci, uhci->skel_term_qh);
481check_qh_link: 532check_qh_link:
482 if (qh->link != link) 533 if (qh->link != link)
483 out += sprintf(out, " last QH not linked to next skeleton!\n"); 534 out += sprintf(out,
535 " last QH not linked to next skeleton!\n");
536
537 if (out - buf > len)
538 goto done;
484 } 539 }
485 540
541done:
542 if (out - buf > len)
543 out += sprintf(out, " ...\n");
544tail:
486 return out - buf; 545 return out - buf;
487} 546}
488 547
@@ -514,7 +573,8 @@ static int uhci_debug_open(struct inode *inode, struct file *file)
514 up->size = 0; 573 up->size = 0;
515 spin_lock_irqsave(&uhci->lock, flags); 574 spin_lock_irqsave(&uhci->lock, flags);
516 if (uhci->is_initialized) 575 if (uhci->is_initialized)
517 up->size = uhci_sprint_schedule(uhci, up->data, MAX_OUTPUT); 576 up->size = uhci_sprint_schedule(uhci, up->data,
577 MAX_OUTPUT - EXTRA_SPACE);
518 spin_unlock_irqrestore(&uhci->lock, flags); 578 spin_unlock_irqrestore(&uhci->lock, flags);
519 579
520 file->private_data = up; 580 file->private_data = up;
@@ -529,7 +589,9 @@ static loff_t uhci_debug_lseek(struct file *file, loff_t off, int whence)
529 589
530 up = file->private_data; 590 up = file->private_data;
531 591
532 /* XXX: atomic 64bit seek access, but that needs to be fixed in the VFS */ 592 /*
593 * XXX: atomic 64bit seek access, but that needs to be fixed in the VFS
594 */
533 switch (whence) { 595 switch (whence) {
534 case 0: 596 case 0:
535 new = off; 597 new = off;
diff --git a/drivers/usb/host/uhci-hcd.c b/drivers/usb/host/uhci-hcd.c
index 4f64d24eebc8..4a86b63745b8 100644
--- a/drivers/usb/host/uhci-hcd.c
+++ b/drivers/usb/host/uhci-hcd.c
@@ -453,20 +453,19 @@ static irqreturn_t uhci_irq(struct usb_hcd *hcd)
453 453
454 if (status & ~(USBSTS_USBINT | USBSTS_ERROR | USBSTS_RD)) { 454 if (status & ~(USBSTS_USBINT | USBSTS_ERROR | USBSTS_RD)) {
455 if (status & USBSTS_HSE) 455 if (status & USBSTS_HSE)
456 dev_err(uhci_dev(uhci), "host system error, " 456 dev_err(uhci_dev(uhci),
457 "PCI problems?\n"); 457 "host system error, PCI problems?\n");
458 if (status & USBSTS_HCPE) 458 if (status & USBSTS_HCPE)
459 dev_err(uhci_dev(uhci), "host controller process " 459 dev_err(uhci_dev(uhci),
460 "error, something bad happened!\n"); 460 "host controller process error, something bad happened!\n");
461 if (status & USBSTS_HCH) { 461 if (status & USBSTS_HCH) {
462 if (uhci->rh_state >= UHCI_RH_RUNNING) { 462 if (uhci->rh_state >= UHCI_RH_RUNNING) {
463 dev_err(uhci_dev(uhci), 463 dev_err(uhci_dev(uhci),
464 "host controller halted, " 464 "host controller halted, very bad!\n");
465 "very bad!\n");
466 if (debug > 1 && errbuf) { 465 if (debug > 1 && errbuf) {
467 /* Print the schedule for debugging */ 466 /* Print the schedule for debugging */
468 uhci_sprint_schedule(uhci, 467 uhci_sprint_schedule(uhci, errbuf,
469 errbuf, ERRBUF_LEN); 468 ERRBUF_LEN - EXTRA_SPACE);
470 lprintk(errbuf); 469 lprintk(errbuf);
471 } 470 }
472 uhci_hc_died(uhci); 471 uhci_hc_died(uhci);
@@ -592,8 +591,8 @@ static int uhci_start(struct usb_hcd *hcd)
592 UHCI_NUMFRAMES * sizeof(*uhci->frame), 591 UHCI_NUMFRAMES * sizeof(*uhci->frame),
593 &uhci->frame_dma_handle, 0); 592 &uhci->frame_dma_handle, 0);
594 if (!uhci->frame) { 593 if (!uhci->frame) {
595 dev_err(uhci_dev(uhci), "unable to allocate " 594 dev_err(uhci_dev(uhci),
596 "consistent memory for frame list\n"); 595 "unable to allocate consistent memory for frame list\n");
597 goto err_alloc_frame; 596 goto err_alloc_frame;
598 } 597 }
599 memset(uhci->frame, 0, UHCI_NUMFRAMES * sizeof(*uhci->frame)); 598 memset(uhci->frame, 0, UHCI_NUMFRAMES * sizeof(*uhci->frame));
@@ -601,8 +600,8 @@ static int uhci_start(struct usb_hcd *hcd)
601 uhci->frame_cpu = kcalloc(UHCI_NUMFRAMES, sizeof(*uhci->frame_cpu), 600 uhci->frame_cpu = kcalloc(UHCI_NUMFRAMES, sizeof(*uhci->frame_cpu),
602 GFP_KERNEL); 601 GFP_KERNEL);
603 if (!uhci->frame_cpu) { 602 if (!uhci->frame_cpu) {
604 dev_err(uhci_dev(uhci), "unable to allocate " 603 dev_err(uhci_dev(uhci),
605 "memory for frame pointers\n"); 604 "unable to allocate memory for frame pointers\n");
606 goto err_alloc_frame_cpu; 605 goto err_alloc_frame_cpu;
607 } 606 }
608 607
@@ -737,8 +736,8 @@ static int uhci_rh_suspend(struct usb_hcd *hcd)
737 */ 736 */
738 else if (hcd->self.root_hub->do_remote_wakeup && 737 else if (hcd->self.root_hub->do_remote_wakeup &&
739 uhci->resuming_ports) { 738 uhci->resuming_ports) {
740 dev_dbg(uhci_dev(uhci), "suspend failed because a port " 739 dev_dbg(uhci_dev(uhci),
741 "is resuming\n"); 740 "suspend failed because a port is resuming\n");
742 rc = -EBUSY; 741 rc = -EBUSY;
743 } else 742 } else
744 suspend_rh(uhci, UHCI_RH_SUSPENDED); 743 suspend_rh(uhci, UHCI_RH_SUSPENDED);
@@ -829,8 +828,8 @@ static int uhci_count_ports(struct usb_hcd *hcd)
829 828
830 /* Anything greater than 7 is weird so we'll ignore it. */ 829 /* Anything greater than 7 is weird so we'll ignore it. */
831 if (port > UHCI_RH_MAXCHILD) { 830 if (port > UHCI_RH_MAXCHILD) {
832 dev_info(uhci_dev(uhci), "port count misdetected? " 831 dev_info(uhci_dev(uhci),
833 "forcing to 2 ports\n"); 832 "port count misdetected? forcing to 2 ports\n");
834 port = 2; 833 port = 2;
835 } 834 }
836 835
diff --git a/drivers/usb/host/uhci-hcd.h b/drivers/usb/host/uhci-hcd.h
index 7af2b7052047..6f986d82472d 100644
--- a/drivers/usb/host/uhci-hcd.h
+++ b/drivers/usb/host/uhci-hcd.h
@@ -212,10 +212,6 @@ struct uhci_qh {
212#define TD_CTRL_BITSTUFF (1 << 17) /* Bit Stuff Error */ 212#define TD_CTRL_BITSTUFF (1 << 17) /* Bit Stuff Error */
213#define TD_CTRL_ACTLEN_MASK 0x7FF /* actual length, encoded as n - 1 */ 213#define TD_CTRL_ACTLEN_MASK 0x7FF /* actual length, encoded as n - 1 */
214 214
215#define TD_CTRL_ANY_ERROR (TD_CTRL_STALLED | TD_CTRL_DBUFERR | \
216 TD_CTRL_BABBLE | TD_CTRL_CRCTIME | \
217 TD_CTRL_BITSTUFF)
218
219#define uhci_maxerr(err) ((err) << TD_CTRL_C_ERR_SHIFT) 215#define uhci_maxerr(err) ((err) << TD_CTRL_C_ERR_SHIFT)
220#define uhci_status_bits(ctrl_sts) ((ctrl_sts) & 0xF60000) 216#define uhci_status_bits(ctrl_sts) ((ctrl_sts) & 0xF60000)
221#define uhci_actual_length(ctrl_sts) (((ctrl_sts) + 1) & \ 217#define uhci_actual_length(ctrl_sts) (((ctrl_sts) + 1) & \
diff --git a/drivers/usb/host/uhci-hub.c b/drivers/usb/host/uhci-hub.c
index 15d13229ddbb..f87bee6d2789 100644
--- a/drivers/usb/host/uhci-hub.c
+++ b/drivers/usb/host/uhci-hub.c
@@ -21,8 +21,8 @@ static const __u8 root_hub_hub_des[] =
21 0x00, /* (per-port OC, no power switching) */ 21 0x00, /* (per-port OC, no power switching) */
22 0x01, /* __u8 bPwrOn2pwrGood; 2ms */ 22 0x01, /* __u8 bPwrOn2pwrGood; 2ms */
23 0x00, /* __u8 bHubContrCurrent; 0 mA */ 23 0x00, /* __u8 bHubContrCurrent; 0 mA */
24 0x00, /* __u8 DeviceRemovable; *** 7 Ports max *** */ 24 0x00, /* __u8 DeviceRemovable; *** 7 Ports max */
25 0xff /* __u8 PortPwrCtrlMask; *** 7 ports max *** */ 25 0xff /* __u8 PortPwrCtrlMask; *** 7 ports max */
26}; 26};
27 27
28#define UHCI_RH_MAXCHILD 7 28#define UHCI_RH_MAXCHILD 7
diff --git a/drivers/usb/host/uhci-q.c b/drivers/usb/host/uhci-q.c
index 15921fd55048..f0976d8190bc 100644
--- a/drivers/usb/host/uhci-q.c
+++ b/drivers/usb/host/uhci-q.c
@@ -1200,7 +1200,7 @@ static int uhci_result_common(struct uhci_hcd *uhci, struct urb *urb)
1200 if (debug > 1 && errbuf) { 1200 if (debug > 1 && errbuf) {
1201 /* Print the chain for debugging */ 1201 /* Print the chain for debugging */
1202 uhci_show_qh(uhci, urbp->qh, errbuf, 1202 uhci_show_qh(uhci, urbp->qh, errbuf,
1203 ERRBUF_LEN, 0); 1203 ERRBUF_LEN - EXTRA_SPACE, 0);
1204 lprintk(errbuf); 1204 lprintk(errbuf);
1205 } 1205 }
1206 } 1206 }
diff --git a/drivers/usb/host/xhci-ring.c b/drivers/usb/host/xhci-ring.c
index 7f76a49e90d3..882875465301 100644
--- a/drivers/usb/host/xhci-ring.c
+++ b/drivers/usb/host/xhci-ring.c
@@ -2708,13 +2708,11 @@ irqreturn_t xhci_irq(struct usb_hcd *hcd)
2708{ 2708{
2709 struct xhci_hcd *xhci = hcd_to_xhci(hcd); 2709 struct xhci_hcd *xhci = hcd_to_xhci(hcd);
2710 u32 status; 2710 u32 status;
2711 union xhci_trb *trb;
2712 u64 temp_64; 2711 u64 temp_64;
2713 union xhci_trb *event_ring_deq; 2712 union xhci_trb *event_ring_deq;
2714 dma_addr_t deq; 2713 dma_addr_t deq;
2715 2714
2716 spin_lock(&xhci->lock); 2715 spin_lock(&xhci->lock);
2717 trb = xhci->event_ring->dequeue;
2718 /* Check if the xHC generated the interrupt, or the irq is shared */ 2716 /* Check if the xHC generated the interrupt, or the irq is shared */
2719 status = xhci_readl(xhci, &xhci->op_regs->status); 2717 status = xhci_readl(xhci, &xhci->op_regs->status);
2720 if (status == 0xffffffff) 2718 if (status == 0xffffffff)