usb: dwc2: add pm runtime support

Adds pm_runtime support for dwc2, so that power domain is
enabled only when there is a transaction going on to help
save power.

Change-Id: I318552774d20eeaed521ff179f99b2551ee24183
Signed-off-by: William Wu <william.wu@rock-chips.com>
Signed-off-by: Frank Wang <frank.wang@rock-chips.com>
This commit is contained in:
William Wu
2018-07-23 09:27:55 +08:00
committed by Frank Wang
parent f7ced1f320
commit b3effcc1a8

View File

@@ -333,6 +333,9 @@ static int dwc2_driver_remove(struct platform_device *dev)
if (hsotg->params.activate_stm_id_vb_detection)
regulator_disable(hsotg->usb33d);
pm_runtime_put_sync(hsotg->dev);
pm_runtime_disable(hsotg->dev);
if (hsotg->ll_hw_enabled)
dwc2_lowlevel_hw_disable(hsotg);
@@ -484,6 +487,11 @@ static int dwc2_driver_probe(struct platform_device *dev)
hsotg->needs_byte_swap = dwc2_check_core_endianness(hsotg);
pm_runtime_enable(hsotg->dev);
retval = pm_runtime_get_sync(hsotg->dev);
if (retval < 0)
goto error;
retval = dwc2_get_dr_mode(hsotg);
if (retval)
goto error;
@@ -640,6 +648,8 @@ error_init:
if (hsotg->params.activate_stm_id_vb_detection)
regulator_disable(hsotg->usb33d);
error:
pm_runtime_put_sync(hsotg->dev);
pm_runtime_disable(hsotg->dev);
if (hsotg->dr_mode != USB_DR_MODE_PERIPHERAL)
dwc2_lowlevel_hw_disable(hsotg);
return retval;