blob: d6974a55379b3c70b445fa4b27053137a666c0cf [file] [log] [blame]
developer5d148cb2023-06-02 13:08:11 +08001From f6aea6b89ce99b4f490fe1e1062b88042096703e Mon Sep 17 00:00:00 2001
2From: Sam Shih <sam.shih@mediatek.com>
3Date: Fri, 2 Jun 2023 13:06:26 +0800
4Subject: [PATCH]
developer3de3aca2023-06-07 20:44:59 +08005 [high-speed-io][999-2621-xHCI-MT7986-USB-2.0-USBIF-compliance-toolkit.patch]
developer9cd822e2021-06-24 09:16:06 +08006
developer9cd822e2021-06-24 09:16:06 +08007---
developer3c58fe12022-08-15 17:17:33 +08008 drivers/usb/host/Kconfig | 9 +++++++++
9 drivers/usb/host/Makefile | 10 ++++++++++
developer8cdcb262022-10-27 14:36:15 +080010 drivers/usb/host/xhci-mtk.c | 6 ++++--
developer3c58fe12022-08-15 17:17:33 +080011 drivers/usb/host/xhci-mtk.h | 7 +++++++
12 drivers/usb/host/xhci.c | 2 +-
13 drivers/usb/host/xhci.h | 1 +
developer8cdcb262022-10-27 14:36:15 +080014 6 files changed, 32 insertions(+), 3 deletions(-)
developer9cd822e2021-06-24 09:16:06 +080015
16diff --git a/drivers/usb/host/Kconfig b/drivers/usb/host/Kconfig
developer5d148cb2023-06-02 13:08:11 +080017index 79b2e79dd..12b1bf9aa 100644
developer9cd822e2021-06-24 09:16:06 +080018--- a/drivers/usb/host/Kconfig
19+++ b/drivers/usb/host/Kconfig
20@@ -69,6 +69,15 @@ config USB_XHCI_MTK
21 found in MediaTek SoCs.
22 If unsure, say N.
23
24+config USB_XHCI_MTK_DEBUGFS
25+ tristate "xHCI DEBUGFS support for Mediatek MT65xx"
26+ depends on USB_XHCI_MTK && DEBUG_FS
27+ default y
28+ ---help---
29+ Say 'Y' to enable the debugfs support for the xHCI host controller
30+ found in Mediatek MT65xx SoCs.
31+ If don't need, say N.
32+
33 config USB_XHCI_MVEBU
34 tristate "xHCI support for Marvell Armada 375/38x/37xx"
35 select USB_XHCI_PLATFORM
36diff --git a/drivers/usb/host/Makefile b/drivers/usb/host/Makefile
developer5d148cb2023-06-02 13:08:11 +080037index b19136125..f064f836d 100644
developer9cd822e2021-06-24 09:16:06 +080038--- a/drivers/usb/host/Makefile
39+++ b/drivers/usb/host/Makefile
developer3c58fe12022-08-15 17:17:33 +080040@@ -21,6 +21,16 @@ endif
developer9cd822e2021-06-24 09:16:06 +080041
42 ifneq ($(CONFIG_USB_XHCI_MTK), )
43 xhci-hcd-y += xhci-mtk-sch.o
developerba28e032021-12-07 10:40:00 +080044+ xhci-hcd-$(CONFIG_USB_XHCI_MTK_DEBUGFS) += xhci-mtk-test.o
45+ xhci-hcd-$(CONFIG_USB_XHCI_MTK_DEBUGFS) += xhci-mtk-unusual.o
46+ xhci-hcd-$(CONFIG_USB_XHCI_MTK_DEBUGFS) += xhci-mtk-intr-en.o
47+ xhci-hcd-$(CONFIG_USB_XHCI_MTK_DEBUGFS) += xhci-mtk-vrt-vref.o
48+ xhci-hcd-$(CONFIG_USB_XHCI_MTK_DEBUGFS) += xhci-mtk-term-vref.o
49+ xhci-hcd-$(CONFIG_USB_XHCI_MTK_DEBUGFS) += xhci-mtk-hstx-srctrl.o
50+ xhci-hcd-$(CONFIG_USB_XHCI_MTK_DEBUGFS) += xhci-mtk-discth.o
51+ xhci-hcd-$(CONFIG_USB_XHCI_MTK_DEBUGFS) += xhci-mtk-chgdt-en.o
developerabd06d72022-03-03 16:13:41 +080052+ xhci-hcd-$(CONFIG_USB_XHCI_MTK_DEBUGFS) += xhci-mtk-reg.o
developer3c58fe12022-08-15 17:17:33 +080053+ xhci-hcd-$(CONFIG_USB_XHCI_MTK_DEBUGFS) += xhci-mtk-preemphasic.o
developer9cd822e2021-06-24 09:16:06 +080054 endif
55
56 xhci-plat-hcd-y := xhci-plat.o
57diff --git a/drivers/usb/host/xhci-mtk.c b/drivers/usb/host/xhci-mtk.c
developer5d148cb2023-06-02 13:08:11 +080058index 77ddb8c05..7a2007931 100644
developer9cd822e2021-06-24 09:16:06 +080059--- a/drivers/usb/host/xhci-mtk.c
60+++ b/drivers/usb/host/xhci-mtk.c
developer8cdcb262022-10-27 14:36:15 +080061@@ -18,10 +18,10 @@
developerba28e032021-12-07 10:40:00 +080062 #include <linux/pm_runtime.h>
63 #include <linux/regmap.h>
64 #include <linux/regulator/consumer.h>
65-
66+#include <linux/usb/of.h>
developer9cd822e2021-06-24 09:16:06 +080067 #include "xhci.h"
68 #include "xhci-mtk.h"
developer8cdcb262022-10-27 14:36:15 +080069-
developer9cd822e2021-06-24 09:16:06 +080070+#include "xhci-mtk-test.h"
developer8cdcb262022-10-27 14:36:15 +080071 /* COMPLIANCE_CP5_CP7_TXDEEMPH_10G register */
72 #define COMPLIANCE_CP5_CP7_TXDEEMPH_10G 0x2428
73 #define CP5_CP7_TXDEEMPH_10G GENMASK(17, 0)
74@@ -586,6 +586,7 @@ static int xhci_mtk_probe(struct platform_device *pdev)
developer9cd822e2021-06-24 09:16:06 +080075 ret = usb_add_hcd(xhci->shared_hcd, irq, IRQF_SHARED);
76 if (ret)
77 goto dealloc_usb2_hcd;
developerba28e032021-12-07 10:40:00 +080078+ hqa_create_attr(dev);
developer9cd822e2021-06-24 09:16:06 +080079
80 return 0;
81
developer8cdcb262022-10-27 14:36:15 +080082@@ -620,6 +621,7 @@ static int xhci_mtk_remove(struct platform_device *dev)
developerba28e032021-12-07 10:40:00 +080083 struct usb_hcd *hcd = mtk->hcd;
84 struct xhci_hcd *xhci = hcd_to_xhci(hcd);
85 struct usb_hcd *shared_hcd = xhci->shared_hcd;
86+ hqa_remove_attr(&dev->dev);
developer9cd822e2021-06-24 09:16:06 +080087
developerba28e032021-12-07 10:40:00 +080088 pm_runtime_put_noidle(&dev->dev);
89 pm_runtime_disable(&dev->dev);
developer9cd822e2021-06-24 09:16:06 +080090diff --git a/drivers/usb/host/xhci-mtk.h b/drivers/usb/host/xhci-mtk.h
developer5d148cb2023-06-02 13:08:11 +080091index 8a884e7b4..e815d7091 100644
developer9cd822e2021-06-24 09:16:06 +080092--- a/drivers/usb/host/xhci-mtk.h
93+++ b/drivers/usb/host/xhci-mtk.h
developer8cdcb262022-10-27 14:36:15 +080094@@ -157,6 +157,13 @@ struct xhci_hcd_mtk {
developer9cd822e2021-06-24 09:16:06 +080095 u32 uwk_reg_base;
96 u32 uwk_vers;
developer8cdcb262022-10-27 14:36:15 +080097 bool p0_speed_fixup;
developer9cd822e2021-06-24 09:16:06 +080098+
99+#ifdef CONFIG_USB_XHCI_MTK_DEBUGFS
developerba28e032021-12-07 10:40:00 +0800100+ int test_mode;
101+ size_t hqa_size;
102+ u32 hqa_pos;
103+ char *hqa_buf;
developer9cd822e2021-06-24 09:16:06 +0800104+#endif
105 };
106
107 static inline struct xhci_hcd_mtk *hcd_to_mtk(struct usb_hcd *hcd)
108diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c
developer5d148cb2023-06-02 13:08:11 +0800109index b8915790a..dd1b520af 100644
developer9cd822e2021-06-24 09:16:06 +0800110--- a/drivers/usb/host/xhci.c
111+++ b/drivers/usb/host/xhci.c
developer5d148cb2023-06-02 13:08:11 +0800112@@ -714,7 +714,7 @@ EXPORT_SYMBOL_GPL(xhci_run);
developer9cd822e2021-06-24 09:16:06 +0800113 * Disable device contexts, disable IRQs, and quiesce the HC.
114 * Reset the HC, finish any completed transactions, and cleanup memory.
115 */
116-static void xhci_stop(struct usb_hcd *hcd)
117+void xhci_stop(struct usb_hcd *hcd)
118 {
119 u32 temp;
120 struct xhci_hcd *xhci = hcd_to_xhci(hcd);
121diff --git a/drivers/usb/host/xhci.h b/drivers/usb/host/xhci.h
developer5d148cb2023-06-02 13:08:11 +0800122index e696f1508..07f904167 100644
developer9cd822e2021-06-24 09:16:06 +0800123--- a/drivers/usb/host/xhci.h
124+++ b/drivers/usb/host/xhci.h
developer5d148cb2023-06-02 13:08:11 +0800125@@ -2073,6 +2073,7 @@ int xhci_halt(struct xhci_hcd *xhci);
developer9cd822e2021-06-24 09:16:06 +0800126 int xhci_start(struct xhci_hcd *xhci);
developer3c58fe12022-08-15 17:17:33 +0800127 int xhci_reset(struct xhci_hcd *xhci, u64 timeout_us);
developer9cd822e2021-06-24 09:16:06 +0800128 int xhci_run(struct usb_hcd *hcd);
129+void xhci_stop(struct usb_hcd *hcd);
130 int xhci_gen_setup(struct usb_hcd *hcd, xhci_get_quirks_t get_quirks);
131 void xhci_shutdown(struct usb_hcd *hcd);
132 void xhci_init_driver(struct hc_driver *drv,
133--
developer5d148cb2023-06-02 13:08:11 +08001342.34.1
developer9cd822e2021-06-24 09:16:06 +0800135