* [PATCH 0/2] usb: host: xhci-plat: Introduce XHCI_SUSPEND_RESUME_CLKS quirk
@ 2022-08-10 22:27 justinpopo6
2022-08-10 22:27 ` [PATCH 1/2] usb: host: xhci-plat: suspend and resume clocks justinpopo6
2022-08-10 22:27 ` [PATCH 2/2] usb: host: xhci-plat: suspend/resume clks for brcm justinpopo6
0 siblings, 2 replies; 5+ messages in thread
From: justinpopo6 @ 2022-08-10 22:27 UTC (permalink / raw)
To: mathias.nyman, gregkh, linux-usb, linux-kernel; +Cc: f.fainelli, Justin Chen
From: Justin Chen <justinpopo6@gmail.com>
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(-)
--
2.7.4
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH 1/2] usb: host: xhci-plat: suspend and resume clocks
2022-08-10 22:27 [PATCH 0/2] usb: host: xhci-plat: Introduce XHCI_SUSPEND_RESUME_CLKS quirk justinpopo6
@ 2022-08-10 22:27 ` justinpopo6
2022-08-10 22:39 ` Florian Fainelli
2022-08-10 22:27 ` [PATCH 2/2] usb: host: xhci-plat: suspend/resume clks for brcm justinpopo6
1 sibling, 1 reply; 5+ messages in thread
From: justinpopo6 @ 2022-08-10 22:27 UTC (permalink / raw)
To: mathias.nyman, gregkh, linux-usb, linux-kernel; +Cc: f.fainelli, Justin Chen
From: Justin Chen <justinpopo6@gmail.com>
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.
Signed-off-by: Justin Chen <justinpopo6@gmail.com>
---
drivers/usb/host/xhci-plat.c | 16 +++++++++++++++-
drivers/usb/host/xhci.h | 1 +
2 files changed, 16 insertions(+), 1 deletion(-)
diff --git a/drivers/usb/host/xhci-plat.c b/drivers/usb/host/xhci-plat.c
index 0448558..a68b2b0 100644
--- a/drivers/usb/host/xhci-plat.c
+++ b/drivers/usb/host/xhci-plat.c
@@ -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;
diff --git a/drivers/usb/host/xhci.h b/drivers/usb/host/xhci.h
index 1960b47..182d1d4 100644
--- a/drivers/usb/host/xhci.h
+++ b/drivers/usb/host/xhci.h
@@ -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;
--
2.7.4
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 2/2] usb: host: xhci-plat: suspend/resume clks for brcm
2022-08-10 22:27 [PATCH 0/2] usb: host: xhci-plat: Introduce XHCI_SUSPEND_RESUME_CLKS quirk justinpopo6
2022-08-10 22:27 ` [PATCH 1/2] usb: host: xhci-plat: suspend and resume clocks justinpopo6
@ 2022-08-10 22:27 ` justinpopo6
2022-08-10 22:39 ` Florian Fainelli
1 sibling, 1 reply; 5+ messages in thread
From: justinpopo6 @ 2022-08-10 22:27 UTC (permalink / raw)
To: mathias.nyman, gregkh, linux-usb, linux-kernel; +Cc: f.fainelli, Justin Chen
From: Justin Chen <justinpopo6@gmail.com>
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.
Signed-off-by: Justin Chen <justinpopo6@gmail.com>
---
drivers/usb/host/xhci-plat.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/usb/host/xhci-plat.c b/drivers/usb/host/xhci-plat.c
index a68b2b0..62756d9 100644
--- a/drivers/usb/host/xhci-plat.c
+++ b/drivers/usb/host/xhci-plat.c
@@ -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[] = {
--
2.7.4
^ permalink raw reply related [flat|nested] 5+ messages in thread
end of thread, other threads:[~2022-08-10 22:39 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-08-10 22:27 [PATCH 0/2] usb: host: xhci-plat: Introduce XHCI_SUSPEND_RESUME_CLKS quirk justinpopo6
2022-08-10 22:27 ` [PATCH 1/2] usb: host: xhci-plat: suspend and resume clocks justinpopo6
2022-08-10 22:39 ` Florian Fainelli
2022-08-10 22:27 ` [PATCH 2/2] usb: host: xhci-plat: suspend/resume clks for brcm justinpopo6
2022-08-10 22:39 ` Florian Fainelli
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).