Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

usb: hcd: Initialize USB phy if needed

This adds external USB phy support to USB HCD driver that
allows to find and initialize external USB phy, bound to
the HCD, when the HCD is added.
The usb_add_hcd function returns -EPROBE_DEFER if the USB
phy, bound to the HCD, is not ready.
If no USB phy is bound, the HCD is initialized as usual.

Signed-off-by: Valentine Barshak <valentine.barshak@cogentembedded.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Valentine Barshak and committed by
Greg Kroah-Hartman
1ae5799e 103e127d

+18
+18
drivers/usb/core/hcd.c
··· 2589 2589 int retval; 2590 2590 struct usb_device *rhdev; 2591 2591 2592 + if (IS_ENABLED(CONFIG_USB_PHY) && !hcd->phy) { 2593 + struct usb_phy *phy = usb_get_phy_dev(hcd->self.controller, 0); 2594 + 2595 + if (IS_ERR(phy)) { 2596 + retval = PTR_ERR(phy); 2597 + if (retval == -EPROBE_DEFER) 2598 + return retval; 2599 + } else { 2600 + retval = usb_phy_init(phy); 2601 + if (retval) { 2602 + usb_put_phy(phy); 2603 + return retval; 2604 + } 2605 + hcd->phy = phy; 2606 + hcd->remove_phy = 1; 2607 + } 2608 + } 2609 + 2592 2610 dev_info(hcd->self.controller, "%s\n", hcd->product_desc); 2593 2611 2594 2612 /* Keep old behaviour if authorized_default is not in [0, 1]. */