aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/musb
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/usb/musb')
-rw-r--r--drivers/usb/musb/Kconfig16
-rw-r--r--drivers/usb/musb/Makefile1
-rw-r--r--drivers/usb/musb/am35x.c1
-rw-r--r--drivers/usb/musb/blackfin.c5
-rw-r--r--drivers/usb/musb/da8xx.c1
-rw-r--r--drivers/usb/musb/davinci.c1
-rw-r--r--drivers/usb/musb/jz4740.c201
-rw-r--r--drivers/usb/musb/musb_am335x.c1
-rw-r--r--drivers/usb/musb/musb_core.c74
-rw-r--r--drivers/usb/musb/musb_core.h3
-rw-r--r--drivers/usb/musb/musb_cppi41.c2
-rw-r--r--drivers/usb/musb/musb_dsps.c118
-rw-r--r--drivers/usb/musb/musb_gadget.c16
-rw-r--r--drivers/usb/musb/musb_host.c13
-rw-r--r--drivers/usb/musb/musb_host.h6
-rw-r--r--drivers/usb/musb/musb_virthub.c70
-rw-r--r--drivers/usb/musb/tusb6010.c1
-rw-r--r--drivers/usb/musb/tusb6010_omap.c1
-rw-r--r--drivers/usb/musb/ux500.c1
-rw-r--r--drivers/usb/musb/ux500_dma.c4
20 files changed, 450 insertions, 86 deletions
diff --git a/drivers/usb/musb/Kconfig b/drivers/usb/musb/Kconfig
index 57dfc0cedb00..688dc8bb192d 100644
--- a/drivers/usb/musb/Kconfig
+++ b/drivers/usb/musb/Kconfig
@@ -6,7 +6,7 @@
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 tristate 'Inventra Highspeed Dual Role Controller (TI, ADI, ...)'
9 depends on USB_GADGET 9 depends on (USB || USB_GADGET)
10 help 10 help
11 Say Y here if your system has a dual role high speed USB 11 Say Y here if your system has a dual role high speed USB
12 controller based on the Mentor Graphics silicon IP. Then 12 controller based on the Mentor Graphics silicon IP. Then
@@ -35,21 +35,21 @@ choice
35 35
36config USB_MUSB_HOST 36config USB_MUSB_HOST
37 bool "Host only mode" 37 bool "Host only mode"
38 depends on USB 38 depends on USB=y || USB=USB_MUSB_HDRC
39 help 39 help
40 Select this when you want to use MUSB in host mode only, 40 Select this when you want to use MUSB in host mode only,
41 thereby the gadget feature will be regressed. 41 thereby the gadget feature will be regressed.
42 42
43config USB_MUSB_GADGET 43config USB_MUSB_GADGET
44 bool "Gadget only mode" 44 bool "Gadget only mode"
45 depends on USB_GADGET 45 depends on USB_GADGET=y || USB_GADGET=USB_MUSB_HDRC
46 help 46 help
47 Select this when you want to use MUSB in gadget mode only, 47 Select this when you want to use MUSB in gadget mode only,
48 thereby the host feature will be regressed. 48 thereby the host feature will be regressed.
49 49
50config USB_MUSB_DUAL_ROLE 50config USB_MUSB_DUAL_ROLE
51 bool "Dual Role mode" 51 bool "Dual Role mode"
52 depends on (USB && USB_GADGET) 52 depends on ((USB=y || USB=USB_MUSB_HDRC) && (USB_GADGET=y || USB_GADGET=USB_MUSB_HDRC))
53 help 53 help
54 This is the default mode of working of MUSB controller where 54 This is the default mode of working of MUSB controller where
55 both host and gadget features are enabled. 55 both host and gadget features are enabled.
@@ -93,6 +93,12 @@ config USB_MUSB_BLACKFIN
93config USB_MUSB_UX500 93config USB_MUSB_UX500
94 tristate "Ux500 platforms" 94 tristate "Ux500 platforms"
95 95
96config USB_MUSB_JZ4740
97 tristate "JZ4740"
98 depends on MACH_JZ4740 || COMPILE_TEST
99 depends on USB_MUSB_GADGET
100 depends on USB_OTG_BLACKLIST_HUB
101
96endchoice 102endchoice
97 103
98config USB_MUSB_AM335X_CHILD 104config USB_MUSB_AM335X_CHILD
@@ -100,7 +106,7 @@ config USB_MUSB_AM335X_CHILD
100 106
101choice 107choice
102 prompt 'MUSB DMA mode' 108 prompt 'MUSB DMA mode'
103 default MUSB_PIO_ONLY if ARCH_MULTIPLATFORM 109 default MUSB_PIO_ONLY if ARCH_MULTIPLATFORM || USB_MUSB_JZ4740
104 default USB_UX500_DMA if USB_MUSB_UX500 110 default USB_UX500_DMA if USB_MUSB_UX500
105 default USB_INVENTRA_DMA if USB_MUSB_OMAP2PLUS || USB_MUSB_BLACKFIN 111 default USB_INVENTRA_DMA if USB_MUSB_OMAP2PLUS || USB_MUSB_BLACKFIN
106 default USB_TI_CPPI_DMA if USB_MUSB_DAVINCI 112 default USB_TI_CPPI_DMA if USB_MUSB_DAVINCI
diff --git a/drivers/usb/musb/Makefile b/drivers/usb/musb/Makefile
index c5ea5c6dc169..ba495018b416 100644
--- a/drivers/usb/musb/Makefile
+++ b/drivers/usb/musb/Makefile
@@ -19,6 +19,7 @@ obj-$(CONFIG_USB_MUSB_DAVINCI) += davinci.o
19obj-$(CONFIG_USB_MUSB_DA8XX) += da8xx.o 19obj-$(CONFIG_USB_MUSB_DA8XX) += da8xx.o
20obj-$(CONFIG_USB_MUSB_BLACKFIN) += blackfin.o 20obj-$(CONFIG_USB_MUSB_BLACKFIN) += blackfin.o
21obj-$(CONFIG_USB_MUSB_UX500) += ux500.o 21obj-$(CONFIG_USB_MUSB_UX500) += ux500.o
22obj-$(CONFIG_USB_MUSB_JZ4740) += jz4740.o
22 23
23 24
24obj-$(CONFIG_USB_MUSB_AM335X_CHILD) += musb_am335x.o 25obj-$(CONFIG_USB_MUSB_AM335X_CHILD) += musb_am335x.o
diff --git a/drivers/usb/musb/am35x.c b/drivers/usb/musb/am35x.c
index ca45b39db5b9..b3aa0184af9a 100644
--- a/drivers/usb/musb/am35x.c
+++ b/drivers/usb/musb/am35x.c
@@ -26,7 +26,6 @@
26 * 26 *
27 */ 27 */
28 28
29#include <linux/init.h>
30#include <linux/module.h> 29#include <linux/module.h>
31#include <linux/clk.h> 30#include <linux/clk.h>
32#include <linux/err.h> 31#include <linux/err.h>
diff --git a/drivers/usb/musb/blackfin.c b/drivers/usb/musb/blackfin.c
index d9692f78e227..796677fa9a15 100644
--- a/drivers/usb/musb/blackfin.c
+++ b/drivers/usb/musb/blackfin.c
@@ -11,7 +11,6 @@
11#include <linux/module.h> 11#include <linux/module.h>
12#include <linux/kernel.h> 12#include <linux/kernel.h>
13#include <linux/sched.h> 13#include <linux/sched.h>
14#include <linux/init.h>
15#include <linux/list.h> 14#include <linux/list.h>
16#include <linux/gpio.h> 15#include <linux/gpio.h>
17#include <linux/io.h> 16#include <linux/io.h>
@@ -77,7 +76,7 @@ void musb_write_fifo(struct musb_hw_ep *hw_ep, u16 len, const u8 *src)
77 bfin_write16(USB_DMA_REG(epnum, USB_DMAx_CTRL), dma_reg); 76 bfin_write16(USB_DMA_REG(epnum, USB_DMAx_CTRL), dma_reg);
78 SSYNC(); 77 SSYNC();
79 78
80 /* Wait for compelete */ 79 /* Wait for complete */
81 while (!(bfin_read_USB_DMA_INTERRUPT() & (1 << epnum))) 80 while (!(bfin_read_USB_DMA_INTERRUPT() & (1 << epnum)))
82 cpu_relax(); 81 cpu_relax();
83 82
@@ -131,7 +130,7 @@ void musb_read_fifo(struct musb_hw_ep *hw_ep, u16 len, u8 *dst)
131 bfin_write16(USB_DMA_REG(epnum, USB_DMAx_CTRL), dma_reg); 130 bfin_write16(USB_DMA_REG(epnum, USB_DMAx_CTRL), dma_reg);
132 SSYNC(); 131 SSYNC();
133 132
134 /* Wait for compelete */ 133 /* Wait for complete */
135 while (!(bfin_read_USB_DMA_INTERRUPT() & (1 << epnum))) 134 while (!(bfin_read_USB_DMA_INTERRUPT() & (1 << epnum)))
136 cpu_relax(); 135 cpu_relax();
137 136
diff --git a/drivers/usb/musb/da8xx.c b/drivers/usb/musb/da8xx.c
index 2f2c1cb36421..e3486de71995 100644
--- a/drivers/usb/musb/da8xx.c
+++ b/drivers/usb/musb/da8xx.c
@@ -26,7 +26,6 @@
26 * 26 *
27 */ 27 */
28 28
29#include <linux/init.h>
30#include <linux/module.h> 29#include <linux/module.h>
31#include <linux/clk.h> 30#include <linux/clk.h>
32#include <linux/err.h> 31#include <linux/err.h>
diff --git a/drivers/usb/musb/davinci.c b/drivers/usb/musb/davinci.c
index 1121fd741bf8..c259dac9d056 100644
--- a/drivers/usb/musb/davinci.c
+++ b/drivers/usb/musb/davinci.c
@@ -24,7 +24,6 @@
24#include <linux/module.h> 24#include <linux/module.h>
25#include <linux/kernel.h> 25#include <linux/kernel.h>
26#include <linux/sched.h> 26#include <linux/sched.h>
27#include <linux/init.h>
28#include <linux/list.h> 27#include <linux/list.h>
29#include <linux/delay.h> 28#include <linux/delay.h>
30#include <linux/clk.h> 29#include <linux/clk.h>
diff --git a/drivers/usb/musb/jz4740.c b/drivers/usb/musb/jz4740.c
new file mode 100644
index 000000000000..5f30537f1927
--- /dev/null
+++ b/drivers/usb/musb/jz4740.c
@@ -0,0 +1,201 @@
1/*
2 * Ingenic JZ4740 "glue layer"
3 *
4 * Copyright (C) 2013, Apelete Seketeli <apelete@seketeli.net>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * You should have received a copy of the GNU General Public License along
12 * with this program; if not, write to the Free Software Foundation, Inc.,
13 * 675 Mass Ave, Cambridge, MA 02139, USA.
14 */
15
16#include <linux/clk.h>
17#include <linux/dma-mapping.h>
18#include <linux/errno.h>
19#include <linux/kernel.h>
20#include <linux/module.h>
21#include <linux/platform_device.h>
22
23#include "musb_core.h"
24
25struct jz4740_glue {
26 struct device *dev;
27 struct platform_device *musb;
28 struct clk *clk;
29};
30
31static irqreturn_t jz4740_musb_interrupt(int irq, void *__hci)
32{
33 unsigned long flags;
34 irqreturn_t retval = IRQ_NONE;
35 struct musb *musb = __hci;
36
37 spin_lock_irqsave(&musb->lock, flags);
38
39 musb->int_usb = musb_readb(musb->mregs, MUSB_INTRUSB);
40 musb->int_tx = musb_readw(musb->mregs, MUSB_INTRTX);
41 musb->int_rx = musb_readw(musb->mregs, MUSB_INTRRX);
42
43 /*
44 * The controller is gadget only, the state of the host mode IRQ bits is
45 * undefined. Mask them to make sure that the musb driver core will
46 * never see them set
47 */
48 musb->int_usb &= MUSB_INTR_SUSPEND | MUSB_INTR_RESUME |
49 MUSB_INTR_RESET | MUSB_INTR_SOF;
50
51 if (musb->int_usb || musb->int_tx || musb->int_rx)
52 retval = musb_interrupt(musb);
53
54 spin_unlock_irqrestore(&musb->lock, flags);
55
56 return retval;
57}
58
59static struct musb_fifo_cfg jz4740_musb_fifo_cfg[] = {
60{ .hw_ep_num = 1, .style = FIFO_TX, .maxpacket = 512, },
61{ .hw_ep_num = 1, .style = FIFO_RX, .maxpacket = 512, },
62{ .hw_ep_num = 2, .style = FIFO_TX, .maxpacket = 64, },
63};
64
65static struct musb_hdrc_config jz4740_musb_config = {
66 /* Silicon does not implement USB OTG. */
67 .multipoint = 0,
68 /* Max EPs scanned, driver will decide which EP can be used. */
69 .num_eps = 4,
70 /* RAMbits needed to configure EPs from table */
71 .ram_bits = 9,
72 .fifo_cfg = jz4740_musb_fifo_cfg,
73 .fifo_cfg_size = ARRAY_SIZE(jz4740_musb_fifo_cfg),
74};
75
76static struct musb_hdrc_platform_data jz4740_musb_platform_data = {
77 .mode = MUSB_PERIPHERAL,
78 .config = &jz4740_musb_config,
79};
80
81static int jz4740_musb_init(struct musb *musb)
82{
83 musb->xceiv = usb_get_phy(USB_PHY_TYPE_USB2);
84 if (!musb->xceiv) {
85 pr_err("HS UDC: no transceiver configured\n");
86 return -ENODEV;
87 }
88
89 /* Silicon does not implement ConfigData register.
90 * Set dyn_fifo to avoid reading EP config from hardware.
91 */
92 musb->dyn_fifo = true;
93
94 musb->isr = jz4740_musb_interrupt;
95
96 return 0;
97}
98
99static int jz4740_musb_exit(struct musb *musb)
100{
101 usb_put_phy(musb->xceiv);
102
103 return 0;
104}
105
106static const struct musb_platform_ops jz4740_musb_ops = {
107 .init = jz4740_musb_init,
108 .exit = jz4740_musb_exit,
109};
110
111static int jz4740_probe(struct platform_device *pdev)
112{
113 struct musb_hdrc_platform_data *pdata = &jz4740_musb_platform_data;
114 struct platform_device *musb;
115 struct jz4740_glue *glue;
116 struct clk *clk;
117 int ret;
118
119 glue = devm_kzalloc(&pdev->dev, sizeof(*glue), GFP_KERNEL);
120 if (!glue)
121 return -ENOMEM;
122
123 musb = platform_device_alloc("musb-hdrc", PLATFORM_DEVID_AUTO);
124 if (!musb) {
125 dev_err(&pdev->dev, "failed to allocate musb device\n");
126 return -ENOMEM;
127 }
128
129 clk = devm_clk_get(&pdev->dev, "udc");
130 if (IS_ERR(clk)) {
131 dev_err(&pdev->dev, "failed to get clock\n");
132 ret = PTR_ERR(clk);
133 goto err_platform_device_put;
134 }
135
136 ret = clk_prepare_enable(clk);
137 if (ret) {
138 dev_err(&pdev->dev, "failed to enable clock\n");
139 goto err_platform_device_put;
140 }
141
142 musb->dev.parent = &pdev->dev;
143
144 glue->dev = &pdev->dev;
145 glue->musb = musb;
146 glue->clk = clk;
147
148 pdata->platform_ops = &jz4740_musb_ops;
149
150 platform_set_drvdata(pdev, glue);
151
152 ret = platform_device_add_resources(musb, pdev->resource,
153 pdev->num_resources);
154 if (ret) {
155 dev_err(&pdev->dev, "failed to add resources\n");
156 goto err_clk_disable;
157 }
158
159 ret = platform_device_add_data(musb, pdata, sizeof(*pdata));
160 if (ret) {
161 dev_err(&pdev->dev, "failed to add platform_data\n");
162 goto err_clk_disable;
163 }
164
165 ret = platform_device_add(musb);
166 if (ret) {
167 dev_err(&pdev->dev, "failed to register musb device\n");
168 goto err_clk_disable;
169 }
170
171 return 0;
172
173err_clk_disable:
174 clk_disable_unprepare(clk);
175err_platform_device_put:
176 platform_device_put(musb);
177 return ret;
178}
179
180static int jz4740_remove(struct platform_device *pdev)
181{
182 struct jz4740_glue *glue = platform_get_drvdata(pdev);
183
184 platform_device_unregister(glue->musb);
185 clk_disable_unprepare(glue->clk);
186
187 return 0;
188}
189
190static struct platform_driver jz4740_driver = {
191 .probe = jz4740_probe,
192 .remove = jz4740_remove,
193 .driver = {
194 .name = "musb-jz4740",
195 },
196};
197
198MODULE_DESCRIPTION("JZ4740 MUSB Glue Layer");
199MODULE_AUTHOR("Apelete Seketeli <apelete@seketeli.net>");
200MODULE_LICENSE("GPL v2");
201module_platform_driver(jz4740_driver);
diff --git a/drivers/usb/musb/musb_am335x.c b/drivers/usb/musb/musb_am335x.c
index 8be9b02c3cc2..d2353781bd2d 100644
--- a/drivers/usb/musb/musb_am335x.c
+++ b/drivers/usb/musb/musb_am335x.c
@@ -1,4 +1,3 @@
1#include <linux/init.h>
2#include <linux/platform_device.h> 1#include <linux/platform_device.h>
3#include <linux/pm_runtime.h> 2#include <linux/pm_runtime.h>
4#include <linux/module.h> 3#include <linux/module.h>
diff --git a/drivers/usb/musb/musb_core.c b/drivers/usb/musb/musb_core.c
index 4d4499b80449..fc192ad9cc6a 100644
--- a/drivers/usb/musb/musb_core.c
+++ b/drivers/usb/musb/musb_core.c
@@ -83,7 +83,7 @@
83 * This gets many kinds of configuration information: 83 * This gets many kinds of configuration information:
84 * - Kconfig for everything user-configurable 84 * - Kconfig for everything user-configurable
85 * - platform_device for addressing, irq, and platform_data 85 * - platform_device for addressing, irq, and platform_data
86 * - platform_data is mostly for board-specific informarion 86 * - platform_data is mostly for board-specific information
87 * (plus recentrly, SOC or family details) 87 * (plus recentrly, SOC or family details)
88 * 88 *
89 * Most of the conditional compilation will (someday) vanish. 89 * Most of the conditional compilation will (someday) vanish.
@@ -93,7 +93,6 @@
93#include <linux/kernel.h> 93#include <linux/kernel.h>
94#include <linux/sched.h> 94#include <linux/sched.h>
95#include <linux/slab.h> 95#include <linux/slab.h>
96#include <linux/init.h>
97#include <linux/list.h> 96#include <linux/list.h>
98#include <linux/kobject.h> 97#include <linux/kobject.h>
99#include <linux/prefetch.h> 98#include <linux/prefetch.h>
@@ -478,8 +477,8 @@ static irqreturn_t musb_stage0_irq(struct musb *musb, u8 int_usb,
478 musb->port1_status |= 477 musb->port1_status |=
479 (USB_PORT_STAT_C_SUSPEND << 16) 478 (USB_PORT_STAT_C_SUSPEND << 16)
480 | MUSB_PORT_STAT_RESUME; 479 | MUSB_PORT_STAT_RESUME;
481 musb->rh_timer = jiffies 480 schedule_delayed_work(
482 + msecs_to_jiffies(20); 481 &musb->finish_resume_work, 20);
483 482
484 musb->xceiv->state = OTG_STATE_A_HOST; 483 musb->xceiv->state = OTG_STATE_A_HOST;
485 musb->is_active = 1; 484 musb->is_active = 1;
@@ -1187,7 +1186,7 @@ fifo_setup(struct musb *musb, struct musb_hw_ep *hw_ep,
1187 musb_writeb(mbase, MUSB_INDEX, hw_ep->epnum); 1186 musb_writeb(mbase, MUSB_INDEX, hw_ep->epnum);
1188 1187
1189 /* EP0 reserved endpoint for control, bidirectional; 1188 /* EP0 reserved endpoint for control, bidirectional;
1190 * EP1 reserved for bulk, two unidirection halves. 1189 * EP1 reserved for bulk, two unidirectional halves.
1191 */ 1190 */
1192 if (hw_ep->epnum == 1) 1191 if (hw_ep->epnum == 1)
1193 musb->bulk_ep = hw_ep; 1192 musb->bulk_ep = hw_ep;
@@ -1813,6 +1812,21 @@ static void musb_free(struct musb *musb)
1813 musb_host_free(musb); 1812 musb_host_free(musb);
1814} 1813}
1815 1814
1815static void musb_deassert_reset(struct work_struct *work)
1816{
1817 struct musb *musb;
1818 unsigned long flags;
1819
1820 musb = container_of(work, struct musb, deassert_reset_work.work);
1821
1822 spin_lock_irqsave(&musb->lock, flags);
1823
1824 if (musb->port1_status & USB_PORT_STAT_RESET)
1825 musb_port_reset(musb, false);
1826
1827 spin_unlock_irqrestore(&musb->lock, flags);
1828}
1829
1816/* 1830/*
1817 * Perform generic per-controller initialization. 1831 * Perform generic per-controller initialization.
1818 * 1832 *
@@ -1857,7 +1871,7 @@ musb_init_controller(struct device *dev, int nIrq, void __iomem *ctrl)
1857 /* The musb_platform_init() call: 1871 /* The musb_platform_init() call:
1858 * - adjusts musb->mregs 1872 * - adjusts musb->mregs
1859 * - sets the musb->isr 1873 * - sets the musb->isr
1860 * - may initialize an integrated tranceiver 1874 * - may initialize an integrated transceiver
1861 * - initializes musb->xceiv, usually by otg_get_phy() 1875 * - initializes musb->xceiv, usually by otg_get_phy()
1862 * - stops powering VBUS 1876 * - stops powering VBUS
1863 * 1877 *
@@ -1897,6 +1911,8 @@ musb_init_controller(struct device *dev, int nIrq, void __iomem *ctrl)
1897 1911
1898 /* Init IRQ workqueue before request_irq */ 1912 /* Init IRQ workqueue before request_irq */
1899 INIT_WORK(&musb->irq_work, musb_irq_work); 1913 INIT_WORK(&musb->irq_work, musb_irq_work);
1914 INIT_DELAYED_WORK(&musb->deassert_reset_work, musb_deassert_reset);
1915 INIT_DELAYED_WORK(&musb->finish_resume_work, musb_host_finish_resume);
1900 1916
1901 /* setup musb parts of the core (especially endpoints) */ 1917 /* setup musb parts of the core (especially endpoints) */
1902 status = musb_core_init(plat->config->multipoint 1918 status = musb_core_init(plat->config->multipoint
@@ -1940,17 +1956,26 @@ musb_init_controller(struct device *dev, int nIrq, void __iomem *ctrl)
1940 switch (musb->port_mode) { 1956 switch (musb->port_mode) {
1941 case MUSB_PORT_MODE_HOST: 1957 case MUSB_PORT_MODE_HOST:
1942 status = musb_host_setup(musb, plat->power); 1958 status = musb_host_setup(musb, plat->power);
1959 if (status < 0)
1960 goto fail3;
1961 status = musb_platform_set_mode(musb, MUSB_HOST);
1943 break; 1962 break;
1944 case MUSB_PORT_MODE_GADGET: 1963 case MUSB_PORT_MODE_GADGET:
1945 status = musb_gadget_setup(musb); 1964 status = musb_gadget_setup(musb);
1965 if (status < 0)
1966 goto fail3;
1967 status = musb_platform_set_mode(musb, MUSB_PERIPHERAL);
1946 break; 1968 break;
1947 case MUSB_PORT_MODE_DUAL_ROLE: 1969 case MUSB_PORT_MODE_DUAL_ROLE:
1948 status = musb_host_setup(musb, plat->power); 1970 status = musb_host_setup(musb, plat->power);
1949 if (status < 0) 1971 if (status < 0)
1950 goto fail3; 1972 goto fail3;
1951 status = musb_gadget_setup(musb); 1973 status = musb_gadget_setup(musb);
1952 if (status) 1974 if (status) {
1953 musb_host_cleanup(musb); 1975 musb_host_cleanup(musb);
1976 goto fail3;
1977 }
1978 status = musb_platform_set_mode(musb, MUSB_OTG);
1954 break; 1979 break;
1955 default: 1980 default:
1956 dev_err(dev, "unsupported port mode %d\n", musb->port_mode); 1981 dev_err(dev, "unsupported port mode %d\n", musb->port_mode);
@@ -1981,6 +2006,8 @@ fail4:
1981 2006
1982fail3: 2007fail3:
1983 cancel_work_sync(&musb->irq_work); 2008 cancel_work_sync(&musb->irq_work);
2009 cancel_delayed_work_sync(&musb->finish_resume_work);
2010 cancel_delayed_work_sync(&musb->deassert_reset_work);
1984 if (musb->dma_controller) 2011 if (musb->dma_controller)
1985 dma_controller_destroy(musb->dma_controller); 2012 dma_controller_destroy(musb->dma_controller);
1986fail2_5: 2013fail2_5:
@@ -2044,6 +2071,8 @@ static int musb_remove(struct platform_device *pdev)
2044 dma_controller_destroy(musb->dma_controller); 2071 dma_controller_destroy(musb->dma_controller);
2045 2072
2046 cancel_work_sync(&musb->irq_work); 2073 cancel_work_sync(&musb->irq_work);
2074 cancel_delayed_work_sync(&musb->finish_resume_work);
2075 cancel_delayed_work_sync(&musb->deassert_reset_work);
2047 musb_free(musb); 2076 musb_free(musb);
2048 device_init_wakeup(dev, 0); 2077 device_init_wakeup(dev, 0);
2049 return 0; 2078 return 0;
@@ -2216,16 +2245,28 @@ static int musb_suspend(struct device *dev)
2216 */ 2245 */
2217 } 2246 }
2218 2247
2248 musb_save_context(musb);
2249
2219 spin_unlock_irqrestore(&musb->lock, flags); 2250 spin_unlock_irqrestore(&musb->lock, flags);
2220 return 0; 2251 return 0;
2221} 2252}
2222 2253
2223static int musb_resume_noirq(struct device *dev) 2254static int musb_resume_noirq(struct device *dev)
2224{ 2255{
2225 /* for static cmos like DaVinci, register values were preserved 2256 struct musb *musb = dev_to_musb(dev);
2257
2258 /*
2259 * For static cmos like DaVinci, register values were preserved
2226 * unless for some reason the whole soc powered down or the USB 2260 * unless for some reason the whole soc powered down or the USB
2227 * module got reset through the PSC (vs just being disabled). 2261 * module got reset through the PSC (vs just being disabled).
2262 *
2263 * For the DSPS glue layer though, a full register restore has to
2264 * be done. As it shouldn't harm other platforms, we do it
2265 * unconditionally.
2228 */ 2266 */
2267
2268 musb_restore_context(musb);
2269
2229 return 0; 2270 return 0;
2230} 2271}
2231 2272
@@ -2283,19 +2324,4 @@ static struct platform_driver musb_driver = {
2283 .shutdown = musb_shutdown, 2324 .shutdown = musb_shutdown,
2284}; 2325};
2285 2326
2286/*-------------------------------------------------------------------------*/ 2327module_platform_driver(musb_driver);
2287
2288static int __init musb_init(void)
2289{
2290 if (usb_disabled())
2291 return 0;
2292
2293 return platform_driver_register(&musb_driver);
2294}
2295module_init(musb_init);
2296
2297static void __exit musb_cleanup(void)
2298{
2299 platform_driver_unregister(&musb_driver);
2300}
2301module_exit(musb_cleanup);
diff --git a/drivers/usb/musb/musb_core.h b/drivers/usb/musb/musb_core.h
index 29f7cd7c7964..7083e82776ff 100644
--- a/drivers/usb/musb/musb_core.h
+++ b/drivers/usb/musb/musb_core.h
@@ -47,6 +47,7 @@
47#include <linux/usb/otg.h> 47#include <linux/usb/otg.h>
48#include <linux/usb/musb.h> 48#include <linux/usb/musb.h>
49#include <linux/phy/phy.h> 49#include <linux/phy/phy.h>
50#include <linux/workqueue.h>
50 51
51struct musb; 52struct musb;
52struct musb_hw_ep; 53struct musb_hw_ep;
@@ -295,6 +296,8 @@ struct musb {
295 296
296 irqreturn_t (*isr)(int, void *); 297 irqreturn_t (*isr)(int, void *);
297 struct work_struct irq_work; 298 struct work_struct irq_work;
299 struct delayed_work deassert_reset_work;
300 struct delayed_work finish_resume_work;
298 u16 hwvers; 301 u16 hwvers;
299 302
300 u16 intrrxe; 303 u16 intrrxe;
diff --git a/drivers/usb/musb/musb_cppi41.c b/drivers/usb/musb/musb_cppi41.c
index a12bd30401e0..f88929609bac 100644
--- a/drivers/usb/musb/musb_cppi41.c
+++ b/drivers/usb/musb/musb_cppi41.c
@@ -615,7 +615,7 @@ static int cppi41_dma_controller_start(struct cppi41_dma_controller *controller)
615 615
616 dc = dma_request_slave_channel(dev, str); 616 dc = dma_request_slave_channel(dev, str);
617 if (!dc) { 617 if (!dc) {
618 dev_err(dev, "Falied to request %s.\n", str); 618 dev_err(dev, "Failed to request %s.\n", str);
619 ret = -EPROBE_DEFER; 619 ret = -EPROBE_DEFER;
620 goto err; 620 goto err;
621 } 621 }
diff --git a/drivers/usb/musb/musb_dsps.c b/drivers/usb/musb/musb_dsps.c
index 1901f6fe5807..7a109eae9b9a 100644
--- a/drivers/usb/musb/musb_dsps.c
+++ b/drivers/usb/musb/musb_dsps.c
@@ -29,7 +29,6 @@
29 * da8xx.c would be merged to this file after testing. 29 * da8xx.c would be merged to this file after testing.
30 */ 30 */
31 31
32#include <linux/init.h>
33#include <linux/io.h> 32#include <linux/io.h>
34#include <linux/err.h> 33#include <linux/err.h>
35#include <linux/platform_device.h> 34#include <linux/platform_device.h>
@@ -83,6 +82,8 @@ struct dsps_musb_wrapper {
83 u16 coreintr_status; 82 u16 coreintr_status;
84 u16 phy_utmi; 83 u16 phy_utmi;
85 u16 mode; 84 u16 mode;
85 u16 tx_mode;
86 u16 rx_mode;
86 87
87 /* bit positions for control */ 88 /* bit positions for control */
88 unsigned reset:5; 89 unsigned reset:5;
@@ -106,10 +107,24 @@ struct dsps_musb_wrapper {
106 107
107 /* bit positions for mode */ 108 /* bit positions for mode */
108 unsigned iddig:5; 109 unsigned iddig:5;
110 unsigned iddig_mux:5;
109 /* miscellaneous stuff */ 111 /* miscellaneous stuff */
110 u8 poll_seconds; 112 u8 poll_seconds;
111}; 113};
112 114
115/*
116 * register shadow for suspend
117 */
118struct dsps_context {
119 u32 control;
120 u32 epintr;
121 u32 coreintr;
122 u32 phy_utmi;
123 u32 mode;
124 u32 tx_mode;
125 u32 rx_mode;
126};
127
113/** 128/**
114 * DSPS glue structure. 129 * DSPS glue structure.
115 */ 130 */
@@ -119,6 +134,8 @@ struct dsps_glue {
119 const struct dsps_musb_wrapper *wrp; /* wrapper register offsets */ 134 const struct dsps_musb_wrapper *wrp; /* wrapper register offsets */
120 struct timer_list timer; /* otg_workaround timer */ 135 struct timer_list timer; /* otg_workaround timer */
121 unsigned long last_timer; /* last timer data for each instance */ 136 unsigned long last_timer; /* last timer data for each instance */
137
138 struct dsps_context context;
122}; 139};
123 140
124static void dsps_musb_try_idle(struct musb *musb, unsigned long timeout) 141static void dsps_musb_try_idle(struct musb *musb, unsigned long timeout)
@@ -341,8 +358,9 @@ static irqreturn_t dsps_interrupt(int irq, void *hci)
341 if (musb->int_tx || musb->int_rx || musb->int_usb) 358 if (musb->int_tx || musb->int_rx || musb->int_usb)
342 ret |= musb_interrupt(musb); 359 ret |= musb_interrupt(musb);
343 360
344 /* Poll for ID change */ 361 /* Poll for ID change in OTG port mode */
345 if (musb->xceiv->state == OTG_STATE_B_IDLE) 362 if (musb->xceiv->state == OTG_STATE_B_IDLE &&
363 musb->port_mode == MUSB_PORT_MODE_DUAL_ROLE)
346 mod_timer(&glue->timer, jiffies + wrp->poll_seconds * HZ); 364 mod_timer(&glue->timer, jiffies + wrp->poll_seconds * HZ);
347out: 365out:
348 spin_unlock_irqrestore(&musb->lock, flags); 366 spin_unlock_irqrestore(&musb->lock, flags);
@@ -406,6 +424,54 @@ static int dsps_musb_exit(struct musb *musb)
406 return 0; 424 return 0;
407} 425}
408 426
427static int dsps_musb_set_mode(struct musb *musb, u8 mode)
428{
429 struct device *dev = musb->controller;
430 struct dsps_glue *glue = dev_get_drvdata(dev->parent);
431 const struct dsps_musb_wrapper *wrp = glue->wrp;
432 void __iomem *ctrl_base = musb->ctrl_base;
433 void __iomem *base = musb->mregs;
434 u32 reg;
435
436 reg = dsps_readl(base, wrp->mode);
437
438 switch (mode) {
439 case MUSB_HOST:
440 reg &= ~(1 << wrp->iddig);
441
442 /*
443 * if we're setting mode to host-only or device-only, we're
444 * going to ignore whatever the PHY sends us and just force
445 * ID pin status by SW
446 */
447 reg |= (1 << wrp->iddig_mux);
448
449 dsps_writel(base, wrp->mode, reg);
450 dsps_writel(ctrl_base, wrp->phy_utmi, 0x02);
451 break;
452 case MUSB_PERIPHERAL:
453 reg |= (1 << wrp->iddig);
454
455 /*
456 * if we're setting mode to host-only or device-only, we're
457 * going to ignore whatever the PHY sends us and just force
458 * ID pin status by SW
459 */
460 reg |= (1 << wrp->iddig_mux);
461
462 dsps_writel(base, wrp->mode, reg);
463 break;
464 case MUSB_OTG:
465 dsps_writel(base, wrp->phy_utmi, 0x02);
466 break;
467 default:
468 dev_err(glue->dev, "unsupported mode %d\n", mode);
469 return -EINVAL;
470 }
471
472 return 0;
473}
474
409static struct musb_platform_ops dsps_ops = { 475static struct musb_platform_ops dsps_ops = {
410 .init = dsps_musb_init, 476 .init = dsps_musb_init,
411 .exit = dsps_musb_exit, 477 .exit = dsps_musb_exit,
@@ -414,6 +480,7 @@ static struct musb_platform_ops dsps_ops = {
414 .disable = dsps_musb_disable, 480 .disable = dsps_musb_disable,
415 481
416 .try_idle = dsps_musb_try_idle, 482 .try_idle = dsps_musb_try_idle,
483 .set_mode = dsps_musb_set_mode,
417}; 484};
418 485
419static u64 musb_dmamask = DMA_BIT_MASK(32); 486static u64 musb_dmamask = DMA_BIT_MASK(32);
@@ -507,6 +574,7 @@ static int dsps_create_musb_pdev(struct dsps_glue *glue,
507 574
508 config->num_eps = get_int_prop(dn, "mentor,num-eps"); 575 config->num_eps = get_int_prop(dn, "mentor,num-eps");
509 config->ram_bits = get_int_prop(dn, "mentor,ram-bits"); 576 config->ram_bits = get_int_prop(dn, "mentor,ram-bits");
577 config->host_port_deassert_reset_at_resume = 1;
510 pdata.mode = get_musb_port_mode(dev); 578 pdata.mode = get_musb_port_mode(dev);
511 /* DT keeps this entry in mA, musb expects it as per USB spec */ 579 /* DT keeps this entry in mA, musb expects it as per USB spec */
512 pdata.power = get_int_prop(dn, "mentor,power") / 2; 580 pdata.power = get_int_prop(dn, "mentor,power") / 2;
@@ -605,9 +673,12 @@ static const struct dsps_musb_wrapper am33xx_driver_data = {
605 .coreintr_status = 0x34, 673 .coreintr_status = 0x34,
606 .phy_utmi = 0xe0, 674 .phy_utmi = 0xe0,
607 .mode = 0xe8, 675 .mode = 0xe8,
676 .tx_mode = 0x70,
677 .rx_mode = 0x74,
608 .reset = 0, 678 .reset = 0,
609 .otg_disable = 21, 679 .otg_disable = 21,
610 .iddig = 8, 680 .iddig = 8,
681 .iddig_mux = 7,
611 .usb_shift = 0, 682 .usb_shift = 0,
612 .usb_mask = 0x1ff, 683 .usb_mask = 0x1ff,
613 .usb_bitmap = (0x1ff << 0), 684 .usb_bitmap = (0x1ff << 0),
@@ -628,11 +699,52 @@ static const struct of_device_id musb_dsps_of_match[] = {
628}; 699};
629MODULE_DEVICE_TABLE(of, musb_dsps_of_match); 700MODULE_DEVICE_TABLE(of, musb_dsps_of_match);
630 701
702#ifdef CONFIG_PM
703static int dsps_suspend(struct device *dev)
704{
705 struct dsps_glue *glue = dev_get_drvdata(dev);
706 const struct dsps_musb_wrapper *wrp = glue->wrp;
707 struct musb *musb = platform_get_drvdata(glue->musb);
708 void __iomem *mbase = musb->ctrl_base;
709
710 glue->context.control = dsps_readl(mbase, wrp->control);
711 glue->context.epintr = dsps_readl(mbase, wrp->epintr_set);
712 glue->context.coreintr = dsps_readl(mbase, wrp->coreintr_set);
713 glue->context.phy_utmi = dsps_readl(mbase, wrp->phy_utmi);
714 glue->context.mode = dsps_readl(mbase, wrp->mode);
715 glue->context.tx_mode = dsps_readl(mbase, wrp->tx_mode);
716 glue->context.rx_mode = dsps_readl(mbase, wrp->rx_mode);
717
718 return 0;
719}
720
721static int dsps_resume(struct device *dev)
722{
723 struct dsps_glue *glue = dev_get_drvdata(dev);
724 const struct dsps_musb_wrapper *wrp = glue->wrp;
725 struct musb *musb = platform_get_drvdata(glue->musb);
726 void __iomem *mbase = musb->ctrl_base;
727
728 dsps_writel(mbase, wrp->control, glue->context.control);
729 dsps_writel(mbase, wrp->epintr_set, glue->context.epintr);
730 dsps_writel(mbase, wrp->coreintr_set, glue->context.coreintr);
731 dsps_writel(mbase, wrp->phy_utmi, glue->context.phy_utmi);
732 dsps_writel(mbase, wrp->mode, glue->context.mode);
733 dsps_writel(mbase, wrp->tx_mode, glue->context.tx_mode);
734 dsps_writel(mbase, wrp->rx_mode, glue->context.rx_mode);
735
736 return 0;
737}
738#endif
739
740static SIMPLE_DEV_PM_OPS(dsps_pm_ops, dsps_suspend, dsps_resume);
741
631static struct platform_driver dsps_usbss_driver = { 742static struct platform_driver dsps_usbss_driver = {
632 .probe = dsps_probe, 743 .probe = dsps_probe,
633 .remove = dsps_remove, 744 .remove = dsps_remove,
634 .driver = { 745 .driver = {
635 .name = "musb-dsps", 746 .name = "musb-dsps",
747 .pm = &dsps_pm_ops,
636 .of_match_table = musb_dsps_of_match, 748 .of_match_table = musb_dsps_of_match,
637 }, 749 },
638}; 750};
diff --git a/drivers/usb/musb/musb_gadget.c b/drivers/usb/musb/musb_gadget.c
index 32fb057c03f5..d4aa779339f1 100644
--- a/drivers/usb/musb/musb_gadget.c
+++ b/drivers/usb/musb/musb_gadget.c
@@ -1727,14 +1727,14 @@ init_peripheral_ep(struct musb *musb, struct musb_ep *ep, u8 epnum, int is_in)
1727 ep->end_point.name = ep->name; 1727 ep->end_point.name = ep->name;
1728 INIT_LIST_HEAD(&ep->end_point.ep_list); 1728 INIT_LIST_HEAD(&ep->end_point.ep_list);
1729 if (!epnum) { 1729 if (!epnum) {
1730 ep->end_point.maxpacket = 64; 1730 usb_ep_set_maxpacket_limit(&ep->end_point, 64);
1731 ep->end_point.ops = &musb_g_ep0_ops; 1731 ep->end_point.ops = &musb_g_ep0_ops;
1732 musb->g.ep0 = &ep->end_point; 1732 musb->g.ep0 = &ep->end_point;
1733 } else { 1733 } else {
1734 if (is_in) 1734 if (is_in)
1735 ep->end_point.maxpacket = hw_ep->max_packet_sz_tx; 1735 usb_ep_set_maxpacket_limit(&ep->end_point, hw_ep->max_packet_sz_tx);
1736 else 1736 else
1737 ep->end_point.maxpacket = hw_ep->max_packet_sz_rx; 1737 usb_ep_set_maxpacket_limit(&ep->end_point, hw_ep->max_packet_sz_rx);
1738 ep->end_point.ops = &musb_ep_ops; 1738 ep->end_point.ops = &musb_ep_ops;
1739 list_add_tail(&ep->end_point.ep_list, &musb->g.ep_list); 1739 list_add_tail(&ep->end_point.ep_list, &musb->g.ep_list);
1740 } 1740 }
@@ -2119,7 +2119,15 @@ __acquires(musb->lock)
2119 /* Normal reset, as B-Device; 2119 /* Normal reset, as B-Device;
2120 * or else after HNP, as A-Device 2120 * or else after HNP, as A-Device
2121 */ 2121 */
2122 if (devctl & MUSB_DEVCTL_BDEVICE) { 2122 if (!musb->g.is_otg) {
2123 /* USB device controllers that are not OTG compatible
2124 * may not have DEVCTL register in silicon.
2125 * In that case, do not rely on devctl for setting
2126 * peripheral mode.
2127 */
2128 musb->xceiv->state = OTG_STATE_B_PERIPHERAL;
2129 musb->g.is_a_peripheral = 0;
2130 } else if (devctl & MUSB_DEVCTL_BDEVICE) {
2123 musb->xceiv->state = OTG_STATE_B_PERIPHERAL; 2131 musb->xceiv->state = OTG_STATE_B_PERIPHERAL;
2124 musb->g.is_a_peripheral = 0; 2132 musb->g.is_a_peripheral = 0;
2125 } else { 2133 } else {
diff --git a/drivers/usb/musb/musb_host.c b/drivers/usb/musb/musb_host.c
index 6582a20bec05..ed455724017b 100644
--- a/drivers/usb/musb/musb_host.c
+++ b/drivers/usb/musb/musb_host.c
@@ -39,7 +39,6 @@
39#include <linux/sched.h> 39#include <linux/sched.h>
40#include <linux/slab.h> 40#include <linux/slab.h>
41#include <linux/errno.h> 41#include <linux/errno.h>
42#include <linux/init.h>
43#include <linux/list.h> 42#include <linux/list.h>
44#include <linux/dma-mapping.h> 43#include <linux/dma-mapping.h>
45 44
@@ -2013,7 +2012,7 @@ static int musb_schedule(
2013 head = &musb->out_bulk; 2012 head = &musb->out_bulk;
2014 2013
2015 /* Enable bulk RX/TX NAK timeout scheme when bulk requests are 2014 /* Enable bulk RX/TX NAK timeout scheme when bulk requests are
2016 * multiplexed. This scheme doen't work in high speed to full 2015 * multiplexed. This scheme does not work in high speed to full
2017 * speed scenario as NAK interrupts are not coming from a 2016 * speed scenario as NAK interrupts are not coming from a
2018 * full speed device connected to a high speed device. 2017 * full speed device connected to a high speed device.
2019 * NAK timeout interval is 8 (128 uframe or 16ms) for HS and 2018 * NAK timeout interval is 8 (128 uframe or 16ms) for HS and
@@ -2433,6 +2432,8 @@ static int musb_bus_suspend(struct usb_hcd *hcd)
2433 struct musb *musb = hcd_to_musb(hcd); 2432 struct musb *musb = hcd_to_musb(hcd);
2434 u8 devctl; 2433 u8 devctl;
2435 2434
2435 musb_port_suspend(musb, true);
2436
2436 if (!is_host_active(musb)) 2437 if (!is_host_active(musb))
2437 return 0; 2438 return 0;
2438 2439
@@ -2462,7 +2463,12 @@ static int musb_bus_suspend(struct usb_hcd *hcd)
2462 2463
2463static int musb_bus_resume(struct usb_hcd *hcd) 2464static int musb_bus_resume(struct usb_hcd *hcd)
2464{ 2465{
2465 /* resuming child port does the work */ 2466 struct musb *musb = hcd_to_musb(hcd);
2467
2468 if (musb->config &&
2469 musb->config->host_port_deassert_reset_at_resume)
2470 musb_port_reset(musb, false);
2471
2466 return 0; 2472 return 0;
2467} 2473}
2468 2474
@@ -2657,6 +2663,7 @@ int musb_host_setup(struct musb *musb, int power_budget)
2657 if (ret < 0) 2663 if (ret < 0)
2658 return ret; 2664 return ret;
2659 2665
2666 device_wakeup_enable(hcd->self.controller);
2660 return 0; 2667 return 0;
2661} 2668}
2662 2669
diff --git a/drivers/usb/musb/musb_host.h b/drivers/usb/musb/musb_host.h
index 960d73570b2f..7bbf01bf4bb0 100644
--- a/drivers/usb/musb/musb_host.h
+++ b/drivers/usb/musb/musb_host.h
@@ -92,6 +92,9 @@ extern void musb_host_rx(struct musb *, u8);
92extern void musb_root_disconnect(struct musb *musb); 92extern void musb_root_disconnect(struct musb *musb);
93extern void musb_host_resume_root_hub(struct musb *musb); 93extern void musb_host_resume_root_hub(struct musb *musb);
94extern void musb_host_poke_root_hub(struct musb *musb); 94extern void musb_host_poke_root_hub(struct musb *musb);
95extern void musb_port_suspend(struct musb *musb, bool do_suspend);
96extern void musb_port_reset(struct musb *musb, bool do_reset);
97extern void musb_host_finish_resume(struct work_struct *work);
95#else 98#else
96static inline struct musb *hcd_to_musb(struct usb_hcd *hcd) 99static inline struct musb *hcd_to_musb(struct usb_hcd *hcd)
97{ 100{
@@ -121,6 +124,9 @@ static inline void musb_root_disconnect(struct musb *musb) {}
121static inline void musb_host_resume_root_hub(struct musb *musb) {} 124static inline void musb_host_resume_root_hub(struct musb *musb) {}
122static inline void musb_host_poll_rh_status(struct musb *musb) {} 125static inline void musb_host_poll_rh_status(struct musb *musb) {}
123static inline void musb_host_poke_root_hub(struct musb *musb) {} 126static inline void musb_host_poke_root_hub(struct musb *musb) {}
127static inline void musb_port_suspend(struct musb *musb, bool do_suspend) {}
128static inline void musb_port_reset(struct musb *musb, bool do_reset) {}
129static inline void musb_host_finish_resume(struct work_struct *work) {}
124#endif 130#endif
125 131
126struct usb_hcd; 132struct usb_hcd;
diff --git a/drivers/usb/musb/musb_virthub.c b/drivers/usb/musb/musb_virthub.c
index 9af6bba5eac9..eb634433ef09 100644
--- a/drivers/usb/musb/musb_virthub.c
+++ b/drivers/usb/musb/musb_virthub.c
@@ -36,7 +36,6 @@
36#include <linux/kernel.h> 36#include <linux/kernel.h>
37#include <linux/sched.h> 37#include <linux/sched.h>
38#include <linux/errno.h> 38#include <linux/errno.h>
39#include <linux/init.h>
40#include <linux/time.h> 39#include <linux/time.h>
41#include <linux/timer.h> 40#include <linux/timer.h>
42 41
@@ -44,7 +43,38 @@
44 43
45#include "musb_core.h" 44#include "musb_core.h"
46 45
47static void musb_port_suspend(struct musb *musb, bool do_suspend) 46void musb_host_finish_resume(struct work_struct *work)
47{
48 struct musb *musb;
49 unsigned long flags;
50 u8 power;
51
52 musb = container_of(work, struct musb, finish_resume_work.work);
53
54 spin_lock_irqsave(&musb->lock, flags);
55
56 power = musb_readb(musb->mregs, MUSB_POWER);
57 power &= ~MUSB_POWER_RESUME;
58 dev_dbg(musb->controller, "root port resume stopped, power %02x\n",
59 power);
60 musb_writeb(musb->mregs, MUSB_POWER, power);
61
62 /*
63 * ISSUE: DaVinci (RTL 1.300) disconnects after
64 * resume of high speed peripherals (but not full
65 * speed ones).
66 */
67 musb->is_active = 1;
68 musb->port1_status &= ~(USB_PORT_STAT_SUSPEND | MUSB_PORT_STAT_RESUME);
69 musb->port1_status |= USB_PORT_STAT_C_SUSPEND << 16;
70 usb_hcd_poll_rh_status(musb->hcd);
71 /* NOTE: it might really be A_WAIT_BCON ... */
72 musb->xceiv->state = OTG_STATE_A_HOST;
73
74 spin_unlock_irqrestore(&musb->lock, flags);
75}
76
77void musb_port_suspend(struct musb *musb, bool do_suspend)
48{ 78{
49 struct usb_otg *otg = musb->xceiv->otg; 79 struct usb_otg *otg = musb->xceiv->otg;
50 u8 power; 80 u8 power;
@@ -105,11 +135,11 @@ static void musb_port_suspend(struct musb *musb, bool do_suspend)
105 135
106 /* later, GetPortStatus will stop RESUME signaling */ 136 /* later, GetPortStatus will stop RESUME signaling */
107 musb->port1_status |= MUSB_PORT_STAT_RESUME; 137 musb->port1_status |= MUSB_PORT_STAT_RESUME;
108 musb->rh_timer = jiffies + msecs_to_jiffies(20); 138 schedule_delayed_work(&musb->finish_resume_work, 20);
109 } 139 }
110} 140}
111 141
112static void musb_port_reset(struct musb *musb, bool do_reset) 142void musb_port_reset(struct musb *musb, bool do_reset)
113{ 143{
114 u8 power; 144 u8 power;
115 void __iomem *mbase = musb->mregs; 145 void __iomem *mbase = musb->mregs;
@@ -150,7 +180,7 @@ static void musb_port_reset(struct musb *musb, bool do_reset)
150 180
151 musb->port1_status |= USB_PORT_STAT_RESET; 181 musb->port1_status |= USB_PORT_STAT_RESET;
152 musb->port1_status &= ~USB_PORT_STAT_ENABLE; 182 musb->port1_status &= ~USB_PORT_STAT_ENABLE;
153 musb->rh_timer = jiffies + msecs_to_jiffies(50); 183 schedule_delayed_work(&musb->deassert_reset_work, 50);
154 } else { 184 } else {
155 dev_dbg(musb->controller, "root port reset stopped\n"); 185 dev_dbg(musb->controller, "root port reset stopped\n");
156 musb_writeb(mbase, MUSB_POWER, 186 musb_writeb(mbase, MUSB_POWER,
@@ -325,36 +355,6 @@ int musb_hub_control(
325 if (wIndex != 1) 355 if (wIndex != 1)
326 goto error; 356 goto error;
327 357
328 /* finish RESET signaling? */
329 if ((musb->port1_status & USB_PORT_STAT_RESET)
330 && time_after_eq(jiffies, musb->rh_timer))
331 musb_port_reset(musb, false);
332
333 /* finish RESUME signaling? */
334 if ((musb->port1_status & MUSB_PORT_STAT_RESUME)
335 && time_after_eq(jiffies, musb->rh_timer)) {
336 u8 power;
337
338 power = musb_readb(musb->mregs, MUSB_POWER);
339 power &= ~MUSB_POWER_RESUME;
340 dev_dbg(musb->controller, "root port resume stopped, power %02x\n",
341 power);
342 musb_writeb(musb->mregs, MUSB_POWER, power);
343
344 /* ISSUE: DaVinci (RTL 1.300) disconnects after
345 * resume of high speed peripherals (but not full
346 * speed ones).
347 */
348
349 musb->is_active = 1;
350 musb->port1_status &= ~(USB_PORT_STAT_SUSPEND
351 | MUSB_PORT_STAT_RESUME);
352 musb->port1_status |= USB_PORT_STAT_C_SUSPEND << 16;
353 usb_hcd_poll_rh_status(musb->hcd);
354 /* NOTE: it might really be A_WAIT_BCON ... */
355 musb->xceiv->state = OTG_STATE_A_HOST;
356 }
357
358 put_unaligned(cpu_to_le32(musb->port1_status 358 put_unaligned(cpu_to_le32(musb->port1_status
359 & ~MUSB_PORT_STAT_RESUME), 359 & ~MUSB_PORT_STAT_RESUME),
360 (__le32 *) buf); 360 (__le32 *) buf);
diff --git a/drivers/usb/musb/tusb6010.c b/drivers/usb/musb/tusb6010.c
index 4432314d70ee..4e9fb1d08698 100644
--- a/drivers/usb/musb/tusb6010.c
+++ b/drivers/usb/musb/tusb6010.c
@@ -18,7 +18,6 @@
18#include <linux/kernel.h> 18#include <linux/kernel.h>
19#include <linux/errno.h> 19#include <linux/errno.h>
20#include <linux/err.h> 20#include <linux/err.h>
21#include <linux/init.h>
22#include <linux/prefetch.h> 21#include <linux/prefetch.h>
23#include <linux/usb.h> 22#include <linux/usb.h>
24#include <linux/irq.h> 23#include <linux/irq.h>
diff --git a/drivers/usb/musb/tusb6010_omap.c b/drivers/usb/musb/tusb6010_omap.c
index b8794eb81e9c..e33b6b2c44c2 100644
--- a/drivers/usb/musb/tusb6010_omap.c
+++ b/drivers/usb/musb/tusb6010_omap.c
@@ -11,7 +11,6 @@
11#include <linux/module.h> 11#include <linux/module.h>
12#include <linux/kernel.h> 12#include <linux/kernel.h>
13#include <linux/errno.h> 13#include <linux/errno.h>
14#include <linux/init.h>
15#include <linux/usb.h> 14#include <linux/usb.h>
16#include <linux/platform_device.h> 15#include <linux/platform_device.h>
17#include <linux/dma-mapping.h> 16#include <linux/dma-mapping.h>
diff --git a/drivers/usb/musb/ux500.c b/drivers/usb/musb/ux500.c
index 122446bf1664..c2e45e632723 100644
--- a/drivers/usb/musb/ux500.c
+++ b/drivers/usb/musb/ux500.c
@@ -21,7 +21,6 @@
21 21
22#include <linux/module.h> 22#include <linux/module.h>
23#include <linux/kernel.h> 23#include <linux/kernel.h>
24#include <linux/init.h>
25#include <linux/clk.h> 24#include <linux/clk.h>
26#include <linux/err.h> 25#include <linux/err.h>
27#include <linux/io.h> 26#include <linux/io.h>
diff --git a/drivers/usb/musb/ux500_dma.c b/drivers/usb/musb/ux500_dma.c
index 3700e9713258..9aad00f11bd5 100644
--- a/drivers/usb/musb/ux500_dma.c
+++ b/drivers/usb/musb/ux500_dma.c
@@ -336,7 +336,9 @@ static int ux500_dma_controller_start(struct ux500_dma_controller *controller)
336 data ? 336 data ?
337 data->dma_filter : 337 data->dma_filter :
338 NULL, 338 NULL,
339 param_array[ch_num]); 339 param_array ?
340 param_array[ch_num] :
341 NULL);
340 342
341 if (!ux500_channel->dma_chan) { 343 if (!ux500_channel->dma_chan) {
342 ERR("Dma pipe allocation error dir=%d ch=%d\n", 344 ERR("Dma pipe allocation error dir=%d ch=%d\n",