usb: host: xhci-plat: Introduce XHCI_SUSPEND_RESUME_CLKS quirk
Subsystems (2)
cover usb: host: xhci-plat: Introduce XHCI_SUSPEND_RESUME_CLKS quirk
From: Justin Chen <[email protected]>
Introduce XHCI_SUSPEND_RESUME_CLKS quirk for turning off clocks during suspend and turning on clocks on resume. Certain hardware, in our case xhci_plat_brcm, can have power savings by turning off clocks before hitting suspend states.
Justin Chen (2):
usb: host: xhci-plat: suspend and resume clocks
usb: host: xhci-plat: suspend/resume clks for brcm
drivers/usb/host/xhci-plat.c | 18 ++++++++++++++++-- drivers/usb/host/xhci.h | 1 + 2 files changed, 17 insertions(+), 2 deletions(-)
Signature · 1 line
2.7.4
PATCH 1/2 usb: host: xhci-plat: suspend and resume clocks
From: Justin Chen <[email protected]>
Introduce XHCI_SUSPEND_RESUME_CLKS quirk as a means to suspend and resume clocks if the hardware is capable of doing so. We assume that clocks will be needed if the device may wake.
--- drivers/usb/host/xhci-plat.c | 16 +++++++++++++++- drivers/usb/host/xhci.h | 1 + 2 files changed, 16 insertions(+), 1 deletion(-)
drivers/usb/host/xhci-plat.c +15 -1
@@ -432,7 +432,16 @@ static int __maybe_unused xhci_plat_suspend(struct device *dev)* xhci_suspend() needs `do_wakeup` to know whether host is allowed * to do wakeup during suspend. */ -return xhci_suspend (xhci,device_may_wakeup (dev)); + ret =xhci_suspend (xhci,device_may_wakeup (dev)); +if (ret) +return ret; + +if (!device_may_wakeup (dev) && (xhci->quirks &XHCI_SUSPEND_RESUME_CLKS )) { +clk_disable_unprepare (xhci->clk); +clk_disable_unprepare (xhci->reg_clk); + } + +return 0 ; }static int __maybe_unused xhci_plat_resume (struct device *dev)
@@ -441,6 +450,11 @@ static int __maybe_unused xhci_plat_resume(struct device *dev)struct xhci_hcd *xhci =hcd_to_xhci (hcd);int ret; +if (!device_may_wakeup (dev) && (xhci->quirks &XHCI_SUSPEND_RESUME_CLKS )) { +clk_prepare_enable (xhci->clk); +clk_prepare_enable (xhci->reg_clk); + } + ret =xhci_priv_resume_quirk (hcd);if (ret)return ret;
drivers/usb/host/xhci.h +1 -0
@@ -1899,6 +1899,7 @@ struct xhci_hcd {#define XHCI_NO_SOFT_RETRY BIT_ULL(40)#define XHCI_BROKEN_D3COLD BIT_ULL(41)#define XHCI_EP_CTX_BROKEN_DCS BIT_ULL(42) +#define XHCI_SUSPEND_RESUME_CLKS BIT_ULL(43)unsigned int num_active_eps;unsigned int limit_active_eps;
Signature · 1 line
2.7.4
Re: [PATCH 1/2] usb: host: xhci-plat: suspend and resume clocks
Quoted 7 lines · On 8/10/22 15:27, [email protected] wrote:
From: Justin Chen <[email protected]>
Introduce
XHCI_SUSPEND_RESUME_CLKSquirk as a means to suspend and resume clocks if the hardware is capable of doing so. We assume that clocks will be needed if the device may wake.Signed-off-by Justin Chen <[email protected]>
Signature · 1 line
Florian
PATCH 2/2 usb: host: xhci-plat: suspend/resume clks for brcm
In reply to [email protected]From: Justin Chen <[email protected]>
The xhci_plat_brcm xhci block can enter suspend with clock disabled to save power and re-enable them on resume. Make use of the XHCI_SUSPEND_RESUME_CLKS quirk to do so.
--- drivers/usb/host/xhci-plat.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/usb/host/xhci-plat.c +1 -1
@@ -123,7 +123,7 @@ static const struct xhci_plat_priv xhci_plat_renesas_rcar_gen3 = { };static const struct xhci_plat_priv xhci_plat_brcm = { - .quirks =XHCI_RESET_ON_RESUME , + .quirks =XHCI_RESET_ON_RESUME |XHCI_SUSPEND_RESUME_CLKS , };static const struct of_device_id usb_xhci_of_match[] = {
Signature · 1 line
2.7.4
Re: [PATCH 2/2] usb: host: xhci-plat: suspend/resume clks for brcm
Quoted 7 lines · On 8/10/22 15:27, [email protected] wrote:
From: Justin Chen <[email protected]>
The
xhci_plat_brcmxhci block can enter suspend with clock disabled to save power and re-enable them on resume. Make use of theXHCI_SUSPEND_RESUME_CLKSquirk to do so.Signed-off-by Justin Chen <[email protected]>
Signature · 1 line
Florian