aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/host/fusbh200-hcd.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/usb/host/fusbh200-hcd.c')
-rw-r--r--drivers/usb/host/fusbh200-hcd.c98
1 files changed, 10 insertions, 88 deletions
diff --git a/drivers/usb/host/fusbh200-hcd.c b/drivers/usb/host/fusbh200-hcd.c
index e1c6d850a7e1..ba9499060f63 100644
--- a/drivers/usb/host/fusbh200-hcd.c
+++ b/drivers/usb/host/fusbh200-hcd.c
@@ -57,13 +57,8 @@
57 57
58static const char hcd_name [] = "fusbh200_hcd"; 58static const char hcd_name [] = "fusbh200_hcd";
59 59
60#undef VERBOSE_DEBUG
61#undef FUSBH200_URB_TRACE 60#undef FUSBH200_URB_TRACE
62 61
63#ifdef DEBUG
64#define FUSBH200_STATS
65#endif
66
67/* magic numbers that can affect system performance */ 62/* magic numbers that can affect system performance */
68#define FUSBH200_TUNE_CERR 3 /* 0-3 qtd retries; 0 == don't stop */ 63#define FUSBH200_TUNE_CERR 3 /* 0-3 qtd retries; 0 == don't stop */
69#define FUSBH200_TUNE_RL_HS 4 /* nak throttle; see 4.9 */ 64#define FUSBH200_TUNE_RL_HS 4 /* nak throttle; see 4.9 */
@@ -108,14 +103,6 @@ MODULE_PARM_DESC(hird, "host initiated resume duration, +1 for each 75us");
108#define fusbh200_warn(fusbh200, fmt, args...) \ 103#define fusbh200_warn(fusbh200, fmt, args...) \
109 dev_warn (fusbh200_to_hcd(fusbh200)->self.controller , fmt , ## args ) 104 dev_warn (fusbh200_to_hcd(fusbh200)->self.controller , fmt , ## args )
110 105
111#ifdef VERBOSE_DEBUG
112# define fusbh200_vdbg fusbh200_dbg
113#else
114 static inline void fusbh200_vdbg(struct fusbh200_hcd *fusbh200, ...) {}
115#endif
116
117#ifdef DEBUG
118
119/* check the values in the HCSPARAMS register 106/* check the values in the HCSPARAMS register
120 * (host controller _Structural_ parameters) 107 * (host controller _Structural_ parameters)
121 * see EHCI spec, Table 2-4 for each value 108 * see EHCI spec, Table 2-4 for each value
@@ -130,13 +117,6 @@ static void dbg_hcs_params (struct fusbh200_hcd *fusbh200, char *label)
130 HCS_N_PORTS (params) 117 HCS_N_PORTS (params)
131 ); 118 );
132} 119}
133#else
134
135static inline void dbg_hcs_params (struct fusbh200_hcd *fusbh200, char *label) {}
136
137#endif
138
139#ifdef DEBUG
140 120
141/* check the values in the HCCPARAMS register 121/* check the values in the HCCPARAMS register
142 * (host controller _Capability_ parameters) 122 * (host controller _Capability_ parameters)
@@ -153,13 +133,6 @@ static void dbg_hcc_params (struct fusbh200_hcd *fusbh200, char *label)
153 HCC_PGM_FRAMELISTLEN(params) ? "256/512/1024" : "1024", 133 HCC_PGM_FRAMELISTLEN(params) ? "256/512/1024" : "1024",
154 HCC_CANPARK(params) ? " park" : ""); 134 HCC_CANPARK(params) ? " park" : "");
155} 135}
156#else
157
158static inline void dbg_hcc_params (struct fusbh200_hcd *fusbh200, char *label) {}
159
160#endif
161
162#ifdef DEBUG
163 136
164static void __maybe_unused 137static void __maybe_unused
165dbg_qtd (const char *label, struct fusbh200_hcd *fusbh200, struct fusbh200_qtd *qtd) 138dbg_qtd (const char *label, struct fusbh200_hcd *fusbh200, struct fusbh200_qtd *qtd)
@@ -302,29 +275,6 @@ dbg_port_buf (char *buf, unsigned len, const char *label, int port, u32 status)
302 (status & PORT_CONNECT) ? " CONNECT" : ""); 275 (status & PORT_CONNECT) ? " CONNECT" : "");
303} 276}
304 277
305#else
306static inline void __maybe_unused
307dbg_qh (char *label, struct fusbh200_hcd *fusbh200, struct fusbh200_qh *qh)
308{}
309
310static inline int __maybe_unused
311dbg_status_buf (char *buf, unsigned len, const char *label, u32 status)
312{ return 0; }
313
314static inline int __maybe_unused
315dbg_command_buf (char *buf, unsigned len, const char *label, u32 command)
316{ return 0; }
317
318static inline int __maybe_unused
319dbg_intr_buf (char *buf, unsigned len, const char *label, u32 enable)
320{ return 0; }
321
322static inline int __maybe_unused
323dbg_port_buf (char *buf, unsigned len, const char *label, int port, u32 status)
324{ return 0; }
325
326#endif /* DEBUG */
327
328/* functions have the "wrong" filename when they're output... */ 278/* functions have the "wrong" filename when they're output... */
329#define dbg_status(fusbh200, label, status) { \ 279#define dbg_status(fusbh200, label, status) { \
330 char _buf [80]; \ 280 char _buf [80]; \
@@ -346,13 +296,6 @@ dbg_port_buf (char *buf, unsigned len, const char *label, int port, u32 status)
346 296
347/*-------------------------------------------------------------------------*/ 297/*-------------------------------------------------------------------------*/
348 298
349#ifdef STUB_DEBUG_FILES
350
351static inline void create_debug_files (struct fusbh200_hcd *bus) { }
352static inline void remove_debug_files (struct fusbh200_hcd *bus) { }
353
354#else
355
356/* troubleshooting help: expose state in debugfs */ 299/* troubleshooting help: expose state in debugfs */
357 300
358static int debug_async_open(struct inode *, struct file *); 301static int debug_async_open(struct inode *, struct file *);
@@ -775,7 +718,6 @@ static ssize_t fill_registers_buffer(struct debug_buffer *buf)
775 next += temp; 718 next += temp;
776 } 719 }
777 720
778#ifdef FUSBH200_STATS
779 temp = scnprintf (next, size, 721 temp = scnprintf (next, size,
780 "irq normal %ld err %ld iaa %ld (lost %ld)\n", 722 "irq normal %ld err %ld iaa %ld (lost %ld)\n",
781 fusbh200->stats.normal, fusbh200->stats.error, fusbh200->stats.iaa, 723 fusbh200->stats.normal, fusbh200->stats.error, fusbh200->stats.iaa,
@@ -787,7 +729,6 @@ static ssize_t fill_registers_buffer(struct debug_buffer *buf)
787 fusbh200->stats.complete, fusbh200->stats.unlink); 729 fusbh200->stats.complete, fusbh200->stats.unlink);
788 size -= temp; 730 size -= temp;
789 next += temp; 731 next += temp;
790#endif
791 732
792done: 733done:
793 spin_unlock_irqrestore (&fusbh200->lock, flags); 734 spin_unlock_irqrestore (&fusbh200->lock, flags);
@@ -928,7 +869,6 @@ static inline void remove_debug_files (struct fusbh200_hcd *fusbh200)
928 debugfs_remove_recursive(fusbh200->debug_dir); 869 debugfs_remove_recursive(fusbh200->debug_dir);
929} 870}
930 871
931#endif /* STUB_DEBUG_FILES */
932/*-------------------------------------------------------------------------*/ 872/*-------------------------------------------------------------------------*/
933 873
934/* 874/*
@@ -1362,7 +1302,7 @@ static void fusbh200_iaa_watchdog(struct fusbh200_hcd *fusbh200)
1362 fusbh200_writel(fusbh200, STS_IAA, &fusbh200->regs->status); 1302 fusbh200_writel(fusbh200, STS_IAA, &fusbh200->regs->status);
1363 } 1303 }
1364 1304
1365 fusbh200_vdbg(fusbh200, "IAA watchdog: status %x cmd %x\n", 1305 fusbh200_dbg(fusbh200, "IAA watchdog: status %x cmd %x\n",
1366 status, cmd); 1306 status, cmd);
1367 end_unlink_async(fusbh200); 1307 end_unlink_async(fusbh200);
1368 } 1308 }
@@ -1769,10 +1709,8 @@ static int fusbh200_hub_control (
1769 if (test_bit(wIndex, &fusbh200->port_c_suspend)) 1709 if (test_bit(wIndex, &fusbh200->port_c_suspend))
1770 status |= USB_PORT_STAT_C_SUSPEND << 16; 1710 status |= USB_PORT_STAT_C_SUSPEND << 16;
1771 1711
1772#ifndef VERBOSE_DEBUG 1712 if (status & ~0xffff) /* only if wPortChange is interesting */
1773 if (status & ~0xffff) /* only if wPortChange is interesting */ 1713 dbg_port(fusbh200, "GetStatus", wIndex + 1, temp);
1774#endif
1775 dbg_port (fusbh200, "GetStatus", wIndex + 1, temp);
1776 put_unaligned_le32(status, buf); 1714 put_unaligned_le32(status, buf);
1777 break; 1715 break;
1778 case SetHubFeature: 1716 case SetHubFeature:
@@ -1814,7 +1752,7 @@ static int fusbh200_hub_control (
1814 * which can be fine if this root hub has a 1752 * which can be fine if this root hub has a
1815 * transaction translator built in. 1753 * transaction translator built in.
1816 */ 1754 */
1817 fusbh200_vdbg (fusbh200, "port %d reset\n", wIndex + 1); 1755 fusbh200_dbg(fusbh200, "port %d reset\n", wIndex + 1);
1818 temp |= PORT_RESET; 1756 temp |= PORT_RESET;
1819 temp &= ~PORT_PE; 1757 temp &= ~PORT_PE;
1820 1758
@@ -2230,13 +2168,13 @@ static void fusbh200_clear_tt_buffer(struct fusbh200_hcd *fusbh200, struct fusbh
2230 * Note: this routine is never called for Isochronous transfers. 2168 * Note: this routine is never called for Isochronous transfers.
2231 */ 2169 */
2232 if (urb->dev->tt && !usb_pipeint(urb->pipe) && !qh->clearing_tt) { 2170 if (urb->dev->tt && !usb_pipeint(urb->pipe) && !qh->clearing_tt) {
2233#ifdef DEBUG
2234 struct usb_device *tt = urb->dev->tt->hub; 2171 struct usb_device *tt = urb->dev->tt->hub;
2172
2235 dev_dbg(&tt->dev, 2173 dev_dbg(&tt->dev,
2236 "clear tt buffer port %d, a%d ep%d t%08x\n", 2174 "clear tt buffer port %d, a%d ep%d t%08x\n",
2237 urb->dev->ttport, urb->dev->devnum, 2175 urb->dev->ttport, urb->dev->devnum,
2238 usb_pipeendpoint(urb->pipe), token); 2176 usb_pipeendpoint(urb->pipe), token);
2239#endif /* DEBUG */ 2177
2240 if (urb->dev->tt->hub != 2178 if (urb->dev->tt->hub !=
2241 fusbh200_to_hcd(fusbh200)->self.root_hub) { 2179 fusbh200_to_hcd(fusbh200)->self.root_hub) {
2242 if (usb_hub_clear_tt_buffer(urb) == 0) 2180 if (usb_hub_clear_tt_buffer(urb) == 0)
@@ -2297,7 +2235,7 @@ static int qtd_copy_status (
2297 status = -EPROTO; 2235 status = -EPROTO;
2298 } 2236 }
2299 2237
2300 fusbh200_vdbg (fusbh200, 2238 fusbh200_dbg(fusbh200,
2301 "dev%d ep%d%s qtd token %08x --> status %d\n", 2239 "dev%d ep%d%s qtd token %08x --> status %d\n",
2302 usb_pipedevice (urb->pipe), 2240 usb_pipedevice (urb->pipe),
2303 usb_pipeendpoint (urb->pipe), 2241 usb_pipeendpoint (urb->pipe),
@@ -3529,11 +3467,9 @@ periodic_usecs (struct fusbh200_hcd *fusbh200, unsigned frame, unsigned uframe)
3529 break; 3467 break;
3530 } 3468 }
3531 } 3469 }
3532#ifdef DEBUG
3533 if (usecs > fusbh200->uframe_periodic_max) 3470 if (usecs > fusbh200->uframe_periodic_max)
3534 fusbh200_err (fusbh200, "uframe %d sched overrun: %d usecs\n", 3471 fusbh200_err (fusbh200, "uframe %d sched overrun: %d usecs\n",
3535 frame * 8 + uframe, usecs); 3472 frame * 8 + uframe, usecs);
3536#endif
3537 return usecs; 3473 return usecs;
3538} 3474}
3539 3475
@@ -4586,7 +4522,7 @@ static void itd_link_urb(
4586 if (unlikely (list_empty(&stream->td_list))) { 4522 if (unlikely (list_empty(&stream->td_list))) {
4587 fusbh200_to_hcd(fusbh200)->self.bandwidth_allocated 4523 fusbh200_to_hcd(fusbh200)->self.bandwidth_allocated
4588 += stream->bandwidth; 4524 += stream->bandwidth;
4589 fusbh200_vdbg (fusbh200, 4525 fusbh200_dbg(fusbh200,
4590 "schedule devp %s ep%d%s-iso period %d start %d.%d\n", 4526 "schedule devp %s ep%d%s-iso period %d start %d.%d\n",
4591 urb->dev->devpath, stream->bEndpointAddress & 0x0f, 4527 urb->dev->devpath, stream->bEndpointAddress & 0x0f,
4592 (stream->bEndpointAddress & USB_DIR_IN) ? "in" : "out", 4528 (stream->bEndpointAddress & USB_DIR_IN) ? "in" : "out",
@@ -4717,7 +4653,7 @@ static bool itd_complete(struct fusbh200_hcd *fusbh200, struct fusbh200_itd *itd
4717 if (unlikely(list_is_singular(&stream->td_list))) { 4653 if (unlikely(list_is_singular(&stream->td_list))) {
4718 fusbh200_to_hcd(fusbh200)->self.bandwidth_allocated 4654 fusbh200_to_hcd(fusbh200)->self.bandwidth_allocated
4719 -= stream->bandwidth; 4655 -= stream->bandwidth;
4720 fusbh200_vdbg (fusbh200, 4656 fusbh200_dbg(fusbh200,
4721 "deschedule devp %s ep%d%s-iso\n", 4657 "deschedule devp %s ep%d%s-iso\n",
4722 dev->devpath, stream->bEndpointAddress & 0x0f, 4658 dev->devpath, stream->bEndpointAddress & 0x0f,
4723 (stream->bEndpointAddress & USB_DIR_IN) ? "in" : "out"); 4659 (stream->bEndpointAddress & USB_DIR_IN) ? "in" : "out");
@@ -5115,13 +5051,11 @@ static void fusbh200_stop (struct usb_hcd *hcd)
5115 spin_unlock_irq (&fusbh200->lock); 5051 spin_unlock_irq (&fusbh200->lock);
5116 fusbh200_mem_cleanup (fusbh200); 5052 fusbh200_mem_cleanup (fusbh200);
5117 5053
5118#ifdef FUSBH200_STATS
5119 fusbh200_dbg(fusbh200, "irq normal %ld err %ld iaa %ld (lost %ld)\n", 5054 fusbh200_dbg(fusbh200, "irq normal %ld err %ld iaa %ld (lost %ld)\n",
5120 fusbh200->stats.normal, fusbh200->stats.error, fusbh200->stats.iaa, 5055 fusbh200->stats.normal, fusbh200->stats.error, fusbh200->stats.iaa,
5121 fusbh200->stats.lost_iaa); 5056 fusbh200->stats.lost_iaa);
5122 fusbh200_dbg (fusbh200, "complete %ld unlink %ld\n", 5057 fusbh200_dbg (fusbh200, "complete %ld unlink %ld\n",
5123 fusbh200->stats.complete, fusbh200->stats.unlink); 5058 fusbh200->stats.complete, fusbh200->stats.unlink);
5124#endif
5125 5059
5126 dbg_status (fusbh200, "fusbh200_stop completed", 5060 dbg_status (fusbh200, "fusbh200_stop completed",
5127 fusbh200_readl(fusbh200, &fusbh200->regs->status)); 5061 fusbh200_readl(fusbh200, &fusbh200->regs->status));
@@ -5365,13 +5299,6 @@ static irqreturn_t fusbh200_irq (struct usb_hcd *hcd)
5365 cmd = fusbh200_readl(fusbh200, &fusbh200->regs->command); 5299 cmd = fusbh200_readl(fusbh200, &fusbh200->regs->command);
5366 bh = 0; 5300 bh = 0;
5367 5301
5368#ifdef VERBOSE_DEBUG
5369 /* unrequested/ignored: Frame List Rollover */
5370 dbg_status (fusbh200, "irq", status);
5371#endif
5372
5373 /* INT, ERR, and IAA interrupt rates can be throttled */
5374
5375 /* normal [4.15.1.2] or error [4.15.1.1] completion */ 5302 /* normal [4.15.1.2] or error [4.15.1.1] completion */
5376 if (likely ((status & (STS_INT|STS_ERR)) != 0)) { 5303 if (likely ((status & (STS_INT|STS_ERR)) != 0)) {
5377 if (likely ((status & STS_ERR) == 0)) 5304 if (likely ((status & STS_ERR) == 0))
@@ -5871,6 +5798,7 @@ static int fusbh200_hcd_probe(struct platform_device *pdev)
5871 dev_err(dev, "failed to add hcd with err %d\n", retval); 5798 dev_err(dev, "failed to add hcd with err %d\n", retval);
5872 goto fail_add_hcd; 5799 goto fail_add_hcd;
5873 } 5800 }
5801 device_wakeup_enable(hcd->self.controller);
5874 5802
5875 return retval; 5803 return retval;
5876 5804
@@ -5936,13 +5864,11 @@ static int __init fusbh200_hcd_init(void)
5936 sizeof(struct fusbh200_qh), sizeof(struct fusbh200_qtd), 5864 sizeof(struct fusbh200_qh), sizeof(struct fusbh200_qtd),
5937 sizeof(struct fusbh200_itd)); 5865 sizeof(struct fusbh200_itd));
5938 5866
5939#ifdef DEBUG
5940 fusbh200_debug_root = debugfs_create_dir("fusbh200", usb_debug_root); 5867 fusbh200_debug_root = debugfs_create_dir("fusbh200", usb_debug_root);
5941 if (!fusbh200_debug_root) { 5868 if (!fusbh200_debug_root) {
5942 retval = -ENOENT; 5869 retval = -ENOENT;
5943 goto err_debug; 5870 goto err_debug;
5944 } 5871 }
5945#endif
5946 5872
5947 retval = platform_driver_register(&fusbh200_hcd_fusbh200_driver); 5873 retval = platform_driver_register(&fusbh200_hcd_fusbh200_driver);
5948 if (retval < 0) 5874 if (retval < 0)
@@ -5951,11 +5877,9 @@ static int __init fusbh200_hcd_init(void)
5951 5877
5952 platform_driver_unregister(&fusbh200_hcd_fusbh200_driver); 5878 platform_driver_unregister(&fusbh200_hcd_fusbh200_driver);
5953clean: 5879clean:
5954#ifdef DEBUG
5955 debugfs_remove(fusbh200_debug_root); 5880 debugfs_remove(fusbh200_debug_root);
5956 fusbh200_debug_root = NULL; 5881 fusbh200_debug_root = NULL;
5957err_debug: 5882err_debug:
5958#endif
5959 clear_bit(USB_EHCI_LOADED, &usb_hcds_loaded); 5883 clear_bit(USB_EHCI_LOADED, &usb_hcds_loaded);
5960 return retval; 5884 return retval;
5961} 5885}
@@ -5964,9 +5888,7 @@ module_init(fusbh200_hcd_init);
5964static void __exit fusbh200_hcd_cleanup(void) 5888static void __exit fusbh200_hcd_cleanup(void)
5965{ 5889{
5966 platform_driver_unregister(&fusbh200_hcd_fusbh200_driver); 5890 platform_driver_unregister(&fusbh200_hcd_fusbh200_driver);
5967#ifdef DEBUG
5968 debugfs_remove(fusbh200_debug_root); 5891 debugfs_remove(fusbh200_debug_root);
5969#endif
5970 clear_bit(USB_EHCI_LOADED, &usb_hcds_loaded); 5892 clear_bit(USB_EHCI_LOADED, &usb_hcds_loaded);
5971} 5893}
5972module_exit(fusbh200_hcd_cleanup); 5894module_exit(fusbh200_hcd_cleanup);