aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/musb
diff options
context:
space:
mode:
authorGreg Kroah-Hartman <gregkh@linuxfoundation.org>2014-03-07 19:47:36 -0500
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2014-03-07 19:47:36 -0500
commit7338a0659365ec0fbdc6f79de8b9fba2280fd155 (patch)
tree876358e9d7187cad93d41b9e9918653fc24fa38a /drivers/usb/musb
parentc9050b64940a1b47dfa623630431fec400edbf33 (diff)
parent4b76e14d95f7b69e71eabc002dcb0dcb9ebb5340 (diff)
Merge tag 'usb-for-v3.15' of git://git.kernel.org/pub/scm/linux/kernel/git/balbi/usb into usb-next
Felipe writes: usb: patches for v3.15 another substantial pull request with new features all over the place. dwc3 got a bit closer towards hibernation support with after a few patches re-factoring code to be reused for hibernation. Also in dwc3 two new workarounds for known silicon bugs have been implemented, some randconfig build errors have been fixed, and it was taught about the new generic phy layer. MUSB on AM335x now supports isochronous transfers thanks to George Cherian's work. The atmel_usba driver got two crash fixes: one when no endpoint was specified in DeviceTree data and another when stopping the UDC in DEBUG builds. Function FS got a much needed fix to ffs_epfile_io() which was copying too much data to userspace in some cases. The printer gadget got a fix for a possible deadlock and plugged a memory leak. Ethernet drivers now use NAPI for RX which gives improved throughput. Other than that, the usual miscelaneous fixes, cleanups, and the like. Signed-of-by: Felipe Balbi <balbi@ti.com>
Diffstat (limited to 'drivers/usb/musb')
-rw-r--r--drivers/usb/musb/Kconfig2
-rw-r--r--drivers/usb/musb/musb_core.c5
-rw-r--r--drivers/usb/musb/musb_cppi41.c69
-rw-r--r--drivers/usb/musb/musb_dsps.c58
-rw-r--r--drivers/usb/musb/musb_host.c30
5 files changed, 153 insertions, 11 deletions
diff --git a/drivers/usb/musb/Kconfig b/drivers/usb/musb/Kconfig
index 688dc8bb192d..8b789792f6fa 100644
--- a/drivers/usb/musb/Kconfig
+++ b/drivers/usb/musb/Kconfig
@@ -43,6 +43,7 @@ config USB_MUSB_HOST
43config USB_MUSB_GADGET 43config USB_MUSB_GADGET
44 bool "Gadget only mode" 44 bool "Gadget only mode"
45 depends on USB_GADGET=y || USB_GADGET=USB_MUSB_HDRC 45 depends on USB_GADGET=y || USB_GADGET=USB_MUSB_HDRC
46 depends on HAS_DMA
46 help 47 help
47 Select this when you want to use MUSB in gadget mode only, 48 Select this when you want to use MUSB in gadget mode only,
48 thereby the host feature will be regressed. 49 thereby the host feature will be regressed.
@@ -50,6 +51,7 @@ config USB_MUSB_GADGET
50config USB_MUSB_DUAL_ROLE 51config USB_MUSB_DUAL_ROLE
51 bool "Dual Role mode" 52 bool "Dual Role mode"
52 depends on ((USB=y || USB=USB_MUSB_HDRC) && (USB_GADGET=y || USB_GADGET=USB_MUSB_HDRC)) 53 depends on ((USB=y || USB=USB_MUSB_HDRC) && (USB_GADGET=y || USB_GADGET=USB_MUSB_HDRC))
54 depends on HAS_DMA
53 help 55 help
54 This is the default mode of working of MUSB controller where 56 This is the default mode of working of MUSB controller where
55 both host and gadget features are enabled. 57 both host and gadget features are enabled.
diff --git a/drivers/usb/musb/musb_core.c b/drivers/usb/musb/musb_core.c
index 239ad0b1ceb6..07576907e2c6 100644
--- a/drivers/usb/musb/musb_core.c
+++ b/drivers/usb/musb/musb_core.c
@@ -438,7 +438,6 @@ void musb_hnp_stop(struct musb *musb)
438static irqreturn_t musb_stage0_irq(struct musb *musb, u8 int_usb, 438static irqreturn_t musb_stage0_irq(struct musb *musb, u8 int_usb,
439 u8 devctl) 439 u8 devctl)
440{ 440{
441 struct usb_otg *otg = musb->xceiv->otg;
442 irqreturn_t handled = IRQ_NONE; 441 irqreturn_t handled = IRQ_NONE;
443 442
444 dev_dbg(musb->controller, "<== DevCtl=%02x, int_usb=0x%x\n", devctl, 443 dev_dbg(musb->controller, "<== DevCtl=%02x, int_usb=0x%x\n", devctl,
@@ -656,7 +655,7 @@ static irqreturn_t musb_stage0_irq(struct musb *musb, u8 int_usb,
656 break; 655 break;
657 case OTG_STATE_B_PERIPHERAL: 656 case OTG_STATE_B_PERIPHERAL:
658 musb_g_suspend(musb); 657 musb_g_suspend(musb);
659 musb->is_active = otg->gadget->b_hnp_enable; 658 musb->is_active = musb->g.b_hnp_enable;
660 if (musb->is_active) { 659 if (musb->is_active) {
661 musb->xceiv->state = OTG_STATE_B_WAIT_ACON; 660 musb->xceiv->state = OTG_STATE_B_WAIT_ACON;
662 dev_dbg(musb->controller, "HNP: Setting timer for b_ase0_brst\n"); 661 dev_dbg(musb->controller, "HNP: Setting timer for b_ase0_brst\n");
@@ -672,7 +671,7 @@ static irqreturn_t musb_stage0_irq(struct musb *musb, u8 int_usb,
672 break; 671 break;
673 case OTG_STATE_A_HOST: 672 case OTG_STATE_A_HOST:
674 musb->xceiv->state = OTG_STATE_A_SUSPEND; 673 musb->xceiv->state = OTG_STATE_A_SUSPEND;
675 musb->is_active = otg->host->b_hnp_enable; 674 musb->is_active = musb->hcd->self.b_hnp_enable;
676 break; 675 break;
677 case OTG_STATE_B_HOST: 676 case OTG_STATE_B_HOST:
678 /* Transition to B_PERIPHERAL, see 6.8.2.6 p 44 */ 677 /* Transition to B_PERIPHERAL, see 6.8.2.6 p 44 */
diff --git a/drivers/usb/musb/musb_cppi41.c b/drivers/usb/musb/musb_cppi41.c
index f88929609bac..7b8bbf53127e 100644
--- a/drivers/usb/musb/musb_cppi41.c
+++ b/drivers/usb/musb/musb_cppi41.c
@@ -39,6 +39,7 @@ struct cppi41_dma_channel {
39 u32 transferred; 39 u32 transferred;
40 u32 packet_sz; 40 u32 packet_sz;
41 struct list_head tx_check; 41 struct list_head tx_check;
42 struct work_struct dma_completion;
42}; 43};
43 44
44#define MUSB_DMA_NUM_CHANNELS 15 45#define MUSB_DMA_NUM_CHANNELS 15
@@ -112,6 +113,18 @@ static bool musb_is_tx_fifo_empty(struct musb_hw_ep *hw_ep)
112 return true; 113 return true;
113} 114}
114 115
116static bool is_isoc(struct musb_hw_ep *hw_ep, bool in)
117{
118 if (in && hw_ep->in_qh) {
119 if (hw_ep->in_qh->type == USB_ENDPOINT_XFER_ISOC)
120 return true;
121 } else if (hw_ep->out_qh) {
122 if (hw_ep->out_qh->type == USB_ENDPOINT_XFER_ISOC)
123 return true;
124 }
125 return false;
126}
127
115static void cppi41_dma_callback(void *private_data); 128static void cppi41_dma_callback(void *private_data);
116 129
117static void cppi41_trans_done(struct cppi41_dma_channel *cppi41_channel) 130static void cppi41_trans_done(struct cppi41_dma_channel *cppi41_channel)
@@ -119,7 +132,8 @@ static void cppi41_trans_done(struct cppi41_dma_channel *cppi41_channel)
119 struct musb_hw_ep *hw_ep = cppi41_channel->hw_ep; 132 struct musb_hw_ep *hw_ep = cppi41_channel->hw_ep;
120 struct musb *musb = hw_ep->musb; 133 struct musb *musb = hw_ep->musb;
121 134
122 if (!cppi41_channel->prog_len) { 135 if (!cppi41_channel->prog_len ||
136 (cppi41_channel->channel.status == MUSB_DMA_STATUS_FREE)) {
123 137
124 /* done, complete */ 138 /* done, complete */
125 cppi41_channel->channel.actual_len = 139 cppi41_channel->channel.actual_len =
@@ -165,6 +179,32 @@ static void cppi41_trans_done(struct cppi41_dma_channel *cppi41_channel)
165 } 179 }
166} 180}
167 181
182static void cppi_trans_done_work(struct work_struct *work)
183{
184 unsigned long flags;
185 struct cppi41_dma_channel *cppi41_channel =
186 container_of(work, struct cppi41_dma_channel, dma_completion);
187 struct cppi41_dma_controller *controller = cppi41_channel->controller;
188 struct musb *musb = controller->musb;
189 struct musb_hw_ep *hw_ep = cppi41_channel->hw_ep;
190 bool empty;
191
192 if (!cppi41_channel->is_tx && is_isoc(hw_ep, 1)) {
193 spin_lock_irqsave(&musb->lock, flags);
194 cppi41_trans_done(cppi41_channel);
195 spin_unlock_irqrestore(&musb->lock, flags);
196 } else {
197 empty = musb_is_tx_fifo_empty(hw_ep);
198 if (empty) {
199 spin_lock_irqsave(&musb->lock, flags);
200 cppi41_trans_done(cppi41_channel);
201 spin_unlock_irqrestore(&musb->lock, flags);
202 } else {
203 schedule_work(&cppi41_channel->dma_completion);
204 }
205 }
206}
207
168static enum hrtimer_restart cppi41_recheck_tx_req(struct hrtimer *timer) 208static enum hrtimer_restart cppi41_recheck_tx_req(struct hrtimer *timer)
169{ 209{
170 struct cppi41_dma_controller *controller; 210 struct cppi41_dma_controller *controller;
@@ -228,6 +268,14 @@ static void cppi41_dma_callback(void *private_data)
228 transferred < cppi41_channel->packet_sz) 268 transferred < cppi41_channel->packet_sz)
229 cppi41_channel->prog_len = 0; 269 cppi41_channel->prog_len = 0;
230 270
271 if (!cppi41_channel->is_tx) {
272 if (is_isoc(hw_ep, 1))
273 schedule_work(&cppi41_channel->dma_completion);
274 else
275 cppi41_trans_done(cppi41_channel);
276 goto out;
277 }
278
231 empty = musb_is_tx_fifo_empty(hw_ep); 279 empty = musb_is_tx_fifo_empty(hw_ep);
232 if (empty) { 280 if (empty) {
233 cppi41_trans_done(cppi41_channel); 281 cppi41_trans_done(cppi41_channel);
@@ -264,6 +312,10 @@ static void cppi41_dma_callback(void *private_data)
264 goto out; 312 goto out;
265 } 313 }
266 } 314 }
315 if (is_isoc(hw_ep, 0)) {
316 schedule_work(&cppi41_channel->dma_completion);
317 goto out;
318 }
267 list_add_tail(&cppi41_channel->tx_check, 319 list_add_tail(&cppi41_channel->tx_check,
268 &controller->early_tx_list); 320 &controller->early_tx_list);
269 if (!hrtimer_active(&controller->early_tx)) { 321 if (!hrtimer_active(&controller->early_tx)) {
@@ -448,12 +500,25 @@ static int cppi41_dma_channel_program(struct dma_channel *channel,
448 dma_addr_t dma_addr, u32 len) 500 dma_addr_t dma_addr, u32 len)
449{ 501{
450 int ret; 502 int ret;
503 struct cppi41_dma_channel *cppi41_channel = channel->private_data;
504 int hb_mult = 0;
451 505
452 BUG_ON(channel->status == MUSB_DMA_STATUS_UNKNOWN || 506 BUG_ON(channel->status == MUSB_DMA_STATUS_UNKNOWN ||
453 channel->status == MUSB_DMA_STATUS_BUSY); 507 channel->status == MUSB_DMA_STATUS_BUSY);
454 508
509 if (is_host_active(cppi41_channel->controller->musb)) {
510 if (cppi41_channel->is_tx)
511 hb_mult = cppi41_channel->hw_ep->out_qh->hb_mult;
512 else
513 hb_mult = cppi41_channel->hw_ep->in_qh->hb_mult;
514 }
515
455 channel->status = MUSB_DMA_STATUS_BUSY; 516 channel->status = MUSB_DMA_STATUS_BUSY;
456 channel->actual_len = 0; 517 channel->actual_len = 0;
518
519 if (hb_mult)
520 packet_sz = hb_mult * (packet_sz & 0x7FF);
521
457 ret = cppi41_configure_channel(channel, packet_sz, mode, dma_addr, len); 522 ret = cppi41_configure_channel(channel, packet_sz, mode, dma_addr, len);
458 if (!ret) 523 if (!ret)
459 channel->status = MUSB_DMA_STATUS_FREE; 524 channel->status = MUSB_DMA_STATUS_FREE;
@@ -607,6 +672,8 @@ static int cppi41_dma_controller_start(struct cppi41_dma_controller *controller)
607 cppi41_channel->port_num = port; 672 cppi41_channel->port_num = port;
608 cppi41_channel->is_tx = is_tx; 673 cppi41_channel->is_tx = is_tx;
609 INIT_LIST_HEAD(&cppi41_channel->tx_check); 674 INIT_LIST_HEAD(&cppi41_channel->tx_check);
675 INIT_WORK(&cppi41_channel->dma_completion,
676 cppi_trans_done_work);
610 677
611 musb_dma = &cppi41_channel->channel; 678 musb_dma = &cppi41_channel->channel;
612 musb_dma->private_data = cppi41_channel; 679 musb_dma->private_data = cppi41_channel;
diff --git a/drivers/usb/musb/musb_dsps.c b/drivers/usb/musb/musb_dsps.c
index 7a109eae9b9a..3372ded5def7 100644
--- a/drivers/usb/musb/musb_dsps.c
+++ b/drivers/usb/musb/musb_dsps.c
@@ -45,6 +45,8 @@
45#include <linux/of_irq.h> 45#include <linux/of_irq.h>
46#include <linux/usb/of.h> 46#include <linux/usb/of.h>
47 47
48#include <linux/debugfs.h>
49
48#include "musb_core.h" 50#include "musb_core.h"
49 51
50static const struct of_device_id musb_dsps_of_match[]; 52static const struct of_device_id musb_dsps_of_match[];
@@ -136,6 +138,26 @@ struct dsps_glue {
136 unsigned long last_timer; /* last timer data for each instance */ 138 unsigned long last_timer; /* last timer data for each instance */
137 139
138 struct dsps_context context; 140 struct dsps_context context;
141 struct debugfs_regset32 regset;
142 struct dentry *dbgfs_root;
143};
144
145static const struct debugfs_reg32 dsps_musb_regs[] = {
146 { "revision", 0x00 },
147 { "control", 0x14 },
148 { "status", 0x18 },
149 { "eoi", 0x24 },
150 { "intr0_stat", 0x30 },
151 { "intr1_stat", 0x34 },
152 { "intr0_set", 0x38 },
153 { "intr1_set", 0x3c },
154 { "txmode", 0x70 },
155 { "rxmode", 0x74 },
156 { "autoreq", 0xd0 },
157 { "srpfixtime", 0xd4 },
158 { "tdown", 0xd8 },
159 { "phy_utmi", 0xe0 },
160 { "mode", 0xe8 },
139}; 161};
140 162
141static void dsps_musb_try_idle(struct musb *musb, unsigned long timeout) 163static void dsps_musb_try_idle(struct musb *musb, unsigned long timeout)
@@ -368,6 +390,30 @@ out:
368 return ret; 390 return ret;
369} 391}
370 392
393static int dsps_musb_dbg_init(struct musb *musb, struct dsps_glue *glue)
394{
395 struct dentry *root;
396 struct dentry *file;
397 char buf[128];
398
399 sprintf(buf, "%s.dsps", dev_name(musb->controller));
400 root = debugfs_create_dir(buf, NULL);
401 if (!root)
402 return -ENOMEM;
403 glue->dbgfs_root = root;
404
405 glue->regset.regs = dsps_musb_regs;
406 glue->regset.nregs = ARRAY_SIZE(dsps_musb_regs);
407 glue->regset.base = musb->ctrl_base;
408
409 file = debugfs_create_regset32("regdump", S_IRUGO, root, &glue->regset);
410 if (!file) {
411 debugfs_remove_recursive(root);
412 return -ENOMEM;
413 }
414 return 0;
415}
416
371static int dsps_musb_init(struct musb *musb) 417static int dsps_musb_init(struct musb *musb)
372{ 418{
373 struct device *dev = musb->controller; 419 struct device *dev = musb->controller;
@@ -377,6 +423,7 @@ static int dsps_musb_init(struct musb *musb)
377 void __iomem *reg_base; 423 void __iomem *reg_base;
378 struct resource *r; 424 struct resource *r;
379 u32 rev, val; 425 u32 rev, val;
426 int ret;
380 427
381 r = platform_get_resource_byname(parent, IORESOURCE_MEM, "control"); 428 r = platform_get_resource_byname(parent, IORESOURCE_MEM, "control");
382 if (!r) 429 if (!r)
@@ -410,6 +457,10 @@ static int dsps_musb_init(struct musb *musb)
410 val &= ~(1 << wrp->otg_disable); 457 val &= ~(1 << wrp->otg_disable);
411 dsps_writel(musb->ctrl_base, wrp->phy_utmi, val); 458 dsps_writel(musb->ctrl_base, wrp->phy_utmi, val);
412 459
460 ret = dsps_musb_dbg_init(musb, glue);
461 if (ret)
462 return ret;
463
413 return 0; 464 return 0;
414} 465}
415 466
@@ -616,7 +667,7 @@ static int dsps_probe(struct platform_device *pdev)
616 wrp = match->data; 667 wrp = match->data;
617 668
618 /* allocate glue */ 669 /* allocate glue */
619 glue = kzalloc(sizeof(*glue), GFP_KERNEL); 670 glue = devm_kzalloc(&pdev->dev, sizeof(*glue), GFP_KERNEL);
620 if (!glue) { 671 if (!glue) {
621 dev_err(&pdev->dev, "unable to allocate glue memory\n"); 672 dev_err(&pdev->dev, "unable to allocate glue memory\n");
622 return -ENOMEM; 673 return -ENOMEM;
@@ -644,7 +695,6 @@ err3:
644 pm_runtime_put(&pdev->dev); 695 pm_runtime_put(&pdev->dev);
645err2: 696err2:
646 pm_runtime_disable(&pdev->dev); 697 pm_runtime_disable(&pdev->dev);
647 kfree(glue);
648 return ret; 698 return ret;
649} 699}
650 700
@@ -657,7 +707,9 @@ static int dsps_remove(struct platform_device *pdev)
657 /* disable usbss clocks */ 707 /* disable usbss clocks */
658 pm_runtime_put(&pdev->dev); 708 pm_runtime_put(&pdev->dev);
659 pm_runtime_disable(&pdev->dev); 709 pm_runtime_disable(&pdev->dev);
660 kfree(glue); 710
711 debugfs_remove_recursive(glue->dbgfs_root);
712
661 return 0; 713 return 0;
662} 714}
663 715
diff --git a/drivers/usb/musb/musb_host.c b/drivers/usb/musb/musb_host.c
index abb38c3833ef..eb06291a40c8 100644
--- a/drivers/usb/musb/musb_host.c
+++ b/drivers/usb/musb/musb_host.c
@@ -1694,7 +1694,8 @@ void musb_host_rx(struct musb *musb, u8 epnum)
1694 | MUSB_RXCSR_RXPKTRDY); 1694 | MUSB_RXCSR_RXPKTRDY);
1695 musb_writew(hw_ep->regs, MUSB_RXCSR, val); 1695 musb_writew(hw_ep->regs, MUSB_RXCSR, val);
1696 1696
1697#if defined(CONFIG_USB_INVENTRA_DMA) || defined(CONFIG_USB_UX500_DMA) 1697#if defined(CONFIG_USB_INVENTRA_DMA) || defined(CONFIG_USB_UX500_DMA) || \
1698 defined(CONFIG_USB_TI_CPPI41_DMA)
1698 if (usb_pipeisoc(pipe)) { 1699 if (usb_pipeisoc(pipe)) {
1699 struct usb_iso_packet_descriptor *d; 1700 struct usb_iso_packet_descriptor *d;
1700 1701
@@ -1707,10 +1708,30 @@ void musb_host_rx(struct musb *musb, u8 epnum)
1707 if (d->status != -EILSEQ && d->status != -EOVERFLOW) 1708 if (d->status != -EILSEQ && d->status != -EOVERFLOW)
1708 d->status = 0; 1709 d->status = 0;
1709 1710
1710 if (++qh->iso_idx >= urb->number_of_packets) 1711 if (++qh->iso_idx >= urb->number_of_packets) {
1711 done = true; 1712 done = true;
1712 else 1713 } else {
1714#if defined(CONFIG_USB_TI_CPPI41_DMA)
1715 struct dma_controller *c;
1716 dma_addr_t *buf;
1717 u32 length, ret;
1718
1719 c = musb->dma_controller;
1720 buf = (void *)
1721 urb->iso_frame_desc[qh->iso_idx].offset
1722 + (u32)urb->transfer_dma;
1723
1724 length =
1725 urb->iso_frame_desc[qh->iso_idx].length;
1726
1727 val |= MUSB_RXCSR_DMAENAB;
1728 musb_writew(hw_ep->regs, MUSB_RXCSR, val);
1729
1730 ret = c->channel_program(dma, qh->maxpacket,
1731 0, (u32) buf, length);
1732#endif
1713 done = false; 1733 done = false;
1734 }
1714 1735
1715 } else { 1736 } else {
1716 /* done if urb buffer is full or short packet is recd */ 1737 /* done if urb buffer is full or short packet is recd */
@@ -1750,7 +1771,8 @@ void musb_host_rx(struct musb *musb, u8 epnum)
1750 } 1771 }
1751 1772
1752 /* we are expecting IN packets */ 1773 /* we are expecting IN packets */
1753#if defined(CONFIG_USB_INVENTRA_DMA) || defined(CONFIG_USB_UX500_DMA) 1774#if defined(CONFIG_USB_INVENTRA_DMA) || defined(CONFIG_USB_UX500_DMA) || \
1775 defined(CONFIG_USB_TI_CPPI41_DMA)
1754 if (dma) { 1776 if (dma) {
1755 struct dma_controller *c; 1777 struct dma_controller *c;
1756 u16 rx_count; 1778 u16 rx_count;