static int __devexit msm_otg_remove(struct platform_device *pdev) { struct msm_otg *motg = platform_get_drvdata(pdev); struct otg_transceiver *otg = &motg->otg; int cnt = 0; if (otg->host || otg->gadget) return -EBUSY; msm_otg_debugfs_cleanup(); cancel_work_sync(&motg->sm_work); msm_otg_resume(motg); device_init_wakeup(&pdev->dev, 0); pm_runtime_disable(&pdev->dev); otg_set_transceiver(NULL); free_irq(motg->irq, motg); /* * Put PHY in low power mode. */ ulpi_read(otg, 0x14); ulpi_write(otg, 0x08, 0x09); writel(readl(USB_PORTSC) | PORTSC_PHCD, USB_PORTSC); while (cnt < PHY_SUSPEND_TIMEOUT_USEC) { if (readl(USB_PORTSC) & PORTSC_PHCD) break; udelay(1); cnt++; } if (cnt >= PHY_SUSPEND_TIMEOUT_USEC) dev_err(otg->dev, "Unable to suspend PHY\n"); clk_disable(motg->pclk); clk_disable(motg->clk); if (motg->core_clk) clk_disable(motg->core_clk); iounmap(motg->regs); pm_runtime_set_suspended(&pdev->dev); clk_put(motg->phy_reset_clk); clk_put(motg->pclk); clk_put(motg->clk); if (motg->core_clk) clk_put(motg->core_clk); kfree(motg); return 0; }
static int msm_otg_remove(struct platform_device *pdev) { struct msm_otg *motg = platform_get_drvdata(pdev); struct usb_phy *phy = &motg->phy; int cnt = 0; if (phy->otg->host || phy->otg->gadget) return -EBUSY; msm_otg_debugfs_cleanup(); cancel_delayed_work_sync(&motg->chg_work); cancel_work_sync(&motg->sm_work); pm_runtime_resume(&pdev->dev); device_init_wakeup(&pdev->dev, 0); pm_runtime_disable(&pdev->dev); usb_remove_phy(phy); disable_irq(motg->irq); /* * Put PHY in low power mode. */ ulpi_read(phy, 0x14); ulpi_write(phy, 0x08, 0x09); writel(readl(USB_PORTSC) | PORTSC_PHCD, USB_PORTSC); while (cnt < PHY_SUSPEND_TIMEOUT_USEC) { if (readl(USB_PORTSC) & PORTSC_PHCD) break; udelay(1); cnt++; } if (cnt >= PHY_SUSPEND_TIMEOUT_USEC) dev_err(phy->dev, "Unable to suspend PHY\n"); clk_disable_unprepare(motg->pclk); clk_disable_unprepare(motg->clk); if (!IS_ERR(motg->core_clk)) clk_disable_unprepare(motg->core_clk); msm_hsusb_ldo_init(motg, 0); pm_runtime_set_suspended(&pdev->dev); return 0; }
static int __exit msm_otg_remove(struct platform_device *pdev) { struct msm_otg *dev = the_msm_otg; free_irq(dev->irq, pdev); iounmap(dev->regs); clk_disable(dev->pclk); clk_disable(dev->clk); clk_put(dev->pclk); clk_put(dev->clk); wake_lock_destroy(&dev->wlock); msm_otg_debugfs_cleanup(); kfree(dev); if (dev->rpc_connect) dev->rpc_connect(0); return 0; }