phy: usb: Fix clock imbalance for suspend/resume
authorJustin Chen <justinpopo6@gmail.com>
Wed, 5 Oct 2022 21:30:18 +0000 (14:30 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 31 Dec 2022 12:32:48 +0000 (13:32 +0100)
[ Upstream commit 8484199c09347bdd5d81ee8a2bc530850f900797 ]

We should be disabling clocks when wake from USB is not needed. Since
this wasn't done, we had a clock imbalance since clocks were always
being enabled on resume.

Fixes: ae532b2b7aa5 ("phy: usb: Add "wake on" functionality for newer Synopsis XHCI controllers")
Fixes: b0c0b66c0b43 ("phy: usb: Add support for wake and USB low power mode for 7211 S2/S5")
Signed-off-by: Justin Chen <justinpopo6@gmail.com>
Acked-by: Florian Fainelli <f.fainelli@gmail.com>
Link: https://lore.kernel.org/r/1665005418-15807-7-git-send-email-justinpopo6@gmail.com
Signed-off-by: Vinod Koul <vkoul@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/phy/broadcom/phy-brcm-usb-init-synopsys.c
drivers/phy/broadcom/phy-brcm-usb-init.h
drivers/phy/broadcom/phy-brcm-usb.c

index b3386e4..3b374b3 100644 (file)
@@ -424,7 +424,6 @@ void brcm_usb_dvr_init_7216(struct brcm_usb_init_params *params)
 
        params->family_name = "7216";
        params->ops = &bcm7216_ops;
-       params->suspend_with_clocks = true;
 }
 
 void brcm_usb_dvr_init_7211b0(struct brcm_usb_init_params *params)
@@ -434,5 +433,4 @@ void brcm_usb_dvr_init_7211b0(struct brcm_usb_init_params *params)
 
        params->family_name = "7211";
        params->ops = &bcm7211b0_ops;
-       params->suspend_with_clocks = true;
 }
index 1ccb5dd..3236e94 100644 (file)
@@ -61,7 +61,6 @@ struct  brcm_usb_init_params {
        const struct brcm_usb_init_ops *ops;
        struct regmap *syscon_piarbctl;
        bool wake_enabled;
-       bool suspend_with_clocks;
 };
 
 void brcm_usb_dvr_init_4908(struct brcm_usb_init_params *params);
index c0c3ab9..2bfd78e 100644 (file)
@@ -598,7 +598,7 @@ static int brcm_usb_phy_suspend(struct device *dev)
                 * and newer XHCI->2.0-clks/3.0-clks.
                 */
 
-               if (!priv->ini.suspend_with_clocks) {
+               if (!priv->ini.wake_enabled) {
                        if (priv->phys[BRCM_USB_PHY_3_0].inited)
                                clk_disable_unprepare(priv->usb_30_clk);
                        if (priv->phys[BRCM_USB_PHY_2_0].inited ||
@@ -615,8 +615,10 @@ static int brcm_usb_phy_resume(struct device *dev)
 {
        struct brcm_usb_phy_data *priv = dev_get_drvdata(dev);
 
-       clk_prepare_enable(priv->usb_20_clk);
-       clk_prepare_enable(priv->usb_30_clk);
+       if (!priv->ini.wake_enabled) {
+               clk_prepare_enable(priv->usb_20_clk);
+               clk_prepare_enable(priv->usb_30_clk);
+       }
        brcm_usb_init_ipp(&priv->ini);
 
        /*