blob: 36362f580008ae37b05599b354d3d74e20852b57 [file] [log] [blame]
developer5db5a612022-10-29 11:48:11 +08001From 3295585b4e77f4a365bd1a4e17d8be6ee504584a Mon Sep 17 00:00:00 2001
developer8cdcb262022-10-27 14:36:15 +08002From: Zhanyong Wang <zhanyong.wang@mediatek.com>
3Date: Sat, 15 Oct 2022 17:38:54 +0800
4Subject: [PATCH 5/8] tphy: one setting of TTSSC-Freq-Dev for all IC cases
5
6try to use one setting of TTSSC-Freq-Dev to covery all IC cases
7
8Signed-off-by: Zhanyong Wang <zhanyong.wang@mediatek.com>
9---
developer5db5a612022-10-29 11:48:11 +080010 drivers/phy/mediatek/phy-mtk-tphy.c | 37 +++++++++++++++++++++++++++++
11 1 file changed, 37 insertions(+)
developer8cdcb262022-10-27 14:36:15 +080012
13diff --git a/drivers/phy/mediatek/phy-mtk-tphy.c b/drivers/phy/mediatek/phy-mtk-tphy.c
developer5db5a612022-10-29 11:48:11 +080014index a5b17a1aed5c..49a2625c1fc1 100644
developer8cdcb262022-10-27 14:36:15 +080015--- 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)
developer5db5a612022-10-29 11:48:11 +080032@@ -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,
developer8cdcb262022-10-27 14:36:15 +080042 tmp |= P3D_RG_RXDET_STB2_SET_P3_VAL(0x10);
43 writel(tmp, u3_banks->phyd + U3P_U3_PHYD_RXDET2);
44
developer5db5a612022-10-29 11:48:11 +080045+ 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+ }
developer8cdcb262022-10-27 14:36:15 +080051+
developer5db5a612022-10-29 11:48:11 +080052+ 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+ }
developer8cdcb262022-10-27 14:36:15 +080058+
59 dev_dbg(tphy->dev, "%s(%d)\n", __func__, instance->index);
60 }
61
developer5db5a612022-10-29 11:48:11 +080062@@ -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
developer8cdcb262022-10-27 14:36:15 +080082--
832.18.0
84