示例#1
0
static int __init ehci_msm_probe(struct platform_device *pdev)
{
	struct usb_hcd *hcd;
	struct resource *res;
	struct msm_usb_host_platform_data *pdata;
	int retval;
	struct msmusb_hcd *mhcd;

	hcd = usb_create_hcd(&msm_hc_driver, &pdev->dev, dev_name(&pdev->dev));
	if (!hcd)
		return  -ENOMEM;

	hcd->irq = platform_get_irq(pdev, 0);
	if (hcd->irq < 0) {
		usb_put_hcd(hcd);
		return hcd->irq;
	}

	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
	if (!res) {
		usb_put_hcd(hcd);
		return -ENODEV;
	}

	hcd->rsrc_start = res->start;
	hcd->rsrc_len = resource_size(res);

	mhcd = hcd_to_mhcd(hcd);
	spin_lock_init(&mhcd->lock);
	mhcd->in_lpm = 0;
	mhcd->running = 0;
	device_init_wakeup(&pdev->dev, 1);

	pdata = pdev->dev.platform_data;
	if (PHY_TYPE(pdata->phy_info) == USB_PHY_UNDEFINED) {
		usb_put_hcd(hcd);
		return -ENODEV;
	}
	hcd->power_budget = pdata->power_budget;
	mhcd->pdata = pdata;
	INIT_WORK(&mhcd->lpm_exit_work, usb_lpm_exit_w);

	wake_lock_init(&mhcd->wlock, WAKE_LOCK_SUSPEND, dev_name(&pdev->dev));
	pm_qos_add_requirement(PM_QOS_SYSTEM_BUS_FREQ, (char *)dev_name(&pdev->dev),
					PM_QOS_DEFAULT_VALUE);

	retval = msm_xusb_init_host(mhcd);

	if (retval < 0) {
		usb_put_hcd(hcd);
		wake_lock_destroy(&mhcd->wlock);
		pm_qos_remove_requirement(PM_QOS_SYSTEM_BUS_FREQ,
				(char *) dev_name(&pdev->dev));
	}

	return retval;
}
static int __devinit ehci_msm_probe(struct platform_device *pdev)
{
    struct usb_hcd *hcd;
    struct resource *res;
    struct msm_usb_host_platform_data *pdata;
    int retval;
    struct msmusb_hcd *mhcd;

    hcd = usb_create_hcd(&msm_hc_driver, &pdev->dev, dev_name(&pdev->dev));
    if (!hcd)
        return  -ENOMEM;

    hcd->irq = platform_get_irq(pdev, 0);
    if (hcd->irq < 0) {
        usb_put_hcd(hcd);
        return hcd->irq;
    }

    res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
    if (!res) {
        usb_put_hcd(hcd);
        return -ENODEV;
    }

    hcd->rsrc_start = res->start;
    hcd->rsrc_len = resource_size(res);

    mhcd = hcd_to_mhcd(hcd);
    spin_lock_init(&mhcd->lock);
    mhcd->in_lpm = 0;
    mhcd->running = 0;
    device_init_wakeup(&pdev->dev, 1);

    pdata = pdev->dev.platform_data;
    if (PHY_TYPE(pdata->phy_info) == USB_PHY_UNDEFINED) {
        usb_put_hcd(hcd);
        return -ENODEV;
    }
    hcd->power_budget = pdata->power_budget;
    mhcd->pdata = pdata;
    INIT_WORK(&mhcd->lpm_exit_work, usb_lpm_exit_w);

    wake_lock_init(&mhcd->wlock, WAKE_LOCK_SUSPEND, dev_name(&pdev->dev));
    pdata->ebi1_clk = clk_get(&pdev->dev, "core_clk");
    if (IS_ERR(pdata->ebi1_clk))
        pdata->ebi1_clk = NULL;
    else
        clk_set_rate(pdata->ebi1_clk, INT_MAX);

    retval = msm_xusb_init_host(pdev, mhcd);

    if (retval < 0) {
        wake_lock_destroy(&mhcd->wlock);
        usb_put_hcd(hcd);
        clk_put(pdata->ebi1_clk);
    }

    pm_runtime_enable(&pdev->dev);

    return retval;
}