int usbotg_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 "DR transceiver ops missing\n"); return -EINVAL; } pdata->xcvr_ops = xops; pdata->xcvr_type = xops->xcvr_type; pdata->pdev = pdev; if (fsl_check_usbclk() != 0) return -EINVAL; if (!mxc_otg_used) { if (cpu_is_mx50()) /* Turn on AHB CLK for OTG*/ USB_CLKONOFF_CTRL &= ~OTG_AHBCLK_OFF; pr_debug("%s: grab pins\n", __func__); if (pdata->gpio_usb_active && pdata->gpio_usb_active()) return -EINVAL; if (clk_enable(usb_clk)) { printk(KERN_ERR "clk_enable(usb_clk) failed\n"); return -EINVAL; } if (xops->init) xops->init(xops); UOG_PORTSC1 = UOG_PORTSC1 & ~PORTSC_PHCD; if (xops->xcvr_type == PORTSC_PTS_SERIAL) { if (pdata->operating_mode == FSL_USB2_DR_HOST) { otg_set_serial_host(); /* need reset */ UOG_USBCMD |= UCMD_RESET; msleep(100); } else if (pdata->operating_mode == FSL_USB2_DR_DEVICE) otg_set_serial_peripheral(); otg_set_serial_xcvr(); } else if (xops->xcvr_type == PORTSC_PTS_ULPI) { otg_set_ulpi_xcvr(); } else if (xops->xcvr_type == PORTSC_PTS_UTMI) { otg_set_utmi_xcvr(); } } if (usb_register_remote_wakeup(pdev)) pr_debug("DR is not a wakeup source.\n"); mxc_otg_used++; pr_debug("%s: success\n", __func__); return 0; }
int usbotg_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 "DR transceiver ops missing\n"); return -EINVAL; } pdata->xcvr_ops = xops; pdata->xcvr_type = xops->xcvr_type; pdata->pdev = pdev; if (!otg_used) { 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 (xops->init) xops->init(xops); UOG_PORTSC1 = UOG_PORTSC1 & ~PORTSC_PHCD; if (xops->xcvr_type == PORTSC_PTS_SERIAL) { if (pdata->operating_mode == FSL_USB2_DR_HOST) { otg_set_serial_host(); /* need reset */ UOG_USBCMD |= UCMD_RESET; msleep(100); } else if (pdata->operating_mode == FSL_USB2_DR_DEVICE) otg_set_serial_peripheral(); otg_set_serial_xcvr(); } else if (xops->xcvr_type == PORTSC_PTS_ULPI) { otg_set_ulpi_xcvr(); } else if (xops->xcvr_type == PORTSC_PTS_UTMI) { otg_set_utmi_xcvr(); //pdata->usb_clock_for_pm(0); } } otg_used++; pr_debug("%s: success\n", __func__); return 0; }
static void pmic_event_handler(const PMIC_CONVITY_EVENTS event) { if (event & USB_DETECT_4V4_RISE) pr_debug("%s: USB_DETECT_4V4_RISE\n", __func__); if (event & USB_DETECT_4V4_FALL) pr_debug("%s: USB_DETECT_4V4_FALL\n", __func__); if (event & USB_DETECT_2V0_RISE) pr_debug("%s: USB_DETECT_2V0_RISE\n", __func__); if (event & USB_DETECT_2V0_FALL) pr_debug("%s: USB_DETECT_2V0_FALL\n", __func__); if (event & USB_DETECT_0V8_RISE) pr_debug("%s: USB_DETECT_0V8_RISE\n", __func__); if (event & USB_DETECT_0V8_FALL) pr_debug("%s: USB_DETECT_0V8_FALL\n", __func__); if (event & USB_DETECT_MINI_B) { pr_debug("%s: USB_DETECT_MINI_B\n", __func__); otg_set_serial_peripheral(); g_event = USB_DETECT_MINI_B; p_event = MC13783_USB_DETECT_MINI_B; schedule_work(&xc_work); } if (event & USB_DETECT_MINI_A) { pr_debug("%s: USB_DETECT_MINI_A\n", __func__); otg_set_serial_host(); g_event = USB_DETECT_MINI_A; p_event = MC13783_USB_DETECT_MINI_A; schedule_work(&xc_work); } /* * Mini-B cable insertion/removal does not generate cable-detect * event, so we rely on the VBUS changes to identify a mini-b cable * connect. This logic is only used if mini-b is the first cable that * is connected after bootup. At all other times, removal of mini-a * cable is used to initialize peripheral. */ if (g_event != USB_DETECT_MINI_A && g_event != USB_DETECT_MINI_B) { if ((event & USB_DETECT_0V8_RISE) && (event & USB_DETECT_2V0_RISE) && (event & USB_DETECT_4V4_RISE)) { otg_set_serial_peripheral(); g_event = USB_DETECT_MINI_B; p_event = MC13783_USB_DETECT_MINI_B; schedule_work(&xc_work); } } }