developer | 5db5a61 | 2022-10-29 11:48:11 +0800 | [diff] [blame] | 1 | From 3295585b4e77f4a365bd1a4e17d8be6ee504584a Mon Sep 17 00:00:00 2001 |
developer | 8cdcb26 | 2022-10-27 14:36:15 +0800 | [diff] [blame] | 2 | From: Zhanyong Wang <zhanyong.wang@mediatek.com> |
| 3 | Date: Sat, 15 Oct 2022 17:38:54 +0800 |
| 4 | Subject: [PATCH 5/8] tphy: one setting of TTSSC-Freq-Dev for all IC cases |
| 5 | |
| 6 | try to use one setting of TTSSC-Freq-Dev to covery all IC cases |
| 7 | |
| 8 | Signed-off-by: Zhanyong Wang <zhanyong.wang@mediatek.com> |
| 9 | --- |
developer | 5db5a61 | 2022-10-29 11:48:11 +0800 | [diff] [blame] | 10 | drivers/phy/mediatek/phy-mtk-tphy.c | 37 +++++++++++++++++++++++++++++ |
| 11 | 1 file changed, 37 insertions(+) |
developer | 8cdcb26 | 2022-10-27 14:36:15 +0800 | [diff] [blame] | 12 | |
| 13 | diff --git a/drivers/phy/mediatek/phy-mtk-tphy.c b/drivers/phy/mediatek/phy-mtk-tphy.c |
developer | 5db5a61 | 2022-10-29 11:48:11 +0800 | [diff] [blame] | 14 | index a5b17a1aed5c..49a2625c1fc1 100644 |
developer | 8cdcb26 | 2022-10-27 14:36:15 +0800 | [diff] [blame] | 15 | --- a/drivers/phy/mediatek/phy-mtk-tphy.c |
| 16 | +++ b/drivers/phy/mediatek/phy-mtk-tphy.c |
| 17 | @@ -219,6 +219,14 @@ |
| 18 | #define P3D_RG_RXDET_STB2_SET_P3 GENMASK(8, 0) |
| 19 | #define P3D_RG_RXDET_STB2_SET_P3_VAL(x) (0x1ff & (x)) |
| 20 | |
| 21 | +#define U3P_U3_PHYD_REG19 0x338 |
| 22 | +#define P3D_RG_PLL_SSC_DELTA1 GENMASK(15, 0) |
| 23 | +#define P3D_RG_PLL_SSC_DELTA1_VAL(x) (0xffff & (x)) |
| 24 | + |
| 25 | +#define U3P_U3_PHYD_REG21 0x340 |
| 26 | +#define P3D_RG_PLL_SSC_DELTA GENMASK(31, 16) |
| 27 | +#define P3D_RG_PLL_SSC_DELTA_VAL(x) ((0xffff & (x)) << 16) |
| 28 | + |
| 29 | #define U3P_SPLLC_XTALCTL3 0x018 |
| 30 | #define XC3_RG_U3_XTAL_RX_PWD BIT(9) |
| 31 | #define XC3_RG_U3_FRC_XTAL_RX_PWD BIT(8) |
developer | 5db5a61 | 2022-10-29 11:48:11 +0800 | [diff] [blame] | 32 | @@ -373,6 +381,8 @@ struct mtk_phy_instance { |
| 33 | int eye_vrt; |
| 34 | int eye_term; |
| 35 | bool bc12_en; |
| 36 | + bool u3_pll_ssc_delta; |
| 37 | + bool u3_pll_ssc_delta1; |
| 38 | }; |
| 39 | |
| 40 | struct mtk_tphy { |
| 41 | @@ -514,6 +524,20 @@ static void u3_phy_instance_init(struct mtk_tphy *tphy, |
developer | 8cdcb26 | 2022-10-27 14:36:15 +0800 | [diff] [blame] | 42 | tmp |= P3D_RG_RXDET_STB2_SET_P3_VAL(0x10); |
| 43 | writel(tmp, u3_banks->phyd + U3P_U3_PHYD_RXDET2); |
| 44 | |
developer | 5db5a61 | 2022-10-29 11:48:11 +0800 | [diff] [blame] | 45 | + if (instance->u3_pll_ssc_delta1) { |
| 46 | + tmp = readl(u3_banks->phyd + U3P_U3_PHYD_REG19); |
| 47 | + tmp &= ~P3D_RG_PLL_SSC_DELTA1; |
| 48 | + tmp |= P3D_RG_PLL_SSC_DELTA1_VAL(0x1c3); |
| 49 | + writel(tmp, u3_banks->phyd + U3P_U3_PHYD_REG19); |
| 50 | + } |
developer | 8cdcb26 | 2022-10-27 14:36:15 +0800 | [diff] [blame] | 51 | + |
developer | 5db5a61 | 2022-10-29 11:48:11 +0800 | [diff] [blame] | 52 | + if (instance->u3_pll_ssc_delta) { |
| 53 | + tmp = readl(u3_banks->phyd + U3P_U3_PHYD_REG21); |
| 54 | + tmp &= ~P3D_RG_PLL_SSC_DELTA; |
| 55 | + tmp |= P3D_RG_PLL_SSC_DELTA_VAL(0x1c3); |
| 56 | + writel(tmp, u3_banks->phyd + U3P_U3_PHYD_REG21); |
| 57 | + } |
developer | 8cdcb26 | 2022-10-27 14:36:15 +0800 | [diff] [blame] | 58 | + |
| 59 | dev_dbg(tphy->dev, "%s(%d)\n", __func__, instance->index); |
| 60 | } |
| 61 | |
developer | 5db5a61 | 2022-10-29 11:48:11 +0800 | [diff] [blame] | 62 | @@ -942,6 +966,19 @@ static void phy_parse_property(struct mtk_tphy *tphy, |
| 63 | { |
| 64 | struct device *dev = &instance->phy->dev; |
| 65 | |
| 66 | + if (instance->type == PHY_TYPE_USB3) { |
| 67 | + instance->u3_pll_ssc_delta = |
| 68 | + device_property_read_bool(dev, |
| 69 | + "mediatek,usb3-pll-ssc-delta"); |
| 70 | + instance->u3_pll_ssc_delta1 = |
| 71 | + device_property_read_bool(dev, |
| 72 | + "mediatek,usb3-pll-ssc-delta1"); |
| 73 | + |
| 74 | + dev_dbg(dev, "u3_pll_ssc_delta:%i, u3_pll_ssc_delta1:%i\n", |
| 75 | + instance->u3_pll_ssc_delta, |
| 76 | + instance->u3_pll_ssc_delta1); |
| 77 | + } |
| 78 | + |
| 79 | if (instance->type != PHY_TYPE_USB2) |
| 80 | return; |
| 81 | |
developer | 8cdcb26 | 2022-10-27 14:36:15 +0800 | [diff] [blame] | 82 | -- |
| 83 | 2.18.0 |
| 84 | |