blob: 0b3bf3cb9edb2dc08e1a8ecc4712ea0914e11ca8 [file] [log] [blame]
developer3c58fe12022-08-15 17:17:33 +08001From 4d19c233a01598a28fdc528ebaeb7a1b4bb6884f Mon Sep 17 00:00:00 2001
developer9cd822e2021-06-24 09:16:06 +08002From: Zhanyong Wang <zhanyong.wang@mediatek.com>
developer3c58fe12022-08-15 17:17:33 +08003Date: Mon, 15 Aug 2022 12:40:22 +0800
4Subject: [PATCH 2/3] xHCI: MT79xx USB 2.0 USBIF compliance toolkit
developer9cd822e2021-06-24 09:16:06 +08005
developer3c58fe12022-08-15 17:17:33 +08006MT79xx USB 2.0 USBIF compliance toolkit
developer9cd822e2021-06-24 09:16:06 +08007
8Signed-off-by: Zhanyong Wang <zhanyong.wang@mediatek.com>
9---
developer3c58fe12022-08-15 17:17:33 +080010 drivers/usb/host/Kconfig | 9 +++++++++
11 drivers/usb/host/Makefile | 10 ++++++++++
12 drivers/usb/host/xhci-mtk.c | 5 ++++-
13 drivers/usb/host/xhci-mtk.h | 7 +++++++
14 drivers/usb/host/xhci.c | 2 +-
15 drivers/usb/host/xhci.h | 1 +
16 6 files changed, 32 insertions(+), 2 deletions(-)
developer9cd822e2021-06-24 09:16:06 +080017
18diff --git a/drivers/usb/host/Kconfig b/drivers/usb/host/Kconfig
19index 79b2e79dddd0..12b1bf9aa043 100644
20--- a/drivers/usb/host/Kconfig
21+++ b/drivers/usb/host/Kconfig
22@@ -69,6 +69,15 @@ config USB_XHCI_MTK
23 found in MediaTek SoCs.
24 If unsure, say N.
25
26+config USB_XHCI_MTK_DEBUGFS
27+ tristate "xHCI DEBUGFS support for Mediatek MT65xx"
28+ depends on USB_XHCI_MTK && DEBUG_FS
29+ default y
30+ ---help---
31+ Say 'Y' to enable the debugfs support for the xHCI host controller
32+ found in Mediatek MT65xx SoCs.
33+ If don't need, say N.
34+
35 config USB_XHCI_MVEBU
36 tristate "xHCI support for Marvell Armada 375/38x/37xx"
37 select USB_XHCI_PLATFORM
38diff --git a/drivers/usb/host/Makefile b/drivers/usb/host/Makefile
developer3c58fe12022-08-15 17:17:33 +080039index b191361257cc..f064f836db2b 100644
developer9cd822e2021-06-24 09:16:06 +080040--- a/drivers/usb/host/Makefile
41+++ b/drivers/usb/host/Makefile
developer3c58fe12022-08-15 17:17:33 +080042@@ -21,6 +21,16 @@ endif
developer9cd822e2021-06-24 09:16:06 +080043
44 ifneq ($(CONFIG_USB_XHCI_MTK), )
45 xhci-hcd-y += xhci-mtk-sch.o
developerba28e032021-12-07 10:40:00 +080046+ xhci-hcd-$(CONFIG_USB_XHCI_MTK_DEBUGFS) += xhci-mtk-test.o
47+ xhci-hcd-$(CONFIG_USB_XHCI_MTK_DEBUGFS) += xhci-mtk-unusual.o
48+ xhci-hcd-$(CONFIG_USB_XHCI_MTK_DEBUGFS) += xhci-mtk-intr-en.o
49+ xhci-hcd-$(CONFIG_USB_XHCI_MTK_DEBUGFS) += xhci-mtk-vrt-vref.o
50+ xhci-hcd-$(CONFIG_USB_XHCI_MTK_DEBUGFS) += xhci-mtk-term-vref.o
51+ xhci-hcd-$(CONFIG_USB_XHCI_MTK_DEBUGFS) += xhci-mtk-hstx-srctrl.o
52+ xhci-hcd-$(CONFIG_USB_XHCI_MTK_DEBUGFS) += xhci-mtk-discth.o
53+ xhci-hcd-$(CONFIG_USB_XHCI_MTK_DEBUGFS) += xhci-mtk-chgdt-en.o
developerabd06d72022-03-03 16:13:41 +080054+ xhci-hcd-$(CONFIG_USB_XHCI_MTK_DEBUGFS) += xhci-mtk-reg.o
developer3c58fe12022-08-15 17:17:33 +080055+ xhci-hcd-$(CONFIG_USB_XHCI_MTK_DEBUGFS) += xhci-mtk-preemphasic.o
developer9cd822e2021-06-24 09:16:06 +080056 endif
57
58 xhci-plat-hcd-y := xhci-plat.o
59diff --git a/drivers/usb/host/xhci-mtk.c b/drivers/usb/host/xhci-mtk.c
developer3c58fe12022-08-15 17:17:33 +080060index 104296fdd03e..d4345657945d 100644
developer9cd822e2021-06-24 09:16:06 +080061--- a/drivers/usb/host/xhci-mtk.c
62+++ b/drivers/usb/host/xhci-mtk.c
developer3c58fe12022-08-15 17:17:33 +080063@@ -19,9 +19,10 @@
developerba28e032021-12-07 10:40:00 +080064 #include <linux/pm_runtime.h>
65 #include <linux/regmap.h>
66 #include <linux/regulator/consumer.h>
67-
68+#include <linux/usb/of.h>
developer9cd822e2021-06-24 09:16:06 +080069 #include "xhci.h"
70 #include "xhci-mtk.h"
developer9cd822e2021-06-24 09:16:06 +080071+#include "xhci-mtk-test.h"
developer9cd822e2021-06-24 09:16:06 +080072
73 /* ip_pw_ctrl0 register */
74 #define CTRL0_IP_SW_RST BIT(0)
developer3c58fe12022-08-15 17:17:33 +080075@@ -581,6 +582,7 @@ static int xhci_mtk_probe(struct platform_device *pdev)
developer9cd822e2021-06-24 09:16:06 +080076 ret = usb_add_hcd(xhci->shared_hcd, irq, IRQF_SHARED);
77 if (ret)
78 goto dealloc_usb2_hcd;
developerba28e032021-12-07 10:40:00 +080079+ hqa_create_attr(dev);
developer9cd822e2021-06-24 09:16:06 +080080
81 return 0;
82
developer3c58fe12022-08-15 17:17:33 +080083@@ -615,6 +617,7 @@ static int xhci_mtk_remove(struct platform_device *dev)
developerba28e032021-12-07 10:40:00 +080084 struct usb_hcd *hcd = mtk->hcd;
85 struct xhci_hcd *xhci = hcd_to_xhci(hcd);
86 struct usb_hcd *shared_hcd = xhci->shared_hcd;
87+ hqa_remove_attr(&dev->dev);
developer9cd822e2021-06-24 09:16:06 +080088
developerba28e032021-12-07 10:40:00 +080089 pm_runtime_put_noidle(&dev->dev);
90 pm_runtime_disable(&dev->dev);
developer9cd822e2021-06-24 09:16:06 +080091diff --git a/drivers/usb/host/xhci-mtk.h b/drivers/usb/host/xhci-mtk.h
developerba28e032021-12-07 10:40:00 +080092index 985e7a19f6f6..1540c66799d7 100644
developer9cd822e2021-06-24 09:16:06 +080093--- a/drivers/usb/host/xhci-mtk.h
94+++ b/drivers/usb/host/xhci-mtk.h
developerba28e032021-12-07 10:40:00 +080095@@ -158,6 +158,13 @@ struct xhci_hcd_mtk {
developer9cd822e2021-06-24 09:16:06 +080096 struct regmap *uwk;
97 u32 uwk_reg_base;
98 u32 uwk_vers;
99+
100+#ifdef CONFIG_USB_XHCI_MTK_DEBUGFS
developerba28e032021-12-07 10:40:00 +0800101+ int test_mode;
102+ size_t hqa_size;
103+ u32 hqa_pos;
104+ char *hqa_buf;
developer9cd822e2021-06-24 09:16:06 +0800105+#endif
106 };
107
108 static inline struct xhci_hcd_mtk *hcd_to_mtk(struct usb_hcd *hcd)
109diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c
developer3c58fe12022-08-15 17:17:33 +0800110index 9fe35bb67731..4f62eddce6ab 100644
developer9cd822e2021-06-24 09:16:06 +0800111--- a/drivers/usb/host/xhci.c
112+++ b/drivers/usb/host/xhci.c
developer3c58fe12022-08-15 17:17:33 +0800113@@ -711,7 +711,7 @@ EXPORT_SYMBOL_GPL(xhci_run);
developer9cd822e2021-06-24 09:16:06 +0800114 * Disable device contexts, disable IRQs, and quiesce the HC.
115 * Reset the HC, finish any completed transactions, and cleanup memory.
116 */
117-static void xhci_stop(struct usb_hcd *hcd)
118+void xhci_stop(struct usb_hcd *hcd)
119 {
120 u32 temp;
121 struct xhci_hcd *xhci = hcd_to_xhci(hcd);
122diff --git a/drivers/usb/host/xhci.h b/drivers/usb/host/xhci.h
developer3c58fe12022-08-15 17:17:33 +0800123index a9031f494984..b54be4833ef7 100644
developer9cd822e2021-06-24 09:16:06 +0800124--- a/drivers/usb/host/xhci.h
125+++ b/drivers/usb/host/xhci.h
developer3c58fe12022-08-15 17:17:33 +0800126@@ -2070,6 +2070,7 @@ int xhci_halt(struct xhci_hcd *xhci);
developer9cd822e2021-06-24 09:16:06 +0800127 int xhci_start(struct xhci_hcd *xhci);
developer3c58fe12022-08-15 17:17:33 +0800128 int xhci_reset(struct xhci_hcd *xhci, u64 timeout_us);
developer9cd822e2021-06-24 09:16:06 +0800129 int xhci_run(struct usb_hcd *hcd);
130+void xhci_stop(struct usb_hcd *hcd);
131 int xhci_gen_setup(struct usb_hcd *hcd, xhci_get_quirks_t get_quirks);
132 void xhci_shutdown(struct usb_hcd *hcd);
133 void xhci_init_driver(struct hc_driver *drv,
134--
1352.18.0
136