developer | 5d148cb | 2023-06-02 13:08:11 +0800 | [diff] [blame] | 1 | From 9ef2a9d208fba86dfbc06d4f2f743562bd14c145 Mon Sep 17 00:00:00 2001 |
developer | 8cdcb26 | 2022-10-27 14:36:15 +0800 | [diff] [blame] | 2 | From: Sam Shih <sam.shih@mediatek.com> |
developer | 5d148cb | 2023-06-02 13:08:11 +0800 | [diff] [blame] | 3 | Date: Fri, 2 Jun 2023 13:06:26 +0800 |
| 4 | Subject: [PATCH] |
developer | 3de3aca | 2023-06-07 20:44:59 +0800 | [diff] [blame] | 5 | [high-speed-io][999-2620-xHCI-change-compliance-mode-de-emphasis-default-as-g.patch] |
developer | 2cdaeb1 | 2022-10-04 20:25:05 +0800 | [diff] [blame] | 6 | |
developer | 2cdaeb1 | 2022-10-04 20:25:05 +0800 | [diff] [blame] | 7 | --- |
developer | 8cdcb26 | 2022-10-27 14:36:15 +0800 | [diff] [blame] | 8 | drivers/usb/host/xhci-mtk.c | 18 +++++++++++++++++- |
| 9 | drivers/usb/host/xhci-mtk.h | 1 + |
| 10 | 2 files changed, 18 insertions(+), 1 deletion(-) |
developer | 2cdaeb1 | 2022-10-04 20:25:05 +0800 | [diff] [blame] | 11 | |
| 12 | diff --git a/drivers/usb/host/xhci-mtk.c b/drivers/usb/host/xhci-mtk.c |
developer | 5d148cb | 2023-06-02 13:08:11 +0800 | [diff] [blame] | 13 | index 5c0eb35cd..77ddb8c05 100644 |
developer | 2cdaeb1 | 2022-10-04 20:25:05 +0800 | [diff] [blame] | 14 | --- a/drivers/usb/host/xhci-mtk.c |
| 15 | +++ b/drivers/usb/host/xhci-mtk.c |
developer | 8cdcb26 | 2022-10-27 14:36:15 +0800 | [diff] [blame] | 16 | @@ -22,6 +22,11 @@ |
| 17 | #include "xhci.h" |
developer | 2cdaeb1 | 2022-10-04 20:25:05 +0800 | [diff] [blame] | 18 | #include "xhci-mtk.h" |
developer | 2cdaeb1 | 2022-10-04 20:25:05 +0800 | [diff] [blame] | 19 | |
| 20 | +/* COMPLIANCE_CP5_CP7_TXDEEMPH_10G register */ |
| 21 | +#define COMPLIANCE_CP5_CP7_TXDEEMPH_10G 0x2428 |
| 22 | +#define CP5_CP7_TXDEEMPH_10G GENMASK(17, 0) |
| 23 | +#define CP5_CP7_TXDEEMPH_10G_VAL(val) ((val) & 0x03FFFF) |
| 24 | + |
| 25 | /* ip_pw_ctrl0 register */ |
| 26 | #define CTRL0_IP_SW_RST BIT(0) |
| 27 | |
developer | 8cdcb26 | 2022-10-27 14:36:15 +0800 | [diff] [blame] | 28 | @@ -413,6 +418,7 @@ static int xhci_mtk_setup(struct usb_hcd *hcd) |
developer | 2cdaeb1 | 2022-10-04 20:25:05 +0800 | [diff] [blame] | 29 | { |
| 30 | struct xhci_hcd_mtk *mtk = hcd_to_mtk(hcd); |
| 31 | int ret; |
| 32 | + u32 val; |
| 33 | |
| 34 | if (usb_hcd_is_primary_hcd(hcd)) { |
| 35 | ret = xhci_mtk_ssusb_config(mtk); |
developer | 8cdcb26 | 2022-10-27 14:36:15 +0800 | [diff] [blame] | 36 | @@ -430,6 +436,15 @@ static int xhci_mtk_setup(struct usb_hcd *hcd) |
developer | 2cdaeb1 | 2022-10-04 20:25:05 +0800 | [diff] [blame] | 37 | return ret; |
| 38 | } |
| 39 | |
| 40 | + /* change COMPLIANCE_CP5_CP7_TXDEEMPH_10G as Gen1 instead Gen2 */ |
developer | 8cdcb26 | 2022-10-27 14:36:15 +0800 | [diff] [blame] | 41 | + if (mtk->p0_speed_fixup) { |
developer | 2cdaeb1 | 2022-10-04 20:25:05 +0800 | [diff] [blame] | 42 | + val = readl(mtk->hcd->regs + COMPLIANCE_CP5_CP7_TXDEEMPH_10G); |
| 43 | + val &= ~CP5_CP7_TXDEEMPH_10G; |
| 44 | + val |= 0x00001; |
| 45 | + val = CP5_CP7_TXDEEMPH_10G_VAL(val); |
| 46 | + writel(val, mtk->hcd->regs + COMPLIANCE_CP5_CP7_TXDEEMPH_10G); |
| 47 | + } |
| 48 | + |
| 49 | return ret; |
| 50 | } |
| 51 | |
developer | 8cdcb26 | 2022-10-27 14:36:15 +0800 | [diff] [blame] | 52 | @@ -475,7 +490,8 @@ static int xhci_mtk_probe(struct platform_device *pdev) |
| 53 | /* optional property, ignore the error if it does not exist */ |
| 54 | of_property_read_u32(node, "mediatek,u3p-dis-msk", |
| 55 | &mtk->u3p_dis_msk); |
| 56 | - |
| 57 | + mtk->p0_speed_fixup = of_property_read_bool(node, |
| 58 | + "mediatek,p0_speed_fixup"); |
| 59 | ret = usb_wakeup_of_property_parse(mtk, node); |
| 60 | if (ret) { |
| 61 | dev_err(dev, "failed to parse uwk property\n"); |
| 62 | diff --git a/drivers/usb/host/xhci-mtk.h b/drivers/usb/host/xhci-mtk.h |
developer | 5d148cb | 2023-06-02 13:08:11 +0800 | [diff] [blame] | 63 | index 2f702342d..8a884e7b4 100644 |
developer | 8cdcb26 | 2022-10-27 14:36:15 +0800 | [diff] [blame] | 64 | --- a/drivers/usb/host/xhci-mtk.h |
| 65 | +++ b/drivers/usb/host/xhci-mtk.h |
| 66 | @@ -156,6 +156,7 @@ struct xhci_hcd_mtk { |
| 67 | struct regmap *uwk; |
| 68 | u32 uwk_reg_base; |
| 69 | u32 uwk_vers; |
| 70 | + bool p0_speed_fixup; |
| 71 | }; |
| 72 | |
| 73 | static inline struct xhci_hcd_mtk *hcd_to_mtk(struct usb_hcd *hcd) |
developer | 2cdaeb1 | 2022-10-04 20:25:05 +0800 | [diff] [blame] | 74 | -- |
developer | 5d148cb | 2023-06-02 13:08:11 +0800 | [diff] [blame] | 75 | 2.34.1 |
developer | 2cdaeb1 | 2022-10-04 20:25:05 +0800 | [diff] [blame] | 76 | |