39 #include <linux/module.h>
132 static void dsps_musb_enable(
struct musb *
musb)
136 struct dsps_glue *glue = platform_get_drvdata(pdev);
139 u32 epmask, coremask;
146 dsps_writel(reg_base, wrp->
epintr_set, epmask);
156 static void dsps_musb_disable(
struct musb *
musb)
160 struct dsps_glue *glue = platform_get_drvdata(pdev);
168 dsps_writel(reg_base, wrp->
eoi, 0);
171 static void otg_timer(
unsigned long _musb)
191 switch (musb->
xceiv->state) {
212 if (devctl & MUSB_DEVCTL_BDEVICE)
221 spin_unlock_irqrestore(&musb->
lock, flags);
224 static void dsps_musb_try_idle(
struct musb *musb,
unsigned long timeout)
244 timer_pending(&glue->
timer[pdev->
id])) {
246 "Longer idle timer already pending, ignoring...\n");
257 static irqreturn_t dsps_interrupt(
int irq,
void *hci)
259 struct musb *musb = hci;
281 if (!usbintr && !epintr)
299 pr_info(
"CAUTION: musb: Babble Interrupt Occured\n");
324 WARNING(
"VBUS error workaround (delay coming)\n");
325 }
else if (drvvbus) {
328 musb->
xceiv->otg->default_a = 1;
334 musb->
xceiv->otg->default_a = 0;
340 drvvbus ?
"on" :
"off",
353 dsps_writel(reg_base, wrp->
eoi, 1);
360 spin_unlock_irqrestore(&musb->
lock, flags);
365 static int dsps_musb_init(
struct musb *musb)
382 if (IS_ERR_OR_NULL(musb->
xceiv))
386 rev = dsps_readl(reg_base, wrp->
revision);
398 if (data->set_phy_power)
399 data->set_phy_power(1);
401 musb->
isr = dsps_interrupt;
404 val = dsps_readl(reg_base, wrp->
phy_utmi);
409 dsps_writel(reg_base, wrp->
eoi, 0);
418 static int dsps_musb_exit(
struct musb *musb)
422 struct omap_musb_board_data *data = plat->
board_data;
429 if (data->set_phy_power)
430 data->set_phy_power(0);
440 .init = dsps_musb_init,
441 .exit = dsps_musb_exit,
443 .enable = dsps_musb_enable,
444 .disable = dsps_musb_disable,
446 .try_idle = dsps_musb_try_idle,
465 snprintf(res_name,
sizeof(res_name),
"musb%d",
id);
468 dev_err(dev,
"%s get mem resource failed\n", res_name);
476 snprintf(res_name,
sizeof(res_name),
"musb%d-irq",
id);
479 dev_err(dev,
"%s get irq resource failed\n", res_name);
490 dev_err(dev,
"failed to allocate musb id\n");
497 dev_err(dev,
"failed to allocate musb device\n");
504 musb->
dev.dma_mask = &musb_dmamask;
505 musb->
dev.coherent_dma_mask = musb_dmamask;
511 dev_err(dev,
"failed to add resources\n");
519 "failed to allocate musb platfrom data\n");
527 "failed to allocate musb hdrc config\n");
531 of_property_read_u32(np,
"num-eps", (
u32 *)&config->
num_eps);
532 of_property_read_u32(np,
"ram-bits", (
u32 *)&config->
ram_bits);
533 snprintf(res_name,
sizeof(res_name),
"port%d-mode",
id);
534 of_property_read_u32(np, res_name, (
u32 *)&pdata->
mode);
535 of_property_read_u32(np,
"power", (
u32 *)&pdata->
power);
536 config->
multipoint = of_property_read_bool(np,
"multipoint");
545 dev_err(dev,
"failed to add platform_data\n");
551 dev_err(dev,
"failed to register musb device\n");
565 static void dsps_delete_musb_pdev(
struct dsps_glue *glue,
u8 id)
583 dev_err(&pdev->
dev,
"fail to get matching of_match struct\n");
592 dev_err(&pdev->
dev,
"unable to allocate glue memory\n");
600 dev_err(&pdev->
dev,
"failed to get usbss mem resourse\n");
609 dev_err(&pdev->
dev,
"failed to duplicate wrapper struct memory\n");
613 platform_set_drvdata(pdev, glue);
618 ret = pm_runtime_get_sync(&pdev->
dev);
620 dev_err(&pdev->
dev,
"pm_runtime_get_sync FAILED");
626 ret = dsps_create_musb_pdev(glue, i);
628 dev_err(&pdev->
dev,
"failed to create child pdev\n");
630 for (i--; i >= 0 ; i--)
631 dsps_delete_musb_pdev(glue, i);
639 pm_runtime_put(&pdev->
dev);
641 pm_runtime_disable(&pdev->
dev);
650 struct dsps_glue *glue = platform_get_drvdata(pdev);
656 dsps_delete_musb_pdev(glue, i);
659 pm_runtime_put(&pdev->
dev);
660 pm_runtime_disable(&pdev->
dev);
666 #ifdef CONFIG_PM_SLEEP
667 static int dsps_suspend(
struct device *dev)
670 struct omap_musb_board_data *data = plat->
board_data;
673 if (data->set_phy_power)
674 data->set_phy_power(0);
679 static int dsps_resume(
struct device *dev)
682 struct omap_musb_board_data *data = plat->
board_data;
685 if (data->set_phy_power)
686 data->set_phy_power(1);
700 .epintr_clear = 0x40,
701 .epintr_status = 0x30,
702 .coreintr_set = 0x3c,
703 .coreintr_clear = 0x44,
704 .coreintr_status = 0x34,
712 .usb_bitmap = (0x1ff << 0),
719 .rxep_bitmap = (0xfffe << 16),
727 .name =
"musb-ti81xx",
735 static const struct of_device_id musb_dsps_of_match[] __devinitconst = {
736 { .compatible =
"ti,musb-am33xx",
737 .data = (
void *) &ti81xx_driver_data, },
751 .id_table = musb_dsps_id_table,
759 static int __init dsps_init(
void)
765 static void __exit dsps_exit(
void)