aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/musb
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2012-01-09 15:09:47 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2012-01-09 15:09:47 -0500
commit55b81e6f2795484ea8edf5805c95c007cacfa736 (patch)
treec3724975107857fcc03b5dd649c462e4f72397be /drivers/usb/musb
parent5983faf942f260023e547f3c5f38c1033c35cc9b (diff)
parent08e87d0d773dc9ca5faf4c3306e238ed0ea129b0 (diff)
Merge branch 'usb-next' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb
* 'usb-next' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb: (232 commits) USB: Add USB-ID for Multiplex RC serial adapter to cp210x.c xhci: Clean up 32-bit build warnings. USB: update documentation for usbmon usb: usb-storage doesn't support dynamic id currently, the patch disables the feature to fix an oops drivers/usb/class/cdc-acm.c: clear dangling pointer drivers/usb/dwc3/dwc3-pci.c: introduce missing kfree drivers/usb/host/isp1760-if.c: introduce missing kfree usb: option: add ZD Incorporated HSPA modem usb: ch9: fix up MaxStreams helper USB: usb-skeleton.c: cleanup open_count USB: usb-skeleton.c: fix open/disconnect race xhci: Properly handle COMP_2ND_BW_ERR USB: remove dead code from suspend/resume path USB: add quirk for another camera drivers: usb: wusbcore: Fix dependency for USB_WUSB xhci: Better debugging for critical host errors. xhci: Be less verbose during URB cancellation. xhci: Remove debugging about ring structure allocation. xhci: Remove debugging about toggling cycle bits. xhci: Remove debugging for individual transfers. ...
Diffstat (limited to 'drivers/usb/musb')
-rw-r--r--drivers/usb/musb/Kconfig61
-rw-r--r--drivers/usb/musb/Makefile26
-rw-r--r--drivers/usb/musb/musb_core.c8
-rw-r--r--drivers/usb/musb/musb_core.h4
-rw-r--r--drivers/usb/musb/musb_debug.h4
-rw-r--r--drivers/usb/musb/musb_debugfs.c8
-rw-r--r--drivers/usb/musb/musb_gadget.c6
-rw-r--r--drivers/usb/musb/musb_gadget_ep0.c1
-rw-r--r--drivers/usb/musb/musb_io.h2
-rw-r--r--drivers/usb/musb/omap2430.c61
-rw-r--r--drivers/usb/musb/tusb6010.c1
-rw-r--r--drivers/usb/musb/ux500_dma.c39
12 files changed, 87 insertions, 134 deletions
diff --git a/drivers/usb/musb/Kconfig b/drivers/usb/musb/Kconfig
index 07a03460a598..f70cab3beeec 100644
--- a/drivers/usb/musb/Kconfig
+++ b/drivers/usb/musb/Kconfig
@@ -5,14 +5,13 @@
5 5
6# (M)HDRC = (Multipoint) Highspeed Dual-Role Controller 6# (M)HDRC = (Multipoint) Highspeed Dual-Role Controller
7config USB_MUSB_HDRC 7config USB_MUSB_HDRC
8 tristate 'Inventra Highspeed Dual Role Controller (TI, ADI, ...)'
8 depends on USB && USB_GADGET 9 depends on USB && USB_GADGET
9 depends on (ARM || (BF54x && !BF544) || (BF52x && !BF522 && !BF523))
10 select NOP_USB_XCEIV if (ARCH_DAVINCI || MACH_OMAP3EVM || BLACKFIN) 10 select NOP_USB_XCEIV if (ARCH_DAVINCI || MACH_OMAP3EVM || BLACKFIN)
11 select TWL4030_USB if MACH_OMAP_3430SDP 11 select TWL4030_USB if MACH_OMAP_3430SDP
12 select TWL6030_USB if MACH_OMAP_4430SDP || MACH_OMAP4_PANDA 12 select TWL6030_USB if MACH_OMAP_4430SDP || MACH_OMAP4_PANDA
13 select USB_OTG_UTILS 13 select USB_OTG_UTILS
14 select USB_GADGET_DUALSPEED 14 select USB_GADGET_DUALSPEED
15 tristate 'Inventra Highspeed Dual Role Controller (TI, ADI, ...)'
16 help 15 help
17 Say Y here if your system has a dual role high speed USB 16 Say Y here if your system has a dual role high speed USB
18 controller based on the Mentor Graphics silicon IP. Then 17 controller based on the Mentor Graphics silicon IP. Then
@@ -31,9 +30,10 @@ config USB_MUSB_HDRC
31 To compile this driver as a module, choose M here; the 30 To compile this driver as a module, choose M here; the
32 module will be called "musb-hdrc". 31 module will be called "musb-hdrc".
33 32
33if USB_MUSB_HDRC
34
34choice 35choice
35 prompt "Platform Glue Layer" 36 prompt "Platform Glue Layer"
36 depends on USB_MUSB_HDRC
37 37
38config USB_MUSB_DAVINCI 38config USB_MUSB_DAVINCI
39 tristate "DaVinci" 39 tristate "DaVinci"
@@ -45,7 +45,6 @@ config USB_MUSB_DA8XX
45 45
46config USB_MUSB_TUSB6010 46config USB_MUSB_TUSB6010
47 tristate "TUSB6010" 47 tristate "TUSB6010"
48 depends on ARCH_OMAP
49 48
50config USB_MUSB_OMAP2PLUS 49config USB_MUSB_OMAP2PLUS
51 tristate "OMAP2430 and onwards" 50 tristate "OMAP2430 and onwards"
@@ -65,46 +64,54 @@ config USB_MUSB_UX500
65 64
66endchoice 65endchoice
67 66
68config MUSB_PIO_ONLY 67choice
69 bool 'Disable DMA (always use PIO)' 68 prompt 'MUSB DMA mode'
70 depends on USB_MUSB_HDRC 69 default USB_UX500_DMA if USB_MUSB_UX500
71 default USB_MUSB_TUSB6010 || USB_MUSB_DA8XX || USB_MUSB_AM35X 70 default USB_INVENTRA_DMA if USB_MUSB_OMAP2PLUS || USB_MUSB_BLACKFIN
71 default USB_TI_CPPI_DMA if USB_MUSB_DAVINCI
72 default USB_TUSB_OMAP_DMA if USB_MUSB_TUSB6010
73 default MUSB_PIO_ONLY if USB_MUSB_TUSB6010 || USB_MUSB_DA8XX || USB_MUSB_AM35X
72 help 74 help
73 All data is copied between memory and FIFO by the CPU. 75 Unfortunately, only one option can be enabled here. Ideally one
74 DMA controllers are ignored. 76 should be able to build all these drivers into one kernel to
75 77 allow using DMA on multiplatform kernels.
76 Do not select 'n' here unless DMA support for your SOC or board
77 is unavailable (or unstable). When DMA is enabled at compile time,
78 you can still disable it at run time using the "use_dma=n" module
79 parameter.
80 78
81config USB_UX500_DMA 79config USB_UX500_DMA
82 bool 80 bool 'ST Ericsson U8500 and U5500'
83 depends on USB_MUSB_HDRC && !MUSB_PIO_ONLY 81 depends on USB_MUSB_UX500
84 default USB_MUSB_UX500
85 help 82 help
86 Enable DMA transfers on UX500 platforms. 83 Enable DMA transfers on UX500 platforms.
87 84
88config USB_INVENTRA_DMA 85config USB_INVENTRA_DMA
89 bool 86 bool 'Inventra'
90 depends on USB_MUSB_HDRC && !MUSB_PIO_ONLY 87 depends on USB_MUSB_OMAP2PLUS || USB_MUSB_BLACKFIN
91 default USB_MUSB_OMAP2PLUS || USB_MUSB_BLACKFIN
92 help 88 help
93 Enable DMA transfers using Mentor's engine. 89 Enable DMA transfers using Mentor's engine.
94 90
95config USB_TI_CPPI_DMA 91config USB_TI_CPPI_DMA
96 bool 92 bool 'TI CPPI (Davinci)'
97 depends on USB_MUSB_HDRC && !MUSB_PIO_ONLY 93 depends on USB_MUSB_DAVINCI
98 default USB_MUSB_DAVINCI
99 help 94 help
100 Enable DMA transfers when TI CPPI DMA is available. 95 Enable DMA transfers when TI CPPI DMA is available.
101 96
102config USB_TUSB_OMAP_DMA 97config USB_TUSB_OMAP_DMA
103 bool 98 bool 'TUSB 6010'
104 depends on USB_MUSB_HDRC && !MUSB_PIO_ONLY
105 depends on USB_MUSB_TUSB6010 99 depends on USB_MUSB_TUSB6010
106 depends on ARCH_OMAP 100 depends on ARCH_OMAP
107 default y
108 help 101 help
109 Enable DMA transfers on TUSB 6010 when OMAP DMA is available. 102 Enable DMA transfers on TUSB 6010 when OMAP DMA is available.
110 103
104config MUSB_PIO_ONLY
105 bool 'Disable DMA (always use PIO)'
106 help
107 All data is copied between memory and FIFO by the CPU.
108 DMA controllers are ignored.
109
110 Do not choose this unless DMA support for your SOC or board
111 is unavailable (or unstable). When DMA is enabled at compile time,
112 you can still disable it at run time using the "use_dma=n" module
113 parameter.
114
115endchoice
116
117endif # USB_MUSB_HDRC
diff --git a/drivers/usb/musb/Makefile b/drivers/usb/musb/Makefile
index d8fd9d092dec..88bfb9dee4bf 100644
--- a/drivers/usb/musb/Makefile
+++ b/drivers/usb/musb/Makefile
@@ -24,25 +24,7 @@ obj-$(CONFIG_USB_MUSB_UX500) += ux500.o
24# PIO only, or DMA (several potential schemes). 24# PIO only, or DMA (several potential schemes).
25# though PIO is always there to back up DMA, and for ep0 25# though PIO is always there to back up DMA, and for ep0
26 26
27ifneq ($(CONFIG_MUSB_PIO_ONLY),y) 27musb_hdrc-$(CONFIG_USB_INVENTRA_DMA) += musbhsdma.o
28 28musb_hdrc-$(CONFIG_USB_TI_CPPI_DMA) += cppi_dma.o
29 ifeq ($(CONFIG_USB_INVENTRA_DMA),y) 29musb_hdrc-$(CONFIG_USB_TUSB_OMAP_DMA) += tusb6010_omap.o
30 musb_hdrc-y += musbhsdma.o 30musb_hdrc-$(CONFIG_USB_UX500_DMA) += ux500_dma.o
31
32 else
33 ifeq ($(CONFIG_USB_TI_CPPI_DMA),y)
34 musb_hdrc-y += cppi_dma.o
35
36 else
37 ifeq ($(CONFIG_USB_TUSB_OMAP_DMA),y)
38 musb_hdrc-y += tusb6010_omap.o
39
40 else
41 ifeq ($(CONFIG_USB_UX500_DMA),y)
42 musb_hdrc-y += ux500_dma.o
43
44 endif
45 endif
46 endif
47 endif
48endif
diff --git a/drivers/usb/musb/musb_core.c b/drivers/usb/musb/musb_core.c
index b63ab1570103..f6ff7923048b 100644
--- a/drivers/usb/musb/musb_core.c
+++ b/drivers/usb/musb/musb_core.c
@@ -661,7 +661,6 @@ static irqreturn_t musb_stage0_irq(struct musb *musb, u8 int_usb,
661 661
662 handled = IRQ_HANDLED; 662 handled = IRQ_HANDLED;
663 musb->is_active = 1; 663 musb->is_active = 1;
664 set_bit(HCD_FLAG_SAW_IRQ, &hcd->flags);
665 664
666 musb->ep0_stage = MUSB_EP0_START; 665 musb->ep0_stage = MUSB_EP0_START;
667 666
@@ -1432,7 +1431,7 @@ static int __init musb_core_init(u16 musb_type, struct musb *musb)
1432 struct musb_hw_ep *hw_ep = musb->endpoints + i; 1431 struct musb_hw_ep *hw_ep = musb->endpoints + i;
1433 1432
1434 hw_ep->fifo = MUSB_FIFO_OFFSET(i) + mbase; 1433 hw_ep->fifo = MUSB_FIFO_OFFSET(i) + mbase;
1435#ifdef CONFIG_USB_MUSB_TUSB6010 1434#if defined(CONFIG_USB_MUSB_TUSB6010) || defined (CONFIG_USB_MUSB_TUSB6010_MODULE)
1436 hw_ep->fifo_async = musb->async + 0x400 + MUSB_FIFO_OFFSET(i); 1435 hw_ep->fifo_async = musb->async + 0x400 + MUSB_FIFO_OFFSET(i);
1437 hw_ep->fifo_sync = musb->sync + 0x400 + MUSB_FIFO_OFFSET(i); 1436 hw_ep->fifo_sync = musb->sync + 0x400 + MUSB_FIFO_OFFSET(i);
1438 hw_ep->fifo_sync_va = 1437 hw_ep->fifo_sync_va =
@@ -1631,6 +1630,7 @@ void musb_dma_completion(struct musb *musb, u8 epnum, u8 transmit)
1631 } 1630 }
1632 } 1631 }
1633} 1632}
1633EXPORT_SYMBOL_GPL(musb_dma_completion);
1634 1634
1635#else 1635#else
1636#define use_dma 0 1636#define use_dma 0
@@ -2012,8 +2012,6 @@ musb_init_controller(struct device *dev, int nIrq, void __iomem *ctrl)
2012 if (status < 0) 2012 if (status < 0)
2013 goto fail3; 2013 goto fail3;
2014 2014
2015 pm_runtime_put(musb->controller);
2016
2017 status = musb_init_debugfs(musb); 2015 status = musb_init_debugfs(musb);
2018 if (status < 0) 2016 if (status < 0)
2019 goto fail4; 2017 goto fail4;
@@ -2158,6 +2156,7 @@ static void musb_save_context(struct musb *musb)
2158 if (!epio) 2156 if (!epio)
2159 continue; 2157 continue;
2160 2158
2159 musb_writeb(musb_base, MUSB_INDEX, i);
2161 musb->context.index_regs[i].txmaxp = 2160 musb->context.index_regs[i].txmaxp =
2162 musb_readw(epio, MUSB_TXMAXP); 2161 musb_readw(epio, MUSB_TXMAXP);
2163 musb->context.index_regs[i].txcsr = 2162 musb->context.index_regs[i].txcsr =
@@ -2233,6 +2232,7 @@ static void musb_restore_context(struct musb *musb)
2233 if (!epio) 2232 if (!epio)
2234 continue; 2233 continue;
2235 2234
2235 musb_writeb(musb_base, MUSB_INDEX, i);
2236 musb_writew(epio, MUSB_TXMAXP, 2236 musb_writew(epio, MUSB_TXMAXP,
2237 musb->context.index_regs[i].txmaxp); 2237 musb->context.index_regs[i].txmaxp);
2238 musb_writew(epio, MUSB_TXCSR, 2238 musb_writew(epio, MUSB_TXCSR,
diff --git a/drivers/usb/musb/musb_core.h b/drivers/usb/musb/musb_core.h
index b3c065ab9dbc..3d28fb8a2dc9 100644
--- a/drivers/usb/musb/musb_core.h
+++ b/drivers/usb/musb/musb_core.h
@@ -40,7 +40,6 @@
40#include <linux/interrupt.h> 40#include <linux/interrupt.h>
41#include <linux/errno.h> 41#include <linux/errno.h>
42#include <linux/timer.h> 42#include <linux/timer.h>
43#include <linux/clk.h>
44#include <linux/device.h> 43#include <linux/device.h>
45#include <linux/usb/ch9.h> 44#include <linux/usb/ch9.h>
46#include <linux/usb/gadget.h> 45#include <linux/usb/gadget.h>
@@ -311,6 +310,7 @@ struct musb_context_registers {
311 u8 index, testmode; 310 u8 index, testmode;
312 311
313 u8 devctl, busctl, misc; 312 u8 devctl, busctl, misc;
313 u32 otg_interfsel;
314 314
315 struct musb_csr_regs index_regs[MUSB_C_NUM_EPS]; 315 struct musb_csr_regs index_regs[MUSB_C_NUM_EPS];
316}; 316};
@@ -327,6 +327,7 @@ struct musb {
327 327
328 irqreturn_t (*isr)(int, void *); 328 irqreturn_t (*isr)(int, void *);
329 struct work_struct irq_work; 329 struct work_struct irq_work;
330 struct work_struct otg_notifier_work;
330 u16 hwvers; 331 u16 hwvers;
331 332
332/* this hub status bit is reserved by USB 2.0 and not seen by usbcore */ 333/* this hub status bit is reserved by USB 2.0 and not seen by usbcore */
@@ -372,6 +373,7 @@ struct musb {
372 u16 int_tx; 373 u16 int_tx;
373 374
374 struct otg_transceiver *xceiv; 375 struct otg_transceiver *xceiv;
376 u8 xceiv_event;
375 377
376 int nIrq; 378 int nIrq;
377 unsigned irq_wake:1; 379 unsigned irq_wake:1;
diff --git a/drivers/usb/musb/musb_debug.h b/drivers/usb/musb/musb_debug.h
index 742eada5002e..27ba8f799462 100644
--- a/drivers/usb/musb/musb_debug.h
+++ b/drivers/usb/musb/musb_debug.h
@@ -43,8 +43,8 @@
43#define ERR(fmt, args...) yprintk(KERN_ERR, fmt, ## args) 43#define ERR(fmt, args...) yprintk(KERN_ERR, fmt, ## args)
44 44
45#ifdef CONFIG_DEBUG_FS 45#ifdef CONFIG_DEBUG_FS
46extern int musb_init_debugfs(struct musb *musb); 46int musb_init_debugfs(struct musb *musb);
47extern void musb_exit_debugfs(struct musb *musb); 47void musb_exit_debugfs(struct musb *musb);
48#else 48#else
49static inline int musb_init_debugfs(struct musb *musb) 49static inline int musb_init_debugfs(struct musb *musb)
50{ 50{
diff --git a/drivers/usb/musb/musb_debugfs.c b/drivers/usb/musb/musb_debugfs.c
index 61f4ee466df7..13d9af9bf920 100644
--- a/drivers/usb/musb/musb_debugfs.c
+++ b/drivers/usb/musb/musb_debugfs.c
@@ -33,11 +33,7 @@
33 33
34#include <linux/module.h> 34#include <linux/module.h>
35#include <linux/kernel.h> 35#include <linux/kernel.h>
36#include <linux/sched.h>
37#include <linux/init.h> 36#include <linux/init.h>
38#include <linux/list.h>
39#include <linux/platform_device.h>
40#include <linux/io.h>
41#include <linux/debugfs.h> 37#include <linux/debugfs.h>
42#include <linux/seq_file.h> 38#include <linux/seq_file.h>
43 39
@@ -46,10 +42,6 @@
46#include "musb_core.h" 42#include "musb_core.h"
47#include "musb_debug.h" 43#include "musb_debug.h"
48 44
49#ifdef CONFIG_ARCH_DAVINCI
50#include "davinci.h"
51#endif
52
53struct musb_register_map { 45struct musb_register_map {
54 char *name; 46 char *name;
55 unsigned offset; 47 unsigned offset;
diff --git a/drivers/usb/musb/musb_gadget.c b/drivers/usb/musb/musb_gadget.c
index 922148ff8d29..ac3d2eec20fe 100644
--- a/drivers/usb/musb/musb_gadget.c
+++ b/drivers/usb/musb/musb_gadget.c
@@ -40,8 +40,6 @@
40#include <linux/smp.h> 40#include <linux/smp.h>
41#include <linux/spinlock.h> 41#include <linux/spinlock.h>
42#include <linux/delay.h> 42#include <linux/delay.h>
43#include <linux/moduleparam.h>
44#include <linux/stat.h>
45#include <linux/dma-mapping.h> 43#include <linux/dma-mapping.h>
46#include <linux/slab.h> 44#include <linux/slab.h>
47 45
@@ -1844,7 +1842,7 @@ int __init musb_gadget_setup(struct musb *musb)
1844 */ 1842 */
1845 1843
1846 musb->g.ops = &musb_gadget_operations; 1844 musb->g.ops = &musb_gadget_operations;
1847 musb->g.is_dualspeed = 1; 1845 musb->g.max_speed = USB_SPEED_HIGH;
1848 musb->g.speed = USB_SPEED_UNKNOWN; 1846 musb->g.speed = USB_SPEED_UNKNOWN;
1849 1847
1850 /* this "gadget" abstracts/virtualizes the controller */ 1848 /* this "gadget" abstracts/virtualizes the controller */
@@ -1903,7 +1901,7 @@ static int musb_gadget_start(struct usb_gadget *g,
1903 unsigned long flags; 1901 unsigned long flags;
1904 int retval = -EINVAL; 1902 int retval = -EINVAL;
1905 1903
1906 if (driver->speed < USB_SPEED_HIGH) 1904 if (driver->max_speed < USB_SPEED_HIGH)
1907 goto err0; 1905 goto err0;
1908 1906
1909 pm_runtime_get_sync(musb->controller); 1907 pm_runtime_get_sync(musb->controller);
diff --git a/drivers/usb/musb/musb_gadget_ep0.c b/drivers/usb/musb/musb_gadget_ep0.c
index 6a0d0467ec74..e40d7647caf1 100644
--- a/drivers/usb/musb/musb_gadget_ep0.c
+++ b/drivers/usb/musb/musb_gadget_ep0.c
@@ -37,7 +37,6 @@
37#include <linux/list.h> 37#include <linux/list.h>
38#include <linux/timer.h> 38#include <linux/timer.h>
39#include <linux/spinlock.h> 39#include <linux/spinlock.h>
40#include <linux/init.h>
41#include <linux/device.h> 40#include <linux/device.h>
42#include <linux/interrupt.h> 41#include <linux/interrupt.h>
43 42
diff --git a/drivers/usb/musb/musb_io.h b/drivers/usb/musb/musb_io.h
index 03c6ccdbb3be..e61aa95f2d2a 100644
--- a/drivers/usb/musb/musb_io.h
+++ b/drivers/usb/musb/musb_io.h
@@ -74,7 +74,7 @@ static inline void musb_writel(void __iomem *addr, unsigned offset, u32 data)
74 { __raw_writel(data, addr + offset); } 74 { __raw_writel(data, addr + offset); }
75 75
76 76
77#ifdef CONFIG_USB_MUSB_TUSB6010 77#if defined(CONFIG_USB_MUSB_TUSB6010) || defined (CONFIG_USB_MUSB_TUSB6010_MODULE)
78 78
79/* 79/*
80 * TUSB6010 doesn't allow 8-bit access; 16-bit access is the minimum. 80 * TUSB6010 doesn't allow 8-bit access; 16-bit access is the minimum.
diff --git a/drivers/usb/musb/omap2430.c b/drivers/usb/musb/omap2430.c
index ba85f273e487..c27bbbf32b52 100644
--- a/drivers/usb/musb/omap2430.c
+++ b/drivers/usb/musb/omap2430.c
@@ -29,7 +29,6 @@
29#include <linux/sched.h> 29#include <linux/sched.h>
30#include <linux/init.h> 30#include <linux/init.h>
31#include <linux/list.h> 31#include <linux/list.h>
32#include <linux/clk.h>
33#include <linux/io.h> 32#include <linux/io.h>
34#include <linux/platform_device.h> 33#include <linux/platform_device.h>
35#include <linux/dma-mapping.h> 34#include <linux/dma-mapping.h>
@@ -228,21 +227,25 @@ static int musb_otg_notifications(struct notifier_block *nb,
228 unsigned long event, void *unused) 227 unsigned long event, void *unused)
229{ 228{
230 struct musb *musb = container_of(nb, struct musb, nb); 229 struct musb *musb = container_of(nb, struct musb, nb);
230
231 musb->xceiv_event = event;
232 schedule_work(&musb->otg_notifier_work);
233
234 return 0;
235}
236
237static void musb_otg_notifier_work(struct work_struct *data_notifier_work)
238{
239 struct musb *musb = container_of(data_notifier_work, struct musb, otg_notifier_work);
231 struct device *dev = musb->controller; 240 struct device *dev = musb->controller;
232 struct musb_hdrc_platform_data *pdata = dev->platform_data; 241 struct musb_hdrc_platform_data *pdata = dev->platform_data;
233 struct omap_musb_board_data *data = pdata->board_data; 242 struct omap_musb_board_data *data = pdata->board_data;
234 243
235 switch (event) { 244 switch (musb->xceiv_event) {
236 case USB_EVENT_ID: 245 case USB_EVENT_ID:
237 dev_dbg(musb->controller, "ID GND\n"); 246 dev_dbg(musb->controller, "ID GND\n");
238 247
239 if (is_otg_enabled(musb)) { 248 if (!is_otg_enabled(musb) || musb->gadget_driver) {
240 if (musb->gadget_driver) {
241 pm_runtime_get_sync(musb->controller);
242 otg_init(musb->xceiv);
243 omap2430_musb_set_vbus(musb, 1);
244 }
245 } else {
246 pm_runtime_get_sync(musb->controller); 249 pm_runtime_get_sync(musb->controller);
247 otg_init(musb->xceiv); 250 otg_init(musb->xceiv);
248 omap2430_musb_set_vbus(musb, 1); 251 omap2430_musb_set_vbus(musb, 1);
@@ -274,10 +277,7 @@ static int musb_otg_notifications(struct notifier_block *nb,
274 break; 277 break;
275 default: 278 default:
276 dev_dbg(musb->controller, "ID float\n"); 279 dev_dbg(musb->controller, "ID float\n");
277 return NOTIFY_DONE;
278 } 280 }
279
280 return NOTIFY_OK;
281} 281}
282 282
283static int omap2430_musb_init(struct musb *musb) 283static int omap2430_musb_init(struct musb *musb)
@@ -297,6 +297,8 @@ static int omap2430_musb_init(struct musb *musb)
297 return -ENODEV; 297 return -ENODEV;
298 } 298 }
299 299
300 INIT_WORK(&musb->otg_notifier_work, musb_otg_notifier_work);
301
300 status = pm_runtime_get_sync(dev); 302 status = pm_runtime_get_sync(dev);
301 if (status < 0) { 303 if (status < 0) {
302 dev_err(dev, "pm_runtime_get_sync FAILED"); 304 dev_err(dev, "pm_runtime_get_sync FAILED");
@@ -334,7 +336,6 @@ static int omap2430_musb_init(struct musb *musb)
334 return 0; 336 return 0;
335 337
336err1: 338err1:
337 pm_runtime_disable(dev);
338 return status; 339 return status;
339} 340}
340 341
@@ -350,20 +351,19 @@ static void omap2430_musb_enable(struct musb *musb)
350 351
351 case USB_EVENT_ID: 352 case USB_EVENT_ID:
352 otg_init(musb->xceiv); 353 otg_init(musb->xceiv);
353 if (data->interface_type == MUSB_INTERFACE_UTMI) { 354 if (data->interface_type != MUSB_INTERFACE_UTMI)
354 devctl = musb_readb(musb->mregs, MUSB_DEVCTL); 355 break;
355 /* start the session */ 356 devctl = musb_readb(musb->mregs, MUSB_DEVCTL);
356 devctl |= MUSB_DEVCTL_SESSION; 357 /* start the session */
357 musb_writeb(musb->mregs, MUSB_DEVCTL, devctl); 358 devctl |= MUSB_DEVCTL_SESSION;
358 while (musb_readb(musb->mregs, MUSB_DEVCTL) & 359 musb_writeb(musb->mregs, MUSB_DEVCTL, devctl);
359 MUSB_DEVCTL_BDEVICE) { 360 while (musb_readb(musb->mregs, MUSB_DEVCTL) &
360 cpu_relax(); 361 MUSB_DEVCTL_BDEVICE) {
361 362 cpu_relax();
362 if (time_after(jiffies, timeout)) { 363
363 dev_err(musb->controller, 364 if (time_after(jiffies, timeout)) {
364 "configured as A device timeout"); 365 dev_err(dev, "configured as A device timeout");
365 break; 366 break;
366 }
367 } 367 }
368 } 368 }
369 break; 369 break;
@@ -478,7 +478,6 @@ static int __exit omap2430_remove(struct platform_device *pdev)
478 platform_device_del(glue->musb); 478 platform_device_del(glue->musb);
479 platform_device_put(glue->musb); 479 platform_device_put(glue->musb);
480 pm_runtime_put(&pdev->dev); 480 pm_runtime_put(&pdev->dev);
481 pm_runtime_disable(&pdev->dev);
482 kfree(glue); 481 kfree(glue);
483 482
484 return 0; 483 return 0;
@@ -491,6 +490,9 @@ static int omap2430_runtime_suspend(struct device *dev)
491 struct omap2430_glue *glue = dev_get_drvdata(dev); 490 struct omap2430_glue *glue = dev_get_drvdata(dev);
492 struct musb *musb = glue_to_musb(glue); 491 struct musb *musb = glue_to_musb(glue);
493 492
493 musb->context.otg_interfsel = musb_readl(musb->mregs,
494 OTG_INTERFSEL);
495
494 omap2430_low_level_exit(musb); 496 omap2430_low_level_exit(musb);
495 otg_set_suspend(musb->xceiv, 1); 497 otg_set_suspend(musb->xceiv, 1);
496 498
@@ -503,6 +505,9 @@ static int omap2430_runtime_resume(struct device *dev)
503 struct musb *musb = glue_to_musb(glue); 505 struct musb *musb = glue_to_musb(glue);
504 506
505 omap2430_low_level_init(musb); 507 omap2430_low_level_init(musb);
508 musb_writel(musb->mregs, OTG_INTERFSEL,
509 musb->context.otg_interfsel);
510
506 otg_set_suspend(musb->xceiv, 0); 511 otg_set_suspend(musb->xceiv, 0);
507 512
508 return 0; 513 return 0;
diff --git a/drivers/usb/musb/tusb6010.c b/drivers/usb/musb/tusb6010.c
index ec1480191f78..1f405616e6cd 100644
--- a/drivers/usb/musb/tusb6010.c
+++ b/drivers/usb/musb/tusb6010.c
@@ -56,6 +56,7 @@ u8 tusb_get_revision(struct musb *musb)
56 56
57 return rev; 57 return rev;
58} 58}
59EXPORT_SYMBOL_GPL(tusb_get_revision);
59 60
60static int tusb_print_revision(struct musb *musb) 61static int tusb_print_revision(struct musb *musb)
61{ 62{
diff --git a/drivers/usb/musb/ux500_dma.c b/drivers/usb/musb/ux500_dma.c
index ef4333f4bbe0..a163632877af 100644
--- a/drivers/usb/musb/ux500_dma.c
+++ b/drivers/usb/musb/ux500_dma.c
@@ -37,7 +37,6 @@ struct ux500_dma_channel {
37 struct dma_channel channel; 37 struct dma_channel channel;
38 struct ux500_dma_controller *controller; 38 struct ux500_dma_controller *controller;
39 struct musb_hw_ep *hw_ep; 39 struct musb_hw_ep *hw_ep;
40 struct work_struct channel_work;
41 struct dma_chan *dma_chan; 40 struct dma_chan *dma_chan;
42 unsigned int cur_len; 41 unsigned int cur_len;
43 dma_cookie_t cookie; 42 dma_cookie_t cookie;
@@ -56,31 +55,11 @@ struct ux500_dma_controller {
56 dma_addr_t phy_base; 55 dma_addr_t phy_base;
57}; 56};
58 57
59/* Work function invoked from DMA callback to handle tx transfers. */
60static void ux500_tx_work(struct work_struct *data)
61{
62 struct ux500_dma_channel *ux500_channel = container_of(data,
63 struct ux500_dma_channel, channel_work);
64 struct musb_hw_ep *hw_ep = ux500_channel->hw_ep;
65 struct musb *musb = hw_ep->musb;
66 unsigned long flags;
67
68 dev_dbg(musb->controller, "DMA tx transfer done on hw_ep=%d\n",
69 hw_ep->epnum);
70
71 spin_lock_irqsave(&musb->lock, flags);
72 ux500_channel->channel.actual_len = ux500_channel->cur_len;
73 ux500_channel->channel.status = MUSB_DMA_STATUS_FREE;
74 musb_dma_completion(musb, hw_ep->epnum,
75 ux500_channel->is_tx);
76 spin_unlock_irqrestore(&musb->lock, flags);
77}
78
79/* Work function invoked from DMA callback to handle rx transfers. */ 58/* Work function invoked from DMA callback to handle rx transfers. */
80static void ux500_rx_work(struct work_struct *data) 59void ux500_dma_callback(void *private_data)
81{ 60{
82 struct ux500_dma_channel *ux500_channel = container_of(data, 61 struct dma_channel *channel = private_data;
83 struct ux500_dma_channel, channel_work); 62 struct ux500_dma_channel *ux500_channel = channel->private_data;
84 struct musb_hw_ep *hw_ep = ux500_channel->hw_ep; 63 struct musb_hw_ep *hw_ep = ux500_channel->hw_ep;
85 struct musb *musb = hw_ep->musb; 64 struct musb *musb = hw_ep->musb;
86 unsigned long flags; 65 unsigned long flags;
@@ -94,14 +73,7 @@ static void ux500_rx_work(struct work_struct *data)
94 musb_dma_completion(musb, hw_ep->epnum, 73 musb_dma_completion(musb, hw_ep->epnum,
95 ux500_channel->is_tx); 74 ux500_channel->is_tx);
96 spin_unlock_irqrestore(&musb->lock, flags); 75 spin_unlock_irqrestore(&musb->lock, flags);
97}
98
99void ux500_dma_callback(void *private_data)
100{
101 struct dma_channel *channel = (struct dma_channel *)private_data;
102 struct ux500_dma_channel *ux500_channel = channel->private_data;
103 76
104 schedule_work(&ux500_channel->channel_work);
105} 77}
106 78
107static bool ux500_configure_channel(struct dma_channel *channel, 79static bool ux500_configure_channel(struct dma_channel *channel,
@@ -330,7 +302,6 @@ static int ux500_dma_controller_start(struct dma_controller *c)
330 void **param_array; 302 void **param_array;
331 struct ux500_dma_channel *channel_array; 303 struct ux500_dma_channel *channel_array;
332 u32 ch_count; 304 u32 ch_count;
333 void (*musb_channel_work)(struct work_struct *);
334 dma_cap_mask_t mask; 305 dma_cap_mask_t mask;
335 306
336 if ((data->num_rx_channels > UX500_MUSB_DMA_NUM_RX_CHANNELS) || 307 if ((data->num_rx_channels > UX500_MUSB_DMA_NUM_RX_CHANNELS) ||
@@ -347,7 +318,6 @@ static int ux500_dma_controller_start(struct dma_controller *c)
347 channel_array = controller->rx_channel; 318 channel_array = controller->rx_channel;
348 ch_count = data->num_rx_channels; 319 ch_count = data->num_rx_channels;
349 param_array = data->dma_rx_param_array; 320 param_array = data->dma_rx_param_array;
350 musb_channel_work = ux500_rx_work;
351 321
352 for (dir = 0; dir < 2; dir++) { 322 for (dir = 0; dir < 2; dir++) {
353 for (ch_num = 0; ch_num < ch_count; ch_num++) { 323 for (ch_num = 0; ch_num < ch_count; ch_num++) {
@@ -374,15 +344,12 @@ static int ux500_dma_controller_start(struct dma_controller *c)
374 return -EBUSY; 344 return -EBUSY;
375 } 345 }
376 346
377 INIT_WORK(&ux500_channel->channel_work,
378 musb_channel_work);
379 } 347 }
380 348
381 /* Prepare the loop for TX channels */ 349 /* Prepare the loop for TX channels */
382 channel_array = controller->tx_channel; 350 channel_array = controller->tx_channel;
383 ch_count = data->num_tx_channels; 351 ch_count = data->num_tx_channels;
384 param_array = data->dma_tx_param_array; 352 param_array = data->dma_tx_param_array;
385 musb_channel_work = ux500_tx_work;
386 is_tx = 1; 353 is_tx = 1;
387 } 354 }
388 355