usb: dwc3: rockchip: add pm runtime control for dwc3 parent
authorWu Liang feng <wulf@rock-chips.com>
Fri, 14 Oct 2016 09:41:26 +0000 (17:41 +0800)
committerWu Liang feng <wulf@rock-chips.com>
Fri, 14 Oct 2016 09:41:26 +0000 (17:41 +0800)
In usb3 tcphy init, it will access usb3 module to set
usb3 working on USB3.0 mode or USB2.0 only mode, and
usb3 pd must be enabled before do this operation. So
we add pm runtime control for dwc3 parent in extcon
evt work. If plug in usb device, resume dwc3 parent
first to enable usb3 pd and then do phy init.

Change-Id: I90dd762d7f76e5f1722c95611e440eacd3afcdc9
Signed-off-by: Wu Liang feng <wulf@rock-chips.com>
drivers/usb/dwc3/dwc3-rockchip.c

index d4a4335d22742c00bb8e498f4a682704f39e95e5..036f8742cad8ffa779a4fb3526a4deda59950b96 100644 (file)
@@ -116,6 +116,7 @@ static void dwc3_rockchip_otg_extcon_evt_work(struct work_struct *work)
                usleep_range(1000, 1200);
                reset_control_deassert(rockchip->otg_rst);
 
+               pm_runtime_get_sync(rockchip->dev);
                pm_runtime_get_sync(dwc->dev);
 
                spin_lock_irqsave(&dwc->lock, flags);
@@ -152,6 +153,13 @@ static void dwc3_rockchip_otg_extcon_evt_work(struct work_struct *work)
                usleep_range(1000, 1200);
                reset_control_deassert(rockchip->otg_rst);
 
+               /*
+                * In usb3 phy init, it will access usb3 module, so we need
+                * to resume rockchip dev before phy init to make sure usb3
+                * pd is enabled.
+                */
+               pm_runtime_get_sync(rockchip->dev);
+
                /*
                 * Don't abort on errors. If powering on a phy fails,
                 * we still need to init dwc controller and add the
@@ -221,6 +229,7 @@ static void dwc3_rockchip_otg_extcon_evt_work(struct work_struct *work)
                        phy_power_off(dwc->usb3_generic_phy);
                }
 
+               pm_runtime_put_sync(rockchip->dev);
                pm_runtime_put_sync_suspend(dwc->dev);
 
                rockchip->connected = false;