Skip to content

Commit

Permalink
usb: dwc3: Fix the USB 3.0 hub detection bug after warm boot
Browse files Browse the repository at this point in the history
The dwc3 could not release resources when the module is built-in
because this module does not have shutdown method. This causes the USB
3.0 hub is not able to detect after warm boot.

Change-Id: Ie6d2f3d242710fdd1c727e8b543496fedae5c471
Signed-off-by: Brian Kim <[email protected]>
  • Loading branch information
bkrepo committed Mar 28, 2017
1 parent 4e7699d commit 2166ffd
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 6 deletions.
33 changes: 33 additions & 0 deletions drivers/usb/dwc3/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -1145,6 +1145,38 @@ static int dwc3_probe(struct platform_device *pdev)
return ret;
}

static void dwc3_shutdown(struct platform_device *pdev)
{
struct dwc3 *dwc = platform_get_drvdata(pdev);
struct resource *res = platform_get_resource(pdev, IORESOURCE_MEM, 0);

pm_runtime_get_sync(&pdev->dev);
/*
* restore res->start back to its original value so that, in case the
* probe is deferred, we don't end up getting error in request the
* memory region the next time probe is called.
*/
res->start -= DWC3_GLOBALS_REGS_START;

dwc3_debugfs_exit(dwc);
dwc3_core_exit_mode(dwc);
dwc3_event_buffers_cleanup(dwc);
dwc3_free_event_buffers(dwc);

usb_phy_set_suspend(dwc->usb2_phy, 1);
usb_phy_set_suspend(dwc->usb3_phy, 1);

phy_power_off(dwc->usb2_generic_phy);
phy_power_off(dwc->usb3_generic_phy);

dwc3_core_exit(dwc);
dwc3_ulpi_exit(dwc);

pm_runtime_put_sync(&pdev->dev);
pm_runtime_allow(&pdev->dev);
pm_runtime_disable(&pdev->dev);
}

static int dwc3_remove(struct platform_device *pdev)
{
struct dwc3 *dwc = platform_get_drvdata(pdev);
Expand Down Expand Up @@ -1379,6 +1411,7 @@ MODULE_DEVICE_TABLE(acpi, dwc3_acpi_match);
static struct platform_driver dwc3_driver = {
.probe = dwc3_probe,
.remove = dwc3_remove,
.shutdown = dwc3_shutdown,
.driver = {
.name = "dwc3",
.of_match_table = of_match_ptr(of_dwc3_match),
Expand Down
6 changes: 0 additions & 6 deletions drivers/usb/host/xhci-plat.c
Original file line number Diff line number Diff line change
Expand Up @@ -304,15 +304,9 @@ static int xhci_plat_remove(struct platform_device *dev)
struct xhci_hcd *xhci = hcd_to_xhci(hcd);
struct clk *clk = xhci->clk;

phy_power_off(xhci->shared_hcd->phy);
phy_exit(xhci->shared_hcd->phy);

usb_remove_hcd(xhci->shared_hcd);
usb_phy_shutdown(hcd->usb_phy);

phy_power_off(hcd->phy);
phy_exit(hcd->phy);

usb_remove_hcd(hcd);
usb_put_hcd(xhci->shared_hcd);

Expand Down

0 comments on commit 2166ffd

Please sign in to comment.