blob: 64e68c38d195ddd3e6b4e15ba28e5c8453ee2f9d [file] [log] [blame]
developer5d148cb2023-06-02 13:08:11 +08001From 0e03f2c1ade35e8d40c87425414d0a6ccef0439c Mon Sep 17 00:00:00 2001
2From: Sam Shih <sam.shih@mediatek.com>
3Date: Fri, 2 Jun 2023 13:06:25 +0800
4Subject: [PATCH]
5 [high-speed-io][999-2613-phy-phy-mtk-tphy-add-auto-load-valid-check-mechanism.patch]
developer44e1bbf2022-01-28 17:20:00 +08006
developer44e1bbf2022-01-28 17:20:00 +08007---
8 drivers/phy/mediatek/phy-mtk-tphy.c | 67 +++++++++++++++++++++++++++--
9 1 file changed, 64 insertions(+), 3 deletions(-)
10
11diff --git a/drivers/phy/mediatek/phy-mtk-tphy.c b/drivers/phy/mediatek/phy-mtk-tphy.c
developer5d148cb2023-06-02 13:08:11 +080012index 6c07885be..149464f37 100644
developer44e1bbf2022-01-28 17:20:00 +080013--- a/drivers/phy/mediatek/phy-mtk-tphy.c
14+++ b/drivers/phy/mediatek/phy-mtk-tphy.c
developer5d148cb2023-06-02 13:08:11 +080015@@ -359,9 +359,13 @@ struct mtk_phy_instance {
developer44e1bbf2022-01-28 17:20:00 +080016 };
17 struct clk *ref_clk; /* reference clock of anolog phy */
18 u32 efuse_sw_en;
19+ bool efuse_alv_en;
20+ u32 efuse_autoloadvalid;
21 u32 efuse_intr;
22 u32 efuse_tx_imp;
23 u32 efuse_rx_imp;
24+ bool efuse_alv_ln1_en;
25+ u32 efuse_ln1_autoloadvalid;
26 u32 efuse_intr_ln1;
27 u32 efuse_tx_imp_ln1;
28 u32 efuse_rx_imp_ln1;
developer5d148cb2023-06-02 13:08:11 +080029@@ -1060,6 +1064,7 @@ static int phy_efuse_get(struct mtk_tphy *tphy, struct mtk_phy_instance *instanc
developer44e1bbf2022-01-28 17:20:00 +080030 {
31 struct device *dev = &instance->phy->dev;
32 int ret = 0;
33+ bool alv = false;
34
35 dev_err(dev, "try to get sw efuse\n");
36
developer5d148cb2023-06-02 13:08:11 +080037@@ -1078,6 +1083,20 @@ static int phy_efuse_get(struct mtk_tphy *tphy, struct mtk_phy_instance *instanc
developer44e1bbf2022-01-28 17:20:00 +080038
39 switch (instance->type) {
40 case PHY_TYPE_USB2:
41+ alv = of_property_read_bool(dev->of_node, "auto_load_valid");
42+ if (alv) {
43+ instance->efuse_alv_en = alv;
44+ ret = nvmem_cell_read_variable_le_u32(dev, "auto_load_valid",
45+ &instance->efuse_autoloadvalid);
46+ if (ret) {
47+ dev_err(dev, "fail to get u2 alv efuse, %d\n", ret);
48+ break;
49+ }
50+ dev_info(dev,
51+ "u2 auto load valid efuse: ENABLE with value: %u\n",
52+ instance->efuse_autoloadvalid);
53+ }
54+
55 ret = nvmem_cell_read_variable_le_u32(dev, "intr", &instance->efuse_intr);
56 if (ret) {
57 dev_err(dev, "fail to get u2 intr efuse, %d\n", ret);
developer5d148cb2023-06-02 13:08:11 +080058@@ -1095,6 +1114,20 @@ static int phy_efuse_get(struct mtk_tphy *tphy, struct mtk_phy_instance *instanc
developer44e1bbf2022-01-28 17:20:00 +080059 break;
60 case PHY_TYPE_USB3:
61 case PHY_TYPE_PCIE:
62+ alv = of_property_read_bool(dev->of_node, "auto_load_valid");
63+ if (alv) {
64+ instance->efuse_alv_en = alv;
65+ ret = nvmem_cell_read_variable_le_u32(dev, "auto_load_valid",
66+ &instance->efuse_autoloadvalid);
67+ if (ret) {
68+ dev_err(dev, "fail to get u3(pcei) alv efuse, %d\n", ret);
69+ break;
70+ }
71+ dev_info(dev,
72+ "u3 auto load valid efuse: ENABLE with value: %u\n",
73+ instance->efuse_autoloadvalid);
74+ }
75+
76 ret = nvmem_cell_read_variable_le_u32(dev, "intr", &instance->efuse_intr);
77 if (ret) {
78 dev_err(dev, "fail to get u3 intr efuse, %d\n", ret);
developer5d148cb2023-06-02 13:08:11 +080079@@ -1129,6 +1162,20 @@ static int phy_efuse_get(struct mtk_tphy *tphy, struct mtk_phy_instance *instanc
developer44e1bbf2022-01-28 17:20:00 +080080 if (tphy->pdata->version != MTK_PHY_V4)
81 break;
82
83+ alv = of_property_read_bool(dev->of_node, "auto_load_valid_ln1");
84+ if (alv) {
85+ instance->efuse_alv_ln1_en = alv;
86+ ret = nvmem_cell_read_variable_le_u32(dev, "auto_load_valid_ln1",
87+ &instance->efuse_ln1_autoloadvalid);
88+ if (ret) {
89+ dev_err(dev, "fail to get pcie auto_load_valid efuse, %d\n", ret);
90+ break;
91+ }
92+ dev_info(dev,
93+ "pcie auto load valid efuse: ENABLE with value: %u\n",
94+ instance->efuse_ln1_autoloadvalid);
95+ }
96+
97 ret = nvmem_cell_read_variable_le_u32(dev, "intr_ln1", &instance->efuse_intr_ln1);
98 if (ret) {
99 dev_err(dev, "fail to get u3 lane1 intr efuse, %d\n", ret);
developer5d148cb2023-06-02 13:08:11 +0800100@@ -1180,6 +1227,10 @@ static void phy_efuse_set(struct mtk_phy_instance *instance)
developer44e1bbf2022-01-28 17:20:00 +0800101
102 switch (instance->type) {
103 case PHY_TYPE_USB2:
104+ if (instance->efuse_alv_en &&
105+ instance->efuse_autoloadvalid == 1)
106+ break;
107+
108 tmp = readl(u2_banks->misc + U3P_MISC_REG1);
109 tmp |= MR1_EFUSE_AUTO_LOAD_DIS;
110 writel(tmp, u2_banks->misc + U3P_MISC_REG1);
developer5d148cb2023-06-02 13:08:11 +0800111@@ -1192,6 +1243,10 @@ static void phy_efuse_set(struct mtk_phy_instance *instance)
developer44e1bbf2022-01-28 17:20:00 +0800112
113 break;
114 case PHY_TYPE_USB3:
115+ if (instance->efuse_alv_en &&
116+ instance->efuse_autoloadvalid == 1)
117+ break;
118+
119 tmp = readl(u3_banks->phyd + U3P_U3_PHYD_RSV);
120 tmp |= P3D_RG_EFUSE_AUTO_LOAD_DIS;
121 writel(tmp, u3_banks->phyd + U3P_U3_PHYD_RSV);
developer5d148cb2023-06-02 13:08:11 +0800122@@ -1218,6 +1273,10 @@ static void phy_efuse_set(struct mtk_phy_instance *instance)
developer44e1bbf2022-01-28 17:20:00 +0800123
124 break;
125 case PHY_TYPE_PCIE:
126+ if (instance->efuse_alv_en &&
127+ instance->efuse_autoloadvalid == 1)
128+ break;
129+
130 tmp = readl(u3_banks->phyd + U3P_U3_PHYD_RSV);
131 tmp |= P3D_RG_EFUSE_AUTO_LOAD_DIS;
132 writel(tmp, u3_banks->phyd + U3P_U3_PHYD_RSV);
developer5d148cb2023-06-02 13:08:11 +0800133@@ -1242,9 +1301,11 @@ static void phy_efuse_set(struct mtk_phy_instance *instance)
developer44e1bbf2022-01-28 17:20:00 +0800134 __func__, instance->efuse_tx_imp,
135 instance->efuse_rx_imp, instance->efuse_intr);
136
137- if (!instance->efuse_intr_ln1 &&
138- !instance->efuse_rx_imp_ln1 &&
139- !instance->efuse_tx_imp_ln1)
140+ if ((!instance->efuse_intr_ln1 &&
141+ !instance->efuse_rx_imp_ln1 &&
142+ !instance->efuse_tx_imp_ln1) ||
143+ (instance->efuse_alv_ln1_en &&
144+ instance->efuse_ln1_autoloadvalid == 1))
145 break;
146
147 tmp = readl(u3_banks->phyd + SSUSB_LN1_OFFSET + U3P_U3_PHYD_RSV);
148--
developer5d148cb2023-06-02 13:08:11 +08001492.34.1
developer44e1bbf2022-01-28 17:20:00 +0800150