static int msm_otg_set_host(struct otg_transceiver *xceiv, struct usb_bus *host) { struct msm_otg *dev = container_of(xceiv, struct msm_otg, otg); if (!dev || (dev != the_msm_otg)) return -ENODEV; if (!host) { msm_otg_start_host(xceiv, 0); dev->otg.host = 0; disable_idgnd(dev); return 0; } dev->otg.host = host; enable_idgnd(dev); pr_info("host driver registered w/ tranceiver\n"); #ifndef CONFIG_USB_GADGET_MSM_72K if (is_host()) msm_otg_start_host(&dev->otg, 1); else msm_otg_suspend(dev); #endif return 0; }
static int msm_otg_set_host(struct otg_transceiver *xceiv, struct usb_bus *host) { struct msm_otg *dev = container_of(xceiv, struct msm_otg, otg); if (!dev || (dev != the_msm_otg)) return -ENODEV; /* Id pin is not routed to PMIC. Host mode can not be * supported with pmic notification support. */ if (!dev->start_host || dev->pmic_notif_supp) return -ENODEV; if (!host) { msm_otg_start_host(xceiv, REQUEST_STOP); usb_unregister_notify(&dev->usbdev_nb); dev->otg.host = 0; dev->start_host = 0; disable_idgnd(dev); return 0; } dev->usbdev_nb.notifier_call = usbdev_notify; usb_register_notify(&dev->usbdev_nb); dev->otg.host = host; enable_idgnd(dev); pr_info("host driver registered w/ tranceiver\n"); #ifdef CONFIG_USB_OTG host->otg_port = 1; #else wake_lock(&dev->wlock); queue_work(dev->wq, &dev->sm_work); #endif return 0; }
static void otg_reset(struct msm_otg *dev, int phy_reset) { unsigned long timeout; u32 mode; clk_enable(dev->hs_clk); if (!phy_reset) goto reset_link; if (dev->pdata->phy_reset) dev->pdata->phy_reset(dev->regs); else msm_otg_phy_reset(dev); /*disable all phy interrupts*/ ulpi_write(dev, 0xFF, 0x0F); ulpi_write(dev, 0xFF, 0x12); msleep(100); reset_link: writel(USBCMD_RESET, USB_USBCMD); timeout = jiffies + USB_LINK_RESET_TIMEOUT; do { if (time_after(jiffies, timeout)) { pr_err("msm_otg: usb link reset timeout\n"); break; } msleep(1); } while (readl(USB_USBCMD) & USBCMD_RESET); /* select ULPI phy */ writel(0x80000000, USB_PORTSC); set_pre_emphasis_level(dev); set_cdr_auto_reset(dev); set_driver_amplitude(dev); writel(0x0, USB_AHB_BURST); writel(0x00, USB_AHB_MODE); clk_disable(dev->hs_clk); if (test_bit(ID, &dev->inputs)) mode = USBMODE_SDIS | USBMODE_DEVICE; else mode = USBMODE_SDIS | USBMODE_HOST; writel(mode, USB_USBMODE); if (dev->otg.gadget) enable_sess_valid(dev); #ifdef CONFIG_USB_EHCI_MSM if (dev->otg.host) enable_idgnd(dev); #endif }
static void otg_reset(struct msm_otg *dev) { unsigned long timeout; unsigned temp; clk_enable(dev->clk); if (dev->phy_reset) dev->phy_reset(dev->regs); /*disable all phy interrupts*/ ulpi_write(dev, 0xFF, 0x0F); ulpi_write(dev, 0xFF, 0x12); msleep(100); writel(USBCMD_RESET, USB_USBCMD); timeout = jiffies + USB_LINK_RESET_TIMEOUT; do { if (time_after(jiffies, timeout)) { pr_err("msm_otg: usb link reset timeout\n"); break; } msleep(1); } while (readl(USB_USBCMD) & USBCMD_RESET); /* select ULPI phy */ writel(0x80000000, USB_PORTSC); temp = ulpi_read(dev, ULPI_CONFIG_REG); temp |= ULPI_AMPLITUDE_MAX; ulpi_write(dev, temp, ULPI_CONFIG_REG); writel(0x0, USB_AHB_BURST); writel(0x00, USB_AHB_MODE); clk_disable(dev->clk); if (dev->otg.gadget) enable_sess_valid(dev); if (dev->otg.host) enable_idgnd(dev); }