static int msm_sdcc_cfg_mpm_sdiowakeup(struct device *dev, unsigned mode) { struct platform_device *pdev; enum msm_mpm_pin pin; int ret = 0; pdev = container_of(dev, struct platform_device, dev); /* Only SDCC4 slot connected to WLAN chip has wakeup capability */ if (pdev->id == 4) pin = MSM_MPM_PIN_SDC4_DAT1; else return -EINVAL; switch (mode) { case SDC_DAT1_DISABLE: ret = msm_mpm_enable_pin(pin, 0); break; case SDC_DAT1_ENABLE: ret = msm_mpm_set_pin_type(pin, IRQ_TYPE_LEVEL_LOW); ret = msm_mpm_enable_pin(pin, 1); break; case SDC_DAT1_ENWAKE: ret = msm_mpm_set_pin_wake(pin, 1); break; case SDC_DAT1_DISWAKE: ret = msm_mpm_set_pin_wake(pin, 0); break; default: ret = -EINVAL; break; } return ret; }
static int __devexit ehci_msm2_remove(struct platform_device *pdev) { struct msm_usb_host_platform_data *pdata; struct usb_hcd *hcd = platform_get_drvdata(pdev); struct msm_hcd *mhcd = hcd_to_mhcd(hcd); pdata = mhcd->dev->platform_data; if (mhcd->pmic_gpio_dp_irq) { if (mhcd->pmic_gpio_dp_irq_enabled) disable_irq_wake(mhcd->pmic_gpio_dp_irq); free_irq(mhcd->pmic_gpio_dp_irq, mhcd); } else if (pdata->mpm_xo_wakeup_int) { msm_mpm_set_pin_wake(pdata->mpm_xo_wakeup_int, 0); msm_mpm_enable_pin(pdata->mpm_xo_wakeup_int, 0); } device_init_wakeup(&pdev->dev, 0); pm_runtime_set_suspended(&pdev->dev); usb_remove_hcd(hcd); msm_xo_put(mhcd->xo_handle); msm_ehci_vbus_power(mhcd, 0); msm_ehci_init_vbus(mhcd, 0); msm_ehci_ldo_enable(mhcd, 0); msm_ehci_ldo_init(mhcd, 0); msm_ehci_init_vddcx(mhcd, 0); msm_ehci_init_clocks(mhcd, 0); wake_lock_destroy(&mhcd->wlock); iounmap(hcd->regs); usb_put_hcd(hcd); #if defined(CONFIG_DEBUG_FS) debugfs_remove_recursive(dent_ehci); #endif return 0; }
static int __devinit ehci_msm2_probe(struct platform_device *pdev) { struct usb_hcd *hcd; struct resource *res; struct msm_hcd *mhcd; const struct msm_usb_host_platform_data *pdata; char pdev_name[PDEV_NAME_LEN]; int ret; dev_dbg(&pdev->dev, "ehci_msm2 probe\n"); hcd = usb_create_hcd(&msm_hc2_driver, &pdev->dev, dev_name(&pdev->dev)); if (!hcd) { dev_err(&pdev->dev, "Unable to create HCD\n"); return -ENOMEM; } hcd->irq = platform_get_irq(pdev, 0); if (hcd->irq < 0) { dev_err(&pdev->dev, "Unable to get IRQ resource\n"); ret = hcd->irq; goto put_hcd; } res = platform_get_resource(pdev, IORESOURCE_MEM, 0); if (!res) { dev_err(&pdev->dev, "Unable to get memory resource\n"); ret = -ENODEV; goto put_hcd; } hcd->rsrc_start = res->start; hcd->rsrc_len = resource_size(res); hcd->regs = ioremap(hcd->rsrc_start, hcd->rsrc_len); if (!hcd->regs) { dev_err(&pdev->dev, "ioremap failed\n"); ret = -ENOMEM; goto put_hcd; } mhcd = hcd_to_mhcd(hcd); mhcd->dev = &pdev->dev; snprintf(pdev_name, PDEV_NAME_LEN, "%s.%d", pdev->name, pdev->id); mhcd->xo_handle = msm_xo_get(MSM_XO_TCXO_D0, pdev_name); if (IS_ERR(mhcd->xo_handle)) { dev_err(&pdev->dev, "%s not able to get the handle " "to vote for TCXO D0 buffer\n", __func__); ret = PTR_ERR(mhcd->xo_handle); goto unmap; } ret = msm_xo_mode_vote(mhcd->xo_handle, MSM_XO_MODE_ON); if (ret) { dev_err(&pdev->dev, "%s failed to vote for TCXO " "D0 buffer%d\n", __func__, ret); goto free_xo_handle; } ret = msm_ehci_init_clocks(mhcd, 1); if (ret) { dev_err(&pdev->dev, "unable to initialize clocks\n"); ret = -ENODEV; goto devote_xo_handle; } ret = msm_ehci_init_vddcx(mhcd, 1); if (ret) { dev_err(&pdev->dev, "unable to initialize VDDCX\n"); ret = -ENODEV; goto deinit_clocks; } ret = msm_ehci_config_vddcx(mhcd, 1); if (ret) { dev_err(&pdev->dev, "hsusb vddcx configuration failed\n"); goto deinit_vddcx; } ret = msm_ehci_ldo_init(mhcd, 1); if (ret) { dev_err(&pdev->dev, "hsusb vreg configuration failed\n"); goto deinit_vddcx; } ret = msm_ehci_ldo_enable(mhcd, 1); if (ret) { dev_err(&pdev->dev, "hsusb vreg enable failed\n"); goto deinit_ldo; } ret = msm_ehci_init_vbus(mhcd, 1); if (ret) { dev_err(&pdev->dev, "unable to get vbus\n"); goto disable_ldo; } ret = msm_hsusb_reset(mhcd); if (ret) { dev_err(&pdev->dev, "hsusb PHY initialization failed\n"); goto vbus_deinit; } ret = usb_add_hcd(hcd, hcd->irq, IRQF_SHARED); if (ret) { dev_err(&pdev->dev, "unable to register HCD\n"); goto vbus_deinit; } pdata = mhcd->dev->platform_data; if (pdata && (!pdata->dock_connect_irq || !irq_read_line(pdata->dock_connect_irq))) msm_ehci_vbus_power(mhcd, 1); device_init_wakeup(&pdev->dev, 1); wake_lock_init(&mhcd->wlock, WAKE_LOCK_SUSPEND, dev_name(&pdev->dev)); wake_lock(&mhcd->wlock); INIT_WORK(&mhcd->phy_susp_fail_work, msm_ehci_phy_susp_fail_work); /* * This pdev->dev is assigned parent of root-hub by USB core, * hence, runtime framework automatically calls this driver's * runtime APIs based on root-hub's state. */ /* configure pmic_gpio_irq for D+ change */ if (pdata && pdata->pmic_gpio_dp_irq) mhcd->pmic_gpio_dp_irq = pdata->pmic_gpio_dp_irq; if (mhcd->pmic_gpio_dp_irq) { ret = request_threaded_irq(mhcd->pmic_gpio_dp_irq, NULL, msm_ehci_host_wakeup_irq, IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING, "msm_ehci_host_wakeup", mhcd); if (!ret) { disable_irq_nosync(mhcd->pmic_gpio_dp_irq); } else { dev_err(&pdev->dev, "request_irq(%d) failed: %d\n", mhcd->pmic_gpio_dp_irq, ret); mhcd->pmic_gpio_dp_irq = 0; } } else if (pdata->mpm_xo_wakeup_int) { msm_mpm_set_pin_type(pdata->mpm_xo_wakeup_int, IRQ_TYPE_LEVEL_HIGH); msm_mpm_set_pin_wake(pdata->mpm_xo_wakeup_int, 1); } pm_runtime_set_active(&pdev->dev); pm_runtime_enable(&pdev->dev); if (ehci_debugfs_init(mhcd) < 0) dev_err(mhcd->dev, "%s: debugfs init failed\n", __func__); return 0; vbus_deinit: msm_ehci_init_vbus(mhcd, 0); disable_ldo: msm_ehci_ldo_enable(mhcd, 0); deinit_ldo: msm_ehci_ldo_init(mhcd, 0); deinit_vddcx: msm_ehci_init_vddcx(mhcd, 0); deinit_clocks: msm_ehci_init_clocks(mhcd, 0); devote_xo_handle: msm_xo_mode_vote(mhcd->xo_handle, MSM_XO_MODE_OFF); free_xo_handle: msm_xo_put(mhcd->xo_handle); unmap: iounmap(hcd->regs); put_hcd: usb_put_hcd(hcd); return ret; }