summaryrefslogtreecommitdiff
path: root/drivers/usb/core
diff options
context:
space:
mode:
authorValentine Barshak <valentine.barshak@cogentembedded.com>2013-12-04 01:42:22 +0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2013-12-08 18:00:51 -0800
commit1ae5799ef63176cc75ec10e545cb65f620a82747 (patch)
tree93eb78ab6681ff47825fcb1e1dc98d86276cbdaa /drivers/usb/core
parent103e127d1f8f985e8a662da6537ebc5e08902ee3 (diff)
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>
Diffstat (limited to 'drivers/usb/core')
-rw-r--r--drivers/usb/core/hcd.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/drivers/usb/core/hcd.c b/drivers/usb/core/hcd.c
index 7527c8e4ec64..d3a9bcde53c3 100644
--- a/drivers/usb/core/hcd.c
+++ b/drivers/usb/core/hcd.c
@@ -2589,6 +2589,24 @@ int usb_add_hcd(struct usb_hcd *hcd,
int retval;
struct usb_device *rhdev;
+ if (IS_ENABLED(CONFIG_USB_PHY) && !hcd->phy) {
+ struct usb_phy *phy = usb_get_phy_dev(hcd->self.controller, 0);
+
+ if (IS_ERR(phy)) {
+ retval = PTR_ERR(phy);
+ if (retval == -EPROBE_DEFER)
+ return retval;
+ } else {
+ retval = usb_phy_init(phy);
+ if (retval) {
+ usb_put_phy(phy);
+ return retval;
+ }
+ hcd->phy = phy;
+ hcd->remove_phy = 1;
+ }
+ }
+
dev_info(hcd->self.controller, "%s\n", hcd->product_desc);
/* Keep old behaviour if authorized_default is not in [0, 1]. */