Skip to contentSkip to conversation

Add support for MediaTek MT7987/MT7988 built-in 2.5Gb ethernet PHY

PATCH Superseded Weijie Gao 1 participant 5 messages Aug 20, 2025

Subsystems (4)

v1 of 4 Superseded Latest is v4 →

lore
Share & tools
lore

Weijie Gao

author
#0 lore raw

cover Add support for MediaTek MT7987/MT7988 built-in 2.5Gb ethernet PHY

This patch adds PHY driver for MediaTek MT7987/MT7988 built-in 2.5Gb ethernet PHY.

Weijie Gao (4):
net: mediatek: associate PHY device with dts node specified by
phy-handle
net: phy: Add MediaTek built-in 2.5Gb ethernet PHY driver
dt-bindings: mediatek: add doc for MediaTek MT7987/MT7988 2.5Gb
ethernrt PHY
MAINTAINERS: update ethernet-related file list for MediaTek ARM
platform

 MAINTAINERS                                   |   4 +-
 .../net/phy/mediatek,mt798x-i2p5ge-phy.txt    |  60 ++
 drivers/net/mtk_eth/mtk_eth.c                 |   4 +
 drivers/net/phy/Kconfig                       |   2 +
 drivers/net/phy/Makefile                      |   1 +
 drivers/net/phy/mediatek/Kconfig              |  15 +
 drivers/net/phy/mediatek/Makefile             |   4 +
 drivers/net/phy/mediatek/mtk-2p5ge.c          | 586 ++++++++++++++++++
 drivers/net/phy/mediatek/mtk-phy-lib.c        | 106 ++++
 drivers/net/phy/mediatek/mtk.h                | 103 +++
 10 files changed, 883 insertions(+), 2 deletions(-)
 create mode 100644 doc/device-tree-bindings/net/phy/mediatek,mt798x-i2p5ge-phy.txt
 create mode 100644 drivers/net/phy/mediatek/Kconfig
 create mode 100644 drivers/net/phy/mediatek/Makefile
 create mode 100644 drivers/net/phy/mediatek/mtk-2p5ge.c
 create mode 100644 drivers/net/phy/mediatek/mtk-phy-lib.c
 create mode 100644 drivers/net/phy/mediatek/mtk.h
Signature · 1 line
2.34.1
author
#1 lore raw

PATCH 1/4 net: mediatek: associate PHY device with dts node specified by phy-handle

Associate PHY device with its device node specified by phy-handle property. This makes it possible for PHY drivers to read dedicated information to configure the PHY device.

---
 drivers/net/mtk_eth/mtk_eth.c | 4 ++++
 1 file changed, 4 insertions(+)
drivers/net/mtk_eth/mtk_eth.c +4 -0
index 5d6a42bceb4..e91f7b6d176 100644
@@ -100,6 +100,7 @@ struct mtk_eth_priv {
 	bool pn_swap;
 
 	struct phy_device *phydev;
+	ofnode phy_node;
 	int phy_interface;
 	int phy_addr;
 
@@ -572,6 +573,7 @@ static int mtk_phy_probe(struct udevice *dev)
 	if (!phydev)
 		return -ENODEV;
 
+	phydev->node = priv->phy_node;
 	phydev->supported &= PHY_GBIT_FEATURES;
 	phydev->advertising = phydev->supported;
 
@@ -1458,6 +1460,8 @@ static int mtk_eth_of_to_plat(struct udevice *dev)
 			return ret;
 		}
 
+		priv->phy_node = args.node;
+
 		priv->phy_addr = ofnode_read_s32_default(args.node, "reg", -1);
 		if (priv->phy_addr < 0) {
 			printf("error: phy address is not specified\n");
Signature · 1 line
2.34.1
author
#2 lore raw

PATCH 2/4 net: phy: Add MediaTek built-in 2.5Gb ethernet PHY driver

In reply to Weijie Gao

The MediaTek MT7987/MT7988 SoCs features a built-in 2.5Gb PHY connected to GMAC1. The PHY supports 10/100/1000/2500 Mbps full-duplex only.

The PHY requires one or two firmware files. Firmware for MT7988 has already been added to upstream: mediatek/mt7988/i2p5ge-phy-pmb.bin. MT7987 has two firmware files which will be add to upstream later:
i2p5ge-phy-pmb.bin and i2p5ge-phy-DSPBitTb.bin.

This driver currently provides dedicated weak functions to be overridden by board to provide the firmware data:
mt7987_i2p5ge_get_fw() for MT7987 mt7988_i2p5ge_get_fw() for MT7988

---
 drivers/net/phy/Kconfig                |   2 +
 drivers/net/phy/Makefile               |   1 +
 drivers/net/phy/mediatek/Kconfig       |  15 +
 drivers/net/phy/mediatek/Makefile      |   4 +
 drivers/net/phy/mediatek/mtk-2p5ge.c   | 586 +++++++++++++++++++++++++
 drivers/net/phy/mediatek/mtk-phy-lib.c | 106 +++++
 drivers/net/phy/mediatek/mtk.h         | 103 +++++
 7 files changed, 817 insertions(+)
 create mode 100644 drivers/net/phy/mediatek/Kconfig
 create mode 100644 drivers/net/phy/mediatek/Makefile
 create mode 100644 drivers/net/phy/mediatek/mtk-2p5ge.c
 create mode 100644 drivers/net/phy/mediatek/mtk-phy-lib.c
 create mode 100644 drivers/net/phy/mediatek/mtk.h
drivers/net/phy/Kconfig +2 -0
index 21bf983056a..185c6a3156e 100644
@@ -184,6 +184,8 @@ config PHY_MARVELL_10G
 	help
 	  Support for the Marvell Alaska MV88X3310 and compatible PHYs.
 
+source "drivers/net/phy/mediatek/Kconfig"
+
 config PHY_MESON_GXL
 	bool "Amlogic Meson GXL Internal PHY support"
 
drivers/net/phy/Makefile +1 -0
index a119eb5e177..a339b8ac29d 100644
@@ -21,6 +21,7 @@ obj-$(CONFIG_PHY_ET1011C) += et1011c.o
 obj-$(CONFIG_PHY_LXT) += lxt.o
 obj-$(CONFIG_PHY_MARVELL) += marvell.o
 obj-$(CONFIG_PHY_MARVELL_10G) += marvell10g.o
+obj-y += mediatek/
 obj-$(CONFIG_PHY_MICREL_KSZ8XXX) += micrel_ksz8xxx.o
 obj-$(CONFIG_PHY_MICREL_KSZ90X1) += micrel_ksz90x1.o
 obj-$(CONFIG_PHY_MESON_GXL) += meson-gxl.o
drivers/net/phy/mediatek/Kconfig new file +15 -0
new file mode 100644
index 00000000000..16313249373
@@ -0,0 +1,15 @@
+# SPDX-License-Identifier: GPL-2.0-only
+
+config MTK_NET_PHYLIB
+	tristate
+
+config PHY_MEDIATEK_2P5GE
+	tristate "MediaTek built-in 2.5Gb ethernet PHYs"
+	depends on OF_CONTROL && (TARGET_MT7987 || TARGET_MT7988)
+	select MTK_NET_PHYLIB
+	help
+	  Supports MediaTek SoC built-in 2.5Gb ethernet PHYs.
+
+	  This driver requires firmware download for PHY to enable its
+	  functionality. The board must override certian firmware downloading
+	  function to provide the firmware data.
drivers/net/phy/mediatek/Makefile new file +4 -0
new file mode 100644
index 00000000000..bc8dd4e878c
@@ -0,0 +1,4 @@
+# SPDX-License-Identifier: GPL-2.0
+
+obj-$(CONFIG_MTK_NET_PHYLIB)		+= mtk-phy-lib.o
+obj-$(CONFIG_PHY_MEDIATEK_2P5GE)	+= mtk-2p5ge.o
drivers/net/phy/mediatek/mtk-2p5ge.c new file +586 -0

586 lines not on this page · raw message

drivers/net/phy/mediatek/mtk-phy-lib.c new file +106 -0

106 lines not on this page · raw message

drivers/net/phy/mediatek/mtk.h new file +103 -0

103 lines not on this page · raw message

Signature · 1 line
2.34.1
author
#3 lore raw

PATCH 3/4 dt-bindings: mediatek: add doc for MediaTek MT7987/MT7988 2.5Gb ethernrt PHY

In reply to Weijie Gao

The MediaTek MT7987 and MT7988 platforms supports one built-in 2.5Gb ethernet PHY through eth1 interface.

This patch add documentation for configuring these PHYs.

---
 .../net/phy/mediatek,mt798x-i2p5ge-phy.txt    | 60 +++++++++++++++++++
 1 file changed, 60 insertions(+)
 create mode 100644 doc/device-tree-bindings/net/phy/mediatek,mt798x-i2p5ge-phy.txt
doc/device-tree-bindings/net/phy/mediatek,mt798x-i2p5ge-phy.txt new file +60 -0
new file mode 100644
index 00000000000..ebac28d2d9a
@@ -0,0 +1,60 @@
+MediaTek MT7987/MT7988 built-in 2.5Gb Ethernet PHY
+
+This document describes the device tree bindings for MediaTek MT7987/MT7988
+built-in 2.5Gb Ethernet PHY.
+
+Required properties:
+- reg: The phy address
+
+Optional properties:
+- pd-disable: Boolean. PD (Parallel detction) is enabled in this PHY, even
+  though this may cause duplex mismatch for devices supporting only 10M/half
+  or 100M/half. If you are concerned with duplex mismatch, use this option to
+  prevent this built-in PHY to link up with those devices.
+
+- gbe-min-ipg-11-bytes: Boolean. If present, enables 11-byte minimum
+  inter-packet gap for 1000Mbps link speed. When not present (by default),
+  the PHY uses optimized IPG settings for better performance. This option is
+  basically for those legacy 1G link partners which only accept higher IPG
+  transfer.
+
+- auto-downshift-disable: Boolean. If present, disables the hardware
+  auto-downshift feature. When not present (by default), the PHY will
+  automatically downshift link speed when link quality is poor.
+
+- pinctrl-names: Accepts "i2p5gbe-led" pinctrl for PHY status indicator
+
+Notes:
+- Firmware loading is required for proper operation. The driver expects
+  firmware files to be available through weak symbol functions provided by
+  boards.
+
+Examples:
+&eth1 {
+	status = "okay";
+	phy-mode = "xgmii";
+	phy-handle = <&phy15>;
+
+	phy15: ethernet-phy@15 {
+		compatible = "ethernet-phy-ieee802.3-c45";
+		reg = <15>;
+		phy-mode = "xgmii";
+	};
+};
+
+&eth1 {
+	status = "okay";
+	pinctrl-names = "i2p5gbe-led";
+	pinctrl-0 = <&i2p5gbe_led0_pins>;
+	phy-mode = "xgmii";
+	phy-handle = <&phy15>;
+
+	phy15: ethernet-phy@15 {
+		compatible = "ethernet-phy-ieee802.3-c45";
+		reg = <15>;
+		pd-disable;
+		gbe-min-ipg-11-bytes;
+		auto-downshift-disable;
+		phy-mode = "xgmii";
+	};
+};
Signature · 1 line
2.34.1
author
#4 lore raw

PATCH 4/4 MAINTAINERS: update ethernet-related file list for MediaTek ARM platform

In reply to Weijie Gao

Update ethernet-related files for MediaTek ARM platform

---
 MAINTAINERS | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
MAINTAINERS +2 -2
index 3fb163aa1db..065834246de 100644
@@ -423,6 +423,8 @@ F:	drivers/clk/mediatek/
 F:	drivers/cpu/mtk_cpu.c
 F:	drivers/i2c/mtk_i2c.c
 F:	drivers/mmc/mtk-sd.c
+F:	drivers/net/mtk_eth/
+F:	drivers/net/phy/mediatek/
 F:	drivers/phy/phy-mtk-*
 F:	drivers/pinctrl/mediatek/
 F:	drivers/power/domain/mtk-power-domain.c
@@ -437,8 +439,6 @@ F:	drivers/timer/mtk_timer.c
 F:	drivers/usb/host/xhci-mtk.c
 F:	drivers/usb/mtu3/
 F:	drivers/watchdog/mtk_wdt.c
-F:	drivers/net/mtk_eth.c
-F:	drivers/net/mtk_eth.h
 F:	drivers/reset/reset-mediatek.c
 F:	drivers/serial/serial_mtk.c
 F:	include/dt-bindings/clock/mediatek,*
Signature · 1 line
2.34.1