developer | 8cbed67 | 2022-10-27 14:36:15 +0800 | [diff] [blame^] | 1 | From 0df9413c8ff0df4ed69b6e1577d7cd5fd2d72e5e Mon Sep 17 00:00:00 2001 |
| 2 | From: Sam Shih <sam.shih@mediatek.com> |
| 3 | Date: Tue, 25 Oct 2022 18:25:25 +0800 |
| 4 | Subject: [PATCH 1/3] xHCI: change compliance mode de-emphasis default as gen1 |
developer | 2d27fb1 | 2022-10-04 20:25:05 +0800 | [diff] [blame] | 5 | |
| 6 | Port0 is using Gen2 Phy for 10GHz, and Port0 is running |
| 7 | on 5GHz actually. hence to change compliance mode de- |
| 8 | emphasis default as Gen1. |
| 9 | |
| 10 | Signed-off-by: Zhanyong Wang <zhanyong.wang@mediatek.com> |
developer | 8cbed67 | 2022-10-27 14:36:15 +0800 | [diff] [blame^] | 11 | Signed-off-by: Sam Shih <sam.shih@mediatek.com> |
developer | 2d27fb1 | 2022-10-04 20:25:05 +0800 | [diff] [blame] | 12 | --- |
developer | 8cbed67 | 2022-10-27 14:36:15 +0800 | [diff] [blame^] | 13 | drivers/usb/host/xhci-mtk.c | 18 +++++++++++++++++- |
| 14 | drivers/usb/host/xhci-mtk.h | 1 + |
| 15 | 2 files changed, 18 insertions(+), 1 deletion(-) |
developer | 2d27fb1 | 2022-10-04 20:25:05 +0800 | [diff] [blame] | 16 | |
| 17 | diff --git a/drivers/usb/host/xhci-mtk.c b/drivers/usb/host/xhci-mtk.c |
developer | 8cbed67 | 2022-10-27 14:36:15 +0800 | [diff] [blame^] | 18 | index 5c0eb35cd007..77ddb8c05500 100644 |
developer | 2d27fb1 | 2022-10-04 20:25:05 +0800 | [diff] [blame] | 19 | --- a/drivers/usb/host/xhci-mtk.c |
| 20 | +++ b/drivers/usb/host/xhci-mtk.c |
developer | 8cbed67 | 2022-10-27 14:36:15 +0800 | [diff] [blame^] | 21 | @@ -22,6 +22,11 @@ |
| 22 | #include "xhci.h" |
developer | 2d27fb1 | 2022-10-04 20:25:05 +0800 | [diff] [blame] | 23 | #include "xhci-mtk.h" |
developer | 2d27fb1 | 2022-10-04 20:25:05 +0800 | [diff] [blame] | 24 | |
| 25 | +/* COMPLIANCE_CP5_CP7_TXDEEMPH_10G register */ |
| 26 | +#define COMPLIANCE_CP5_CP7_TXDEEMPH_10G 0x2428 |
| 27 | +#define CP5_CP7_TXDEEMPH_10G GENMASK(17, 0) |
| 28 | +#define CP5_CP7_TXDEEMPH_10G_VAL(val) ((val) & 0x03FFFF) |
| 29 | + |
| 30 | /* ip_pw_ctrl0 register */ |
| 31 | #define CTRL0_IP_SW_RST BIT(0) |
| 32 | |
developer | 8cbed67 | 2022-10-27 14:36:15 +0800 | [diff] [blame^] | 33 | @@ -413,6 +418,7 @@ static int xhci_mtk_setup(struct usb_hcd *hcd) |
developer | 2d27fb1 | 2022-10-04 20:25:05 +0800 | [diff] [blame] | 34 | { |
| 35 | struct xhci_hcd_mtk *mtk = hcd_to_mtk(hcd); |
| 36 | int ret; |
| 37 | + u32 val; |
| 38 | |
| 39 | if (usb_hcd_is_primary_hcd(hcd)) { |
| 40 | ret = xhci_mtk_ssusb_config(mtk); |
developer | 8cbed67 | 2022-10-27 14:36:15 +0800 | [diff] [blame^] | 41 | @@ -430,6 +436,15 @@ static int xhci_mtk_setup(struct usb_hcd *hcd) |
developer | 2d27fb1 | 2022-10-04 20:25:05 +0800 | [diff] [blame] | 42 | return ret; |
| 43 | } |
| 44 | |
| 45 | + /* change COMPLIANCE_CP5_CP7_TXDEEMPH_10G as Gen1 instead Gen2 */ |
developer | 8cbed67 | 2022-10-27 14:36:15 +0800 | [diff] [blame^] | 46 | + if (mtk->p0_speed_fixup) { |
developer | 2d27fb1 | 2022-10-04 20:25:05 +0800 | [diff] [blame] | 47 | + val = readl(mtk->hcd->regs + COMPLIANCE_CP5_CP7_TXDEEMPH_10G); |
| 48 | + val &= ~CP5_CP7_TXDEEMPH_10G; |
| 49 | + val |= 0x00001; |
| 50 | + val = CP5_CP7_TXDEEMPH_10G_VAL(val); |
| 51 | + writel(val, mtk->hcd->regs + COMPLIANCE_CP5_CP7_TXDEEMPH_10G); |
| 52 | + } |
| 53 | + |
| 54 | return ret; |
| 55 | } |
| 56 | |
developer | 8cbed67 | 2022-10-27 14:36:15 +0800 | [diff] [blame^] | 57 | @@ -475,7 +490,8 @@ static int xhci_mtk_probe(struct platform_device *pdev) |
| 58 | /* optional property, ignore the error if it does not exist */ |
| 59 | of_property_read_u32(node, "mediatek,u3p-dis-msk", |
| 60 | &mtk->u3p_dis_msk); |
| 61 | - |
| 62 | + mtk->p0_speed_fixup = of_property_read_bool(node, |
| 63 | + "mediatek,p0_speed_fixup"); |
| 64 | ret = usb_wakeup_of_property_parse(mtk, node); |
| 65 | if (ret) { |
| 66 | dev_err(dev, "failed to parse uwk property\n"); |
| 67 | diff --git a/drivers/usb/host/xhci-mtk.h b/drivers/usb/host/xhci-mtk.h |
| 68 | index 2f702342de66..8a884e7b481b 100644 |
| 69 | --- a/drivers/usb/host/xhci-mtk.h |
| 70 | +++ b/drivers/usb/host/xhci-mtk.h |
| 71 | @@ -156,6 +156,7 @@ struct xhci_hcd_mtk { |
| 72 | struct regmap *uwk; |
| 73 | u32 uwk_reg_base; |
| 74 | u32 uwk_vers; |
| 75 | + bool p0_speed_fixup; |
| 76 | }; |
| 77 | |
| 78 | static inline struct xhci_hcd_mtk *hcd_to_mtk(struct usb_hcd *hcd) |
developer | 2d27fb1 | 2022-10-04 20:25:05 +0800 | [diff] [blame] | 79 | -- |
| 80 | 2.18.0 |
| 81 | |