usb: dwc3: support continuous runtime PM with dual role
The DRD module calls dwc3_set_mode() on role switches, i.e. when a device is being plugged in. In order to support continuous runtime power management when plugging in / unplugging a cable, we need to call pm_runtime_get_sync() in this path. Reviewed-by: Peter Chen <peter.chen@nxp.com> Signed-off-by: Martin Kepplinger <martin.kepplinger@puri.sm> Signed-off-by: Li Jun <jun.li@nxp.com>5.4-rM2-2.2.x-imx-squashed
parent
efe0c93c82
commit
cc2876fabf
|
@ -120,17 +120,19 @@ static void __dwc3_set_mode(struct work_struct *work)
|
|||
if (dwc->dr_mode != USB_DR_MODE_OTG)
|
||||
return;
|
||||
|
||||
pm_runtime_get_sync(dwc->dev);
|
||||
|
||||
if (dwc->current_dr_role == DWC3_GCTL_PRTCAP_OTG)
|
||||
dwc3_otg_update(dwc, 0);
|
||||
|
||||
if (!dwc->desired_dr_role)
|
||||
return;
|
||||
goto out;
|
||||
|
||||
if (dwc->desired_dr_role == dwc->current_dr_role)
|
||||
return;
|
||||
goto out;
|
||||
|
||||
if (dwc->desired_dr_role == DWC3_GCTL_PRTCAP_OTG && dwc->edev)
|
||||
return;
|
||||
goto out;
|
||||
|
||||
switch (dwc->current_dr_role) {
|
||||
case DWC3_GCTL_PRTCAP_HOST:
|
||||
|
@ -191,6 +193,10 @@ static void __dwc3_set_mode(struct work_struct *work)
|
|||
|
||||
if (dwc->priv_data && dwc->priv_data->set_role_post)
|
||||
dwc->priv_data->set_role_post(dwc, dwc->desired_dr_role);
|
||||
|
||||
out:
|
||||
pm_runtime_mark_last_busy(dwc->dev);
|
||||
pm_runtime_put_autosuspend(dwc->dev);
|
||||
}
|
||||
|
||||
void dwc3_set_mode(struct dwc3 *dwc, u32 mode)
|
||||
|
|
Loading…
Reference in New Issue