developer | 8cdcb26 | 2022-10-27 14:36:15 +0800 | [diff] [blame] | 1 | From 083b79c977495cafc70c5d044db1f3f6c0587b1c 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> |
developer | 3c58fe1 | 2022-08-15 17:17:33 +0800 | [diff] [blame] | 3 | Date: Mon, 15 Aug 2022 12:40:22 +0800 |
| 4 | Subject: [PATCH 2/3] xHCI: MT79xx USB 2.0 USBIF compliance toolkit |
developer | 9cd822e | 2021-06-24 09:16:06 +0800 | [diff] [blame] | 5 | |
developer | 3c58fe1 | 2022-08-15 17:17:33 +0800 | [diff] [blame] | 6 | MT79xx USB 2.0 USBIF compliance toolkit |
developer | 9cd822e | 2021-06-24 09:16:06 +0800 | [diff] [blame] | 7 | |
| 8 | Signed-off-by: Zhanyong Wang <zhanyong.wang@mediatek.com> |
| 9 | --- |
developer | 3c58fe1 | 2022-08-15 17:17:33 +0800 | [diff] [blame] | 10 | drivers/usb/host/Kconfig | 9 +++++++++ |
| 11 | drivers/usb/host/Makefile | 10 ++++++++++ |
developer | 8cdcb26 | 2022-10-27 14:36:15 +0800 | [diff] [blame] | 12 | drivers/usb/host/xhci-mtk.c | 6 ++++-- |
developer | 3c58fe1 | 2022-08-15 17:17:33 +0800 | [diff] [blame] | 13 | drivers/usb/host/xhci-mtk.h | 7 +++++++ |
| 14 | drivers/usb/host/xhci.c | 2 +- |
| 15 | drivers/usb/host/xhci.h | 1 + |
developer | 8cdcb26 | 2022-10-27 14:36:15 +0800 | [diff] [blame] | 16 | 6 files changed, 32 insertions(+), 3 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 | 3c58fe1 | 2022-08-15 17:17:33 +0800 | [diff] [blame] | 39 | index b191361257cc..f064f836db2b 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 | 3c58fe1 | 2022-08-15 17:17:33 +0800 | [diff] [blame] | 42 | @@ -21,6 +21,16 @@ 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 | abd06d7 | 2022-03-03 16:13:41 +0800 | [diff] [blame] | 54 | + xhci-hcd-$(CONFIG_USB_XHCI_MTK_DEBUGFS) += xhci-mtk-reg.o |
developer | 3c58fe1 | 2022-08-15 17:17:33 +0800 | [diff] [blame] | 55 | + xhci-hcd-$(CONFIG_USB_XHCI_MTK_DEBUGFS) += xhci-mtk-preemphasic.o |
developer | 9cd822e | 2021-06-24 09:16:06 +0800 | [diff] [blame] | 56 | endif |
| 57 | |
| 58 | xhci-plat-hcd-y := xhci-plat.o |
| 59 | diff --git a/drivers/usb/host/xhci-mtk.c b/drivers/usb/host/xhci-mtk.c |
developer | 8cdcb26 | 2022-10-27 14:36:15 +0800 | [diff] [blame] | 60 | index 77ddb8c05500..7a200793169b 100644 |
developer | 9cd822e | 2021-06-24 09:16:06 +0800 | [diff] [blame] | 61 | --- a/drivers/usb/host/xhci-mtk.c |
| 62 | +++ b/drivers/usb/host/xhci-mtk.c |
developer | 8cdcb26 | 2022-10-27 14:36:15 +0800 | [diff] [blame] | 63 | @@ -18,10 +18,10 @@ |
developer | ba28e03 | 2021-12-07 10:40:00 +0800 | [diff] [blame] | 64 | #include <linux/pm_runtime.h> |
| 65 | #include <linux/regmap.h> |
| 66 | #include <linux/regulator/consumer.h> |
| 67 | - |
| 68 | +#include <linux/usb/of.h> |
developer | 9cd822e | 2021-06-24 09:16:06 +0800 | [diff] [blame] | 69 | #include "xhci.h" |
| 70 | #include "xhci-mtk.h" |
developer | 8cdcb26 | 2022-10-27 14:36:15 +0800 | [diff] [blame] | 71 | - |
developer | 9cd822e | 2021-06-24 09:16:06 +0800 | [diff] [blame] | 72 | +#include "xhci-mtk-test.h" |
developer | 8cdcb26 | 2022-10-27 14:36:15 +0800 | [diff] [blame] | 73 | /* COMPLIANCE_CP5_CP7_TXDEEMPH_10G register */ |
| 74 | #define COMPLIANCE_CP5_CP7_TXDEEMPH_10G 0x2428 |
| 75 | #define CP5_CP7_TXDEEMPH_10G GENMASK(17, 0) |
| 76 | @@ -586,6 +586,7 @@ static int xhci_mtk_probe(struct platform_device *pdev) |
developer | 9cd822e | 2021-06-24 09:16:06 +0800 | [diff] [blame] | 77 | ret = usb_add_hcd(xhci->shared_hcd, irq, IRQF_SHARED); |
| 78 | if (ret) |
| 79 | goto dealloc_usb2_hcd; |
developer | ba28e03 | 2021-12-07 10:40:00 +0800 | [diff] [blame] | 80 | + hqa_create_attr(dev); |
developer | 9cd822e | 2021-06-24 09:16:06 +0800 | [diff] [blame] | 81 | |
| 82 | return 0; |
| 83 | |
developer | 8cdcb26 | 2022-10-27 14:36:15 +0800 | [diff] [blame] | 84 | @@ -620,6 +621,7 @@ static int xhci_mtk_remove(struct platform_device *dev) |
developer | ba28e03 | 2021-12-07 10:40:00 +0800 | [diff] [blame] | 85 | struct usb_hcd *hcd = mtk->hcd; |
| 86 | struct xhci_hcd *xhci = hcd_to_xhci(hcd); |
| 87 | struct usb_hcd *shared_hcd = xhci->shared_hcd; |
| 88 | + hqa_remove_attr(&dev->dev); |
developer | 9cd822e | 2021-06-24 09:16:06 +0800 | [diff] [blame] | 89 | |
developer | ba28e03 | 2021-12-07 10:40:00 +0800 | [diff] [blame] | 90 | pm_runtime_put_noidle(&dev->dev); |
| 91 | pm_runtime_disable(&dev->dev); |
developer | 9cd822e | 2021-06-24 09:16:06 +0800 | [diff] [blame] | 92 | diff --git a/drivers/usb/host/xhci-mtk.h b/drivers/usb/host/xhci-mtk.h |
developer | 8cdcb26 | 2022-10-27 14:36:15 +0800 | [diff] [blame] | 93 | index 8a884e7b481b..e815d7091acc 100644 |
developer | 9cd822e | 2021-06-24 09:16:06 +0800 | [diff] [blame] | 94 | --- a/drivers/usb/host/xhci-mtk.h |
| 95 | +++ b/drivers/usb/host/xhci-mtk.h |
developer | 8cdcb26 | 2022-10-27 14:36:15 +0800 | [diff] [blame] | 96 | @@ -157,6 +157,13 @@ struct xhci_hcd_mtk { |
developer | 9cd822e | 2021-06-24 09:16:06 +0800 | [diff] [blame] | 97 | u32 uwk_reg_base; |
| 98 | u32 uwk_vers; |
developer | 8cdcb26 | 2022-10-27 14:36:15 +0800 | [diff] [blame] | 99 | bool p0_speed_fixup; |
developer | 9cd822e | 2021-06-24 09:16:06 +0800 | [diff] [blame] | 100 | + |
| 101 | +#ifdef CONFIG_USB_XHCI_MTK_DEBUGFS |
developer | ba28e03 | 2021-12-07 10:40:00 +0800 | [diff] [blame] | 102 | + int test_mode; |
| 103 | + size_t hqa_size; |
| 104 | + u32 hqa_pos; |
| 105 | + char *hqa_buf; |
developer | 9cd822e | 2021-06-24 09:16:06 +0800 | [diff] [blame] | 106 | +#endif |
| 107 | }; |
| 108 | |
| 109 | static inline struct xhci_hcd_mtk *hcd_to_mtk(struct usb_hcd *hcd) |
| 110 | diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c |
developer | 8cdcb26 | 2022-10-27 14:36:15 +0800 | [diff] [blame] | 111 | index 5ce16a259e61..b6f8383f7371 100644 |
developer | 9cd822e | 2021-06-24 09:16:06 +0800 | [diff] [blame] | 112 | --- a/drivers/usb/host/xhci.c |
| 113 | +++ b/drivers/usb/host/xhci.c |
developer | 8cdcb26 | 2022-10-27 14:36:15 +0800 | [diff] [blame] | 114 | @@ -713,7 +713,7 @@ EXPORT_SYMBOL_GPL(xhci_run); |
developer | 9cd822e | 2021-06-24 09:16:06 +0800 | [diff] [blame] | 115 | * Disable device contexts, disable IRQs, and quiesce the HC. |
| 116 | * Reset the HC, finish any completed transactions, and cleanup memory. |
| 117 | */ |
| 118 | -static void xhci_stop(struct usb_hcd *hcd) |
| 119 | +void xhci_stop(struct usb_hcd *hcd) |
| 120 | { |
| 121 | u32 temp; |
| 122 | struct xhci_hcd *xhci = hcd_to_xhci(hcd); |
| 123 | diff --git a/drivers/usb/host/xhci.h b/drivers/usb/host/xhci.h |
developer | 8cdcb26 | 2022-10-27 14:36:15 +0800 | [diff] [blame] | 124 | index 0dc448630197..80b3124c43e2 100644 |
developer | 9cd822e | 2021-06-24 09:16:06 +0800 | [diff] [blame] | 125 | --- a/drivers/usb/host/xhci.h |
| 126 | +++ b/drivers/usb/host/xhci.h |
developer | 3c58fe1 | 2022-08-15 17:17:33 +0800 | [diff] [blame] | 127 | @@ -2070,6 +2070,7 @@ int xhci_halt(struct xhci_hcd *xhci); |
developer | 9cd822e | 2021-06-24 09:16:06 +0800 | [diff] [blame] | 128 | int xhci_start(struct xhci_hcd *xhci); |
developer | 3c58fe1 | 2022-08-15 17:17:33 +0800 | [diff] [blame] | 129 | int xhci_reset(struct xhci_hcd *xhci, u64 timeout_us); |
developer | 9cd822e | 2021-06-24 09:16:06 +0800 | [diff] [blame] | 130 | int xhci_run(struct usb_hcd *hcd); |
| 131 | +void xhci_stop(struct usb_hcd *hcd); |
| 132 | int xhci_gen_setup(struct usb_hcd *hcd, xhci_get_quirks_t get_quirks); |
| 133 | void xhci_shutdown(struct usb_hcd *hcd); |
| 134 | void xhci_init_driver(struct hc_driver *drv, |
| 135 | -- |
| 136 | 2.18.0 |
| 137 | |