developer | 9cd822e | 2021-06-24 09:16:06 +0800 | [diff] [blame] | 1 | From 40340ed85ffef55379444713a32ad5e7d8633c4b Mon Sep 17 00:00:00 2001 |
| 2 | From: Zhanyong Wang <zhanyong.wang@mediatek.com> |
| 3 | Date: Thu, 27 May 2021 11:44:17 +0800 |
| 4 | Subject: [PATCH] [PATCH 1/2] xHCI: MT7986 USB 2.0 USBIF compliance toolkit |
| 5 | |
| 6 | MT7986 USB 2.0 USBIF compliance toolkit |
| 7 | |
| 8 | Signed-off-by: Zhanyong Wang <zhanyong.wang@mediatek.com> |
| 9 | --- |
| 10 | drivers/usb/host/Kconfig | 9 +++++++++ |
| 11 | drivers/usb/host/Makefile | 1 + |
| 12 | drivers/usb/host/xhci-mtk.c | 9 +++++++++ |
| 13 | drivers/usb/host/xhci-mtk.h | 5 +++++ |
| 14 | drivers/usb/host/xhci.c | 2 +- |
| 15 | drivers/usb/host/xhci.h | 1 + |
| 16 | 6 files changed, 26 insertions(+), 1 deletion(-) |
| 17 | |
| 18 | diff --git a/drivers/usb/host/Kconfig b/drivers/usb/host/Kconfig |
| 19 | index 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 |
| 38 | diff --git a/drivers/usb/host/Makefile b/drivers/usb/host/Makefile |
| 39 | index b191361257cc..447431408e54 100644 |
| 40 | --- a/drivers/usb/host/Makefile |
| 41 | +++ b/drivers/usb/host/Makefile |
| 42 | @@ -21,6 +21,7 @@ endif |
| 43 | |
| 44 | ifneq ($(CONFIG_USB_XHCI_MTK), ) |
| 45 | xhci-hcd-y += xhci-mtk-sch.o |
| 46 | + xhci-hcd-$(CONFIG_USB_XHCI_MTK_DEBUGFS) += xhci-mtk-test.o |
| 47 | endif |
| 48 | |
| 49 | xhci-plat-hcd-y := xhci-plat.o |
| 50 | diff --git a/drivers/usb/host/xhci-mtk.c b/drivers/usb/host/xhci-mtk.c |
| 51 | index 5c0eb35cd007..d5c3d8edfdd4 100644 |
| 52 | --- a/drivers/usb/host/xhci-mtk.c |
| 53 | +++ b/drivers/usb/host/xhci-mtk.c |
| 54 | @@ -21,6 +21,9 @@ |
| 55 | |
| 56 | #include "xhci.h" |
| 57 | #include "xhci-mtk.h" |
| 58 | +#ifdef CONFIG_USB_XHCI_MTK_DEBUGFS |
| 59 | +#include "xhci-mtk-test.h" |
| 60 | +#endif |
| 61 | |
| 62 | /* ip_pw_ctrl0 register */ |
| 63 | #define CTRL0_IP_SW_RST BIT(0) |
| 64 | @@ -570,6 +573,9 @@ static int xhci_mtk_probe(struct platform_device *pdev) |
| 65 | ret = usb_add_hcd(xhci->shared_hcd, irq, IRQF_SHARED); |
| 66 | if (ret) |
| 67 | goto dealloc_usb2_hcd; |
| 68 | +#ifdef CONFIG_USB_XHCI_MTK_DEBUGFS |
| 69 | + mu3h_hqa_create_attr(dev); |
| 70 | +#endif |
| 71 | |
| 72 | return 0; |
| 73 | |
| 74 | @@ -618,6 +624,9 @@ static int xhci_mtk_remove(struct platform_device *dev) |
| 75 | xhci_mtk_sch_exit(mtk); |
| 76 | xhci_mtk_clks_disable(mtk); |
| 77 | xhci_mtk_ldos_disable(mtk); |
| 78 | +#ifdef CONFIG_USB_XHCI_MTK_DEBUGFS |
| 79 | + mu3h_hqa_remove_attr(&dev->dev); |
| 80 | +#endif |
| 81 | |
| 82 | return 0; |
| 83 | } |
| 84 | diff --git a/drivers/usb/host/xhci-mtk.h b/drivers/usb/host/xhci-mtk.h |
| 85 | index 985e7a19f6f6..783f9629bc68 100644 |
| 86 | --- a/drivers/usb/host/xhci-mtk.h |
| 87 | +++ b/drivers/usb/host/xhci-mtk.h |
| 88 | @@ -158,6 +158,11 @@ struct xhci_hcd_mtk { |
| 89 | struct regmap *uwk; |
| 90 | u32 uwk_reg_base; |
| 91 | u32 uwk_vers; |
| 92 | + |
| 93 | +#ifdef CONFIG_USB_XHCI_MTK_DEBUGFS |
| 94 | + int test_mode; |
| 95 | + void __iomem *ip_base; |
| 96 | +#endif |
| 97 | }; |
| 98 | |
| 99 | static inline struct xhci_hcd_mtk *hcd_to_mtk(struct usb_hcd *hcd) |
| 100 | diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c |
| 101 | index de05ac9d3ae1..01266749357c 100644 |
| 102 | --- a/drivers/usb/host/xhci.c |
| 103 | +++ b/drivers/usb/host/xhci.c |
| 104 | @@ -713,7 +713,7 @@ EXPORT_SYMBOL_GPL(xhci_run); |
| 105 | * Disable device contexts, disable IRQs, and quiesce the HC. |
| 106 | * Reset the HC, finish any completed transactions, and cleanup memory. |
| 107 | */ |
| 108 | -static void xhci_stop(struct usb_hcd *hcd) |
| 109 | +void xhci_stop(struct usb_hcd *hcd) |
| 110 | { |
| 111 | u32 temp; |
| 112 | struct xhci_hcd *xhci = hcd_to_xhci(hcd); |
| 113 | diff --git a/drivers/usb/host/xhci.h b/drivers/usb/host/xhci.h |
| 114 | index 8798ed031786..66f0a9a01edc 100644 |
| 115 | --- a/drivers/usb/host/xhci.h |
| 116 | +++ b/drivers/usb/host/xhci.h |
| 117 | @@ -2063,6 +2063,7 @@ int xhci_halt(struct xhci_hcd *xhci); |
| 118 | int xhci_start(struct xhci_hcd *xhci); |
| 119 | int xhci_reset(struct xhci_hcd *xhci); |
| 120 | int xhci_run(struct usb_hcd *hcd); |
| 121 | +void xhci_stop(struct usb_hcd *hcd); |
| 122 | int xhci_gen_setup(struct usb_hcd *hcd, xhci_get_quirks_t get_quirks); |
| 123 | void xhci_shutdown(struct usb_hcd *hcd); |
| 124 | void xhci_init_driver(struct hc_driver *drv, |
| 125 | -- |
| 126 | 2.18.0 |
| 127 | |