コード例 #1
0
int fsl_usb_host_init(struct platform_device *pdev)
{
	struct fsl_usb2_platform_data *pdata = pdev->dev.platform_data;
	struct fsl_xcvr_ops *xops;

	pr_debug("%s: pdev=0x%p  pdata=0x%p\n", __func__, pdev, pdata);

	xops = fsl_usb_get_xcvr(pdata->transceiver);
	if (!xops) {
		printk(KERN_ERR "%s transceiver ops missing\n", pdata->name);
		return -EINVAL;
	}
	pdata->xcvr_ops = xops;
	pdata->xcvr_type = xops->xcvr_type;
	pdata->pdev = pdev;

	if (fsl_check_usbclk() != 0)
		return -EINVAL;

	/* set host2 usb phy usb3317 power supply for imx31 3 stack */
	if ((pdata->xcvr_type == PORTSC_PTS_ULPI) && (machine_is_mx31_3ds())) {
		pdata->xcvr_pwr =
		    kmalloc(sizeof(struct fsl_xcvr_power), GFP_KERNEL);
		if (!(pdata->xcvr_pwr))
			return -ENOMEM;

		pdata->xcvr_pwr->usb_pdev = pdev;
		usbh2_get_xcvr_power(&(pdev->dev));
	}

	pr_debug("%s: grab pins\n", __func__);
	if (pdata->gpio_usb_active())
		return -EINVAL;

	if (clk_enable(usb_clk)) {
		printk(KERN_ERR "clk_enable(usb_clk) failed\n");
		return -EINVAL;
	}

	if (cpu_is_mx51()) {
		usb_clk = clk_get(NULL, "usboh3_clk");
		clk_enable(usb_clk);
		clk_put(usb_clk);
	}

	if (xops->init)
		xops->init(xops);

	if (xops->xcvr_type == PORTSC_PTS_SERIAL) {
		if (machine_is_mx35_3ds())
			usbh2_set_serial_xcvr();
		else
			usbh1_set_serial_xcvr();
	} else if (xops->xcvr_type == PORTSC_PTS_ULPI) {
		if (cpu_is_mx51()) {
			usbh1_set_ulpi_xcvr();
			gpio_usbh1_setback_stp();
		} else
			usbh2_set_ulpi_xcvr();
	}

	pr_debug("%s: %s success\n", __func__, pdata->name);
	return 0;
}
コード例 #2
0
int fsl_usb_host_init(struct platform_device *pdev)
{
	struct fsl_usb2_platform_data *pdata = pdev->dev.platform_data;
	struct fsl_xcvr_ops *xops;

	pr_debug("%s: pdev=0x%p  pdata=0x%p\n", __func__, pdev, pdata);

	xops = fsl_usb_get_xcvr(pdata->transceiver);
	if (!xops) {
		printk(KERN_ERR "%s transceiver ops missing\n", pdata->name);
		return -EINVAL;
	}
	pdata->xcvr_ops = xops;
	pdata->xcvr_type = xops->xcvr_type;
	pdata->pdev = pdev;

	if (fsl_check_usbclk() != 0)
		return -EINVAL;

	pr_debug("%s: grab pins\n", __func__);
	if (pdata->gpio_usb_active())
		return -EINVAL;

	if (clk_enable(usb_clk)) {
		printk(KERN_ERR "clk_enable(usb_clk) failed\n");
		return -EINVAL;
	}

	if (cpu_is_mx51()) {
		usb_clk = clk_get(NULL, "usboh3_clk");
		clk_enable(usb_clk);
		clk_put(usb_clk);
	}

	/* enable board power supply for xcvr */
	if (pdata->xcvr_pwr) {
		if (pdata->xcvr_pwr->regu1)
			regulator_enable(pdata->xcvr_pwr->regu1);
		if (pdata->xcvr_pwr->regu2)
			regulator_enable(pdata->xcvr_pwr->regu2);
	}

	if (xops->init)
		xops->init(xops);

	if (usb_register_remote_wakeup(pdev))
		pr_debug("Host is not a wakeup source.\n");

	if (xops->xcvr_type == PORTSC_PTS_SERIAL) {
		if (cpu_is_mx35()) {
			usbh2_set_serial_xcvr();
			/* Close the internal 60Mhz */
			USBCTRL &= ~UCTRL_XCSH2;
		} else if (cpu_is_mx25())
			usbh2_set_serial_xcvr();
		else
			usbh1_set_serial_xcvr();
	} else if (xops->xcvr_type == PORTSC_PTS_ULPI) {
		if (cpu_is_mx51()) {
#ifdef CONFIG_USB_EHCI_ARC_H1
		if (pdata->name == "Host 1") {
			usbh1_set_ulpi_xcvr();
			if (cpu_is_mx51())
			gpio_usbh1_setback_stp();
			}
#endif
#ifdef CONFIG_USB_EHCI_ARC_H2
		if (pdata->name == "Host 2") {
			usbh2_set_ulpi_xcvr();
			if (cpu_is_mx51())
				gpio_usbh2_setback_stp();
			}
#endif
		} else
			usbh2_set_ulpi_xcvr();
	}

	if (pdata->name == "Host 2")
		/* disable remote wakeup irq */
		USBCTRL &= ~UCTRL_H2WIE;

	pr_debug("%s: %s success\n", __func__, pdata->name);
	return 0;
}