From b9b76d08b5e37a78073a00a32446353bbd7c496c Mon Sep 17 00:00:00 2001 From: William Wu Date: Mon, 1 Aug 2022 20:13:19 +0800 Subject: [PATCH] phy: rockchip: inno-usb2: add phy reset during resume On most of rockchip platforms, the usb2 phy lost power during deep sleep. So we need to reset phy during pm resume to recovery clock to usb controller. When do sleeptest on rk3588 evb1, without this patch, it may fail in ehci_resume or ohci_resume, because the ehci/ohci controller can't get clock from usb2 phy. Note that the phy reset is optional in devicetree, so it needs to check the reset_control of phy before phy reset operation to avoid unnecessary delay. Fixes: ba8a6e65a7bb ("phy: rockchip: inno_usb2: only reset phy if deassert iddq for rk3588") Signed-off-by: William Wu Change-Id: I31dee9baea472d9e314eca6cb9f78b2aab0e5353 --- drivers/phy/rockchip/phy-rockchip-inno-usb2.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/drivers/phy/rockchip/phy-rockchip-inno-usb2.c b/drivers/phy/rockchip/phy-rockchip-inno-usb2.c index 75fe946a70f2..0b39eca8f83f 100644 --- a/drivers/phy/rockchip/phy-rockchip-inno-usb2.c +++ b/drivers/phy/rockchip/phy-rockchip-inno-usb2.c @@ -403,6 +403,9 @@ static int rockchip_usb2phy_reset(struct rockchip_usb2phy *rphy) { int ret; + if (!rphy->phy_reset) + return 0; + ret = reset_control_assert(rphy->phy_reset); if (ret) return ret; @@ -2916,6 +2919,13 @@ static int rockchip_usb2phy_pm_resume(struct device *dev) if (device_may_wakeup(rphy->dev)) wakeup_enable = true; + /* + * PHY lost power in suspend, it needs to reset + * PHY to recovery clock to usb controller. + */ + if (!wakeup_enable) + rockchip_usb2phy_reset(rphy); + if (phy_cfg->phy_tuning) ret = phy_cfg->phy_tuning(rphy);