Skip to content

Commit 1ddc5d9

Browse files
committed
Merge branch 'net-ethernet-mediatek-convert-to-PHYLINK'
René van Dorst says: ==================== net: ethernet: mediatek: convert to PHYLINK These patches converts mediatek driver to PHYLINK API. v3->v4: * Phylink improvements and clean-ups after review v2->v3: * Phylink improvements and clean-ups after review v1->v2: * Rebase for mt76x8 changes * Phylink improvements and clean-ups after review * SGMII port doesn't support 2.5Gbit in SGMII mode only in BASE-X mode. Refactor the code. ==================== Signed-off-by: David S. Miller <[email protected]>
2 parents cb6ec97 + bd69baa commit 1ddc5d9

File tree

8 files changed

+470
-292
lines changed

8 files changed

+470
-292
lines changed

Documentation/devicetree/bindings/arm/mediatek/mediatek,sgmiisys.txt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@ Required Properties:
99
- "mediatek,mt7622-sgmiisys", "syscon"
1010
- "mediatek,mt7629-sgmiisys", "syscon"
1111
- #clock-cells: Must be 1
12-
- mediatek,physpeed: Should be one of "auto", "1000" or "2500" to match up
13-
the capability of the target PHY.
1412

1513
The SGMIISYS controller uses the common clk binding from
1614
Documentation/devicetree/bindings/clock/clock-bindings.txt

arch/arm64/boot/dts/mediatek/mt7622-bananapi-bpi-r64.dts

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -115,24 +115,34 @@
115115
};
116116

117117
&eth {
118-
pinctrl-names = "default";
119-
pinctrl-0 = <&eth_pins>;
120118
status = "okay";
119+
gmac0: mac@0 {
120+
compatible = "mediatek,eth-mac";
121+
reg = <0>;
122+
phy-mode = "2500base-x";
123+
124+
fixed-link {
125+
speed = <2500>;
126+
full-duplex;
127+
pause;
128+
};
129+
};
121130

122131
gmac1: mac@1 {
123132
compatible = "mediatek,eth-mac";
124133
reg = <1>;
125-
phy-handle = <&phy5>;
134+
phy-mode = "rgmii";
135+
136+
fixed-link {
137+
speed = <1000>;
138+
full-duplex;
139+
pause;
140+
};
126141
};
127142

128-
mdio-bus {
143+
mdio: mdio-bus {
129144
#address-cells = <1>;
130145
#size-cells = <0>;
131-
132-
phy5: ethernet-phy@5 {
133-
reg = <5>;
134-
phy-mode = "sgmii";
135-
};
136146
};
137147
};
138148

arch/arm64/boot/dts/mediatek/mt7622.dtsi

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -931,6 +931,5 @@
931931
"syscon";
932932
reg = <0 0x1b128000 0 0x3000>;
933933
#clock-cells = <1>;
934-
mediatek,physpeed = "2500";
935934
};
936935
};

drivers/net/ethernet/mediatek/Kconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ if NET_VENDOR_MEDIATEK
99

1010
config NET_MEDIATEK_SOC
1111
tristate "MediaTek SoC Gigabit Ethernet support"
12-
select PHYLIB
12+
select PHYLINK
1313
---help---
1414
This driver supports the gigabit ethernet MACs in the
1515
MediaTek SoC family.

drivers/net/ethernet/mediatek/mtk_eth_path.c

Lines changed: 4 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -239,10 +239,9 @@ static int mtk_eth_mux_setup(struct mtk_eth *eth, int path)
239239
return err;
240240
}
241241

242-
static int mtk_gmac_sgmii_path_setup(struct mtk_eth *eth, int mac_id)
242+
int mtk_gmac_sgmii_path_setup(struct mtk_eth *eth, int mac_id)
243243
{
244-
unsigned int val = 0;
245-
int sid, err, path;
244+
int err, path;
246245

247246
path = (mac_id == 0) ? MTK_ETH_PATH_GMAC1_SGMII :
248247
MTK_ETH_PATH_GMAC2_SGMII;
@@ -252,33 +251,10 @@ static int mtk_gmac_sgmii_path_setup(struct mtk_eth *eth, int mac_id)
252251
if (err)
253252
return err;
254253

255-
/* The path GMAC to SGMII will be enabled once the SGMIISYS is being
256-
* setup done.
257-
*/
258-
regmap_read(eth->ethsys, ETHSYS_SYSCFG0, &val);
259-
260-
regmap_update_bits(eth->ethsys, ETHSYS_SYSCFG0,
261-
SYSCFG0_SGMII_MASK, ~(u32)SYSCFG0_SGMII_MASK);
262-
263-
/* Decide how GMAC and SGMIISYS be mapped */
264-
sid = (MTK_HAS_CAPS(eth->soc->caps, MTK_SHARED_SGMII)) ? 0 : mac_id;
265-
266-
/* Setup SGMIISYS with the determined property */
267-
if (MTK_HAS_FLAGS(eth->sgmii->flags[sid], MTK_SGMII_PHYSPEED_AN))
268-
err = mtk_sgmii_setup_mode_an(eth->sgmii, sid);
269-
else
270-
err = mtk_sgmii_setup_mode_force(eth->sgmii, sid);
271-
272-
if (err)
273-
return err;
274-
275-
regmap_update_bits(eth->ethsys, ETHSYS_SYSCFG0,
276-
SYSCFG0_SGMII_MASK, val);
277-
278254
return 0;
279255
}
280256

281-
static int mtk_gmac_gephy_path_setup(struct mtk_eth *eth, int mac_id)
257+
int mtk_gmac_gephy_path_setup(struct mtk_eth *eth, int mac_id)
282258
{
283259
int err, path = 0;
284260

@@ -296,7 +272,7 @@ static int mtk_gmac_gephy_path_setup(struct mtk_eth *eth, int mac_id)
296272
return 0;
297273
}
298274

299-
static int mtk_gmac_rgmii_path_setup(struct mtk_eth *eth, int mac_id)
275+
int mtk_gmac_rgmii_path_setup(struct mtk_eth *eth, int mac_id)
300276
{
301277
int err, path;
302278

@@ -311,46 +287,3 @@ static int mtk_gmac_rgmii_path_setup(struct mtk_eth *eth, int mac_id)
311287
return 0;
312288
}
313289

314-
int mtk_setup_hw_path(struct mtk_eth *eth, int mac_id, int phymode)
315-
{
316-
int err;
317-
318-
/* No mux'ing for MT7628/88 */
319-
if (MTK_HAS_CAPS(eth->soc->caps, MTK_SOC_MT7628))
320-
return 0;
321-
322-
switch (phymode) {
323-
case PHY_INTERFACE_MODE_TRGMII:
324-
case PHY_INTERFACE_MODE_RGMII_TXID:
325-
case PHY_INTERFACE_MODE_RGMII_RXID:
326-
case PHY_INTERFACE_MODE_RGMII_ID:
327-
case PHY_INTERFACE_MODE_RGMII:
328-
case PHY_INTERFACE_MODE_MII:
329-
case PHY_INTERFACE_MODE_REVMII:
330-
case PHY_INTERFACE_MODE_RMII:
331-
if (MTK_HAS_CAPS(eth->soc->caps, MTK_RGMII)) {
332-
err = mtk_gmac_rgmii_path_setup(eth, mac_id);
333-
if (err)
334-
return err;
335-
}
336-
break;
337-
case PHY_INTERFACE_MODE_SGMII:
338-
if (MTK_HAS_CAPS(eth->soc->caps, MTK_SGMII)) {
339-
err = mtk_gmac_sgmii_path_setup(eth, mac_id);
340-
if (err)
341-
return err;
342-
}
343-
break;
344-
case PHY_INTERFACE_MODE_GMII:
345-
if (MTK_HAS_CAPS(eth->soc->caps, MTK_GEPHY)) {
346-
err = mtk_gmac_gephy_path_setup(eth, mac_id);
347-
if (err)
348-
return err;
349-
}
350-
break;
351-
default:
352-
break;
353-
}
354-
355-
return 0;
356-
}

0 commit comments

Comments
 (0)