net: phy: add driver for MediaTek SoC built-in GE PHYs
Subsystems (4)
PATCH v3 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, so add support for these PHYs by introducing a new driver for only MediaTek's ARM64 SoCs.
---
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 | 1263 +++++++++++++++++++++++++++++ drivers/net/phy/mediatek-ge.c | 3 +- 5 files changed, 1287 insertions(+), 1 deletion(-) create mode 100644 drivers/net/phy/mediatek-ge-soc.c
MAINTAINERS +9 -0
@@ -13128,6 +13128,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
@@ -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
@@ -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 +1263 -0
1,263 lines not on this page · raw message
drivers/net/phy/mediatek-ge.c +2 -1
@@ -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.40.0
drivers/net/phy/mediatek-ge-soc.c line 1184
Quoted 10 lines
drivers/net/phy/mediatek-ge-soc.c new file +10
-0+static int mt7988_phy_probe_shared (struct phy_device *phydev) +{ +struct mtk_socphy_shared_priv *priv = phydev->shared->priv; +void __iomem *boottrap; +struct device_node *np; +u32 reg; + + np =of_find_compatible_node (NULL ,NULL ,"mediatek,boottrap" ); +if (!np) +return -ENOENT ;
Is this documented somewhere in the DT binding document?
The rest of the driver just seems to be undocumented magic which nobody except the vendor would understand.
Andrew
Quoted 7 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, so add support for these PHYs by introducing a new driver for only MediaTek's ARM64 SoCs.Signed-off-by Daniel Golle <[email protected]>
Hi Daniel,
some minor nits from my side.
...
Quoted 1 line
drivers/net/phy/mediatek-ge-soc.c +0
-0
...
drivers/net/phy/mediatek-ge-soc.c line 263
Quoted 4 lines
drivers/net/phy/mediatek-ge-soc.c +4
-0+#define MTK_PHY_RG_BG_RASEL 0x115 +#define MTK_PHY_RG_BG_RASEL_MASK GENMASK(2, 0) + +/* These macro privides efuse parsing for internal phy. */
nit: s/privides/provides/
Please consider using checkpatch --codespell
...
drivers/net/phy/mediatek-ge-soc.c line 424
Quoted 12 lines
drivers/net/phy/mediatek-ge-soc.c +12
-0+static int tx_amp_fill_result (struct phy_device *phydev,u16 *buf) +{ +int i; +int bias[16 ] = {}; +const int vals_9461[16 ] = {7 ,1 ,4 ,7 , +7 ,1 ,4 ,7 , +7 ,1 ,4 ,7 , +7 ,1 ,4 ,7 }; +const int vals_9481[16 ] = {10 ,6 ,6 ,10 , +10 ,6 ,6 ,10 , +10 ,6 ,6 ,10 , +10 ,6 ,6 ,10 };
nits: Please put a blank line here.
Please arrange local variables in networking code in reverse xmas tree order.
Quoted 12 lines
drivers/net/phy/mediatek-ge-soc.c +12
-0+switch (phydev->drv->phy_id) { +case MTK_GPHY_ID_MT7981 : +/* We add some calibration to efuse values +* due to board level influence. +* GBE: +7, TBT: +1, HBT: +4, TST: +7 +*/ +memcpy (bias, (const void *)vals_9461,sizeof (bias)); +break ; +case MTK_GPHY_ID_MT7988 : +memcpy (bias, (const void *)vals_9481,sizeof (bias)); +break ; + }
...