xref: /linux/drivers/usb/musb/omap2430.c (revision 0d456bad36d42d16022be045c8a53ddbb59ee478)
1 /*
2  * Copyright (C) 2005-2007 by Texas Instruments
3  * Some code has been taken from tusb6010.c
4  * Copyrights for that are attributable to:
5  * Copyright (C) 2006 Nokia Corporation
6  * Tony Lindgren <tony@atomide.com>
7  *
8  * This file is part of the Inventra Controller Driver for Linux.
9  *
10  * The Inventra Controller Driver for Linux is free software; you
11  * can redistribute it and/or modify it under the terms of the GNU
12  * General Public License version 2 as published by the Free Software
13  * Foundation.
14  *
15  * The Inventra Controller Driver for Linux is distributed in
16  * the hope that it will be useful, but WITHOUT ANY WARRANTY;
17  * without even the implied warranty of MERCHANTABILITY or
18  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public
19  * License for more details.
20  *
21  * You should have received a copy of the GNU General Public License
22  * along with The Inventra Controller Driver for Linux ; if not,
23  * write to the Free Software Foundation, Inc., 59 Temple Place,
24  * Suite 330, Boston, MA  02111-1307  USA
25  *
26  */
27 #include <linux/module.h>
28 #include <linux/kernel.h>
29 #include <linux/sched.h>
30 #include <linux/init.h>
31 #include <linux/list.h>
32 #include <linux/io.h>
33 #include <linux/of.h>
34 #include <linux/platform_device.h>
35 #include <linux/dma-mapping.h>
36 #include <linux/pm_runtime.h>
37 #include <linux/err.h>
38 #include <linux/delay.h>
39 #include <linux/usb/musb-omap.h>
40 
41 #include "musb_core.h"
42 #include "omap2430.h"
43 
44 struct omap2430_glue {
45 	struct device		*dev;
46 	struct platform_device	*musb;
47 	enum omap_musb_vbus_id_status status;
48 	struct work_struct	omap_musb_mailbox_work;
49 	u32 __iomem		*control_otghs;
50 };
51 #define glue_to_musb(g)		platform_get_drvdata(g->musb)
52 
53 struct omap2430_glue		*_glue;
54 
55 static struct timer_list musb_idle_timer;
56 
57 /**
58  * omap4_usb_phy_mailbox - write to usb otg mailbox
59  * @glue: struct omap2430_glue *
60  * @val: the value to be written to the mailbox
61  *
62  * On detection of a device (ID pin is grounded), this API should be called
63  * to set AVALID, VBUSVALID and ID pin is grounded.
64  *
65  * When OMAP is connected to a host (OMAP in device mode), this API
66  * is called to set AVALID, VBUSVALID and ID pin in high impedance.
67  *
68  * XXX: This function will be removed once we have a seperate driver for
69  * control module
70  */
71 static void omap4_usb_phy_mailbox(struct omap2430_glue *glue, u32 val)
72 {
73 	if (glue->control_otghs)
74 		writel(val, glue->control_otghs);
75 }
76 
77 static void musb_do_idle(unsigned long _musb)
78 {
79 	struct musb	*musb = (void *)_musb;
80 	unsigned long	flags;
81 	u8	power;
82 	u8	devctl;
83 
84 	spin_lock_irqsave(&musb->lock, flags);
85 
86 	switch (musb->xceiv->state) {
87 	case OTG_STATE_A_WAIT_BCON:
88 
89 		devctl = musb_readb(musb->mregs, MUSB_DEVCTL);
90 		if (devctl & MUSB_DEVCTL_BDEVICE) {
91 			musb->xceiv->state = OTG_STATE_B_IDLE;
92 			MUSB_DEV_MODE(musb);
93 		} else {
94 			musb->xceiv->state = OTG_STATE_A_IDLE;
95 			MUSB_HST_MODE(musb);
96 		}
97 		break;
98 	case OTG_STATE_A_SUSPEND:
99 		/* finish RESUME signaling? */
100 		if (musb->port1_status & MUSB_PORT_STAT_RESUME) {
101 			power = musb_readb(musb->mregs, MUSB_POWER);
102 			power &= ~MUSB_POWER_RESUME;
103 			dev_dbg(musb->controller, "root port resume stopped, power %02x\n", power);
104 			musb_writeb(musb->mregs, MUSB_POWER, power);
105 			musb->is_active = 1;
106 			musb->port1_status &= ~(USB_PORT_STAT_SUSPEND
107 						| MUSB_PORT_STAT_RESUME);
108 			musb->port1_status |= USB_PORT_STAT_C_SUSPEND << 16;
109 			usb_hcd_poll_rh_status(musb_to_hcd(musb));
110 			/* NOTE: it might really be A_WAIT_BCON ... */
111 			musb->xceiv->state = OTG_STATE_A_HOST;
112 		}
113 		break;
114 	case OTG_STATE_A_HOST:
115 		devctl = musb_readb(musb->mregs, MUSB_DEVCTL);
116 		if (devctl &  MUSB_DEVCTL_BDEVICE)
117 			musb->xceiv->state = OTG_STATE_B_IDLE;
118 		else
119 			musb->xceiv->state = OTG_STATE_A_WAIT_BCON;
120 	default:
121 		break;
122 	}
123 	spin_unlock_irqrestore(&musb->lock, flags);
124 }
125 
126 
127 static void omap2430_musb_try_idle(struct musb *musb, unsigned long timeout)
128 {
129 	unsigned long		default_timeout = jiffies + msecs_to_jiffies(3);
130 	static unsigned long	last_timer;
131 
132 	if (timeout == 0)
133 		timeout = default_timeout;
134 
135 	/* Never idle if active, or when VBUS timeout is not set as host */
136 	if (musb->is_active || ((musb->a_wait_bcon == 0)
137 			&& (musb->xceiv->state == OTG_STATE_A_WAIT_BCON))) {
138 		dev_dbg(musb->controller, "%s active, deleting timer\n",
139 			otg_state_string(musb->xceiv->state));
140 		del_timer(&musb_idle_timer);
141 		last_timer = jiffies;
142 		return;
143 	}
144 
145 	if (time_after(last_timer, timeout)) {
146 		if (!timer_pending(&musb_idle_timer))
147 			last_timer = timeout;
148 		else {
149 			dev_dbg(musb->controller, "Longer idle timer already pending, ignoring\n");
150 			return;
151 		}
152 	}
153 	last_timer = timeout;
154 
155 	dev_dbg(musb->controller, "%s inactive, for idle timer for %lu ms\n",
156 		otg_state_string(musb->xceiv->state),
157 		(unsigned long)jiffies_to_msecs(timeout - jiffies));
158 	mod_timer(&musb_idle_timer, timeout);
159 }
160 
161 static void omap2430_musb_set_vbus(struct musb *musb, int is_on)
162 {
163 	struct usb_otg	*otg = musb->xceiv->otg;
164 	u8		devctl;
165 	unsigned long timeout = jiffies + msecs_to_jiffies(1000);
166 	/* HDRC controls CPEN, but beware current surges during device
167 	 * connect.  They can trigger transient overcurrent conditions
168 	 * that must be ignored.
169 	 */
170 
171 	devctl = musb_readb(musb->mregs, MUSB_DEVCTL);
172 
173 	if (is_on) {
174 		if (musb->xceiv->state == OTG_STATE_A_IDLE) {
175 			int loops = 100;
176 			/* start the session */
177 			devctl |= MUSB_DEVCTL_SESSION;
178 			musb_writeb(musb->mregs, MUSB_DEVCTL, devctl);
179 			/*
180 			 * Wait for the musb to set as A device to enable the
181 			 * VBUS
182 			 */
183 			while (musb_readb(musb->mregs, MUSB_DEVCTL) & 0x80) {
184 
185 				mdelay(5);
186 				cpu_relax();
187 
188 				if (time_after(jiffies, timeout)
189 				    || loops-- <= 0) {
190 					dev_err(musb->controller,
191 					"configured as A device timeout");
192 					break;
193 				}
194 			}
195 
196 			if (otg->set_vbus)
197 				otg_set_vbus(otg, 1);
198 		} else {
199 			musb->is_active = 1;
200 			otg->default_a = 1;
201 			musb->xceiv->state = OTG_STATE_A_WAIT_VRISE;
202 			devctl |= MUSB_DEVCTL_SESSION;
203 			MUSB_HST_MODE(musb);
204 		}
205 	} else {
206 		musb->is_active = 0;
207 
208 		/* NOTE:  we're skipping A_WAIT_VFALL -> A_IDLE and
209 		 * jumping right to B_IDLE...
210 		 */
211 
212 		otg->default_a = 0;
213 		musb->xceiv->state = OTG_STATE_B_IDLE;
214 		devctl &= ~MUSB_DEVCTL_SESSION;
215 
216 		MUSB_DEV_MODE(musb);
217 	}
218 	musb_writeb(musb->mregs, MUSB_DEVCTL, devctl);
219 
220 	dev_dbg(musb->controller, "VBUS %s, devctl %02x "
221 		/* otg %3x conf %08x prcm %08x */ "\n",
222 		otg_state_string(musb->xceiv->state),
223 		musb_readb(musb->mregs, MUSB_DEVCTL));
224 }
225 
226 static int omap2430_musb_set_mode(struct musb *musb, u8 musb_mode)
227 {
228 	u8	devctl = musb_readb(musb->mregs, MUSB_DEVCTL);
229 
230 	devctl |= MUSB_DEVCTL_SESSION;
231 	musb_writeb(musb->mregs, MUSB_DEVCTL, devctl);
232 
233 	return 0;
234 }
235 
236 static inline void omap2430_low_level_exit(struct musb *musb)
237 {
238 	u32 l;
239 
240 	/* in any role */
241 	l = musb_readl(musb->mregs, OTG_FORCESTDBY);
242 	l |= ENABLEFORCE;	/* enable MSTANDBY */
243 	musb_writel(musb->mregs, OTG_FORCESTDBY, l);
244 }
245 
246 static inline void omap2430_low_level_init(struct musb *musb)
247 {
248 	u32 l;
249 
250 	l = musb_readl(musb->mregs, OTG_FORCESTDBY);
251 	l &= ~ENABLEFORCE;	/* disable MSTANDBY */
252 	musb_writel(musb->mregs, OTG_FORCESTDBY, l);
253 }
254 
255 void omap_musb_mailbox(enum omap_musb_vbus_id_status status)
256 {
257 	struct omap2430_glue	*glue = _glue;
258 	struct musb		*musb = glue_to_musb(glue);
259 
260 	glue->status = status;
261 	if (!musb) {
262 		dev_err(glue->dev, "musb core is not yet ready\n");
263 		return;
264 	}
265 
266 	schedule_work(&glue->omap_musb_mailbox_work);
267 }
268 EXPORT_SYMBOL_GPL(omap_musb_mailbox);
269 
270 static void omap_musb_set_mailbox(struct omap2430_glue *glue)
271 {
272 	u32 val;
273 	struct musb *musb = glue_to_musb(glue);
274 	struct device *dev = musb->controller;
275 	struct musb_hdrc_platform_data *pdata = dev->platform_data;
276 	struct omap_musb_board_data *data = pdata->board_data;
277 	struct usb_otg *otg = musb->xceiv->otg;
278 
279 	switch (glue->status) {
280 	case OMAP_MUSB_ID_GROUND:
281 		dev_dbg(dev, "ID GND\n");
282 
283 		otg->default_a = true;
284 		musb->xceiv->state = OTG_STATE_A_IDLE;
285 		musb->xceiv->last_event = USB_EVENT_ID;
286 		if (musb->gadget_driver) {
287 			pm_runtime_get_sync(dev);
288 			val = AVALID | VBUSVALID;
289 			omap4_usb_phy_mailbox(glue, val);
290 			omap2430_musb_set_vbus(musb, 1);
291 		}
292 		break;
293 
294 	case OMAP_MUSB_VBUS_VALID:
295 		dev_dbg(dev, "VBUS Connect\n");
296 
297 		otg->default_a = false;
298 		musb->xceiv->state = OTG_STATE_B_IDLE;
299 		musb->xceiv->last_event = USB_EVENT_VBUS;
300 		if (musb->gadget_driver)
301 			pm_runtime_get_sync(dev);
302 		val = IDDIG | AVALID | VBUSVALID;
303 		omap4_usb_phy_mailbox(glue, val);
304 		break;
305 
306 	case OMAP_MUSB_ID_FLOAT:
307 	case OMAP_MUSB_VBUS_OFF:
308 		dev_dbg(dev, "VBUS Disconnect\n");
309 
310 		musb->xceiv->last_event = USB_EVENT_NONE;
311 		if (musb->gadget_driver) {
312 			pm_runtime_mark_last_busy(dev);
313 			pm_runtime_put_autosuspend(dev);
314 		}
315 
316 		if (data->interface_type == MUSB_INTERFACE_UTMI) {
317 			if (musb->xceiv->otg->set_vbus)
318 				otg_set_vbus(musb->xceiv->otg, 0);
319 		}
320 		val = SESSEND | IDDIG;
321 		omap4_usb_phy_mailbox(glue, val);
322 		break;
323 	default:
324 		dev_dbg(dev, "ID float\n");
325 	}
326 }
327 
328 
329 static void omap_musb_mailbox_work(struct work_struct *mailbox_work)
330 {
331 	struct omap2430_glue *glue = container_of(mailbox_work,
332 				struct omap2430_glue, omap_musb_mailbox_work);
333 	omap_musb_set_mailbox(glue);
334 }
335 
336 static irqreturn_t omap2430_musb_interrupt(int irq, void *__hci)
337 {
338 	unsigned long   flags;
339 	irqreturn_t     retval = IRQ_NONE;
340 	struct musb     *musb = __hci;
341 
342 	spin_lock_irqsave(&musb->lock, flags);
343 
344 	musb->int_usb = musb_readb(musb->mregs, MUSB_INTRUSB);
345 	musb->int_tx = musb_readw(musb->mregs, MUSB_INTRTX);
346 	musb->int_rx = musb_readw(musb->mregs, MUSB_INTRRX);
347 
348 	if (musb->int_usb || musb->int_tx || musb->int_rx)
349 		retval = musb_interrupt(musb);
350 
351 	spin_unlock_irqrestore(&musb->lock, flags);
352 
353 	return retval;
354 }
355 
356 static int omap2430_musb_init(struct musb *musb)
357 {
358 	u32 l;
359 	int status = 0;
360 	struct device *dev = musb->controller;
361 	struct omap2430_glue *glue = dev_get_drvdata(dev->parent);
362 	struct musb_hdrc_platform_data *plat = dev->platform_data;
363 	struct omap_musb_board_data *data = plat->board_data;
364 
365 	/* We require some kind of external transceiver, hooked
366 	 * up through ULPI.  TWL4030-family PMICs include one,
367 	 * which needs a driver, drivers aren't always needed.
368 	 */
369 	musb->xceiv = devm_usb_get_phy(dev, USB_PHY_TYPE_USB2);
370 	if (IS_ERR_OR_NULL(musb->xceiv)) {
371 		pr_err("HS USB OTG: no transceiver configured\n");
372 		return -ENODEV;
373 	}
374 
375 	musb->isr = omap2430_musb_interrupt;
376 
377 	status = pm_runtime_get_sync(dev);
378 	if (status < 0) {
379 		dev_err(dev, "pm_runtime_get_sync FAILED %d\n", status);
380 		goto err1;
381 	}
382 
383 	l = musb_readl(musb->mregs, OTG_INTERFSEL);
384 
385 	if (data->interface_type == MUSB_INTERFACE_UTMI) {
386 		/* OMAP4 uses Internal PHY GS70 which uses UTMI interface */
387 		l &= ~ULPI_12PIN;       /* Disable ULPI */
388 		l |= UTMI_8BIT;         /* Enable UTMI  */
389 	} else {
390 		l |= ULPI_12PIN;
391 	}
392 
393 	musb_writel(musb->mregs, OTG_INTERFSEL, l);
394 
395 	pr_debug("HS USB OTG: revision 0x%x, sysconfig 0x%02x, "
396 			"sysstatus 0x%x, intrfsel 0x%x, simenable  0x%x\n",
397 			musb_readl(musb->mregs, OTG_REVISION),
398 			musb_readl(musb->mregs, OTG_SYSCONFIG),
399 			musb_readl(musb->mregs, OTG_SYSSTATUS),
400 			musb_readl(musb->mregs, OTG_INTERFSEL),
401 			musb_readl(musb->mregs, OTG_SIMENABLE));
402 
403 	setup_timer(&musb_idle_timer, musb_do_idle, (unsigned long) musb);
404 
405 	if (glue->status != OMAP_MUSB_UNKNOWN)
406 		omap_musb_set_mailbox(glue);
407 
408 	pm_runtime_put_noidle(musb->controller);
409 	return 0;
410 
411 err1:
412 	return status;
413 }
414 
415 static void omap2430_musb_enable(struct musb *musb)
416 {
417 	u8		devctl;
418 	u32		val;
419 	unsigned long timeout = jiffies + msecs_to_jiffies(1000);
420 	struct device *dev = musb->controller;
421 	struct omap2430_glue *glue = dev_get_drvdata(dev->parent);
422 	struct musb_hdrc_platform_data *pdata = dev->platform_data;
423 	struct omap_musb_board_data *data = pdata->board_data;
424 
425 	switch (glue->status) {
426 
427 	case OMAP_MUSB_ID_GROUND:
428 		val = AVALID | VBUSVALID;
429 		omap4_usb_phy_mailbox(glue, val);
430 		if (data->interface_type != MUSB_INTERFACE_UTMI)
431 			break;
432 		devctl = musb_readb(musb->mregs, MUSB_DEVCTL);
433 		/* start the session */
434 		devctl |= MUSB_DEVCTL_SESSION;
435 		musb_writeb(musb->mregs, MUSB_DEVCTL, devctl);
436 		while (musb_readb(musb->mregs, MUSB_DEVCTL) &
437 				MUSB_DEVCTL_BDEVICE) {
438 			cpu_relax();
439 
440 			if (time_after(jiffies, timeout)) {
441 				dev_err(dev, "configured as A device timeout");
442 				break;
443 			}
444 		}
445 		break;
446 
447 	case OMAP_MUSB_VBUS_VALID:
448 		val = IDDIG | AVALID | VBUSVALID;
449 		omap4_usb_phy_mailbox(glue, val);
450 		break;
451 
452 	default:
453 		break;
454 	}
455 }
456 
457 static void omap2430_musb_disable(struct musb *musb)
458 {
459 	u32 val;
460 	struct device *dev = musb->controller;
461 	struct omap2430_glue *glue = dev_get_drvdata(dev->parent);
462 
463 	if (glue->status != OMAP_MUSB_UNKNOWN) {
464 		val = SESSEND | IDDIG;
465 		omap4_usb_phy_mailbox(glue, val);
466 	}
467 }
468 
469 static int omap2430_musb_exit(struct musb *musb)
470 {
471 	del_timer_sync(&musb_idle_timer);
472 
473 	omap2430_low_level_exit(musb);
474 
475 	return 0;
476 }
477 
478 static const struct musb_platform_ops omap2430_ops = {
479 	.init		= omap2430_musb_init,
480 	.exit		= omap2430_musb_exit,
481 
482 	.set_mode	= omap2430_musb_set_mode,
483 	.try_idle	= omap2430_musb_try_idle,
484 
485 	.set_vbus	= omap2430_musb_set_vbus,
486 
487 	.enable		= omap2430_musb_enable,
488 	.disable	= omap2430_musb_disable,
489 };
490 
491 static u64 omap2430_dmamask = DMA_BIT_MASK(32);
492 
493 static int omap2430_probe(struct platform_device *pdev)
494 {
495 	struct musb_hdrc_platform_data	*pdata = pdev->dev.platform_data;
496 	struct omap_musb_board_data	*data;
497 	struct platform_device		*musb;
498 	struct omap2430_glue		*glue;
499 	struct device_node		*np = pdev->dev.of_node;
500 	struct musb_hdrc_config		*config;
501 	struct resource			*res;
502 	int				ret = -ENOMEM;
503 
504 	glue = devm_kzalloc(&pdev->dev, sizeof(*glue), GFP_KERNEL);
505 	if (!glue) {
506 		dev_err(&pdev->dev, "failed to allocate glue context\n");
507 		goto err0;
508 	}
509 
510 	musb = platform_device_alloc("musb-hdrc", PLATFORM_DEVID_AUTO);
511 	if (!musb) {
512 		dev_err(&pdev->dev, "failed to allocate musb device\n");
513 		goto err0;
514 	}
515 
516 	musb->dev.parent		= &pdev->dev;
517 	musb->dev.dma_mask		= &omap2430_dmamask;
518 	musb->dev.coherent_dma_mask	= omap2430_dmamask;
519 
520 	glue->dev			= &pdev->dev;
521 	glue->musb			= musb;
522 	glue->status			= OMAP_MUSB_UNKNOWN;
523 
524 	res = platform_get_resource(pdev, IORESOURCE_MEM, 1);
525 
526 	glue->control_otghs = devm_request_and_ioremap(&pdev->dev, res);
527 	if (glue->control_otghs == NULL)
528 		dev_dbg(&pdev->dev, "Failed to obtain control memory\n");
529 
530 	if (np) {
531 		pdata = devm_kzalloc(&pdev->dev, sizeof(*pdata), GFP_KERNEL);
532 		if (!pdata) {
533 			dev_err(&pdev->dev,
534 				"failed to allocate musb platfrom data\n");
535 			ret = -ENOMEM;
536 			goto err2;
537 		}
538 
539 		data = devm_kzalloc(&pdev->dev, sizeof(*data), GFP_KERNEL);
540 		if (!data) {
541 			dev_err(&pdev->dev,
542 					"failed to allocate musb board data\n");
543 			ret = -ENOMEM;
544 			goto err2;
545 		}
546 
547 		config = devm_kzalloc(&pdev->dev, sizeof(*config), GFP_KERNEL);
548 		if (!data) {
549 			dev_err(&pdev->dev,
550 				"failed to allocate musb hdrc config\n");
551 			goto err2;
552 		}
553 
554 		of_property_read_u32(np, "mode", (u32 *)&pdata->mode);
555 		of_property_read_u32(np, "interface_type",
556 						(u32 *)&data->interface_type);
557 		of_property_read_u32(np, "num_eps", (u32 *)&config->num_eps);
558 		of_property_read_u32(np, "ram_bits", (u32 *)&config->ram_bits);
559 		of_property_read_u32(np, "power", (u32 *)&pdata->power);
560 		config->multipoint = of_property_read_bool(np, "multipoint");
561 
562 		pdata->board_data	= data;
563 		pdata->config		= config;
564 	}
565 
566 	pdata->platform_ops		= &omap2430_ops;
567 
568 	platform_set_drvdata(pdev, glue);
569 
570 	/*
571 	 * REVISIT if we ever have two instances of the wrapper, we will be
572 	 * in big trouble
573 	 */
574 	_glue	= glue;
575 
576 	INIT_WORK(&glue->omap_musb_mailbox_work, omap_musb_mailbox_work);
577 
578 	ret = platform_device_add_resources(musb, pdev->resource,
579 			pdev->num_resources);
580 	if (ret) {
581 		dev_err(&pdev->dev, "failed to add resources\n");
582 		goto err2;
583 	}
584 
585 	ret = platform_device_add_data(musb, pdata, sizeof(*pdata));
586 	if (ret) {
587 		dev_err(&pdev->dev, "failed to add platform_data\n");
588 		goto err2;
589 	}
590 
591 	pm_runtime_enable(&pdev->dev);
592 
593 	ret = platform_device_add(musb);
594 	if (ret) {
595 		dev_err(&pdev->dev, "failed to register musb device\n");
596 		goto err2;
597 	}
598 
599 	return 0;
600 
601 err2:
602 	platform_device_put(musb);
603 
604 err0:
605 	return ret;
606 }
607 
608 static int omap2430_remove(struct platform_device *pdev)
609 {
610 	struct omap2430_glue		*glue = platform_get_drvdata(pdev);
611 
612 	cancel_work_sync(&glue->omap_musb_mailbox_work);
613 	platform_device_unregister(glue->musb);
614 
615 	return 0;
616 }
617 
618 #ifdef CONFIG_PM
619 
620 static int omap2430_runtime_suspend(struct device *dev)
621 {
622 	struct omap2430_glue		*glue = dev_get_drvdata(dev);
623 	struct musb			*musb = glue_to_musb(glue);
624 
625 	if (musb) {
626 		musb->context.otg_interfsel = musb_readl(musb->mregs,
627 				OTG_INTERFSEL);
628 
629 		omap2430_low_level_exit(musb);
630 		usb_phy_set_suspend(musb->xceiv, 1);
631 	}
632 
633 	return 0;
634 }
635 
636 static int omap2430_runtime_resume(struct device *dev)
637 {
638 	struct omap2430_glue		*glue = dev_get_drvdata(dev);
639 	struct musb			*musb = glue_to_musb(glue);
640 
641 	if (musb) {
642 		omap2430_low_level_init(musb);
643 		musb_writel(musb->mregs, OTG_INTERFSEL,
644 				musb->context.otg_interfsel);
645 
646 		usb_phy_set_suspend(musb->xceiv, 0);
647 	}
648 
649 	return 0;
650 }
651 
652 static struct dev_pm_ops omap2430_pm_ops = {
653 	.runtime_suspend = omap2430_runtime_suspend,
654 	.runtime_resume = omap2430_runtime_resume,
655 };
656 
657 #define DEV_PM_OPS	(&omap2430_pm_ops)
658 #else
659 #define DEV_PM_OPS	NULL
660 #endif
661 
662 #ifdef CONFIG_OF
663 static const struct of_device_id omap2430_id_table[] = {
664 	{
665 		.compatible = "ti,omap4-musb"
666 	},
667 	{
668 		.compatible = "ti,omap3-musb"
669 	},
670 	{},
671 };
672 MODULE_DEVICE_TABLE(of, omap2430_id_table);
673 #endif
674 
675 static struct platform_driver omap2430_driver = {
676 	.probe		= omap2430_probe,
677 	.remove		= omap2430_remove,
678 	.driver		= {
679 		.name	= "musb-omap2430",
680 		.pm	= DEV_PM_OPS,
681 		.of_match_table = of_match_ptr(omap2430_id_table),
682 	},
683 };
684 
685 MODULE_DESCRIPTION("OMAP2PLUS MUSB Glue Layer");
686 MODULE_AUTHOR("Felipe Balbi <balbi@ti.com>");
687 MODULE_LICENSE("GPL v2");
688 
689 static int __init omap2430_init(void)
690 {
691 	return platform_driver_register(&omap2430_driver);
692 }
693 subsys_initcall(omap2430_init);
694 
695 static void __exit omap2430_exit(void)
696 {
697 	platform_driver_unregister(&omap2430_driver);
698 }
699 module_exit(omap2430_exit);
700