Takashi Iwai 655a27
From d1d90dd27254c44d087ad3f8b5b3e4fff0571f45 Mon Sep 17 00:00:00 2001
Takashi Iwai 655a27
From: Jack Pham <jackp@codeaurora.org>
Takashi Iwai 655a27
Date: Wed, 28 Apr 2021 02:01:10 -0700
Takashi Iwai 655a27
Subject: [PATCH] usb: dwc3: gadget: Enable suspend events
Takashi Iwai 655a27
Git-commit: d1d90dd27254c44d087ad3f8b5b3e4fff0571f45
Takashi Iwai 655a27
Patch-mainline: v5.13-rc2
Takashi Iwai 655a27
References: git-fixes
Takashi Iwai 655a27
Takashi Iwai 655a27
[ backport note: open-coded the missing DWC3_VER_IS_PRIOR() macro -- tiwai ]
Takashi Iwai 655a27
Takashi Iwai 655a27
commit 72704f876f50 ("dwc3: gadget: Implement the suspend entry event
Takashi Iwai 655a27
handler") introduced (nearly 5 years ago!) an interrupt handler for
Takashi Iwai 655a27
U3/L1-L2 suspend events.  The problem is that these events aren't
Takashi Iwai 655a27
currently enabled in the DEVTEN register so the handler is never
Takashi Iwai 655a27
even invoked.  Fix this simply by enabling the corresponding bit
Takashi Iwai 655a27
in dwc3_gadget_enable_irq() using the same revision check as found
Takashi Iwai 655a27
in the handler.
Takashi Iwai 655a27
Takashi Iwai 655a27
Fixes: 72704f876f50 ("dwc3: gadget: Implement the suspend entry event handler")
Takashi Iwai 655a27
Acked-by: Felipe Balbi <balbi@kernel.org>
Takashi Iwai 655a27
Signed-off-by: Jack Pham <jackp@codeaurora.org>
Takashi Iwai 655a27
Cc: stable <stable@vger.kernel.org>
Takashi Iwai 655a27
Link: https://lore.kernel.org/r/20210428090111.3370-1-jackp@codeaurora.org
Takashi Iwai 655a27
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Takashi Iwai 655a27
Acked-by: Takashi Iwai <tiwai@suse.de>
Takashi Iwai 655a27
Takashi Iwai 655a27
---
Takashi Iwai 655a27
 drivers/usb/dwc3/gadget.c |    4 ++++
Takashi Iwai 655a27
 1 file changed, 4 insertions(+)
Takashi Iwai 655a27
Takashi Iwai 655a27
--- a/drivers/usb/dwc3/gadget.c
Takashi Iwai 655a27
+++ b/drivers/usb/dwc3/gadget.c
Takashi Iwai 655a27
@@ -1959,6 +1959,10 @@ static void dwc3_gadget_enable_irq(struc
Takashi Iwai 655a27
 	if (dwc->revision < DWC3_REVISION_250A)
Takashi Iwai 655a27
 		reg |= DWC3_DEVTEN_ULSTCNGEN;
Takashi Iwai 655a27
 
Takashi Iwai 655a27
+	/* On 2.30a and above this bit enables U3/L2-L1 Suspend Events */
Takashi Iwai 655a27
+	if (dwc->revision >= DWC3_REVISION_230A)
Takashi Iwai 655a27
+		reg |= DWC3_DEVTEN_EOPFEN;
Takashi Iwai 655a27
+
Takashi Iwai 655a27
 	dwc3_writel(dwc->regs, DWC3_DEVTEN, reg);
Takashi Iwai 655a27
 }
Takashi Iwai 655a27