]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/blame - drivers/usb/musb/omap2430.c
usbip: usbip_host: run rebind from exit when module is removed
[mirror_ubuntu-bionic-kernel.git] / drivers / usb / musb / omap2430.c
CommitLineData
5fd54ace 1// SPDX-License-Identifier: GPL-2.0
550a7375
FB
2/*
3 * Copyright (C) 2005-2007 by Texas Instruments
4 * Some code has been taken from tusb6010.c
5 * Copyrights for that are attributable to:
6 * Copyright (C) 2006 Nokia Corporation
550a7375
FB
7 * Tony Lindgren <tony@atomide.com>
8 *
9 * This file is part of the Inventra Controller Driver for Linux.
550a7375
FB
10 */
11#include <linux/module.h>
12#include <linux/kernel.h>
13#include <linux/sched.h>
550a7375
FB
14#include <linux/init.h>
15#include <linux/list.h>
550a7375 16#include <linux/io.h>
00a0b1d5 17#include <linux/of.h>
dc09886b
FB
18#include <linux/platform_device.h>
19#include <linux/dma-mapping.h>
207b0e1f
HH
20#include <linux/pm_runtime.h>
21#include <linux/err.h>
12a19b5f 22#include <linux/delay.h>
8055555f 23#include <linux/usb/musb.h>
14da699b 24#include <linux/phy/omap_control_phy.h>
8934d3e4 25#include <linux/of_platform.h>
550a7375 26
550a7375
FB
27#include "musb_core.h"
28#include "omap2430.h"
29
a3cee12a
FB
30struct omap2430_glue {
31 struct device *dev;
32 struct platform_device *musb;
8055555f 33 enum musb_vbus_id_status status;
1e5acb8d 34 struct work_struct omap_musb_mailbox_work;
ca784be3 35 struct device *control_otghs;
a3cee12a 36};
c20aebb9 37#define glue_to_musb(g) platform_get_drvdata(g->musb)
a3cee12a 38
4b58ed11 39static struct omap2430_glue *_glue;
c9721438 40
743411b3 41static void omap2430_musb_set_vbus(struct musb *musb, int is_on)
550a7375 42{
d445b6da 43 struct usb_otg *otg = musb->xceiv->otg;
550a7375 44 u8 devctl;
594632ef 45 unsigned long timeout = jiffies + msecs_to_jiffies(1000);
550a7375
FB
46 /* HDRC controls CPEN, but beware current surges during device
47 * connect. They can trigger transient overcurrent conditions
48 * that must be ignored.
49 */
50
51 devctl = musb_readb(musb->mregs, MUSB_DEVCTL);
52
53 if (is_on) {
e47d9254 54 if (musb->xceiv->otg->state == OTG_STATE_A_IDLE) {
12a19b5f 55 int loops = 100;
594632ef
HH
56 /* start the session */
57 devctl |= MUSB_DEVCTL_SESSION;
58 musb_writeb(musb->mregs, MUSB_DEVCTL, devctl);
59 /*
60 * Wait for the musb to set as A device to enable the
61 * VBUS
62 */
5a805309
SS
63 while (musb_readb(musb->mregs, MUSB_DEVCTL) &
64 MUSB_DEVCTL_BDEVICE) {
594632ef 65
12a19b5f 66 mdelay(5);
594632ef
HH
67 cpu_relax();
68
12a19b5f
N
69 if (time_after(jiffies, timeout)
70 || loops-- <= 0) {
594632ef
HH
71 dev_err(musb->controller,
72 "configured as A device timeout");
594632ef
HH
73 break;
74 }
75 }
76
bb467cf5 77 otg_set_vbus(otg, 1);
594632ef
HH
78 } else {
79 musb->is_active = 1;
d445b6da 80 otg->default_a = 1;
e47d9254 81 musb->xceiv->otg->state = OTG_STATE_A_WAIT_VRISE;
594632ef
HH
82 devctl |= MUSB_DEVCTL_SESSION;
83 MUSB_HST_MODE(musb);
84 }
550a7375
FB
85 } else {
86 musb->is_active = 0;
87
88 /* NOTE: we're skipping A_WAIT_VFALL -> A_IDLE and
89 * jumping right to B_IDLE...
90 */
91
d445b6da 92 otg->default_a = 0;
e47d9254 93 musb->xceiv->otg->state = OTG_STATE_B_IDLE;
550a7375
FB
94 devctl &= ~MUSB_DEVCTL_SESSION;
95
96 MUSB_DEV_MODE(musb);
97 }
98 musb_writeb(musb->mregs, MUSB_DEVCTL, devctl);
99
5c8a86e1 100 dev_dbg(musb->controller, "VBUS %s, devctl %02x "
550a7375 101 /* otg %3x conf %08x prcm %08x */ "\n",
e47d9254 102 usb_otg_state_string(musb->xceiv->otg->state),
550a7375
FB
103 musb_readb(musb->mregs, MUSB_DEVCTL));
104}
550a7375 105
c20aebb9
FB
106static inline void omap2430_low_level_exit(struct musb *musb)
107{
108 u32 l;
109
110 /* in any role */
111 l = musb_readl(musb->mregs, OTG_FORCESTDBY);
112 l |= ENABLEFORCE; /* enable MSTANDBY */
113 musb_writel(musb->mregs, OTG_FORCESTDBY, l);
c20aebb9
FB
114}
115
116static inline void omap2430_low_level_init(struct musb *musb)
117{
118 u32 l;
119
c20aebb9
FB
120 l = musb_readl(musb->mregs, OTG_FORCESTDBY);
121 l &= ~ENABLEFORCE; /* disable MSTANDBY */
122 musb_writel(musb->mregs, OTG_FORCESTDBY, l);
123}
124
12b7db2b 125static int omap2430_musb_mailbox(enum musb_vbus_id_status status)
594632ef 126{
c9721438 127 struct omap2430_glue *glue = _glue;
712d8efa 128
f8c4b0e7
AK
129 if (!glue) {
130 pr_err("%s: musb core is not yet initialized\n", __func__);
12b7db2b 131 return -EPROBE_DEFER;
f8c4b0e7
AK
132 }
133 glue->status = status;
134
135 if (!glue_to_musb(glue)) {
80ab72e1 136 pr_err("%s: musb core is not yet ready\n", __func__);
12b7db2b 137 return -EPROBE_DEFER;
c9721438 138 }
712d8efa 139
c9721438 140 schedule_work(&glue->omap_musb_mailbox_work);
12b7db2b
TL
141
142 return 0;
712d8efa
VP
143}
144
c9721438 145static void omap_musb_set_mailbox(struct omap2430_glue *glue)
712d8efa 146{
1e5acb8d 147 struct musb *musb = glue_to_musb(glue);
ae909fe4
TL
148 struct musb_hdrc_platform_data *pdata =
149 dev_get_platdata(musb->controller);
594632ef 150 struct omap_musb_board_data *data = pdata->board_data;
c83a8542 151 struct usb_otg *otg = musb->xceiv->otg;
594632ef 152
ae909fe4 153 pm_runtime_get_sync(musb->controller);
c9721438 154 switch (glue->status) {
8055555f 155 case MUSB_ID_GROUND:
ae909fe4 156 dev_dbg(musb->controller, "ID GND\n");
594632ef 157
c83a8542 158 otg->default_a = true;
e47d9254 159 musb->xceiv->otg->state = OTG_STATE_A_IDLE;
c9721438 160 musb->xceiv->last_event = USB_EVENT_ID;
032ec49f 161 if (musb->gadget_driver) {
ca784be3
KVA
162 omap_control_usb_set_mode(glue->control_otghs,
163 USB_MODE_HOST);
70045c57 164 omap2430_musb_set_vbus(musb, 1);
594632ef
HH
165 }
166 break;
167
8055555f 168 case MUSB_VBUS_VALID:
ae909fe4 169 dev_dbg(musb->controller, "VBUS Connect\n");
594632ef 170
c83a8542 171 otg->default_a = false;
e47d9254 172 musb->xceiv->otg->state = OTG_STATE_B_IDLE;
c9721438 173 musb->xceiv->last_event = USB_EVENT_VBUS;
ca784be3 174 omap_control_usb_set_mode(glue->control_otghs, USB_MODE_DEVICE);
594632ef
HH
175 break;
176
8055555f
TL
177 case MUSB_ID_FLOAT:
178 case MUSB_VBUS_OFF:
ae909fe4 179 dev_dbg(musb->controller, "VBUS Disconnect\n");
594632ef 180
c9721438 181 musb->xceiv->last_event = USB_EVENT_NONE;
21f77bee 182 if (musb->gadget_driver)
2c1fe89d 183 omap2430_musb_set_vbus(musb, 0);
7acc6197 184
bb467cf5
KVA
185 if (data->interface_type == MUSB_INTERFACE_UTMI)
186 otg_set_vbus(musb->xceiv->otg, 0);
187
ca784be3
KVA
188 omap_control_usb_set_mode(glue->control_otghs,
189 USB_MODE_DISCONNECT);
594632ef
HH
190 break;
191 default:
ae909fe4 192 dev_dbg(musb->controller, "ID float\n");
594632ef 193 }
ae909fe4
TL
194 pm_runtime_mark_last_busy(musb->controller);
195 pm_runtime_put_autosuspend(musb->controller);
6fa7178c
PR
196 atomic_notifier_call_chain(&musb->xceiv->notifier,
197 musb->xceiv->last_event, NULL);
594632ef
HH
198}
199
c9721438
KVA
200
201static void omap_musb_mailbox_work(struct work_struct *mailbox_work)
202{
203 struct omap2430_glue *glue = container_of(mailbox_work,
204 struct omap2430_glue, omap_musb_mailbox_work);
8b2bc2c9 205
c9721438
KVA
206 omap_musb_set_mailbox(glue);
207}
208
baef653a
PDS
209static irqreturn_t omap2430_musb_interrupt(int irq, void *__hci)
210{
211 unsigned long flags;
212 irqreturn_t retval = IRQ_NONE;
213 struct musb *musb = __hci;
214
215 spin_lock_irqsave(&musb->lock, flags);
216
217 musb->int_usb = musb_readb(musb->mregs, MUSB_INTRUSB);
218 musb->int_tx = musb_readw(musb->mregs, MUSB_INTRTX);
219 musb->int_rx = musb_readw(musb->mregs, MUSB_INTRRX);
220
221 if (musb->int_usb || musb->int_tx || musb->int_rx)
222 retval = musb_interrupt(musb);
223
224 spin_unlock_irqrestore(&musb->lock, flags);
225
226 return retval;
227}
228
743411b3 229static int omap2430_musb_init(struct musb *musb)
550a7375 230{
ad579699
S
231 u32 l;
232 int status = 0;
ea65df57 233 struct device *dev = musb->controller;
c9721438 234 struct omap2430_glue *glue = dev_get_drvdata(dev->parent);
c1a7d67c 235 struct musb_hdrc_platform_data *plat = dev_get_platdata(dev);
ea65df57 236 struct omap_musb_board_data *data = plat->board_data;
550a7375 237
84e250ff
DB
238 /* We require some kind of external transceiver, hooked
239 * up through ULPI. TWL4030-family PMICs include one,
240 * which needs a driver, drivers aren't always needed.
241 */
3e3101d5
KVA
242 if (dev->parent->of_node) {
243 musb->phy = devm_phy_get(dev->parent, "usb2-phy");
244
245 /* We can't totally remove musb->xceiv as of now because
246 * musb core uses xceiv.state and xceiv.otg. Once we have
247 * a separate state machine to handle otg, these can be moved
248 * out of xceiv and then we can start using the generic PHY
249 * framework
250 */
b16604f2
KVA
251 musb->xceiv = devm_usb_get_phy_by_phandle(dev->parent,
252 "usb-phy", 0);
3e3101d5 253 } else {
b16604f2 254 musb->xceiv = devm_usb_get_phy_dev(dev, 0);
3e3101d5
KVA
255 musb->phy = devm_phy_get(dev, "usb");
256 }
b16604f2 257
a90199bb
FB
258 if (IS_ERR(musb->xceiv)) {
259 status = PTR_ERR(musb->xceiv);
260
261 if (status == -ENXIO)
262 return status;
263
dc66ba8d 264 dev_dbg(dev, "HS USB OTG: no transceiver configured\n");
25736e0c 265 return -EPROBE_DEFER;
84e250ff
DB
266 }
267
3e3101d5 268 if (IS_ERR(musb->phy)) {
71127a79 269 dev_err(dev, "HS USB OTG: no PHY configured\n");
3e3101d5
KVA
270 return PTR_ERR(musb->phy);
271 }
baef653a 272 musb->isr = omap2430_musb_interrupt;
a83e17d0 273 phy_init(musb->phy);
d8e5f0ec 274 phy_power_on(musb->phy);
baef653a 275
8573e6a6 276 l = musb_readl(musb->mregs, OTG_INTERFSEL);
de2e1b0c
MM
277
278 if (data->interface_type == MUSB_INTERFACE_UTMI) {
279 /* OMAP4 uses Internal PHY GS70 which uses UTMI interface */
280 l &= ~ULPI_12PIN; /* Disable ULPI */
281 l |= UTMI_8BIT; /* Enable UTMI */
282 } else {
283 l |= ULPI_12PIN;
284 }
285
8573e6a6 286 musb_writel(musb->mregs, OTG_INTERFSEL, l);
550a7375 287
71127a79 288 dev_dbg(dev, "HS USB OTG: revision 0x%x, sysconfig 0x%02x, "
550a7375 289 "sysstatus 0x%x, intrfsel 0x%x, simenable 0x%x\n",
8573e6a6
FB
290 musb_readl(musb->mregs, OTG_REVISION),
291 musb_readl(musb->mregs, OTG_SYSCONFIG),
292 musb_readl(musb->mregs, OTG_SYSSTATUS),
293 musb_readl(musb->mregs, OTG_INTERFSEL),
294 musb_readl(musb->mregs, OTG_SIMENABLE));
550a7375 295
8055555f 296 if (glue->status != MUSB_UNKNOWN)
c9721438
KVA
297 omap_musb_set_mailbox(glue);
298
550a7375
FB
299 return 0;
300}
301
002eda13
HH
302static void omap2430_musb_enable(struct musb *musb)
303{
304 u8 devctl;
305 unsigned long timeout = jiffies + msecs_to_jiffies(1000);
306 struct device *dev = musb->controller;
c9721438 307 struct omap2430_glue *glue = dev_get_drvdata(dev->parent);
c1a7d67c 308 struct musb_hdrc_platform_data *pdata = dev_get_platdata(dev);
002eda13
HH
309 struct omap_musb_board_data *data = pdata->board_data;
310
a83e17d0 311
c9721438 312 switch (glue->status) {
002eda13 313
8055555f 314 case MUSB_ID_GROUND:
ca784be3 315 omap_control_usb_set_mode(glue->control_otghs, USB_MODE_HOST);
08dec56e
FC
316 if (data->interface_type != MUSB_INTERFACE_UTMI)
317 break;
318 devctl = musb_readb(musb->mregs, MUSB_DEVCTL);
319 /* start the session */
320 devctl |= MUSB_DEVCTL_SESSION;
321 musb_writeb(musb->mregs, MUSB_DEVCTL, devctl);
322 while (musb_readb(musb->mregs, MUSB_DEVCTL) &
323 MUSB_DEVCTL_BDEVICE) {
324 cpu_relax();
325
326 if (time_after(jiffies, timeout)) {
327 dev_err(dev, "configured as A device timeout");
328 break;
002eda13
HH
329 }
330 }
331 break;
332
8055555f 333 case MUSB_VBUS_VALID:
ca784be3 334 omap_control_usb_set_mode(glue->control_otghs, USB_MODE_DEVICE);
002eda13
HH
335 break;
336
337 default:
338 break;
339 }
340}
341
342static void omap2430_musb_disable(struct musb *musb)
343{
c9721438
KVA
344 struct device *dev = musb->controller;
345 struct omap2430_glue *glue = dev_get_drvdata(dev->parent);
346
8055555f 347 if (glue->status != MUSB_UNKNOWN)
ca784be3
KVA
348 omap_control_usb_set_mode(glue->control_otghs,
349 USB_MODE_DISCONNECT);
550a7375
FB
350}
351
743411b3 352static int omap2430_musb_exit(struct musb *musb)
550a7375 353{
a83e17d0
TL
354 struct device *dev = musb->controller;
355 struct omap2430_glue *glue = dev_get_drvdata(dev->parent);
550a7375 356
c20aebb9 357 omap2430_low_level_exit(musb);
d8e5f0ec 358 phy_power_off(musb->phy);
3e3101d5 359 phy_exit(musb->phy);
a83e17d0
TL
360 musb->phy = NULL;
361 cancel_work_sync(&glue->omap_musb_mailbox_work);
c20aebb9 362
550a7375
FB
363 return 0;
364}
743411b3 365
f7ec9437 366static const struct musb_platform_ops omap2430_ops = {
f8e9f34f 367 .quirks = MUSB_DMA_INVENTRA,
7f6283ed
TL
368#ifdef CONFIG_USB_INVENTRA_DMA
369 .dma_init = musbhs_dma_controller_create,
370 .dma_exit = musbhs_dma_controller_destroy,
371#endif
743411b3
FB
372 .init = omap2430_musb_init,
373 .exit = omap2430_musb_exit,
374
743411b3 375 .set_vbus = omap2430_musb_set_vbus,
002eda13
HH
376
377 .enable = omap2430_musb_enable,
378 .disable = omap2430_musb_disable,
8055555f
TL
379
380 .phy_callback = omap2430_musb_mailbox,
743411b3 381};
dc09886b
FB
382
383static u64 omap2430_dmamask = DMA_BIT_MASK(32);
384
41ac7b3a 385static int omap2430_probe(struct platform_device *pdev)
dc09886b 386{
c1f01be4 387 struct resource musb_resources[3];
c1a7d67c 388 struct musb_hdrc_platform_data *pdata = dev_get_platdata(&pdev->dev);
00a0b1d5 389 struct omap_musb_board_data *data;
dc09886b 390 struct platform_device *musb;
a3cee12a 391 struct omap2430_glue *glue;
00a0b1d5
KVA
392 struct device_node *np = pdev->dev.of_node;
393 struct musb_hdrc_config *config;
606bf4d5 394 int ret = -ENOMEM, val;
dc09886b 395
b1183c24 396 glue = devm_kzalloc(&pdev->dev, sizeof(*glue), GFP_KERNEL);
af1bdfc9 397 if (!glue)
a3cee12a 398 goto err0;
a3cee12a 399
2f771164 400 musb = platform_device_alloc("musb-hdrc", PLATFORM_DEVID_AUTO);
dc09886b
FB
401 if (!musb) {
402 dev_err(&pdev->dev, "failed to allocate musb device\n");
2f771164 403 goto err0;
dc09886b
FB
404 }
405
406 musb->dev.parent = &pdev->dev;
407 musb->dev.dma_mask = &omap2430_dmamask;
408 musb->dev.coherent_dma_mask = omap2430_dmamask;
409
a3cee12a
FB
410 glue->dev = &pdev->dev;
411 glue->musb = musb;
8055555f 412 glue->status = MUSB_UNKNOWN;
8934d3e4 413 glue->control_otghs = ERR_PTR(-ENODEV);
a3cee12a 414
00a0b1d5 415 if (np) {
8934d3e4
RQ
416 struct device_node *control_node;
417 struct platform_device *control_pdev;
418
00a0b1d5 419 pdata = devm_kzalloc(&pdev->dev, sizeof(*pdata), GFP_KERNEL);
af1bdfc9 420 if (!pdata)
2f771164 421 goto err2;
00a0b1d5
KVA
422
423 data = devm_kzalloc(&pdev->dev, sizeof(*data), GFP_KERNEL);
af1bdfc9 424 if (!data)
2f771164 425 goto err2;
00a0b1d5
KVA
426
427 config = devm_kzalloc(&pdev->dev, sizeof(*config), GFP_KERNEL);
af1bdfc9 428 if (!config)
2f771164 429 goto err2;
00a0b1d5
KVA
430
431 of_property_read_u32(np, "mode", (u32 *)&pdata->mode);
eee44da0 432 of_property_read_u32(np, "interface-type",
00a0b1d5 433 (u32 *)&data->interface_type);
eee44da0
KVA
434 of_property_read_u32(np, "num-eps", (u32 *)&config->num_eps);
435 of_property_read_u32(np, "ram-bits", (u32 *)&config->ram_bits);
00a0b1d5 436 of_property_read_u32(np, "power", (u32 *)&pdata->power);
606bf4d5
TL
437
438 ret = of_property_read_u32(np, "multipoint", &val);
439 if (!ret && val)
440 config->multipoint = true;
00a0b1d5
KVA
441
442 pdata->board_data = data;
443 pdata->config = config;
00a0b1d5 444
8934d3e4
RQ
445 control_node = of_parse_phandle(np, "ctrl-module", 0);
446 if (control_node) {
447 control_pdev = of_find_device_by_node(control_node);
448 if (!control_pdev) {
449 dev_err(&pdev->dev, "Failed to get control device\n");
450 ret = -EINVAL;
451 goto err2;
452 }
453 glue->control_otghs = &control_pdev->dev;
ca784be3 454 }
ca784be3 455 }
f7ec9437
FB
456 pdata->platform_ops = &omap2430_ops;
457
a3cee12a 458 platform_set_drvdata(pdev, glue);
dc09886b 459
c9721438
KVA
460 /*
461 * REVISIT if we ever have two instances of the wrapper, we will be
462 * in big trouble
463 */
464 _glue = glue;
465
1e5acb8d
KVA
466 INIT_WORK(&glue->omap_musb_mailbox_work, omap_musb_mailbox_work);
467
3a0ddc71 468 memset(musb_resources, 0x00, sizeof(*musb_resources) *
09fc7d22
FB
469 ARRAY_SIZE(musb_resources));
470
471 musb_resources[0].name = pdev->resource[0].name;
472 musb_resources[0].start = pdev->resource[0].start;
473 musb_resources[0].end = pdev->resource[0].end;
474 musb_resources[0].flags = pdev->resource[0].flags;
475
476 musb_resources[1].name = pdev->resource[1].name;
477 musb_resources[1].start = pdev->resource[1].start;
478 musb_resources[1].end = pdev->resource[1].end;
479 musb_resources[1].flags = pdev->resource[1].flags;
480
c1f01be4
KVA
481 musb_resources[2].name = pdev->resource[2].name;
482 musb_resources[2].start = pdev->resource[2].start;
483 musb_resources[2].end = pdev->resource[2].end;
484 musb_resources[2].flags = pdev->resource[2].flags;
485
09fc7d22
FB
486 ret = platform_device_add_resources(musb, musb_resources,
487 ARRAY_SIZE(musb_resources));
dc09886b
FB
488 if (ret) {
489 dev_err(&pdev->dev, "failed to add resources\n");
65b3d52d 490 goto err2;
dc09886b
FB
491 }
492
493 ret = platform_device_add_data(musb, pdata, sizeof(*pdata));
494 if (ret) {
495 dev_err(&pdev->dev, "failed to add platform_data\n");
65b3d52d 496 goto err2;
dc09886b
FB
497 }
498
87326e85 499 pm_runtime_enable(glue->dev);
3006dc8c 500
dc09886b
FB
501 ret = platform_device_add(musb);
502 if (ret) {
503 dev_err(&pdev->dev, "failed to register musb device\n");
536d599d 504 goto err3;
dc09886b
FB
505 }
506
207b0e1f 507 return 0;
03491761 508
536d599d
TL
509err3:
510 pm_runtime_disable(glue->dev);
511
65b3d52d 512err2:
b1183c24 513 platform_device_put(musb);
a3cee12a 514
dc09886b
FB
515err0:
516 return ret;
517}
518
fb4e98ab 519static int omap2430_remove(struct platform_device *pdev)
dc09886b 520{
21f77bee 521 struct omap2430_glue *glue = platform_get_drvdata(pdev);
dc09886b 522
f039df58 523 platform_device_unregister(glue->musb);
03e43528 524 pm_runtime_disable(glue->dev);
dc09886b
FB
525
526 return 0;
527}
528
c20aebb9 529#ifdef CONFIG_PM
c20aebb9 530
7acc6197 531static int omap2430_runtime_suspend(struct device *dev)
c20aebb9
FB
532{
533 struct omap2430_glue *glue = dev_get_drvdata(dev);
534 struct musb *musb = glue_to_musb(glue);
535
a83e17d0
TL
536 if (!musb)
537 return 0;
e25bec16 538
a83e17d0
TL
539 musb->context.otg_interfsel = musb_readl(musb->mregs,
540 OTG_INTERFSEL);
541
542 omap2430_low_level_exit(musb);
c20aebb9
FB
543
544 return 0;
545}
546
7acc6197 547static int omap2430_runtime_resume(struct device *dev)
c20aebb9
FB
548{
549 struct omap2430_glue *glue = dev_get_drvdata(dev);
550 struct musb *musb = glue_to_musb(glue);
c20aebb9 551
8f2279d5 552 if (!musb)
a83e17d0 553 return 0;
8f2279d5
TL
554
555 omap2430_low_level_init(musb);
556 musb_writel(musb->mregs, OTG_INTERFSEL,
557 musb->context.otg_interfsel);
c20aebb9
FB
558
559 return 0;
560}
561
c0927fea 562static const struct dev_pm_ops omap2430_pm_ops = {
7acc6197
HH
563 .runtime_suspend = omap2430_runtime_suspend,
564 .runtime_resume = omap2430_runtime_resume,
c20aebb9
FB
565};
566
567#define DEV_PM_OPS (&omap2430_pm_ops)
568#else
569#define DEV_PM_OPS NULL
570#endif
571
00a0b1d5
KVA
572#ifdef CONFIG_OF
573static const struct of_device_id omap2430_id_table[] = {
574 {
575 .compatible = "ti,omap4-musb"
576 },
577 {
578 .compatible = "ti,omap3-musb"
579 },
580 {},
581};
582MODULE_DEVICE_TABLE(of, omap2430_id_table);
583#endif
584
dc09886b 585static struct platform_driver omap2430_driver = {
e9e8c85e 586 .probe = omap2430_probe,
7690417d 587 .remove = omap2430_remove,
dc09886b
FB
588 .driver = {
589 .name = "musb-omap2430",
c20aebb9 590 .pm = DEV_PM_OPS,
00a0b1d5 591 .of_match_table = of_match_ptr(omap2430_id_table),
dc09886b
FB
592 },
593};
594
aec373c1
TL
595module_platform_driver(omap2430_driver);
596
dc09886b
FB
597MODULE_DESCRIPTION("OMAP2PLUS MUSB Glue Layer");
598MODULE_AUTHOR("Felipe Balbi <balbi@ti.com>");
599MODULE_LICENSE("GPL v2");