developer | ba28e03 | 2021-12-07 10:40:00 +0800 | [diff] [blame] | 1 | From b4048b5efd1ac39f85d86dedbf54a9b614d17d64 Mon Sep 17 00:00:00 2001 |
developer | 9cd822e | 2021-06-24 09:16:06 +0800 | [diff] [blame] | 2 | From: Zhanyong Wang <zhanyong.wang@mediatek.com> |
| 3 | Date: Thu, 27 May 2021 11:44:17 +0800 |
developer | ba28e03 | 2021-12-07 10:40:00 +0800 | [diff] [blame] | 4 | Subject: [PATCH 1/2] xHCI: MT7986 USB 2.0 USBIF compliance toolkit |
developer | 9cd822e | 2021-06-24 09:16:06 +0800 | [diff] [blame] | 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 +++++++++ |
developer | ba28e03 | 2021-12-07 10:40:00 +0800 | [diff] [blame] | 11 | drivers/usb/host/Makefile | 8 ++++++++ |
| 12 | drivers/usb/host/xhci-mtk.c | 5 ++++- |
| 13 | drivers/usb/host/xhci-mtk.h | 7 +++++++ |
developer | 9cd822e | 2021-06-24 09:16:06 +0800 | [diff] [blame] | 14 | drivers/usb/host/xhci.c | 2 +- |
| 15 | drivers/usb/host/xhci.h | 1 + |
developer | ba28e03 | 2021-12-07 10:40:00 +0800 | [diff] [blame] | 16 | 6 files changed, 30 insertions(+), 2 deletions(-) |
developer | 9cd822e | 2021-06-24 09:16:06 +0800 | [diff] [blame] | 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 |
developer | ba28e03 | 2021-12-07 10:40:00 +0800 | [diff] [blame] | 39 | index b191361257cc..704237831a58 100644 |
developer | 9cd822e | 2021-06-24 09:16:06 +0800 | [diff] [blame] | 40 | --- a/drivers/usb/host/Makefile |
| 41 | +++ b/drivers/usb/host/Makefile |
developer | ba28e03 | 2021-12-07 10:40:00 +0800 | [diff] [blame] | 42 | @@ -21,6 +21,14 @@ endif |
developer | 9cd822e | 2021-06-24 09:16:06 +0800 | [diff] [blame] | 43 | |
| 44 | ifneq ($(CONFIG_USB_XHCI_MTK), ) |
| 45 | xhci-hcd-y += xhci-mtk-sch.o |
developer | ba28e03 | 2021-12-07 10:40:00 +0800 | [diff] [blame] | 46 | + 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 |
developer | 9cd822e | 2021-06-24 09:16:06 +0800 | [diff] [blame] | 54 | endif |
| 55 | |
| 56 | xhci-plat-hcd-y := xhci-plat.o |
| 57 | diff --git a/drivers/usb/host/xhci-mtk.c b/drivers/usb/host/xhci-mtk.c |
developer | ba28e03 | 2021-12-07 10:40:00 +0800 | [diff] [blame] | 58 | index 5c0eb35cd007..8bd4c95a5435 100644 |
developer | 9cd822e | 2021-06-24 09:16:06 +0800 | [diff] [blame] | 59 | --- a/drivers/usb/host/xhci-mtk.c |
| 60 | +++ b/drivers/usb/host/xhci-mtk.c |
developer | ba28e03 | 2021-12-07 10:40:00 +0800 | [diff] [blame] | 61 | @@ -18,9 +18,10 @@ |
| 62 | #include <linux/pm_runtime.h> |
| 63 | #include <linux/regmap.h> |
| 64 | #include <linux/regulator/consumer.h> |
| 65 | - |
| 66 | +#include <linux/usb/of.h> |
developer | 9cd822e | 2021-06-24 09:16:06 +0800 | [diff] [blame] | 67 | #include "xhci.h" |
| 68 | #include "xhci-mtk.h" |
developer | 9cd822e | 2021-06-24 09:16:06 +0800 | [diff] [blame] | 69 | +#include "xhci-mtk-test.h" |
developer | 9cd822e | 2021-06-24 09:16:06 +0800 | [diff] [blame] | 70 | |
| 71 | /* ip_pw_ctrl0 register */ |
| 72 | #define CTRL0_IP_SW_RST BIT(0) |
developer | ba28e03 | 2021-12-07 10:40:00 +0800 | [diff] [blame] | 73 | @@ -570,6 +571,7 @@ static int xhci_mtk_probe(struct platform_device *pdev) |
developer | 9cd822e | 2021-06-24 09:16:06 +0800 | [diff] [blame] | 74 | ret = usb_add_hcd(xhci->shared_hcd, irq, IRQF_SHARED); |
| 75 | if (ret) |
| 76 | goto dealloc_usb2_hcd; |
developer | ba28e03 | 2021-12-07 10:40:00 +0800 | [diff] [blame] | 77 | + hqa_create_attr(dev); |
developer | 9cd822e | 2021-06-24 09:16:06 +0800 | [diff] [blame] | 78 | |
| 79 | return 0; |
| 80 | |
developer | ba28e03 | 2021-12-07 10:40:00 +0800 | [diff] [blame] | 81 | @@ -604,6 +606,7 @@ static int xhci_mtk_remove(struct platform_device *dev) |
| 82 | struct usb_hcd *hcd = mtk->hcd; |
| 83 | struct xhci_hcd *xhci = hcd_to_xhci(hcd); |
| 84 | struct usb_hcd *shared_hcd = xhci->shared_hcd; |
| 85 | + hqa_remove_attr(&dev->dev); |
developer | 9cd822e | 2021-06-24 09:16:06 +0800 | [diff] [blame] | 86 | |
developer | ba28e03 | 2021-12-07 10:40:00 +0800 | [diff] [blame] | 87 | pm_runtime_put_noidle(&dev->dev); |
| 88 | pm_runtime_disable(&dev->dev); |
developer | 9cd822e | 2021-06-24 09:16:06 +0800 | [diff] [blame] | 89 | diff --git a/drivers/usb/host/xhci-mtk.h b/drivers/usb/host/xhci-mtk.h |
developer | ba28e03 | 2021-12-07 10:40:00 +0800 | [diff] [blame] | 90 | index 985e7a19f6f6..1540c66799d7 100644 |
developer | 9cd822e | 2021-06-24 09:16:06 +0800 | [diff] [blame] | 91 | --- a/drivers/usb/host/xhci-mtk.h |
| 92 | +++ b/drivers/usb/host/xhci-mtk.h |
developer | ba28e03 | 2021-12-07 10:40:00 +0800 | [diff] [blame] | 93 | @@ -158,6 +158,13 @@ struct xhci_hcd_mtk { |
developer | 9cd822e | 2021-06-24 09:16:06 +0800 | [diff] [blame] | 94 | struct regmap *uwk; |
| 95 | u32 uwk_reg_base; |
| 96 | u32 uwk_vers; |
| 97 | + |
| 98 | +#ifdef CONFIG_USB_XHCI_MTK_DEBUGFS |
developer | ba28e03 | 2021-12-07 10:40:00 +0800 | [diff] [blame] | 99 | + int test_mode; |
| 100 | + size_t hqa_size; |
| 101 | + u32 hqa_pos; |
| 102 | + char *hqa_buf; |
developer | 9cd822e | 2021-06-24 09:16:06 +0800 | [diff] [blame] | 103 | +#endif |
| 104 | }; |
| 105 | |
| 106 | static inline struct xhci_hcd_mtk *hcd_to_mtk(struct usb_hcd *hcd) |
| 107 | diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c |
developer | ba28e03 | 2021-12-07 10:40:00 +0800 | [diff] [blame] | 108 | index 4bb850370bb6..710ccbe5a3b8 100644 |
developer | 9cd822e | 2021-06-24 09:16:06 +0800 | [diff] [blame] | 109 | --- a/drivers/usb/host/xhci.c |
| 110 | +++ b/drivers/usb/host/xhci.c |
| 111 | @@ -713,7 +713,7 @@ EXPORT_SYMBOL_GPL(xhci_run); |
| 112 | * Disable device contexts, disable IRQs, and quiesce the HC. |
| 113 | * Reset the HC, finish any completed transactions, and cleanup memory. |
| 114 | */ |
| 115 | -static void xhci_stop(struct usb_hcd *hcd) |
| 116 | +void xhci_stop(struct usb_hcd *hcd) |
| 117 | { |
| 118 | u32 temp; |
| 119 | struct xhci_hcd *xhci = hcd_to_xhci(hcd); |
| 120 | diff --git a/drivers/usb/host/xhci.h b/drivers/usb/host/xhci.h |
developer | ba28e03 | 2021-12-07 10:40:00 +0800 | [diff] [blame] | 121 | index 02df309e4409..3af400068324 100644 |
developer | 9cd822e | 2021-06-24 09:16:06 +0800 | [diff] [blame] | 122 | --- a/drivers/usb/host/xhci.h |
| 123 | +++ b/drivers/usb/host/xhci.h |
developer | ba28e03 | 2021-12-07 10:40:00 +0800 | [diff] [blame] | 124 | @@ -2067,6 +2067,7 @@ int xhci_halt(struct xhci_hcd *xhci); |
developer | 9cd822e | 2021-06-24 09:16:06 +0800 | [diff] [blame] | 125 | int xhci_start(struct xhci_hcd *xhci); |
| 126 | int xhci_reset(struct xhci_hcd *xhci); |
| 127 | int xhci_run(struct usb_hcd *hcd); |
| 128 | +void xhci_stop(struct usb_hcd *hcd); |
| 129 | int xhci_gen_setup(struct usb_hcd *hcd, xhci_get_quirks_t get_quirks); |
| 130 | void xhci_shutdown(struct usb_hcd *hcd); |
| 131 | void xhci_init_driver(struct hc_driver *drv, |
| 132 | -- |
| 133 | 2.18.0 |
| 134 | |