blob: 452b237b200be0feeb49b4d23dfcb78e15159a16 [file] [log] [blame]
developerabd06d72022-03-03 16:13:41 +08001From 9deb29cc86b8fdee6702f8d575f08f9a214cf90a Mon Sep 17 00:00:00 2001
developer9cd822e2021-06-24 09:16:06 +08002From: Zhanyong Wang <zhanyong.wang@mediatek.com>
3Date: Thu, 27 May 2021 11:44:17 +0800
developerba28e032021-12-07 10:40:00 +08004Subject: [PATCH 1/2] xHCI: MT7986 USB 2.0 USBIF compliance toolkit
developer9cd822e2021-06-24 09:16:06 +08005
6MT7986 USB 2.0 USBIF compliance toolkit
7
8Signed-off-by: Zhanyong Wang <zhanyong.wang@mediatek.com>
9---
10 drivers/usb/host/Kconfig | 9 +++++++++
developerabd06d72022-03-03 16:13:41 +080011 drivers/usb/host/Makefile | 9 +++++++++
developerba28e032021-12-07 10:40:00 +080012 drivers/usb/host/xhci-mtk.c | 5 ++++-
13 drivers/usb/host/xhci-mtk.h | 7 +++++++
developer9cd822e2021-06-24 09:16:06 +080014 drivers/usb/host/xhci.c | 2 +-
15 drivers/usb/host/xhci.h | 1 +
developerabd06d72022-03-03 16:13:41 +080016 6 files changed, 31 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
developerabd06d72022-03-03 16:13:41 +080039index b191361257cc..612c855adfa1 100644
developer9cd822e2021-06-24 09:16:06 +080040--- a/drivers/usb/host/Makefile
41+++ b/drivers/usb/host/Makefile
developerabd06d72022-03-03 16:13:41 +080042@@ -21,6 +21,15 @@ 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
developer9cd822e2021-06-24 09:16:06 +080055 endif
56
57 xhci-plat-hcd-y := xhci-plat.o
58diff --git a/drivers/usb/host/xhci-mtk.c b/drivers/usb/host/xhci-mtk.c
developerba28e032021-12-07 10:40:00 +080059index 5c0eb35cd007..8bd4c95a5435 100644
developer9cd822e2021-06-24 09:16:06 +080060--- a/drivers/usb/host/xhci-mtk.c
61+++ b/drivers/usb/host/xhci-mtk.c
developerba28e032021-12-07 10:40:00 +080062@@ -18,9 +18,10 @@
63 #include <linux/pm_runtime.h>
64 #include <linux/regmap.h>
65 #include <linux/regulator/consumer.h>
66-
67+#include <linux/usb/of.h>
developer9cd822e2021-06-24 09:16:06 +080068 #include "xhci.h"
69 #include "xhci-mtk.h"
developer9cd822e2021-06-24 09:16:06 +080070+#include "xhci-mtk-test.h"
developer9cd822e2021-06-24 09:16:06 +080071
72 /* ip_pw_ctrl0 register */
73 #define CTRL0_IP_SW_RST BIT(0)
developerba28e032021-12-07 10:40:00 +080074@@ -570,6 +571,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
developerba28e032021-12-07 10:40:00 +080082@@ -604,6 +606,7 @@ static int xhci_mtk_remove(struct platform_device *dev)
83 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
developerba28e032021-12-07 10:40:00 +080091index 985e7a19f6f6..1540c66799d7 100644
developer9cd822e2021-06-24 09:16:06 +080092--- a/drivers/usb/host/xhci-mtk.h
93+++ b/drivers/usb/host/xhci-mtk.h
developerba28e032021-12-07 10:40:00 +080094@@ -158,6 +158,13 @@ struct xhci_hcd_mtk {
developer9cd822e2021-06-24 09:16:06 +080095 struct regmap *uwk;
96 u32 uwk_reg_base;
97 u32 uwk_vers;
98+
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
developerabd06d72022-03-03 16:13:41 +0800109index 1c8070023161..cf004950bc00 100644
developer9cd822e2021-06-24 09:16:06 +0800110--- a/drivers/usb/host/xhci.c
111+++ b/drivers/usb/host/xhci.c
112@@ -713,7 +713,7 @@ EXPORT_SYMBOL_GPL(xhci_run);
113 * 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
developerba28e032021-12-07 10:40:00 +0800122index 02df309e4409..3af400068324 100644
developer9cd822e2021-06-24 09:16:06 +0800123--- a/drivers/usb/host/xhci.h
124+++ b/drivers/usb/host/xhci.h
developerba28e032021-12-07 10:40:00 +0800125@@ -2067,6 +2067,7 @@ int xhci_halt(struct xhci_hcd *xhci);
developer9cd822e2021-06-24 09:16:06 +0800126 int xhci_start(struct xhci_hcd *xhci);
127 int xhci_reset(struct xhci_hcd *xhci);
128 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--
1342.18.0
135