[PATCH 1/1] usb: dwc3: avoid setting ClearPendIn for Intel Cherry Trail devices

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Commit 50c763f8c1bac ("usb: dwc3: Set the ClearPendIN bit on Clear
Stall EP command") causes Clear Stall EP command failure on Intel
Cherry Trail devices. This patch add a quirk to avoid setting this
bit for those Intel devices.

Cc: stable@xxxxxxxxxxxxxxx # 4.7+
Signed-off-by: Lu Baolu <baolu.lu@xxxxxxxxxxxxxxx>
---
 drivers/usb/dwc3/core.c     |  3 +++
 drivers/usb/dwc3/core.h     |  3 +++
 drivers/usb/dwc3/dwc3-pci.c | 11 +++++++++++
 drivers/usb/dwc3/gadget.c   |  3 ++-
 4 files changed, 19 insertions(+), 1 deletion(-)

diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c
index 35d0924..b858c43 100644
--- a/drivers/usb/dwc3/core.c
+++ b/drivers/usb/dwc3/core.c
@@ -934,6 +934,9 @@ static int dwc3_probe(struct platform_device *pdev)
 	device_property_read_u32(dev, "snps,quirk-frame-length-adjustment",
 				 &dwc->fladj);
 
+	dwc->avoid_clearpendin_quirk = device_property_read_bool(dev,
+				"snps,avoid_clearpendin_quirk");
+
 	dwc->lpm_nyet_threshold = lpm_nyet_threshold;
 	dwc->tx_de_emphasis = tx_de_emphasis;
 
diff --git a/drivers/usb/dwc3/core.h b/drivers/usb/dwc3/core.h
index 45d6de5..eddfa75 100644
--- a/drivers/usb/dwc3/core.h
+++ b/drivers/usb/dwc3/core.h
@@ -805,6 +805,8 @@ struct dwc3_scratchpad_array {
  * 	1	- -3.5dB de-emphasis
  * 	2	- No de-emphasis
  * 	3	- Reserved
+ * @avoid_clearpendin_quirk: set if we avoid setting ClearPendIn bit
+ *                           on Clear Stall EP command
  */
 struct dwc3 {
 	struct usb_ctrlrequest	*ctrl_req;
@@ -945,6 +947,7 @@ struct dwc3 {
 
 	unsigned		tx_de_emphasis_quirk:1;
 	unsigned		tx_de_emphasis:2;
+	unsigned		avoid_clearpendin_quirk:1;
 };
 
 /* -------------------------------------------------------------------------- */
diff --git a/drivers/usb/dwc3/dwc3-pci.c b/drivers/usb/dwc3/dwc3-pci.c
index 0a32430..e89893e 100644
--- a/drivers/usb/dwc3/dwc3-pci.c
+++ b/drivers/usb/dwc3/dwc3-pci.c
@@ -117,6 +117,17 @@ static int dwc3_pci_quirks(struct pci_dev *pdev, struct platform_device *dwc3)
 				usleep_range(10000, 11000);
 			}
 		}
+
+		if (pdev->device == PCI_DEVICE_ID_INTEL_BSW) {
+			struct property_entry bsw_properties[] = {
+				PROPERTY_ENTRY_BOOL(
+					"snps,avoid_clearpendin_quirk"),
+				{ }
+			};
+
+			return platform_device_add_properties(dwc3,
+							      bsw_properties);
+		}
 	}
 
 	if (pdev->vendor == PCI_VENDOR_ID_SYNOPSYS &&
diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c
index 7a8d3d8..5a6897e 100644
--- a/drivers/usb/dwc3/gadget.c
+++ b/drivers/usb/dwc3/gadget.c
@@ -348,7 +348,8 @@ static int dwc3_send_clear_stall_ep_cmd(struct dwc3_ep *dep)
 	 * IN transfers due to a mishandled error condition. Synopsys
 	 * STAR 9000614252.
 	 */
-	if (dep->direction && (dwc->revision >= DWC3_REVISION_260A))
+	if (dep->direction && (dwc->revision >= DWC3_REVISION_260A) &&
+	    !dwc->avoid_clearpendin_quirk)
 		cmd |= DWC3_DEPCMD_CLEARPENDIN;
 
 	memset(&params, 0, sizeof(params));
-- 
2.1.4

--
To unsubscribe from this list: send the line "unsubscribe stable" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Linux Kernel]     [Kernel Development Newbies]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite Hiking]     [Linux Kernel]     [Linux SCSI]