[RFC PATCH 6/6] usb: xhci-mtk: Add support drop extra CS

Chunfeng Yun chunfeng.yun at mediatek.com
Mon Aug 23 05:53:56 PDT 2021


Support option to drop extra CS for FS isoc/intr whith TT.

Signed-off-by: Chunfeng Yun <chunfeng.yun at mediatek.com>
---
 drivers/usb/host/xhci-mtk-sch.c | 17 ++++++++++-------
 drivers/usb/host/xhci-mtk.c     |  1 +
 drivers/usb/host/xhci-mtk.h     |  2 ++
 3 files changed, 13 insertions(+), 7 deletions(-)

diff --git a/drivers/usb/host/xhci-mtk-sch.c b/drivers/usb/host/xhci-mtk-sch.c
index 134f4789bd89..e5e9d930981f 100644
--- a/drivers/usb/host/xhci-mtk-sch.c
+++ b/drivers/usb/host/xhci-mtk-sch.c
@@ -280,6 +280,7 @@ create_sch_ep(struct xhci_hcd_mtk *mtk, struct usb_device *udev,
 	sch_ep->sch_tt = tt;
 	sch_ep->ep = ep;
 	sch_ep->speed = udev->speed;
+	sch_ep->no_extra_cs = mtk->no_extra_cs;
 	INIT_LIST_HEAD(&sch_ep->endpoint);
 	INIT_LIST_HEAD(&sch_ep->tt_endpoint);
 	INIT_HLIST_NODE(&sch_ep->hentry);
@@ -512,14 +513,16 @@ static int check_sch_tt(struct mu3h_sch_ep_info *sch_ep, u32 offset)
 		if (last_cs > 7)
 			return -ESCH_CS_OVERFLOW;
 
-		if (sch_ep->ep_type == ISOC_IN_EP)
-			extra_cs_count = (last_cs == 7) ? 1 : 2;
-		else /*  ep_type : INTR IN / INTR OUT */
-			extra_cs_count = 1;
+		if (!sch_ep->no_extra_cs) {
+			if (sch_ep->ep_type == ISOC_IN_EP)
+				extra_cs_count = (last_cs == 7) ? 1 : 2;
+			else /*  ep_type : INTR IN / INTR OUT */
+				extra_cs_count = 1;
 
-		cs_count += extra_cs_count;
-		if (cs_count > 7)
-			cs_count = 7; /* HW limit */
+			cs_count += extra_cs_count;
+			if (cs_count > 7)
+				cs_count = 7; /* HW limit */
+		}
 
 		sch_ep->cs_count = cs_count;
 		/* one for ss, the other for idle */
diff --git a/drivers/usb/host/xhci-mtk.c b/drivers/usb/host/xhci-mtk.c
index d66b6a8b59ba..da559d1db813 100644
--- a/drivers/usb/host/xhci-mtk.c
+++ b/drivers/usb/host/xhci-mtk.c
@@ -442,6 +442,7 @@ static int xhci_mtk_probe(struct platform_device *pdev)
 
 	mtk->lpm_support = of_property_read_bool(node, "usb3-lpm-capable");
 	mtk->u2_lpm_disable = of_property_read_bool(node, "usb2-lpm-disable");
+	mtk->no_extra_cs = of_property_read_bool(node, "mediatek,no-extra-cs");
 	/* optional property, ignore the error if it does not exist */
 	of_property_read_u32(node, "mediatek,u3p-dis-msk",
 			     &mtk->u3p_dis_msk);
diff --git a/drivers/usb/host/xhci-mtk.h b/drivers/usb/host/xhci-mtk.h
index 7cc0123eada0..bd8f7f7160f6 100644
--- a/drivers/usb/host/xhci-mtk.h
+++ b/drivers/usb/host/xhci-mtk.h
@@ -98,6 +98,7 @@ struct mu3h_sch_ep_info {
 	struct usb_host_endpoint *ep;
 	enum usb_device_speed speed;
 	bool allocated;
+	bool no_extra_cs;
 	/*
 	 * mtk xHCI scheduling information put into reserved DWs
 	 * in ep context
@@ -155,6 +156,7 @@ struct xhci_hcd_mtk {
 	unsigned int has_ippc:1;
 	unsigned int lpm_support:1;
 	unsigned int u2_lpm_disable:1;
+	unsigned int no_extra_cs:1;
 	/* usb remote wakeup */
 	unsigned int uwk_en:1;
 	struct regmap *uwk;
-- 
2.18.0


More information about the Linux-mediatek mailing list