Skip to content

Commit 3c54ede

Browse files
dangowrtfrank-w
authored andcommitted
net: ethernet: mtk_eth_soc: add paths and SerDes modes for MT7988
MT7988 comes with a built-in 2.5G PHY as well as SerDes lanes to connect external PHYs or transceivers in USXGMII, 10GBase-R, 5GBase-R, 2500Base-X, 1000Base-X and Cisco SGMII interface modes. Implement support for configuring for the new paths to SerDes interfaces and the internal 2.5G PHY. Add USXGMII PCS driver for 10GBase-R, 5GBase-R and USXGMII mode, and setup the new PHYA on MT7988 to access the also still existing old LynxI PCS for 1000Base-X, 2500Base-X and Cisco SGMII PCS interface modes. Signed-off-by: Daniel Golle <daniel@makrotopia.org>
1 parent ed2c7e0 commit 3c54ede

3 files changed

Lines changed: 437 additions & 42 deletions

File tree

drivers/net/ethernet/mediatek/mtk_eth_path.c

Lines changed: 118 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,20 @@ static const char *mtk_eth_path_name(u64 path)
3131
return "gmac2_rgmii";
3232
case MTK_ETH_PATH_GMAC2_SGMII:
3333
return "gmac2_sgmii";
34+
case MTK_ETH_PATH_GMAC2_2P5GPHY:
35+
return "gmac2_2p5gphy";
3436
case MTK_ETH_PATH_GMAC2_GEPHY:
3537
return "gmac2_gephy";
38+
case MTK_ETH_PATH_GMAC3_SGMII:
39+
return "gmac3_sgmii";
3640
case MTK_ETH_PATH_GDM1_ESW:
3741
return "gdm1_esw";
42+
case MTK_ETH_PATH_GMAC1_USXGMII:
43+
return "gmac1_usxgmii";
44+
case MTK_ETH_PATH_GMAC2_USXGMII:
45+
return "gmac2_usxgmii";
46+
case MTK_ETH_PATH_GMAC3_USXGMII:
47+
return "gmac3_usxgmii";
3848
default:
3949
return "unknown path";
4050
}
@@ -127,6 +137,27 @@ static int set_mux_u3_gmac2_to_qphy(struct mtk_eth *eth, u64 path)
127137
return 0;
128138
}
129139

140+
static int set_mux_gmac2_to_2p5gphy(struct mtk_eth *eth, u64 path)
141+
{
142+
int ret;
143+
144+
if (path == MTK_ETH_PATH_GMAC2_2P5GPHY) {
145+
ret = regmap_clear_bits(eth->ethsys, ETHSYS_SYSCFG0, SYSCFG0_SGMII_GMAC2_V2);
146+
if (ret)
147+
return ret;
148+
149+
/* Setup mux to 2p5g PHY */
150+
ret = regmap_clear_bits(eth->infra, TOP_MISC_NETSYS_PCS_MUX, MUX_G2_USXGMII_SEL);
151+
if (ret)
152+
return ret;
153+
154+
dev_dbg(eth->dev, "path %s in %s updated\n",
155+
mtk_eth_path_name(path), __func__);
156+
}
157+
158+
return 0;
159+
}
160+
130161
static int set_mux_gmac1_gmac2_to_sgmii_rgmii(struct mtk_eth *eth, u64 path)
131162
{
132163
unsigned int val = 0;
@@ -165,7 +196,48 @@ static int set_mux_gmac1_gmac2_to_sgmii_rgmii(struct mtk_eth *eth, u64 path)
165196
return 0;
166197
}
167198

168-
static int set_mux_gmac12_to_gephy_sgmii(struct mtk_eth *eth, u64 path)
199+
static int set_mux_gmac123_to_usxgmii(struct mtk_eth *eth, u64 path)
200+
{
201+
unsigned int val = 0;
202+
bool updated = true;
203+
int mac_id = 0;
204+
205+
/* Disable SYSCFG1 SGMII */
206+
regmap_read(eth->ethsys, ETHSYS_SYSCFG0, &val);
207+
208+
switch (path) {
209+
case MTK_ETH_PATH_GMAC1_USXGMII:
210+
val &= ~(u32)SYSCFG0_SGMII_GMAC1_V2;
211+
mac_id = MTK_GMAC1_ID;
212+
break;
213+
case MTK_ETH_PATH_GMAC2_USXGMII:
214+
val &= ~(u32)SYSCFG0_SGMII_GMAC2_V2;
215+
mac_id = MTK_GMAC2_ID;
216+
break;
217+
case MTK_ETH_PATH_GMAC3_USXGMII:
218+
val &= ~(u32)SYSCFG0_SGMII_GMAC3_V2;
219+
mac_id = MTK_GMAC3_ID;
220+
break;
221+
default:
222+
updated = false;
223+
};
224+
225+
if (updated) {
226+
regmap_update_bits(eth->ethsys, ETHSYS_SYSCFG0,
227+
SYSCFG0_SGMII_MASK, val);
228+
229+
if (mac_id == MTK_GMAC2_ID)
230+
regmap_set_bits(eth->infra, TOP_MISC_NETSYS_PCS_MUX,
231+
MUX_G2_USXGMII_SEL);
232+
}
233+
234+
dev_dbg(eth->dev, "path %s in %s updated = %d\n",
235+
mtk_eth_path_name(path), __func__, updated);
236+
237+
return 0;
238+
}
239+
240+
static int set_mux_gmac123_to_gephy_sgmii(struct mtk_eth *eth, u64 path)
169241
{
170242
unsigned int val = 0;
171243
bool updated = true;
@@ -182,6 +254,9 @@ static int set_mux_gmac12_to_gephy_sgmii(struct mtk_eth *eth, u64 path)
182254
case MTK_ETH_PATH_GMAC2_SGMII:
183255
val |= SYSCFG0_SGMII_GMAC2_V2;
184256
break;
257+
case MTK_ETH_PATH_GMAC3_SGMII:
258+
val |= SYSCFG0_SGMII_GMAC3_V2;
259+
break;
185260
default:
186261
updated = false;
187262
}
@@ -209,14 +284,26 @@ static const struct mtk_eth_muxc mtk_eth_muxc[] = {
209284
.name = "mux_u3_gmac2_to_qphy",
210285
.cap_bit = MTK_ETH_MUX_U3_GMAC2_TO_QPHY,
211286
.set_path = set_mux_u3_gmac2_to_qphy,
287+
}, {
288+
.name = "mux_gmac2_to_2p5gphy",
289+
.cap_bit = MTK_ETH_MUX_GMAC2_TO_2P5GPHY,
290+
.set_path = set_mux_gmac2_to_2p5gphy,
212291
}, {
213292
.name = "mux_gmac1_gmac2_to_sgmii_rgmii",
214293
.cap_bit = MTK_ETH_MUX_GMAC1_GMAC2_TO_SGMII_RGMII,
215294
.set_path = set_mux_gmac1_gmac2_to_sgmii_rgmii,
216295
}, {
217296
.name = "mux_gmac12_to_gephy_sgmii",
218297
.cap_bit = MTK_ETH_MUX_GMAC12_TO_GEPHY_SGMII,
219-
.set_path = set_mux_gmac12_to_gephy_sgmii,
298+
.set_path = set_mux_gmac123_to_gephy_sgmii,
299+
}, {
300+
.name = "mux_gmac123_to_gephy_sgmii",
301+
.cap_bit = MTK_ETH_MUX_GMAC123_TO_GEPHY_SGMII,
302+
.set_path = set_mux_gmac123_to_gephy_sgmii,
303+
}, {
304+
.name = "mux_gmac123_to_usxgmii",
305+
.cap_bit = MTK_ETH_MUX_GMAC123_TO_USXGMII,
306+
.set_path = set_mux_gmac123_to_usxgmii,
220307
},
221308
};
222309

@@ -249,12 +336,39 @@ static int mtk_eth_mux_setup(struct mtk_eth *eth, u64 path)
249336
return err;
250337
}
251338

339+
int mtk_gmac_usxgmii_path_setup(struct mtk_eth *eth, int mac_id)
340+
{
341+
u64 path;
342+
343+
path = (mac_id == MTK_GMAC1_ID) ? MTK_ETH_PATH_GMAC1_USXGMII :
344+
(mac_id == MTK_GMAC2_ID) ? MTK_ETH_PATH_GMAC2_USXGMII :
345+
MTK_ETH_PATH_GMAC3_USXGMII;
346+
347+
/* Setup proper MUXes along the path */
348+
return mtk_eth_mux_setup(eth, path);
349+
}
350+
252351
int mtk_gmac_sgmii_path_setup(struct mtk_eth *eth, int mac_id)
253352
{
254353
u64 path;
255354

256-
path = (mac_id == 0) ? MTK_ETH_PATH_GMAC1_SGMII :
257-
MTK_ETH_PATH_GMAC2_SGMII;
355+
path = (mac_id == MTK_GMAC1_ID) ? MTK_ETH_PATH_GMAC1_SGMII :
356+
(mac_id == MTK_GMAC2_ID) ? MTK_ETH_PATH_GMAC2_SGMII :
357+
MTK_ETH_PATH_GMAC3_SGMII;
358+
359+
/* Setup proper MUXes along the path */
360+
return mtk_eth_mux_setup(eth, path);
361+
}
362+
363+
int mtk_gmac_2p5gphy_path_setup(struct mtk_eth *eth, int mac_id)
364+
{
365+
u64 path = 0;
366+
367+
if (mac_id == MTK_GMAC2_ID)
368+
path = MTK_ETH_PATH_GMAC2_2P5GPHY;
369+
370+
if (!path)
371+
return -EINVAL;
258372

259373
/* Setup proper MUXes along the path */
260374
return mtk_eth_mux_setup(eth, path);

0 commit comments

Comments
 (0)