From fe198e34a44ce7f27e39c303d62a754129938194 Mon Sep 17 00:00:00 2001 From: Markus Pargmann Date: Wed, 14 Jan 2015 16:08:38 +0100 Subject: usb: musb: debugfs: improve copy_from_user() argument While the code is correct and functions well, it's still a bit misleading to add the reference operator in from of the buf argument. This patch simply removes that operator in order to make use of buf slightly better to the eyes. Signed-off-by: Markus Pargmann Signed-off-by: Felipe Balbi --- drivers/usb/musb/musb_debugfs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/usb/musb') diff --git a/drivers/usb/musb/musb_debugfs.c b/drivers/usb/musb/musb_debugfs.c index ad3701a..bb13e04 100644 --- a/drivers/usb/musb/musb_debugfs.c +++ b/drivers/usb/musb/musb_debugfs.c @@ -194,7 +194,7 @@ static ssize_t musb_test_mode_write(struct file *file, memset(buf, 0x00, sizeof(buf)); - if (copy_from_user(&buf, ubuf, min_t(size_t, sizeof(buf) - 1, count))) + if (copy_from_user(buf, ubuf, min_t(size_t, sizeof(buf) - 1, count))) return -EFAULT; if (!strncmp(buf, "force host", 9)) -- cgit v1.1 From c509ba6e48d394aa7fe0f04c38493967c1268317 Mon Sep 17 00:00:00 2001 From: Sergei Shtylyov Date: Mon, 19 Jan 2015 01:57:18 +0300 Subject: usb: musb: virthub: use HUB_CHAR_* Fix using the bare numbers to set the 'wHubCharacteristics' field of the Hub Descriptor while the values are #define'd in . Signed-off-by: Sergei Shtylyov Signed-off-by: Felipe Balbi --- drivers/usb/musb/musb_virthub.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'drivers/usb/musb') diff --git a/drivers/usb/musb/musb_virthub.c b/drivers/usb/musb/musb_virthub.c index b072420..662de58 100644 --- a/drivers/usb/musb/musb_virthub.c +++ b/drivers/usb/musb/musb_virthub.c @@ -349,9 +349,9 @@ int musb_hub_control( desc->bDescriptorType = 0x29; desc->bNbrPorts = 1; desc->wHubCharacteristics = cpu_to_le16( - 0x0001 /* per-port power switching */ - | 0x0010 /* no overcurrent reporting */ - ); + HUB_CHAR_INDV_PORT_LPSM /* per-port power switching */ + | HUB_CHAR_NO_OCPM /* no overcurrent reporting */ + ); desc->bPwrOn2PwrGood = 5; /* msec/2 */ desc->bHubContrCurrent = 0; -- cgit v1.1 From 0149b07a9e28b0d8bd2fc1c238ffe7d530c2673f Mon Sep 17 00:00:00 2001 From: Bin Liu Date: Mon, 26 Jan 2015 16:22:06 -0600 Subject: usb: musb: cppi41: correct the macro name EP_MODE_AUTOREG_* The macro EP_MODE_AUTOREG_* should be called EP_MODE_AUTOREQ_*, as they are used for register AUTOREQ. Signed-off-by: Bin Liu Signed-off-by: Felipe Balbi --- drivers/usb/musb/musb_cppi41.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'drivers/usb/musb') diff --git a/drivers/usb/musb/musb_cppi41.c b/drivers/usb/musb/musb_cppi41.c index c39a16a..6af10e7 100644 --- a/drivers/usb/musb/musb_cppi41.c +++ b/drivers/usb/musb/musb_cppi41.c @@ -9,9 +9,9 @@ #define RNDIS_REG(x) (0x80 + ((x - 1) * 4)) -#define EP_MODE_AUTOREG_NONE 0 -#define EP_MODE_AUTOREG_ALL_NEOP 1 -#define EP_MODE_AUTOREG_ALWAYS 3 +#define EP_MODE_AUTOREQ_NONE 0 +#define EP_MODE_AUTOREQ_ALL_NEOP 1 +#define EP_MODE_AUTOREQ_ALWAYS 3 #define EP_MODE_DMA_TRANSPARENT 0 #define EP_MODE_DMA_RNDIS 1 @@ -404,19 +404,19 @@ static bool cppi41_configure_channel(struct dma_channel *channel, /* auto req */ cppi41_set_autoreq_mode(cppi41_channel, - EP_MODE_AUTOREG_ALL_NEOP); + EP_MODE_AUTOREQ_ALL_NEOP); } else { musb_writel(musb->ctrl_base, RNDIS_REG(cppi41_channel->port_num), 0); cppi41_set_dma_mode(cppi41_channel, EP_MODE_DMA_TRANSPARENT); cppi41_set_autoreq_mode(cppi41_channel, - EP_MODE_AUTOREG_NONE); + EP_MODE_AUTOREQ_NONE); } } else { /* fallback mode */ cppi41_set_dma_mode(cppi41_channel, EP_MODE_DMA_TRANSPARENT); - cppi41_set_autoreq_mode(cppi41_channel, EP_MODE_AUTOREG_NONE); + cppi41_set_autoreq_mode(cppi41_channel, EP_MODE_AUTOREQ_NONE); len = min_t(u32, packet_sz, len); } cppi41_channel->prog_len = len; -- cgit v1.1 From cb83df77f3ec151d68a1b6be957207e6fc7b7f50 Mon Sep 17 00:00:00 2001 From: Bin Liu Date: Mon, 26 Jan 2015 16:22:07 -0600 Subject: usb: musb: cppi41: improve rx channel abort routine 1. set AUTOREQ to NONE at the beginning of teardown; 2. add delay for dma pipeline to drain; 3. Do not set USB_TDOWN bit for RX teardown. The CPPI hw has an issue that when tearing down a RX channel, if another RX channel is receiving data, the CPPI will lockup. To workaround the issue, do not set the CPPI TD bit. The steps before this point ensures the CPPI channel will be torn down properly. Signed-off-by: Bin Liu Signed-off-by: Felipe Balbi --- drivers/usb/musb/musb_cppi41.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'drivers/usb/musb') diff --git a/drivers/usb/musb/musb_cppi41.c b/drivers/usb/musb/musb_cppi41.c index 6af10e7..be84562 100644 --- a/drivers/usb/musb/musb_cppi41.c +++ b/drivers/usb/musb/musb_cppi41.c @@ -549,10 +549,15 @@ static int cppi41_dma_channel_abort(struct dma_channel *channel) csr &= ~MUSB_TXCSR_DMAENAB; musb_writew(epio, MUSB_TXCSR, csr); } else { + cppi41_set_autoreq_mode(cppi41_channel, EP_MODE_AUTOREQ_NONE); + csr = musb_readw(epio, MUSB_RXCSR); csr &= ~(MUSB_RXCSR_H_REQPKT | MUSB_RXCSR_DMAENAB); musb_writew(epio, MUSB_RXCSR, csr); + /* wait to drain cppi dma pipe line */ + udelay(50); + csr = musb_readw(epio, MUSB_RXCSR); if (csr & MUSB_RXCSR_RXPKTRDY) { csr |= MUSB_RXCSR_FLUSHFIFO; @@ -566,13 +571,14 @@ static int cppi41_dma_channel_abort(struct dma_channel *channel) tdbit <<= 16; do { - musb_writel(musb->ctrl_base, USB_TDOWN, tdbit); + if (is_tx) + musb_writel(musb->ctrl_base, USB_TDOWN, tdbit); ret = dmaengine_terminate_all(cppi41_channel->dc); } while (ret == -EAGAIN); - musb_writel(musb->ctrl_base, USB_TDOWN, tdbit); - if (is_tx) { + musb_writel(musb->ctrl_base, USB_TDOWN, tdbit); + csr = musb_readw(epio, MUSB_TXCSR); if (csr & MUSB_TXCSR_TXPKTRDY) { csr |= MUSB_TXCSR_FLUSHFIFO; -- cgit v1.1 From dadac9861f466635c3ac0851f2a39be68fa10a71 Mon Sep 17 00:00:00 2001 From: Peter Chen Date: Wed, 28 Jan 2015 16:32:41 +0800 Subject: usb: musb: gadget: use common is_selfpowered Delete private selfpowered variable, and use common one. Signed-off-by: Peter Chen Signed-off-by: Felipe Balbi --- drivers/usb/musb/musb_gadget.c | 4 +--- drivers/usb/musb/musb_gadget_ep0.c | 2 +- 2 files changed, 2 insertions(+), 4 deletions(-) (limited to 'drivers/usb/musb') diff --git a/drivers/usb/musb/musb_gadget.c b/drivers/usb/musb/musb_gadget.c index 49b04cb..b2d9040 100644 --- a/drivers/usb/musb/musb_gadget.c +++ b/drivers/usb/musb/musb_gadget.c @@ -1612,9 +1612,7 @@ done: static int musb_gadget_set_self_powered(struct usb_gadget *gadget, int is_selfpowered) { - struct musb *musb = gadget_to_musb(gadget); - - musb->is_self_powered = !!is_selfpowered; + gadget->is_selfpowered = !!is_selfpowered; return 0; } diff --git a/drivers/usb/musb/musb_gadget_ep0.c b/drivers/usb/musb/musb_gadget_ep0.c index 2af45a0..10d30af 100644 --- a/drivers/usb/musb/musb_gadget_ep0.c +++ b/drivers/usb/musb/musb_gadget_ep0.c @@ -85,7 +85,7 @@ static int service_tx_status_request( switch (recip) { case USB_RECIP_DEVICE: - result[0] = musb->is_self_powered << USB_DEVICE_SELF_POWERED; + result[0] = musb->g.is_selfpowered << USB_DEVICE_SELF_POWERED; result[0] |= musb->may_wakeup << USB_DEVICE_REMOTE_WAKEUP; if (musb->g.is_otg) { result[0] |= musb->g.b_hnp_enable -- cgit v1.1 From a0cb12e2ed61f4c1bb586268ca43b27dd8ce959e Mon Sep 17 00:00:00 2001 From: Arnd Bergmann Date: Wed, 28 Jan 2015 22:50:04 +0100 Subject: usb: musb: add generic usb phy dependencies Multiple musb glue drivers depend on the generic usb phy support, but fail to list it as a dependency in Kconfig. This results in build erros like: drivers/built-in.o: In function `am35x_remove': :(.text+0xadacc): undefined reference to `usb_phy_generic_unregister' drivers/built-in.o: In function `am35x_probe': :(.text+0xae1c8): undefined reference to `usb_phy_generic_register' :(.text+0xae244): undefined reference to `usb_phy_generic_unregister' drivers/built-in.o: In function `jz4740_remove': :(.text+0xaf648): undefined reference to `usb_phy_generic_unregister' drivers/built-in.o: In function `jz4740_musb_init': :(.text+0xaf694): undefined reference to `usb_phy_generic_register' This adds the ones that are missing. Signed-off-by: Arnd Bergmann Signed-off-by: Felipe Balbi --- drivers/usb/musb/Kconfig | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'drivers/usb/musb') diff --git a/drivers/usb/musb/Kconfig b/drivers/usb/musb/Kconfig index b005010..26c835f 100644 --- a/drivers/usb/musb/Kconfig +++ b/drivers/usb/musb/Kconfig @@ -63,11 +63,13 @@ comment "Platform Glue Layer" config USB_MUSB_DAVINCI tristate "DaVinci" depends on ARCH_DAVINCI_DMx + depends on NOP_USB_XCEIV depends on BROKEN config USB_MUSB_DA8XX tristate "DA8xx/OMAP-L1x" depends on ARCH_DAVINCI_DA8XX + depends on NOP_USB_XCEIV depends on BROKEN config USB_MUSB_TUSB6010 @@ -83,6 +85,7 @@ config USB_MUSB_OMAP2PLUS config USB_MUSB_AM35X tristate "AM35x" depends on ARCH_OMAP + depends on NOP_USB_XCEIV config USB_MUSB_DSPS tristate "TI DSPS platforms" @@ -93,6 +96,7 @@ config USB_MUSB_DSPS config USB_MUSB_BLACKFIN tristate "Blackfin" depends on (BF54x && !BF544) || (BF52x && ! BF522 && !BF523) + depends on NOP_USB_XCEIV config USB_MUSB_UX500 tristate "Ux500 platforms" @@ -100,6 +104,7 @@ config USB_MUSB_UX500 config USB_MUSB_JZ4740 tristate "JZ4740" + depends on NOP_USB_XCEIV depends on MACH_JZ4740 || COMPILE_TEST depends on USB_MUSB_GADGET depends on USB_OTG_BLACKLIST_HUB -- cgit v1.1 From fbba7db3990cb707ff91cd6507d53a0a730afe97 Mon Sep 17 00:00:00 2001 From: Arnd Bergmann Date: Wed, 28 Jan 2015 22:51:04 +0100 Subject: usb: musb: add omap-control dependency The omap musb front-end calls into the phy driver directly instead of using a generic phy interface, which causes a link error when the specific driver is not built-in: drivers/built-in.o: In function `omap2430_musb_disable': usb/musb/omap2430.c:480: undefined reference to `omap_control_usb_set_mode' drivers/built-in.o: In function `omap2430_musb_enable': usb/musb/omap2430.c:466: undefined reference to `omap_control_usb_set_mode' usb/musb/omap2430.c:447: undefined reference to `omap_control_usb_set_mode' drivers/built-in.o: In function `omap_musb_set_mailbox': usb/musb/omap2430.c:273: undefined reference to `omap_control_usb_set_mode' usb/musb/omap2430.c:304: undefined reference to `omap_control_usb_set_mode' drivers/built-in.o:(.debug_addr+0xbd9e0): more undefined references to `omap_control_usb_set_mode' follow This adds an explicit dependency. Signed-off-by: Arnd Bergmann Fixes: ca784be36cc725 ("usb: start using the control module driver") Cc: # v3.9+ Signed-off-by: Felipe Balbi --- drivers/usb/musb/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/usb/musb') diff --git a/drivers/usb/musb/Kconfig b/drivers/usb/musb/Kconfig index 26c835f..14e1628 100644 --- a/drivers/usb/musb/Kconfig +++ b/drivers/usb/musb/Kconfig @@ -79,7 +79,7 @@ config USB_MUSB_TUSB6010 config USB_MUSB_OMAP2PLUS tristate "OMAP2430 and onwards" - depends on ARCH_OMAP2PLUS && USB + depends on ARCH_OMAP2PLUS && USB && OMAP_CONTROL_PHY select GENERIC_PHY config USB_MUSB_AM35X -- cgit v1.1 From d9b2b19fc45265a2423fa68e22318882b42a111c Mon Sep 17 00:00:00 2001 From: Dmitry Torokhov Date: Sat, 31 Jan 2015 21:13:59 -0800 Subject: usb: musb: blackfin: remove incorrect __exit_p() bfin_remove() is not (nor should it be) marked as __exit, so we should not be using __exit_p() wrapper with it, otherwise unbinding through sysfs does not work properly. Signed-off-by: Dmitry Torokhov Signed-off-by: Felipe Balbi --- drivers/usb/musb/blackfin.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/usb/musb') diff --git a/drivers/usb/musb/blackfin.c b/drivers/usb/musb/blackfin.c index 1782501..6123b74 100644 --- a/drivers/usb/musb/blackfin.c +++ b/drivers/usb/musb/blackfin.c @@ -608,7 +608,7 @@ static SIMPLE_DEV_PM_OPS(bfin_pm_ops, bfin_suspend, bfin_resume); static struct platform_driver bfin_driver = { .probe = bfin_probe, - .remove = __exit_p(bfin_remove), + .remove = bfin_remove, .driver = { .name = "musb-blackfin", .pm = &bfin_pm_ops, -- cgit v1.1 From 9298b4aad37e8c6962edcdbd0b62620adb207d03 Mon Sep 17 00:00:00 2001 From: Bin Liu Date: Tue, 3 Feb 2015 11:02:10 -0600 Subject: usb: musb: fix device hotplug behind hub The commit 889ad3b "usb: musb: try a race-free wakeup" breaks device hotplug enumeraitonn when the device is connected behind a hub while usb autosuspend is enabled. Adding finish_resume_work into runtime resume callback fixes the issue. Also resume root hub is required to resume the bus from runtime suspend, so move musb_host_resume_root_hub() back to its original location, where handles RESUME interrupt. Signed-off-by: Bin Liu Tested-by: Tony Lindgren Signed-off-by: Felipe Balbi --- drivers/usb/musb/musb_core.c | 7 +++++++ drivers/usb/musb/musb_virthub.c | 1 - 2 files changed, 7 insertions(+), 1 deletion(-) (limited to 'drivers/usb/musb') diff --git a/drivers/usb/musb/musb_core.c b/drivers/usb/musb/musb_core.c index 34cce3e..e6f4cbf 100644 --- a/drivers/usb/musb/musb_core.c +++ b/drivers/usb/musb/musb_core.c @@ -567,6 +567,7 @@ static irqreturn_t musb_stage0_irq(struct musb *musb, u8 int_usb, musb->xceiv->otg->state = OTG_STATE_A_HOST; musb->is_active = 1; + musb_host_resume_root_hub(musb); break; case OTG_STATE_B_WAIT_ACON: musb->xceiv->otg->state = OTG_STATE_B_PERIPHERAL; @@ -2500,6 +2501,12 @@ static int musb_runtime_resume(struct device *dev) musb_restore_context(musb); first = 0; + if (musb->need_finish_resume) { + musb->need_finish_resume = 0; + schedule_delayed_work(&musb->finish_resume_work, + msecs_to_jiffies(20)); + } + return 0; } diff --git a/drivers/usb/musb/musb_virthub.c b/drivers/usb/musb/musb_virthub.c index 662de58..294e159 100644 --- a/drivers/usb/musb/musb_virthub.c +++ b/drivers/usb/musb/musb_virthub.c @@ -72,7 +72,6 @@ void musb_host_finish_resume(struct work_struct *work) musb->xceiv->otg->state = OTG_STATE_A_HOST; spin_unlock_irqrestore(&musb->lock, flags); - musb_host_resume_root_hub(musb); } void musb_port_suspend(struct musb *musb, bool do_suspend) -- cgit v1.1