Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

phy: usb: Fix clock imbalance for suspend/resume

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>

authored by

Justin Chen and committed by
Vinod Koul
8484199c 700c44b5

+5 -6
-2
drivers/phy/broadcom/phy-brcm-usb-init-synopsys.c
··· 430 430 431 431 params->family_name = "7216"; 432 432 params->ops = &bcm7216_ops; 433 - params->suspend_with_clocks = true; 434 433 } 435 434 436 435 void brcm_usb_dvr_init_7211b0(struct brcm_usb_init_params *params) ··· 439 440 440 441 params->family_name = "7211"; 441 442 params->ops = &bcm7211b0_ops; 442 - params->suspend_with_clocks = true; 443 443 }
-1
drivers/phy/broadcom/phy-brcm-usb-init.h
··· 62 62 const struct brcm_usb_init_ops *ops; 63 63 struct regmap *syscon_piarbctl; 64 64 bool wake_enabled; 65 - bool suspend_with_clocks; 66 65 }; 67 66 68 67 void brcm_usb_dvr_init_4908(struct brcm_usb_init_params *params);
+5 -3
drivers/phy/broadcom/phy-brcm-usb.c
··· 602 602 * and newer XHCI->2.0-clks/3.0-clks. 603 603 */ 604 604 605 - if (!priv->ini.suspend_with_clocks) { 605 + if (!priv->ini.wake_enabled) { 606 606 if (priv->phys[BRCM_USB_PHY_3_0].inited) 607 607 clk_disable_unprepare(priv->usb_30_clk); 608 608 if (priv->phys[BRCM_USB_PHY_2_0].inited || ··· 619 619 { 620 620 struct brcm_usb_phy_data *priv = dev_get_drvdata(dev); 621 621 622 - clk_prepare_enable(priv->usb_20_clk); 623 - clk_prepare_enable(priv->usb_30_clk); 622 + if (!priv->ini.wake_enabled) { 623 + clk_prepare_enable(priv->usb_20_clk); 624 + clk_prepare_enable(priv->usb_30_clk); 625 + } 624 626 brcm_usb_init_ipp(&priv->ini); 625 627 626 628 /*