Commit 0c51dc6db9ea0e3912d1d3e2d953bc22de433c60

Authored by Stephen Warren
Committed by Marek Vasut
1 parent 8aac6e9c53

usb: ci_udc: make PHY initialization conditional

usb_gadget_register_driver() currently unconditionally programs PORTSC
to select a ULPI PHY. This is incorrect on at least the Tegra boards I
am testing with, which use a UTMI PHY for the OTG ports. Make the PHY
selection code conditional upon the specific EHCI controller that is in
use.

Ideally, I believe that the PHY initialization code should be part of
ehci_hcd_init() in the relevant EHCI controller driver, or some board-
specific function that ehci_hcd_init() calls.

For MX6, I'm not sure this PHY initialization code is correct even before
this patch, since ehci-mx6's ehci_hcd_init() already configures PORTSC to
a board-specific value, and it seems likely that the code in ci_udc.c is
incorrectly undoing this. Perhaps this is not an issue if the PHY
selection register bits aren't implemented on this instance of the MX6
USB controller?

ehci-mxs.c doens't appear to touch PORTSC, so this code is likely still
required there.

Signed-off-by: Stephen Warren <swarren@nvidia.com>

Showing 1 changed file with 7 additions and 2 deletions Side-by-side Diff

drivers/usb/gadget/ci_udc.c
... ... @@ -702,7 +702,6 @@
702 702  
703 703 int usb_gadget_register_driver(struct usb_gadget_driver *driver)
704 704 {
705   - struct ci_udc *udc;
706 705 int ret;
707 706  
708 707 if (!driver)
709 708  
710 709  
... ... @@ -717,12 +716,18 @@
717 716 return ret;
718 717  
719 718 ret = ci_udc_probe();
  719 +#if defined(CONFIG_USB_EHCI_MX6) || defined(CONFIG_USB_EHCI_MXS)
  720 + /*
  721 + * FIXME: usb_lowlevel_init()->ehci_hcd_init() should be doing all
  722 + * HW-specific initialization, e.g. ULPI-vs-UTMI PHY selection
  723 + */
720 724 if (!ret) {
721   - udc = (struct ci_udc *)controller.ctrl->hcor;
  725 + struct ci_udc *udc = (struct ci_udc *)controller.ctrl->hcor;
722 726  
723 727 /* select ULPI phy */
724 728 writel(PTS(PTS_ENABLE) | PFSC, &udc->portsc);
725 729 }
  730 +#endif
726 731  
727 732 ret = driver->bind(&controller.gadget);
728 733 if (ret) {