Skip to contentSkip to conversation

net: phy: add driver for MediaTek SoC built-in GE PHYs

PATCH Applied Daniel Golle 4 participants 4 messages Jun 10, 2023 – Jun 13, 2023

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH v5 1/1 net: phy: add driver for MediaTek SoC built-in GE PHYs

Some of MediaTek's Filogic SoCs come with built-in gigabit Ethernet PHYs which require calibration data from the SoC's efuse. Despite the similar design the driver doesn't share any code with the existing mediatek-ge.c.
Add support for such PHYs by introducing a new driver with basic support for MediaTek SoCs MT7981 and MT7988 built-in 1GE PHYs.

---
Changes since v4:
* completely drop LED intialization for now, reduce to bare minimal working driver

Changes since v3:
* fix spelling and reverse xmas tree
* add dt-binding for mediatek,boottrap

Changes since v2:
* remove everything related to PHY LEDs for now, LED support will be cleaned up and submitted once PHY LED framework is more ready

Changes since v1:
* split-off SoC-specific driver from mediatek-ge.c as requested
* address comments made by Heiner Kallweit
* add pinctrl handling for PHY LED
* remove calibration details not needed in production hardware

 MAINTAINERS                       |    9 +
 drivers/net/phy/Kconfig           |   12 +
 drivers/net/phy/Makefile          |    1 +
 drivers/net/phy/mediatek-ge-soc.c | 1116 +++++++++++++++++++++++++++++
 drivers/net/phy/mediatek-ge.c     |    3 +-
 5 files changed, 1140 insertions(+), 1 deletion(-)
 create mode 100644 drivers/net/phy/mediatek-ge-soc.c
MAINTAINERS +9 -0
index 0971854323a7e..45787f1c4c575 100644
@@ -13151,6 +13151,15 @@ S:	Maintained
 F:	drivers/net/pcs/pcs-mtk-lynxi.c
 F:	include/linux/pcs/pcs-mtk-lynxi.h
 
+MEDIATEK ETHERNET PHY DRIVERS
+M:	Daniel Golle <[email protected]>
+M:	Qingfang Deng <[email protected]>
+M:	SkyLake Huang <[email protected]>
+L:	[email protected]
+S:	Maintained
+F:	drivers/net/phy/mediatek-ge-soc.c
+F:	drivers/net/phy/mediatek-ge.c
+
 MEDIATEK I2C CONTROLLER DRIVER
 M:	Qii Wang <[email protected]>
 L:	[email protected]
drivers/net/phy/Kconfig +12 -0
index 059bd06a8cce4..a40269c175974 100644
@@ -236,6 +236,18 @@ config MEDIATEK_GE_PHY
 	help
 	  Supports the MediaTek Gigabit Ethernet PHYs.
 
+config MEDIATEK_GE_SOC_PHY
+	tristate "MediaTek SoC Ethernet PHYs"
+	depends on (ARM64 && ARCH_MEDIATEK) || COMPILE_TEST
+	select NVMEM_MTK_EFUSE
+	help
+	  Supports MediaTek SoC built-in Gigabit Ethernet PHYs.
+
+	  Include support for built-in Ethernet PHYs which are present in
+	  the MT7981 and MT7988 SoCs. These PHYs need calibration data
+	  present in the SoCs efuse and will dynamically calibrate VCM
+	  (common-mode voltage) during startup.
+
 config MICREL_PHY
 	tristate "Micrel PHYs"
 	depends on PTP_1588_CLOCK_OPTIONAL
drivers/net/phy/Makefile +1 -0
index f289ab16a1dab..2fe51ea83babe 100644
@@ -69,6 +69,7 @@ obj-$(CONFIG_MARVELL_PHY)	+= marvell.o
 obj-$(CONFIG_MARVELL_88X2222_PHY)	+= marvell-88x2222.o
 obj-$(CONFIG_MAXLINEAR_GPHY)	+= mxl-gpy.o
 obj-$(CONFIG_MEDIATEK_GE_PHY)	+= mediatek-ge.o
+obj-$(CONFIG_MEDIATEK_GE_SOC_PHY)	+= mediatek-ge-soc.o
 obj-$(CONFIG_MESON_GXL_PHY)	+= meson-gxl.o
 obj-$(CONFIG_MICREL_KS8995MA)	+= spi_ks8995.o
 obj-$(CONFIG_MICREL_PHY)	+= micrel.o
drivers/net/phy/mediatek-ge-soc.c new file +1116 -0

1,116 lines not on this page · raw message

drivers/net/phy/mediatek-ge.c +2 -1
index 68ee434f9dea3..a493ae01b267a 100644
@@ -102,7 +102,8 @@ static struct phy_driver mtk_gephy_driver[] = {
 module_phy_driver(mtk_gephy_driver);
 
 static struct mdio_device_id __maybe_unused mtk_gephy_tbl[] = {
-	{ PHY_ID_MATCH_VENDOR(0x03a29400) },
+	{ PHY_ID_MATCH_EXACT(0x03a29441) },
+	{ PHY_ID_MATCH_EXACT(0x03a29412) },
 	{ }
 };
 
Signature · 1 line
2.41.0
maintainer Reviewed-by on v5 1/1
#1 lore raw
Quoted 8 lines · Daniel Golle

Some of MediaTek's Filogic SoCs come with built-in gigabit Ethernet PHYs which require calibration data from the SoC's efuse. Despite the similar design the driver doesn't share any code with the existing mediatek-ge.c.
Add support for such PHYs by introducing a new driver with basic support for MediaTek SoCs MT7981 and MT7988 built-in 1GE PHYs.

drivers/net/phy/mediatek-ge-soc.c line 824

Quoted 8 lines
drivers/net/phy/mediatek-ge-soc.c new file +8 -0
+static void mt798x_phy_eee(struct phy_device *phydev)
+{
+	phy_modify_mmd(phydev, MDIO_MMD_VEND1,
+		       MTK_PHY_RG_LPI_PCS_DSP_CTRL_REG120,
+		       MTK_PHY_LPI_SIG_EN_LO_THRESH1000_MASK |
+		       MTK_PHY_LPI_SIG_EN_HI_THRESH1000_MASK,
+		       FIELD_PREP(MTK_PHY_LPI_SIG_EN_LO_THRESH1000_MASK, 0x0) |
+		       FIELD_PREP(MTK_PHY_LPI_SIG_EN_HI_THRESH1000_MASK, 0x14));

Does this PHY have SmartEEE? Where the PHY itself does EEE without the help of the MAC? At some point we would like to properly support that, but first we need to sort out the mess MAC/PHY EEE is in.

Andrew

#2 lore raw
In reply to Daniel Golle
This patch was applied to netdev/net-next.git (main) by David S. Miller <[email protected]>:

Hello:

This patch was applied to netdev/net-next.git (main) by David S. Miller <[email protected]>:

Quoted 8 lines · On Sun, 11 Jun 2023 00:48:10 +0100 you wrote:

Some of MediaTek's Filogic SoCs come with built-in gigabit Ethernet PHYs which require calibration data from the SoC's efuse. Despite the similar design the driver doesn't share any code with the existing mediatek-ge.c.
Add support for such PHYs by introducing a new driver with basic support for MediaTek SoCs MT7981 and MT7988 built-in 1GE PHYs.

[...]

Here is the summary with links:
- [net-next,v5] net: phy: add driver for MediaTek SoC built-in GE PHYs

    https://git.kernel.org/netdev/net-next/c/98c485eaf509

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
#3 lore raw
In reply to Daniel Golle
Quoted 8 lines · Daniel Golle

Some of MediaTek's Filogic SoCs come with built-in gigabit Ethernet PHYs which require calibration data from the SoC's efuse. Despite the similar design the driver doesn't share any code with the existing mediatek-ge.c.
Add support for such PHYs by introducing a new driver with basic support for MediaTek SoCs MT7981 and MT7988 built-in 1GE PHYs.

Hi Daniel,

It looks like your series wasn't threaded to this message. I assume that was a mistake?

Thanks.

Signature · 2 lines
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTP is here! 80Mbps down 10Mbps up. Decent connectivity at last!