aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/host
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/usb/host')
-rw-r--r--drivers/usb/host/Kconfig7
-rw-r--r--drivers/usb/host/ehci-hcd.c36
-rw-r--r--drivers/usb/host/ehci-q.c32
-rw-r--r--drivers/usb/host/ehci-sched.c2
-rw-r--r--drivers/usb/host/ehci.h39
-rw-r--r--drivers/usb/host/fhci-dbg.c2
-rw-r--r--drivers/usb/host/fhci-hcd.c4
-rw-r--r--drivers/usb/host/hwa-hc.c3
-rw-r--r--drivers/usb/host/isp116x-hcd.c2
-rw-r--r--drivers/usb/host/isp116x.h8
-rw-r--r--drivers/usb/host/isp1760-hcd.c25
-rw-r--r--drivers/usb/host/isp1760-hcd.h7
-rw-r--r--drivers/usb/host/isp1760-if.c95
-rw-r--r--drivers/usb/host/ohci-hcd.c5
-rw-r--r--drivers/usb/host/ohci-s3c2410.c6
-rw-r--r--drivers/usb/host/oxu210hp-hcd.c24
-rw-r--r--drivers/usb/host/oxu210hp.h8
-rw-r--r--drivers/usb/host/pci-quirks.c2
-rw-r--r--drivers/usb/host/r8a66597-hcd.c118
-rw-r--r--drivers/usb/host/r8a66597.h2
-rw-r--r--drivers/usb/host/sl811-hcd.c4
-rw-r--r--drivers/usb/host/uhci-debug.c4
-rw-r--r--drivers/usb/host/uhci-hcd.h10
-rw-r--r--drivers/usb/host/uhci-q.c21
24 files changed, 338 insertions, 128 deletions
diff --git a/drivers/usb/host/Kconfig b/drivers/usb/host/Kconfig
index 2c63bfb1f8d9..845479f7c707 100644
--- a/drivers/usb/host/Kconfig
+++ b/drivers/usb/host/Kconfig
@@ -24,10 +24,7 @@ config USB_EHCI_HCD
24 The Enhanced Host Controller Interface (EHCI) is standard for USB 2.0 24 The Enhanced Host Controller Interface (EHCI) is standard for USB 2.0
25 "high speed" (480 Mbit/sec, 60 Mbyte/sec) host controller hardware. 25 "high speed" (480 Mbit/sec, 60 Mbyte/sec) host controller hardware.
26 If your USB host controller supports USB 2.0, you will likely want to 26 If your USB host controller supports USB 2.0, you will likely want to
27 configure this Host Controller Driver. At the time of this writing, 27 configure this Host Controller Driver.
28 the primary implementation of EHCI is a chip from NEC, widely available
29 in add-on PCI cards, but implementations are in the works from other
30 vendors including Intel and Philips. Motherboard support is appearing.
31 28
32 EHCI controllers are packaged with "companion" host controllers (OHCI 29 EHCI controllers are packaged with "companion" host controllers (OHCI
33 or UHCI) to handle USB 1.1 devices connected to root hub ports. Ports 30 or UHCI) to handle USB 1.1 devices connected to root hub ports. Ports
@@ -123,7 +120,7 @@ config USB_ISP116X_HCD
123 120
124config USB_ISP1760_HCD 121config USB_ISP1760_HCD
125 tristate "ISP 1760 HCD support" 122 tristate "ISP 1760 HCD support"
126 depends on USB && EXPERIMENTAL && (PCI || PPC_OF) 123 depends on USB && EXPERIMENTAL
127 ---help--- 124 ---help---
128 The ISP1760 chip is a USB 2.0 host controller. 125 The ISP1760 chip is a USB 2.0 host controller.
129 126
diff --git a/drivers/usb/host/ehci-hcd.c b/drivers/usb/host/ehci-hcd.c
index e551bb38852b..f2618d17710d 100644
--- a/drivers/usb/host/ehci-hcd.c
+++ b/drivers/usb/host/ehci-hcd.c
@@ -110,6 +110,42 @@ MODULE_PARM_DESC (ignore_oc, "ignore bogus hardware overcurrent indications");
110 110
111/*-------------------------------------------------------------------------*/ 111/*-------------------------------------------------------------------------*/
112 112
113static void
114timer_action(struct ehci_hcd *ehci, enum ehci_timer_action action)
115{
116 /* Don't override timeouts which shrink or (later) disable
117 * the async ring; just the I/O watchdog. Note that if a
118 * SHRINK were pending, OFF would never be requested.
119 */
120 if (timer_pending(&ehci->watchdog)
121 && ((BIT(TIMER_ASYNC_SHRINK) | BIT(TIMER_ASYNC_OFF))
122 & ehci->actions))
123 return;
124
125 if (!test_and_set_bit(action, &ehci->actions)) {
126 unsigned long t;
127
128 switch (action) {
129 case TIMER_IO_WATCHDOG:
130 t = EHCI_IO_JIFFIES;
131 break;
132 case TIMER_ASYNC_OFF:
133 t = EHCI_ASYNC_JIFFIES;
134 break;
135 /* case TIMER_ASYNC_SHRINK: */
136 default:
137 /* add a jiffie since we synch against the
138 * 8 KHz uframe counter.
139 */
140 t = DIV_ROUND_UP(EHCI_SHRINK_FRAMES * HZ, 1000) + 1;
141 break;
142 }
143 mod_timer(&ehci->watchdog, t + jiffies);
144 }
145}
146
147/*-------------------------------------------------------------------------*/
148
113/* 149/*
114 * handshake - spin reading hc until handshake completes or fails 150 * handshake - spin reading hc until handshake completes or fails
115 * @ptr: address of hc register to be read 151 * @ptr: address of hc register to be read
diff --git a/drivers/usb/host/ehci-q.c b/drivers/usb/host/ehci-q.c
index ecc9b66c03cd..1976b1b3778c 100644
--- a/drivers/usb/host/ehci-q.c
+++ b/drivers/usb/host/ehci-q.c
@@ -333,12 +333,40 @@ qh_completions (struct ehci_hcd *ehci, struct ehci_qh *qh)
333 token = hc32_to_cpu(ehci, qtd->hw_token); 333 token = hc32_to_cpu(ehci, qtd->hw_token);
334 334
335 /* always clean up qtds the hc de-activated */ 335 /* always clean up qtds the hc de-activated */
336 retry_xacterr:
336 if ((token & QTD_STS_ACTIVE) == 0) { 337 if ((token & QTD_STS_ACTIVE) == 0) {
337 338
338 /* on STALL, error, and short reads this urb must 339 /* on STALL, error, and short reads this urb must
339 * complete and all its qtds must be recycled. 340 * complete and all its qtds must be recycled.
340 */ 341 */
341 if ((token & QTD_STS_HALT) != 0) { 342 if ((token & QTD_STS_HALT) != 0) {
343
344 /* retry transaction errors until we
345 * reach the software xacterr limit
346 */
347 if ((token & QTD_STS_XACT) &&
348 QTD_CERR(token) == 0 &&
349 --qh->xacterrs > 0 &&
350 !urb->unlinked) {
351 ehci_dbg(ehci,
352 "detected XactErr len %zu/%zu retry %d\n",
353 qtd->length - QTD_LENGTH(token), qtd->length,
354 QH_XACTERR_MAX - qh->xacterrs);
355
356 /* reset the token in the qtd and the
357 * qh overlay (which still contains
358 * the qtd) so that we pick up from
359 * where we left off
360 */
361 token &= ~QTD_STS_HALT;
362 token |= QTD_STS_ACTIVE |
363 (EHCI_TUNE_CERR << 10);
364 qtd->hw_token = cpu_to_hc32(ehci,
365 token);
366 wmb();
367 qh->hw_token = cpu_to_hc32(ehci, token);
368 goto retry_xacterr;
369 }
342 stopped = 1; 370 stopped = 1;
343 371
344 /* magic dummy for some short reads; qh won't advance. 372 /* magic dummy for some short reads; qh won't advance.
@@ -421,6 +449,9 @@ halt:
421 /* remove qtd; it's recycled after possible urb completion */ 449 /* remove qtd; it's recycled after possible urb completion */
422 list_del (&qtd->qtd_list); 450 list_del (&qtd->qtd_list);
423 last = qtd; 451 last = qtd;
452
453 /* reinit the xacterr counter for the next qtd */
454 qh->xacterrs = QH_XACTERR_MAX;
424 } 455 }
425 456
426 /* last urb's completion might still need calling */ 457 /* last urb's completion might still need calling */
@@ -862,6 +893,7 @@ static void qh_link_async (struct ehci_hcd *ehci, struct ehci_qh *qh)
862 head->qh_next.qh = qh; 893 head->qh_next.qh = qh;
863 head->hw_next = dma; 894 head->hw_next = dma;
864 895
896 qh->xacterrs = QH_XACTERR_MAX;
865 qh->qh_state = QH_STATE_LINKED; 897 qh->qh_state = QH_STATE_LINKED;
866 /* qtd completions reported later by interrupt */ 898 /* qtd completions reported later by interrupt */
867} 899}
diff --git a/drivers/usb/host/ehci-sched.c b/drivers/usb/host/ehci-sched.c
index 1d0b49e3f192..ada5d2ba297b 100644
--- a/drivers/usb/host/ehci-sched.c
+++ b/drivers/usb/host/ehci-sched.c
@@ -563,7 +563,7 @@ static int qh_unlink_periodic(struct ehci_hcd *ehci, struct ehci_qh *qh)
563 // and this qh is active in the current uframe 563 // and this qh is active in the current uframe
564 // (and overlay token SplitXstate is false?) 564 // (and overlay token SplitXstate is false?)
565 // THEN 565 // THEN
566 // qh->hw_info1 |= __constant_cpu_to_hc32(1 << 7 /* "ignore" */); 566 // qh->hw_info1 |= cpu_to_hc32(1 << 7 /* "ignore" */);
567 567
568 /* high bandwidth, or otherwise part of every microframe */ 568 /* high bandwidth, or otherwise part of every microframe */
569 if ((period = qh->period) == 0) 569 if ((period = qh->period) == 0)
diff --git a/drivers/usb/host/ehci.h b/drivers/usb/host/ehci.h
index 262b00c9b334..6cff195e1a36 100644
--- a/drivers/usb/host/ehci.h
+++ b/drivers/usb/host/ehci.h
@@ -190,40 +190,6 @@ timer_action_done (struct ehci_hcd *ehci, enum ehci_timer_action action)
190 clear_bit (action, &ehci->actions); 190 clear_bit (action, &ehci->actions);
191} 191}
192 192
193static inline void
194timer_action (struct ehci_hcd *ehci, enum ehci_timer_action action)
195{
196 /* Don't override timeouts which shrink or (later) disable
197 * the async ring; just the I/O watchdog. Note that if a
198 * SHRINK were pending, OFF would never be requested.
199 */
200 if (timer_pending(&ehci->watchdog)
201 && ((BIT(TIMER_ASYNC_SHRINK) | BIT(TIMER_ASYNC_OFF))
202 & ehci->actions))
203 return;
204
205 if (!test_and_set_bit (action, &ehci->actions)) {
206 unsigned long t;
207
208 switch (action) {
209 case TIMER_IO_WATCHDOG:
210 t = EHCI_IO_JIFFIES;
211 break;
212 case TIMER_ASYNC_OFF:
213 t = EHCI_ASYNC_JIFFIES;
214 break;
215 // case TIMER_ASYNC_SHRINK:
216 default:
217 /* add a jiffie since we synch against the
218 * 8 KHz uframe counter.
219 */
220 t = DIV_ROUND_UP(EHCI_SHRINK_FRAMES * HZ, 1000) + 1;
221 break;
222 }
223 mod_timer(&ehci->watchdog, t + jiffies);
224 }
225}
226
227static void free_cached_itd_list(struct ehci_hcd *ehci); 193static void free_cached_itd_list(struct ehci_hcd *ehci);
228 194
229/*-------------------------------------------------------------------------*/ 195/*-------------------------------------------------------------------------*/
@@ -287,7 +253,7 @@ struct ehci_qtd {
287 253
288/* 254/*
289 * Now the following defines are not converted using the 255 * Now the following defines are not converted using the
290 * __constant_cpu_to_le32() macro anymore, since we have to support 256 * cpu_to_le32() macro anymore, since we have to support
291 * "dynamic" switching between be and le support, so that the driver 257 * "dynamic" switching between be and le support, so that the driver
292 * can be used on one system with SoC EHCI controller using big-endian 258 * can be used on one system with SoC EHCI controller using big-endian
293 * descriptors as well as a normal little-endian PCI EHCI controller. 259 * descriptors as well as a normal little-endian PCI EHCI controller.
@@ -376,6 +342,9 @@ struct ehci_qh {
376#define QH_STATE_UNLINK_WAIT 4 /* LINKED and on reclaim q */ 342#define QH_STATE_UNLINK_WAIT 4 /* LINKED and on reclaim q */
377#define QH_STATE_COMPLETING 5 /* don't touch token.HALT */ 343#define QH_STATE_COMPLETING 5 /* don't touch token.HALT */
378 344
345 u8 xacterrs; /* XactErr retry counter */
346#define QH_XACTERR_MAX 32 /* XactErr retry limit */
347
379 /* periodic schedule info */ 348 /* periodic schedule info */
380 u8 usecs; /* intr bandwidth */ 349 u8 usecs; /* intr bandwidth */
381 u8 gap_uf; /* uframes split/csplit gap */ 350 u8 gap_uf; /* uframes split/csplit gap */
diff --git a/drivers/usb/host/fhci-dbg.c b/drivers/usb/host/fhci-dbg.c
index 34e14edf390b..ea8a4255c5da 100644
--- a/drivers/usb/host/fhci-dbg.c
+++ b/drivers/usb/host/fhci-dbg.c
@@ -108,7 +108,7 @@ void fhci_dfs_create(struct fhci_hcd *fhci)
108{ 108{
109 struct device *dev = fhci_to_hcd(fhci)->self.controller; 109 struct device *dev = fhci_to_hcd(fhci)->self.controller;
110 110
111 fhci->dfs_root = debugfs_create_dir(dev->bus_id, NULL); 111 fhci->dfs_root = debugfs_create_dir(dev_name(dev), NULL);
112 if (!fhci->dfs_root) { 112 if (!fhci->dfs_root) {
113 WARN_ON(1); 113 WARN_ON(1);
114 return; 114 return;
diff --git a/drivers/usb/host/fhci-hcd.c b/drivers/usb/host/fhci-hcd.c
index ba622cc8a9ba..0951818ef93b 100644
--- a/drivers/usb/host/fhci-hcd.c
+++ b/drivers/usb/host/fhci-hcd.c
@@ -583,7 +583,7 @@ static int __devinit of_fhci_probe(struct of_device *ofdev,
583 if (sprop && strcmp(sprop, "host")) 583 if (sprop && strcmp(sprop, "host"))
584 return -ENODEV; 584 return -ENODEV;
585 585
586 hcd = usb_create_hcd(&fhci_driver, dev, dev->bus_id); 586 hcd = usb_create_hcd(&fhci_driver, dev, dev_name(dev));
587 if (!hcd) { 587 if (!hcd) {
588 dev_err(dev, "could not create hcd\n"); 588 dev_err(dev, "could not create hcd\n");
589 return -ENOMEM; 589 return -ENOMEM;
@@ -650,7 +650,7 @@ static int __devinit of_fhci_probe(struct of_device *ofdev,
650 } 650 }
651 } 651 }
652 652
653 ret = gpio_request(gpio, dev->bus_id); 653 ret = gpio_request(gpio, dev_name(dev));
654 if (ret) { 654 if (ret) {
655 dev_err(dev, "failed to request gpio %d", i); 655 dev_err(dev, "failed to request gpio %d", i);
656 goto err_gpios; 656 goto err_gpios;
diff --git a/drivers/usb/host/hwa-hc.c b/drivers/usb/host/hwa-hc.c
index 8582236e4cad..cbf30e515f29 100644
--- a/drivers/usb/host/hwa-hc.c
+++ b/drivers/usb/host/hwa-hc.c
@@ -464,8 +464,7 @@ static int __hwahc_dev_set_key(struct wusbhc *wusbhc, u8 port_idx, u32 tkid,
464 port_idx << 8 | iface_no, 464 port_idx << 8 | iface_no,
465 keyd, keyd_len, 1000 /* FIXME: arbitrary */); 465 keyd, keyd_len, 1000 /* FIXME: arbitrary */);
466 466
467 memset(keyd, 0, sizeof(*keyd)); /* clear keys etc. */ 467 kzfree(keyd); /* clear keys etc. */
468 kfree(keyd);
469 return result; 468 return result;
470} 469}
471 470
diff --git a/drivers/usb/host/isp116x-hcd.c b/drivers/usb/host/isp116x-hcd.c
index 4dda31b26892..a2b305477afe 100644
--- a/drivers/usb/host/isp116x-hcd.c
+++ b/drivers/usb/host/isp116x-hcd.c
@@ -772,7 +772,7 @@ static int isp116x_urb_enqueue(struct usb_hcd *hcd,
772 break; 772 break;
773 case PIPE_INTERRUPT: 773 case PIPE_INTERRUPT:
774 urb->interval = ep->period; 774 urb->interval = ep->period;
775 ep->length = min((int)ep->maxpacket, 775 ep->length = min_t(u32, ep->maxpacket,
776 urb->transfer_buffer_length); 776 urb->transfer_buffer_length);
777 777
778 /* urb submitted for already existing endpoint */ 778 /* urb submitted for already existing endpoint */
diff --git a/drivers/usb/host/isp116x.h b/drivers/usb/host/isp116x.h
index aa211bafcff9..12db961acdfb 100644
--- a/drivers/usb/host/isp116x.h
+++ b/drivers/usb/host/isp116x.h
@@ -563,7 +563,7 @@ static void urb_dbg(struct urb *urb, char *msg)
563*/ 563*/
564static inline void dump_ptd(struct ptd *ptd) 564static inline void dump_ptd(struct ptd *ptd)
565{ 565{
566 printk("td: %x %d%c%d %d,%d,%d %x %x%x%x\n", 566 printk(KERN_WARNING "td: %x %d%c%d %d,%d,%d %x %x%x%x\n",
567 PTD_GET_CC(ptd), PTD_GET_FA(ptd), 567 PTD_GET_CC(ptd), PTD_GET_FA(ptd),
568 PTD_DIR_STR(ptd), PTD_GET_EP(ptd), 568 PTD_DIR_STR(ptd), PTD_GET_EP(ptd),
569 PTD_GET_COUNT(ptd), PTD_GET_LEN(ptd), PTD_GET_MPS(ptd), 569 PTD_GET_COUNT(ptd), PTD_GET_LEN(ptd), PTD_GET_MPS(ptd),
@@ -576,7 +576,7 @@ static inline void dump_ptd_out_data(struct ptd *ptd, u8 * buf)
576 int k; 576 int k;
577 577
578 if (PTD_GET_DIR(ptd) != PTD_DIR_IN && PTD_GET_LEN(ptd)) { 578 if (PTD_GET_DIR(ptd) != PTD_DIR_IN && PTD_GET_LEN(ptd)) {
579 printk("-> "); 579 printk(KERN_WARNING "-> ");
580 for (k = 0; k < PTD_GET_LEN(ptd); ++k) 580 for (k = 0; k < PTD_GET_LEN(ptd); ++k)
581 printk("%02x ", ((u8 *) buf)[k]); 581 printk("%02x ", ((u8 *) buf)[k]);
582 printk("\n"); 582 printk("\n");
@@ -588,13 +588,13 @@ static inline void dump_ptd_in_data(struct ptd *ptd, u8 * buf)
588 int k; 588 int k;
589 589
590 if (PTD_GET_DIR(ptd) == PTD_DIR_IN && PTD_GET_COUNT(ptd)) { 590 if (PTD_GET_DIR(ptd) == PTD_DIR_IN && PTD_GET_COUNT(ptd)) {
591 printk("<- "); 591 printk(KERN_WARNING "<- ");
592 for (k = 0; k < PTD_GET_COUNT(ptd); ++k) 592 for (k = 0; k < PTD_GET_COUNT(ptd); ++k)
593 printk("%02x ", ((u8 *) buf)[k]); 593 printk("%02x ", ((u8 *) buf)[k]);
594 printk("\n"); 594 printk("\n");
595 } 595 }
596 if (PTD_GET_LAST(ptd)) 596 if (PTD_GET_LAST(ptd))
597 printk("-\n"); 597 printk(KERN_WARNING "-\n");
598} 598}
599 599
600#else 600#else
diff --git a/drivers/usb/host/isp1760-hcd.c b/drivers/usb/host/isp1760-hcd.c
index b899f1a59c26..cd07ea3f0c63 100644
--- a/drivers/usb/host/isp1760-hcd.c
+++ b/drivers/usb/host/isp1760-hcd.c
@@ -644,7 +644,7 @@ static void transform_add_int(struct isp1760_hcd *priv, struct isp1760_qh *qh,
644 644
645 if (urb->dev->speed != USB_SPEED_HIGH) { 645 if (urb->dev->speed != USB_SPEED_HIGH) {
646 /* split */ 646 /* split */
647 ptd->dw5 = __constant_cpu_to_le32(0x1c); 647 ptd->dw5 = cpu_to_le32(0x1c);
648 648
649 if (qh->period >= 32) 649 if (qh->period >= 32)
650 period = qh->period / 2; 650 period = qh->period / 2;
@@ -819,6 +819,13 @@ static void enqueue_an_ATL_packet(struct usb_hcd *hcd, struct isp1760_qh *qh,
819 u32 atl_regs, payload; 819 u32 atl_regs, payload;
820 u32 buffstatus; 820 u32 buffstatus;
821 821
822 /*
823 * When this function is called from the interrupt handler to enqueue
824 * a follow-up packet, the SKIP register gets written and read back
825 * almost immediately. With ISP1761, this register requires a delay of
826 * 195ns between a write and subsequent read (see section 15.1.1.3).
827 */
828 ndelay(195);
822 skip_map = isp1760_readl(hcd->regs + HC_ATL_PTD_SKIPMAP_REG); 829 skip_map = isp1760_readl(hcd->regs + HC_ATL_PTD_SKIPMAP_REG);
823 830
824 BUG_ON(!skip_map); 831 BUG_ON(!skip_map);
@@ -853,6 +860,13 @@ static void enqueue_an_INT_packet(struct usb_hcd *hcd, struct isp1760_qh *qh,
853 u32 int_regs, payload; 860 u32 int_regs, payload;
854 u32 buffstatus; 861 u32 buffstatus;
855 862
863 /*
864 * When this function is called from the interrupt handler to enqueue
865 * a follow-up packet, the SKIP register gets written and read back
866 * almost immediately. With ISP1761, this register requires a delay of
867 * 195ns between a write and subsequent read (see section 15.1.1.3).
868 */
869 ndelay(195);
856 skip_map = isp1760_readl(hcd->regs + HC_INT_PTD_SKIPMAP_REG); 870 skip_map = isp1760_readl(hcd->regs + HC_INT_PTD_SKIPMAP_REG);
857 871
858 BUG_ON(!skip_map); 872 BUG_ON(!skip_map);
@@ -1054,7 +1068,7 @@ static void do_atl_int(struct usb_hcd *usb_hcd)
1054 priv_write_copy(priv, (u32 *)&ptd, usb_hcd->regs + 1068 priv_write_copy(priv, (u32 *)&ptd, usb_hcd->regs +
1055 atl_regs, sizeof(ptd)); 1069 atl_regs, sizeof(ptd));
1056 1070
1057 ptd.dw0 |= __constant_cpu_to_le32(PTD_VALID); 1071 ptd.dw0 |= cpu_to_le32(PTD_VALID);
1058 priv_write_copy(priv, (u32 *)&ptd, usb_hcd->regs + 1072 priv_write_copy(priv, (u32 *)&ptd, usb_hcd->regs +
1059 atl_regs, sizeof(ptd)); 1073 atl_regs, sizeof(ptd));
1060 1074
@@ -2235,9 +2249,10 @@ void deinit_kmem_cache(void)
2235 kmem_cache_destroy(qh_cachep); 2249 kmem_cache_destroy(qh_cachep);
2236} 2250}
2237 2251
2238struct usb_hcd *isp1760_register(u64 res_start, u64 res_len, int irq, 2252struct usb_hcd *isp1760_register(phys_addr_t res_start, resource_size_t res_len,
2239 u64 irqflags, struct device *dev, const char *busname, 2253 int irq, unsigned long irqflags,
2240 unsigned int devflags) 2254 struct device *dev, const char *busname,
2255 unsigned int devflags)
2241{ 2256{
2242 struct usb_hcd *hcd; 2257 struct usb_hcd *hcd;
2243 struct isp1760_hcd *priv; 2258 struct isp1760_hcd *priv;
diff --git a/drivers/usb/host/isp1760-hcd.h b/drivers/usb/host/isp1760-hcd.h
index a9daea587962..462f4943cb1b 100644
--- a/drivers/usb/host/isp1760-hcd.h
+++ b/drivers/usb/host/isp1760-hcd.h
@@ -2,9 +2,10 @@
2#define _ISP1760_HCD_H_ 2#define _ISP1760_HCD_H_
3 3
4/* exports for if */ 4/* exports for if */
5struct usb_hcd *isp1760_register(u64 res_start, u64 res_len, int irq, 5struct usb_hcd *isp1760_register(phys_addr_t res_start, resource_size_t res_len,
6 u64 irqflags, struct device *dev, const char *busname, 6 int irq, unsigned long irqflags,
7 unsigned int devflags); 7 struct device *dev, const char *busname,
8 unsigned int devflags);
8int init_kmem_once(void); 9int init_kmem_once(void);
9void deinit_kmem_cache(void); 10void deinit_kmem_cache(void);
10 11
diff --git a/drivers/usb/host/isp1760-if.c b/drivers/usb/host/isp1760-if.c
index 4cf7ca428b33..3fa3a1702796 100644
--- a/drivers/usb/host/isp1760-if.c
+++ b/drivers/usb/host/isp1760-if.c
@@ -10,6 +10,7 @@
10 10
11#include <linux/usb.h> 11#include <linux/usb.h>
12#include <linux/io.h> 12#include <linux/io.h>
13#include <linux/platform_device.h>
13 14
14#include "../core/hcd.h" 15#include "../core/hcd.h"
15#include "isp1760-hcd.h" 16#include "isp1760-hcd.h"
@@ -300,39 +301,101 @@ static struct pci_driver isp1761_pci_driver = {
300}; 301};
301#endif 302#endif
302 303
304static int __devinit isp1760_plat_probe(struct platform_device *pdev)
305{
306 int ret = 0;
307 struct usb_hcd *hcd;
308 struct resource *mem_res;
309 struct resource *irq_res;
310 resource_size_t mem_size;
311 unsigned long irqflags = IRQF_SHARED | IRQF_DISABLED;
312
313 mem_res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
314 if (!mem_res) {
315 pr_warning("isp1760: Memory resource not available\n");
316 ret = -ENODEV;
317 goto out;
318 }
319 mem_size = resource_size(mem_res);
320 if (!request_mem_region(mem_res->start, mem_size, "isp1760")) {
321 pr_warning("isp1760: Cannot reserve the memory resource\n");
322 ret = -EBUSY;
323 goto out;
324 }
325
326 irq_res = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
327 if (!irq_res) {
328 pr_warning("isp1760: IRQ resource not available\n");
329 return -ENODEV;
330 }
331 irqflags |= irq_res->flags & IRQF_TRIGGER_MASK;
332
333 hcd = isp1760_register(mem_res->start, mem_size, irq_res->start,
334 irqflags, &pdev->dev, dev_name(&pdev->dev), 0);
335 if (IS_ERR(hcd)) {
336 pr_warning("isp1760: Failed to register the HCD device\n");
337 ret = -ENODEV;
338 goto cleanup;
339 }
340
341 pr_info("ISP1760 USB device initialised\n");
342 return ret;
343
344cleanup:
345 release_mem_region(mem_res->start, mem_size);
346out:
347 return ret;
348}
349
350static int __devexit isp1760_plat_remove(struct platform_device *pdev)
351{
352 struct resource *mem_res;
353 resource_size_t mem_size;
354
355 mem_res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
356 mem_size = resource_size(mem_res);
357 release_mem_region(mem_res->start, mem_size);
358
359 return 0;
360}
361
362static struct platform_driver isp1760_plat_driver = {
363 .probe = isp1760_plat_probe,
364 .remove = isp1760_plat_remove,
365 .driver = {
366 .name = "isp1760",
367 },
368};
369
303static int __init isp1760_init(void) 370static int __init isp1760_init(void)
304{ 371{
305 int ret; 372 int ret, any_ret = -ENODEV;
306 373
307 init_kmem_once(); 374 init_kmem_once();
308 375
376 ret = platform_driver_register(&isp1760_plat_driver);
377 if (!ret)
378 any_ret = 0;
309#ifdef CONFIG_PPC_OF 379#ifdef CONFIG_PPC_OF
310 ret = of_register_platform_driver(&isp1760_of_driver); 380 ret = of_register_platform_driver(&isp1760_of_driver);
311 if (ret) { 381 if (!ret)
312 deinit_kmem_cache(); 382 any_ret = 0;
313 return ret;
314 }
315#endif 383#endif
316#ifdef CONFIG_PCI 384#ifdef CONFIG_PCI
317 ret = pci_register_driver(&isp1761_pci_driver); 385 ret = pci_register_driver(&isp1761_pci_driver);
318 if (ret) 386 if (!ret)
319 goto unreg_of; 387 any_ret = 0;
320#endif 388#endif
321 return ret;
322 389
323#ifdef CONFIG_PCI 390 if (any_ret)
324unreg_of: 391 deinit_kmem_cache();
325#endif 392 return any_ret;
326#ifdef CONFIG_PPC_OF
327 of_unregister_platform_driver(&isp1760_of_driver);
328#endif
329 deinit_kmem_cache();
330 return ret;
331} 393}
332module_init(isp1760_init); 394module_init(isp1760_init);
333 395
334static void __exit isp1760_exit(void) 396static void __exit isp1760_exit(void)
335{ 397{
398 platform_driver_unregister(&isp1760_plat_driver);
336#ifdef CONFIG_PPC_OF 399#ifdef CONFIG_PPC_OF
337 of_unregister_platform_driver(&isp1760_of_driver); 400 of_unregister_platform_driver(&isp1760_of_driver);
338#endif 401#endif
diff --git a/drivers/usb/host/ohci-hcd.c b/drivers/usb/host/ohci-hcd.c
index 5cf5f1eca4f4..25db704f3a2a 100644
--- a/drivers/usb/host/ohci-hcd.c
+++ b/drivers/usb/host/ohci-hcd.c
@@ -997,7 +997,7 @@ MODULE_LICENSE ("GPL");
997#define SA1111_DRIVER ohci_hcd_sa1111_driver 997#define SA1111_DRIVER ohci_hcd_sa1111_driver
998#endif 998#endif
999 999
1000#ifdef CONFIG_ARCH_S3C2410 1000#if defined(CONFIG_ARCH_S3C2410) || defined(CONFIG_ARCH_S3C64XX)
1001#include "ohci-s3c2410.c" 1001#include "ohci-s3c2410.c"
1002#define PLATFORM_DRIVER ohci_hcd_s3c2410_driver 1002#define PLATFORM_DRIVER ohci_hcd_s3c2410_driver
1003#endif 1003#endif
@@ -1049,7 +1049,8 @@ MODULE_LICENSE ("GPL");
1049 1049
1050#if defined(CONFIG_CPU_SUBTYPE_SH7720) || \ 1050#if defined(CONFIG_CPU_SUBTYPE_SH7720) || \
1051 defined(CONFIG_CPU_SUBTYPE_SH7721) || \ 1051 defined(CONFIG_CPU_SUBTYPE_SH7721) || \
1052 defined(CONFIG_CPU_SUBTYPE_SH7763) 1052 defined(CONFIG_CPU_SUBTYPE_SH7763) || \
1053 defined(CONFIG_CPU_SUBTYPE_SH7786)
1053#include "ohci-sh.c" 1054#include "ohci-sh.c"
1054#define PLATFORM_DRIVER ohci_hcd_sh_driver 1055#define PLATFORM_DRIVER ohci_hcd_sh_driver
1055#endif 1056#endif
diff --git a/drivers/usb/host/ohci-s3c2410.c b/drivers/usb/host/ohci-s3c2410.c
index f46af7a718d4..a68af2dd55ca 100644
--- a/drivers/usb/host/ohci-s3c2410.c
+++ b/drivers/usb/host/ohci-s3c2410.c
@@ -21,9 +21,7 @@
21 21
22#include <linux/platform_device.h> 22#include <linux/platform_device.h>
23#include <linux/clk.h> 23#include <linux/clk.h>
24 24#include <plat/usb-control.h>
25#include <mach/hardware.h>
26#include <mach/usb-control.h>
27 25
28#define valid_port(idx) ((idx) == 1 || (idx) == 2) 26#define valid_port(idx) ((idx) == 1 || (idx) == 2)
29 27
@@ -372,7 +370,7 @@ static int usb_hcd_s3c2410_probe (const struct hc_driver *driver,
372 370
373 usb_clk = clk_get(&dev->dev, "usb-bus-host"); 371 usb_clk = clk_get(&dev->dev, "usb-bus-host");
374 if (IS_ERR(usb_clk)) { 372 if (IS_ERR(usb_clk)) {
375 dev_err(&dev->dev, "cannot get usb-host clock\n"); 373 dev_err(&dev->dev, "cannot get usb-bus-host clock\n");
376 retval = -ENOENT; 374 retval = -ENOENT;
377 goto err_clk; 375 goto err_clk;
378 } 376 }
diff --git a/drivers/usb/host/oxu210hp-hcd.c b/drivers/usb/host/oxu210hp-hcd.c
index 75548f7c716b..5ac489ee3dab 100644
--- a/drivers/usb/host/oxu210hp-hcd.c
+++ b/drivers/usb/host/oxu210hp-hcd.c
@@ -845,14 +845,14 @@ static inline void qh_update(struct oxu_hcd *oxu,
845 is_out = !(qtd->hw_token & cpu_to_le32(1 << 8)); 845 is_out = !(qtd->hw_token & cpu_to_le32(1 << 8));
846 epnum = (le32_to_cpup(&qh->hw_info1) >> 8) & 0x0f; 846 epnum = (le32_to_cpup(&qh->hw_info1) >> 8) & 0x0f;
847 if (unlikely(!usb_gettoggle(qh->dev, epnum, is_out))) { 847 if (unlikely(!usb_gettoggle(qh->dev, epnum, is_out))) {
848 qh->hw_token &= ~__constant_cpu_to_le32(QTD_TOGGLE); 848 qh->hw_token &= ~cpu_to_le32(QTD_TOGGLE);
849 usb_settoggle(qh->dev, epnum, is_out, 1); 849 usb_settoggle(qh->dev, epnum, is_out, 1);
850 } 850 }
851 } 851 }
852 852
853 /* HC must see latest qtd and qh data before we clear ACTIVE+HALT */ 853 /* HC must see latest qtd and qh data before we clear ACTIVE+HALT */
854 wmb(); 854 wmb();
855 qh->hw_token &= __constant_cpu_to_le32(QTD_TOGGLE | QTD_STS_PING); 855 qh->hw_token &= cpu_to_le32(QTD_TOGGLE | QTD_STS_PING);
856} 856}
857 857
858/* If it weren't for a common silicon quirk (writing the dummy into the qh 858/* If it weren't for a common silicon quirk (writing the dummy into the qh
@@ -937,7 +937,7 @@ __acquires(oxu->lock)
937 struct ehci_qh *qh = (struct ehci_qh *) urb->hcpriv; 937 struct ehci_qh *qh = (struct ehci_qh *) urb->hcpriv;
938 938
939 /* S-mask in a QH means it's an interrupt urb */ 939 /* S-mask in a QH means it's an interrupt urb */
940 if ((qh->hw_info2 & __constant_cpu_to_le32(QH_SMASK)) != 0) { 940 if ((qh->hw_info2 & cpu_to_le32(QH_SMASK)) != 0) {
941 941
942 /* ... update hc-wide periodic stats (for usbfs) */ 942 /* ... update hc-wide periodic stats (for usbfs) */
943 oxu_to_hcd(oxu)->self.bandwidth_int_reqs--; 943 oxu_to_hcd(oxu)->self.bandwidth_int_reqs--;
@@ -981,7 +981,7 @@ static void unlink_async(struct oxu_hcd *oxu, struct ehci_qh *qh);
981static void intr_deschedule(struct oxu_hcd *oxu, struct ehci_qh *qh); 981static void intr_deschedule(struct oxu_hcd *oxu, struct ehci_qh *qh);
982static int qh_schedule(struct oxu_hcd *oxu, struct ehci_qh *qh); 982static int qh_schedule(struct oxu_hcd *oxu, struct ehci_qh *qh);
983 983
984#define HALT_BIT __constant_cpu_to_le32(QTD_STS_HALT) 984#define HALT_BIT cpu_to_le32(QTD_STS_HALT)
985 985
986/* Process and free completed qtds for a qh, returning URBs to drivers. 986/* Process and free completed qtds for a qh, returning URBs to drivers.
987 * Chases up to qh->hw_current. Returns number of completions called, 987 * Chases up to qh->hw_current. Returns number of completions called,
@@ -1160,7 +1160,7 @@ halt:
1160 /* should be rare for periodic transfers, 1160 /* should be rare for periodic transfers,
1161 * except maybe high bandwidth ... 1161 * except maybe high bandwidth ...
1162 */ 1162 */
1163 if ((__constant_cpu_to_le32(QH_SMASK) 1163 if ((cpu_to_le32(QH_SMASK)
1164 & qh->hw_info2) != 0) { 1164 & qh->hw_info2) != 0) {
1165 intr_deschedule(oxu, qh); 1165 intr_deschedule(oxu, qh);
1166 (void) qh_schedule(oxu, qh); 1166 (void) qh_schedule(oxu, qh);
@@ -1350,7 +1350,7 @@ static struct list_head *qh_urb_transaction(struct oxu_hcd *oxu,
1350 } 1350 }
1351 1351
1352 /* by default, enable interrupt on urb completion */ 1352 /* by default, enable interrupt on urb completion */
1353 qtd->hw_token |= __constant_cpu_to_le32(QTD_IOC); 1353 qtd->hw_token |= cpu_to_le32(QTD_IOC);
1354 return head; 1354 return head;
1355 1355
1356cleanup: 1356cleanup:
@@ -1539,7 +1539,7 @@ static void qh_link_async(struct oxu_hcd *oxu, struct ehci_qh *qh)
1539 /* qtd completions reported later by interrupt */ 1539 /* qtd completions reported later by interrupt */
1540} 1540}
1541 1541
1542#define QH_ADDR_MASK __constant_cpu_to_le32(0x7f) 1542#define QH_ADDR_MASK cpu_to_le32(0x7f)
1543 1543
1544/* 1544/*
1545 * For control/bulk/interrupt, return QH with these TDs appended. 1545 * For control/bulk/interrupt, return QH with these TDs appended.
@@ -2012,7 +2012,7 @@ static void qh_unlink_periodic(struct oxu_hcd *oxu, struct ehci_qh *qh)
2012 * and this qh is active in the current uframe 2012 * and this qh is active in the current uframe
2013 * (and overlay token SplitXstate is false?) 2013 * (and overlay token SplitXstate is false?)
2014 * THEN 2014 * THEN
2015 * qh->hw_info1 |= __constant_cpu_to_le32(1 << 7 "ignore"); 2015 * qh->hw_info1 |= cpu_to_le32(1 << 7 "ignore");
2016 */ 2016 */
2017 2017
2018 /* high bandwidth, or otherwise part of every microframe */ 2018 /* high bandwidth, or otherwise part of every microframe */
@@ -2057,7 +2057,7 @@ static void intr_deschedule(struct oxu_hcd *oxu, struct ehci_qh *qh)
2057 * active high speed queues may need bigger delays... 2057 * active high speed queues may need bigger delays...
2058 */ 2058 */
2059 if (list_empty(&qh->qtd_list) 2059 if (list_empty(&qh->qtd_list)
2060 || (__constant_cpu_to_le32(QH_CMASK) & qh->hw_info2) != 0) 2060 || (cpu_to_le32(QH_CMASK) & qh->hw_info2) != 0)
2061 wait = 2; 2061 wait = 2;
2062 else 2062 else
2063 wait = 55; /* worst case: 3 * 1024 */ 2063 wait = 55; /* worst case: 3 * 1024 */
@@ -2183,10 +2183,10 @@ static int qh_schedule(struct oxu_hcd *oxu, struct ehci_qh *qh)
2183 qh->start = frame; 2183 qh->start = frame;
2184 2184
2185 /* reset S-frame and (maybe) C-frame masks */ 2185 /* reset S-frame and (maybe) C-frame masks */
2186 qh->hw_info2 &= __constant_cpu_to_le32(~(QH_CMASK | QH_SMASK)); 2186 qh->hw_info2 &= cpu_to_le32(~(QH_CMASK | QH_SMASK));
2187 qh->hw_info2 |= qh->period 2187 qh->hw_info2 |= qh->period
2188 ? cpu_to_le32(1 << uframe) 2188 ? cpu_to_le32(1 << uframe)
2189 : __constant_cpu_to_le32(QH_SMASK); 2189 : cpu_to_le32(QH_SMASK);
2190 qh->hw_info2 |= c_mask; 2190 qh->hw_info2 |= c_mask;
2191 } else 2191 } else
2192 oxu_dbg(oxu, "reused qh %p schedule\n", qh); 2192 oxu_dbg(oxu, "reused qh %p schedule\n", qh);
@@ -2684,7 +2684,7 @@ static int oxu_reset(struct usb_hcd *hcd)
2684 oxu->urb_len = 0; 2684 oxu->urb_len = 0;
2685 2685
2686 /* FIMXE */ 2686 /* FIMXE */
2687 hcd->self.controller->dma_mask = 0UL; 2687 hcd->self.controller->dma_mask = NULL;
2688 2688
2689 if (oxu->is_otg) { 2689 if (oxu->is_otg) {
2690 oxu->caps = hcd->regs + OXU_OTG_CAP_OFFSET; 2690 oxu->caps = hcd->regs + OXU_OTG_CAP_OFFSET;
diff --git a/drivers/usb/host/oxu210hp.h b/drivers/usb/host/oxu210hp.h
index 8910e271cc7d..1c216ad9aad2 100644
--- a/drivers/usb/host/oxu210hp.h
+++ b/drivers/usb/host/oxu210hp.h
@@ -235,21 +235,21 @@ struct ehci_qtd {
235} __attribute__ ((aligned(32))); 235} __attribute__ ((aligned(32)));
236 236
237/* mask NakCnt+T in qh->hw_alt_next */ 237/* mask NakCnt+T in qh->hw_alt_next */
238#define QTD_MASK __constant_cpu_to_le32 (~0x1f) 238#define QTD_MASK cpu_to_le32 (~0x1f)
239 239
240#define IS_SHORT_READ(token) (QTD_LENGTH(token) != 0 && QTD_PID(token) == 1) 240#define IS_SHORT_READ(token) (QTD_LENGTH(token) != 0 && QTD_PID(token) == 1)
241 241
242/* Type tag from {qh, itd, sitd, fstn}->hw_next */ 242/* Type tag from {qh, itd, sitd, fstn}->hw_next */
243#define Q_NEXT_TYPE(dma) ((dma) & __constant_cpu_to_le32 (3 << 1)) 243#define Q_NEXT_TYPE(dma) ((dma) & cpu_to_le32 (3 << 1))
244 244
245/* values for that type tag */ 245/* values for that type tag */
246#define Q_TYPE_QH __constant_cpu_to_le32 (1 << 1) 246#define Q_TYPE_QH cpu_to_le32 (1 << 1)
247 247
248/* next async queue entry, or pointer to interrupt/periodic QH */ 248/* next async queue entry, or pointer to interrupt/periodic QH */
249#define QH_NEXT(dma) (cpu_to_le32(((u32)dma)&~0x01f)|Q_TYPE_QH) 249#define QH_NEXT(dma) (cpu_to_le32(((u32)dma)&~0x01f)|Q_TYPE_QH)
250 250
251/* for periodic/async schedules and qtd lists, mark end of list */ 251/* for periodic/async schedules and qtd lists, mark end of list */
252#define EHCI_LIST_END __constant_cpu_to_le32(1) /* "null pointer" to hw */ 252#define EHCI_LIST_END cpu_to_le32(1) /* "null pointer" to hw */
253 253
254/* 254/*
255 * Entries in periodic shadow table are pointers to one of four kinds 255 * Entries in periodic shadow table are pointers to one of four kinds
diff --git a/drivers/usb/host/pci-quirks.c b/drivers/usb/host/pci-quirks.c
index 75b69847918e..033c2846ce59 100644
--- a/drivers/usb/host/pci-quirks.c
+++ b/drivers/usb/host/pci-quirks.c
@@ -234,7 +234,7 @@ static void __devinit quirk_usb_disable_ehci(struct pci_dev *pdev)
234 */ 234 */
235 hcc_params = readl(base + EHCI_HCC_PARAMS); 235 hcc_params = readl(base + EHCI_HCC_PARAMS);
236 offset = (hcc_params >> 8) & 0xff; 236 offset = (hcc_params >> 8) & 0xff;
237 while (offset && count--) { 237 while (offset && --count) {
238 u32 cap; 238 u32 cap;
239 int msec; 239 int msec;
240 240
diff --git a/drivers/usb/host/r8a66597-hcd.c b/drivers/usb/host/r8a66597-hcd.c
index 319041205b57..f1626e58c141 100644
--- a/drivers/usb/host/r8a66597-hcd.c
+++ b/drivers/usb/host/r8a66597-hcd.c
@@ -660,9 +660,9 @@ static u16 get_empty_pipenum(struct r8a66597 *r8a66597,
660 u16 array[R8A66597_MAX_NUM_PIPE], i = 0, min; 660 u16 array[R8A66597_MAX_NUM_PIPE], i = 0, min;
661 661
662 memset(array, 0, sizeof(array)); 662 memset(array, 0, sizeof(array));
663 switch (ep->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) { 663 switch (usb_endpoint_type(ep)) {
664 case USB_ENDPOINT_XFER_BULK: 664 case USB_ENDPOINT_XFER_BULK:
665 if (ep->bEndpointAddress & USB_ENDPOINT_DIR_MASK) 665 if (usb_endpoint_dir_in(ep))
666 array[i++] = 4; 666 array[i++] = 4;
667 else { 667 else {
668 array[i++] = 3; 668 array[i++] = 3;
@@ -670,7 +670,7 @@ static u16 get_empty_pipenum(struct r8a66597 *r8a66597,
670 } 670 }
671 break; 671 break;
672 case USB_ENDPOINT_XFER_INT: 672 case USB_ENDPOINT_XFER_INT:
673 if (ep->bEndpointAddress & USB_ENDPOINT_DIR_MASK) { 673 if (usb_endpoint_dir_in(ep)) {
674 array[i++] = 6; 674 array[i++] = 6;
675 array[i++] = 7; 675 array[i++] = 7;
676 array[i++] = 8; 676 array[i++] = 8;
@@ -678,7 +678,7 @@ static u16 get_empty_pipenum(struct r8a66597 *r8a66597,
678 array[i++] = 9; 678 array[i++] = 9;
679 break; 679 break;
680 case USB_ENDPOINT_XFER_ISOC: 680 case USB_ENDPOINT_XFER_ISOC:
681 if (ep->bEndpointAddress & USB_ENDPOINT_DIR_MASK) 681 if (usb_endpoint_dir_in(ep))
682 array[i++] = 2; 682 array[i++] = 2;
683 else 683 else
684 array[i++] = 1; 684 array[i++] = 1;
@@ -928,10 +928,9 @@ static void init_pipe_info(struct r8a66597 *r8a66597, struct urb *urb,
928 928
929 info.pipenum = get_empty_pipenum(r8a66597, ep); 929 info.pipenum = get_empty_pipenum(r8a66597, ep);
930 info.address = get_urb_to_r8a66597_addr(r8a66597, urb); 930 info.address = get_urb_to_r8a66597_addr(r8a66597, urb);
931 info.epnum = ep->bEndpointAddress & USB_ENDPOINT_NUMBER_MASK; 931 info.epnum = usb_endpoint_num(ep);
932 info.maxpacket = le16_to_cpu(ep->wMaxPacketSize); 932 info.maxpacket = le16_to_cpu(ep->wMaxPacketSize);
933 info.type = get_r8a66597_type(ep->bmAttributes 933 info.type = get_r8a66597_type(usb_endpoint_type(ep));
934 & USB_ENDPOINT_XFERTYPE_MASK);
935 info.bufnum = get_bufnum(info.pipenum); 934 info.bufnum = get_bufnum(info.pipenum);
936 info.buf_bsize = get_buf_bsize(info.pipenum); 935 info.buf_bsize = get_buf_bsize(info.pipenum);
937 if (info.type == R8A66597_BULK) { 936 if (info.type == R8A66597_BULK) {
@@ -941,7 +940,7 @@ static void init_pipe_info(struct r8a66597 *r8a66597, struct urb *urb,
941 info.interval = get_interval(urb, ep->bInterval); 940 info.interval = get_interval(urb, ep->bInterval);
942 info.timer_interval = get_timer_interval(urb, ep->bInterval); 941 info.timer_interval = get_timer_interval(urb, ep->bInterval);
943 } 942 }
944 if (ep->bEndpointAddress & USB_ENDPOINT_DIR_MASK) 943 if (usb_endpoint_dir_in(ep))
945 info.dir_in = 1; 944 info.dir_in = 1;
946 else 945 else
947 info.dir_in = 0; 946 info.dir_in = 0;
@@ -1014,6 +1013,9 @@ static void r8a66597_check_syssts(struct r8a66597 *r8a66597, int port,
1014 1013
1015 r8a66597_write(r8a66597, ~DTCH, get_intsts_reg(port)); 1014 r8a66597_write(r8a66597, ~DTCH, get_intsts_reg(port));
1016 r8a66597_bset(r8a66597, DTCHE, get_intenb_reg(port)); 1015 r8a66597_bset(r8a66597, DTCHE, get_intenb_reg(port));
1016
1017 if (r8a66597->bus_suspended)
1018 usb_hcd_resume_root_hub(r8a66597_to_hcd(r8a66597));
1017} 1019}
1018 1020
1019/* this function must be called with interrupt disabled */ 1021/* this function must be called with interrupt disabled */
@@ -1395,7 +1397,7 @@ static void packet_write(struct r8a66597 *r8a66597, u16 pipenum)
1395 (int)urb->iso_frame_desc[td->iso_cnt].length); 1397 (int)urb->iso_frame_desc[td->iso_cnt].length);
1396 } else { 1398 } else {
1397 buf = (u16 *)(urb->transfer_buffer + urb->actual_length); 1399 buf = (u16 *)(urb->transfer_buffer + urb->actual_length);
1398 size = min((int)bufsize, 1400 size = min_t(u32, bufsize,
1399 urb->transfer_buffer_length - urb->actual_length); 1401 urb->transfer_buffer_length - urb->actual_length);
1400 } 1402 }
1401 1403
@@ -1615,6 +1617,11 @@ static irqreturn_t r8a66597_irq(struct usb_hcd *hcd)
1615 r8a66597_bclr(r8a66597, DTCHE, INTENB2); 1617 r8a66597_bclr(r8a66597, DTCHE, INTENB2);
1616 r8a66597_usb_disconnect(r8a66597, 1); 1618 r8a66597_usb_disconnect(r8a66597, 1);
1617 } 1619 }
1620 if (mask2 & BCHG) {
1621 r8a66597_write(r8a66597, ~BCHG, INTSTS2);
1622 r8a66597_bclr(r8a66597, BCHGE, INTENB2);
1623 usb_hcd_resume_root_hub(r8a66597_to_hcd(r8a66597));
1624 }
1618 } 1625 }
1619 1626
1620 if (mask1) { 1627 if (mask1) {
@@ -1630,6 +1637,12 @@ static irqreturn_t r8a66597_irq(struct usb_hcd *hcd)
1630 r8a66597_bclr(r8a66597, DTCHE, INTENB1); 1637 r8a66597_bclr(r8a66597, DTCHE, INTENB1);
1631 r8a66597_usb_disconnect(r8a66597, 0); 1638 r8a66597_usb_disconnect(r8a66597, 0);
1632 } 1639 }
1640 if (mask1 & BCHG) {
1641 r8a66597_write(r8a66597, ~BCHG, INTSTS1);
1642 r8a66597_bclr(r8a66597, BCHGE, INTENB1);
1643 usb_hcd_resume_root_hub(r8a66597_to_hcd(r8a66597));
1644 }
1645
1633 if (mask1 & SIGN) { 1646 if (mask1 & SIGN) {
1634 r8a66597_write(r8a66597, ~SIGN, INTSTS1); 1647 r8a66597_write(r8a66597, ~SIGN, INTSTS1);
1635 status = get_urb_error(r8a66597, 0); 1648 status = get_urb_error(r8a66597, 0);
@@ -2141,7 +2154,7 @@ static int r8a66597_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue,
2141 2154
2142 switch (wValue) { 2155 switch (wValue) {
2143 case USB_PORT_FEAT_ENABLE: 2156 case USB_PORT_FEAT_ENABLE:
2144 rh->port &= (1 << USB_PORT_FEAT_POWER); 2157 rh->port &= ~(1 << USB_PORT_FEAT_POWER);
2145 break; 2158 break;
2146 case USB_PORT_FEAT_SUSPEND: 2159 case USB_PORT_FEAT_SUSPEND:
2147 break; 2160 break;
@@ -2213,6 +2226,68 @@ error:
2213 return ret; 2226 return ret;
2214} 2227}
2215 2228
2229#if defined(CONFIG_PM)
2230static int r8a66597_bus_suspend(struct usb_hcd *hcd)
2231{
2232 struct r8a66597 *r8a66597 = hcd_to_r8a66597(hcd);
2233 int port;
2234
2235 dbg("%s", __func__);
2236
2237 for (port = 0; port < R8A66597_MAX_ROOT_HUB; port++) {
2238 struct r8a66597_root_hub *rh = &r8a66597->root_hub[port];
2239 unsigned long dvstctr_reg = get_dvstctr_reg(port);
2240
2241 if (!(rh->port & (1 << USB_PORT_FEAT_ENABLE)))
2242 continue;
2243
2244 dbg("suspend port = %d", port);
2245 r8a66597_bclr(r8a66597, UACT, dvstctr_reg); /* suspend */
2246 rh->port |= 1 << USB_PORT_FEAT_SUSPEND;
2247
2248 if (rh->dev->udev->do_remote_wakeup) {
2249 msleep(3); /* waiting last SOF */
2250 r8a66597_bset(r8a66597, RWUPE, dvstctr_reg);
2251 r8a66597_write(r8a66597, ~BCHG, get_intsts_reg(port));
2252 r8a66597_bset(r8a66597, BCHGE, get_intenb_reg(port));
2253 }
2254 }
2255
2256 r8a66597->bus_suspended = 1;
2257
2258 return 0;
2259}
2260
2261static int r8a66597_bus_resume(struct usb_hcd *hcd)
2262{
2263 struct r8a66597 *r8a66597 = hcd_to_r8a66597(hcd);
2264 int port;
2265
2266 dbg("%s", __func__);
2267
2268 for (port = 0; port < R8A66597_MAX_ROOT_HUB; port++) {
2269 struct r8a66597_root_hub *rh = &r8a66597->root_hub[port];
2270 unsigned long dvstctr_reg = get_dvstctr_reg(port);
2271
2272 if (!(rh->port & (1 << USB_PORT_FEAT_SUSPEND)))
2273 continue;
2274
2275 dbg("resume port = %d", port);
2276 rh->port &= ~(1 << USB_PORT_FEAT_SUSPEND);
2277 rh->port |= 1 << USB_PORT_FEAT_C_SUSPEND;
2278 r8a66597_mdfy(r8a66597, RESUME, RESUME | UACT, dvstctr_reg);
2279 msleep(50);
2280 r8a66597_mdfy(r8a66597, UACT, RESUME | UACT, dvstctr_reg);
2281 }
2282
2283 return 0;
2284
2285}
2286#else
2287#define r8a66597_bus_suspend NULL
2288#define r8a66597_bus_resume NULL
2289#endif
2290
2216static struct hc_driver r8a66597_hc_driver = { 2291static struct hc_driver r8a66597_hc_driver = {
2217 .description = hcd_name, 2292 .description = hcd_name,
2218 .hcd_priv_size = sizeof(struct r8a66597), 2293 .hcd_priv_size = sizeof(struct r8a66597),
@@ -2243,16 +2318,39 @@ static struct hc_driver r8a66597_hc_driver = {
2243 */ 2318 */
2244 .hub_status_data = r8a66597_hub_status_data, 2319 .hub_status_data = r8a66597_hub_status_data,
2245 .hub_control = r8a66597_hub_control, 2320 .hub_control = r8a66597_hub_control,
2321 .bus_suspend = r8a66597_bus_suspend,
2322 .bus_resume = r8a66597_bus_resume,
2246}; 2323};
2247 2324
2248#if defined(CONFIG_PM) 2325#if defined(CONFIG_PM)
2249static int r8a66597_suspend(struct platform_device *pdev, pm_message_t state) 2326static int r8a66597_suspend(struct platform_device *pdev, pm_message_t state)
2250{ 2327{
2328 struct r8a66597 *r8a66597 = dev_get_drvdata(&pdev->dev);
2329 int port;
2330
2331 dbg("%s", __func__);
2332
2333 disable_controller(r8a66597);
2334
2335 for (port = 0; port < R8A66597_MAX_ROOT_HUB; port++) {
2336 struct r8a66597_root_hub *rh = &r8a66597->root_hub[port];
2337
2338 rh->port = 0x00000000;
2339 }
2340
2251 return 0; 2341 return 0;
2252} 2342}
2253 2343
2254static int r8a66597_resume(struct platform_device *pdev) 2344static int r8a66597_resume(struct platform_device *pdev)
2255{ 2345{
2346 struct r8a66597 *r8a66597 = dev_get_drvdata(&pdev->dev);
2347 struct usb_hcd *hcd = r8a66597_to_hcd(r8a66597);
2348
2349 dbg("%s", __func__);
2350
2351 enable_controller(r8a66597);
2352 usb_root_hub_lost_power(hcd->self.root_hub);
2353
2256 return 0; 2354 return 0;
2257} 2355}
2258#else /* if defined(CONFIG_PM) */ 2356#else /* if defined(CONFIG_PM) */
diff --git a/drivers/usb/host/r8a66597.h b/drivers/usb/host/r8a66597.h
index ecacde4d69b0..f49208f1bb74 100644
--- a/drivers/usb/host/r8a66597.h
+++ b/drivers/usb/host/r8a66597.h
@@ -504,6 +504,8 @@ struct r8a66597 {
504 504
505 struct list_head child_device; 505 struct list_head child_device;
506 unsigned long child_connect_map[4]; 506 unsigned long child_connect_map[4];
507
508 unsigned bus_suspended:1;
507}; 509};
508 510
509static inline struct r8a66597 *hcd_to_r8a66597(struct usb_hcd *hcd) 511static inline struct r8a66597 *hcd_to_r8a66597(struct usb_hcd *hcd)
diff --git a/drivers/usb/host/sl811-hcd.c b/drivers/usb/host/sl811-hcd.c
index e106e9d48d4a..a949259f18b9 100644
--- a/drivers/usb/host/sl811-hcd.c
+++ b/drivers/usb/host/sl811-hcd.c
@@ -230,7 +230,7 @@ static void in_packet(
230 writeb(usb_pipedevice(urb->pipe), data_reg); 230 writeb(usb_pipedevice(urb->pipe), data_reg);
231 231
232 sl811_write(sl811, bank + SL11H_HOSTCTLREG, control); 232 sl811_write(sl811, bank + SL11H_HOSTCTLREG, control);
233 ep->length = min((int)len, 233 ep->length = min_t(u32, len,
234 urb->transfer_buffer_length - urb->actual_length); 234 urb->transfer_buffer_length - urb->actual_length);
235 PACKET("IN%s/%d qh%p len%d\n", ep->nak_count ? "/retry" : "", 235 PACKET("IN%s/%d qh%p len%d\n", ep->nak_count ? "/retry" : "",
236 !!usb_gettoggle(urb->dev, ep->epnum, 0), ep, len); 236 !!usb_gettoggle(urb->dev, ep->epnum, 0), ep, len);
@@ -255,7 +255,7 @@ static void out_packet(
255 buf = urb->transfer_buffer + urb->actual_length; 255 buf = urb->transfer_buffer + urb->actual_length;
256 prefetch(buf); 256 prefetch(buf);
257 257
258 len = min((int)ep->maxpacket, 258 len = min_t(u32, ep->maxpacket,
259 urb->transfer_buffer_length - urb->actual_length); 259 urb->transfer_buffer_length - urb->actual_length);
260 260
261 if (!(control & SL11H_HCTLMASK_ISOCH) 261 if (!(control & SL11H_HCTLMASK_ISOCH)
diff --git a/drivers/usb/host/uhci-debug.c b/drivers/usb/host/uhci-debug.c
index 20cc58b97807..e52b954dda47 100644
--- a/drivers/usb/host/uhci-debug.c
+++ b/drivers/usb/host/uhci-debug.c
@@ -118,7 +118,9 @@ static int uhci_show_urbp(struct urb_priv *urbp, char *buf, int len, int space)
118 } 118 }
119 119
120 out += sprintf(out, "%s%s", ptype, (urbp->fsbr ? " FSBR" : "")); 120 out += sprintf(out, "%s%s", ptype, (urbp->fsbr ? " FSBR" : ""));
121 out += sprintf(out, " Actlen=%d", urbp->urb->actual_length); 121 out += sprintf(out, " Actlen=%d%s", urbp->urb->actual_length,
122 (urbp->qh->type == USB_ENDPOINT_XFER_CONTROL ?
123 "-8" : ""));
122 124
123 if (urbp->urb->unlinked) 125 if (urbp->urb->unlinked)
124 out += sprintf(out, " Unlinked=%d", urbp->urb->unlinked); 126 out += sprintf(out, " Unlinked=%d", urbp->urb->unlinked);
diff --git a/drivers/usb/host/uhci-hcd.h b/drivers/usb/host/uhci-hcd.h
index 7d01c5677f92..26bd1b2bcbfc 100644
--- a/drivers/usb/host/uhci-hcd.h
+++ b/drivers/usb/host/uhci-hcd.h
@@ -73,11 +73,11 @@
73#define USBLEGSUP_RWC 0x8f00 /* the R/WC bits */ 73#define USBLEGSUP_RWC 0x8f00 /* the R/WC bits */
74#define USBLEGSUP_RO 0x5040 /* R/O and reserved bits */ 74#define USBLEGSUP_RO 0x5040 /* R/O and reserved bits */
75 75
76#define UHCI_PTR_BITS __constant_cpu_to_le32(0x000F) 76#define UHCI_PTR_BITS cpu_to_le32(0x000F)
77#define UHCI_PTR_TERM __constant_cpu_to_le32(0x0001) 77#define UHCI_PTR_TERM cpu_to_le32(0x0001)
78#define UHCI_PTR_QH __constant_cpu_to_le32(0x0002) 78#define UHCI_PTR_QH cpu_to_le32(0x0002)
79#define UHCI_PTR_DEPTH __constant_cpu_to_le32(0x0004) 79#define UHCI_PTR_DEPTH cpu_to_le32(0x0004)
80#define UHCI_PTR_BREADTH __constant_cpu_to_le32(0x0000) 80#define UHCI_PTR_BREADTH cpu_to_le32(0x0000)
81 81
82#define UHCI_NUMFRAMES 1024 /* in the frame list [array] */ 82#define UHCI_NUMFRAMES 1024 /* in the frame list [array] */
83#define UHCI_MAX_SOF_NUMBER 2047 /* in an SOF packet */ 83#define UHCI_MAX_SOF_NUMBER 2047 /* in an SOF packet */
diff --git a/drivers/usb/host/uhci-q.c b/drivers/usb/host/uhci-q.c
index 5631d89c8730..3e5807d14ffb 100644
--- a/drivers/usb/host/uhci-q.c
+++ b/drivers/usb/host/uhci-q.c
@@ -402,7 +402,7 @@ static void uhci_fixup_toggles(struct uhci_qh *qh, int skip_first)
402 /* Otherwise all the toggles in the URB have to be switched */ 402 /* Otherwise all the toggles in the URB have to be switched */
403 } else { 403 } else {
404 list_for_each_entry(td, &urbp->td_list, list) { 404 list_for_each_entry(td, &urbp->td_list, list) {
405 td->token ^= __constant_cpu_to_le32( 405 td->token ^= cpu_to_le32(
406 TD_TOKEN_TOGGLE); 406 TD_TOKEN_TOGGLE);
407 toggle ^= 1; 407 toggle ^= 1;
408 } 408 }
@@ -883,7 +883,7 @@ static int uhci_submit_control(struct uhci_hcd *uhci, struct urb *urb,
883 883
884 uhci_fill_td(td, 0, USB_PID_OUT | uhci_explen(0), 0); 884 uhci_fill_td(td, 0, USB_PID_OUT | uhci_explen(0), 0);
885 wmb(); 885 wmb();
886 qh->dummy_td->status |= __constant_cpu_to_le32(TD_CTRL_ACTIVE); 886 qh->dummy_td->status |= cpu_to_le32(TD_CTRL_ACTIVE);
887 qh->dummy_td = td; 887 qh->dummy_td = td;
888 888
889 /* Low-speed transfers get a different queue, and won't hog the bus. 889 /* Low-speed transfers get a different queue, and won't hog the bus.
@@ -899,8 +899,6 @@ static int uhci_submit_control(struct uhci_hcd *uhci, struct urb *urb,
899 } 899 }
900 if (qh->state != QH_STATE_ACTIVE) 900 if (qh->state != QH_STATE_ACTIVE)
901 qh->skel = skel; 901 qh->skel = skel;
902
903 urb->actual_length = -8; /* Account for the SETUP packet */
904 return 0; 902 return 0;
905 903
906nomem: 904nomem:
@@ -1003,7 +1001,7 @@ static int uhci_submit_common(struct uhci_hcd *uhci, struct urb *urb,
1003 * fast side but not enough to justify delaying an interrupt 1001 * fast side but not enough to justify delaying an interrupt
1004 * more than 2 or 3 URBs, so we will ignore the URB_NO_INTERRUPT 1002 * more than 2 or 3 URBs, so we will ignore the URB_NO_INTERRUPT
1005 * flag setting. */ 1003 * flag setting. */
1006 td->status |= __constant_cpu_to_le32(TD_CTRL_IOC); 1004 td->status |= cpu_to_le32(TD_CTRL_IOC);
1007 1005
1008 /* 1006 /*
1009 * Build the new dummy TD and activate the old one 1007 * Build the new dummy TD and activate the old one
@@ -1015,7 +1013,7 @@ static int uhci_submit_common(struct uhci_hcd *uhci, struct urb *urb,
1015 1013
1016 uhci_fill_td(td, 0, USB_PID_OUT | uhci_explen(0), 0); 1014 uhci_fill_td(td, 0, USB_PID_OUT | uhci_explen(0), 0);
1017 wmb(); 1015 wmb();
1018 qh->dummy_td->status |= __constant_cpu_to_le32(TD_CTRL_ACTIVE); 1016 qh->dummy_td->status |= cpu_to_le32(TD_CTRL_ACTIVE);
1019 qh->dummy_td = td; 1017 qh->dummy_td = td;
1020 1018
1021 usb_settoggle(urb->dev, usb_pipeendpoint(urb->pipe), 1019 usb_settoggle(urb->dev, usb_pipeendpoint(urb->pipe),
@@ -1317,7 +1315,7 @@ static int uhci_submit_isochronous(struct uhci_hcd *uhci, struct urb *urb,
1317 } 1315 }
1318 1316
1319 /* Set the interrupt-on-completion flag on the last packet. */ 1317 /* Set the interrupt-on-completion flag on the last packet. */
1320 td->status |= __constant_cpu_to_le32(TD_CTRL_IOC); 1318 td->status |= cpu_to_le32(TD_CTRL_IOC);
1321 1319
1322 /* Add the TDs to the frame list */ 1320 /* Add the TDs to the frame list */
1323 frame = urb->start_frame; 1321 frame = urb->start_frame;
@@ -1494,11 +1492,10 @@ __acquires(uhci->lock)
1494 1492
1495 if (qh->type == USB_ENDPOINT_XFER_CONTROL) { 1493 if (qh->type == USB_ENDPOINT_XFER_CONTROL) {
1496 1494
1497 /* urb->actual_length < 0 means the setup transaction didn't 1495 /* Subtract off the length of the SETUP packet from
1498 * complete successfully. Either it failed or the URB was 1496 * urb->actual_length.
1499 * unlinked first. Regardless, don't confuse people with a 1497 */
1500 * negative length. */ 1498 urb->actual_length -= min_t(u32, 8, urb->actual_length);
1501 urb->actual_length = max(urb->actual_length, 0);
1502 } 1499 }
1503 1500
1504 /* When giving back the first URB in an Isochronous queue, 1501 /* When giving back the first URB in an Isochronous queue,