diff options
| author | Frank Li <[email protected]> | 2021-02-18 22:51:08 +0000 |
|---|---|---|
| committer | Peter Chen <[email protected]> | 2021-04-12 12:19:20 +0000 |
| commit | 2cf2581cd2290ccef674f1be5f7977d66702eedb (patch) | |
| tree | fa20b3bab591e194ba2eb4e372b03cf3145d6568 /drivers/usb/cdns3/core.c | |
| parent | Merge 5.12-rc7 into usb-next (diff) | |
| download | kernel-2cf2581cd2290ccef674f1be5f7977d66702eedb.tar.gz kernel-2cf2581cd2290ccef674f1be5f7977d66702eedb.zip | |
usb: cdns3: add power lost support for system resume
If the controller lost its power during the system suspend, we need
to do all initialiation operations.
Signed-off-by: Peter Chen <[email protected]>
Signed-off-by: Frank Li <[email protected]>
Signed-off-by: Peter Chen <[email protected]>
Diffstat (limited to 'drivers/usb/cdns3/core.c')
| -rw-r--r-- | drivers/usb/cdns3/core.c | 29 |
1 files changed, 28 insertions, 1 deletions
diff --git a/drivers/usb/cdns3/core.c b/drivers/usb/cdns3/core.c index 199713769289..5d486c8a9d99 100644 --- a/drivers/usb/cdns3/core.c +++ b/drivers/usb/cdns3/core.c @@ -525,9 +525,36 @@ EXPORT_SYMBOL_GPL(cdns_suspend); int cdns_resume(struct cdns *cdns, u8 set_active) { struct device *dev = cdns->dev; + enum usb_role real_role; + bool role_changed = false; + int ret; + + if (cdns_power_is_lost(cdns)) { + if (cdns->role_sw) { + cdns->role = cdns_role_get(cdns->role_sw); + } else { + real_role = cdns_hw_role_state_machine(cdns); + if (real_role != cdns->role) { + ret = cdns_hw_role_switch(cdns); + if (ret) + return ret; + role_changed = true; + } + } + + if (!role_changed) { + if (cdns->role == USB_ROLE_HOST) + ret = cdns_drd_host_on(cdns); + else if (cdns->role == USB_ROLE_DEVICE) + ret = cdns_drd_gadget_on(cdns); + + if (ret) + return ret; + } + } if (cdns->roles[cdns->role]->resume) - cdns->roles[cdns->role]->resume(cdns, false); + cdns->roles[cdns->role]->resume(cdns, cdns_power_is_lost(cdns)); if (set_active) { pm_runtime_disable(dev); |
