blob: 07b87fc33b0a16cf02a5096067f15e87335a3538 [file] [log] [blame]
From 083b79c977495cafc70c5d044db1f3f6c0587b1c Mon Sep 17 00:00:00 2001
From: Zhanyong Wang <zhanyong.wang@mediatek.com>
Date: Mon, 15 Aug 2022 12:40:22 +0800
Subject: [PATCH 2/3] xHCI: MT79xx USB 2.0 USBIF compliance toolkit
MT79xx USB 2.0 USBIF compliance toolkit
Signed-off-by: Zhanyong Wang <zhanyong.wang@mediatek.com>
---
drivers/usb/host/Kconfig | 9 +++++++++
drivers/usb/host/Makefile | 10 ++++++++++
drivers/usb/host/xhci-mtk.c | 6 ++++--
drivers/usb/host/xhci-mtk.h | 7 +++++++
drivers/usb/host/xhci.c | 2 +-
drivers/usb/host/xhci.h | 1 +
6 files changed, 32 insertions(+), 3 deletions(-)
diff --git a/drivers/usb/host/Kconfig b/drivers/usb/host/Kconfig
index 79b2e79dddd0..12b1bf9aa043 100644
--- a/drivers/usb/host/Kconfig
+++ b/drivers/usb/host/Kconfig
@@ -69,6 +69,15 @@ config USB_XHCI_MTK
found in MediaTek SoCs.
If unsure, say N.
+config USB_XHCI_MTK_DEBUGFS
+ tristate "xHCI DEBUGFS support for Mediatek MT65xx"
+ depends on USB_XHCI_MTK && DEBUG_FS
+ default y
+ ---help---
+ Say 'Y' to enable the debugfs support for the xHCI host controller
+ found in Mediatek MT65xx SoCs.
+ If don't need, say N.
+
config USB_XHCI_MVEBU
tristate "xHCI support for Marvell Armada 375/38x/37xx"
select USB_XHCI_PLATFORM
diff --git a/drivers/usb/host/Makefile b/drivers/usb/host/Makefile
index b191361257cc..f064f836db2b 100644
--- a/drivers/usb/host/Makefile
+++ b/drivers/usb/host/Makefile
@@ -21,6 +21,16 @@ endif
ifneq ($(CONFIG_USB_XHCI_MTK), )
xhci-hcd-y += xhci-mtk-sch.o
+ xhci-hcd-$(CONFIG_USB_XHCI_MTK_DEBUGFS) += xhci-mtk-test.o
+ xhci-hcd-$(CONFIG_USB_XHCI_MTK_DEBUGFS) += xhci-mtk-unusual.o
+ xhci-hcd-$(CONFIG_USB_XHCI_MTK_DEBUGFS) += xhci-mtk-intr-en.o
+ xhci-hcd-$(CONFIG_USB_XHCI_MTK_DEBUGFS) += xhci-mtk-vrt-vref.o
+ xhci-hcd-$(CONFIG_USB_XHCI_MTK_DEBUGFS) += xhci-mtk-term-vref.o
+ xhci-hcd-$(CONFIG_USB_XHCI_MTK_DEBUGFS) += xhci-mtk-hstx-srctrl.o
+ xhci-hcd-$(CONFIG_USB_XHCI_MTK_DEBUGFS) += xhci-mtk-discth.o
+ xhci-hcd-$(CONFIG_USB_XHCI_MTK_DEBUGFS) += xhci-mtk-chgdt-en.o
+ xhci-hcd-$(CONFIG_USB_XHCI_MTK_DEBUGFS) += xhci-mtk-reg.o
+ xhci-hcd-$(CONFIG_USB_XHCI_MTK_DEBUGFS) += xhci-mtk-preemphasic.o
endif
xhci-plat-hcd-y := xhci-plat.o
diff --git a/drivers/usb/host/xhci-mtk.c b/drivers/usb/host/xhci-mtk.c
index 77ddb8c05500..7a200793169b 100644
--- a/drivers/usb/host/xhci-mtk.c
+++ b/drivers/usb/host/xhci-mtk.c
@@ -18,10 +18,10 @@
#include <linux/pm_runtime.h>
#include <linux/regmap.h>
#include <linux/regulator/consumer.h>
-
+#include <linux/usb/of.h>
#include "xhci.h"
#include "xhci-mtk.h"
-
+#include "xhci-mtk-test.h"
/* COMPLIANCE_CP5_CP7_TXDEEMPH_10G register */
#define COMPLIANCE_CP5_CP7_TXDEEMPH_10G 0x2428
#define CP5_CP7_TXDEEMPH_10G GENMASK(17, 0)
@@ -586,6 +586,7 @@ static int xhci_mtk_probe(struct platform_device *pdev)
ret = usb_add_hcd(xhci->shared_hcd, irq, IRQF_SHARED);
if (ret)
goto dealloc_usb2_hcd;
+ hqa_create_attr(dev);
return 0;
@@ -620,6 +621,7 @@ static int xhci_mtk_remove(struct platform_device *dev)
struct usb_hcd *hcd = mtk->hcd;
struct xhci_hcd *xhci = hcd_to_xhci(hcd);
struct usb_hcd *shared_hcd = xhci->shared_hcd;
+ hqa_remove_attr(&dev->dev);
pm_runtime_put_noidle(&dev->dev);
pm_runtime_disable(&dev->dev);
diff --git a/drivers/usb/host/xhci-mtk.h b/drivers/usb/host/xhci-mtk.h
index 8a884e7b481b..e815d7091acc 100644
--- a/drivers/usb/host/xhci-mtk.h
+++ b/drivers/usb/host/xhci-mtk.h
@@ -157,6 +157,13 @@ struct xhci_hcd_mtk {
u32 uwk_reg_base;
u32 uwk_vers;
bool p0_speed_fixup;
+
+#ifdef CONFIG_USB_XHCI_MTK_DEBUGFS
+ int test_mode;
+ size_t hqa_size;
+ u32 hqa_pos;
+ char *hqa_buf;
+#endif
};
static inline struct xhci_hcd_mtk *hcd_to_mtk(struct usb_hcd *hcd)
diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c
index 5ce16a259e61..b6f8383f7371 100644
--- a/drivers/usb/host/xhci.c
+++ b/drivers/usb/host/xhci.c
@@ -713,7 +713,7 @@ EXPORT_SYMBOL_GPL(xhci_run);
* Disable device contexts, disable IRQs, and quiesce the HC.
* Reset the HC, finish any completed transactions, and cleanup memory.
*/
-static void xhci_stop(struct usb_hcd *hcd)
+void xhci_stop(struct usb_hcd *hcd)
{
u32 temp;
struct xhci_hcd *xhci = hcd_to_xhci(hcd);
diff --git a/drivers/usb/host/xhci.h b/drivers/usb/host/xhci.h
index 0dc448630197..80b3124c43e2 100644
--- a/drivers/usb/host/xhci.h
+++ b/drivers/usb/host/xhci.h
@@ -2070,6 +2070,7 @@ int xhci_halt(struct xhci_hcd *xhci);
int xhci_start(struct xhci_hcd *xhci);
int xhci_reset(struct xhci_hcd *xhci, u64 timeout_us);
int xhci_run(struct usb_hcd *hcd);
+void xhci_stop(struct usb_hcd *hcd);
int xhci_gen_setup(struct usb_hcd *hcd, xhci_get_quirks_t get_quirks);
void xhci_shutdown(struct usb_hcd *hcd);
void xhci_init_driver(struct hc_driver *drv,
--
2.18.0