usb: allow to supply the PHY in the drivers when using HCD

This patch modify the generic code handling PHYs to allow them to be
supplied from the drivers. This adds checks to ensure no PHY was already
there when looking for one in the generic code. This also makes sure we
do not modify its state in the generic HCD functions, it was provided by
the driver.

Signed-off-by: Antoine Tenart <antoine.tenart@free-electrons.com>
Acked-by: Alan Stern <stern@rowland.harvard.edu>
Signed-off-by: Felipe Balbi <balbi@ti.com>
This commit is contained in:
Antoine Tenart
2014-10-30 18:41:16 +01:00
committed by Felipe Balbi
parent 48bcc18076
commit ef44cb4226
10 changed files with 33 additions and 40 deletions

View File

@@ -312,7 +312,7 @@ static int ci_usb_phy_init(struct ci_hdrc *ci)
case USBPHY_INTERFACE_MODE_UTMI:
case USBPHY_INTERFACE_MODE_UTMIW:
case USBPHY_INTERFACE_MODE_HSIC:
ret = usb_phy_init(ci->transceiver);
ret = usb_phy_init(ci->usb_phy);
if (ret)
return ret;
hw_phymode_configure(ci);
@@ -320,12 +320,12 @@ static int ci_usb_phy_init(struct ci_hdrc *ci)
case USBPHY_INTERFACE_MODE_ULPI:
case USBPHY_INTERFACE_MODE_SERIAL:
hw_phymode_configure(ci);
ret = usb_phy_init(ci->transceiver);
ret = usb_phy_init(ci->usb_phy);
if (ret)
return ret;
break;
default:
ret = usb_phy_init(ci->transceiver);
ret = usb_phy_init(ci->usb_phy);
}
return ret;
@@ -605,13 +605,13 @@ static int ci_hdrc_probe(struct platform_device *pdev)
return -ENODEV;
}
if (ci->platdata->phy)
ci->transceiver = ci->platdata->phy;
if (ci->platdata->usb_phy)
ci->usb_phy = ci->platdata->usb_phy;
else
ci->transceiver = devm_usb_get_phy(dev, USB_PHY_TYPE_USB2);
ci->usb_phy = devm_usb_get_phy(dev, USB_PHY_TYPE_USB2);
if (IS_ERR(ci->transceiver)) {
ret = PTR_ERR(ci->transceiver);
if (IS_ERR(ci->usb_phy)) {
ret = PTR_ERR(ci->usb_phy);
/*
* if -ENXIO is returned, it means PHY layer wasn't
* enabled, so it makes no sense to return -EPROBE_DEFER
@@ -728,7 +728,7 @@ static int ci_hdrc_probe(struct platform_device *pdev)
stop:
ci_role_destroy(ci);
deinit_phy:
usb_phy_shutdown(ci->transceiver);
usb_phy_shutdown(ci->usb_phy);
return ret;
}
@@ -741,7 +741,7 @@ static int ci_hdrc_remove(struct platform_device *pdev)
free_irq(ci->irq, ci);
ci_role_destroy(ci);
ci_hdrc_enter_lpm(ci, true);
usb_phy_shutdown(ci->transceiver);
usb_phy_shutdown(ci->usb_phy);
return 0;
}