Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1632693
| From | Sevak Arakelyan <SEVAK.ARAKELYAN@synopsys.com> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | [PATCH 3/9] usb: dwc2: gadget: Add functionality to exit from LPM L1 state |
| Date | 2017-04-28 11:00 +0200 |
| Message-ID | <tB9US-53z-19@gated-at.bofh.it> (permalink) |
| References | <tB9Lb-4Zj-1@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
Add a function which will be called if device is in L1 sleep state
and Resume/Remote Wakeup Detected interrupt is asserted.
Signed-off-by: Sevak Arakelyan <sevaka@synopsys.com>
---
drivers/usb/dwc2/core_intr.c | 49 ++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 49 insertions(+)
diff --git a/drivers/usb/dwc2/core_intr.c b/drivers/usb/dwc2/core_intr.c
index b8bcb007c92a..c7dd764fbfa9 100644
--- a/drivers/usb/dwc2/core_intr.c
+++ b/drivers/usb/dwc2/core_intr.c
@@ -334,6 +334,50 @@ static void dwc2_handle_session_req_intr(struct dwc2_hsotg *hsotg)
}
}
+/**
+ * dwc2_wakeup_from_lpm_l1 - Exit the device from LPM L1 state
+ */
+static void dwc2_wakeup_from_lpm_l1(struct dwc2_hsotg *hsotg)
+{
+ u32 glpmcfg;
+ u32 i = 0;
+
+ if (hsotg->lx_state != DWC2_L1) {
+ dev_err(hsotg->dev, "Core isn't in DWC2_L1 state\n");
+ return;
+ }
+
+ glpmcfg = dwc2_readl(hsotg->regs + GLPMCFG);
+ if (dwc2_is_device_mode(hsotg)) {
+ dev_dbg(hsotg->dev, "Exit from L1 state\n");
+ glpmcfg &= ~GLPMCFG_ENBLSLPM;
+ glpmcfg &= ~GLPMCFG_HIRD_THRES_EN;
+ dwc2_writel(glpmcfg, hsotg->regs + GLPMCFG);
+
+ do {
+ glpmcfg = dwc2_readl(hsotg->regs + GLPMCFG);
+
+ if (!(glpmcfg & (GLPMCFG_COREL1RES_MASK |
+ GLPMCFG_L1RESUMEOK | GLPMCFG_SLPSTS)))
+ break;
+
+ udelay(1);
+ } while (++i < 200);
+
+ if (i == 200) {
+ dev_err(hsotg->dev, "Failed to exit L1 sleep state in 200us.\n");
+ return;
+ }
+ } else {
+ /* TODO */
+ dev_err(hsotg->dev, "Host side LPM is not supported.\n");
+ return;
+ }
+
+ /* Change to L0 state */
+ hsotg->lx_state = DWC2_L0;
+}
+
/*
* This interrupt indicates that the DWC_otg controller has detected a
* resume or remote wakeup sequence. If the DWC_otg controller is in
@@ -351,6 +395,11 @@ static void dwc2_handle_wakeup_detected_intr(struct dwc2_hsotg *hsotg)
dev_dbg(hsotg->dev, "++Resume or Remote Wakeup Detected Interrupt++\n");
dev_dbg(hsotg->dev, "%s lxstate = %d\n", __func__, hsotg->lx_state);
+ if (hsotg->lx_state == DWC2_L1) {
+ dwc2_wakeup_from_lpm_l1(hsotg);
+ return;
+ }
+
if (dwc2_is_device_mode(hsotg)) {
dev_dbg(hsotg->dev, "DSTS=0x%0x\n",
dwc2_readl(hsotg->regs + DSTS));
--
2.11.0
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
[PATCH 0/9] usb: dwc2: gadget: Add LPM functionality Sevak Arakelyan <SEVAK.ARAKELYAN@synopsys.com> - 2017-04-28 10:50 +0200
[PATCH 1/9] usb: dwc2: Fix GLPMCFG... definitions Sevak Arakelyan <SEVAK.ARAKELYAN@synopsys.com> - 2017-04-28 10:50 +0200
[PATCH 2/9] usb: dwc2: Add core parameters for LPM support Sevak Arakelyan <SEVAK.ARAKELYAN@synopsys.com> - 2017-04-28 10:50 +0200
[PATCH 9/9] [HSLPM] usb: dwc2: Enable LPM Sevak Arakelyan <SEVAK.ARAKELYAN@synopsys.com> - 2017-04-28 11:00 +0200
Re: [PATCH 9/9] [HSLPM] usb: dwc2: Enable LPM Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-04-28 11:30 +0200
[PATCH 5/9] usb: dwc2: Enable LPM Transaction Received interrupt. Sevak Arakelyan <SEVAK.ARAKELYAN@synopsys.com> - 2017-04-28 11:00 +0200
[PATCH 3/9] usb: dwc2: gadget: Add functionality to exit from LPM L1 state Sevak Arakelyan <SEVAK.ARAKELYAN@synopsys.com> - 2017-04-28 11:00 +0200
[PATCH 6/9] usb: dwc2: gadget: Configure the core to enable LPM. Sevak Arakelyan <SEVAK.ARAKELYAN@synopsys.com> - 2017-04-28 11:00 +0200
[PATCH 8/9] [HSLPM] usb: gadget: Allow a non-SuperSpeed gadget to support LPM Sevak Arakelyan <SEVAK.ARAKELYAN@synopsys.com> - 2017-04-28 11:00 +0200
[PATCH 4/9] usb: dwc2: gadget: LPM interrupt handler Sevak Arakelyan <SEVAK.ARAKELYAN@synopsys.com> - 2017-04-28 11:00 +0200
[PATCH 7/9] [HSLPM] usb: gadget: composite: Exclude SS Dev Cap Desc Sevak Arakelyan <SEVAK.ARAKELYAN@synopsys.com> - 2017-04-28 11:00 +0200
csiph-web