On Wednesday, January 06, 2016 at 07:21:21 PM, Mateusz Kulikowski wrote: > This driver is able to reconfigure OTG controller into HOST mode. > Board can add board-specific initialization as board_prepare_usb(). > It requires USB_ULPI_VIEWPORT enabled in board configuration. > > Signed-off-by: Mateusz Kulikowski <mateusz.kulikow...@gmail.com>
[...] > +static int msm_init_after_reset(struct ehci_ctrl *dev) > +{ > + struct msm_ehci_priv *p = container_of(dev, struct msm_ehci_priv, ctrl); > + struct usb_ehci *ehci = p->ehci; > + > + /* select ULPI phy */ > + writel(0x80000000, &ehci->portsc); Don't we have macro for this bit ? > + setup_usb_phy(p); > + > + /* Enable sess_vld */ > + setbits_le32(&ehci->genconfig2, GEN2_SESS_VLD_CTRL_EN); > + > + /* Enable external vbus configuration in the LINK */ > + setbits_le32(&ehci->usbcmd, SESS_VLD_CTRL); > + > + /* USB_OTG_HS_AHB_BURST */ > + writel(0x0, &ehci->sbuscfg); > + > + /* USB_OTG_HS_AHB_MODE: HPROT_MODE */ > + /* Bus access related config. */ > + writel(0x08, &ehci->sbusmode); > + > + /* set mode to host controller */ > + writel(CM_HOST, &ehci->usbmode); > + > + return 0; > +} [...] > +static int ehci_usb_remove(struct udevice *dev) > +{ > + struct msm_ehci_priv *p = dev_get_priv(dev); > + struct usb_ehci *ehci = p->ehci; > + int ret; > + > + ret = ehci_deregister(dev); > + if (ret) > + return ret; > + > + /* Stop controller. */ > + clrbits_le32(&ehci->usbcmd, CMD_RUN); > + > + reset_usb_phy(p); > + > + ret = board_prepare_usb(USB_INIT_DEVICE); /* Board specific hook */ > + if (ret < 0) > + return ret; > + > + /* Reset controller */ > + setbits_le32(&ehci->usbcmd, CMD_RESET); > + > + /* Wait for reset */ > + if (wait_for_bit(__func__, &ehci->usbcmd, CMD_RESET, false, 30, Ad. this wait_for_bit() , you can define a macro "wait_for_bit()" in some header file which would call the final __wait_for_bit(). The trick is, such macro will expand in place and you wouldn't have to call it with __func__ argument. The macro would be able to pass that __func__ argument into the final __wait_for_bit() . But that's just an idea, it doesn't prevent this driver from mainlining of course. > + false)) { > + printf("Stuck on USB reset.\n"); > + return -ETIMEDOUT; > + } > + > + return 0; > +} Other than that portsc bit, add my Acked-by: Marek Vasut <ma...@denx.de> _______________________________________________ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot