AI Trajectory


Trajectory: (Expand/Collapse All)
Seq Timestamp Type Name Duration
0/0 2026/10/14 12:04 flow patch-triage
6m Args:
null

Results:
{
  "EnableConfigs": null,
  "FocusSymbols": [],
  "KMSANReasoning": "",
  "NeedsKMSAN": false,
  "Reasoning": "The patch adds the Airoha SoC Gigabit Ethernet PHY driver (airoha-ge-soc.c) and refactors shared helper and LED functions across MediaTek/Airoha PHY drivers (mtk-ge-soc.c, mtk-phy-lib.c). These drivers target built-in Gigabit Ethernet PHYs physically integrated into ARM64 (Airoha AN7581/AN7583, MediaTek MT7981/MT7988) and MIPS (EcoNet EN7528) networking SoCs. On the target amd64 architecture, these drivers can only be built with COMPILE_TEST and require physical SoC hardware not emulated in standard QEMU/GCE environments. Because the modified code is structurally unreachable, it does not warrant fuzzing.",
  "WorthFuzzing": false
}

1/1 2026/10/14 12:04 action read-patch-diff
0m Args:
null

Results:
{
  "PatchDiff": "commit 85208cdda5c957df633d19c809fc86ed605eec74\nAuthor: syz-cluster \u003ctriage@syzkaller.com\u003e\nDate:   Wed Oct 14 12:04:24 2026 +0000\n\n    syz-cluster: applied patch under review\n\ndiff --git a/MAINTAINERS b/MAINTAINERS\nindex 509b35b5a0e7a..7ad81a83d6706 100644\n--- a/MAINTAINERS\n+++ b/MAINTAINERS\n@@ -759,6 +759,14 @@ S:\tMaintained\n F:\tDocumentation/devicetree/bindings/net/airoha,en7581-eth.yaml\n F:\tdrivers/net/ethernet/airoha/\n \n+AIROHA ETHERNET PHY DRIVER\n+M:\tChristian Marangi \u003cansuelsmth@gmail.com\u003e\n+L:\tlinux-arm-kernel@lists.infradead.org (moderated for non-subscribers)\n+L:\tlinux-mediatek@lists.infradead.org (moderated for non-subscribers)\n+L:\tnetdev@vger.kernel.org\n+S:\tMaintained\n+F:\tdrivers/net/phy/mediatek/airoha-ge-soc.c\n+\n AIROHA PCIE PHY DRIVER\n M:\tLorenzo Bianconi \u003clorenzo@kernel.org\u003e\n L:\tlinux-arm-kernel@lists.infradead.org (moderated for non-subscribers)\n@@ -16645,6 +16653,7 @@ L:\tnetdev@vger.kernel.org\n S:\tMaintained\n F:\tdrivers/net/phy/mediatek/mtk-2p5ge.c\n F:\tdrivers/net/phy/mediatek/mtk-ge-soc.c\n+F:\tdrivers/net/phy/mediatek/mtk-ge-soc.h\n F:\tdrivers/net/phy/mediatek/mtk-phy-lib.c\n F:\tdrivers/net/phy/mediatek/mtk-ge.c\n F:\tdrivers/net/phy/mediatek/mtk.h\ndiff --git a/drivers/net/phy/mediatek/Kconfig b/drivers/net/phy/mediatek/Kconfig\nindex 3b9cf82c0cb28..15f4481b9dc11 100644\n--- a/drivers/net/phy/mediatek/Kconfig\n+++ b/drivers/net/phy/mediatek/Kconfig\n@@ -1,4 +1,17 @@\n # SPDX-License-Identifier: GPL-2.0-only\n+config AIROHA_GE_SOC_PHY\n+\ttristate \"Airoha SoC Gigabit Ethernet PHYs\"\n+\tdepends on ARM64 || ECONET || COMPILE_TEST\n+\tdepends on ARCH_AIROHA || ECONET || COMPILE_TEST\n+\tselect MTK_NET_PHYLIB\n+\tselect PHY_PACKAGE\n+\thelp\n+\t  Supports Airoha SoC built-in Gigabit Ethernet PHYs.\n+\n+\t  Include support for built-in Ethernet PHYs which are present in\n+\t  the AN7581 and AN7583 SoCs. These PHYs d will dynamically\n+\t  calibrate during startup.\n+\n config MEDIATEK_2P5GE_PHY\n \ttristate \"MediaTek 2.5Gb Ethernet PHYs\"\n \tdepends on (ARM64 \u0026\u0026 ARCH_MEDIATEK) || COMPILE_TEST\n@@ -32,9 +45,8 @@ config MEDIATEK_FE_SOC_PHY\n \n config MEDIATEK_GE_SOC_PHY\n \ttristate \"MediaTek SoC Gigabit Ethernet PHYs\"\n-\tdepends on ARM64 || ECONET || COMPILE_TEST\n-\tdepends on ARCH_AIROHA || (ARCH_MEDIATEK \u0026\u0026 NVMEM_MTK_EFUSE) || \\\n-\t\t   ECONET || COMPILE_TEST\n+\tdepends on ARM64 || COMPILE_TEST\n+\tdepends on (ARCH_MEDIATEK \u0026\u0026 NVMEM_MTK_EFUSE) || COMPILE_TEST\n \tselect MTK_NET_PHYLIB\n \tselect PHY_PACKAGE\n \thelp\ndiff --git a/drivers/net/phy/mediatek/Makefile b/drivers/net/phy/mediatek/Makefile\nindex 6f9cacf7f9065..5594057f51d0f 100644\n--- a/drivers/net/phy/mediatek/Makefile\n+++ b/drivers/net/phy/mediatek/Makefile\n@@ -1,4 +1,5 @@\n # SPDX-License-Identifier: GPL-2.0\n+obj-$(CONFIG_AIROHA_GE_SOC_PHY)\t\t+= airoha-ge-soc.o\n obj-$(CONFIG_MEDIATEK_2P5GE_PHY)\t+= mtk-2p5ge.o\n obj-$(CONFIG_MEDIATEK_FE_SOC_PHY)\t+= mtk-fe-soc.o\n obj-$(CONFIG_MEDIATEK_GE_PHY)\t\t+= mtk-ge.o\ndiff --git a/drivers/net/phy/mediatek/airoha-ge-soc.c b/drivers/net/phy/mediatek/airoha-ge-soc.c\nnew file mode 100644\nindex 0000000000000..1d88f66e4773e\n--- /dev/null\n+++ b/drivers/net/phy/mediatek/airoha-ge-soc.c\n@@ -0,0 +1,1851 @@\n+// SPDX-License-Identifier: GPL-2.0+\n+#include \u003clinux/bitfield.h\u003e\n+#include \u003clinux/pinctrl/consumer.h\u003e\n+#include \u003clinux/phy.h\u003e\n+\n+#include \"../phylib.h\"\n+#include \"mtk.h\"\n+#include \"mtk-ge-soc.h\"\n+\n+#define AIROHA_DEFAULT_PORT0_ADDR\t\t0x9\n+#define AIROHA_PHY_MAX_LEDS\t\t\t2\n+\n+enum airoha_mdi_resister_type {\n+\tMDI_0R,\n+\tMDI_5R,\n+\n+\tMDI_TYPE_MAX,\n+};\n+\n+enum airoha_transformer_type {\n+\tDISCRETE,\n+\tTXMR,\n+\n+\tTRANSFORMER_TYPE_MAX,\n+};\n+\n+enum airoha_calib_const_type {\n+\tTX_AMP_TEST_A,\n+\tTX_AMP_TEST_B,\n+\tTX_AMP_TEST_C,\n+\tTX_AMP_TEST_D,\n+\tTX_AMP_1G_A,\n+\tTX_AMP_1G_B,\n+\tTX_AMP_1G_C,\n+\tTX_AMP_1G_D,\n+\tTX_AMP_100M_A,\n+\tTX_AMP_100M_B,\n+\tTX_AMP_10M_A,\n+\tTX_AMP_10M_B,\n+\tR50_A,\n+\tR50_B,\n+\tR50_C,\n+\tR50_D,\n+\n+\tCALIB_CONST_TYPE_MAX,\n+};\n+\n+struct airoha_socphy_shared {\n+\tstruct phy_device *phydev_p0;\n+\tenum airoha_transformer_type transformer_type[4];\n+\tenum airoha_mdi_resister_type mdi_resister_type;\n+\tbool rext_sw_calib_done;\n+\tint (*tx_amp_compensation_tbl)[TRANSFORMER_TYPE_MAX][MDI_TYPE_MAX][CALIB_CONST_TYPE_MAX][4];\n+\tu8 *r50_cal_tbl;\n+};\n+\n+/*\n+ * 2 chip revision\n+ * TXMR or discrete\n+ * 2 MDI type\n+ * TX AMP test/TX AMP 1G/TX AMP 100M/TX AMP 10M/R50\n+ * 4 PHY\n+ */\n+static int an7581_tx_amp_compensation_tbl[2][TRANSFORMER_TYPE_MAX][MDI_TYPE_MAX][CALIB_CONST_TYPE_MAX][4] = {\n+\t{ /* IC version 1 */\n+\t\t[DISCRETE] = {\n+\t\t\t{ },\n+\t\t\t{\n+\t\t\t\t[TX_AMP_TEST_A] = { -9, -7, -7, -5 },\n+\t\t\t\t[TX_AMP_TEST_B] = { -9, -9, -7, -4 },\n+\t\t\t\t[TX_AMP_TEST_C] = { -9, -7, -9, -6 },\n+\t\t\t\t[TX_AMP_TEST_D] = { -11, -9, -10, -8 },\n+\t\t\t\t[TX_AMP_1G_A] = { -9, -7, -7, -5 },\n+\t\t\t\t[TX_AMP_1G_B] = { -9, -8, -7, -4 },\n+\t\t\t\t[TX_AMP_1G_C] = { -9, -7, -9, -6 },\n+\t\t\t\t[TX_AMP_1G_D] = { -11, -8, -10, -8 },\n+\t\t\t\t[TX_AMP_100M_A] = { 4, 3, 4, 4 },\n+\t\t\t\t[TX_AMP_100M_B] = { 4, 4, 5, 4 },\n+\t\t\t\t[TX_AMP_10M_A] = { 0, 0, 0, 0 },\n+\t\t\t\t[TX_AMP_10M_B] = { 0, 0, 0, 0 },\n+\t\t\t\t[R50_A] = { 0, 0, 0, 0 },\n+\t\t\t\t[R50_B] = { 0, 0, 0, 0 },\n+\t\t\t\t[R50_C] = { 0, 0, 0, 0 },\n+\t\t\t\t[R50_D] = { 0, 0, 0, 0 },\n+\t\t\t},\n+\t\t},\n+\t\t[TXMR] = {\n+\t\t\t{ },\n+\t\t\t{\n+\t\t\t\t[TX_AMP_TEST_A] = { -12, -11, -9, -6 },\n+\t\t\t\t[TX_AMP_TEST_B] = { -9, -13, -9, -5 },\n+\t\t\t\t[TX_AMP_TEST_C] = { -5, -4, -3, 1 },\n+\t\t\t\t[TX_AMP_TEST_D] = { -9, -8, -7, -5 },\n+\t\t\t\t[TX_AMP_1G_A] = { -12, -11, -9, -6 },\n+\t\t\t\t[TX_AMP_1G_B] = { -9, -13, -9, -5 },\n+\t\t\t\t[TX_AMP_1G_C] = { -5, -4, -3, 1 },\n+\t\t\t\t[TX_AMP_1G_D] = { -9, -8, -7, -5 },\n+\t\t\t\t[TX_AMP_100M_A] = { -2, -2, 0, 2 },\n+\t\t\t\t[TX_AMP_100M_B] = { -2, -2, 1, 1 },\n+\t\t\t\t[TX_AMP_10M_A] = { 0, 0, 0, 0 },\n+\t\t\t\t[TX_AMP_10M_B] = { 0, 0, 0, 0 },\n+\t\t\t\t[R50_A] = { 15, 15, 15, 15 },\n+\t\t\t\t[R50_B] = { 15, 15, 18, 15 },\n+\t\t\t\t[R50_C] = { -8, -8, -8, -8 },\n+\t\t\t\t[R50_D] = { -8, -8, -8, -8 },\n+\t\t\t},\n+\t\t},\n+\t},\n+\t{ /* IC version 2 */\n+\t\t[DISCRETE] = {\n+\t\t\t{ },\n+\t\t\t{\n+\t\t\t\t[TX_AMP_TEST_A] = { -11, 11, -12, -7 },\n+\t\t\t\t[TX_AMP_TEST_B] = { -9, -10, -9, -8 },\n+\t\t\t\t[TX_AMP_TEST_C] = { -6, -3, -7, -4 },\n+\t\t\t\t[TX_AMP_TEST_D] = { -7, -8, -10, -7 },\n+\t\t\t\t[TX_AMP_1G_A] = { -11, -11, -12, -7 },\n+\t\t\t\t[TX_AMP_1G_B] = { -9, -10, -9, -8 },\n+\t\t\t\t[TX_AMP_1G_C] = { -6, -3, -7, -4 },\n+\t\t\t\t[TX_AMP_1G_D] = { -7, -8, -10, -7 },\n+\t\t\t\t[TX_AMP_100M_A] = { 2, 2, 1, 2 },\n+\t\t\t\t[TX_AMP_100M_B] = { 3, 3, 3, 3 },\n+\t\t\t\t[TX_AMP_10M_A] = { 0, 0, 0, 0 },\n+\t\t\t\t[TX_AMP_10M_B] = { 0, 0, 0, 0 },\n+\t\t\t\t[R50_A] = { 12, 12, 12, 12 },\n+\t\t\t\t[R50_B] = { 7, 7, 7, 7 },\n+\t\t\t\t[R50_C] = { 2, 2, 0, 0 },\n+\t\t\t\t[R50_D] = { 0, 0, 2, 2 },\n+\t\t\t},\n+\t\t},\n+\t\t[TXMR] = {\n+\t\t\t{ },\n+\t\t\t{\n+\t\t\t\t[TX_AMP_TEST_A] = { -10, -12, -12, -11 },\n+\t\t\t\t[TX_AMP_TEST_B] = { -10, -11, -11, -10 },\n+\t\t\t\t[TX_AMP_TEST_C] = { -5, -7, -9, -3 },\n+\t\t\t\t[TX_AMP_TEST_D] = { -8, -10, -7, -8 },\n+\t\t\t\t[TX_AMP_1G_A] = { -12, -6, -6, 4 },\n+\t\t\t\t[TX_AMP_1G_B] = { -10, -5, -5, 1 },\n+\t\t\t\t[TX_AMP_1G_C] = { -5, -3, -4, 11 },\n+\t\t\t\t[TX_AMP_1G_D] = { -8, -3, -3, 4 },\n+\t\t\t\t[TX_AMP_100M_A] = { 2, 1, 0, 3 },\n+\t\t\t\t[TX_AMP_100M_B] = { 0, 0, 0, 3 },\n+\t\t\t\t[TX_AMP_10M_A] = { 0, 0, 0, 0 },\n+\t\t\t\t[TX_AMP_10M_B] = { 0, 0, 0, 0 },\n+\t\t\t\t[R50_A] = { 15, 15, 15, 15 },\n+\t\t\t\t[R50_B] = { 15, 15, 18, 15 },\n+\t\t\t\t[R50_C] = { 4, 4, 4, 4 },\n+\t\t\t\t[R50_D] = { 4, 4, 4, 4 },\n+\t\t\t},\n+\t\t},\n+\t},\n+};\n+\n+static u8 an7581_zcal_to_r45ohm[64] = {\n+\t127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127,\n+\t127, 127, 127, 127, 127, 127, 127, 127, 123, 119, 115, 112, 108, 104, 100,  96,\n+\t 94,  92,  88,  85,  82,  80,  76,  74,  72,  68,  66,  64,  62,  60,  56,  55,\n+\t 52,  50,  48,  46,  44,  42,  40,  39,  36,  35,  32,  32,  30,  28,  27,  25\n+};\n+\n+/*\n+ * 2 chip revision\n+ * TXMR or discrete\n+ * 2 MDI type\n+ * TX AMP test/TX AMP 1G/TX AMP 100M/TX AMP 10M/R50\n+ * 4 PHY\n+ */\n+static int an7583_tx_amp_compensation_tbl[TRANSFORMER_TYPE_MAX][MDI_TYPE_MAX][CALIB_CONST_TYPE_MAX][4] = {\n+\t[DISCRETE] = {\n+\t\t[MDI_0R] = {\n+\t\t\t[TX_AMP_TEST_A] = { -3, -3, -3, -3 },\n+\t\t\t[TX_AMP_TEST_B] = { -3, -3, -3, -3 },\n+\t\t\t[TX_AMP_TEST_C] = { -3, -3, -3, -3 },\n+\t\t\t[TX_AMP_TEST_D] = { -3, -3, -3, -3 },\n+\t\t\t[TX_AMP_1G_A] = { 0, 0, 0, 0 },\n+\t\t\t[TX_AMP_1G_B] = { 0, 0, 0, 0 },\n+\t\t\t[TX_AMP_1G_C] = { 0, 0, 0, 0 },\n+\t\t\t[TX_AMP_1G_D] = { 0, 0, 0, 0 },\n+\t\t\t[TX_AMP_100M_A] = { 4, 4, 4, 4 },\n+\t\t\t[TX_AMP_100M_B] = { 4, 4, 4, 4 },\n+\t\t\t[TX_AMP_10M_A] = { 0, 0, 0, 0 },\n+\t\t\t[TX_AMP_10M_B] = { 0, 0, 0, 0 },\n+\t\t\t[R50_A] = { 4, 4, 4, 4 },\n+\t\t\t[R50_B] = { 4, 4, 4, 4 },\n+\t\t\t[R50_C] = { 6, 6, 6, 6 },\n+\t\t\t[R50_D] = { 4, 4, 4, 4 },\n+\t\t},\n+\t\t[MDI_5R] = {\n+\t\t\t[TX_AMP_TEST_A] = { -3, -3, -3, -3 },\n+\t\t\t[TX_AMP_TEST_B] = { -3, -3, -3, -3 },\n+\t\t\t[TX_AMP_TEST_C] = { -3, -3, -3, -3 },\n+\t\t\t[TX_AMP_TEST_D] = { -3, -3, -3, -3 },\n+\t\t\t[TX_AMP_1G_A] = { 0, 0, 0, 0 },\n+\t\t\t[TX_AMP_1G_B] = { 0, 0, 0, 0 },\n+\t\t\t[TX_AMP_1G_C] = { 0, 0, 0, 0 },\n+\t\t\t[TX_AMP_1G_D] = { 0, 0, 0, 0 },\n+\t\t\t[TX_AMP_100M_A] = { 4, 4, 4, 4 },\n+\t\t\t[TX_AMP_100M_B] = { 4, 4, 4, 4 },\n+\t\t\t[TX_AMP_10M_A] = { 0, 0, 0, 0 },\n+\t\t\t[TX_AMP_10M_B] = { 0, 0, 0, 0 },\n+\t\t\t[R50_A] = { 0, 0, 0, 0 },\n+\t\t\t[R50_B] = { 0, 0, 0, 0 },\n+\t\t\t[R50_C] = { 0, 0, 0, 0 },\n+\t\t\t[R50_D] = { 0, 0, 0, 0 },\n+\t\t},\n+\t},\n+\t[TXMR] = {\n+\t\t[MDI_0R] = {\n+\t\t\t[TX_AMP_TEST_A] = { -3, -3, -3, -3 },\n+\t\t\t[TX_AMP_TEST_B] = { -3, -3, -3, -3 },\n+\t\t\t[TX_AMP_TEST_C] = { -3, -3, -3, -3 },\n+\t\t\t[TX_AMP_TEST_D] = { -3, -3, -3, -3 },\n+\t\t\t[TX_AMP_1G_A] = { 0, 0, 0, 0 },\n+\t\t\t[TX_AMP_1G_B] = { 0, 0, 0, 0 },\n+\t\t\t[TX_AMP_1G_C] = { 0, 0, 0, 0 },\n+\t\t\t[TX_AMP_1G_D] = { 0, 0, 0, 0 },\n+\t\t\t[TX_AMP_100M_A] = { 4, 4, 4, 4 },\n+\t\t\t[TX_AMP_100M_B] = { 4, 4, 4, 4 },\n+\t\t\t[TX_AMP_10M_A] = { 0, 0, 0, 0 },\n+\t\t\t[TX_AMP_10M_B] = { 0, 0, 0, 0 },\n+\t\t\t[R50_A] = { 4, 4, 0, 0 },\n+\t\t\t[R50_B] = { 4, 4, 0, 0 },\n+\t\t\t[R50_C] = { 5, 5, 3, 4 },\n+\t\t\t[R50_D] = { 4, 4, 4, 0 },\n+\t\t},\n+\t\t[MDI_5R] = {\n+\t\t\t[TX_AMP_TEST_A] = { -3, -3, -3, -3 },\n+\t\t\t[TX_AMP_TEST_B] = { -3, -3, -3, -3 },\n+\t\t\t[TX_AMP_TEST_C] = { -3, -3, -3, -3 },\n+\t\t\t[TX_AMP_TEST_D] = { -3, -3, -3, -3 },\n+\t\t\t[TX_AMP_1G_A] = { 0, 0, 0, 0 },\n+\t\t\t[TX_AMP_1G_B] = { 0, 0, 0, 0 },\n+\t\t\t[TX_AMP_1G_C] = { 0, 0, 0, 0 },\n+\t\t\t[TX_AMP_1G_D] = { 0, 0, 0, 0 },\n+\t\t\t[TX_AMP_100M_A] = { 4, 4, 4, 4 },\n+\t\t\t[TX_AMP_100M_B] = { 4, 4, 4, 4 },\n+\t\t\t[TX_AMP_10M_A] = { 0, 0, 0, 0 },\n+\t\t\t[TX_AMP_10M_B] = { 0, 0, 0, 0 },\n+\t\t\t[R50_A] = { -4, -4, -4, -4 },\n+\t\t\t[R50_B] = { -4, -4, -4, -4 },\n+\t\t\t[R50_C] = { -2, -2, -2, -2 },\n+\t\t\t[R50_D] = { -3, -3, -2, -2 },\n+\t\t},\n+\t},\n+};\n+\n+static u8 an7583_zcal_to_r50ohm_0R[64] = {\n+\t127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127,\n+\t127, 127, 127, 122, 118, 114, 110, 106, 102,  98,  96,  92,  88,  85,  82,  80,\n+\t 76,  72,  70,  68,  64,  62,  60,  57,  55,  52,  50,  48,  46,  44,  41,  40,\n+\t 38,  36,  33,  32,  30,  28,  26,  24,  24,  22,  20,  18,  16,  16,  14,  12,\n+};\n+\n+static u8 an7583_zcal_to_r50ohm_5R[64] = {\n+\t127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127,\n+\t127, 127, 127, 127, 127, 127, 127, 127, 127, 124, 120, 116, 112, 110, 106, 102,\n+\t 99,  96,  93,  90,  88,  84,  81,  79,  76,  73,  71,  68,  66,  64,  61,  59,\n+\t 56,  54,  52,  50,  48,  46,  44,  42,  40,  39,  37,  36,  33,  32,  31,  29,\n+};\n+\n+static int airoha_cal_cycle(struct phy_device *phydev, int devad,\n+\t\t\t    u32 regnum, u16 mask, u16 cal_val)\n+{\n+\tstruct airoha_socphy_shared *shared = phy_package_get_priv(phydev);\n+\tstruct phy_device *phydev_p0;\n+\tint ret;\n+\n+\tphydev_p0 = shared-\u003ephydev_p0;\n+\n+\tphy_modify_mmd(phydev, devad, regnum, mask, cal_val);\n+\n+\tret = mtk_cal_cycle_wait(phydev_p0);\n+\tphydev_dbg(phydev, \"cal_val: 0x%x, ret: %d\\n\", cal_val, ret);\n+\n+\treturn ret;\n+}\n+\n+static int airoha_rext_cal_sw(struct phy_device *phydev)\n+{\n+\tint calibration_polarity;\n+\tu8 zcal_ctrl = 32;\n+\tint first_calib;\n+\tint ret;\n+\n+\t/* BG voltage output */\n+\tphy_write_mmd(phydev, MDIO_MMD_VEND2, 0x100, 0xc000);\n+\t/* tst_mode2 */\n+\tphy_write_mmd(phydev, MDIO_MMD_VEND2, 0xff, 0x2);\n+\n+\tphy_write_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_RG_ANA_CAL_RG0,\n+\t\t      MTK_PHY_RG_CAL_CKINV | MTK_PHY_RG_ANA_CALEN |\n+\t\t      MTK_PHY_RG_REXT_CALEN);\n+\tphy_write_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_RG_ANA_CAL_RG1, 0);\n+\tphy_write_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_RG_ANA_CAL_RG6, 0);\n+\n+\tphydev_dbg(phydev, \"Start REXT SW cal.\\n\");\n+\tfirst_calib = airoha_cal_cycle(phydev, MDIO_MMD_VEND1, MTK_PHY_RG_ANA_CAL_RG5,\n+\t\t\t\t       MTK_PHY_RG_REXT_ZCAL_CTRL_MASK, zcal_ctrl);\n+\n+\tif (first_calib \u003c 0) {\n+\t\tphydev_err(phydev, \"REXT SW calibration failed.\\n\");\n+\t\treturn -EINVAL;\n+\t}\n+\n+\t/* If REXT calibration failed:\n+\t * - increase dB until calibration succeed.\n+\t * If REXT calibration succeeded:\n+\t * - decrease dB until calibration fail to fine tune it.\n+\t */\n+\tif (first_calib == 1)\n+\t\tcalibration_polarity = -1;\n+\telse\n+\t\tcalibration_polarity = 1;\n+\n+\twhile (zcal_ctrl \u003e 0 \u0026\u0026\n+\t       zcal_ctrl \u003c FIELD_MAX(MTK_PHY_RG_REXT_ZCAL_CTRL_MASK)) {\n+\t\tzcal_ctrl += calibration_polarity;\n+\n+\t\tret = airoha_cal_cycle(phydev, MDIO_MMD_VEND1, MTK_PHY_RG_ANA_CAL_RG5,\n+\t\t\t\t       MTK_PHY_RG_REXT_ZCAL_CTRL_MASK, zcal_ctrl);\n+\t\t/* Exit if we either failed or succeeded compared to the\n+\t\t * first calibration result. (aka we finished fine tuning or\n+\t\t * we succeeded with calibration)\n+\t\t */\n+\t\tif (ret != first_calib)\n+\t\t\tbreak;\n+\t}\n+\n+\tif (ret \u003c 0) {\n+\t\tphydev_err(phydev, \"REXT SW calibration failed.\\n\");\n+\t\treturn -EINVAL;\n+\t}\n+\n+\tif (zcal_ctrl == 0 ||\n+\t    zcal_ctrl == FIELD_MAX(MTK_PHY_RG_REXT_ZCAL_CTRL_MASK)) {\n+\t\tzcal_ctrl = 32;\n+\t\tphydev_err(phydev, \"REXT SW calibration saturation. Defaulting to %x.\\n\",\n+\t\t\t   zcal_ctrl);\n+\t}\n+\n+\tphy_modify_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_RG_ANA_CAL_RG5,\n+\t\t       MTK_PHY_RG_REXT_TRIM_MASK,\n+\t\t       FIELD_PREP(MTK_PHY_RG_REXT_TRIM_MASK, zcal_ctrl));\n+\tphy_modify_mmd(phydev, MDIO_MMD_VEND2, MTK_PHY_RG_BG_RASEL,\n+\t\t       MTK_PHY_RG_BG_RASEL_MASK,\n+\t\t       FIELD_PREP(MTK_PHY_RG_BG_RASEL_MASK, zcal_ctrl \u003e\u003e 3));\n+\n+\tphy_write_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_RG_ANA_CAL_RG0, 0);\n+\n+\treturn 0;\n+}\n+\n+static int airoha_tx_offset_cal_sw(struct phy_device *phydev, u8 txg_calen_x)\n+{\n+\tstruct airoha_socphy_shared *shared = phy_package_get_priv(phydev);\n+\tstruct phy_device *phydev_p0;\n+\tu16 dev1e_145_tmp, bmcr_tmp;\n+\tint calibration_polarity;\n+\tu16 reg_dac1, reg_dac2;\n+\tint zcal_ctrl = 32;\n+\tint first_calib;\n+\tu16 reg, mask;\n+\tint ret;\n+\n+\tphydev_p0 = shared-\u003ephydev_p0;\n+\n+\t/* BG voltage output */\n+\tphy_write_mmd(phydev_p0, MDIO_MMD_VEND2, 0x100, 0xc000);\n+\n+\tphy_write_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_RG_ANA_CAL_RG0,\n+\t\t      MTK_PHY_RG_ANA_CALEN);\n+\tphy_write_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_RG_ANA_CAL_RG1,\n+\t\t      MTK_PHY_RG_TXVOS_CALEN);\n+\tphy_write_mmd(phydev_p0, MDIO_MMD_VEND1, MTK_PHY_RG_ANA_CAL_RG0,\n+\t\t      MTK_PHY_RG_ANA_CALEN);\n+\tphy_write_mmd(phydev_p0, MDIO_MMD_VEND1, MTK_PHY_RG_ANA_CAL_RG1,\n+\t\t      MTK_PHY_RG_TXVOS_CALEN);\n+\n+\t/* Force 1G full duplex for calibration */\n+\tbmcr_tmp = phy_read(phydev, MII_BMCR);\n+\tphy_write(phydev, MII_BMCR, BMCR_FULLDPLX | BMCR_SPEED1000);\n+\n+\t/* Force MDI */\n+\tdev1e_145_tmp = phy_read_mmd(phydev, MDIO_MMD_VEND1, 0x0145);\n+\tphy_write_mmd(phydev, MDIO_MMD_VEND1, 0x0145, 0x1010);\n+\n+\t/* 1e_96[15]:bypass_tx_offset_cal, Hw bypass, Fw cal */\n+\tphy_write_mmd(phydev, MDIO_MMD_VEND1, 0x96,\n+\t\t      0x8000);\n+\tphy_write_mmd(phydev, MDIO_MMD_VEND1, 0x3e,\n+\t\t      0xf808);\n+\n+\tswitch (txg_calen_x) {\n+\tcase PAIR_A:\n+\t\tphy_write_mmd(phydev, MDIO_MMD_VEND1, 0xdd, BIT(12));\n+\t\treg_dac1 = MTK_PHY_RG_DASN_DAC_IN0_A;\n+\t\treg_dac2 = MTK_PHY_RG_DASN_DAC_IN1_A;\n+\t\treg = MTK_PHY_RG_CR_TX_AMP_OFFSET_A_B;\n+\t\tmask = MTK_PHY_CR_TX_AMP_OFFSET_A_MASK;\n+\t\tbreak;\n+\tcase PAIR_B:\n+\t\tphy_write_mmd(phydev, MDIO_MMD_VEND1, 0xdd, BIT(8));\n+\t\treg_dac1 = MTK_PHY_RG_DASN_DAC_IN0_B;\n+\t\treg_dac2 = MTK_PHY_RG_DASN_DAC_IN1_B;\n+\t\treg = MTK_PHY_RG_CR_TX_AMP_OFFSET_A_B;\n+\t\tmask = AIROHA_PHY_CR_TX_AMP_OFFSET_B_MASK;\n+\t\tbreak;\n+\tcase PAIR_C:\n+\t\tphy_write_mmd(phydev, MDIO_MMD_VEND1, 0xdd, BIT(4));\n+\t\treg_dac1 = MTK_PHY_RG_DASN_DAC_IN0_C;\n+\t\treg_dac2 = MTK_PHY_RG_DASN_DAC_IN1_C;\n+\t\treg = MTK_PHY_RG_CR_TX_AMP_OFFSET_C_D;\n+\t\tmask = MTK_PHY_CR_TX_AMP_OFFSET_C_MASK;\n+\t\tbreak;\n+\tcase PAIR_D:\n+\t\tphy_write_mmd(phydev, MDIO_MMD_VEND1, 0xdd, BIT(0));\n+\t\treg_dac1 = MTK_PHY_RG_DASN_DAC_IN0_D;\n+\t\treg_dac2 = MTK_PHY_RG_DASN_DAC_IN1_D;\n+\t\treg = MTK_PHY_RG_CR_TX_AMP_OFFSET_C_D;\n+\t\tmask = AIROHA_PHY_CR_TX_AMP_OFFSET_D_MASK;\n+\t\tbreak;\n+\tdefault:\n+\t\treturn -EINVAL;\n+\t}\n+\n+\tphy_write_mmd(phydev, MDIO_MMD_VEND1, reg_dac1,\n+\t\t      0x8000);\n+\tphy_write_mmd(phydev, MDIO_MMD_VEND1, reg_dac2,\n+\t\t      0x8000);\n+\n+\tphydev_dbg(phydev, \"Start TX Offset SW cal.\\n\");\n+\n+\tfirst_calib = airoha_cal_cycle(phydev, MDIO_MMD_VEND1, reg, mask,\n+\t\t\t\t       zcal_ctrl \u003c\u003c __ffs(mask));\n+\n+\t/* If TX Offset calibration failed:\n+\t * - increase dB until calibration succeed.\n+\t * If TX Offset calibration succeeded:\n+\t * - decrease dB until calibration fail to fine tune it.\n+\t */\n+\tif (first_calib == 1)\n+\t\tcalibration_polarity = -1;\n+\telse\n+\t\tcalibration_polarity = 1;\n+\n+\twhile (zcal_ctrl \u003e 0 \u0026\u0026 zcal_ctrl \u003c 64) {\n+\t\tu32 val;\n+\n+\t\tzcal_ctrl += calibration_polarity;\n+\t\tif (zcal_ctrl \u003e= 0)\n+\t\t\tval = zcal_ctrl;\n+\t\telse\n+\t\t\tval = 63;\n+\n+\t\tret = airoha_cal_cycle(phydev, MDIO_MMD_VEND1, reg, mask,\n+\t\t\t\t       val \u003c\u003c __ffs(mask));\n+\t\t/* Exit if we either failed or succeeded compared to the\n+\t\t * first calibration result. (aka we finished fine tuning or\n+\t\t * we succeeded with calibration)\n+\t\t */\n+\t\tif (ret != first_calib)\n+\t\t\tbreak;\n+\t}\n+\n+\tif (ret \u003c 0) {\n+\t\tphydev_err(phydev, \"TX Offset calibration failed.\\n\");\n+\t\treturn -EINVAL;\n+\t}\n+\n+\tif (zcal_ctrl == -32 ||\n+\t    zcal_ctrl == 32) {\n+\t\tzcal_ctrl = 0;\n+\t\tphydev_err(phydev, \"TX Offset SW calibration saturation. Defaulting to %x.\\n\",\n+\t\t\t   zcal_ctrl);\n+\n+\t\tphy_modify_mmd(phydev, MDIO_MMD_VEND1, reg, mask,\n+\t\t\t       zcal_ctrl \u003c\u003c __ffs(mask));\n+\t}\n+\n+\tphy_write_mmd(phydev, MDIO_MMD_VEND2, 0x100, 0x0);\n+\n+\tphy_write_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_RG_DASN_DAC_IN0_A, 0);\n+\tphy_write_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_RG_DASN_DAC_IN0_B, 0);\n+\tphy_write_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_RG_DASN_DAC_IN0_C, 0);\n+\tphy_write_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_RG_DASN_DAC_IN0_D, 0);\n+\tphy_write_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_RG_DASN_DAC_IN1_A, 0);\n+\tphy_write_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_RG_DASN_DAC_IN1_B, 0);\n+\tphy_write_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_RG_DASN_DAC_IN1_C, 0);\n+\tphy_write_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_RG_DASN_DAC_IN1_D, 0);\n+\n+\tphy_write_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_RG_ANA_CAL_RG0, 0);\n+\tphy_write_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_RG_ANA_CAL_RG1, 0);\n+\tphy_write_mmd(phydev_p0, MDIO_MMD_VEND1, MTK_PHY_RG_ANA_CAL_RG0, 0);\n+\tphy_write_mmd(phydev_p0, MDIO_MMD_VEND1, MTK_PHY_RG_ANA_CAL_RG1, 0);\n+\tphy_write_mmd(phydev, MDIO_MMD_VEND1, 0x96, 0x0);\n+\tphy_write_mmd(phydev, MDIO_MMD_VEND1, 0x3e, 0xc000);\n+\tphy_write_mmd(phydev, MDIO_MMD_VEND1, 0xdd, 0);\n+\n+\t/* Restore BMCR */\n+\tphy_write(phydev, MII_BMCR, bmcr_tmp);\n+\n+\t/* Restore MDI */\n+\tphy_write_mmd(phydev, MDIO_MMD_VEND1, 0x0145, dev1e_145_tmp);\n+\n+\treturn 0;\n+}\n+\n+static int airoha_tx_amp_cal_sw(struct phy_device *phydev, u8 txg_calen_x)\n+{\n+\tstruct airoha_socphy_shared *shared = phy_package_get_priv(phydev);\n+\tu16 mask_gbe, mask_tbt, mask_tst, mask_hbt;\n+\tu16 reg, reg_100, reg_dac1, reg_dac2;\n+\tstruct phy_device *phydev_p0;\n+\tint calibration_polarity;\n+\tu8 zcal_ctrl = 32;\n+\tint first_calib;\n+\tint ret;\n+\n+\tphydev_p0 = shared-\u003ephydev_p0;\n+\n+\t/* BG voltage output */\n+\tphy_write_mmd(phydev_p0, MDIO_MMD_VEND2, 0x100, 0xc000);\n+\n+\tphy_write_mmd(phydev, MDIO_MMD_VEND1, 0x145, 0x1010);\n+\n+\tphy_write_mmd(phydev_p0, MDIO_MMD_VEND1, MTK_PHY_RG_ANA_CAL_RG0,\n+\t\t      MTK_PHY_RG_CAL_CKINV | MTK_PHY_RG_ANA_CALEN);\n+\tphy_write_mmd(phydev_p0, MDIO_MMD_VEND1, MTK_PHY_RG_ANA_CAL_RG1,\n+\t\t      MTK_PHY_RG_TXVOS_CALEN);\n+\n+\t/* select 1V */\n+\tphy_write_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_RG_ANA_CAL_RG6, 0x10);\n+\n+\t/* enable Tx VLD*/\n+\tphy_write_mmd(phydev, MDIO_MMD_VEND1, 0x3e, 0xf808);\n+\n+\t/* Force 1G full duplex for calibration */\n+\tphy_write(phydev, MII_BMCR, BMCR_FULLDPLX | BMCR_SPEED1000);\n+\n+\tphy_write_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_RG_DASN_DAC_IN0_A,\n+\t\t      0x8000 | 0xf0);\n+\tphy_write_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_RG_DASN_DAC_IN1_A,\n+\t\t      0x8000 | 0xf0);\n+\tphy_write_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_RG_DASN_DAC_IN0_B,\n+\t\t      0x8000 | 0xf0);\n+\tphy_write_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_RG_DASN_DAC_IN1_B,\n+\t\t      0x8000 | 0xf0);\n+\tphy_write_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_RG_DASN_DAC_IN0_C,\n+\t\t      0x8000 | 0xf0);\n+\tphy_write_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_RG_DASN_DAC_IN1_C,\n+\t\t      0x8000 | 0xf0);\n+\tphy_write_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_RG_DASN_DAC_IN0_D,\n+\t\t      0x8000 | 0xf0);\n+\tphy_write_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_RG_DASN_DAC_IN1_D,\n+\t\t      0x8000 | 0xf0);\n+\n+\tswitch (txg_calen_x) {\n+\tcase PAIR_A:\n+\t\tphy_write_mmd(phydev, MDIO_MMD_VEND1, 0xdd, BIT(12));\n+\t\treg_dac1 = MTK_PHY_RG_DASN_DAC_IN0_A;\n+\t\treg_dac2 = MTK_PHY_RG_DASN_DAC_IN1_A;\n+\t\treg = MTK_PHY_TXVLD_DA_RG;\n+\t\tmask_gbe = MTK_PHY_DA_TX_I2MPB_A_GBE_MASK;\n+\t\tmask_tbt = MTK_PHY_DA_TX_I2MPB_A_TBT_MASK;\n+\t\treg_100 = MTK_PHY_TX_I2MPB_TEST_MODE_A2;\n+\t\tmask_hbt = MTK_PHY_DA_TX_I2MPB_A_HBT_MASK;\n+\t\tmask_tst = MTK_PHY_DA_TX_I2MPB_A_TST_MASK;\n+\t\tbreak;\n+\tcase PAIR_B:\n+\t\tphy_write_mmd(phydev, MDIO_MMD_VEND1, 0xdd, BIT(8));\n+\t\treg_dac1 = MTK_PHY_RG_DASN_DAC_IN0_B;\n+\t\treg_dac2 = MTK_PHY_RG_DASN_DAC_IN1_B;\n+\t\treg = MTK_PHY_TX_I2MPB_TEST_MODE_B1;\n+\t\tmask_gbe = MTK_PHY_DA_TX_I2MPB_B_GBE_MASK;\n+\t\tmask_tbt = MTK_PHY_DA_TX_I2MPB_B_TBT_MASK;\n+\t\treg_100 = MTK_PHY_TX_I2MPB_TEST_MODE_B2;\n+\t\tmask_hbt = MTK_PHY_DA_TX_I2MPB_B_HBT_MASK;\n+\t\tmask_tst = MTK_PHY_DA_TX_I2MPB_B_TST_MASK;\n+\t\tbreak;\n+\tcase PAIR_C:\n+\t\tphy_write_mmd(phydev, MDIO_MMD_VEND1, 0xdd, BIT(4));\n+\t\treg_dac1 = MTK_PHY_RG_DASN_DAC_IN0_C;\n+\t\treg_dac2 = MTK_PHY_RG_DASN_DAC_IN1_C;\n+\t\treg = MTK_PHY_TX_I2MPB_TEST_MODE_C1;\n+\t\tmask_gbe = MTK_PHY_DA_TX_I2MPB_C_GBE_MASK;\n+\t\tmask_tbt = MTK_PHY_DA_TX_I2MPB_C_TBT_MASK;\n+\t\treg_100 = MTK_PHY_TX_I2MPB_TEST_MODE_C2;\n+\t\tmask_hbt = MTK_PHY_DA_TX_I2MPB_C_HBT_MASK;\n+\t\tmask_tst = MTK_PHY_DA_TX_I2MPB_C_TST_MASK;\n+\t\tbreak;\n+\tcase PAIR_D:\n+\t\tphy_write_mmd(phydev, MDIO_MMD_VEND1, 0xdd, BIT(0));\n+\t\treg_dac1 = MTK_PHY_RG_DASN_DAC_IN0_D;\n+\t\treg_dac2 = MTK_PHY_RG_DASN_DAC_IN1_D;\n+\t\treg = MTK_PHY_TX_I2MPB_TEST_MODE_D1;\n+\t\tmask_gbe = MTK_PHY_DA_TX_I2MPB_D_GBE_MASK;\n+\t\tmask_tbt = MTK_PHY_DA_TX_I2MPB_D_TBT_MASK;\n+\t\treg_100 = MTK_PHY_TX_I2MPB_TEST_MODE_D2;\n+\t\tmask_hbt = MTK_PHY_DA_TX_I2MPB_D_HBT_MASK;\n+\t\tmask_tst = MTK_PHY_DA_TX_I2MPB_D_TST_MASK;\n+\t\tbreak;\n+\tdefault:\n+\t\treturn -EINVAL;\n+\t}\n+\n+\tphy_write_mmd(phydev, MDIO_MMD_VEND1, reg_dac1,\n+\t\t      0x8000 | 0xf0);\n+\tphy_write_mmd(phydev, MDIO_MMD_VEND1, reg_dac2,\n+\t\t      0x8000 | 0xf0);\n+\n+\tphydev_dbg(phydev, \"Start TX Amp SW cal.\\n\");\n+\tfirst_calib = airoha_cal_cycle(phydev, MDIO_MMD_VEND1, reg,\n+\t\t\t\t       mask_gbe, zcal_ctrl \u003c\u003c __ffs(mask_gbe));\n+\n+\t/* If TX Amp calibration failed:\n+\t * - increase dB until calibration succeed.\n+\t * If TX Amp calibration succeeded:\n+\t * - decrease dB until calibration fail to fine tune it.\n+\t */\n+\tif (first_calib == 1)\n+\t\tcalibration_polarity = -1;\n+\telse\n+\t\tcalibration_polarity = 1;\n+\n+\twhile (zcal_ctrl \u003e 0 \u0026\u0026\n+\t       zcal_ctrl \u003c FIELD_MAX(MTK_PHY_RG_REXT_ZCAL_CTRL_MASK)) {\n+\t\tzcal_ctrl += calibration_polarity;\n+\n+\t\tret = airoha_cal_cycle(phydev, MDIO_MMD_VEND1, reg,\n+\t\t\t\t       mask_gbe, zcal_ctrl \u003c\u003c __ffs(mask_gbe));\n+\t\t/* Exit if we either failed or succeeded compared to the\n+\t\t * first calibration result. (aka we finished fine tuning or\n+\t\t * we succeeded with calibration)\n+\t\t */\n+\t\tif (ret != first_calib)\n+\t\t\tbreak;\n+\t}\n+\n+\tif (ret \u003c 0) {\n+\t\tphydev_err(phydev, \"TX AMP calibration failed.\\n\");\n+\t\tzcal_ctrl = 32;\n+\t\tphy_modify_mmd(phydev, MDIO_MMD_VEND1, reg,\n+\t\t\t       mask_gbe | mask_tbt,\n+\t\t\t       (zcal_ctrl \u003c\u003c __ffs(mask_gbe)) |\n+\t\t\t       (zcal_ctrl \u003c\u003c __ffs(mask_tbt)));\n+\n+\t\treturn -EINVAL;\n+\t}\n+\n+\tif (zcal_ctrl == 0 ||\n+\t    zcal_ctrl == FIELD_MAX(MTK_PHY_RG_REXT_ZCAL_CTRL_MASK))\n+\t\tphydev_warn(phydev, \"TX AMP SW calibration saturation.\\n\");\n+\n+\tphy_modify_mmd(phydev, MDIO_MMD_VEND1, reg,\n+\t\t       mask_gbe | mask_tbt,\n+\t\t       (zcal_ctrl \u003c\u003c __ffs(mask_gbe)) |\n+\t\t       (zcal_ctrl \u003c\u003c __ffs(mask_tbt)));\n+\n+\tphy_modify_mmd(phydev, MDIO_MMD_VEND1, reg_100,\n+\t\t       mask_hbt | mask_tst,\n+\t\t       (zcal_ctrl \u003c\u003c __ffs(mask_hbt)) |\n+\t\t       (zcal_ctrl \u003c\u003c __ffs(mask_tst)));\n+\n+\tphy_write_mmd(phydev_p0, MDIO_MMD_VEND2, 0x100, 0x0);\n+\n+\tphy_write_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_RG_DASN_DAC_IN0_A, 0);\n+\tphy_write_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_RG_DASN_DAC_IN0_B, 0);\n+\tphy_write_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_RG_DASN_DAC_IN0_C, 0);\n+\tphy_write_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_RG_DASN_DAC_IN0_D, 0);\n+\tphy_write_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_RG_DASN_DAC_IN1_A, 0);\n+\tphy_write_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_RG_DASN_DAC_IN1_B, 0);\n+\tphy_write_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_RG_DASN_DAC_IN1_C, 0);\n+\tphy_write_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_RG_DASN_DAC_IN1_D, 0);\n+\tphy_write_mmd(phydev_p0, MDIO_MMD_VEND1, 0x145, 0x1000);\n+\n+\tphy_write_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_RG_ANA_CAL_RG0, 0);\n+\tphy_write_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_RG_ANA_CAL_RG1, 0);\n+\tphy_write_mmd(phydev_p0, MDIO_MMD_VEND1, MTK_PHY_RG_ANA_CAL_RG0, 0);\n+\tphy_write_mmd(phydev_p0, MDIO_MMD_VEND1, MTK_PHY_RG_ANA_CAL_RG1, 0);\n+\tphy_write_mmd(phydev, MDIO_MMD_VEND1, 0x3e, 0xc000);\n+\tphy_write_mmd(phydev, MDIO_MMD_VEND1, 0xdd, 0);\n+\n+\t/* Restore AN enable */\n+\tphy_write(phydev, MII_BMCR, BMCR_ANENABLE);\n+\n+\treturn 0;\n+}\n+\n+static int airoha_tx_r50_cal_sw(struct phy_device *phydev, u8 txg_calen_x)\n+{\n+\tstruct airoha_socphy_shared *shared = phy_package_get_priv(phydev);\n+\tstruct phy_device *phydev_p0;\n+\tu16 dev1e_145_tmp, bmcr_tmp;\n+\tint calibration_polarity;\n+\tu8 zcal_ctrl = 32;\n+\tint first_calib;\n+\tu16 val;\n+\tint ret;\n+\n+\tphydev_p0 = shared-\u003ephydev_p0;\n+\n+\t/* BG voltage output */\n+\tphy_write_mmd(phydev_p0, MDIO_MMD_VEND2, 0x100, 0xc000);\n+\n+\tphy_write_mmd(phydev_p0, MDIO_MMD_VEND1, MTK_PHY_RG_ANA_CAL_RG0,\n+\t\t      MTK_PHY_RG_CAL_CKINV | MTK_PHY_RG_ANA_CALEN);\n+\tphy_write_mmd(phydev_p0, MDIO_MMD_VEND1, MTK_PHY_RG_ANA_CAL_RG1, 0);\n+\t/* select 1V */\n+\tphy_write_mmd(phydev_p0, MDIO_MMD_VEND1, MTK_PHY_RG_ANA_CAL_RG6, 0x10);\n+\n+\tphy_write_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_RG_ANA_CAL_RG0,\n+\t\t      MTK_PHY_RG_CAL_CKINV | MTK_PHY_RG_ANA_CALEN);\n+\tphy_write_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_RG_ANA_CAL_RG1, 0);\n+\t/* select 1V */\n+\tphy_write_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_RG_ANA_CAL_RG6, 0x10);\n+\n+\t/* Force 1G full duplex for calibration */\n+\tbmcr_tmp = phy_read(phydev, MII_BMCR);\n+\tphy_write(phydev, MII_BMCR, BMCR_FULLDPLX | BMCR_SPEED1000);\n+\n+\t/* Force MDI */\n+\tdev1e_145_tmp = phy_read_mmd(phydev, MDIO_MMD_VEND1, 0x0145);\n+\tphy_write_mmd(phydev, MDIO_MMD_VEND1, 0x0145, 0x1010);\n+\n+\t/* disable tx slew control */\n+\tphy_write_mmd(phydev, MDIO_MMD_VEND1, 0x0185, 0x0000);\n+\tphy_write_mmd(phydev, MDIO_MMD_VEND1, 0x00fb, 0x0100);\n+\n+\tswitch (txg_calen_x) {\n+\tcase PAIR_A:\n+\t\tphy_set_bits_mmd(phydev, MDIO_MMD_VEND1,\n+\t\t\t\t MTK_PHY_RG_ANA_CAL_RG0,\n+\t\t\t\t MTK_PHY_RG_ZCALEN_A);\n+\t\tbreak;\n+\tcase PAIR_B:\n+\t\tphy_set_bits_mmd(phydev, MDIO_MMD_VEND1,\n+\t\t\t\t MTK_PHY_RG_ANA_CAL_RG1,\n+\t\t\t\t MTK_PHY_RG_ZCALEN_B);\n+\t\tbreak;\n+\tcase PAIR_C:\n+\t\tphy_set_bits_mmd(phydev, MDIO_MMD_VEND1,\n+\t\t\t\t MTK_PHY_RG_ANA_CAL_RG1,\n+\t\t\t\t MTK_PHY_RG_ZCALEN_C);\n+\t\tbreak;\n+\tcase PAIR_D:\n+\t\tphy_set_bits_mmd(phydev, MDIO_MMD_VEND1,\n+\t\t\t\t MTK_PHY_RG_ANA_CAL_RG1,\n+\t\t\t\t MTK_PHY_RG_ZCALEN_D);\n+\t\tbreak;\n+\tdefault:\n+\t\treturn -EINVAL;\n+\t}\n+\n+\tphydev_dbg(phydev, \"Start TX r50 SW cal.\\n\");\n+\tfirst_calib = airoha_cal_cycle(phydev_p0, MDIO_MMD_VEND1, MTK_PHY_RG_ANA_CAL_RG5,\n+\t\t\t\t       MTK_PHY_RG_REXT_ZCAL_CTRL_MASK, zcal_ctrl);\n+\n+\tif (first_calib \u003c 0) {\n+\t\tphydev_err(phydev, \"TX r50 SW calibration failed.\\n\");\n+\t\treturn -EINVAL;\n+\t}\n+\n+\t/* If TX r50 calibration failed:\n+\t * - increase dB until calibration succeed.\n+\t * If TX r50 calibration succeeded:\n+\t * - decrease dB until calibration fail to fine tune it.\n+\t */\n+\tif (first_calib == 1)\n+\t\tcalibration_polarity = -1;\n+\telse\n+\t\tcalibration_polarity = 1;\n+\n+\twhile (zcal_ctrl \u003e 0 \u0026\u0026\n+\t       zcal_ctrl \u003c FIELD_MAX(MTK_PHY_RG_REXT_ZCAL_CTRL_MASK)) {\n+\t\tzcal_ctrl += calibration_polarity;\n+\n+\t\tret = airoha_cal_cycle(phydev_p0, MDIO_MMD_VEND1, MTK_PHY_RG_ANA_CAL_RG5,\n+\t\t\t\t       MTK_PHY_RG_REXT_ZCAL_CTRL_MASK, zcal_ctrl);\n+\t\t/* Exit if we either failed or succeeded compared to the\n+\t\t * first calibration result. (aka we finished fine tuning or\n+\t\t * we succeeded with calibration)\n+\t\t */\n+\t\tif (ret != first_calib)\n+\t\t\tbreak;\n+\t}\n+\n+\tif (ret \u003c 0) {\n+\t\tphydev_err(phydev, \"TX r50 SW calibration failed.\\n\");\n+\t\treturn -EINVAL;\n+\t}\n+\n+\tif (zcal_ctrl == 0 ||\n+\t    zcal_ctrl == FIELD_MAX(MTK_PHY_RG_REXT_ZCAL_CTRL_MASK))\n+\t\tphydev_warn(phydev, \"TX r50 SW calibration saturation.\\n\");\n+\n+\tzcal_ctrl = shared-\u003er50_cal_tbl[zcal_ctrl];\n+\n+\tswitch (txg_calen_x) {\n+\tcase PAIR_A:\n+\t\tval = BIT(15) | FIELD_PREP(AIROHA_PHY_CR_TX_R50_OFFSET_A_MASK, zcal_ctrl);\n+\t\tphy_modify_mmd(phydev, MDIO_MMD_VEND1,\n+\t\t\t       MTK_PHY_RG_CR_TX_R50_OFFSET_A_B,\n+\t\t\t       BIT(15) | AIROHA_PHY_CR_TX_R50_OFFSET_A_MASK, val);\n+\t\tbreak;\n+\tcase PAIR_B:\n+\t\tval = BIT(7) | FIELD_PREP(MTK_PHY_CR_TX_R50_OFFSET_B_MASK, zcal_ctrl);\n+\t\tphy_modify_mmd(phydev, MDIO_MMD_VEND1,\n+\t\t\t       MTK_PHY_RG_CR_TX_R50_OFFSET_A_B,\n+\t\t\t       BIT(7) | MTK_PHY_CR_TX_R50_OFFSET_B_MASK, val);\n+\t\tbreak;\n+\tcase PAIR_C:\n+\t\tval = BIT(15) | FIELD_PREP(AIROHA_PHY_CR_TX_R50_OFFSET_C_MASK, zcal_ctrl);\n+\t\tphy_modify_mmd(phydev, MDIO_MMD_VEND1,\n+\t\t\t       MTK_PHY_RG_CR_TX_R50_OFFSET_C_D,\n+\t\t\t       BIT(15) | AIROHA_PHY_CR_TX_R50_OFFSET_C_MASK, val);\n+\t\tbreak;\n+\tcase PAIR_D:\n+\t\tval = BIT(7) | FIELD_PREP(MTK_PHY_CR_TX_R50_OFFSET_D_MASK, zcal_ctrl);\n+\t\tphy_modify_mmd(phydev, MDIO_MMD_VEND1,\n+\t\t\t       MTK_PHY_RG_CR_TX_R50_OFFSET_C_D,\n+\t\t\t       BIT(7) | MTK_PHY_CR_TX_R50_OFFSET_D_MASK, val);\n+\t\tbreak;\n+\tdefault:\n+\t\treturn -EINVAL;\n+\t}\n+\n+\tphy_write_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_RG_ANA_CAL_RG0, 0);\n+\tphy_write_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_RG_ANA_CAL_RG1, 0);\n+\tphy_write_mmd(phydev_p0, MDIO_MMD_VEND1, MTK_PHY_RG_ANA_CAL_RG0, 0);\n+\tphy_write_mmd(phydev_p0, MDIO_MMD_VEND1, MTK_PHY_RG_ANA_CAL_RG1, 0);\n+\n+\t/* Enable tx slew control */\n+\tphy_write_mmd(phydev, MDIO_MMD_VEND1, 0x0185, 0x0001);\n+\tphy_write_mmd(phydev, MDIO_MMD_VEND1, 0x00fb, 0x0000);\n+\n+\tphy_write_mmd(phydev_p0, MDIO_MMD_VEND2, 0x100, 0x0);\n+\n+\tphy_write_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_RG_ANA_CAL_RG6, 0x0);\n+\tphy_write_mmd(phydev_p0, MDIO_MMD_VEND1, MTK_PHY_RG_ANA_CAL_RG6, 0x0);\n+\n+\t/* Restore BMCR */\n+\tphy_write(phydev, MII_BMCR, bmcr_tmp);\n+\n+\t/* Restore MDI */\n+\tphy_write_mmd(phydev, MDIO_MMD_VEND1, 0x0145, dev1e_145_tmp);\n+\n+\treturn 0;\n+}\n+\n+static int airoha_rx_offset_cal_sw(struct phy_device *phydev)\n+{\n+\t/* Hw bypass, Fw cal */\n+\tphy_write_mmd(phydev, MDIO_MMD_VEND1, 0x96, 0x0);\n+\t/* tx/rx_cal_criteria_value */\n+\tphy_write_mmd(phydev, MDIO_MMD_VEND1, 0x37, 0x0033);\n+\n+\t/* rx offset cal by Hw setup */\n+\tphy_clear_bits_mmd(phydev, MDIO_MMD_VEND1, 0x39,\n+\t\t\t   BIT(14) | BIT(11));\n+\n+\t/* disable rtune calibration */\n+\tphy_clear_bits_mmd(phydev, MDIO_MMD_VEND2, 0x107,\n+\t\t\t   BIT(12));\n+\n+\t/* bypass tx/rx dc offset cancellation process */\n+\tphy_set_bits_mmd(phydev, MDIO_MMD_VEND1, 0x171,\n+\t\t\t BIT(8) | BIT(7));\n+\n+\t/* rx offset calibration start */\n+\tphy_set_bits_mmd(phydev, MDIO_MMD_VEND1, 0x39,\n+\t\t\t BIT(13));\n+\n+\t/* rx offset calibration stop */\n+\tphy_clear_bits_mmd(phydev, MDIO_MMD_VEND1, 0x39,\n+\t\t\t   BIT(13));\n+\n+\tmdelay(10);\n+\n+\tphy_clear_bits_mmd(phydev, MDIO_MMD_VEND1, 0x171,\n+\t\t\t   BIT(8) | BIT(7));\n+\n+\tphy_write_mmd(phydev, MDIO_MMD_VEND2, 0x100, 0x0);\n+\tphy_write_mmd(phydev, MDIO_MMD_VEND1, 0x145, 0x1000);\n+\n+\tif (phydev-\u003edrv-\u003ephy_id == AIROHA_GPHY_ID_AN7581)\n+\t\tphy_write_mmd(phydev, MDIO_MMD_VEND1,\n+\t\t\t      MTK_PHY_RG_ANA_CAL_RG6, 0x1);\n+\n+\treturn 0;\n+}\n+\n+static int airoha_cal_sw(struct phy_device *phydev, enum CAL_ITEM cal_item,\n+\t\t\t u8 start_pair, u8 end_pair)\n+{\n+\tu8 pair_n;\n+\tint ret;\n+\n+\tfor (pair_n = start_pair; pair_n \u003c= end_pair; pair_n++) {\n+\t\tswitch (cal_item) {\n+\t\tcase REXT:\n+\t\t\tret = airoha_rext_cal_sw(phydev);\n+\t\t\tbreak;\n+\t\tcase TX_OFFSET:\n+\t\t\tret = airoha_tx_offset_cal_sw(phydev, pair_n);\n+\t\t\tbreak;\n+\t\tcase TX_AMP:\n+\t\t\tret = airoha_tx_amp_cal_sw(phydev, pair_n);\n+\t\t\tbreak;\n+\t\tcase TX_R50:\n+\t\t\tret = airoha_tx_r50_cal_sw(phydev, pair_n);\n+\t\t\tbreak;\n+\t\tcase RX_OFFSET:\n+\t\t\tret = airoha_rx_offset_cal_sw(phydev);\n+\t\t\tbreak;\n+\t\tdefault:\n+\t\t\treturn -EINVAL;\n+\t\t}\n+\t\tif (ret)\n+\t\t\treturn ret;\n+\t}\n+\treturn 0;\n+}\n+\n+static int airoha_start_cal(struct phy_device *phydev, enum CAL_ITEM cal_item,\n+\t\t\t    enum CAL_MODE cal_mode, u8 start_pair,\n+\t\t\t    u8 end_pair, u32 *buf)\n+{\n+\tint ret;\n+\n+\tswitch (cal_mode) {\n+\tcase SW_M:\n+\t\tret = airoha_cal_sw(phydev, cal_item, start_pair, end_pair);\n+\t\tbreak;\n+\tdefault:\n+\t\treturn -EINVAL;\n+\t}\n+\n+\tif (ret) {\n+\t\tphydev_err(phydev, \"cal %d failed\\n\", cal_item);\n+\t\treturn -EIO;\n+\t}\n+\n+\treturn 0;\n+}\n+\n+static int airoha_phy_calib(struct phy_device *phydev)\n+{\n+\tstruct airoha_socphy_shared *shared = phy_package_get_priv(phydev);\n+\tstruct phy_device *phydev_p0;\n+\tint ret;\n+\n+\tphydev_p0 = shared-\u003ephydev_p0;\n+\n+\t/* PreCalibrate Set */\n+\tphy_write_mmd(phydev, MDIO_MMD_VEND1, 0x5c, 0x6666);\n+\n+\tif (!shared-\u003erext_sw_calib_done) {\n+\t\tret = airoha_start_cal(phydev, REXT, SW_M, NO_PAIR, NO_PAIR, NULL);\n+\t\tif (ret)\n+\t\t\treturn ret;\n+\n+\t\tshared-\u003erext_sw_calib_done = true;\n+\t}\n+\n+\tret = airoha_start_cal(phydev, TX_R50, SW_M, PAIR_A, PAIR_D, NULL);\n+\tif (ret)\n+\t\treturn ret;\n+\n+\tret = airoha_start_cal(phydev, TX_OFFSET, SW_M, PAIR_A, PAIR_D, NULL);\n+\tif (ret)\n+\t\treturn ret;\n+\n+\tret = airoha_start_cal(phydev, TX_AMP, SW_M, PAIR_A, PAIR_D, NULL);\n+\tif (ret)\n+\t\treturn ret;\n+\n+\tret = airoha_start_cal(phydev, RX_OFFSET, SW_M, NO_PAIR, NO_PAIR, NULL);\n+\tif (ret)\n+\t\treturn ret;\n+\n+\t/* Gating, short with other pair */\n+\tphy_write_mmd(phydev, MDIO_MMD_VEND1, 0x15, 0x0);\n+\n+\tphy_write_mmd(phydev_p0, MDIO_MMD_VEND2, 0x100, 0x0);\n+\n+\treturn 0;\n+}\n+\n+static int airoha_phy_auto_select_transformer(struct phy_device *phydev)\n+{\n+\tstruct airoha_socphy_shared *shared = phy_package_get_priv(phydev);\n+\tstruct phy_device *phydev_p0;\n+\tu8 phy_offset;\n+\tu16 bmcr_tmp;\n+\tu16 val;\n+\tint i;\n+\n+\tphydev_p0 = shared-\u003ephydev_p0;\n+\tphy_offset = phydev-\u003emdio.addr - phydev_p0-\u003emdio.addr;\n+\n+\t/* Force 1G full duplex for calibration */\n+\tbmcr_tmp = phy_read(phydev, MII_BMCR);\n+\tphy_write(phydev, MII_BMCR, BMCR_FULLDPLX | BMCR_SPEED1000);\n+\n+\tphy_modify_mmd(phydev, MDIO_MMD_VEND2, 0x271, GENMASK(4, 0),\n+\t\t       FIELD_PREP(GENMASK(4, 0), 0x3));\n+\n+\tphy_modify_mmd(phydev, MDIO_MMD_VEND2, 0x269, GENMASK(15, 12),\n+\t\t       FIELD_PREP(GENMASK(15, 12), 0x2));\n+\n+\tphy_modify_mmd(phydev, MDIO_MMD_VEND2, 0x26f, GENMASK(14, 12),\n+\t\t       FIELD_PREP(GENMASK(14, 12), 0x0));\n+\n+\tphy_write_mmd(phydev, MDIO_MMD_VEND1, 0xdd, BIT(12));\n+\n+\tphy_write_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_RG_DASN_DAC_IN0_A,\n+\t\t      0x8000 | 0xf0);\n+\tphy_write_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_RG_DASN_DAC_IN1_A,\n+\t\t      0x8000 | 0xf0);\n+\tphy_write_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_RG_DASN_DAC_IN0_B,\n+\t\t      0x8000 | 0xf0);\n+\tphy_write_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_RG_DASN_DAC_IN1_B,\n+\t\t      0x8000 | 0xf0);\n+\tphy_write_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_RG_DASN_DAC_IN0_C,\n+\t\t      0x8000 | 0xf0);\n+\tphy_write_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_RG_DASN_DAC_IN1_C,\n+\t\t      0x8000 | 0xf0);\n+\tphy_write_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_RG_DASN_DAC_IN0_D,\n+\t\t      0x8000 | 0xf0);\n+\tphy_write_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_RG_DASN_DAC_IN1_D,\n+\t\t      0x8000 | 0xf0);\n+\n+\t/* Force pGA gain */\n+\tphy_select_page(phydev, MTK_PHY_PAGE_EXTENDED_52B5);\n+\t__mtk_tr_modify(phydev, 0x1, 0xf, 0x10,\n+\t\t\tGENMASK(20, 15),\n+\t\t\tFIELD_PREP(GENMASK(20, 15), 0x1f));\n+\n+\t__mtk_tr_modify(phydev, 0x1, 0xf, 0x11,\n+\t\t\tGENMASK(23, 18) | GENMASK(15, 10) | GENMASK(7, 2),\n+\t\t\tFIELD_PREP(GENMASK(23, 18), 0x1f) |\n+\t\t\tFIELD_PREP(GENMASK(15, 10), 0x1f) |\n+\t\t\tFIELD_PREP(GENMASK(7, 2), 0x1f));\n+\tphy_restore_page(phydev, MTK_PHY_PAGE_STANDARD, 0);\n+\n+\tphy_write_mmd(phydev, MDIO_MMD_VEND1, 0xc9, 0xffff);\n+\tphy_write_mmd(phydev, MDIO_MMD_VEND1, 0x151, 0x12);\n+\n+\tswitch (phy_offset) {\n+\tcase 0:\n+\t\tval = 0x1;\n+\t\tbreak;\n+\tcase 1:\n+\t\tval = 0x3;\n+\t\tbreak;\n+\tcase 2:\n+\t\tval = 0x5;\n+\t\tbreak;\n+\tcase 3:\n+\t\tval = 0x7;\n+\t\tbreak;\n+\tdefault:\n+\t\treturn -EINVAL;\n+\t}\n+\tphy_write_mmd(phydev, MDIO_MMD_VEND2, 0x15,\n+\t\t      FIELD_PREP(GENMASK(14, 12), val) | 0x161);\n+\tmdelay(500);\n+\n+\tfor (i = 0; i \u003c 3; i++)\n+\t\tval = phy_read_mmd(phydev, MDIO_MMD_VEND2, 0x1a);\n+\n+\t/* Check the value and report transformer type for later */\n+\tshared-\u003etransformer_type[phy_offset] = val \u003c 0xe0;\n+\n+\t/* Switch to Default */\n+\tphy_write_mmd(phydev, MDIO_MMD_VEND2, 0x15, 0x1000);\n+\n+\tphy_write_mmd(phydev, MDIO_MMD_VEND1, 0xdd, 0x0);\n+\n+\tphy_write_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_RG_DASN_DAC_IN0_A,\n+\t\t      0x0);\n+\tphy_write_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_RG_DASN_DAC_IN1_A,\n+\t\t      0x0);\n+\tphy_write_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_RG_DASN_DAC_IN0_B,\n+\t\t      0x0);\n+\tphy_write_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_RG_DASN_DAC_IN1_B,\n+\t\t      0x0);\n+\tphy_write_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_RG_DASN_DAC_IN0_C,\n+\t\t      0x0);\n+\tphy_write_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_RG_DASN_DAC_IN1_C,\n+\t\t      0x0);\n+\tphy_write_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_RG_DASN_DAC_IN0_D,\n+\t\t      0x0);\n+\tphy_write_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_RG_DASN_DAC_IN1_D,\n+\t\t      0x0);\n+\n+\tphy_write_mmd(phydev, MDIO_MMD_VEND1, 0xc9, 0xfff);\n+\tphy_write_mmd(phydev, MDIO_MMD_VEND1, 0x151, 0x0);\n+\n+\tphy_select_page(phydev, MTK_PHY_PAGE_EXTENDED_52B5);\n+\t__mtk_tr_modify(phydev, 0x1, 0xf, 0x10,\n+\t\t\tGENMASK(20, 15),\n+\t\t\tFIELD_PREP(GENMASK(20, 15), 0x4));\n+\n+\t__mtk_tr_modify(phydev, 0x1, 0xf, 0x11,\n+\t\t\tGENMASK(23, 18) | GENMASK(15, 10) | GENMASK(7, 2),\n+\t\t\tFIELD_PREP(GENMASK(23, 18), 0x0) |\n+\t\t\tFIELD_PREP(GENMASK(15, 10), 0x0) |\n+\t\t\tFIELD_PREP(GENMASK(7, 2), 0x0));\n+\tphy_restore_page(phydev, MTK_PHY_PAGE_STANDARD, 0);\n+\n+\t/* Restore BMCR */\n+\tphy_write(phydev, MII_BMCR, bmcr_tmp);\n+\n+\treturn 0;\n+}\n+\n+static int airoha_phy_tx_amp_compensation(struct phy_device *phydev)\n+{\n+\tstruct airoha_socphy_shared *shared = phy_package_get_priv(phydev);\n+\n+\tu16 reg_1e_12_read;\n+\tu16 reg_1e_16_read;\n+\tu16 reg_1e_17_read;\n+\tu16 reg_1e_18_read;\n+\tu16 reg_1e_19_read;\n+\tu16 reg_1e_20_read;\n+\tu16 reg_1e_21_read;\n+\tu16 reg_1e_22_read;\n+\tu16 reg_1e_174_read;\n+\tu16 reg_1e_175_read;\n+\n+\tint reg_1e_12_header;\n+\tint reg_1e_16_header;\n+\tint reg_1e_17_header;\n+\tint reg_1e_18_header;\n+\tint reg_1e_19_header;\n+\tint reg_1e_21_header;\n+\tint reg_1e_174_header;\n+\tint reg_1e_175_header;\n+\n+\tint reg_1e_12_end;\n+\tint reg_1e_16_end;\n+\tint reg_1e_17_end;\n+\tint reg_1e_18_end;\n+\tint reg_1e_20_end;\n+\tint reg_1e_22_end;\n+\tint reg_1e_174_end;\n+\tint reg_1e_175_end;\n+\n+\tstruct phy_device *phydev_p0;\n+\tu8 phy_offset;\n+\n+\tint txamp_low_limit = -3;\n+\tint txamp_high_limit = 0x42;\n+\n+\tint r50_low_limit = -8;\n+\tint r50_high_limit = 0x88;\n+\n+\tbool overflow;\n+\tint (*tx_amp_table)[CALIB_CONST_TYPE_MAX][4];\n+\tint transformer_type, mdi_resister_type;\n+\n+\tphydev_p0 = shared-\u003ephydev_p0;\n+\tphy_offset = phydev-\u003emdio.addr - phydev_p0-\u003emdio.addr;\n+\n+\ttransformer_type = shared-\u003etransformer_type[phy_offset];\n+\tmdi_resister_type = shared-\u003emdi_resister_type;\n+\ttx_amp_table = \u0026(*shared-\u003etx_amp_compensation_tbl)[transformer_type][mdi_resister_type];\n+\n+\treg_1e_12_read = phy_read_mmd(phydev, MDIO_MMD_VEND1, 0x12);\n+\treg_1e_16_read = phy_read_mmd(phydev, MDIO_MMD_VEND1, 0x16);\n+\treg_1e_17_read = phy_read_mmd(phydev, MDIO_MMD_VEND1, 0x17);\n+\treg_1e_18_read = phy_read_mmd(phydev, MDIO_MMD_VEND1, 0x18);\n+\treg_1e_19_read = phy_read_mmd(phydev, MDIO_MMD_VEND1, 0x19);\n+\treg_1e_20_read = phy_read_mmd(phydev, MDIO_MMD_VEND1, 0x20);\n+\treg_1e_21_read = phy_read_mmd(phydev, MDIO_MMD_VEND1, 0x21);\n+\treg_1e_22_read = phy_read_mmd(phydev, MDIO_MMD_VEND1, 0x22);\n+\treg_1e_174_read = phy_read_mmd(phydev, MDIO_MMD_VEND1, 0x174);\n+\treg_1e_175_read = phy_read_mmd(phydev, MDIO_MMD_VEND1, 0x175);\n+\n+\treg_1e_12_header = ((reg_1e_12_read \u0026 0xfc00) / 1024) + (*tx_amp_table)[TX_AMP_1G_A][phy_offset];\n+\treg_1e_17_header = ((reg_1e_17_read \u0026 0x3f00) / 256) + (*tx_amp_table)[TX_AMP_1G_B][phy_offset];\n+\treg_1e_19_header = ((reg_1e_19_read \u0026 0x3f00) / 256) + (*tx_amp_table)[TX_AMP_1G_C][phy_offset];\n+\treg_1e_21_header = ((reg_1e_21_read \u0026 0x3f00) / 256) + (*tx_amp_table)[TX_AMP_1G_D][phy_offset];\n+\n+\toverflow = false;\n+\tif (reg_1e_12_header \u003c txamp_low_limit ||\n+\t    reg_1e_12_header \u003e txamp_high_limit)\n+\t\toverflow = true;\n+\tif (reg_1e_17_header \u003c txamp_low_limit ||\n+\t    reg_1e_17_header \u003e txamp_high_limit)\n+\t\toverflow = true;\n+\tif (reg_1e_19_header \u003c txamp_low_limit ||\n+\t    reg_1e_19_header \u003e txamp_high_limit)\n+\t\toverflow = true;\n+\tif (reg_1e_21_header \u003c txamp_low_limit ||\n+\t    reg_1e_21_header \u003e txamp_high_limit)\n+\t\toverflow = true;\n+\n+\tif (overflow) {\n+\t\treg_1e_12_header = 0x20;\n+\t\treg_1e_17_header = 0x20;\n+\t\treg_1e_19_header = 0x20;\n+\t\treg_1e_21_header = 0x20;\n+\t} else {\n+\t\tif (reg_1e_12_header \u003c 0)\n+\t\t\treg_1e_12_header = 0;\n+\t\telse if (reg_1e_12_header \u003e 0x3f)\n+\t\t\treg_1e_12_header = 0x3f;\n+\t\tif (reg_1e_17_header \u003c 0)\n+\t\t\treg_1e_17_header = 0;\n+\t\telse if (reg_1e_17_header \u003e 0x3f)\n+\t\t\treg_1e_17_header = 0x3f;\n+\t\tif (reg_1e_19_header \u003c 0)\n+\t\t\treg_1e_19_header = 0;\n+\t\telse if (reg_1e_19_header \u003e 0x3f)\n+\t\t\treg_1e_19_header = 0x3f;\n+\t\tif (reg_1e_21_header \u003c 0)\n+\t\t\treg_1e_21_header = 0;\n+\t\telse if (reg_1e_21_header \u003e 0x3f)\n+\t\t\treg_1e_21_header = 0x3f;\n+\t}\n+\n+\treg_1e_16_end = (reg_1e_16_read \u0026 0x003f) + (*tx_amp_table)[TX_AMP_TEST_A][phy_offset];\n+\treg_1e_18_end = (reg_1e_18_read \u0026 0x003f) + (*tx_amp_table)[TX_AMP_TEST_B][phy_offset];\n+\treg_1e_20_end = (reg_1e_20_read \u0026 0x003f) + (*tx_amp_table)[TX_AMP_TEST_C][phy_offset];\n+\treg_1e_22_end = (reg_1e_22_read \u0026 0x003f) + (*tx_amp_table)[TX_AMP_TEST_D][phy_offset];\n+\n+\toverflow = false;\n+\tif (reg_1e_16_end \u003c txamp_low_limit ||\n+\t    reg_1e_16_end \u003e txamp_high_limit)\n+\t\toverflow = true;\n+\tif (reg_1e_18_end \u003c txamp_low_limit ||\n+\t    reg_1e_18_end \u003e txamp_high_limit)\n+\t\toverflow = true;\n+\tif (reg_1e_20_end \u003c txamp_low_limit ||\n+\t    reg_1e_20_end \u003e txamp_high_limit)\n+\t\toverflow = true;\n+\tif (reg_1e_22_end \u003c txamp_low_limit ||\n+\t    reg_1e_22_end \u003e txamp_high_limit)\n+\t\toverflow = true;\n+\n+\tif (overflow) {\n+\t\treg_1e_16_end = 0x20;\n+\t\treg_1e_18_end = 0x20;\n+\t\treg_1e_20_end = 0x20;\n+\t\treg_1e_22_end = 0x20;\n+\t} else {\n+\t\tif (reg_1e_16_end \u003c 0)\n+\t\t\treg_1e_16_end = 0;\n+\t\telse if (reg_1e_16_end \u003e 0x3f)\n+\t\t\treg_1e_16_end = 0x3f;\n+\t\tif (reg_1e_18_end \u003c 0)\n+\t\t\treg_1e_18_end = 0;\n+\t\telse if (reg_1e_18_end \u003e 0x3f)\n+\t\t\treg_1e_18_end = 0x3f;\n+\t\tif (reg_1e_20_end \u003c 0)\n+\t\t\treg_1e_20_end = 0;\n+\t\telse if (reg_1e_20_end \u003e 0x3f)\n+\t\t\treg_1e_20_end = 0x3f;\n+\t\tif (reg_1e_22_end \u003c 0)\n+\t\t\treg_1e_22_end = 0;\n+\t\telse if (reg_1e_22_end \u003e 0x3f)\n+\t\t\treg_1e_22_end = 0x3f;\n+\t}\n+\n+\treg_1e_16_header = ((reg_1e_16_read \u0026 0xfc00) / 1024) + (*tx_amp_table)[TX_AMP_100M_A][phy_offset];\n+\treg_1e_18_header = ((reg_1e_18_read \u0026 0x3f00) / 256) + (*tx_amp_table)[TX_AMP_100M_B][phy_offset];\n+\n+\toverflow = false;\n+\tif (reg_1e_16_header \u003c txamp_low_limit ||\n+\t    reg_1e_16_header \u003e txamp_high_limit)\n+\t\toverflow = true;\n+\tif (reg_1e_18_header \u003c txamp_low_limit ||\n+\t    reg_1e_18_header \u003e txamp_high_limit)\n+\t\toverflow = true;\n+\n+\tif (overflow) {\n+\t\treg_1e_16_header = 0x20;\n+\t\treg_1e_18_header = 0x20;\n+\t} else {\n+\t\tif (reg_1e_16_header \u003c 0)\n+\t\t\treg_1e_16_header = 0;\n+\t\telse if (reg_1e_16_header \u003e 0x3f)\n+\t\t\treg_1e_16_header = 0x3f;\n+\t\tif (reg_1e_18_header \u003c 0)\n+\t\t\treg_1e_18_header = 0;\n+\t\telse if (reg_1e_18_header \u003e 0x3f)\n+\t\t\treg_1e_18_header = 0x3f;\n+\t}\n+\n+\treg_1e_12_end = (reg_1e_12_read \u0026 0x003f) + (*tx_amp_table)[TX_AMP_10M_A][phy_offset];\n+\treg_1e_17_end = (reg_1e_17_read \u0026 0x003f) + (*tx_amp_table)[TX_AMP_10M_B][phy_offset];\n+\n+\toverflow = false;\n+\tif (reg_1e_12_end \u003c txamp_low_limit ||\n+\t    reg_1e_12_end \u003e txamp_high_limit)\n+\t\toverflow = true;\n+\tif (reg_1e_17_end \u003c txamp_low_limit ||\n+\t    reg_1e_17_end \u003e txamp_high_limit)\n+\t\toverflow = true;\n+\n+\tif (overflow) {\n+\t\treg_1e_12_end = 0x20;\n+\t\treg_1e_17_end = 0x20;\n+\t} else {\n+\t\tif (reg_1e_12_end \u003c 0)\n+\t\t\treg_1e_12_end = 0;\n+\t\telse if (reg_1e_12_end \u003e 0x3f)\n+\t\t\treg_1e_12_end = 0x3f;\n+\t\tif (reg_1e_17_end \u003c 0)\n+\t\t\treg_1e_17_end = 0;\n+\t\telse if (reg_1e_17_end \u003e 0x3f)\n+\t\t\treg_1e_17_end = 0x3f;\n+\t}\n+\n+\treg_1e_174_header = ((reg_1e_174_read \u0026 0x7f00) / 256) + (*tx_amp_table)[R50_A][phy_offset];\n+\treg_1e_174_end = (reg_1e_174_read \u0026 0x007f) + (*tx_amp_table)[R50_B][phy_offset];\n+\treg_1e_175_header = ((reg_1e_175_read \u0026 0x7f00) / 256) + (*tx_amp_table)[R50_C][phy_offset];\n+\treg_1e_175_end = (reg_1e_175_read \u0026 0x007f) + (*tx_amp_table)[R50_D][phy_offset];\n+\n+\toverflow = false;\n+\tif (reg_1e_174_header \u003c r50_low_limit ||\n+\t    reg_1e_174_header \u003e r50_high_limit)\n+\t\toverflow = true;\n+\tif (reg_1e_174_end \u003c r50_low_limit ||\n+\t    reg_1e_174_end \u003e r50_high_limit)\n+\t\toverflow = true;\n+\tif (reg_1e_175_header \u003c r50_low_limit ||\n+\t    reg_1e_175_header \u003e r50_high_limit)\n+\t\toverflow = true;\n+\tif (reg_1e_175_end \u003c r50_low_limit ||\n+\t    reg_1e_175_end \u003e r50_high_limit)\n+\t\toverflow = true;\n+\n+\tif (overflow) {\n+\t\treg_1e_174_header = 0x34;\n+\t\treg_1e_174_end = 0x34;\n+\t\treg_1e_175_header = 0x34;\n+\t\treg_1e_175_end = 0x34;\n+\t} else {\n+\t\tif (reg_1e_174_header \u003c 0)\n+\t\t\treg_1e_174_header = 0;\n+\t\telse if (reg_1e_174_header \u003e 0x7f)\n+\t\t\treg_1e_174_header = 0x7f;\n+\t\tif (reg_1e_174_end \u003c 0)\n+\t\t\treg_1e_174_end = 0;\n+\t\telse if (reg_1e_174_end \u003e 0x7f)\n+\t\t\treg_1e_174_end = 0x7f;\n+\t\tif (reg_1e_175_header \u003c 0)\n+\t\t\treg_1e_175_header = 0;\n+\t\telse if (reg_1e_175_header \u003e 0x7f)\n+\t\t\treg_1e_175_header = 0x7f;\n+\t\tif (reg_1e_175_end \u003c 0)\n+\t\t\treg_1e_175_end = 0;\n+\t\telse if (reg_1e_175_end \u003e 0x7f)\n+\t\t\treg_1e_175_end = 0x7f;\n+\t}\n+\n+\tphy_write_mmd(phydev, MDIO_MMD_VEND1, 0x12,\n+\t\t      (reg_1e_12_header * 1024) + reg_1e_12_end);\n+\tphy_write_mmd(phydev, MDIO_MMD_VEND1, 0x16,\n+\t\t      (reg_1e_16_header * 1024) + reg_1e_16_end);\n+\tphy_write_mmd(phydev, MDIO_MMD_VEND1, 0x17,\n+\t\t      (reg_1e_17_header * 256) + reg_1e_17_end);\n+\tphy_write_mmd(phydev, MDIO_MMD_VEND1, 0x18,\n+\t\t      (reg_1e_18_header * 256) + reg_1e_18_end);\n+\tphy_write_mmd(phydev, MDIO_MMD_VEND1, 0x19,\n+\t\t      (reg_1e_19_read \u0026 0x00ff) + (reg_1e_19_header * 256));\n+\tphy_write_mmd(phydev, MDIO_MMD_VEND1, 0x20,\n+\t\t      (reg_1e_20_read \u0026 0xff00) + reg_1e_20_end);\n+\tphy_write_mmd(phydev, MDIO_MMD_VEND1, 0x21,\n+\t\t      (reg_1e_21_read \u0026 0x00ff) + (reg_1e_21_header * 256));\n+\tphy_write_mmd(phydev, MDIO_MMD_VEND1, 0x22,\n+\t\t      (reg_1e_22_read \u0026 0xff00) + reg_1e_22_end);\n+\tphy_write_mmd(phydev, MDIO_MMD_VEND1, 0x174,\n+\t\t      0x8080 + (reg_1e_174_header * 256) + reg_1e_174_end);\n+\tphy_write_mmd(phydev, MDIO_MMD_VEND1, 0x175,\n+\t\t      0x8080 + (reg_1e_175_header * 256) + reg_1e_175_end);\n+\n+\treturn 0;\n+}\n+\n+static int an7581_phy_config_init(struct phy_device *phydev)\n+{\n+\tstruct airoha_socphy_shared *shared = phy_package_get_priv(phydev);\n+\tstruct phy_device *phydev_p0;\n+\tu32 soc_pdidr;\n+\tu8 phy_offset;\n+\tint ret;\n+\n+\tphydev_p0 = shared-\u003ephydev_p0;\n+\tphy_offset = phydev-\u003emdio.addr - phydev_p0-\u003emdio.addr;\n+\n+\t/* FIXME: Read SoC PDIDR if available or default to 2 (latest) */\n+\tsoc_pdidr = 2;\n+\n+\tshared-\u003emdi_resister_type = MDI_5R;\n+\tif (soc_pdidr == 2)\n+\t\tshared-\u003etx_amp_compensation_tbl = \u0026an7581_tx_amp_compensation_tbl[1];\n+\telse\n+\t\tshared-\u003etx_amp_compensation_tbl = \u0026an7581_tx_amp_compensation_tbl[0];\n+\tshared-\u003er50_cal_tbl = an7581_zcal_to_r45ohm;\n+\n+\tret = airoha_phy_calib(phydev);\n+\tif (ret)\n+\t\treturn ret;\n+\n+\tret = airoha_phy_auto_select_transformer(phydev);\n+\tif (ret)\n+\t\treturn ret;\n+\n+\tret = airoha_phy_tx_amp_compensation(phydev);\n+\tif (ret)\n+\t\treturn ret;\n+\n+\t/* RX setting for 5R_TXMR before AN setting */\n+\tphy_write_mmd(phydev, MDIO_MMD_VEND1, 0xe6, 0x1111);\n+\tphy_write_mmd(phydev, MDIO_MMD_VEND1, 0xe7, 0x5555);\n+\tphy_write_mmd(phydev, MDIO_MMD_VEND1, 0xe9, 0x0001);\n+\tphy_write_mmd(phydev, MDIO_MMD_VEND1, 0xfe, 0x0000);\n+\n+\t/* Long Loop Reach setting */\n+\tphy_write_mmd(phydev, MDIO_MMD_VEND1, 0x11, 0xff00);\n+\tphy_write_mmd(phydev, MDIO_MMD_VEND2, 0x202, 0x2310);\n+\tphy_write_mmd(phydev, MDIO_MMD_VEND2, 0x203, 0x0025);\n+\tphy_write_mmd(phydev, MDIO_MMD_VEND2, 0x204, 0x2310);\n+\tphy_write_mmd(phydev, MDIO_MMD_VEND2, 0x205, 0x0025);\n+\tphy_write_mmd(phydev, MDIO_MMD_VEND2, 0x206, 0x2310);\n+\tphy_write_mmd(phydev, MDIO_MMD_VEND2, 0x207, 0x0025);\n+\tphy_write_mmd(phydev, MDIO_MMD_VEND2, 0x208, 0x2310);\n+\tphy_write_mmd(phydev, MDIO_MMD_VEND2, 0x209, 0x0025);\n+\tphy_write_mmd(phydev, MDIO_MMD_VEND2, 0x20a, 0x2310);\n+\tphy_write_mmd(phydev, MDIO_MMD_VEND2, 0x20b, 0x0025);\n+\tphy_write_mmd(phydev, MDIO_MMD_VEND2, 0x20e, 0x2310);\n+\tphy_write_mmd(phydev, MDIO_MMD_VEND2, 0x20f, 0x0025);\n+\tphy_write_mmd(phydev, MDIO_MMD_VEND2, 0x210, 0x2310);\n+\tphy_write_mmd(phydev, MDIO_MMD_VEND2, 0x211, 0x0025);\n+\tphy_write_mmd(phydev, MDIO_MMD_VEND2, 0x212, 0x2310);\n+\tphy_write_mmd(phydev, MDIO_MMD_VEND2, 0x213, 0x0025);\n+\tphy_write_mmd(phydev, MDIO_MMD_VEND2, 0x214, 0x2310);\n+\tphy_write_mmd(phydev, MDIO_MMD_VEND2, 0x215, 0x0025);\n+\tphy_write_mmd(phydev, MDIO_MMD_VEND2, 0x216, 0x2310);\n+\tphy_write_mmd(phydev, MDIO_MMD_VEND2, 0x217, 0x0025);\n+\tphy_write_mmd(phydev, MDIO_MMD_VEND2, 0x21a, 0x2310);\n+\tphy_write_mmd(phydev, MDIO_MMD_VEND2, 0x21b, 0x0025);\n+\tphy_write_mmd(phydev, MDIO_MMD_VEND2, 0x21c, 0x2310);\n+\tphy_write_mmd(phydev, MDIO_MMD_VEND2, 0x21d, 0x0025);\n+\tphy_write_mmd(phydev, MDIO_MMD_VEND2, 0x21e, 0x2310);\n+\tphy_write_mmd(phydev, MDIO_MMD_VEND2, 0x21f, 0x0025);\n+\tphy_write_mmd(phydev, MDIO_MMD_VEND2, 0x220, 0x2310);\n+\tphy_write_mmd(phydev, MDIO_MMD_VEND2, 0x221, 0x0025);\n+\tphy_write_mmd(phydev, MDIO_MMD_VEND2, 0x222, 0x2310);\n+\tphy_write_mmd(phydev, MDIO_MMD_VEND2, 0x223, 0x0025);\n+\tphy_write_mmd(phydev, MDIO_MMD_VEND2, 0x226, 0x2310);\n+\tphy_write_mmd(phydev, MDIO_MMD_VEND2, 0x227, 0x0025);\n+\tphy_write_mmd(phydev, MDIO_MMD_VEND2, 0x228, 0x2310);\n+\tphy_write_mmd(phydev, MDIO_MMD_VEND2, 0x229, 0x0025);\n+\tphy_write_mmd(phydev, MDIO_MMD_VEND2, 0x22a, 0x2310);\n+\tphy_write_mmd(phydev, MDIO_MMD_VEND2, 0x22b, 0x0025);\n+\tphy_write_mmd(phydev, MDIO_MMD_VEND2, 0x22c, 0x2310);\n+\tphy_write_mmd(phydev, MDIO_MMD_VEND2, 0x22d, 0x0025);\n+\tphy_write_mmd(phydev, MDIO_MMD_VEND2, 0x22e, 0x2310);\n+\tphy_write_mmd(phydev, MDIO_MMD_VEND2, 0x22f, 0x0025);\n+\n+\t/* RX Setting */\n+\tphy_write_mmd(phydev, MDIO_MMD_VEND1, 0x3c, 0xc000);\n+\tphy_write_mmd(phydev, MDIO_MMD_VEND1, 0x3d, 0x0000);\n+\tphy_write_mmd(phydev, MDIO_MMD_VEND1, 0x3e, 0xc000);\n+\n+\t/* EEE setting */\n+\tphy_write_mmd(phydev, MDIO_MMD_AN, 0x3c, 0x0000);\n+\n+\t/* RX */\n+\tphy_write_mmd(phydev, MDIO_MMD_VEND2, 0x41, 0x3333);\n+\tphy_write_mmd(phydev, MDIO_MMD_VEND2, 0x44, 0x00c0);\n+\n+\t/* 10M settings */\n+\tphy_write_mmd(phydev, MDIO_MMD_VEND1, 0x1a3, 0x00d2);\n+\tphy_write_mmd(phydev, MDIO_MMD_VEND1, 0x1a4, 0x010e);\n+\tphy_write_mmd(phydev, MDIO_MMD_VEND2, 0x27b, 0x1177);\n+\tphy_write_mmd(phydev, MDIO_MMD_VEND2, 0x27c, 0x0808);\n+\n+\tphy_select_page(phydev, MTK_PHY_PAGE_EXTENDED_1);\n+\t__phy_write(phydev, 0x14, 0x3a18);\n+\tphy_restore_page(phydev, MTK_PHY_PAGE_STANDARD, 0);\n+\n+\tphy_write(phydev, 0x9, 0x1e00);\n+\n+\tphy_write_mmd(phydev, MDIO_MMD_VEND2, 0x269, 0x2114);\n+\tphy_write_mmd(phydev, MDIO_MMD_VEND2, 0x26a, 0x1113);\n+\tphy_write_mmd(phydev, MDIO_MMD_VEND2, 0x26f, 0x0000);\n+\tphy_write_mmd(phydev, MDIO_MMD_VEND2, 0x271, 0x2c63);\n+\tphy_write_mmd(phydev, MDIO_MMD_VEND2, 0x272, 0x0c2b);\n+\n+\t/* EEE set because power down can't set tokenring */\n+\tphy_select_page(phydev, MTK_PHY_PAGE_EXTENDED_52B5);\n+\t__mtk_tr_write(phydev, 0x0, 0x7, 0x15, 0x0055a0);\n+\t__mtk_tr_write(phydev, 0x0, 0x7, 0x17, 0x07ff3f);\n+\t__mtk_tr_write(phydev, 0x1, 0xf, 0x0, 0x00001e);\n+\t__mtk_tr_write(phydev, 0x1, 0xf, 0x1, 0x6fb90a);\n+\t__mtk_tr_write(phydev, 0x1, 0xf, 0x18, 0x0e2f00);\n+\t__mtk_tr_write(phydev, 0x1, 0xd, 0x26, 0x444444);\n+\t__mtk_tr_write(phydev, 0x2, 0xd, 0x3, 0x000004);\n+\t__mtk_tr_write(phydev, 0x2, 0xd, 0x6, 0x2ebaef);\n+\t__mtk_tr_write(phydev, 0x2, 0xd, 0x8, 0x00000b);\n+\t__mtk_tr_write(phydev, 0x2, 0xd, 0xc, 0x00504d);\n+\t__mtk_tr_write(phydev, 0x2, 0xd, 0xd, 0x02314f);\n+\t__mtk_tr_write(phydev, 0x2, 0xd, 0xf, 0x003028);\n+\t__mtk_tr_write(phydev, 0x2, 0xd, 0x10, 0x00000a);\n+\t__mtk_tr_write(phydev, 0x2, 0xd, 0x11, 0x040001);\n+\t__mtk_tr_write(phydev, 0x2, 0xd, 0x14, 0x00024a);\n+\t__mtk_tr_write(phydev, 0x2, 0xd, 0x1c, 0x003210);\n+\tphy_restore_page(phydev, MTK_PHY_PAGE_STANDARD, 0);\n+\n+\tphy_write_mmd(phydev, MDIO_MMD_VEND1, 0x120, 0x8014);\n+\tphy_write_mmd(phydev, MDIO_MMD_VEND1, 0x122, 0xffff);\n+\tphy_write_mmd(phydev, MDIO_MMD_VEND1, 0x144, 0x0200);\n+\tphy_write_mmd(phydev, MDIO_MMD_VEND1, 0x14a, 0xee20);\n+\tphy_write_mmd(phydev, MDIO_MMD_VEND1, 0x19b, 0x0111);\n+\tphy_write_mmd(phydev, MDIO_MMD_VEND1, 0x234, 0x1181);\n+\tphy_write_mmd(phydev, MDIO_MMD_VEND1, 0x238, 0x0120);\n+\tphy_write_mmd(phydev, MDIO_MMD_VEND1, 0x239, 0x0117);\n+\tphy_write_mmd(phydev, MDIO_MMD_VEND1, 0x2d1, 0x0733);\n+\tphy_write_mmd(phydev, MDIO_MMD_VEND1, 0x323, 0x0011);\n+\tphy_write_mmd(phydev, MDIO_MMD_VEND1, 0x324, 0x013f);\n+\tphy_write_mmd(phydev, MDIO_MMD_VEND1, 0x326, 0x0037);\n+\tphy_write_mmd(phydev, MDIO_MMD_VEND2, 0x268, 0x07f4);\n+\n+\tif (shared-\u003etransformer_type[phy_offset] == TXMR) {\n+\t\tphy_write_mmd(phydev, MDIO_MMD_VEND1, 0x00, 0x0187);\n+\t\tphy_write_mmd(phydev, MDIO_MMD_VEND1, 0x01, 0x01cc);\n+\t\tphy_write_mmd(phydev, MDIO_MMD_VEND1, 0x02, 0x01c2);\n+\t\tphy_write_mmd(phydev, MDIO_MMD_VEND1, 0x03, 0x0109);\n+\t\tphy_write_mmd(phydev, MDIO_MMD_VEND1, 0x04, 0x020b);\n+\t\tphy_write_mmd(phydev, MDIO_MMD_VEND1, 0x05, 0x0202);\n+\t\tphy_write_mmd(phydev, MDIO_MMD_VEND1, 0x06, 0x0387);\n+\t\tphy_write_mmd(phydev, MDIO_MMD_VEND1, 0x07, 0x03c5);\n+\t\tphy_write_mmd(phydev, MDIO_MMD_VEND1, 0x08, 0x03c2);\n+\t\tphy_write_mmd(phydev, MDIO_MMD_VEND1, 0x09, 0x0309);\n+\t\tphy_write_mmd(phydev, MDIO_MMD_VEND1, 0x0a, 0x000e);\n+\t\tphy_write_mmd(phydev, MDIO_MMD_VEND1, 0x0b, 0x0002);\n+\n+\t\tphy_write_mmd(phydev, MDIO_MMD_VEND1, 0x23, 0x0880);\n+\t\tphy_write_mmd(phydev, MDIO_MMD_VEND1, 0x24, 0x0880);\n+\t\tphy_write_mmd(phydev, MDIO_MMD_VEND1, 0x25, 0x0880);\n+\t\tphy_write_mmd(phydev, MDIO_MMD_VEND1, 0x26, 0x0880);\n+\t} else {\n+\t\tif (soc_pdidr == 2) {\n+\t\t\tphy_write_mmd(phydev, MDIO_MMD_VEND2, 0x269, 0x1114);\n+\t\t\tphy_write_mmd(phydev, MDIO_MMD_VEND2, 0x26a, 0x1113);\n+\t\t\tphy_write_mmd(phydev, MDIO_MMD_VEND2, 0x26f, 0x2000);\n+\t\t\tphy_write_mmd(phydev, MDIO_MMD_VEND2, 0x271, 0x4c88);\n+\t\t\tphy_write_mmd(phydev, MDIO_MMD_VEND2, 0x272, 0x0c2b);\n+\n+\t\t\t/* 100M sharp */\n+\t\t\tphy_write_mmd(phydev, MDIO_MMD_VEND1, 0x00, 0x0190);\n+\t\t\tphy_write_mmd(phydev, MDIO_MMD_VEND1, 0x01, 0x01c8);\n+\t\t\tphy_write_mmd(phydev, MDIO_MMD_VEND1, 0x02, 0x01c0);\n+\t\t\tphy_write_mmd(phydev, MDIO_MMD_VEND1, 0x03, 0x0030);\n+\t\t\tphy_write_mmd(phydev, MDIO_MMD_VEND1, 0x04, 0x0208);\n+\t\t\tphy_write_mmd(phydev, MDIO_MMD_VEND1, 0x05, 0x0000);\n+\t\t\tphy_write_mmd(phydev, MDIO_MMD_VEND1, 0x06, 0x0318);\n+\t\t\tphy_write_mmd(phydev, MDIO_MMD_VEND1, 0x07, 0x03c8);\n+\t\t\tphy_write_mmd(phydev, MDIO_MMD_VEND1, 0x08, 0x03c0);\n+\t\t\tphy_write_mmd(phydev, MDIO_MMD_VEND1, 0x09, 0x0230);\n+\t\t\tphy_write_mmd(phydev, MDIO_MMD_VEND1, 0x0a, 0x0008);\n+\t\t\tphy_write_mmd(phydev, MDIO_MMD_VEND1, 0x0b, 0x0200);\n+\n+\t\t\tphy_write_mmd(phydev, MDIO_MMD_VEND1, 0x23, 0x0885);\n+\t\t\tphy_write_mmd(phydev, MDIO_MMD_VEND1, 0x24, 0x0885);\n+\t\t\tphy_write_mmd(phydev, MDIO_MMD_VEND1, 0x25, 0x0885);\n+\t\t\tphy_write_mmd(phydev, MDIO_MMD_VEND1, 0x26, 0x0885);\n+\t\t} else {\n+\t\t\tphy_write_mmd(phydev, MDIO_MMD_VEND1, 0x00, 0x0190);\n+\t\t\tphy_write_mmd(phydev, MDIO_MMD_VEND1, 0x01, 0x01cf);\n+\t\t\tphy_write_mmd(phydev, MDIO_MMD_VEND1, 0x02, 0x01c0);\n+\t\t\tphy_write_mmd(phydev, MDIO_MMD_VEND1, 0x03, 0x0030);\n+\t\t\tphy_write_mmd(phydev, MDIO_MMD_VEND1, 0x04, 0x020f);\n+\t\t\tphy_write_mmd(phydev, MDIO_MMD_VEND1, 0x05, 0x0000);\n+\t\t\tphy_write_mmd(phydev, MDIO_MMD_VEND1, 0x06, 0x0318);\n+\t\t\tphy_write_mmd(phydev, MDIO_MMD_VEND1, 0x07, 0x03cf);\n+\t\t\tphy_write_mmd(phydev, MDIO_MMD_VEND1, 0x08, 0x03c0);\n+\t\t\tphy_write_mmd(phydev, MDIO_MMD_VEND1, 0x09, 0x0230);\n+\t\t\tphy_write_mmd(phydev, MDIO_MMD_VEND1, 0x0a, 0x000f);\n+\t\t\tphy_write_mmd(phydev, MDIO_MMD_VEND1, 0x0b, 0x0200);\n+\n+\t\t\tphy_write_mmd(phydev, MDIO_MMD_VEND1, 0x23, 0x0003);\n+\t\t\tphy_write_mmd(phydev, MDIO_MMD_VEND1, 0x24, 0x0003);\n+\t\t\tphy_write_mmd(phydev, MDIO_MMD_VEND1, 0x25, 0x0003);\n+\t\t\tphy_write_mmd(phydev, MDIO_MMD_VEND1, 0x26, 0x0003);\n+\t\t}\n+\t}\n+\n+\treturn 0;\n+}\n+\n+static int an7581_phy_probe(struct phy_device *phydev)\n+{\n+\tstruct airoha_socphy_shared *shared;\n+\tstruct mtk_socphy_priv *priv;\n+\tstruct pinctrl *pinctrl;\n+\tint ret;\n+\n+\t/* Toggle pinctrl to enable PHY LED */\n+\tpinctrl = devm_pinctrl_get_select(\u0026phydev-\u003emdio.dev, \"gbe-led\");\n+\tif (IS_ERR(pinctrl))\n+\t\tdev_err(\u0026phydev-\u003emdio.bus-\u003edev,\n+\t\t\t\"Failed to setup PHY LED pinctrl\\n\");\n+\n+\tret = devm_phy_package_join(\u0026phydev-\u003emdio.dev, phydev, 0,\n+\t\t\t\t    sizeof(struct airoha_socphy_shared));\n+\tif (ret)\n+\t\treturn ret;\n+\n+\tpriv = devm_kzalloc(\u0026phydev-\u003emdio.dev, sizeof(*priv), GFP_KERNEL);\n+\tif (!priv)\n+\t\treturn -ENOMEM;\n+\n+\tif (phydev-\u003emdio.addr == AIROHA_DEFAULT_PORT0_ADDR)\n+\t\tshared-\u003ephydev_p0 = phydev;\n+\n+\tphydev-\u003epriv = priv;\n+\n+\treturn 0;\n+}\n+\n+static int an7581_phy_led_polarity_set(struct phy_device *phydev, int index,\n+\t\t\t\t       unsigned long modes)\n+{\n+\tu16 val = 0;\n+\tu32 mode;\n+\n+\tif (index \u003e= AIROHA_PHY_MAX_LEDS)\n+\t\treturn -EINVAL;\n+\n+\tfor_each_set_bit(mode, \u0026modes, __PHY_LED_MODES_NUM) {\n+\t\tswitch (mode) {\n+\t\tcase PHY_LED_ACTIVE_LOW:\n+\t\t\tval = MTK_PHY_LED_ON_POLARITY;\n+\t\t\tbreak;\n+\t\tcase PHY_LED_ACTIVE_HIGH:\n+\t\t\tbreak;\n+\t\tdefault:\n+\t\t\treturn -EINVAL;\n+\t\t}\n+\t}\n+\n+\treturn phy_modify_mmd(phydev, MDIO_MMD_VEND2, index ?\n+\t\t\t      MTK_PHY_LED1_ON_CTRL : MTK_PHY_LED0_ON_CTRL,\n+\t\t\t      MTK_PHY_LED_ON_POLARITY, val);\n+}\n+\n+static int en7528_phy_config_init(struct phy_device *phydev)\n+{\n+\t/* The LED controller of the EN7528 powers up with its external\n+\t * control disabled, leaving the LED pins dark regardless of what is\n+\t * programmed into the LED control registers. Hand the pins over to\n+\t * the LED control registers the same way the air_en8811h driver\n+\t * does; the mode field of this register is already set out of reset.\n+\t */\n+\treturn phy_set_bits_mmd(phydev, MDIO_MMD_VEND2, MTK_PHY_LED_BCR,\n+\t\t\t\tMTK_PHY_LED_BCR_CLK_EN |\n+\t\t\t\tMTK_PHY_LED_BCR_EXT_CTRL);\n+}\n+\n+static int an7583_phy_config_init(struct phy_device *phydev)\n+{\n+\tstruct airoha_socphy_shared *shared = phy_package_get_priv(phydev);\n+\tstruct phy_device *phydev_p0;\n+\tu8 phy_offset;\n+\tint ret;\n+\n+\t/* BMCR_PDOWN is enabled by default */\n+\tphy_clear_bits(phydev, MII_BMCR, BMCR_PDOWN);\n+\n+\tphydev_p0 = shared-\u003ephydev_p0;\n+\tphy_offset = phydev-\u003emdio.addr - phydev_p0-\u003emdio.addr;\n+\n+\t/* FIXME: Read SoC MDI Resister Type if available or default to 5R */\n+\tshared-\u003emdi_resister_type = MDI_5R;\n+\n+\tif (shared-\u003emdi_resister_type == MDI_0R)\n+\t\tshared-\u003er50_cal_tbl = an7583_zcal_to_r50ohm_0R;\n+\tif (shared-\u003emdi_resister_type == MDI_5R)\n+\t\tshared-\u003er50_cal_tbl = an7583_zcal_to_r50ohm_5R;\n+\tshared-\u003etx_amp_compensation_tbl = \u0026an7583_tx_amp_compensation_tbl;\n+\n+\tret = airoha_phy_calib(phydev);\n+\tif (ret)\n+\t\treturn ret;\n+\n+\tret = airoha_phy_auto_select_transformer(phydev);\n+\tif (ret)\n+\t\treturn ret;\n+\n+\tret = airoha_phy_tx_amp_compensation(phydev);\n+\tif (ret)\n+\t\treturn ret;\n+\n+\t/* Enable Idle Mode Power Setting */\n+\tif (phy_offset == 0) {\n+\t\tphy_write_mmd(phydev, MDIO_MMD_VEND2, 0x268, 0x07F1);\n+\t\tphy_write_mmd(phydev, MDIO_MMD_VEND2, 0x703, 0x3111);\n+\t\tphy_write_mmd(phydev, MDIO_MMD_VEND2, 0x271, 0x3C24);\n+\t\tphy_write_mmd(phydev, MDIO_MMD_VEND2, 0x701, 0x1023);\n+\t}\n+\n+\tif (shared-\u003etransformer_type[phy_offset] == TXMR) {\n+\t\tphy_write_mmd(phydev, MDIO_MMD_VEND1, 0x23, 0x0881);\n+\t\tphy_write_mmd(phydev, MDIO_MMD_VEND1, 0x24, 0x0881);\n+\t\tphy_write_mmd(phydev, MDIO_MMD_VEND1, 0x25, 0x0881);\n+\t\tphy_write_mmd(phydev, MDIO_MMD_VEND1, 0x26, 0x0881);\n+\n+\t\tif (shared-\u003emdi_resister_type == MDI_5R)\n+\t\t\tphy_write_mmd(phydev, MDIO_MMD_VEND1, 0x05, 0x0205);\n+\t\telse\n+\t\t\tphy_write_mmd(phydev, MDIO_MMD_VEND1, 0x05, 0x0200);\n+\t} else {\n+\t\tif (shared-\u003emdi_resister_type == MDI_5R) {\n+\t\t\t/* RX setting for 5R_TXMR before AN setting */\n+\t\t\tphy_write_mmd(phydev, MDIO_MMD_VEND1, 0xe7, 0x6666);\n+\t\t\tphy_write_mmd(phydev, MDIO_MMD_VEND1, 0xe9, 0x0003);\n+\t\t\tphy_write_mmd(phydev, MDIO_MMD_VEND1, 0xfe, 0x0006);\n+\t\t\tphy_write_mmd(phydev, MDIO_MMD_VEND1, 0xe6, 0x1111);\n+\t\t\t/* 100M sharp */\n+\t\t\tphy_write_mmd(phydev, MDIO_MMD_VEND1, 0x23, 0x0c86);\n+\t\t\tphy_write_mmd(phydev, MDIO_MMD_VEND1, 0x24, 0x0c86);\n+\t\t\tphy_write_mmd(phydev, MDIO_MMD_VEND1, 0x25, 0x0c86);\n+\t\t\tphy_write_mmd(phydev, MDIO_MMD_VEND1, 0x26, 0x0c86);\n+\t\t\tphy_write_mmd(phydev, MDIO_MMD_VEND1, 0x01, 0x01cb);\n+\t\t\tphy_write_mmd(phydev, MDIO_MMD_VEND1, 0x02, 0x01c2);\n+\t\t\tphy_write_mmd(phydev, MDIO_MMD_VEND1, 0x03, 0x0108);\n+\t\t\tphy_write_mmd(phydev, MDIO_MMD_VEND1, 0x04, 0x0211);\n+\t\t\tphy_write_mmd(phydev, MDIO_MMD_VEND1, 0x05, 0x0205);\n+\t\t\tphy_write_mmd(phydev, MDIO_MMD_VEND1, 0x06, 0x0387);\n+\t\t\tphy_write_mmd(phydev, MDIO_MMD_VEND1, 0x07, 0x03ce);\n+\t\t\tphy_write_mmd(phydev, MDIO_MMD_VEND1, 0x08, 0x03c8);\n+\t\t\tphy_write_mmd(phydev, MDIO_MMD_VEND1, 0x0b, 0x0005);\n+\t\t} else {\n+\t\t\t/* 100M sharp */\n+\t\t\tphy_write_mmd(phydev, MDIO_MMD_VEND1, 0x23, 0x0886);\n+\t\t\tphy_write_mmd(phydev, MDIO_MMD_VEND1, 0x24, 0x0886);\n+\t\t\tphy_write_mmd(phydev, MDIO_MMD_VEND1, 0x25, 0x0886);\n+\t\t\tphy_write_mmd(phydev, MDIO_MMD_VEND1, 0x26, 0x0886);\n+\t\t\tphy_write_mmd(phydev, MDIO_MMD_VEND1, 0x00, 0x0195);\n+\t\t\tphy_write_mmd(phydev, MDIO_MMD_VEND1, 0x01, 0x01cb);\n+\t\t\tphy_write_mmd(phydev, MDIO_MMD_VEND1, 0x02, 0x01c2);\n+\t\t\tphy_write_mmd(phydev, MDIO_MMD_VEND1, 0x03, 0x0108);\n+\t\t\tphy_write_mmd(phydev, MDIO_MMD_VEND1, 0x04, 0x0211);\n+\t\t\tphy_write_mmd(phydev, MDIO_MMD_VEND1, 0x05, 0x0205);\n+\t\t\tphy_write_mmd(phydev, MDIO_MMD_VEND1, 0x06, 0x0387);\n+\t\t\tphy_write_mmd(phydev, MDIO_MMD_VEND1, 0x07, 0x03ce);\n+\t\t\tphy_write_mmd(phydev, MDIO_MMD_VEND1, 0x08, 0x03c3);\n+\t\t\tphy_write_mmd(phydev, MDIO_MMD_VEND1, 0x0a, 0x0010);\n+\t\t\tphy_write_mmd(phydev, MDIO_MMD_VEND1, 0x0b, 0x0005);\n+\t\t}\n+\t}\n+\n+\t/* RX Setting */\n+\tphy_write_mmd(phydev, MDIO_MMD_VEND1, 0x3c, 0xc000);\n+\tphy_write_mmd(phydev, MDIO_MMD_VEND1, 0x3d, 0x0000);\n+\tphy_write_mmd(phydev, MDIO_MMD_VEND1, 0x3e, 0xc000);\n+\n+\t/* EEE setting */\n+\tphy_write_mmd(phydev, MDIO_MMD_AN, 0x3c, 0x0000);\n+\n+\t/* 10M settings */\n+\tphy_write_mmd(phydev, MDIO_MMD_VEND1, 0x1a3, 0x00d2);\n+\tphy_write_mmd(phydev, MDIO_MMD_VEND1, 0x1a4, 0x010e);\n+\tphy_write_mmd(phydev, MDIO_MMD_VEND2, 0x27b, 0x1177);\n+\tphy_write_mmd(phydev, MDIO_MMD_VEND2, 0x27c, 0x0808);\n+\n+\tphy_select_page(phydev, MTK_PHY_PAGE_EXTENDED_3);\n+\t__phy_write(phydev, 0x14, 0x190);\n+\tphy_restore_page(phydev, MTK_PHY_PAGE_STANDARD, 0);\n+\n+\tphy_select_page(phydev, MTK_PHY_PAGE_EXTENDED_1);\n+\t__phy_write(phydev, 0x14, 0x3a18);\n+\tphy_restore_page(phydev, MTK_PHY_PAGE_STANDARD, 0);\n+\n+\tphy_write(phydev, 0x9, 0x0600);\n+\n+\t/* EEE keep only Pair A ON */\n+\tphy_write_mmd(phydev, MDIO_MMD_VEND1, 0x630, 0x006E);\n+\n+\treturn 0;\n+}\n+\n+static struct phy_driver mtk_socphy_driver[] = {\n+\t{\n+\t\tPHY_ID_MATCH_EXACT(AIROHA_GPHY_ID_EN7528),\n+\t\t.name\t\t= \"EcoNet EN7528 PHY\",\n+\t\t.config_init\t= en7528_phy_config_init,\n+\t\t.probe\t\t= an7581_phy_probe,\n+\t\t.led_blink_set\t= mt798x_phy_led_blink_set,\n+\t\t.led_brightness_set = mt798x_phy_led_brightness_set,\n+\t\t.led_hw_is_supported = mt798x_phy_led_hw_is_supported,\n+\t\t.led_hw_control_set = mt798x_phy_led_hw_control_set,\n+\t\t.led_hw_control_get = mt798x_phy_led_hw_control_get,\n+\t\t.led_polarity_set = an7581_phy_led_polarity_set,\n+\t},\n+\t{\n+\t\tPHY_ID_MATCH_EXACT(AIROHA_GPHY_ID_AN7581),\n+\t\t.name\t\t= \"Airoha AN7581 PHY\",\n+\t\t.config_init\t= an7581_phy_config_init,\n+\t\t.config_intr\t= genphy_no_config_intr,\n+\t\t.handle_interrupt = genphy_handle_interrupt_no_ack,\n+\t\t.probe\t\t= an7581_phy_probe,\n+\t\t.led_blink_set\t= mt798x_phy_led_blink_set,\n+\t\t.led_brightness_set = mt798x_phy_led_brightness_set,\n+\t\t.led_hw_is_supported = mt798x_phy_led_hw_is_supported,\n+\t\t.led_hw_control_set = mt798x_phy_led_hw_control_set,\n+\t\t.led_hw_control_get = mt798x_phy_led_hw_control_get,\n+\t\t.led_polarity_set = an7581_phy_led_polarity_set,\n+\t\t.read_page\t= mtk_phy_read_page,\n+\t\t.write_page\t= mtk_phy_write_page,\n+\t},\n+\t{\n+\t\tPHY_ID_MATCH_EXACT(AIROHA_GPHY_ID_AN7583),\n+\t\t.name\t\t= \"Airoha AN7583 PHY\",\n+\t\t.config_init\t= an7583_phy_config_init,\n+\t\t.probe\t\t= an7581_phy_probe,\n+\t\t.led_blink_set\t= mt798x_phy_led_blink_set,\n+\t\t.led_brightness_set = mt798x_phy_led_brightness_set,\n+\t\t.led_hw_is_supported = mt798x_phy_led_hw_is_supported,\n+\t\t.led_hw_control_set = mt798x_phy_led_hw_control_set,\n+\t\t.led_hw_control_get = mt798x_phy_led_hw_control_get,\n+\t\t.led_polarity_set = an7581_phy_led_polarity_set,\n+\t\t.read_page\t= mtk_phy_read_page,\n+\t\t.write_page\t= mtk_phy_write_page,\n+\t},\n+};\n+\n+module_phy_driver(mtk_socphy_driver);\n+\n+static const struct mdio_device_id __maybe_unused airoha_socphy_tbl[] = {\n+\t{ PHY_ID_MATCH_EXACT(AIROHA_GPHY_ID_EN7528) },\n+\t{ PHY_ID_MATCH_EXACT(AIROHA_GPHY_ID_AN7581) },\n+\t{ PHY_ID_MATCH_EXACT(AIROHA_GPHY_ID_AN7583) },\n+\t{ }\n+};\n+\n+MODULE_DESCRIPTION(\"Airoha SoC Gigabit Ethernet PHY driver\");\n+MODULE_AUTHOR(\"Christian Marangi \u003cansuelsmth@gmail.com\u003e\");\n+MODULE_LICENSE(\"GPL\");\n+MODULE_VERSION(\"01.01.20260306\");\n+\n+MODULE_DEVICE_TABLE(mdio, airoha_socphy_tbl);\ndiff --git a/drivers/net/phy/mediatek/mtk-ge-soc.c b/drivers/net/phy/mediatek/mtk-ge-soc.c\nindex 0041300d4f101..4132ac4035835 100644\n--- a/drivers/net/phy/mediatek/mtk-ge-soc.c\n+++ b/drivers/net/phy/mediatek/mtk-ge-soc.c\n@@ -11,331 +11,10 @@\n \n #include \"../phylib.h\"\n #include \"mtk.h\"\n+#include \"mtk-ge-soc.h\"\n \n #define MTK_PHY_MAX_LEDS\t\t\t2\n \n-#define MTK_GPHY_ID_MT7981\t\t\t0x03a29461\n-#define MTK_GPHY_ID_MT7988\t\t\t0x03a29481\n-#define MTK_GPHY_ID_EN7528\t\t\t0x03a29491\n-#define MTK_GPHY_ID_AN7581\t\t\t0x03a294c1\n-#define MTK_GPHY_ID_AN7583\t\t\t0xc0ff0420\n-\n-#define MTK_EXT_PAGE_ACCESS\t\t\t0x1f\n-#define MTK_PHY_PAGE_STANDARD\t\t\t0x0000\n-#define MTK_PHY_PAGE_EXTENDED_3\t\t\t0x0003\n-\n-#define MTK_PHY_LPI_REG_14\t\t\t0x14\n-#define MTK_PHY_LPI_WAKE_TIMER_1000_MASK\tGENMASK(8, 0)\n-\n-#define MTK_PHY_LPI_REG_1c\t\t\t0x1c\n-#define MTK_PHY_SMI_DET_ON_THRESH_MASK\t\tGENMASK(13, 8)\n-\n-#define MTK_PHY_PAGE_EXTENDED_2A30\t\t0x2a30\n-\n-/* Registers on Token Ring debug nodes */\n-/* ch_addr = 0x0, node_addr = 0x7, data_addr = 0x15 */\n-/* NormMseLoThresh */\n-#define NORMAL_MSE_LO_THRESH_MASK\t\tGENMASK(15, 8)\n-\n-/* ch_addr = 0x0, node_addr = 0xf, data_addr = 0x3c */\n-/* RemAckCntLimitCtrl */\n-#define REMOTE_ACK_COUNT_LIMIT_CTRL_MASK\tGENMASK(2, 1)\n-\n-/* ch_addr = 0x1, node_addr = 0xd, data_addr = 0x20 */\n-/* VcoSlicerThreshBitsHigh */\n-#define VCO_SLICER_THRESH_HIGH_MASK\t\tGENMASK(23, 0)\n-\n-/* ch_addr = 0x1, node_addr = 0xf, data_addr = 0x0 */\n-/* DfeTailEnableVgaThresh1000 */\n-#define DFE_TAIL_EANBLE_VGA_TRHESH_1000\t\tGENMASK(5, 1)\n-\n-/* ch_addr = 0x1, node_addr = 0xf, data_addr = 0x1 */\n-/* MrvlTrFix100Kp */\n-#define MRVL_TR_FIX_100KP_MASK\t\t\tGENMASK(22, 20)\n-/* MrvlTrFix100Kf */\n-#define MRVL_TR_FIX_100KF_MASK\t\t\tGENMASK(19, 17)\n-/* MrvlTrFix1000Kp */\n-#define MRVL_TR_FIX_1000KP_MASK\t\t\tGENMASK(16, 14)\n-/* MrvlTrFix1000Kf */\n-#define MRVL_TR_FIX_1000KF_MASK\t\t\tGENMASK(13, 11)\n-\n-/* ch_addr = 0x1, node_addr = 0xf, data_addr = 0x12 */\n-/* VgaDecRate */\n-#define VGA_DECIMATION_RATE_MASK\t\tGENMASK(8, 5)\n-\n-/* ch_addr = 0x1, node_addr = 0xf, data_addr = 0x17 */\n-/* SlvDSPreadyTime */\n-#define SLAVE_DSP_READY_TIME_MASK\t\tGENMASK(22, 15)\n-/* MasDSPreadyTime */\n-#define MASTER_DSP_READY_TIME_MASK\t\tGENMASK(14, 7)\n-\n-/* ch_addr = 0x1, node_addr = 0xf, data_addr = 0x18 */\n-/* EnabRandUpdTrig */\n-#define ENABLE_RANDOM_UPDOWN_COUNTER_TRIGGER\tBIT(8)\n-\n-/* ch_addr = 0x1, node_addr = 0xf, data_addr = 0x20 */\n-/* ResetSyncOffset */\n-#define RESET_SYNC_OFFSET_MASK\t\t\tGENMASK(11, 8)\n-\n-/* ch_addr = 0x2, node_addr = 0xd, data_addr = 0x0 */\n-/* FfeUpdGainForceVal */\n-#define FFE_UPDATE_GAIN_FORCE_VAL_MASK\t\tGENMASK(9, 7)\n-/* FfeUpdGainForce */\n-#define FFE_UPDATE_GAIN_FORCE\t\t\tBIT(6)\n-\n-/* ch_addr = 0x2, node_addr = 0xd, data_addr = 0x3 */\n-/* TrFreeze */\n-#define TR_FREEZE_MASK\t\t\t\tGENMASK(11, 0)\n-\n-/* ch_addr = 0x2, node_addr = 0xd, data_addr = 0x6 */\n-/* SS: Steady-state, KP: Proportional Gain */\n-/* SSTrKp100 */\n-#define SS_TR_KP100_MASK\t\t\tGENMASK(21, 19)\n-/* SSTrKf100 */\n-#define SS_TR_KF100_MASK\t\t\tGENMASK(18, 16)\n-/* SSTrKp1000Mas */\n-#define SS_TR_KP1000_MASTER_MASK\t\tGENMASK(15, 13)\n-/* SSTrKf1000Mas */\n-#define SS_TR_KF1000_MASTER_MASK\t\tGENMASK(12, 10)\n-/* SSTrKp1000Slv */\n-#define SS_TR_KP1000_SLAVE_MASK\t\t\tGENMASK(9, 7)\n-/* SSTrKf1000Slv */\n-#define SS_TR_KF1000_SLAVE_MASK\t\t\tGENMASK(6, 4)\n-\n-/* ch_addr = 0x2, node_addr = 0xd, data_addr = 0x8 */\n-/* clear this bit if wanna select from AFE */\n-/* Regsigdet_sel_1000 */\n-#define EEE1000_SELECT_SIGNAL_DETECTION_FROM_DFE\tBIT(4)\n-\n-/* ch_addr = 0x2, node_addr = 0xd, data_addr = 0xd */\n-/* RegEEE_st2TrKf1000 */\n-#define EEE1000_STAGE2_TR_KF_MASK\t\tGENMASK(13, 11)\n-\n-/* ch_addr = 0x2, node_addr = 0xd, data_addr = 0xf */\n-/* RegEEE_slv_waketr_timer_tar */\n-#define SLAVE_WAKETR_TIMER_MASK\t\t\tGENMASK(20, 11)\n-/* RegEEE_slv_remtx_timer_tar */\n-#define SLAVE_REMTX_TIMER_MASK\t\t\tGENMASK(10, 1)\n-\n-/* ch_addr = 0x2, node_addr = 0xd, data_addr = 0x10 */\n-/* RegEEE_slv_wake_int_timer_tar */\n-#define SLAVE_WAKEINT_TIMER_MASK\t\tGENMASK(10, 1)\n-\n-/* ch_addr = 0x2, node_addr = 0xd, data_addr = 0x14 */\n-/* RegEEE_trfreeze_timer2 */\n-#define TR_FREEZE_TIMER2_MASK\t\t\tGENMASK(9, 0)\n-\n-/* ch_addr = 0x2, node_addr = 0xd, data_addr = 0x1c */\n-/* RegEEE100Stg1_tar */\n-#define EEE100_LPSYNC_STAGE1_UPDATE_TIMER_MASK\tGENMASK(8, 0)\n-\n-/* ch_addr = 0x2, node_addr = 0xd, data_addr = 0x25 */\n-/* REGEEE_wake_slv_tr_wait_dfesigdet_en */\n-#define WAKE_SLAVE_TR_WAIT_DFE_DETECTION_EN\tBIT(11)\n-\n-#define ANALOG_INTERNAL_OPERATION_MAX_US\t20\n-#define TXRESERVE_MIN\t\t\t\t0\n-#define TXRESERVE_MAX\t\t\t\t7\n-\n-#define MTK_PHY_ANARG_RG\t\t\t0x10\n-#define   MTK_PHY_TCLKOFFSET_MASK\t\tGENMASK(12, 8)\n-\n-/* Registers on MDIO_MMD_VEND1 */\n-#define MTK_PHY_TXVLD_DA_RG\t\t\t0x12\n-#define   MTK_PHY_DA_TX_I2MPB_A_GBE_MASK\tGENMASK(15, 10)\n-#define   MTK_PHY_DA_TX_I2MPB_A_TBT_MASK\tGENMASK(5, 0)\n-\n-#define MTK_PHY_TX_I2MPB_TEST_MODE_A2\t\t0x16\n-#define   MTK_PHY_DA_TX_I2MPB_A_HBT_MASK\tGENMASK(15, 10)\n-#define   MTK_PHY_DA_TX_I2MPB_A_TST_MASK\tGENMASK(5, 0)\n-\n-#define MTK_PHY_TX_I2MPB_TEST_MODE_B1\t\t0x17\n-#define   MTK_PHY_DA_TX_I2MPB_B_GBE_MASK\tGENMASK(13, 8)\n-#define   MTK_PHY_DA_TX_I2MPB_B_TBT_MASK\tGENMASK(5, 0)\n-\n-#define MTK_PHY_TX_I2MPB_TEST_MODE_B2\t\t0x18\n-#define   MTK_PHY_DA_TX_I2MPB_B_HBT_MASK\tGENMASK(13, 8)\n-#define   MTK_PHY_DA_TX_I2MPB_B_TST_MASK\tGENMASK(5, 0)\n-\n-#define MTK_PHY_TX_I2MPB_TEST_MODE_C1\t\t0x19\n-#define   MTK_PHY_DA_TX_I2MPB_C_GBE_MASK\tGENMASK(13, 8)\n-#define   MTK_PHY_DA_TX_I2MPB_C_TBT_MASK\tGENMASK(5, 0)\n-\n-#define MTK_PHY_TX_I2MPB_TEST_MODE_C2\t\t0x20\n-#define   MTK_PHY_DA_TX_I2MPB_C_HBT_MASK\tGENMASK(13, 8)\n-#define   MTK_PHY_DA_TX_I2MPB_C_TST_MASK\tGENMASK(5, 0)\n-\n-#define MTK_PHY_TX_I2MPB_TEST_MODE_D1\t\t0x21\n-#define   MTK_PHY_DA_TX_I2MPB_D_GBE_MASK\tGENMASK(13, 8)\n-#define   MTK_PHY_DA_TX_I2MPB_D_TBT_MASK\tGENMASK(5, 0)\n-\n-#define MTK_PHY_TX_I2MPB_TEST_MODE_D2\t\t0x22\n-#define   MTK_PHY_DA_TX_I2MPB_D_HBT_MASK\tGENMASK(13, 8)\n-#define   MTK_PHY_DA_TX_I2MPB_D_TST_MASK\tGENMASK(5, 0)\n-\n-#define MTK_PHY_RXADC_CTRL_RG7\t\t\t0xc6\n-#define   MTK_PHY_DA_AD_BUF_BIAS_LP_MASK\tGENMASK(9, 8)\n-\n-#define MTK_PHY_RXADC_CTRL_RG9\t\t\t0xc8\n-#define   MTK_PHY_DA_RX_PSBN_TBT_MASK\t\tGENMASK(14, 12)\n-#define   MTK_PHY_DA_RX_PSBN_HBT_MASK\t\tGENMASK(10, 8)\n-#define   MTK_PHY_DA_RX_PSBN_GBE_MASK\t\tGENMASK(6, 4)\n-#define   MTK_PHY_DA_RX_PSBN_LP_MASK\t\tGENMASK(2, 0)\n-\n-#define MTK_PHY_LDO_OUTPUT_V\t\t\t0xd7\n-\n-#define MTK_PHY_RG_ANA_CAL_RG0\t\t\t0xdb\n-#define   MTK_PHY_RG_CAL_CKINV\t\t\tBIT(12)\n-#define   MTK_PHY_RG_ANA_CALEN\t\t\tBIT(8)\n-#define   MTK_PHY_RG_ZCALEN_A\t\t\tBIT(0)\n-\n-#define MTK_PHY_RG_ANA_CAL_RG1\t\t\t0xdc\n-#define   MTK_PHY_RG_ZCALEN_B\t\t\tBIT(12)\n-#define   MTK_PHY_RG_ZCALEN_C\t\t\tBIT(8)\n-#define   MTK_PHY_RG_ZCALEN_D\t\t\tBIT(4)\n-#define   MTK_PHY_RG_TXVOS_CALEN\t\tBIT(0)\n-\n-#define MTK_PHY_RG_ANA_CAL_RG5\t\t\t0xe0\n-#define   MTK_PHY_RG_REXT_TRIM_MASK\t\tGENMASK(13, 8)\n-\n-#define MTK_PHY_RG_TX_FILTER\t\t\t0xfe\n-\n-#define MTK_PHY_RG_LPI_PCS_DSP_CTRL_REG120\t0x120\n-#define   MTK_PHY_LPI_SIG_EN_LO_THRESH1000_MASK\tGENMASK(12, 8)\n-#define   MTK_PHY_LPI_SIG_EN_HI_THRESH1000_MASK\tGENMASK(4, 0)\n-\n-#define MTK_PHY_RG_LPI_PCS_DSP_CTRL_REG122\t0x122\n-#define   MTK_PHY_LPI_NORM_MSE_HI_THRESH1000_MASK\tGENMASK(7, 0)\n-\n-#define MTK_PHY_RG_TESTMUX_ADC_CTRL\t\t0x144\n-#define   MTK_PHY_RG_TXEN_DIG_MASK\t\tGENMASK(5, 5)\n-\n-#define MTK_PHY_RG_CR_TX_AMP_OFFSET_A_B\t\t0x172\n-#define   MTK_PHY_CR_TX_AMP_OFFSET_A_MASK\tGENMASK(13, 8)\n-#define   MTK_PHY_CR_TX_AMP_OFFSET_B_MASK\tGENMASK(6, 0)\n-\n-#define MTK_PHY_RG_CR_TX_AMP_OFFSET_C_D\t\t0x173\n-#define   MTK_PHY_CR_TX_AMP_OFFSET_C_MASK\tGENMASK(13, 8)\n-#define   MTK_PHY_CR_TX_AMP_OFFSET_D_MASK\tGENMASK(6, 0)\n-\n-#define MTK_PHY_RG_AD_CAL_COMP\t\t\t0x17a\n-#define   MTK_PHY_AD_CAL_COMP_OUT_MASK\t\tGENMASK(8, 8)\n-\n-#define MTK_PHY_RG_AD_CAL_CLK\t\t\t0x17b\n-#define   MTK_PHY_DA_CAL_CLK\t\t\tBIT(0)\n-\n-#define MTK_PHY_RG_AD_CALIN\t\t\t0x17c\n-#define   MTK_PHY_DA_CALIN_FLAG\t\t\tBIT(0)\n-\n-#define MTK_PHY_RG_DASN_DAC_IN0_A\t\t0x17d\n-#define   MTK_PHY_DASN_DAC_IN0_A_MASK\t\tGENMASK(9, 0)\n-\n-#define MTK_PHY_RG_DASN_DAC_IN0_B\t\t0x17e\n-#define   MTK_PHY_DASN_DAC_IN0_B_MASK\t\tGENMASK(9, 0)\n-\n-#define MTK_PHY_RG_DASN_DAC_IN0_C\t\t0x17f\n-#define   MTK_PHY_DASN_DAC_IN0_C_MASK\t\tGENMASK(9, 0)\n-\n-#define MTK_PHY_RG_DASN_DAC_IN0_D\t\t0x180\n-#define   MTK_PHY_DASN_DAC_IN0_D_MASK\t\tGENMASK(9, 0)\n-\n-#define MTK_PHY_RG_DASN_DAC_IN1_A\t\t0x181\n-#define   MTK_PHY_DASN_DAC_IN1_A_MASK\t\tGENMASK(9, 0)\n-\n-#define MTK_PHY_RG_DASN_DAC_IN1_B\t\t0x182\n-#define   MTK_PHY_DASN_DAC_IN1_B_MASK\t\tGENMASK(9, 0)\n-\n-#define MTK_PHY_RG_DASN_DAC_IN1_C\t\t0x183\n-#define   MTK_PHY_DASN_DAC_IN1_C_MASK\t\tGENMASK(9, 0)\n-\n-#define MTK_PHY_RG_DASN_DAC_IN1_D\t\t0x184\n-#define   MTK_PHY_DASN_DAC_IN1_D_MASK\t\tGENMASK(9, 0)\n-\n-#define MTK_PHY_RG_DEV1E_REG19b\t\t\t0x19b\n-#define   MTK_PHY_BYPASS_DSP_LPI_READY\t\tBIT(8)\n-\n-#define MTK_PHY_RG_LP_IIR2_K1_L\t\t\t0x22a\n-#define MTK_PHY_RG_LP_IIR2_K1_U\t\t\t0x22b\n-#define MTK_PHY_RG_LP_IIR2_K2_L\t\t\t0x22c\n-#define MTK_PHY_RG_LP_IIR2_K2_U\t\t\t0x22d\n-#define MTK_PHY_RG_LP_IIR2_K3_L\t\t\t0x22e\n-#define MTK_PHY_RG_LP_IIR2_K3_U\t\t\t0x22f\n-#define MTK_PHY_RG_LP_IIR2_K4_L\t\t\t0x230\n-#define MTK_PHY_RG_LP_IIR2_K4_U\t\t\t0x231\n-#define MTK_PHY_RG_LP_IIR2_K5_L\t\t\t0x232\n-#define MTK_PHY_RG_LP_IIR2_K5_U\t\t\t0x233\n-\n-#define MTK_PHY_RG_DEV1E_REG234\t\t\t0x234\n-#define   MTK_PHY_TR_OPEN_LOOP_EN_MASK\t\tGENMASK(0, 0)\n-#define   MTK_PHY_LPF_X_AVERAGE_MASK\t\tGENMASK(7, 4)\n-#define   MTK_PHY_TR_LP_IIR_EEE_EN\t\tBIT(12)\n-\n-#define MTK_PHY_RG_LPF_CNT_VAL\t\t\t0x235\n-\n-#define MTK_PHY_RG_DEV1E_REG238\t\t\t0x238\n-#define   MTK_PHY_LPI_SLV_SEND_TX_TIMER_MASK\tGENMASK(8, 0)\n-#define   MTK_PHY_LPI_SLV_SEND_TX_EN\t\tBIT(12)\n-\n-#define MTK_PHY_RG_DEV1E_REG239\t\t\t0x239\n-#define   MTK_PHY_LPI_SEND_LOC_TIMER_MASK\tGENMASK(8, 0)\n-#define   MTK_PHY_LPI_TXPCS_LOC_RCV\t\tBIT(12)\n-\n-#define MTK_PHY_RG_DEV1E_REG27C\t\t\t0x27c\n-#define   MTK_PHY_VGASTATE_FFE_THR_ST1_MASK\tGENMASK(12, 8)\n-#define MTK_PHY_RG_DEV1E_REG27D\t\t\t0x27d\n-#define   MTK_PHY_VGASTATE_FFE_THR_ST2_MASK\tGENMASK(4, 0)\n-\n-#define MTK_PHY_RG_DEV1E_REG2C7\t\t\t0x2c7\n-#define   MTK_PHY_MAX_GAIN_MASK\t\t\tGENMASK(4, 0)\n-#define   MTK_PHY_MIN_GAIN_MASK\t\t\tGENMASK(12, 8)\n-\n-#define MTK_PHY_RG_DEV1E_REG2D1\t\t\t0x2d1\n-#define   MTK_PHY_VCO_SLICER_THRESH_BITS_HIGH_EEE_MASK\tGENMASK(7, 0)\n-#define   MTK_PHY_LPI_SKIP_SD_SLV_TR\t\tBIT(8)\n-#define   MTK_PHY_LPI_TR_READY\t\t\tBIT(9)\n-#define   MTK_PHY_LPI_VCO_EEE_STG0_EN\t\tBIT(10)\n-\n-#define MTK_PHY_RG_DEV1E_REG323\t\t\t0x323\n-#define   MTK_PHY_EEE_WAKE_MAS_INT_DC\t\tBIT(0)\n-#define   MTK_PHY_EEE_WAKE_SLV_INT_DC\t\tBIT(4)\n-\n-#define MTK_PHY_RG_DEV1E_REG324\t\t\t0x324\n-#define   MTK_PHY_SMI_DETCNT_MAX_MASK\t\tGENMASK(5, 0)\n-#define   MTK_PHY_SMI_DET_MAX_EN\t\tBIT(8)\n-\n-#define MTK_PHY_RG_DEV1E_REG326\t\t\t0x326\n-#define   MTK_PHY_LPI_MODE_SD_ON\t\tBIT(0)\n-#define   MTK_PHY_RESET_RANDUPD_CNT\t\tBIT(1)\n-#define   MTK_PHY_TREC_UPDATE_ENAB_CLR\t\tBIT(2)\n-#define   MTK_PHY_LPI_QUIT_WAIT_DFE_SIG_DET_OFF\tBIT(4)\n-#define   MTK_PHY_TR_READY_SKIP_AFE_WAKEUP\tBIT(5)\n-\n-#define MTK_PHY_LDO_PUMP_EN_PAIRAB\t\t0x502\n-#define MTK_PHY_LDO_PUMP_EN_PAIRCD\t\t0x503\n-\n-#define MTK_PHY_DA_TX_R50_PAIR_A\t\t0x53d\n-#define MTK_PHY_DA_TX_R50_PAIR_B\t\t0x53e\n-#define MTK_PHY_DA_TX_R50_PAIR_C\t\t0x53f\n-#define MTK_PHY_DA_TX_R50_PAIR_D\t\t0x540\n-\n-/* Registers on MDIO_MMD_VEND2 */\n-#define MTK_PHY_LED1_DEFAULT_POLARITIES\t\tBIT(1)\n-\n-/* LED basic control register, part of the same LED block as the LED0/LED1\n- * control registers above. The air_en8811h driver describes the same\n- * register as AIR_PHY_LED_BCR.\n- */\n-#define MTK_PHY_LED_BCR\t\t\t\t0x21\n-#define   MTK_PHY_LED_BCR_CLK_EN\t\tBIT(3)\n-#define   MTK_PHY_LED_BCR_EXT_CTRL\t\tBIT(15)\n-\n-#define MTK_PHY_RG_BG_RASEL\t\t\t0x115\n-#define   MTK_PHY_RG_BG_RASEL_MASK\t\tGENMASK(2, 0)\n-\n-/* 'boottrap' register reflecting the configuration of the 4 PHY LEDs */\n-#define RG_GPIO_MISC_TPBANK0\t\t\t0x6f0\n-#define   RG_GPIO_MISC_TPBANK0_BOOTMODE\t\tGENMASK(11, 8)\n-\n /* These macro privides efuse parsing for internal phy. */\n #define EFS_DA_TX_I2MPB_A(x)\t\t\t(((x) \u003e\u003e 0) \u0026 GENMASK(5, 0))\n #define EFS_DA_TX_I2MPB_B(x)\t\t\t(((x) \u003e\u003e 6) \u0026 GENMASK(5, 0))\n@@ -355,51 +34,16 @@\n #define EFS_RG_BG_RASEL(x)\t\t\t(((x) \u003e\u003e 4) \u0026 GENMASK(2, 0))\n #define EFS_RG_REXT_TRIM(x)\t\t\t(((x) \u003e\u003e 7) \u0026 GENMASK(5, 0))\n \n-enum {\n-\tNO_PAIR,\n-\tPAIR_A,\n-\tPAIR_B,\n-\tPAIR_C,\n-\tPAIR_D,\n-};\n-\n-enum calibration_mode {\n-\tEFUSE_K,\n-\tSW_K\n-};\n-\n-enum CAL_ITEM {\n-\tREXT,\n-\tTX_OFFSET,\n-\tTX_AMP,\n-\tTX_R50,\n-\tTX_VCM\n-};\n-\n-enum CAL_MODE {\n-\tEFUSE_M,\n-\tSW_M\n-};\n-\n struct mtk_socphy_shared {\n \tu32\t\t\tboottrap;\n \tstruct mtk_socphy_priv\tpriv[4];\n };\n \n-/* One calibration cycle consists of:\n- * 1.Set DA_CALIN_FLAG high to start calibration. Keep it high\n- *   until AD_CAL_COMP is ready to output calibration result.\n- * 2.Wait until DA_CAL_CLK is available.\n- * 3.Fetch AD_CAL_COMP_OUT.\n- */\n-static int cal_cycle(struct phy_device *phydev, int devad,\n-\t\t     u32 regnum, u16 mask, u16 cal_val)\n+int mtk_cal_cycle_wait(struct phy_device *phydev)\n {\n \tint reg_val;\n \tint ret;\n \n-\tphy_modify_mmd(phydev, devad, regnum,\n-\t\t       mask, cal_val);\n \tphy_set_bits_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_RG_AD_CALIN,\n \t\t\t MTK_PHY_DA_CALIN_FLAG);\n \n@@ -418,7 +62,26 @@ static int cal_cycle(struct phy_device *phydev, int devad,\n \tret = phy_read_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_RG_AD_CAL_COMP);\n \tif (ret \u003c 0)\n \t\treturn ret;\n-\tret = FIELD_GET(MTK_PHY_AD_CAL_COMP_OUT_MASK, ret);\n+\n+\treturn FIELD_GET(MTK_PHY_AD_CAL_COMP_OUT_MASK, ret);\n+}\n+EXPORT_SYMBOL_GPL(mtk_cal_cycle_wait);\n+\n+/* One calibration cycle consists of:\n+ * 1.Set DA_CALIN_FLAG high to start calibration. Keep it high\n+ *   until AD_CAL_COMP is ready to output calibration result.\n+ * 2.Wait until DA_CAL_CLK is available.\n+ * 3.Fetch AD_CAL_COMP_OUT.\n+ */\n+static int cal_cycle(struct phy_device *phydev, int devad,\n+\t\t     u32 regnum, u16 mask, u16 cal_val)\n+{\n+\tint ret;\n+\n+\tphy_modify_mmd(phydev, devad, regnum,\n+\t\t       mask, cal_val);\n+\n+\tret = mtk_cal_cycle_wait(phydev);\n \tphydev_dbg(phydev, \"cal_val: 0x%x, ret: %d\\n\", cal_val, ret);\n \n \treturn ret;\n@@ -1224,73 +887,6 @@ static int mt798x_phy_config_init(struct phy_device *phydev)\n \treturn mt798x_phy_calibration(phydev);\n }\n \n-static int mt798x_phy_led_blink_set(struct phy_device *phydev, u8 index,\n-\t\t\t\t    unsigned long *delay_on,\n-\t\t\t\t    unsigned long *delay_off)\n-{\n-\tbool blinking = false;\n-\tint err;\n-\n-\terr = mtk_phy_led_num_dly_cfg(index, delay_on, delay_off, \u0026blinking);\n-\tif (err \u003c 0)\n-\t\treturn err;\n-\n-\terr = mtk_phy_hw_led_blink_set(phydev, index, blinking);\n-\tif (err)\n-\t\treturn err;\n-\n-\treturn mtk_phy_hw_led_on_set(phydev, index, MTK_GPHY_LED_ON_MASK,\n-\t\t\t\t     false);\n-}\n-\n-static int mt798x_phy_led_brightness_set(struct phy_device *phydev,\n-\t\t\t\t\t u8 index, enum led_brightness value)\n-{\n-\tint err;\n-\n-\terr = mtk_phy_hw_led_blink_set(phydev, index, false);\n-\tif (err)\n-\t\treturn err;\n-\n-\treturn mtk_phy_hw_led_on_set(phydev, index, MTK_GPHY_LED_ON_MASK,\n-\t\t\t\t     (value != LED_OFF));\n-}\n-\n-static const unsigned long supported_triggers =\n-\tBIT(TRIGGER_NETDEV_FULL_DUPLEX) |\n-\tBIT(TRIGGER_NETDEV_HALF_DUPLEX) |\n-\tBIT(TRIGGER_NETDEV_LINK)        |\n-\tBIT(TRIGGER_NETDEV_LINK_10)     |\n-\tBIT(TRIGGER_NETDEV_LINK_100)    |\n-\tBIT(TRIGGER_NETDEV_LINK_1000)   |\n-\tBIT(TRIGGER_NETDEV_RX)          |\n-\tBIT(TRIGGER_NETDEV_TX);\n-\n-static int mt798x_phy_led_hw_is_supported(struct phy_device *phydev, u8 index,\n-\t\t\t\t\t  unsigned long rules)\n-{\n-\treturn mtk_phy_led_hw_is_supported(phydev, index, rules,\n-\t\t\t\t\t   supported_triggers);\n-}\n-\n-static int mt798x_phy_led_hw_control_get(struct phy_device *phydev, u8 index,\n-\t\t\t\t\t unsigned long *rules)\n-{\n-\treturn mtk_phy_led_hw_ctrl_get(phydev, index, rules,\n-\t\t\t\t       MTK_GPHY_LED_ON_SET,\n-\t\t\t\t       MTK_GPHY_LED_RX_BLINK_SET,\n-\t\t\t\t       MTK_GPHY_LED_TX_BLINK_SET);\n-};\n-\n-static int mt798x_phy_led_hw_control_set(struct phy_device *phydev, u8 index,\n-\t\t\t\t\t unsigned long rules)\n-{\n-\treturn mtk_phy_led_hw_ctrl_set(phydev, index, rules,\n-\t\t\t\t       MTK_GPHY_LED_ON_SET,\n-\t\t\t\t       MTK_GPHY_LED_RX_BLINK_SET,\n-\t\t\t\t       MTK_GPHY_LED_TX_BLINK_SET);\n-};\n-\n static bool mt7988_phy_led_get_polarity(struct phy_device *phydev, int led_num)\n {\n \tstruct mtk_socphy_shared *priv = phy_package_get_priv(phydev);\n@@ -1427,71 +1023,6 @@ static int mt7981_phy_probe(struct phy_device *phydev)\n \treturn mt798x_phy_calibration(phydev);\n }\n \n-static int an7581_phy_probe(struct phy_device *phydev)\n-{\n-\tstruct mtk_socphy_priv *priv;\n-\tstruct pinctrl *pinctrl;\n-\n-\t/* Toggle pinctrl to enable PHY LED */\n-\tpinctrl = devm_pinctrl_get_select(\u0026phydev-\u003emdio.dev, \"gbe-led\");\n-\tif (IS_ERR(pinctrl))\n-\t\tdev_err(\u0026phydev-\u003emdio.bus-\u003edev,\n-\t\t\t\"Failed to setup PHY LED pinctrl\\n\");\n-\n-\tpriv = devm_kzalloc(\u0026phydev-\u003emdio.dev, sizeof(*priv), GFP_KERNEL);\n-\tif (!priv)\n-\t\treturn -ENOMEM;\n-\n-\tphydev-\u003epriv = priv;\n-\n-\treturn 0;\n-}\n-\n-static int an7581_phy_led_polarity_set(struct phy_device *phydev, int index,\n-\t\t\t\t       unsigned long modes)\n-{\n-\tu16 val = 0;\n-\tu32 mode;\n-\n-\tif (index \u003e= MTK_PHY_MAX_LEDS)\n-\t\treturn -EINVAL;\n-\n-\tfor_each_set_bit(mode, \u0026modes, __PHY_LED_MODES_NUM) {\n-\t\tswitch (mode) {\n-\t\tcase PHY_LED_ACTIVE_LOW:\n-\t\t\tval = MTK_PHY_LED_ON_POLARITY;\n-\t\t\tbreak;\n-\t\tcase PHY_LED_ACTIVE_HIGH:\n-\t\t\tbreak;\n-\t\tdefault:\n-\t\t\treturn -EINVAL;\n-\t\t}\n-\t}\n-\n-\treturn phy_modify_mmd(phydev, MDIO_MMD_VEND2, index ?\n-\t\t\t      MTK_PHY_LED1_ON_CTRL : MTK_PHY_LED0_ON_CTRL,\n-\t\t\t      MTK_PHY_LED_ON_POLARITY, val);\n-}\n-\n-static int an7583_phy_config_init(struct phy_device *phydev)\n-{\n-\t/* BMCR_PDOWN is enabled by default */\n-\treturn phy_clear_bits(phydev, MII_BMCR, BMCR_PDOWN);\n-}\n-\n-static int en7528_phy_config_init(struct phy_device *phydev)\n-{\n-\t/* The LED controller of the EN7528 powers up with its external\n-\t * control disabled, leaving the LED pins dark regardless of what is\n-\t * programmed into the LED control registers. Hand the pins over to\n-\t * the LED control registers the same way the air_en8811h driver\n-\t * does; the mode field of this register is already set out of reset.\n-\t */\n-\treturn phy_set_bits_mmd(phydev, MDIO_MMD_VEND2, MTK_PHY_LED_BCR,\n-\t\t\t\tMTK_PHY_LED_BCR_CLK_EN |\n-\t\t\t\tMTK_PHY_LED_BCR_EXT_CTRL);\n-}\n-\n static struct phy_driver mtk_socphy_driver[] = {\n \t{\n \t\tPHY_ID_MATCH_EXACT(MTK_GPHY_ID_MT7981),\n@@ -1527,43 +1058,6 @@ static struct phy_driver mtk_socphy_driver[] = {\n \t\t.led_hw_control_set = mt798x_phy_led_hw_control_set,\n \t\t.led_hw_control_get = mt798x_phy_led_hw_control_get,\n \t},\n-\t{\n-\t\tPHY_ID_MATCH_EXACT(MTK_GPHY_ID_EN7528),\n-\t\t.name\t\t= \"EcoNet EN7528 PHY\",\n-\t\t.config_init\t= en7528_phy_config_init,\n-\t\t.probe\t\t= an7581_phy_probe,\n-\t\t.led_blink_set\t= mt798x_phy_led_blink_set,\n-\t\t.led_brightness_set = mt798x_phy_led_brightness_set,\n-\t\t.led_hw_is_supported = mt798x_phy_led_hw_is_supported,\n-\t\t.led_hw_control_set = mt798x_phy_led_hw_control_set,\n-\t\t.led_hw_control_get = mt798x_phy_led_hw_control_get,\n-\t\t.led_polarity_set = an7581_phy_led_polarity_set,\n-\t},\n-\t{\n-\t\tPHY_ID_MATCH_EXACT(MTK_GPHY_ID_AN7581),\n-\t\t.name\t\t= \"Airoha AN7581 PHY\",\n-\t\t.config_intr\t= genphy_no_config_intr,\n-\t\t.handle_interrupt = genphy_handle_interrupt_no_ack,\n-\t\t.probe\t\t= an7581_phy_probe,\n-\t\t.led_blink_set\t= mt798x_phy_led_blink_set,\n-\t\t.led_brightness_set = mt798x_phy_led_brightness_set,\n-\t\t.led_hw_is_supported = mt798x_phy_led_hw_is_supported,\n-\t\t.led_hw_control_set = mt798x_phy_led_hw_control_set,\n-\t\t.led_hw_control_get = mt798x_phy_led_hw_control_get,\n-\t\t.led_polarity_set = an7581_phy_led_polarity_set,\n-\t},\n-\t{\n-\t\tPHY_ID_MATCH_EXACT(MTK_GPHY_ID_AN7583),\n-\t\t.name\t\t= \"Airoha AN7583 PHY\",\n-\t\t.config_init\t= an7583_phy_config_init,\n-\t\t.probe\t\t= an7581_phy_probe,\n-\t\t.led_blink_set\t= mt798x_phy_led_blink_set,\n-\t\t.led_brightness_set = mt798x_phy_led_brightness_set,\n-\t\t.led_hw_is_supported = mt798x_phy_led_hw_is_supported,\n-\t\t.led_hw_control_set = mt798x_phy_led_hw_control_set,\n-\t\t.led_hw_control_get = mt798x_phy_led_hw_control_get,\n-\t\t.led_polarity_set = an7581_phy_led_polarity_set,\n-\t},\n };\n \n module_phy_driver(mtk_socphy_driver);\n@@ -1571,9 +1065,6 @@ module_phy_driver(mtk_socphy_driver);\n static const struct mdio_device_id __maybe_unused mtk_socphy_tbl[] = {\n \t{ PHY_ID_MATCH_EXACT(MTK_GPHY_ID_MT7981) },\n \t{ PHY_ID_MATCH_EXACT(MTK_GPHY_ID_MT7988) },\n-\t{ PHY_ID_MATCH_EXACT(MTK_GPHY_ID_EN7528) },\n-\t{ PHY_ID_MATCH_EXACT(MTK_GPHY_ID_AN7581) },\n-\t{ PHY_ID_MATCH_EXACT(MTK_GPHY_ID_AN7583) },\n \t{ }\n };\n \ndiff --git a/drivers/net/phy/mediatek/mtk-ge-soc.h b/drivers/net/phy/mediatek/mtk-ge-soc.h\nnew file mode 100644\nindex 0000000000000..d6baff245deae\n--- /dev/null\n+++ b/drivers/net/phy/mediatek/mtk-ge-soc.h\n@@ -0,0 +1,377 @@\n+/* SPDX-License-Identifier: GPL-2.0 */\n+\n+#ifndef _MTK_GE_SOC_H_\n+#define _MTK_GE_SOC_H_\n+\n+#include \u003clinux/bitfield.h\u003e\n+\n+#define MTK_GPHY_ID_MT7981\t\t\t0x03a29461\n+#define MTK_GPHY_ID_MT7988\t\t\t0x03a29481\n+#define AIROHA_GPHY_ID_EN7528\t\t\t0x03a29491\n+#define AIROHA_GPHY_ID_AN7581\t\t\t0x03a294c1\n+#define AIROHA_GPHY_ID_AN7583\t\t\t0xc0ff0420\n+\n+#define MTK_EXT_PAGE_ACCESS\t\t\t0x1f\n+#define MTK_PHY_PAGE_STANDARD\t\t\t0x0000\n+#define MTK_PHY_PAGE_EXTENDED_1\t\t\t0x0001\n+#define MTK_PHY_PAGE_EXTENDED_3\t\t\t0x0003\n+\n+#define MTK_PHY_LPI_REG_14\t\t\t0x14\n+#define MTK_PHY_LPI_WAKE_TIMER_1000_MASK\tGENMASK(8, 0)\n+\n+#define MTK_PHY_LPI_REG_1c\t\t\t0x1c\n+#define MTK_PHY_SMI_DET_ON_THRESH_MASK\t\tGENMASK(13, 8)\n+\n+#define MTK_PHY_PAGE_EXTENDED_2A30\t\t0x2a30\n+\n+/* Registers on Token Ring debug nodes */\n+/* ch_addr = 0x0, node_addr = 0x7, data_addr = 0x15 */\n+/* NormMseLoThresh */\n+#define NORMAL_MSE_LO_THRESH_MASK\t\tGENMASK(15, 8)\n+\n+/* ch_addr = 0x0, node_addr = 0xf, data_addr = 0x3c */\n+/* RemAckCntLimitCtrl */\n+#define REMOTE_ACK_COUNT_LIMIT_CTRL_MASK\tGENMASK(2, 1)\n+\n+/* ch_addr = 0x1, node_addr = 0xd, data_addr = 0x20 */\n+/* VcoSlicerThreshBitsHigh */\n+#define VCO_SLICER_THRESH_HIGH_MASK\t\tGENMASK(23, 0)\n+\n+/* ch_addr = 0x1, node_addr = 0xf, data_addr = 0x0 */\n+/* DfeTailEnableVgaThresh1000 */\n+#define DFE_TAIL_EANBLE_VGA_TRHESH_1000\t\tGENMASK(5, 1)\n+\n+/* ch_addr = 0x1, node_addr = 0xf, data_addr = 0x1 */\n+/* MrvlTrFix100Kp */\n+#define MRVL_TR_FIX_100KP_MASK\t\t\tGENMASK(22, 20)\n+/* MrvlTrFix100Kf */\n+#define MRVL_TR_FIX_100KF_MASK\t\t\tGENMASK(19, 17)\n+/* MrvlTrFix1000Kp */\n+#define MRVL_TR_FIX_1000KP_MASK\t\t\tGENMASK(16, 14)\n+/* MrvlTrFix1000Kf */\n+#define MRVL_TR_FIX_1000KF_MASK\t\t\tGENMASK(13, 11)\n+\n+/* ch_addr = 0x1, node_addr = 0xf, data_addr = 0x12 */\n+/* VgaDecRate */\n+#define VGA_DECIMATION_RATE_MASK\t\tGENMASK(8, 5)\n+\n+/* ch_addr = 0x1, node_addr = 0xf, data_addr = 0x17 */\n+/* SlvDSPreadyTime */\n+#define SLAVE_DSP_READY_TIME_MASK\t\tGENMASK(22, 15)\n+/* MasDSPreadyTime */\n+#define MASTER_DSP_READY_TIME_MASK\t\tGENMASK(14, 7)\n+\n+/* ch_addr = 0x1, node_addr = 0xf, data_addr = 0x18 */\n+/* EnabRandUpdTrig */\n+#define ENABLE_RANDOM_UPDOWN_COUNTER_TRIGGER\tBIT(8)\n+\n+/* ch_addr = 0x1, node_addr = 0xf, data_addr = 0x20 */\n+/* ResetSyncOffset */\n+#define RESET_SYNC_OFFSET_MASK\t\t\tGENMASK(11, 8)\n+\n+/* ch_addr = 0x2, node_addr = 0xd, data_addr = 0x0 */\n+/* FfeUpdGainForceVal */\n+#define FFE_UPDATE_GAIN_FORCE_VAL_MASK\t\tGENMASK(9, 7)\n+/* FfeUpdGainForce */\n+#define FFE_UPDATE_GAIN_FORCE\t\t\tBIT(6)\n+\n+/* ch_addr = 0x2, node_addr = 0xd, data_addr = 0x3 */\n+/* TrFreeze */\n+#define TR_FREEZE_MASK\t\t\t\tGENMASK(11, 0)\n+\n+/* ch_addr = 0x2, node_addr = 0xd, data_addr = 0x6 */\n+/* SS: Steady-state, KP: Proportional Gain */\n+/* SSTrKp100 */\n+#define SS_TR_KP100_MASK\t\t\tGENMASK(21, 19)\n+/* SSTrKf100 */\n+#define SS_TR_KF100_MASK\t\t\tGENMASK(18, 16)\n+/* SSTrKp1000Mas */\n+#define SS_TR_KP1000_MASTER_MASK\t\tGENMASK(15, 13)\n+/* SSTrKf1000Mas */\n+#define SS_TR_KF1000_MASTER_MASK\t\tGENMASK(12, 10)\n+/* SSTrKp1000Slv */\n+#define SS_TR_KP1000_SLAVE_MASK\t\t\tGENMASK(9, 7)\n+/* SSTrKf1000Slv */\n+#define SS_TR_KF1000_SLAVE_MASK\t\t\tGENMASK(6, 4)\n+\n+/* ch_addr = 0x2, node_addr = 0xd, data_addr = 0x8 */\n+/* clear this bit if wanna select from AFE */\n+/* Regsigdet_sel_1000 */\n+#define EEE1000_SELECT_SIGNAL_DETECTION_FROM_DFE\tBIT(4)\n+\n+/* ch_addr = 0x2, node_addr = 0xd, data_addr = 0xd */\n+/* RegEEE_st2TrKf1000 */\n+#define EEE1000_STAGE2_TR_KF_MASK\t\tGENMASK(13, 11)\n+\n+/* ch_addr = 0x2, node_addr = 0xd, data_addr = 0xf */\n+/* RegEEE_slv_waketr_timer_tar */\n+#define SLAVE_WAKETR_TIMER_MASK\t\t\tGENMASK(20, 11)\n+/* RegEEE_slv_remtx_timer_tar */\n+#define SLAVE_REMTX_TIMER_MASK\t\t\tGENMASK(10, 1)\n+\n+/* ch_addr = 0x2, node_addr = 0xd, data_addr = 0x10 */\n+/* RegEEE_slv_wake_int_timer_tar */\n+#define SLAVE_WAKEINT_TIMER_MASK\t\tGENMASK(10, 1)\n+\n+/* ch_addr = 0x2, node_addr = 0xd, data_addr = 0x14 */\n+/* RegEEE_trfreeze_timer2 */\n+#define TR_FREEZE_TIMER2_MASK\t\t\tGENMASK(9, 0)\n+\n+/* ch_addr = 0x2, node_addr = 0xd, data_addr = 0x1c */\n+/* RegEEE100Stg1_tar */\n+#define EEE100_LPSYNC_STAGE1_UPDATE_TIMER_MASK\tGENMASK(8, 0)\n+\n+/* ch_addr = 0x2, node_addr = 0xd, data_addr = 0x25 */\n+/* REGEEE_wake_slv_tr_wait_dfesigdet_en */\n+#define WAKE_SLAVE_TR_WAIT_DFE_DETECTION_EN\tBIT(11)\n+\n+#define ANALOG_INTERNAL_OPERATION_MAX_US\t20\n+#define TXRESERVE_MIN\t\t\t\t0\n+#define TXRESERVE_MAX\t\t\t\t7\n+\n+#define MTK_PHY_ANARG_RG\t\t\t0x10\n+#define   MTK_PHY_TCLKOFFSET_MASK\t\tGENMASK(12, 8)\n+\n+/* Registers on MDIO_MMD_VEND1 */\n+#define MTK_PHY_TXVLD_DA_RG\t\t\t0x12\n+#define   MTK_PHY_DA_TX_I2MPB_A_GBE_MASK\tGENMASK(15, 10)\n+#define   MTK_PHY_DA_TX_I2MPB_A_TBT_MASK\tGENMASK(5, 0)\n+\n+#define MTK_PHY_TX_I2MPB_TEST_MODE_A2\t\t0x16\n+#define   MTK_PHY_DA_TX_I2MPB_A_HBT_MASK\tGENMASK(15, 10)\n+#define   MTK_PHY_DA_TX_I2MPB_A_TST_MASK\tGENMASK(5, 0)\n+\n+#define MTK_PHY_TX_I2MPB_TEST_MODE_B1\t\t0x17\n+#define   MTK_PHY_DA_TX_I2MPB_B_GBE_MASK\tGENMASK(13, 8)\n+#define   MTK_PHY_DA_TX_I2MPB_B_TBT_MASK\tGENMASK(5, 0)\n+\n+#define MTK_PHY_TX_I2MPB_TEST_MODE_B2\t\t0x18\n+#define   MTK_PHY_DA_TX_I2MPB_B_HBT_MASK\tGENMASK(13, 8)\n+#define   MTK_PHY_DA_TX_I2MPB_B_TST_MASK\tGENMASK(5, 0)\n+\n+#define MTK_PHY_TX_I2MPB_TEST_MODE_C1\t\t0x19\n+#define   MTK_PHY_DA_TX_I2MPB_C_GBE_MASK\tGENMASK(13, 8)\n+#define   MTK_PHY_DA_TX_I2MPB_C_TBT_MASK\tGENMASK(5, 0)\n+\n+#define MTK_PHY_TX_I2MPB_TEST_MODE_C2\t\t0x20\n+#define   MTK_PHY_DA_TX_I2MPB_C_HBT_MASK\tGENMASK(13, 8)\n+#define   MTK_PHY_DA_TX_I2MPB_C_TST_MASK\tGENMASK(5, 0)\n+\n+#define MTK_PHY_TX_I2MPB_TEST_MODE_D1\t\t0x21\n+#define   MTK_PHY_DA_TX_I2MPB_D_GBE_MASK\tGENMASK(13, 8)\n+#define   MTK_PHY_DA_TX_I2MPB_D_TBT_MASK\tGENMASK(5, 0)\n+\n+#define MTK_PHY_TX_I2MPB_TEST_MODE_D2\t\t0x22\n+#define   MTK_PHY_DA_TX_I2MPB_D_HBT_MASK\tGENMASK(13, 8)\n+#define   MTK_PHY_DA_TX_I2MPB_D_TST_MASK\tGENMASK(5, 0)\n+\n+#define MTK_PHY_RXADC_CTRL_RG7\t\t\t0xc6\n+#define   MTK_PHY_DA_AD_BUF_BIAS_LP_MASK\tGENMASK(9, 8)\n+\n+#define MTK_PHY_RXADC_CTRL_RG9\t\t\t0xc8\n+#define   MTK_PHY_DA_RX_PSBN_TBT_MASK\t\tGENMASK(14, 12)\n+#define   MTK_PHY_DA_RX_PSBN_HBT_MASK\t\tGENMASK(10, 8)\n+#define   MTK_PHY_DA_RX_PSBN_GBE_MASK\t\tGENMASK(6, 4)\n+#define   MTK_PHY_DA_RX_PSBN_LP_MASK\t\tGENMASK(2, 0)\n+\n+#define MTK_PHY_LDO_OUTPUT_V\t\t\t0xd7\n+\n+#define MTK_PHY_RG_ANA_CAL_RG0\t\t\t0xdb\n+#define   MTK_PHY_RG_CAL_CKINV\t\t\tBIT(12)\n+#define   MTK_PHY_RG_ANA_CALEN\t\t\tBIT(8)\n+#define   MTK_PHY_RG_REXT_CALEN\t\t\tBIT(4)\n+#define   MTK_PHY_RG_ZCALEN_A\t\t\tBIT(0)\n+\n+#define MTK_PHY_RG_ANA_CAL_RG1\t\t\t0xdc\n+#define   MTK_PHY_RG_ZCALEN_B\t\t\tBIT(12)\n+#define   MTK_PHY_RG_ZCALEN_C\t\t\tBIT(8)\n+#define   MTK_PHY_RG_ZCALEN_D\t\t\tBIT(4)\n+#define   MTK_PHY_RG_TXVOS_CALEN\t\tBIT(0)\n+\n+#define MTK_PHY_RG_ANA_CAL_RG5\t\t\t0xe0\n+#define   MTK_PHY_RG_REXT_TRIM_MASK\t\tGENMASK(13, 8)\n+#define   MTK_PHY_RG_REXT_ZCAL_CTRL_MASK\tGENMASK(5, 0)\n+\n+#define MTK_PHY_RG_ANA_CAL_RG6\t\t\t0xe1\n+\n+#define MTK_PHY_RG_TX_FILTER\t\t\t0xfe\n+\n+#define MTK_PHY_RG_LPI_PCS_DSP_CTRL_REG120\t0x120\n+#define   MTK_PHY_LPI_SIG_EN_LO_THRESH1000_MASK\tGENMASK(12, 8)\n+#define   MTK_PHY_LPI_SIG_EN_HI_THRESH1000_MASK\tGENMASK(4, 0)\n+\n+#define MTK_PHY_RG_LPI_PCS_DSP_CTRL_REG122\t0x122\n+#define   MTK_PHY_LPI_NORM_MSE_HI_THRESH1000_MASK\tGENMASK(7, 0)\n+\n+#define MTK_PHY_RG_TESTMUX_ADC_CTRL\t\t0x144\n+#define   MTK_PHY_RG_TXEN_DIG_MASK\t\tGENMASK(5, 5)\n+\n+#define MTK_PHY_RG_CR_TX_AMP_OFFSET_A_B\t\t0x172\n+#define   MTK_PHY_CR_TX_AMP_OFFSET_A_MASK\tGENMASK(13, 8)\n+#define   MTK_PHY_CR_TX_AMP_OFFSET_B_MASK\tGENMASK(6, 0)\n+#define   AIROHA_PHY_CR_TX_AMP_OFFSET_B_MASK\tGENMASK(5, 0)\n+\n+#define MTK_PHY_RG_CR_TX_AMP_OFFSET_C_D\t\t0x173\n+#define   MTK_PHY_CR_TX_AMP_OFFSET_C_MASK\tGENMASK(13, 8)\n+#define   MTK_PHY_CR_TX_AMP_OFFSET_D_MASK\tGENMASK(6, 0)\n+#define   AIROHA_PHY_CR_TX_AMP_OFFSET_D_MASK\tGENMASK(5, 0)\n+\n+#define MTK_PHY_RG_CR_TX_R50_OFFSET_A_B\t\t0x174\n+#define   MTK_PHY_CR_TX_R50_OFFSET_A_MASK\tGENMASK(13, 8)\n+#define   AIROHA_PHY_CR_TX_R50_OFFSET_A_MASK\tGENMASK(14, 8)\n+#define   MTK_PHY_CR_TX_R50_OFFSET_B_MASK\tGENMASK(6, 0)\n+\n+#define MTK_PHY_RG_CR_TX_R50_OFFSET_C_D\t\t0x175\n+#define   MTK_PHY_CR_TX_R50_OFFSET_C_MASK\tGENMASK(13, 8)\n+#define   AIROHA_PHY_CR_TX_R50_OFFSET_C_MASK\tGENMASK(14, 8)\n+#define   MTK_PHY_CR_TX_R50_OFFSET_D_MASK\tGENMASK(6, 0)\n+\n+#define MTK_PHY_RG_AD_CAL_COMP\t\t\t0x17a\n+#define   MTK_PHY_AD_CAL_COMP_OUT_MASK\t\tGENMASK(8, 8)\n+\n+#define MTK_PHY_RG_AD_CAL_CLK\t\t\t0x17b\n+#define   MTK_PHY_DA_CAL_CLK\t\t\tBIT(0)\n+\n+#define MTK_PHY_RG_AD_CALIN\t\t\t0x17c\n+#define   MTK_PHY_DA_CALIN_FLAG\t\t\tBIT(0)\n+\n+#define MTK_PHY_RG_DASN_DAC_IN0_A\t\t0x17d\n+#define   MTK_PHY_DASN_DAC_IN0_A_MASK\t\tGENMASK(9, 0)\n+\n+#define MTK_PHY_RG_DASN_DAC_IN0_B\t\t0x17e\n+#define   MTK_PHY_DASN_DAC_IN0_B_MASK\t\tGENMASK(9, 0)\n+\n+#define MTK_PHY_RG_DASN_DAC_IN0_C\t\t0x17f\n+#define   MTK_PHY_DASN_DAC_IN0_C_MASK\t\tGENMASK(9, 0)\n+\n+#define MTK_PHY_RG_DASN_DAC_IN0_D\t\t0x180\n+#define   MTK_PHY_DASN_DAC_IN0_D_MASK\t\tGENMASK(9, 0)\n+\n+#define MTK_PHY_RG_DASN_DAC_IN1_A\t\t0x181\n+#define   MTK_PHY_DASN_DAC_IN1_A_MASK\t\tGENMASK(9, 0)\n+\n+#define MTK_PHY_RG_DASN_DAC_IN1_B\t\t0x182\n+#define   MTK_PHY_DASN_DAC_IN1_B_MASK\t\tGENMASK(9, 0)\n+\n+#define MTK_PHY_RG_DASN_DAC_IN1_C\t\t0x183\n+#define   MTK_PHY_DASN_DAC_IN1_C_MASK\t\tGENMASK(9, 0)\n+\n+#define MTK_PHY_RG_DASN_DAC_IN1_D\t\t0x184\n+#define   MTK_PHY_DASN_DAC_IN1_D_MASK\t\tGENMASK(9, 0)\n+\n+#define MTK_PHY_RG_DEV1E_REG19b\t\t\t0x19b\n+#define   MTK_PHY_BYPASS_DSP_LPI_READY\t\tBIT(8)\n+\n+#define MTK_PHY_RG_LP_IIR2_K1_L\t\t\t0x22a\n+#define MTK_PHY_RG_LP_IIR2_K1_U\t\t\t0x22b\n+#define MTK_PHY_RG_LP_IIR2_K2_L\t\t\t0x22c\n+#define MTK_PHY_RG_LP_IIR2_K2_U\t\t\t0x22d\n+#define MTK_PHY_RG_LP_IIR2_K3_L\t\t\t0x22e\n+#define MTK_PHY_RG_LP_IIR2_K3_U\t\t\t0x22f\n+#define MTK_PHY_RG_LP_IIR2_K4_L\t\t\t0x230\n+#define MTK_PHY_RG_LP_IIR2_K4_U\t\t\t0x231\n+#define MTK_PHY_RG_LP_IIR2_K5_L\t\t\t0x232\n+#define MTK_PHY_RG_LP_IIR2_K5_U\t\t\t0x233\n+\n+#define MTK_PHY_RG_DEV1E_REG234\t\t\t0x234\n+#define   MTK_PHY_TR_OPEN_LOOP_EN_MASK\t\tGENMASK(0, 0)\n+#define   MTK_PHY_LPF_X_AVERAGE_MASK\t\tGENMASK(7, 4)\n+#define   MTK_PHY_TR_LP_IIR_EEE_EN\t\tBIT(12)\n+\n+#define MTK_PHY_RG_LPF_CNT_VAL\t\t\t0x235\n+\n+#define MTK_PHY_RG_DEV1E_REG238\t\t\t0x238\n+#define   MTK_PHY_LPI_SLV_SEND_TX_TIMER_MASK\tGENMASK(8, 0)\n+#define   MTK_PHY_LPI_SLV_SEND_TX_EN\t\tBIT(12)\n+\n+#define MTK_PHY_RG_DEV1E_REG239\t\t\t0x239\n+#define   MTK_PHY_LPI_SEND_LOC_TIMER_MASK\tGENMASK(8, 0)\n+#define   MTK_PHY_LPI_TXPCS_LOC_RCV\t\tBIT(12)\n+\n+#define MTK_PHY_RG_DEV1E_REG27C\t\t\t0x27c\n+#define   MTK_PHY_VGASTATE_FFE_THR_ST1_MASK\tGENMASK(12, 8)\n+#define MTK_PHY_RG_DEV1E_REG27D\t\t\t0x27d\n+#define   MTK_PHY_VGASTATE_FFE_THR_ST2_MASK\tGENMASK(4, 0)\n+\n+#define MTK_PHY_RG_DEV1E_REG2C7\t\t\t0x2c7\n+#define   MTK_PHY_MAX_GAIN_MASK\t\t\tGENMASK(4, 0)\n+#define   MTK_PHY_MIN_GAIN_MASK\t\t\tGENMASK(12, 8)\n+\n+#define MTK_PHY_RG_DEV1E_REG2D1\t\t\t0x2d1\n+#define   MTK_PHY_VCO_SLICER_THRESH_BITS_HIGH_EEE_MASK\tGENMASK(7, 0)\n+#define   MTK_PHY_LPI_SKIP_SD_SLV_TR\t\tBIT(8)\n+#define   MTK_PHY_LPI_TR_READY\t\t\tBIT(9)\n+#define   MTK_PHY_LPI_VCO_EEE_STG0_EN\t\tBIT(10)\n+\n+#define MTK_PHY_RG_DEV1E_REG323\t\t\t0x323\n+#define   MTK_PHY_EEE_WAKE_MAS_INT_DC\t\tBIT(0)\n+#define   MTK_PHY_EEE_WAKE_SLV_INT_DC\t\tBIT(4)\n+\n+#define MTK_PHY_RG_DEV1E_REG324\t\t\t0x324\n+#define   MTK_PHY_SMI_DETCNT_MAX_MASK\t\tGENMASK(5, 0)\n+#define   MTK_PHY_SMI_DET_MAX_EN\t\tBIT(8)\n+\n+#define MTK_PHY_RG_DEV1E_REG326\t\t\t0x326\n+#define   MTK_PHY_LPI_MODE_SD_ON\t\tBIT(0)\n+#define   MTK_PHY_RESET_RANDUPD_CNT\t\tBIT(1)\n+#define   MTK_PHY_TREC_UPDATE_ENAB_CLR\t\tBIT(2)\n+#define   MTK_PHY_LPI_QUIT_WAIT_DFE_SIG_DET_OFF\tBIT(4)\n+#define   MTK_PHY_TR_READY_SKIP_AFE_WAKEUP\tBIT(5)\n+\n+#define MTK_PHY_LDO_PUMP_EN_PAIRAB\t\t0x502\n+#define MTK_PHY_LDO_PUMP_EN_PAIRCD\t\t0x503\n+\n+#define MTK_PHY_DA_TX_R50_PAIR_A\t\t0x53d\n+#define MTK_PHY_DA_TX_R50_PAIR_B\t\t0x53e\n+#define MTK_PHY_DA_TX_R50_PAIR_C\t\t0x53f\n+#define MTK_PHY_DA_TX_R50_PAIR_D\t\t0x540\n+\n+/* Registers on MDIO_MMD_VEND2 */\n+#define MTK_PHY_LED1_DEFAULT_POLARITIES\t\tBIT(1)\n+\n+/* LED basic control register, part of the same LED block as the LED0/LED1\n+ * control registers above. The air_en8811h driver describes the same\n+ * register as AIR_PHY_LED_BCR.\n+ */\n+#define MTK_PHY_LED_BCR\t\t\t\t0x21\n+#define   MTK_PHY_LED_BCR_CLK_EN\t\tBIT(3)\n+#define   MTK_PHY_LED_BCR_EXT_CTRL\t\tBIT(15)\n+\n+#define MTK_PHY_RG_BG_RASEL\t\t\t0x115\n+#define   MTK_PHY_RG_BG_RASEL_MASK\t\tGENMASK(2, 0)\n+\n+/* 'boottrap' register reflecting the configuration of the 4 PHY LEDs */\n+#define RG_GPIO_MISC_TPBANK0\t\t\t0x6f0\n+#define   RG_GPIO_MISC_TPBANK0_BOOTMODE\t\tGENMASK(11, 8)\n+\n+enum CAL_ITEM {\n+\tREXT,\n+\tTX_OFFSET,\n+\tTX_AMP,\n+\tTX_R50,\n+\tTX_VCM,\n+\tRX_OFFSET,\n+};\n+\n+enum {\n+\tNO_PAIR,\n+\tPAIR_A,\n+\tPAIR_B,\n+\tPAIR_C,\n+\tPAIR_D,\n+};\n+\n+enum calibration_mode {\n+\tEFUSE_K,\n+\tSW_K\n+};\n+\n+enum CAL_MODE {\n+\tEFUSE_M,\n+\tSW_M\n+};\n+\n+/* MTK GE SoC common functions */\n+int mtk_cal_cycle_wait(struct phy_device *phydev);\n+\n+#endif /* _MTK_GE_SOC_H_ */\ndiff --git a/drivers/net/phy/mediatek/mtk-phy-lib.c b/drivers/net/phy/mediatek/mtk-phy-lib.c\nindex 4c4eca870bde1..dc4abd95d73fc 100644\n--- a/drivers/net/phy/mediatek/mtk-phy-lib.c\n+++ b/drivers/net/phy/mediatek/mtk-phy-lib.c\n@@ -36,8 +36,8 @@ static void __mtk_tr_read(struct phy_device *phydev, u8 ch_addr, u8 node_addr,\n \t\t*tr_high, *tr_low);\n }\n \n-static void __mtk_tr_write(struct phy_device *phydev, u8 ch_addr, u8 node_addr,\n-\t\t\t   u8 data_addr, u32 tr_data)\n+void __mtk_tr_write(struct phy_device *phydev, u8 ch_addr, u8 node_addr,\n+\t\t    u8 data_addr, u32 tr_data)\n {\n \t__phy_write(phydev, 0x11, tr_data \u0026 0xffff);\n \t__phy_write(phydev, 0x12, tr_data \u003e\u003e 16);\n@@ -45,6 +45,7 @@ static void __mtk_tr_write(struct phy_device *phydev, u8 ch_addr, u8 node_addr,\n \t\ttr_data \u003e\u003e 16, tr_data \u0026 0xffff);\n \t__mtk_tr_access(phydev, false, ch_addr, node_addr, data_addr);\n }\n+EXPORT_SYMBOL_GPL(__mtk_tr_write);\n \n void __mtk_tr_modify(struct phy_device *phydev, u8 ch_addr, u8 node_addr,\n \t\t     u8 data_addr, u32 mask, u32 set)\n@@ -338,6 +339,78 @@ void mtk_phy_leds_state_init(struct phy_device *phydev)\n }\n EXPORT_SYMBOL_GPL(mtk_phy_leds_state_init);\n \n+int mt798x_phy_led_blink_set(struct phy_device *phydev, u8 index,\n+\t\t\t     unsigned long *delay_on,\n+\t\t\t     unsigned long *delay_off)\n+{\n+\tbool blinking = false;\n+\tint err;\n+\n+\terr = mtk_phy_led_num_dly_cfg(index, delay_on, delay_off, \u0026blinking);\n+\tif (err \u003c 0)\n+\t\treturn err;\n+\n+\terr = mtk_phy_hw_led_blink_set(phydev, index, blinking);\n+\tif (err)\n+\t\treturn err;\n+\n+\treturn mtk_phy_hw_led_on_set(phydev, index, MTK_GPHY_LED_ON_MASK,\n+\t\t\t\t     false);\n+}\n+EXPORT_SYMBOL_GPL(mt798x_phy_led_blink_set);\n+\n+int mt798x_phy_led_brightness_set(struct phy_device *phydev,\n+\t\t\t\t  u8 index, enum led_brightness value)\n+{\n+\tint err;\n+\n+\terr = mtk_phy_hw_led_blink_set(phydev, index, false);\n+\tif (err)\n+\t\treturn err;\n+\n+\treturn mtk_phy_hw_led_on_set(phydev, index, MTK_GPHY_LED_ON_MASK,\n+\t\t\t\t     (value != LED_OFF));\n+}\n+EXPORT_SYMBOL_GPL(mt798x_phy_led_brightness_set);\n+\n+static const unsigned long supported_triggers =\n+\tBIT(TRIGGER_NETDEV_FULL_DUPLEX) |\n+\tBIT(TRIGGER_NETDEV_HALF_DUPLEX) |\n+\tBIT(TRIGGER_NETDEV_LINK)        |\n+\tBIT(TRIGGER_NETDEV_LINK_10)     |\n+\tBIT(TRIGGER_NETDEV_LINK_100)    |\n+\tBIT(TRIGGER_NETDEV_LINK_1000)   |\n+\tBIT(TRIGGER_NETDEV_RX)          |\n+\tBIT(TRIGGER_NETDEV_TX);\n+\n+int mt798x_phy_led_hw_is_supported(struct phy_device *phydev, u8 index,\n+\t\t\t\t   unsigned long rules)\n+{\n+\treturn mtk_phy_led_hw_is_supported(phydev, index, rules,\n+\t\t\t\t\t   supported_triggers);\n+}\n+EXPORT_SYMBOL_GPL(mt798x_phy_led_hw_is_supported);\n+\n+int mt798x_phy_led_hw_control_get(struct phy_device *phydev, u8 index,\n+\t\t\t\t  unsigned long *rules)\n+{\n+\treturn mtk_phy_led_hw_ctrl_get(phydev, index, rules,\n+\t\t\t\t       MTK_GPHY_LED_ON_SET,\n+\t\t\t\t       MTK_GPHY_LED_RX_BLINK_SET,\n+\t\t\t\t       MTK_GPHY_LED_TX_BLINK_SET);\n+};\n+EXPORT_SYMBOL_GPL(mt798x_phy_led_hw_control_get);\n+\n+int mt798x_phy_led_hw_control_set(struct phy_device *phydev, u8 index,\n+\t\t\t\t  unsigned long rules)\n+{\n+\treturn mtk_phy_led_hw_ctrl_set(phydev, index, rules,\n+\t\t\t\t       MTK_GPHY_LED_ON_SET,\n+\t\t\t\t       MTK_GPHY_LED_RX_BLINK_SET,\n+\t\t\t\t       MTK_GPHY_LED_TX_BLINK_SET);\n+};\n+EXPORT_SYMBOL_GPL(mt798x_phy_led_hw_control_set);\n+\n MODULE_DESCRIPTION(\"MediaTek Ethernet PHY driver common\");\n MODULE_AUTHOR(\"Sky Huang \u003cSkyLake.Huang@mediatek.com\u003e\");\n MODULE_AUTHOR(\"Daniel Golle \u003cdaniel@makrotopia.org\u003e\");\ndiff --git a/drivers/net/phy/mediatek/mtk.h b/drivers/net/phy/mediatek/mtk.h\nindex 79e09727b81bc..608e5e3d754f9 100644\n--- a/drivers/net/phy/mediatek/mtk.h\n+++ b/drivers/net/phy/mediatek/mtk.h\n@@ -13,6 +13,7 @@\n \n #define MTK_EXT_PAGE_ACCESS\t\t\t0x1f\n #define MTK_PHY_PAGE_EXTENDED_1\t\t\t0x0001\n+#define MTK_PHY_PAGE_EXTENDED_3\t\t\t0x0003\n #define MTK_PHY_PAGE_STANDARD\t\t\t0x0000\n #define MTK_PHY_PAGE_EXTENDED_52B5\t\t0x52b5\n \n@@ -72,6 +73,8 @@ struct mtk_socphy_priv {\n \tunsigned long\t\tled_state;\n };\n \n+void __mtk_tr_write(struct phy_device *phydev, u8 ch_addr, u8 node_addr,\n+\t\t    u8 data_addr, u32 tr_data);\n void __mtk_tr_modify(struct phy_device *phydev, u8 ch_addr, u8 node_addr,\n \t\t     u8 data_addr, u32 mask, u32 set);\n void mtk_tr_modify(struct phy_device *phydev, u8 ch_addr, u8 node_addr,\n@@ -101,4 +104,16 @@ int mtk_phy_hw_led_blink_set(struct phy_device *phydev, u8 index,\n \t\t\t     bool blinking);\n void mtk_phy_leds_state_init(struct phy_device *phydev);\n \n+int mt798x_phy_led_blink_set(struct phy_device *phydev, u8 index,\n+\t\t\t     unsigned long *delay_on,\n+\t\t\t     unsigned long *delay_off);\n+int mt798x_phy_led_brightness_set(struct phy_device *phydev,\n+\t\t\t\t  u8 index, enum led_brightness value);\n+int mt798x_phy_led_hw_is_supported(struct phy_device *phydev, u8 index,\n+\t\t\t\t   unsigned long rules);\n+int mt798x_phy_led_hw_control_get(struct phy_device *phydev, u8 index,\n+\t\t\t\t  unsigned long *rules);\n+int mt798x_phy_led_hw_control_set(struct phy_device *phydev, u8 index,\n+\t\t\t\t  unsigned long rules);\n+\n #endif /* _MTK_EPHY_H_ */\n"
}

2/1 2026/10/14 12:04 agent patch-evaluator
6m Model:
core

Args:
null

Results:
{
  "EnableConfigs": null,
  "FocusSymbols": [],
  "Reasoning": "The patch adds the Airoha SoC Gigabit Ethernet PHY driver (airoha-ge-soc.c) and refactors shared helper and LED functions across MediaTek/Airoha PHY drivers (mtk-ge-soc.c, mtk-phy-lib.c). These drivers target built-in Gigabit Ethernet PHYs physically integrated into ARM64 (Airoha AN7581/AN7583, MediaTek MT7981/MT7988) and MIPS (EcoNet EN7528) networking SoCs. On the target amd64 architecture, these drivers can only be built with COMPILE_TEST and require physical SoC hardware not emulated in standard QEMU/GCE environments. Because the modified code is structurally unreachable, it does not warrant fuzzing.",
  "WorthFuzzing": false
}

Instruction:
You are an expert Linux kernel maintainer and security engineer.
Your job is to review a provided patch series and evaluate whether it warrants fuzzing with syzkaller.

IMPORTANT: The changes have ALREADY been applied and committed as the HEAD commit in
your workspace. Do NOT rely on internal assumptions. You must actively use your code access
tools to inspect the actual source code, callers, and surrounding context.

================================================================================
1. CORE TRIAGE PHILOSOPHY
================================================================================
The goal of patch fuzzing is to discover crashes, regressions, exposed latent bugs,
and newly triggered assertions introduced by the patch series.

- REACHABILITY IS THE PRIMARY GATE:
  Fuzzing can only discover bugs in code that can actually execute in standard virtualized
  environments (GCE or QEMU, utilizing software-emulated devices like USB gadgets, netdev, tun/tap).
  If the modified code is structurally unreachable (see Section 2), it MUST NOT be fuzzed,
  regardless of whether it adds assertions or complex logic.

- DO NOT BLINDLY TRUST "NO FUNCTIONAL CHANGE" (NFCI) OR "REFACTORING" CLAIMS:
  Patch authors routinely label changes as "cleanups", "refactorings", or state
  "No functional change intended". Do NOT take these claims at face value.
  Code refactorings that rearrange logic, introduce helper functions, or alter state management
  in core subsystems frequently introduce subtle semantic shifts or uncover latent kernel bugs.
  If reachable executable code is modified or refactored, it MUST be fuzzed.

- NEW OR MODIFIED ASSERTIONS IN REACHABLE CODE MUST BE FUZZED:
  When a patch introduces or modifies runtime checks or assertions (e.g., WARN_ON*, VM_WARN_ON*,
  BUG_ON*, lockdep_assert*) in reachable code paths, it enforces new or stricter invariants.
  Even if the author believes the invariant always holds, fuzzing is essential to verify whether
  an unusual sequence of operations can violate it.

================================================================================
2. WHEN TO RETURN WorthFuzzing=false (NEGATIVE CRITERIA)
================================================================================
Return WorthFuzzing=false ONLY IF all modified code falls strictly into one or more of these categories:

- Non-kernel and non-executable changes:
  * Modifications to Documentation/, comments, or spelling fixes.
  * User-space directories, self-tests, samples, or scripts (e.g., tools/, samples/, scripts/, usr/)
    that do not affect the compiled kernel image (vmlinux) or kernel modules.
  * Purely decorative logging (e.g., message strings in pr_err, printk, dev_info) or tracepoints
    that do not alter control flow or data structures.
  * Build system or Kconfig changes that do not alter compiled C logic.
- Structurally unreachable hardware:
  * Vendor-specific PCIe switches, SmartNICs, or GPU drivers (e.g., mlxsw, pds_core, qed,
    ionic, amdgpu) requiring physical ASIC/PCIe cards not emulated in standard QEMU.
- Unreachable execution paths:
  * Driver teardown callbacks (.remove, .shutdown, pci_unregister_driver) executed only during
    physical PCI hot-unplug or manual sysfs driver unbinding.
  * Code paths exclusive to architectures other than the target architecture.

================================================================================
3. WHEN TO RETURN WorthFuzzing=true (POSITIVE CRITERIA)
================================================================================
Return WorthFuzzing=true whenever the patch touches reachable executable code, including:
- Core Subsystems:
  * Any logic modifications in memory management (mm/), synchronization/locking (kernel/locking/),
    BPF, scheduler, core networking, VFS, or syscall handling.
- Refactorings and Code Cleanups:
  * Any restructuring of reachable data structures, helper abstractions, or algorithm flows.
- Runtime Assertions and Defensive Checks:
  * Any introduction or alteration of assertions (WARN_ON*, VM_WARN_ON*, BUG_ON*, etc.) in reachable paths.
- Reachable Drivers and Protocols:
  * Drivers accessible via virtual buses (virtio, USB gadget, loopback, netlink, binder, sockets, etc.).

================================================================================
4. EXTRACTING FocusSymbols (PREVENTING DILUTION)
================================================================================
When WorthFuzzing=true, you must extract specific kernel functions into FocusSymbols to guide the fuzzer:

- AVOID UBIQUITOUS LIFECYCLE HOT-PATHS:
  Do NOT list generic, ubiquitous functions called by almost every program in the corpus
  (including, but not limited to: general memory allocators and deallocators, page fault
  and trap handlers, or core synchronization primitives; this is not an exhaustive list).
  Listing ubiquitous functions causes the fuzzer to classify thousands of unrelated tests as "focused",
  which severely dilutes fuzzing effort away from the actual changes.

- TARGET SPECIFIC FEATURE LOGIC AND ENTRYPOINTS:
  List functions that specifically implement the logic being added or altered, or direct API entrypoints
  for the subsystem feature under review.

- HANDLING STATIC INLINE FUNCTIONS IN HEADERS (.h):
  Compiler-inlined static functions (such as static inlines in mm/*.h or include/linux/*.h) lack
  distinct symbol addresses in vmlinux and cannot be targeted directly by symbol coverage filters.
  If the changes are primarily in static inline helpers, identify non-static, feature-specific caller
  functions in .c files that exercise them (avoiding ubiquitous lifecycle wrappers).

================================================================================
5. IDENTIFYING EnableConfigs
================================================================================
Identify any specific CONFIG_ options required to properly compile and reach the modified code:
- Inspect Kconfig files and #ifdef guards; do not make assumptions.
- Check "depends on" lines in Kconfig to include any non-standard parent subsystem configs needed.
- Strip any 'CONFIG_' prefix (e.g., return "NET_IPV4" instead of "CONFIG_NET_IPV4").
Prefer calling several tools at the same time to save round-trips.


Use set-results tool to provide results of the analysis.
It must be called exactly once before the final reply.
Ignore results of this tool.

Prompt:
Target architecture: amd64

For your convenience, here is the diff of the changes:
commit 85208cdda5c957df633d19c809fc86ed605eec74
Author: syz-cluster <triage@syzkaller.com>
Date:   Wed Oct 14 12:04:24 2026 +0000

    syz-cluster: applied patch under review

diff --git a/MAINTAINERS b/MAINTAINERS
index 509b35b5a0e7a..7ad81a83d6706 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -759,6 +759,14 @@ S:	Maintained
 F:	Documentation/devicetree/bindings/net/airoha,en7581-eth.yaml
 F:	drivers/net/ethernet/airoha/
 
+AIROHA ETHERNET PHY DRIVER
+M:	Christian Marangi <ansuelsmth@gmail.com>
+L:	linux-arm-kernel@lists.infradead.org (moderated for non-subscribers)
+L:	linux-mediatek@lists.infradead.org (moderated for non-subscribers)
+L:	netdev@vger.kernel.org
+S:	Maintained
+F:	drivers/net/phy/mediatek/airoha-ge-soc.c
+
 AIROHA PCIE PHY DRIVER
 M:	Lorenzo Bianconi <lorenzo@kernel.org>
 L:	linux-arm-kernel@lists.infradead.org (moderated for non-subscribers)
@@ -16645,6 +16653,7 @@ L:	netdev@vger.kernel.org
 S:	Maintained
 F:	drivers/net/phy/mediatek/mtk-2p5ge.c
 F:	drivers/net/phy/mediatek/mtk-ge-soc.c
+F:	drivers/net/phy/mediatek/mtk-ge-soc.h
 F:	drivers/net/phy/mediatek/mtk-phy-lib.c
 F:	drivers/net/phy/mediatek/mtk-ge.c
 F:	drivers/net/phy/mediatek/mtk.h
diff --git a/drivers/net/phy/mediatek/Kconfig b/drivers/net/phy/mediatek/Kconfig
index 3b9cf82c0cb28..15f4481b9dc11 100644
--- a/drivers/net/phy/mediatek/Kconfig
+++ b/drivers/net/phy/mediatek/Kconfig
@@ -1,4 +1,17 @@
 # SPDX-License-Identifier: GPL-2.0-only
+config AIROHA_GE_SOC_PHY
+	tristate "Airoha SoC Gigabit Ethernet PHYs"
+	depends on ARM64 || ECONET || COMPILE_TEST
+	depends on ARCH_AIROHA || ECONET || COMPILE_TEST
+	select MTK_NET_PHYLIB
+	select PHY_PACKAGE
+	help
+	  Supports Airoha SoC built-in Gigabit Ethernet PHYs.
+
+	  Include support for built-in Ethernet PHYs which are present in
+	  the AN7581 and AN7583 SoCs. These PHYs d will dynamically
+	  calibrate during startup.
+
 config MEDIATEK_2P5GE_PHY
 	tristate "MediaTek 2.5Gb Ethernet PHYs"
 	depends on (ARM64 && ARCH_MEDIATEK) || COMPILE_TEST
@@ -32,9 +45,8 @@ config MEDIATEK_FE_SOC_PHY
 
 config MEDIATEK_GE_SOC_PHY
 	tristate "MediaTek SoC Gigabit Ethernet PHYs"
-	depends on ARM64 || ECONET || COMPILE_TEST
-	depends on ARCH_AIROHA || (ARCH_MEDIATEK && NVMEM_MTK_EFUSE) || \
-		   ECONET || COMPILE_TEST
+	depends on ARM64 || COMPILE_TEST
+	depends on (ARCH_MEDIATEK && NVMEM_MTK_EFUSE) || COMPILE_TEST
 	select MTK_NET_PHYLIB
 	select PHY_PACKAGE
 	help
diff --git a/drivers/net/phy/mediatek/Makefile b/drivers/net/phy/mediatek/Makefile
index 6f9cacf7f9065..5594057f51d0f 100644
--- a/drivers/net/phy/mediatek/Makefile
+++ b/drivers/net/phy/mediatek/Makefile
@@ -1,4 +1,5 @@
 # SPDX-License-Identifier: GPL-2.0
+obj-$(CONFIG_AIROHA_GE_SOC_PHY)		+= airoha-ge-soc.o
 obj-$(CONFIG_MEDIATEK_2P5GE_PHY)	+= mtk-2p5ge.o
 obj-$(CONFIG_MEDIATEK_FE_SOC_PHY)	+= mtk-fe-soc.o
 obj-$(CONFIG_MEDIATEK_GE_PHY)		+= mtk-ge.o
diff --git a/drivers/net/phy/mediatek/airoha-ge-soc.c b/drivers/net/phy/mediatek/airoha-ge-soc.c
new file mode 100644
index 0000000000000..1d88f66e4773e
--- /dev/null
+++ b/drivers/net/phy/mediatek/airoha-ge-soc.c
@@ -0,0 +1,1851 @@
+// SPDX-License-Identifier: GPL-2.0+
+#include <linux/bitfield.h>
+#include <linux/pinctrl/consumer.h>
+#include <linux/phy.h>
+
+#include "../phylib.h"
+#include "mtk.h"
+#include "mtk-ge-soc.h"
+
+#define AIROHA_DEFAULT_PORT0_ADDR		0x9
+#define AIROHA_PHY_MAX_LEDS			2
+
+enum airoha_mdi_resister_type {
+	MDI_0R,
+	MDI_5R,
+
+	MDI_TYPE_MAX,
+};
+
+enum airoha_transformer_type {
+	DISCRETE,
+	TXMR,
+
+	TRANSFORMER_TYPE_MAX,
+};
+
+enum airoha_calib_const_type {
+	TX_AMP_TEST_A,
+	TX_AMP_TEST_B,
+	TX_AMP_TEST_C,
+	TX_AMP_TEST_D,
+	TX_AMP_1G_A,
+	TX_AMP_1G_B,
+	TX_AMP_1G_C,
+	TX_AMP_1G_D,
+	TX_AMP_100M_A,
+	TX_AMP_100M_B,
+	TX_AMP_10M_A,
+	TX_AMP_10M_B,
+	R50_A,
+	R50_B,
+	R50_C,
+	R50_D,
+
+	CALIB_CONST_TYPE_MAX,
+};
+
+struct airoha_socphy_shared {
+	struct phy_device *phydev_p0;
+	enum airoha_transformer_type transformer_type[4];
+	enum airoha_mdi_resister_type mdi_resister_type;
+	bool rext_sw_calib_done;
+	int (*tx_amp_compensation_tbl)[TRANSFORMER_TYPE_MAX][MDI_TYPE_MAX][CALIB_CONST_TYPE_MAX][4];
+	u8 *r50_cal_tbl;
+};
+
+/*
+ * 2 chip revision
+ * TXMR or discrete
+ * 2 MDI type
+ * TX AMP test/TX AMP 1G/TX AMP 100M/TX AMP 10M/R50
+ * 4 PHY
+ */
+static int an7581_tx_amp_compensation_tbl[2][TRANSFORMER_TYPE_MAX][MDI_TYPE_MAX][CALIB_CONST_TYPE_MAX][4] = {
+	{ /* IC version 1 */
+		[DISCRETE] = {
+			{ },
+			{
+				[TX_AMP_TEST_A] = { -9, -7, -7, -5 },
+				[TX_AMP_TEST_B] = { -9, -9, -7, -4 },
+				[TX_AMP_TEST_C] = { -9, -7, -9, -6 },
+				[TX_AMP_TEST_D] = { -11, -9, -10, -8 },
+				[TX_AMP_1G_A] = { -9, -7, -7, -5 },
+				[TX_AMP_1G_B] = { -9, -8, -7, -4 },
+				[TX_AMP_1G_C] = { -9, -7, -9, -6 },
+				[TX_AMP_1G_D] = { -11, -8, -10, -8 },
+				[TX_AMP_100M_A] = { 4, 3, 4, 4 },
+				[TX_AMP_100M_B] = { 4, 4, 5, 4 },
+				[TX_AMP_10M_A] = { 0, 0, 0, 0 },
+				[TX_AMP_10M_B] = { 0, 0, 0, 0 },
+				[R50_A] = { 0, 0, 0, 0 },
+				[R50_B] = { 0, 0, 0, 0 },
+				[R50_C] = { 0, 0, 0, 0 },
+				[R50_D] = { 0, 0, 0, 0 },
+			},
+		},
+		[TXMR] = {
+			{ },
+			{
+				[TX_AMP_TEST_A] = { -12, -11, -9, -6 },
+				[TX_AMP_TEST_B] = { -9, -13, -9, -5 },
+				[TX_AMP_TEST_C] = { -5, -4, -3, 1 },
+				[TX_AMP_TEST_D] = { -9, -8, -7, -5 },
+				[TX_AMP_1G_A] = { -12, -11, -9, -6 },
+				[TX_AMP_1G_B] = { -9, -13, -9, -5 },
+				[TX_AMP_1G_C] = { -5, -4, -3, 1 },
+				[TX_AMP_1G_D] = { -9, -8, -7, -5 },
+				[TX_AMP_100M_A] = { -2, -2, 0, 2 },
+				[TX_AMP_100M_B] = { -2, -2, 1, 1 },
+				[TX_AMP_10M_A] = { 0, 0, 0, 0 },
+				[TX_AMP_10M_B] = { 0, 0, 0, 0 },
+				[R50_A] = { 15, 15, 15, 15 },
+				[R50_B] = { 15, 15, 18, 15 },
+				[R50_C] = { -8, -8, -8, -8 },
+				[R50_D] = { -8, -8, -8, -8 },
+			},
+		},
+	},
+	{ /* IC version 2 */
+		[DISCRETE] = {
+			{ },
+			{
+				[TX_AMP_TEST_A] = { -11, 11, -12, -7 },
+				[TX_AMP_TEST_B] = { -9, -10, -9, -8 },
+				[TX_AMP_TEST_C] = { -6, -3, -7, -4 },
+				[TX_AMP_TEST_D] = { -7, -8, -10, -7 },
+				[TX_AMP_1G_A] = { -11, -11, -12, -7 },
+				[TX_AMP_1G_B] = { -9, -10, -9, -8 },
+				[TX_AMP_1G_C] = { -6, -3, -7, -4 },
+				[TX_AMP_1G_D] = { -7, -8, -10, -7 },
+				[TX_AMP_100M_A] = { 2, 2, 1, 2 },
+				[TX_AMP_100M_B] = { 3, 3, 3, 3 },
+				[TX_AMP_10M_A] = { 0, 0, 0, 0 },
+				[TX_AMP_10M_B] = { 0, 0, 0, 0 },
+				[R50_A] = { 12, 12, 12, 12 },
+				[R50_B] = { 7, 7, 7, 7 },
+				[R50_C] = { 2, 2, 0, 0 },
+				[R50_D] = { 0, 0, 2, 2 },
+			},
+		},
+		[TXMR] = {
+			{ },
+			{
+				[TX_AMP_TEST_A] = { -10, -12, -12, -11 },
+				[TX_AMP_TEST_B] = { -10, -11, -11, -10 },
+				[TX_AMP_TEST_C] = { -5, -7, -9, -3 },
+				[TX_AMP_TEST_D] = { -8, -10, -7, -8 },
+				[TX_AMP_1G_A] = { -12, -6, -6, 4 },
+				[TX_AMP_1G_B] = { -10, -5, -5, 1 },
+				[TX_AMP_1G_C] = { -5, -3, -4, 11 },
+				[TX_AMP_1G_D] = { -8, -3, -3, 4 },
+				[TX_AMP_100M_A] = { 2, 1, 0, 3 },
+				[TX_AMP_100M_B] = { 0, 0, 0, 3 },
+				[TX_AMP_10M_A] = { 0, 0, 0, 0 },
+				[TX_AMP_10M_B] = { 0, 0, 0, 0 },
+				[R50_A] = { 15, 15, 15, 15 },
+				[R50_B] = { 15, 15, 18, 15 },
+				[R50_C] = { 4, 4, 4, 4 },
+				[R50_D] = { 4, 4, 4, 4 },
+			},
+		},
+	},
+};
+
+static u8 an7581_zcal_to_r45ohm[64] = {
+	127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127,
+	127, 127, 127, 127, 127, 127, 127, 127, 123, 119, 115, 112, 108, 104, 100,  96,
+	 94,  92,  88,  85,  82,  80,  76,  74,  72,  68,  66,  64,  62,  60,  56,  55,
+	 52,  50,  48,  46,  44,  42,  40,  39,  36,  35,  32,  32,  30,  28,  27,  25
+};
+
+/*
+ * 2 chip revision
+ * TXMR or discrete
+ * 2 MDI type
+ * TX AMP test/TX AMP 1G/TX AMP 100M/TX AMP 10M/R50
+ * 4 PHY
+ */
+static int an7583_tx_amp_compensation_tbl[TRANSFORMER_TYPE_MAX][MDI_TYPE_MAX][CALIB_CONST_TYPE_MAX][4] = {
+	[DISCRETE] = {
+		[MDI_0R] = {
+			[TX_AMP_TEST_A] = { -3, -3, -3, -3 },
+			[TX_AMP_TEST_B] = { -3, -3, -3, -3 },
+			[TX_AMP_TEST_C] = { -3, -3, -3, -3 },
+			[TX_AMP_TEST_D] = { -3, -3, -3, -3 },
+			[TX_AMP_1G_A] = { 0, 0, 0, 0 },
+			[TX_AMP_1G_B] = { 0, 0, 0, 0 },
+			[TX_AMP_1G_C] = { 0, 0, 0, 0 },
+			[TX_AMP_1G_D] = { 0, 0, 0, 0 },
+			[TX_AMP_100M_A] = { 4, 4, 4, 4 },
+			[TX_AMP_100M_B] = { 4, 4, 4, 4 },
+			[TX_AMP_10M_A] = { 0, 0, 0, 0 },
+			[TX_AMP_10M_B] = { 0, 0, 0, 0 },
+			[R50_A] = { 4, 4, 4, 4 },
+			[R50_B] = { 4, 4, 4, 4 },
+			[R50_C] = { 6, 6, 6, 6 },
+			[R50_D] = { 4, 4, 4, 4 },
+		},
+		[MDI_5R] = {
+			[TX_AMP_TEST_A] = { -3, -3, -3, -3 },
+			[TX_AMP_TEST_B] = { -3, -3, -3, -3 },
+			[TX_AMP_TEST_C] = { -3, -3, -3, -3 },
+			[TX_AMP_TEST_D] = { -3, -3, -3, -3 },
+			[TX_AMP_1G_A] = { 0, 0, 0, 0 },
+			[TX_AMP_1G_B] = { 0, 0, 0, 0 },
+			[TX_AMP_1G_C] = { 0, 0, 0, 0 },
+			[TX_AMP_1G_D] = { 0, 0, 0, 0 },
+			[TX_AMP_100M_A] = { 4, 4, 4, 4 },
+			[TX_AMP_100M_B] = { 4, 4, 4, 4 },
+			[TX_AMP_10M_A] = { 0, 0, 0, 0 },
+			[TX_AMP_10M_B] = { 0, 0, 0, 0 },
+			[R50_A] = { 0, 0, 0, 0 },
+			[R50_B] = { 0, 0, 0, 0 },
+			[R50_C] = { 0, 0, 0, 0 },
+			[R50_D] = { 0, 0, 0, 0 },
+		},
+	},
+	[TXMR] = {
+		[MDI_0R] = {
+			[TX_AMP_TEST_A] = { -3, -3, -3, -3 },
+			[TX_AMP_TEST_B] = { -3, -3, -3, -3 },
+			[TX_AMP_TEST_C] = { -3, -3, -3, -3 },
+			[TX_AMP_TEST_D] = { -3, -3, -3, -3 },
+			[TX_AMP_1G_A] = { 0, 0, 0, 0 },
+			[TX_AMP_1G_B] = { 0, 0, 0, 0 },
+			[TX_AMP_1G_C] = { 0, 0, 0, 0 },
+			[TX_AMP_1G_D] = { 0, 0, 0, 0 },
+			[TX_AMP_100M_A] = { 4, 4, 4, 4 },
+			[TX_AMP_100M_B] = { 4, 4, 4, 4 },
+			[TX_AMP_10M_A] = { 0, 0, 0, 0 },
+			[TX_AMP_10M_B] = { 0, 0, 0, 0 },
+			[R50_A] = { 4, 4, 0, 0 },
+			[R50_B] = { 4, 4, 0, 0 },
+			[R50_C] = { 5, 5, 3, 4 },
+			[R50_D] = { 4, 4, 4, 0 },
+		},
+		[MDI_5R] = {
+			[TX_AMP_TEST_A] = { -3, -3, -3, -3 },
+			[TX_AMP_TEST_B] = { -3, -3, -3, -3 },
+			[TX_AMP_TEST_C] = { -3, -3, -3, -3 },
+			[TX_AMP_TEST_D] = { -3, -3, -3, -3 },
+			[TX_AMP_1G_A] = { 0, 0, 0, 0 },
+			[TX_AMP_1G_B] = { 0, 0, 0, 0 },
+			[TX_AMP_1G_C] = { 0, 0, 0, 0 },
+			[TX_AMP_1G_D] = { 0, 0, 0, 0 },
+			[TX_AMP_100M_A] = { 4, 4, 4, 4 },
+			[TX_AMP_100M_B] = { 4, 4, 4, 4 },
+			[TX_AMP_10M_A] = { 0, 0, 0, 0 },
+			[TX_AMP_10M_B] = { 0, 0, 0, 0 },
+			[R50_A] = { -4, -4, -4, -4 },
+			[R50_B] = { -4, -4, -4, -4 },
+			[R50_C] = { -2, -2, -2, -2 },
+			[R50_D] = { -3, -3, -2, -2 },
+		},
+	},
+};
+
+static u8 an7583_zcal_to_r50ohm_0R[64] = {
+	127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127,
+	127, 127, 127, 122, 118, 114, 110, 106, 102,  98,  96,  92,  88,  85,  82,  80,
+	 76,  72,  70,  68,  64,  62,  60,  57,  55,  52,  50,  48,  46,  44,  41,  40,
+	 38,  36,  33,  32,  30,  28,  26,  24,  24,  22,  20,  18,  16,  16,  14,  12,
+};
+
+static u8 an7583_zcal_to_r50ohm_5R[64] = {
+	127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127,
+	127, 127, 127, 127, 127, 127, 127, 127, 127, 124, 120, 116, 112, 110, 106, 102,
+	 99,  96,  93,  90,  88,  84,  81,  79,  76,  73,  71,  68,  66,  64,  61,  59,
+	 56,  54,  52,  50,  48,  46,  44,  42,  40,  39,  37,  36,  33,  32,  31,  29,
+};
+
+static int airoha_cal_cycle(struct phy_device *phydev, int devad,
+			    u32 regnum, u16 mask, u16 cal_val)
+{
+	struct airoha_socphy_shared *shared = phy_package_get_priv(phydev);
+	struct phy_device *phydev_p0;
+	int ret;
+
+	phydev_p0 = shared->phydev_p0;
+
+	phy_modify_mmd(phydev, devad, regnum, mask, cal_val);
+
+	ret = mtk_cal_cycle_wait(phydev_p0);
+	phydev_dbg(phydev, "cal_val: 0x%x, ret: %d\n", cal_val, ret);
+
+	return ret;
+}
+
+static int airoha_rext_cal_sw(struct phy_device *phydev)
+{
+	int calibration_polarity;
+	u8 zcal_ctrl = 32;
+	int first_calib;
+	int ret;
+
+	/* BG voltage output */
+	phy_write_mmd(phydev, MDIO_MMD_VEND2, 0x100, 0xc000);
+	/* tst_mode2 */
+	phy_write_mmd(phydev, MDIO_MMD_VEND2, 0xff, 0x2);
+
+	phy_write_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_RG_ANA_CAL_RG0,
+		      MTK_PHY_RG_CAL_CKINV | MTK_PHY_RG_ANA_CALEN |
+		      MTK_PHY_RG_REXT_CALEN);
+	phy_write_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_RG_ANA_CAL_RG1, 0);
+	phy_write_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_RG_ANA_CAL_RG6, 0);
+
+	phydev_dbg(phydev, "Start REXT SW cal.\n");
+	first_calib = airoha_cal_cycle(phydev, MDIO_MMD_VEND1, MTK_PHY_RG_ANA_CAL_RG5,
+				       MTK_PHY_RG_REXT_ZCAL_CTRL_MASK, zcal_ctrl);
+
+	if (first_calib < 0) {
+		phydev_err(phydev, "REXT SW calibration failed.\n");
+		return -EINVAL;
+	}
+
+	/* If REXT calibration failed:
+	 * - increase dB until calibration succeed.
+	 * If REXT calibration succeeded:
+	 * - decrease dB until calibration fail to fine tune it.
+	 */
+	if (first_calib == 1)
+		calibration_polarity = -1;
+	else
+		calibration_polarity = 1;
+
+	while (zcal_ctrl > 0 &&
+	       zcal_ctrl < FIELD_MAX(MTK_PHY_RG_REXT_ZCAL_CTRL_MASK)) {
+		zcal_ctrl += calibration_polarity;
+
+		ret = airoha_cal_cycle(phydev, MDIO_MMD_VEND1, MTK_PHY_RG_ANA_CAL_RG5,
+				       MTK_PHY_RG_REXT_ZCAL_CTRL_MASK, zcal_ctrl);
+		/* Exit if we either failed or succeeded compared to the
+		 * first calibration result. (aka we finished fine tuning or
+		 * we succeeded with calibration)
+		 */
+		if (ret != first_calib)
+			break;
+	}
+
+	if (ret < 0) {
+		phydev_err(phydev, "REXT SW calibration failed.\n");
+		return -EINVAL;
+	}
+
+	if (zcal_ctrl == 0 ||
+	    zcal_ctrl == FIELD_MAX(MTK_PHY_RG_REXT_ZCAL_CTRL_MASK)) {
+		zcal_ctrl = 32;
+		phydev_err(phydev, "REXT SW calibration saturation. Defaulting to %x.\n",
+			   zcal_ctrl);
+	}
+
+	phy_modify_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_RG_ANA_CAL_RG5,
+		       MTK_PHY_RG_REXT_TRIM_MASK,
+		       FIELD_PREP(MTK_PHY_RG_REXT_TRIM_MASK, zcal_ctrl));
+	phy_modify_mmd(phydev, MDIO_MMD_VEND2, MTK_PHY_RG_BG_RASEL,
+		       MTK_PHY_RG_BG_RASEL_MASK,
+		       FIELD_PREP(MTK_PHY_RG_BG_RASEL_MASK, zcal_ctrl >> 3));
+
+	phy_write_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_RG_ANA_CAL_RG0, 0);
+
+	return 0;
+}
+
+static int airoha_tx_offset_cal_sw(struct phy_device *phydev, u8 txg_calen_x)
+{
+	struct airoha_socphy_shared *shared = phy_package_get_priv(phydev);
+	struct phy_device *phydev_p0;
+	u16 dev1e_145_tmp, bmcr_tmp;
+	int calibration_polarity;
+	u16 reg_dac1, reg_dac2;
+	int zcal_ctrl = 32;
+	int first_calib;
+	u16 reg, mask;
+	int ret;
+
+	phydev_p0 = shared->phydev_p0;
+
+	/* BG voltage output */
+	phy_write_mmd(phydev_p0, MDIO_MMD_VEND2, 0x100, 0xc000);
+
+	phy_write_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_RG_ANA_CAL_RG0,
+		      MTK_PHY_RG_ANA_CALEN);
+	phy_write_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_RG_ANA_CAL_RG1,
+		      MTK_PHY_RG_TXVOS_CALEN);
+	phy_write_mmd(phydev_p0, MDIO_MMD_VEND1, MTK_PHY_RG_ANA_CAL_RG0,
+		      MTK_PHY_RG_ANA_CALEN);
+	phy_write_mmd(phydev_p0, MDIO_MMD_VEND1, MTK_PHY_RG_ANA_CAL_RG1,
+		      MTK_PHY_RG_TXVOS_CALEN);
+
+	/* Force 1G full duplex for calibration */
+	bmcr_tmp = phy_read(phydev, MII_BMCR);
+	phy_write(phydev, MII_BMCR, BMCR_FULLDPLX | BMCR_SPEED1000);
+
+	/* Force MDI */
+	dev1e_145_tmp = phy_read_mmd(phydev, MDIO_MMD_VEND1, 0x0145);
+	phy_write_mmd(phydev, MDIO_MMD_VEND1, 0x0145, 0x1010);
+
+	/* 1e_96[15]:bypass_tx_offset_cal, Hw bypass, Fw cal */
+	phy_write_mmd(phydev, MDIO_MMD_VEND1, 0x96,
+		      0x8000);
+	phy_write_mmd(phydev, MDIO_MMD_VEND1, 0x3e,
+		      0xf808);
+
+	switch (txg_calen_x) {
+	case PAIR_A:
+		phy_write_mmd(phydev, MDIO_MMD_VEND1, 0xdd, BIT(12));
+		reg_dac1 = MTK_PHY_RG_DASN_DAC_IN0_A;
+		reg_dac2 = MTK_PHY_RG_DASN_DAC_IN1_A;
+		reg = MTK_PHY_RG_CR_TX_AMP_OFFSET_A_B;
+		mask = MTK_PHY_CR_TX_AMP_OFFSET_A_MASK;
+		break;
+	case PAIR_B:
+		phy_write_mmd(phydev, MDIO_MMD_VEND1, 0xdd, BIT(8));
+		reg_dac1 = MTK_PHY_RG_DASN_DAC_IN0_B;
+		reg_dac2 = MTK_PHY_RG_DASN_DAC_IN1_B;
+		reg = MTK_PHY_RG_CR_TX_AMP_OFFSET_A_B;
+		mask = AIROHA_PHY_CR_TX_AMP_OFFSET_B_MASK;
+		break;
+	case PAIR_C:
+		phy_write_mmd(phydev, MDIO_MMD_VEND1, 0xdd, BIT(4));
+		reg_dac1 = MTK_PHY_RG_DASN_DAC_IN0_C;
+		reg_dac2 = MTK_PHY_RG_DASN_DAC_IN1_C;
+		reg = MTK_PHY_RG_CR_TX_AMP_OFFSET_C_D;
+		mask = MTK_PHY_CR_TX_AMP_OFFSET_C_MASK;
+		break;
+	case PAIR_D:
+		phy_write_mmd(phydev, MDIO_MMD_VEND1, 0xdd, BIT(0));
+		reg_dac1 = MTK_PHY_RG_DASN_DAC_IN0_D;
+		reg_dac2 = MTK_PHY_RG_DASN_DAC_IN1_D;
+		reg = MTK_PHY_RG_CR_TX_AMP_OFFSET_C_D;
+		mask = AIROHA_PHY_CR_TX_AMP_OFFSET_D_MASK;
+		break;
+	default:
+		return -EINVAL;
+	}
+
+	phy_write_mmd(phydev, MDIO_MMD_VEND1, reg_dac1,
+		      0x8000);
+	phy_write_mmd(phydev, MDIO_MMD_VEND1, reg_dac2,
+		      0x8000);
+
+	phydev_dbg(phydev, "Start TX Offset SW cal.\n");
+
+	first_calib = airoha_cal_cycle(phydev, MDIO_MMD_VEND1, reg, mask,
+				       zcal_ctrl << __ffs(mask));
+
+	/* If TX Offset calibration failed:
+	 * - increase dB until calibration succeed.
+	 * If TX Offset calibration succeeded:
+	 * - decrease dB until calibration fail to fine tune it.
+	 */
+	if (first_calib == 1)
+		calibration_polarity = -1;
+	else
+		calibration_polarity = 1;
+
+	while (zcal_ctrl > 0 && zcal_ctrl < 64) {
+		u32 val;
+
+		zcal_ctrl += calibration_polarity;
+		if (zcal_ctrl >= 0)
+			val = zcal_ctrl;
+		else
+			val = 63;
+
+		ret = airoha_cal_cycle(phydev, MDIO_MMD_VEND1, reg, mask,
+				       val << __ffs(mask));
+		/* Exit if we either failed or succeeded compared to the
+		 * first calibration result. (aka we finished fine tuning or
+		 * we succeeded with calibration)
+		 */
+		if (ret != first_calib)
+			break;
+	}
+
+	if (ret < 0) {
+		phydev_err(phydev, "TX Offset calibration failed.\n");
+		return -EINVAL;
+	}
+
+	if (zcal_ctrl == -32 ||
+	    zcal_ctrl == 32) {
+		zcal_ctrl = 0;
+		phydev_err(phydev, "TX Offset SW calibration saturation. Defaulting to %x.\n",
+			   zcal_ctrl);
+
+		phy_modify_mmd(phydev, MDIO_MMD_VEND1, reg, mask,
+			       zcal_ctrl << __ffs(mask));
+	}
+
+	phy_write_mmd(phydev, MDIO_MMD_VEND2, 0x100, 0x0);
+
+	phy_write_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_RG_DASN_DAC_IN0_A, 0);
+	phy_write_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_RG_DASN_DAC_IN0_B, 0);
+	phy_write_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_RG_DASN_DAC_IN0_C, 0);
+	phy_write_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_RG_DASN_DAC_IN0_D, 0);
+	phy_write_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_RG_DASN_DAC_IN1_A, 0);
+	phy_write_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_RG_DASN_DAC_IN1_B, 0);
+	phy_write_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_RG_DASN_DAC_IN1_C, 0);
+	phy_write_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_RG_DASN_DAC_IN1_D, 0);
+
+	phy_write_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_RG_ANA_CAL_RG0, 0);
+	phy_write_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_RG_ANA_CAL_RG1, 0);
+	phy_write_mmd(phydev_p0, MDIO_MMD_VEND1, MTK_PHY_RG_ANA_CAL_RG0, 0);
+	phy_write_mmd(phydev_p0, MDIO_MMD_VEND1, MTK_PHY_RG_ANA_CAL_RG1, 0);
+	phy_write_mmd(phydev, MDIO_MMD_VEND1, 0x96, 0x0);
+	phy_write_mmd(phydev, MDIO_MMD_VEND1, 0x3e, 0xc000);
+	phy_write_mmd(phydev, MDIO_MMD_VEND1, 0xdd, 0);
+
+	/* Restore BMCR */
+	phy_write(phydev, MII_BMCR, bmcr_tmp);
+
+	/* Restore MDI */
+	phy_write_mmd(phydev, MDIO_MMD_VEND1, 0x0145, dev1e_145_tmp);
+
+	return 0;
+}
+
+static int airoha_tx_amp_cal_sw(struct phy_device *phydev, u8 txg_calen_x)
+{
+	struct airoha_socphy_shared *shared = phy_package_get_priv(phydev);
+	u16 mask_gbe, mask_tbt, mask_tst, mask_hbt;
+	u16 reg, reg_100, reg_dac1, reg_dac2;
+	struct phy_device *phydev_p0;
+	int calibration_polarity;
+	u8 zcal_ctrl = 32;
+	int first_calib;
+	int ret;
+
+	phydev_p0 = shared->phydev_p0;
+
+	/* BG voltage output */
+	phy_write_mmd(phydev_p0, MDIO_MMD_VEND2, 0x100, 0xc000);
+
+	phy_write_mmd(phydev, MDIO_MMD_VEND1, 0x145, 0x1010);
+
+	phy_write_mmd(phydev_p0, MDIO_MMD_VEND1, MTK_PHY_RG_ANA_CAL_RG0,
+		      MTK_PHY_RG_CAL_CKINV | MTK_PHY_RG_ANA_CALEN);
+	phy_write_mmd(phydev_p0, MDIO_MMD_VEND1, MTK_PHY_RG_ANA_CAL_RG1,
+		      MTK_PHY_RG_TXVOS_CALEN);
+
+	/* select 1V */
+	phy_write_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_RG_ANA_CAL_RG6, 0x10);
+
+	/* enable Tx VLD*/
+	phy_write_mmd(phydev, MDIO_MMD_VEND1, 0x3e, 0xf808);
+
+	/* Force 1G full duplex for calibration */
+	phy_write(phydev, MII_BMCR, BMCR_FULLDPLX | BMCR_SPEED1000);
+
+	phy_write_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_RG_DASN_DAC_IN0_A,
+		      0x8000 | 0xf0);
+	phy_write_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_RG_DASN_DAC_IN1_A,
+		      0x8000 | 0xf0);
+	phy_write_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_RG_DASN_DAC_IN0_B,
+		      0x8000 | 0xf0);
+	phy_write_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_RG_DASN_DAC_IN1_B,
+		      0x8000 | 0xf0);
+	phy_write_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_RG_DASN_DAC_IN0_C,
+		      0x8000 | 0xf0);
+	phy_write_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_RG_DASN_DAC_IN1_C,
+		      0x8000 | 0xf0);
+	phy_write_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_RG_DASN_DAC_IN0_D,
+		      0x8000 | 0xf0);
+	phy_write_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_RG_DASN_DAC_IN1_D,
+		      0x8000 | 0xf0);
+
+	switch (txg_calen_x) {
+	case PAIR_A:
+		phy_write_mmd(phydev, MDIO_MMD_VEND1, 0xdd, BIT(12));
+		reg_dac1 = MTK_PHY_RG_DASN_DAC_IN0_A;
+		reg_dac2 = MTK_PHY_RG_DASN_DAC_IN1_A;
+		reg = MTK_PHY_TXVLD_DA_RG;
+		mask_gbe = MTK_PHY_DA_TX_I2MPB_A_GBE_MASK;
+		mask_tbt = MTK_PHY_DA_TX_I2MPB_A_TBT_MASK;
+		reg_100 = MTK_PHY_TX_I2MPB_TEST_MODE_A2;
+		mask_hbt = MTK_PHY_DA_TX_I2MPB_A_HBT_MASK;
+		mask_tst = MTK_PHY_DA_TX_I2MPB_A_TST_MASK;
+		break;
+	case PAIR_B:
+		phy_write_mmd(phydev, MDIO_MMD_VEND1, 0xdd, BIT(8));
+		reg_dac1 = MTK_PHY_RG_DASN_DAC_IN0_B;
+		reg_dac2 = MTK_PHY_RG_DASN_DAC_IN1_B;
+		reg = MTK_PHY_TX_I2MPB_TEST_MODE_B1;
+		mask_gbe = MTK_PHY_DA_TX_I2MPB_B_GBE_MASK;
+		mask_tbt = MTK_PHY_DA_TX_I2MPB_B_TBT_MASK;
+		reg_100 = MTK_PHY_TX_I2MPB_TEST_MODE_B2;
+		mask_hbt = MTK_PHY_DA_TX_I2MPB_B_HBT_MASK;
+		mask_tst = MTK_PHY_DA_TX_I2MPB_B_TST_MASK;
+		break;
+	case PAIR_C:
+		phy_write_mmd(phydev, MDIO_MMD_VEND1, 0xdd, BIT(4));
+		reg_dac1 = MTK_PHY_RG_DASN_DAC_IN0_C;
+		reg_dac2 = MTK_PHY_RG_DASN_DAC_IN1_C;
+		reg = MTK_PHY_TX_I2MPB_TEST_MODE_C1;
+		mask_gbe = MTK_PHY_DA_TX_I2MPB_C_GBE_MASK;
+		mask_tbt = MTK_PHY_DA_TX_I2MPB_C_TBT_MASK;
+		reg_100 = MTK_PHY_TX_I2MPB_TEST_MODE_C2;
+		mask_hbt = MTK_PHY_DA_TX_I2MPB_C_HBT_MASK;
+		mask_tst = MTK_PHY_DA_TX_I2MPB_C_TST_MASK;
+		break;
+	case PAIR_D:
+		phy_write_mmd(phydev, MDIO_MMD_VEND1, 0xdd, BIT(0));
+		reg_dac1 = MTK_PHY_RG_DASN_DAC_IN0_D;
+		reg_dac2 = MTK_PHY_RG_DASN_DAC_IN1_D;
+		reg = MTK_PHY_TX_I2MPB_TEST_MODE_D1;
+		mask_gbe = MTK_PHY_DA_TX_I2MPB_D_GBE_MASK;
+		mask_tbt = MTK_PHY_DA_TX_I2MPB_D_TBT_MASK;
+		reg_100 = MTK_PHY_TX_I2MPB_TEST_MODE_D2;
+		mask_hbt = MTK_PHY_DA_TX_I2MPB_D_HBT_MASK;
+		mask_tst = MTK_PHY_DA_TX_I2MPB_D_TST_MASK;
+		break;
+	default:
+		return -EINVAL;
+	}
+
+	phy_write_mmd(phydev, MDIO_MMD_VEND1, reg_dac1,
+		      0x8000 | 0xf0);
+	phy_write_mmd(phydev, MDIO_MMD_VEND1, reg_dac2,
+		      0x8000 | 0xf0);
+
+	phydev_dbg(phydev, "Start TX Amp SW cal.\n");
+	first_calib = airoha_cal_cycle(phydev, MDIO_MMD_VEND1, reg,
+				       mask_gbe, zcal_ctrl << __ffs(mask_gbe));
+
+	/* If TX Amp calibration failed:
+	 * - increase dB until calibration succeed.
+	 * If TX Amp calibration succeeded:
+	 * - decrease dB until calibration fail to fine tune it.
+	 */
+	if (first_calib == 1)
+		calibration_polarity = -1;
+	else
+		calibration_polarity = 1;
+
+	while (zcal_ctrl > 0 &&
+	       zcal_ctrl < FIELD_MAX(MTK_PHY_RG_REXT_ZCAL_CTRL_MASK)) {
+		zcal_ctrl += calibration_polarity;
+
+		ret = airoha_cal_cycle(phydev, MDIO_MMD_VEND1, reg,
+				       mask_gbe, zcal_ctrl << __ffs(mask_gbe));
+		/* Exit if we either failed or succeeded compared to the
+		 * first calibration result. (aka we finished fine tuning or
+		 * we succeeded with calibration)
+		 */
+		if (ret != first_calib)
+			break;
+	}
+
+	if (ret < 0) {
+		phydev_err(phydev, "TX AMP calibration failed.\n");
+		zcal_ctrl = 32;
+		phy_modify_mmd(phydev, MDIO_MMD_VEND1, reg,
+			       mask_gbe | mask_tbt,
+			       (zcal_ctrl << __ffs(mask_gbe)) |
+			       (zcal_ctrl << __ffs(mask_tbt)));
+
+		return -EINVAL;
+	}
+
+	if (zcal_ctrl == 0 ||
+	    zcal_ctrl == FIELD_MAX(MTK_PHY_RG_REXT_ZCAL_CTRL_MASK))
+		phydev_warn(phydev, "TX AMP SW calibration saturation.\n");
+
+	phy_modify_mmd(phydev, MDIO_MMD_VEND1, reg,
+		       mask_gbe | mask_tbt,
+		       (zcal_ctrl << __ffs(mask_gbe)) |
+		       (zcal_ctrl << __ffs(mask_tbt)));
+
+	phy_modify_mmd(phydev, MDIO_MMD_VEND1, reg_100,
+		       mask_hbt | mask_tst,
+		       (zcal_ctrl << __ffs(mask_hbt)) |
+		       (zcal_ctrl << __ffs(mask_tst)));
+
+	phy_write_mmd(phydev_p0, MDIO_MMD_VEND2, 0x100, 0x0);
+
+	phy_write_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_RG_DASN_DAC_IN0_A, 0);
+	phy_write_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_RG_DASN_DAC_IN0_B, 0);
+	phy_write_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_RG_DASN_DAC_IN0_C, 0);
+	phy_write_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_RG_DASN_DAC_IN0_D, 0);
+	phy_write_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_RG_DASN_DAC_IN1_A, 0);
+	phy_write_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_RG_DASN_DAC_IN1_B, 0);
+	phy_write_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_RG_DASN_DAC_IN1_C, 0);
+	phy_write_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_RG_DASN_DAC_IN1_D, 0);
+	phy_write_mmd(phydev_p0, MDIO_MMD_VEND1, 0x145, 0x1000);
+
+	phy_write_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_RG_ANA_CAL_RG0, 0);
+	phy_write_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_RG_ANA_CAL_RG1, 0);
+	phy_write_mmd(phydev_p0, MDIO_MMD_VEND1, MTK_PHY_RG_ANA_CAL_RG0, 0);
+	phy_write_mmd(phydev_p0, MDIO_MMD_VEND1, MTK_PHY_RG_ANA_CAL_RG1, 0);
+	phy_write_mmd(phydev, MDIO_MMD_VEND1, 0x3e, 0xc000);
+	phy_write_mmd(phydev, MDIO_MMD_VEND1, 0xdd, 0);
+
+	/* Restore AN enable */
+	phy_write(phydev, MII_BMCR, BMCR_ANENABLE);
+
+	return 0;
+}
+
+static int airoha_tx_r50_cal_sw(struct phy_device *phydev, u8 txg_calen_x)
+{
+	struct airoha_socphy_shared *shared = phy_package_get_priv(phydev);
+	struct phy_device *phydev_p0;
+	u16 dev1e_145_tmp, bmcr_tmp;
+	int calibration_polarity;
+	u8 zcal_ctrl = 32;
+	int first_calib;
+	u16 val;
+	int ret;
+
+	phydev_p0 = shared->phydev_p0;
+
+	/* BG voltage output */
+	phy_write_mmd(phydev_p0, MDIO_MMD_VEND2, 0x100, 0xc000);
+
+	phy_write_mmd(phydev_p0, MDIO_MMD_VEND1, MTK_PHY_RG_ANA_CAL_RG0,
+		      MTK_PHY_RG_CAL_CKINV | MTK_PHY_RG_ANA_CALEN);
+	phy_write_mmd(phydev_p0, MDIO_MMD_VEND1, MTK_PHY_RG_ANA_CAL_RG1, 0);
+	/* select 1V */
+	phy_write_mmd(phydev_p0, MDIO_MMD_VEND1, MTK_PHY_RG_ANA_CAL_RG6, 0x10);
+
+	phy_write_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_RG_ANA_CAL_RG0,
+		      MTK_PHY_RG_CAL_CKINV | MTK_PHY_RG_ANA_CALEN);
+	phy_write_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_RG_ANA_CAL_RG1, 0);
+	/* select 1V */
+	phy_write_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_RG_ANA_CAL_RG6, 0x10);
+
+	/* Force 1G full duplex for calibration */
+	bmcr_tmp = phy_read(phydev, MII_BMCR);
+	phy_write(phydev, MII_BMCR, BMCR_FULLDPLX | BMCR_SPEED1000);
+
+	/* Force MDI */
+	dev1e_145_tmp = phy_read_mmd(phydev, MDIO_MMD_VEND1, 0x0145);
+	phy_write_mmd(phydev, MDIO_MMD_VEND1, 0x0145, 0x1010);
+
+	/* disable tx slew control */
+	phy_write_mmd(phydev, MDIO_MMD_VEND1, 0x0185, 0x0000);
+	phy_write_mmd(phydev, MDIO_MMD_VEND1, 0x00fb, 0x0100);
+
+	switch (txg_calen_x) {
+	case PAIR_A:
+		phy_set_bits_mmd(phydev, MDIO_MMD_VEND1,
+				 MTK_PHY_RG_ANA_CAL_RG0,
+				 MTK_PHY_RG_ZCALEN_A);
+		break;
+	case PAIR_B:
+		phy_set_bits_mmd(phydev, MDIO_MMD_VEND1,
+				 MTK_PHY_RG_ANA_CAL_RG1,
+				 MTK_PHY_RG_ZCALEN_B);
+		break;
+	case PAIR_C:
+		phy_set_bits_mmd(phydev, MDIO_MMD_VEND1,
+				 MTK_PHY_RG_ANA_CAL_RG1,
+				 MTK_PHY_RG_ZCALEN_C);
+		break;
+	case PAIR_D:
+		phy_set_bits_mmd(phydev, MDIO_MMD_VEND1,
+				 MTK_PHY_RG_ANA_CAL_RG1,
+				 MTK_PHY_RG_ZCALEN_D);
+		break;
+	default:
+		return -EINVAL;
+	}
+
+	phydev_dbg(phydev, "Start TX r50 SW cal.\n");
+	first_calib = airoha_cal_cycle(phydev_p0, MDIO_MMD_VEND1, MTK_PHY_RG_ANA_CAL_RG5,
+				       MTK_PHY_RG_REXT_ZCAL_CTRL_MASK, zcal_ctrl);
+
+	if (first_calib < 0) {
+		phydev_err(phydev, "TX r50 SW calibration failed.\n");
+		return -EINVAL;
+	}
+
+	/* If TX r50 calibration failed:
+	 * - increase dB until calibration succeed.
+	 * If TX r50 calibration succeeded:
+	 * - decrease dB until calibration fail to fine tune it.
+	 */
+	if (first_calib == 1)
+		calibration_polarity = -1;
+	else
+		calibration_polarity = 1;
+
+	while (zcal_ctrl > 0 &&
+	       zcal_ctrl < FIELD_MAX(MTK_PHY_RG_REXT_ZCAL_CTRL_MASK)) {
+		zcal_ctrl += calibration_polarity;
+
+		ret = airoha_cal_cycle(phydev_p0, MDIO_MMD_VEND1, MTK_PHY_RG_ANA_CAL_RG5,
+				       MTK_PHY_RG_REXT_ZCAL_CTRL_MASK, zcal_ctrl);
+		/* Exit if we either failed or succeeded compared to the
+		 * first calibration result. (aka we finished fine tuning or
+		 * we succeeded with calibration)
+		 */
+		if (ret != first_calib)
+			break;
+	}
+
+	if (ret < 0) {
+		phydev_err(phydev, "TX r50 SW calibration failed.\n");
+		return -EINVAL;
+	}
+
+	if (zcal_ctrl == 0 ||
+	    zcal_ctrl == FIELD_MAX(MTK_PHY_RG_REXT_ZCAL_CTRL_MASK))
+		phydev_warn(phydev, "TX r50 SW calibration saturation.\n");
+
+	zcal_ctrl = shared->r50_cal_tbl[zcal_ctrl];
+
+	switch (txg_calen_x) {
+	case PAIR_A:
+		val = BIT(15) | FIELD_PREP(AIROHA_PHY_CR_TX_R50_OFFSET_A_MASK, zcal_ctrl);
+		phy_modify_mmd(phydev, MDIO_MMD_VEND1,
+			       MTK_PHY_RG_CR_TX_R50_OFFSET_A_B,
+			       BIT(15) | AIROHA_PHY_CR_TX_R50_OFFSET_A_MASK, val);
+		break;
+	case PAIR_B:
+		val = BIT(7) | FIELD_PREP(MTK_PHY_CR_TX_R50_OFFSET_B_MASK, zcal_ctrl);
+		phy_modify_mmd(phydev, MDIO_MMD_VEND1,
+			       MTK_PHY_RG_CR_TX_R50_OFFSET_A_B,
+			       BIT(7) | MTK_PHY_CR_TX_R50_OFFSET_B_MASK, val);
+		break;
+	case PAIR_C:
+		val = BIT(15) | FIELD_PREP(AIROHA_PHY_CR_TX_R50_OFFSET_C_MASK, zcal_ctrl);
+		phy_modify_mmd(phydev, MDIO_MMD_VEND1,
+			       MTK_PHY_RG_CR_TX_R50_OFFSET_C_D,
+			       BIT(15) | AIROHA_PHY_CR_TX_R50_OFFSET_C_MASK, val);
+		break;
+	case PAIR_D:
+		val = BIT(7) | FIELD_PREP(MTK_PHY_CR_TX_R50_OFFSET_D_MASK, zcal_ctrl);
+		phy_modify_mmd(phydev, MDIO_MMD_VEND1,
+			       MTK_PHY_RG_CR_TX_R50_OFFSET_C_D,
+			       BIT(7) | MTK_PHY_CR_TX_R50_OFFSET_D_MASK, val);
+		break;
+	default:
+		return -EINVAL;
+	}
+
+	phy_write_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_RG_ANA_CAL_RG0, 0);
+	phy_write_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_RG_ANA_CAL_RG1, 0);
+	phy_write_mmd(phydev_p0, MDIO_MMD_VEND1, MTK_PHY_RG_ANA_CAL_RG0, 0);
+	phy_write_mmd(phydev_p0, MDIO_MMD_VEND1, MTK_PHY_RG_ANA_CAL_RG1, 0);
+
+	/* Enable tx slew control */
+	phy_write_mmd(phydev, MDIO_MMD_VEND1, 0x0185, 0x0001);
+	phy_write_mmd(phydev, MDIO_MMD_VEND1, 0x00fb, 0x0000);
+
+	phy_write_mmd(phydev_p0, MDIO_MMD_VEND2, 0x100, 0x0);
+
+	phy_write_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_RG_ANA_CAL_RG6, 0x0);
+	phy_write_mmd(phydev_p0, MDIO_MMD_VEND1, MTK_PHY_RG_ANA_CAL_RG6, 0x0);
+
+	/* Restore BMCR */
+	phy_write(phydev, MII_BMCR, bmcr_tmp);
+
+	/* Restore MDI */
+	phy_write_mmd(phydev, MDIO_MMD_VEND1, 0x0145, dev1e_145_tmp);
+
+	return 0;
+}
+
+static int airoha_rx_offset_cal_sw(struct phy_device *phydev)
+{
+	/* Hw bypass, Fw cal */
+	phy_write_mmd(phydev, MDIO_MMD_VEND1, 0x96, 0x0);
+	/* tx/rx_cal_criteria_value */
+	phy_write_mmd(phydev, MDIO_MMD_VEND1, 0x37, 0x0033);
+
+	/* rx offset cal by Hw setup */
+	phy_clear_bits_mmd(phydev, MDIO_MMD_VEND1, 0x39,
+			   BIT(14) | BIT(11));
+
+	/* disable rtune calibration */
+	phy_clear_bits_mmd(phydev, MDIO_MMD_VEND2, 0x107,
+			   BIT(12));
+
+	/* bypass tx/rx dc offset cancellation process */
+	phy_set_bits_mmd(phydev, MDIO_MMD_VEND1, 0x171,
+			 BIT(8) | BIT(7));
+
+	/* rx offset calibration start */
+	phy_set_bits_mmd(phydev, MDIO_MMD_VEND1, 0x39,
+			 BIT(13));
+
+	/* rx offset calibration stop */
+	phy_clear_bits_mmd(phydev, MDIO_MMD_VEND1, 0x39,
+			   BIT(13));
+
+	mdelay(10);
+
+	phy_clear_bits_mmd(phydev, MDIO_MMD_VEND1, 0x171,
+			   BIT(8) | BIT(7));
+
+	phy_write_mmd(phydev, MDIO_MMD_VEND2, 0x100, 0x0);
+	phy_write_mmd(phydev, MDIO_MMD_VEND1, 0x145, 0x1000);
+
+	if (phydev->drv->phy_id == AIROHA_GPHY_ID_AN7581)
+		phy_write_mmd(phydev, MDIO_MMD_VEND1,
+			      MTK_PHY_RG_ANA_CAL_RG6, 0x1);
+
+	return 0;
+}
+
+static int airoha_cal_sw(struct phy_device *phydev, enum CAL_ITEM cal_item,
+			 u8 start_pair, u8 end_pair)
+{
+	u8 pair_n;
+	int ret;
+
+	for (pair_n = start_pair; pair_n <= end_pair; pair_n++) {
+		switch (cal_item) {
+		case REXT:
+			ret = airoha_rext_cal_sw(phydev);
+			break;
+		case TX_OFFSET:
+			ret = airoha_tx_offset_cal_sw(phydev, pair_n);
+			break;
+		case TX_AMP:
+			ret = airoha_tx_amp_cal_sw(phydev, pair_n);
+			break;
+		case TX_R50:
+			ret = airoha_tx_r50_cal_sw(phydev, pair_n);
+			break;
+		case RX_OFFSET:
+			ret = airoha_rx_offset_cal_sw(phydev);
+			break;
+		default:
+			return -EINVAL;
+		}
+		if (ret)
+			return ret;
+	}
+	return 0;
+}
+
+static int airoha_start_cal(struct phy_device *phydev, enum CAL_ITEM cal_item,
+			    enum CAL_MODE cal_mode, u8 start_pair,
+			    u8 end_pair, u32 *buf)
+{
+	int ret;
+
+	switch (cal_mode) {
+	case SW_M:
+		ret = airoha_cal_sw(phydev, cal_item, start_pair, end_pair);
+		break;
+	default:
+		return -EINVAL;
+	}
+
+	if (ret) {
+		phydev_err(phydev, "cal %d failed\n", cal_item);
+		return -EIO;
+	}
+
+	return 0;
+}
+
+static int airoha_phy_calib(struct phy_device *phydev)
+{
+	struct airoha_socphy_shared *shared = phy_package_get_priv(phydev);
+	struct phy_device *phydev_p0;
+	int ret;
+
+	phydev_p0 = shared->phydev_p0;
+
+	/* PreCalibrate Set */
+	phy_write_mmd(phydev, MDIO_MMD_VEND1, 0x5c, 0x6666);
+
+	if (!shared->rext_sw_calib_done) {
+		ret = airoha_start_cal(phydev, REXT, SW_M, NO_PAIR, NO_PAIR, NULL);
+		if (ret)
+			return ret;
+
+		shared->rext_sw_calib_done = true;
+	}
+
+	ret = airoha_start_cal(phydev, TX_R50, SW_M, PAIR_A, PAIR_D, NULL);
+	if (ret)
+		return ret;
+
+	ret = airoha_start_cal(phydev, TX_OFFSET, SW_M, PAIR_A, PAIR_D, NULL);
+	if (ret)
+		return ret;
+
+	ret = airoha_start_cal(phydev, TX_AMP, SW_M, PAIR_A, PAIR_D, NULL);
+	if (ret)
+		return ret;
+
+	ret = airoha_start_cal(phydev, RX_OFFSET, SW_M, NO_PAIR, NO_PAIR, NULL);
+	if (ret)
+		return ret;
+
+	/* Gating, short with other pair */
+	phy_write_mmd(phydev, MDIO_MMD_VEND1, 0x15, 0x0);
+
+	phy_write_mmd(phydev_p0, MDIO_MMD_VEND2, 0x100, 0x0);
+
+	return 0;
+}
+
+static int airoha_phy_auto_select_transformer(struct phy_device *phydev)
+{
+	struct airoha_socphy_shared *shared = phy_package_get_priv(phydev);
+	struct phy_device *phydev_p0;
+	u8 phy_offset;
+	u16 bmcr_tmp;
+	u16 val;
+	int i;
+
+	phydev_p0 = shared->phydev_p0;
+	phy_offset = phydev->mdio.addr - phydev_p0->mdio.addr;
+
+	/* Force 1G full duplex for calibration */
+	bmcr_tmp = phy_read(phydev, MII_BMCR);
+	phy_write(phydev, MII_BMCR, BMCR_FULLDPLX | BMCR_SPEED1000);
+
+	phy_modify_mmd(phydev, MDIO_MMD_VEND2, 0x271, GENMASK(4, 0),
+		       FIELD_PREP(GENMASK(4, 0), 0x3));
+
+	phy_modify_mmd(phydev, MDIO_MMD_VEND2, 0x269, GENMASK(15, 12),
+		       FIELD_PREP(GENMASK(15, 12), 0x2));
+
+	phy_modify_mmd(phydev, MDIO_MMD_VEND2, 0x26f, GENMASK(14, 12),
+		       FIELD_PREP(GENMASK(14, 12), 0x0));
+
+	phy_write_mmd(phydev, MDIO_MMD_VEND1, 0xdd, BIT(12));
+
+	phy_write_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_RG_DASN_DAC_IN0_A,
+		      0x8000 | 0xf0);
+	phy_write_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_RG_DASN_DAC_IN1_A,
+		      0x8000 | 0xf0);
+	phy_write_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_RG_DASN_DAC_IN0_B,
+		      0x8000 | 0xf0);
+	phy_write_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_RG_DASN_DAC_IN1_B,
+		      0x8000 | 0xf0);
+	phy_write_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_RG_DASN_DAC_IN0_C,
+		      0x8000 | 0xf0);
+	phy_write_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_RG_DASN_DAC_IN1_C,
+		      0x8000 | 0xf0);
+	phy_write_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_RG_DASN_DAC_IN0_D,
+		      0x8000 | 0xf0);
+	phy_write_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_RG_DASN_DAC_IN1_D,
+		      0x8000 | 0xf0);
+
+	/* Force pGA gain */
+	phy_select_page(phydev, MTK_PHY_PAGE_EXTENDED_52B5);
+	__mtk_tr_modify(phydev, 0x1, 0xf, 0x10,
+			GENMASK(20, 15),
+			FIELD_PREP(GENMASK(20, 15), 0x1f));
+
+	__mtk_tr_modify(phydev, 0x1, 0xf, 0x11,
+			GENMASK(23, 18) | GENMASK(15, 10) | GENMASK(7, 2),
+			FIELD_PREP(GENMASK(23, 18), 0x1f) |
+			FIELD_PREP(GENMASK(15, 10), 0x1f) |
+			FIELD_PREP(GENMASK(7, 2), 0x1f));
+	phy_restore_page(phydev, MTK_PHY_PAGE_STANDARD, 0);
+
+	phy_write_mmd(phydev, MDIO_MMD_VEND1, 0xc9, 0xffff);
+	phy_write_mmd(phydev, MDIO_MMD_VEND1, 0x151, 0x12);
+
+	switch (phy_offset) {
+	case 0:
+		val = 0x1;
+		break;
+	case 1:
+		val = 0x3;
+		break;
+	case 2:
+		val = 0x5;
+		break;
+	case 3:
+		val = 0x7;
+		break;
+	default:
+		return -EINVAL;
+	}
+	phy_write_mmd(phydev, MDIO_MMD_VEND2, 0x15,
+		      FIELD_PREP(GENMASK(14, 12), val) | 0x161);
+	mdelay(500);
+
+	for (i = 0; i < 3; i++)
+		val = phy_read_mmd(phydev, MDIO_MMD_VEND2, 0x1a);
+
+	/* Check the value and report transformer type for later */
+	shared->transformer_type[phy_offset] = val < 0xe0;
+
+	/* Switch to Default */
+	phy_write_mmd(phydev, MDIO_MMD_VEND2, 0x15, 0x1000);
+
+	phy_write_mmd(phydev, MDIO_MMD_VEND1, 0xdd, 0x0);
+
+	phy_write_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_RG_DASN_DAC_IN0_A,
+		      0x0);
+	phy_write_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_RG_DASN_DAC_IN1_A,
+		      0x0);
+	phy_write_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_RG_DASN_DAC_IN0_B,
+		      0x0);
+	phy_write_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_RG_DASN_DAC_IN1_B,
+		      0x0);
+	phy_write_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_RG_DASN_DAC_IN0_C,
+		      0x0);
+	phy_write_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_RG_DASN_DAC_IN1_C,
+		      0x0);
+	phy_write_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_RG_DASN_DAC_IN0_D,
+		      0x0);
+	phy_write_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_RG_DASN_DAC_IN1_D,
+		      0x0);
+
+	phy_write_mmd(phydev, MDIO_MMD_VEND1, 0xc9, 0xfff);
+	phy_write_mmd(phydev, MDIO_MMD_VEND1, 0x151, 0x0);
+
+	phy_select_page(phydev, MTK_PHY_PAGE_EXTENDED_52B5);
+	__mtk_tr_modify(phydev, 0x1, 0xf, 0x10,
+			GENMASK(20, 15),
+			FIELD_PREP(GENMASK(20, 15), 0x4));
+
+	__mtk_tr_modify(phydev, 0x1, 0xf, 0x11,
+			GENMASK(23, 18) | GENMASK(15, 10) | GENMASK(7, 2),
+			FIELD_PREP(GENMASK(23, 18), 0x0) |
+			FIELD_PREP(GENMASK(15, 10), 0x0) |
+			FIELD_PREP(GENMASK(7, 2), 0x0));
+	phy_restore_page(phydev, MTK_PHY_PAGE_STANDARD, 0);
+
+	/* Restore BMCR */
+	phy_write(phydev, MII_BMCR, bmcr_tmp);
+
+	return 0;
+}
+
+static int airoha_phy_tx_amp_compensation(struct phy_device *phydev)
+{
+	struct airoha_socphy_shared *shared = phy_package_get_priv(phydev);
+
+	u16 reg_1e_12_read;
+	u16 reg_1e_16_read;
+	u16 reg_1e_17_read;
+	u16 reg_1e_18_read;
+	u16 reg_1e_19_read;
+	u16 reg_1e_20_read;
+	u16 reg_1e_21_read;
+	u16 reg_1e_22_read;
+	u16 reg_1e_174_read;
+	u16 reg_1e_175_read;
+
+	int reg_1e_12_header;
+	int reg_1e_16_header;
+	int reg_1e_17_header;
+	int reg_1e_18_header;
+	int reg_1e_19_header;
+	int reg_1e_21_header;
+	int reg_1e_174_header;
+	int reg_1e_175_header;
+
+	int reg_1e_12_end;
+	int reg_1e_16_end;
+	int reg_1e_17_end;
+	int reg_1e_18_end;
+	int reg_1e_20_end;
+	int reg_1e_22_end;
+	int reg_1e_174_end;
+	int reg_1e_175_end;
+
+	struct phy_device *phydev_p0;
+	u8 phy_offset;
+
+	int txamp_low_limit = -3;
+	int txamp_high_limit = 0x42;
+
+	int r50_low_limit = -8;
+	int r50_high_limit = 0x88;
+
+	bool overflow;
+	int (*tx_amp_table)[CALIB_CONST_TYPE_MAX][4];
+	int transformer_type, mdi_resister_type;
+
+	phydev_p0 = shared->phydev_p0;
+	phy_offset = phydev->mdio.addr - phydev_p0->mdio.addr;
+
+	transformer_type = shared->transformer_type[phy_offset];
+	mdi_resister_type = shared->mdi_resister_type;
+	tx_amp_table = &(*shared->tx_amp_compensation_tbl)[transformer_type][mdi_resister_type];
+
+	reg_1e_12_read = phy_read_mmd(phydev, MDIO_MMD_VEND1, 0x12);
+	reg_1e_16_read = phy_read_mmd(phydev, MDIO_MMD_VEND1, 0x16);
+	reg_1e_17_read = phy_read_mmd(phydev, MDIO_MMD_VEND1, 0x17);
+	reg_1e_18_read = phy_read_mmd(phydev, MDIO_MMD_VEND1, 0x18);
+	reg_1e_19_read = phy_read_mmd(phydev, MDIO_MMD_VEND1, 0x19);
+	reg_1e_20_read = phy_read_mmd(phydev, MDIO_MMD_VEND1, 0x20);
+	reg_1e_21_read = phy_read_mmd(phydev, MDIO_MMD_VEND1, 0x21);
+	reg_1e_22_read = phy_read_mmd(phydev, MDIO_MMD_VEND1, 0x22);
+	reg_1e_174_read = phy_read_mmd(phydev, MDIO_MMD_VEND1, 0x174);
+	reg_1e_175_read = phy_read_mmd(phydev, MDIO_MMD_VEND1, 0x175);
+
+	reg_1e_12_header = ((reg_1e_12_read & 0xfc00) / 1024) + (*tx_amp_table)[TX_AMP_1G_A][phy_offset];
+	reg_1e_17_header = ((reg_1e_17_read & 0x3f00) / 256) + (*tx_amp_table)[TX_AMP_1G_B][phy_offset];
+	reg_1e_19_header = ((reg_1e_19_read & 0x3f00) / 256) + (*tx_amp_table)[TX_AMP_1G_C][phy_offset];
+	reg_1e_21_header = ((reg_1e_21_read & 0x3f00) / 256) + (*tx_amp_table)[TX_AMP_1G_D][phy_offset];
+
+	overflow = false;
+	if (reg_1e_12_header < txamp_low_limit ||
+	    reg_1e_12_header > txamp_high_limit)
+		overflow = true;
+	if (reg_1e_17_header < txamp_low_limit ||
+	    reg_1e_17_header > txamp_high_limit)
+		overflow = true;
+	if (reg_1e_19_header < txamp_low_limit ||
+	    reg_1e_19_header > txamp_high_limit)
+		overflow = true;
+	if (reg_1e_21_header < txamp_low_limit ||
+	    reg_1e_21_header > txamp_high_limit)
+		overflow = true;
+
+	if (overflow) {
+		reg_1e_12_header = 0x20;
+		reg_1e_17_header = 0x20;
+		reg_1e_19_header = 0x20;
+		reg_1e_21_header = 0x20;
+	} else {
+		if (reg_1e_12_header < 0)
+			reg_1e_12_header = 0;
+		else if (reg_1e_12_header > 0x3f)
+			reg_1e_12_header = 0x3f;
+		if (reg_1e_17_header < 0)
+			reg_1e_17_header = 0;
+		else if (reg_1e_17_header > 0x3f)
+			reg_1e_17_header = 0x3f;
+		if (reg_1e_19_header < 0)
+			reg_1e_19_header = 0;
+		else if (reg_1e_19_header > 0x3f)
+			reg_1e_19_header = 0x3f;
+		if (reg_1e_21_header < 0)
+			reg_1e_21_header = 0;
+		else if (reg_1e_21_header > 0x3f)
+			reg_1e_21_header = 0x3f;
+	}
+
+	reg_1e_16_end = (reg_1e_16_read & 0x003f) + (*tx_amp_table)[TX_AMP_TEST_A][phy_offset];
+	reg_1e_18_end = (reg_1e_18_read & 0x003f) + (*tx_amp_table)[TX_AMP_TEST_B][phy_offset];
+	reg_1e_20_end = (reg_1e_20_read & 0x003f) + (*tx_amp_table)[TX_AMP_TEST_C][phy_offset];
+	reg_1e_22_end = (reg_1e_22_read & 0x003f) + (*tx_amp_table)[TX_AMP_TEST_D][phy_offset];
+
+	overflow = false;
+	if (reg_1e_16_end < txamp_low_limit ||
+	    reg_1e_16_end > txamp_high_limit)
+		overflow = true;
+	if (reg_1e_18_end < txamp_low_limit ||
+	    reg_1e_18_end > txamp_high_limit)
+		overflow = true;
+	if (reg_1e_20_end < txamp_low_limit ||
+	    reg_1e_20_end > txamp_high_limit)
+		overflow = true;
+	if (reg_1e_22_end < txamp_low_limit ||
+	    reg_1e_22_end > txamp_high_limit)
+		overflow = true;
+
+	if (overflow) {
+		reg_1e_16_end = 0x20;
+		reg_1e_18_end = 0x20;
+		reg_1e_20_end = 0x20;
+		reg_1e_22_end = 0x20;
+	} else {
+		if (reg_1e_16_end < 0)
+			reg_1e_16_end = 0;
+		else if (reg_1e_16_end > 0x3f)
+			reg_1e_16_end = 0x3f;
+		if (reg_1e_18_end < 0)
+			reg_1e_18_end = 0;
+		else if (reg_1e_18_end > 0x3f)
+			reg_1e_18_end = 0x3f;
+		if (reg_1e_20_end < 0)
+			reg_1e_20_end = 0;
+		else if (reg_1e_20_end > 0x3f)
+			reg_1e_20_end = 0x3f;
+		if (reg_1e_22_end < 0)
+			reg_1e_22_end = 0;
+		else if (reg_1e_22_end > 0x3f)
+			reg_1e_22_end = 0x3f;
+	}
+
+	reg_1e_16_header = ((reg_1e_16_read & 0xfc00) / 1024) + (*tx_amp_table)[TX_AMP_100M_A][phy_offset];
+	reg_1e_18_header = ((reg_1e_18_read & 0x3f00) / 256) + (*tx_amp_table)[TX_AMP_100M_B][phy_offset];
+
+	overflow = false;
+	if (reg_1e_16_header < txamp_low_limit ||
+	    reg_1e_16_header > txamp_high_limit)
+		overflow = true;
+	if (reg_1e_18_header < txamp_low_limit ||
+	    reg_1e_18_header > txamp_high_limit)
+		overflow = true;
+
+	if (overflow) {
+		reg_1e_16_header = 0x20;
+		reg_1e_18_header = 0x20;
+	} else {
+		if (reg_1e_16_header < 0)
+			reg_1e_16_header = 0;
+		else if (reg_1e_16_header > 0x3f)
+			reg_1e_16_header = 0x3f;
+		if (reg_1e_18_header < 0)
+			reg_1e_18_header = 0;
+		else if (reg_1e_18_header > 0x3f)
+			reg_1e_18_header = 0x3f;
+	}
+
+	reg_1e_12_end = (reg_1e_12_read & 0x003f) + (*tx_amp_table)[TX_AMP_10M_A][phy_offset];
+	reg_1e_17_end = (reg_1e_17_read & 0x003f) + (*tx_amp_table)[TX_AMP_10M_B][phy_offset];
+
+	overflow = false;
+	if (reg_1e_12_end < txamp_low_limit ||
+	    reg_1e_12_end > txamp_high_limit)
+		overflow = true;
+	if (reg_1e_17_end < txamp_low_limit ||
+	    reg_1e_17_end > txamp_high_limit)
+		overflow = true;
+
+	if (overflow) {
+		reg_1e_12_end = 0x20;
+		reg_1e_17_end = 0x20;
+	} else {
+		if (reg_1e_12_end < 0)
+			reg_1e_12_end = 0;
+		else if (reg_1e_12_end > 0x3f)
+			reg_1e_12_end = 0x3f;
+		if (reg_1e_17_end < 0)
+			reg_1e_17_end = 0;
+		else if (reg_1e_17_end > 0x3f)
+			reg_1e_17_end = 0x3f;
+	}
+
+	reg_1e_174_header = ((reg_1e_174_read & 0x7f00) / 256) + (*tx_amp_table)[R50_A][phy_offset];
+	reg_1e_174_end = (reg_1e_174_read & 0x007f) + (*tx_amp_table)[R50_B][phy_offset];
+	reg_1e_175_header = ((reg_1e_175_read & 0x7f00) / 256) + (*tx_amp_table)[R50_C][phy_offset];
+	reg_1e_175_end = (reg_1e_175_read & 0x007f) + (*tx_amp_table)[R50_D][phy_offset];
+
+	overflow = false;
+	if (reg_1e_174_header < r50_low_limit ||
+	    reg_1e_174_header > r50_high_limit)
+		overflow = true;
+	if (reg_1e_174_end < r50_low_limit ||
+	    reg_1e_174_end > r50_high_limit)
+		overflow = true;
+	if (reg_1e_175_header < r50_low_limit ||
+	    reg_1e_175_header > r50_high_limit)
+		overflow = true;
+	if (reg_1e_175_end < r50_low_limit ||
+	    reg_1e_175_end > r50_high_limit)
+		overflow = true;
+
+	if (overflow) {
+		reg_1e_174_header = 0x34;
+		reg_1e_174_end = 0x34;
+		reg_1e_175_header = 0x34;
+		reg_1e_175_end = 0x34;
+	} else {
+		if (reg_1e_174_header < 0)
+			reg_1e_174_header = 0;
+		else if (reg_1e_174_header > 0x7f)
+			reg_1e_174_header = 0x7f;
+		if (reg_1e_174_end < 0)
+			reg_1e_174_end = 0;
+		else if (reg_1e_174_end > 0x7f)
+			reg_1e_174_end = 0x7f;
+		if (reg_1e_175_header < 0)
+			reg_1e_175_header = 0;
+		else if (reg_1e_175_header > 0x7f)
+			reg_1e_175_header = 0x7f;
+		if (reg_1e_175_end < 0)
+			reg_1e_175_end = 0;
+		else if (reg_1e_175_end > 0x7f)
+			reg_1e_175_end = 0x7f;
+	}
+
+	phy_write_mmd(phydev, MDIO_MMD_VEND1, 0x12,
+		      (reg_1e_12_header * 1024) + reg_1e_12_end);
+	phy_write_mmd(phydev, MDIO_MMD_VEND1, 0x16,
+		      (reg_1e_16_header * 1024) + reg_1e_16_end);
+	phy_write_mmd(phydev, MDIO_MMD_VEND1, 0x17,
+		      (reg_1e_17_header * 256) + reg_1e_17_end);
+	phy_write_mmd(phydev, MDIO_MMD_VEND1, 0x18,
+		      (reg_1e_18_header * 256) + reg_1e_18_end);
+	phy_write_mmd(phydev, MDIO_MMD_VEND1, 0x19,
+		      (reg_1e_19_read & 0x00ff) + (reg_1e_19_header * 256));
+	phy_write_mmd(phydev, MDIO_MMD_VEND1, 0x20,
+		      (reg_1e_20_read & 0xff00) + reg_1e_20_end);
+	phy_write_mmd(phydev, MDIO_MMD_VEND1, 0x21,
+		      (reg_1e_21_read & 0x00ff) + (reg_1e_21_header * 256));
+	phy_write_mmd(phydev, MDIO_MMD_VEND1, 0x22,
+		      (reg_1e_22_read & 0xff00) + reg_1e_22_end);
+	phy_write_mmd(phydev, MDIO_MMD_VEND1, 0x174,
+		      0x8080 + (reg_1e_174_header * 256) + reg_1e_174_end);
+	phy_write_mmd(phydev, MDIO_MMD_VEND1, 0x175,
+		      0x8080 + (reg_1e_175_header * 256) + reg_1e_175_end);
+
+	return 0;
+}
+
+static int an7581_phy_config_init(struct phy_device *phydev)
+{
+	struct airoha_socphy_shared *shared = phy_package_get_priv(phydev);
+	struct phy_device *phydev_p0;
+	u32 soc_pdidr;
+	u8 phy_offset;
+	int ret;
+
+	phydev_p0 = shared->phydev_p0;
+	phy_offset = phydev->mdio.addr - phydev_p0->mdio.addr;
+
+	/* FIXME: Read SoC PDIDR if available or default to 2 (latest) */
+	soc_pdidr = 2;
+
+	shared->mdi_resister_type = MDI_5R;
+	if (soc_pdidr == 2)
+		shared->tx_amp_compensation_tbl = &an7581_tx_amp_compensation_tbl[1];
+	else
+		shared->tx_amp_compensation_tbl = &an7581_tx_amp_compensation_tbl[0];
+	shared->r50_cal_tbl = an7581_zcal_to_r45ohm;
+
+	ret = airoha_phy_calib(phydev);
+	if (ret)
+		return ret;
+
+	ret = airoha_phy_auto_select_transformer(phydev);
+	if (ret)
+		return ret;
+
+	ret = airoha_phy_tx_amp_compensation(phydev);
+	if (ret)
+		return ret;
+
+	/* RX setting for 5R_TXMR before AN setting */
+	phy_write_mmd(phydev, MDIO_MMD_VEND1, 0xe6, 0x1111);
+	phy_write_mmd(phydev, MDIO_MMD_VEND1, 0xe7, 0x5555);
+	phy_write_mmd(phydev, MDIO_MMD_VEND1, 0xe9, 0x0001);
+	phy_write_mmd(phydev, MDIO_MMD_VEND1, 0xfe, 0x0000);
+
+	/* Long Loop Reach setting */
+	phy_write_mmd(phydev, MDIO_MMD_VEND1, 0x11, 0xff00);
+	phy_write_mmd(phydev, MDIO_MMD_VEND2, 0x202, 0x2310);
+	phy_write_mmd(phydev, MDIO_MMD_VEND2, 0x203, 0x0025);
+	phy_write_mmd(phydev, MDIO_MMD_VEND2, 0x204, 0x2310);
+	phy_write_mmd(phydev, MDIO_MMD_VEND2, 0x205, 0x0025);
+	phy_write_mmd(phydev, MDIO_MMD_VEND2, 0x206, 0x2310);
+	phy_write_mmd(phydev, MDIO_MMD_VEND2, 0x207, 0x0025);
+	phy_write_mmd(phydev, MDIO_MMD_VEND2, 0x208, 0x2310);
+	phy_write_mmd(phydev, MDIO_MMD_VEND2, 0x209, 0x0025);
+	phy_write_mmd(phydev, MDIO_MMD_VEND2, 0x20a, 0x2310);
+	phy_write_mmd(phydev, MDIO_MMD_VEND2, 0x20b, 0x0025);
+	phy_write_mmd(phydev, MDIO_MMD_VEND2, 0x20e, 0x2310);
+	phy_write_mmd(phydev, MDIO_MMD_VEND2, 0x20f, 0x0025);
+	phy_write_mmd(phydev, MDIO_MMD_VEND2, 0x210, 0x2310);
+	phy_write_mmd(phydev, MDIO_MMD_VEND2, 0x211, 0x0025);
+	phy_write_mmd(phydev, MDIO_MMD_VEND2, 0x212, 0x2310);
+	phy_write_mmd(phydev, MDIO_MMD_VEND2, 0x213, 0x0025);
+	phy_write_mmd(phydev, MDIO_MMD_VEND2, 0x214, 0x2310);
+	phy_write_mmd(phydev, MDIO_MMD_VEND2, 0x215, 0x0025);
+	phy_write_mmd(phydev, MDIO_MMD_VEND2, 0x216, 0x2310);
+	phy_write_mmd(phydev, MDIO_MMD_VEND2, 0x217, 0x0025);
+	phy_write_mmd(phydev, MDIO_MMD_VEND2, 0x21a, 0x2310);
+	phy_write_mmd(phydev, MDIO_MMD_VEND2, 0x21b, 0x0025);
+	phy_write_mmd(phydev, MDIO_MMD_VEND2, 0x21c, 0x2310);
+	phy_write_mmd(phydev, MDIO_MMD_VEND2, 0x21d, 0x0025);
+	phy_write_mmd(phydev, MDIO_MMD_VEND2, 0x21e, 0x2310);
+	phy_write_mmd(phydev, MDIO_MMD_VEND2, 0x21f, 0x0025);
+	phy_write_mmd(phydev, MDIO_MMD_VEND2, 0x220, 0x2310);
+	phy_write_mmd(phydev, MDIO_MMD_VEND2, 0x221, 0x0025);
+	phy_write_mmd(phydev, MDIO_MMD_VEND2, 0x222, 0x2310);
+	phy_write_mmd(phydev, MDIO_MMD_VEND2, 0x223, 0x0025);
+	phy_write_mmd(phydev, MDIO_MMD_VEND2, 0x226, 0x2310);
+	phy_write_mmd(phydev, MDIO_MMD_VEND2, 0x227, 0x0025);
+	phy_write_mmd(phydev, MDIO_MMD_VEND2, 0x228, 0x2310);
+	phy_write_mmd(phydev, MDIO_MMD_VEND2, 0x229, 0x0025);
+	phy_write_mmd(phydev, MDIO_MMD_VEND2, 0x22a, 0x2310);
+	phy_write_mmd(phydev, MDIO_MMD_VEND2, 0x22b, 0x0025);
+	phy_write_mmd(phydev, MDIO_MMD_VEND2, 0x22c, 0x2310);
+	phy_write_mmd(phydev, MDIO_MMD_VEND2, 0x22d, 0x0025);
+	phy_write_mmd(phydev, MDIO_MMD_VEND2, 0x22e, 0x2310);
+	phy_write_mmd(phydev, MDIO_MMD_VEND2, 0x22f, 0x0025);
+
+	/* RX Setting */
+	phy_write_mmd(phydev, MDIO_MMD_VEND1, 0x3c, 0xc000);
+	phy_write_mmd(phydev, MDIO_MMD_VEND1, 0x3d, 0x0000);
+	phy_write_mmd(phydev, MDIO_MMD_VEND1, 0x3e, 0xc000);
+
+	/* EEE setting */
+	phy_write_mmd(phydev, MDIO_MMD_AN, 0x3c, 0x0000);
+
+	/* RX */
+	phy_write_mmd(phydev, MDIO_MMD_VEND2, 0x41, 0x3333);
+	phy_write_mmd(phydev, MDIO_MMD_VEND2, 0x44, 0x00c0);
+
+	/* 10M settings */
+	phy_write_mmd(phydev, MDIO_MMD_VEND1, 0x1a3, 0x00d2);
+	phy_write_mmd(phydev, MDIO_MMD_VEND1, 0x1a4, 0x010e);
+	phy_write_mmd(phydev, MDIO_MMD_VEND2, 0x27b, 0x1177);
+	phy_write_mmd(phydev, MDIO_MMD_VEND2, 0x27c, 0x0808);
+
+	phy_select_page(phydev, MTK_PHY_PAGE_EXTENDED_1);
+	__phy_write(phydev, 0x14, 0x3a18);
+	phy_restore_page(phydev, MTK_PHY_PAGE_STANDARD, 0);
+
+	phy_write(phydev, 0x9, 0x1e00);
+
+	phy_write_mmd(phydev, MDIO_MMD_VEND2, 0x269, 0x2114);
+	phy_write_mmd(phydev, MDIO_MMD_VEND2, 0x26a, 0x1113);
+	phy_write_mmd(phydev, MDIO_MMD_VEND2, 0x26f, 0x0000);
+	phy_write_mmd(phydev, MDIO_MMD_VEND2, 0x271, 0x2c63);
+	phy_write_mmd(phydev, MDIO_MMD_VEND2, 0x272, 0x0c2b);
+
+	/* EEE set because power down can't set tokenring */
+	phy_select_page(phydev, MTK_PHY_PAGE_EXTENDED_52B5);
+	__mtk_tr_write(phydev, 0x0, 0x7, 0x15, 0x0055a0);
+	__mtk_tr_write(phydev, 0x0, 0x7, 0x17, 0x07ff3f);
+	__mtk_tr_write(phydev, 0x1, 0xf, 0x0, 0x00001e);
+	__mtk_tr_write(phydev, 0x1, 0xf, 0x1, 0x6fb90a);
+	__mtk_tr_write(phydev, 0x1, 0xf, 0x18, 0x0e2f00);
+	__mtk_tr_write(phydev, 0x1, 0xd, 0x26, 0x444444);
+	__mtk_tr_write(phydev, 0x2, 0xd, 0x3, 0x000004);
+	__mtk_tr_write(phydev, 0x2, 0xd, 0x6, 0x2ebaef);
+	__mtk_tr_write(phydev, 0x2, 0xd, 0x8, 0x00000b);
+	__mtk_tr_write(phydev, 0x2, 0xd, 0xc, 0x00504d);
+	__mtk_tr_write(phydev, 0x2, 0xd, 0xd, 0x02314f);
+	__mtk_tr_write(phydev, 0x2, 0xd, 0xf, 0x003028);
+	__mtk_tr_write(phydev, 0x2, 0xd, 0x10, 0x00000a);
+	__mtk_tr_write(phydev, 0x2, 0xd, 0x11, 0x040001);
+	__mtk_tr_write(phydev, 0x2, 0xd, 0x14, 0x00024a);
+	__mtk_tr_write(phydev, 0x2, 0xd, 0x1c, 0x003210);
+	phy_restore_page(phydev, MTK_PHY_PAGE_STANDARD, 0);
+
+	phy_write_mmd(phydev, MDIO_MMD_VEND1, 0x120, 0x8014);
+	phy_write_mmd(phydev, MDIO_MMD_VEND1, 0x122, 0xffff);
+	phy_write_mmd(phydev, MDIO_MMD_VEND1, 0x144, 0x0200);
+	phy_write_mmd(phydev, MDIO_MMD_VEND1, 0x14a, 0xee20);
+	phy_write_mmd(phydev, MDIO_MMD_VEND1, 0x19b, 0x0111);
+	phy_write_mmd(phydev, MDIO_MMD_VEND1, 0x234, 0x1181);
+	phy_write_mmd(phydev, MDIO_MMD_VEND1, 0x238, 0x0120);
+	phy_write_mmd(phydev, MDIO_MMD_VEND1, 0x239, 0x0117);
+	phy_write_mmd(phydev, MDIO_MMD_VEND1, 0x2d1, 0x0733);
+	phy_write_mmd(phydev, MDIO_MMD_VEND1, 0x323, 0x0011);
+	phy_write_mmd(phydev, MDIO_MMD_VEND1, 0x324, 0x013f);
+	phy_write_mmd(phydev, MDIO_MMD_VEND1, 0x326, 0x0037);
+	phy_write_mmd(phydev, MDIO_MMD_VEND2, 0x268, 0x07f4);
+
+	if (shared->transformer_type[phy_offset] == TXMR) {
+		phy_write_mmd(phydev, MDIO_MMD_VEND1, 0x00, 0x0187);
+		phy_write_mmd(phydev, MDIO_MMD_VEND1, 0x01, 0x01cc);
+		phy_write_mmd(phydev, MDIO_MMD_VEND1, 0x02, 0x01c2);
+		phy_write_mmd(phydev, MDIO_MMD_VEND1, 0x03, 0x0109);
+		phy_write_mmd(phydev, MDIO_MMD_VEND1, 0x04, 0x020b);
+		phy_write_mmd(phydev, MDIO_MMD_VEND1, 0x05, 0x0202);
+		phy_write_mmd(phydev, MDIO_MMD_VEND1, 0x06, 0x0387);
+		phy_write_mmd(phydev, MDIO_MMD_VEND1, 0x07, 0x03c5);
+		phy_write_mmd(phydev, MDIO_MMD_VEND1, 0x08, 0x03c2);
+		phy_write_mmd(phydev, MDIO_MMD_VEND1, 0x09, 0x0309);
+		phy_write_mmd(phydev, MDIO_MMD_VEND1, 0x0a, 0x000e);
+		phy_write_mmd(phydev, MDIO_MMD_VEND1, 0x0b, 0x0002);
+
+		phy_write_mmd(phydev, MDIO_MMD_VEND1, 0x23, 0x0880);
+		phy_write_mmd(phydev, MDIO_MMD_VEND1, 0x24, 0x0880);
+		phy_write_mmd(phydev, MDIO_MMD_VEND1, 0x25, 0x0880);
+		phy_write_mmd(phydev, MDIO_MMD_VEND1, 0x26, 0x0880);
+	} else {
+		if (soc_pdidr == 2) {
+			phy_write_mmd(phydev, MDIO_MMD_VEND2, 0x269, 0x1114);
+			phy_write_mmd(phydev, MDIO_MMD_VEND2, 0x26a, 0x1113);
+			phy_write_mmd(phydev, MDIO_MMD_VEND2, 0x26f, 0x2000);
+			phy_write_mmd(phydev, MDIO_MMD_VEND2, 0x271, 0x4c88);
+			phy_write_mmd(phydev, MDIO_MMD_VEND2, 0x272, 0x0c2b);
+
+			/* 100M sharp */
+			phy_write_mmd(phydev, MDIO_MMD_VEND1, 0x00, 0x0190);
+			phy_write_mmd(phydev, MDIO_MMD_VEND1, 0x01, 0x01c8);
+			phy_write_mmd(phydev, MDIO_MMD_VEND1, 0x02, 0x01c0);
+			phy_write_mmd(phydev, MDIO_MMD_VEND1, 0x03, 0x0030);
+			phy_write_mmd(phydev, MDIO_MMD_VEND1, 0x04, 0x0208);
+			phy_write_mmd(phydev, MDIO_MMD_VEND1, 0x05, 0x0000);
+			phy_write_mmd(phydev, MDIO_MMD_VEND1, 0x06, 0x0318);
+			phy_write_mmd(phydev, MDIO_MMD_VEND1, 0x07, 0x03c8);
+			phy_write_mmd(phydev, MDIO_MMD_VEND1, 0x08, 0x03c0);
+			phy_write_mmd(phydev, MDIO_MMD_VEND1, 0x09, 0x0230);
+			phy_write_mmd(phydev, MDIO_MMD_VEND1, 0x0a, 0x0008);
+			phy_write_mmd(phydev, MDIO_MMD_VEND1, 0x0b, 0x0200);
+
+			phy_write_mmd(phydev, MDIO_MMD_VEND1, 0x23, 0x0885);
+			phy_write_mmd(phydev, MDIO_MMD_VEND1, 0x24, 0x0885);
+			phy_write_mmd(phydev, MDIO_MMD_VEND1, 0x25, 0x0885);
+			phy_write_mmd(phydev, MDIO_MMD_VEND1, 0x26, 0x0885);
+		} else {
+			phy_write_mmd(phydev, MDIO_MMD_VEND1, 0x00, 0x0190);
+			phy_write_mmd(phydev, MDIO_MMD_VEND1, 0x01, 0x01cf);
+			phy_write_mmd(phydev, MDIO_MMD_VEND1, 0x02, 0x01c0);
+			phy_write_mmd(phydev, MDIO_MMD_VEND1, 0x03, 0x0030);
+			phy_write_mmd(phydev, MDIO_MMD_VEND1, 0x04, 0x020f);
+			phy_write_mmd(phydev, MDIO_MMD_VEND1, 0x05, 0x0000);
+			phy_write_mmd(phydev, MDIO_MMD_VEND1, 0x06, 0x0318);
+			phy_write_mmd(phydev, MDIO_MMD_VEND1, 0x07, 0x03cf);
+			phy_write_mmd(phydev, MDIO_MMD_VEND1, 0x08, 0x03c0);
+			phy_write_mmd(phydev, MDIO_MMD_VEND1, 0x09, 0x0230);
+			phy_write_mmd(phydev, MDIO_MMD_VEND1, 0x0a, 0x000f);
+			phy_write_mmd(phydev, MDIO_MMD_VEND1, 0x0b, 0x0200);
+
+			phy_write_mmd(phydev, MDIO_MMD_VEND1, 0x23, 0x0003);
+			phy_write_mmd(phydev, MDIO_MMD_VEND1, 0x24, 0x0003);
+			phy_write_mmd(phydev, MDIO_MMD_VEND1, 0x25, 0x0003);
+			phy_write_mmd(phydev, MDIO_MMD_VEND1, 0x26, 0x0003);
+		}
+	}
+
+	return 0;
+}
+
+static int an7581_phy_probe(struct phy_device *phydev)
+{
+	struct airoha_socphy_shared *shared;
+	struct mtk_socphy_priv *priv;
+	struct pinctrl *pinctrl;
+	int ret;
+
+	/* Toggle pinctrl to enable PHY LED */
+	pinctrl = devm_pinctrl_get_select(&phydev->mdio.dev, "gbe-led");
+	if (IS_ERR(pinctrl))
+		dev_err(&phydev->mdio.bus->dev,
+			"Failed to setup PHY LED pinctrl\n");
+
+	ret = devm_phy_package_join(&phydev->mdio.dev, phydev, 0,
+				    sizeof(struct airoha_socphy_shared));
+	if (ret)
+		return ret;
+
+	priv = devm_kzalloc(&phydev->mdio.dev, sizeof(*priv), GFP_KERNEL);
+	if (!priv)
+		return -ENOMEM;
+
+	if (phydev->mdio.addr == AIROHA_DEFAULT_PORT0_ADDR)
+		shared->phydev_p0 = phydev;
+
+	phydev->priv = priv;
+
+	return 0;
+}
+
+static int an7581_phy_led_polarity_set(struct phy_device *phydev, int index,
+				       unsigned long modes)
+{
+	u16 val = 0;
+	u32 mode;
+
+	if (index >= AIROHA_PHY_MAX_LEDS)
+		return -EINVAL;
+
+	for_each_set_bit(mode, &modes, __PHY_LED_MODES_NUM) {
+		switch (mode) {
+		case PHY_LED_ACTIVE_LOW:
+			val = MTK_PHY_LED_ON_POLARITY;
+			break;
+		case PHY_LED_ACTIVE_HIGH:
+			break;
+		default:
+			return -EINVAL;
+		}
+	}
+
+	return phy_modify_mmd(phydev, MDIO_MMD_VEND2, index ?
+			      MTK_PHY_LED1_ON_CTRL : MTK_PHY_LED0_ON_CTRL,
+			      MTK_PHY_LED_ON_POLARITY, val);
+}
+
+static int en7528_phy_config_init(struct phy_device *phydev)
+{
+	/* The LED controller of the EN7528 powers up with its external
+	 * control disabled, leaving the LED pins dark regardless of what is
+	 * programmed into the LED control registers. Hand the pins over to
+	 * the LED control registers the same way the air_en8811h driver
+	 * does; the mode field of this register is already set out of reset.
+	 */
+	return phy_set_bits_mmd(phydev, MDIO_MMD_VEND2, MTK_PHY_LED_BCR,
+				MTK_PHY_LED_BCR_CLK_EN |
+				MTK_PHY_LED_BCR_EXT_CTRL);
+}
+
+static int an7583_phy_config_init(struct phy_device *phydev)
+{
+	struct airoha_socphy_shared *shared = phy_package_get_priv(phydev);
+	struct phy_device *phydev_p0;
+	u8 phy_offset;
+	int ret;
+
+	/* BMCR_PDOWN is enabled by default */
+	phy_clear_bits(phydev, MII_BMCR, BMCR_PDOWN);
+
+	phydev_p0 = shared->phydev_p0;
+	phy_offset = phydev->mdio.addr - phydev_p0->mdio.addr;
+
+	/* FIXME: Read SoC MDI Resister Type if available or default to 5R */
+	shared->mdi_resister_type = MDI_5R;
+
+	if (shared->mdi_resister_type == MDI_0R)
+		shared->r50_cal_tbl = an7583_zcal_to_r50ohm_0R;
+	if (shared->mdi_resister_type == MDI_5R)
+		shared->r50_cal_tbl = an7583_zcal_to_r50ohm_5R;
+	shared->tx_amp_compensation_tbl = &an7583_tx_amp_compensation_tbl;
+
+	ret = airoha_phy_calib(phydev);
+	if (ret)
+		return ret;
+
+	ret = airoha_phy_auto_select_transformer(phydev);
+	if (ret)
+		return ret;
+
+	ret = airoha_phy_tx_amp_compensation(phydev);
+	if (ret)
+		return ret;
+
+	/* Enable Idle Mode Power Setting */
+	if (phy_offset == 0) {
+		phy_write_mmd(phydev, MDIO_MMD_VEND2, 0x268, 0x07F1);
+		phy_write_mmd(phydev, MDIO_MMD_VEND2, 0x703, 0x3111);
+		phy_write_mmd(phydev, MDIO_MMD_VEND2, 0x271, 0x3C24);
+		phy_write_mmd(phydev, MDIO_MMD_VEND2, 0x701, 0x1023);
+	}
+
+	if (shared->transformer_type[phy_offset] == TXMR) {
+		phy_write_mmd(phydev, MDIO_MMD_VEND1, 0x23, 0x0881);
+		phy_write_mmd(phydev, MDIO_MMD_VEND1, 0x24, 0x0881);
+		phy_write_mmd(phydev, MDIO_MMD_VEND1, 0x25, 0x0881);
+		phy_write_mmd(phydev, MDIO_MMD_VEND1, 0x26, 0x0881);
+
+		if (shared->mdi_resister_type == MDI_5R)
+			phy_write_mmd(phydev, MDIO_MMD_VEND1, 0x05, 0x0205);
+		else
+			phy_write_mmd(phydev, MDIO_MMD_VEND1, 0x05, 0x0200);
+	} else {
+		if (shared->mdi_resister_type == MDI_5R) {
+			/* RX setting for 5R_TXMR before AN setting */
+			phy_write_mmd(phydev, MDIO_MMD_VEND1, 0xe7, 0x6666);
+			phy_write_mmd(phydev, MDIO_MMD_VEND1, 0xe9, 0x0003);
+			phy_write_mmd(phydev, MDIO_MMD_VEND1, 0xfe, 0x0006);
+			phy_write_mmd(phydev, MDIO_MMD_VEND1, 0xe6, 0x1111);
+			/* 100M sharp */
+			phy_write_mmd(phydev, MDIO_MMD_VEND1, 0x23, 0x0c86);
+			phy_write_mmd(phydev, MDIO_MMD_VEND1, 0x24, 0x0c86);
+			phy_write_mmd(phydev, MDIO_MMD_VEND1, 0x25, 0x0c86);
+			phy_write_mmd(phydev, MDIO_MMD_VEND1, 0x26, 0x0c86);
+			phy_write_mmd(phydev, MDIO_MMD_VEND1, 0x01, 0x01cb);
+			phy_write_mmd(phydev, MDIO_MMD_VEND1, 0x02, 0x01c2);
+			phy_write_mmd(phydev, MDIO_MMD_VEND1, 0x03, 0x0108);
+			phy_write_mmd(phydev, MDIO_MMD_VEND1, 0x04, 0x0211);
+			phy_write_mmd(phydev, MDIO_MMD_VEND1, 0x05, 0x0205);
+			phy_write_mmd(phydev, MDIO_MMD_VEND1, 0x06, 0x0387);
+			phy_write_mmd(phydev, MDIO_MMD_VEND1, 0x07, 0x03ce);
+			phy_write_mmd(phydev, MDIO_MMD_VEND1, 0x08, 0x03c8);
+			phy_write_mmd(phydev, MDIO_MMD_VEND1, 0x0b, 0x0005);
+		} else {
+			/* 100M sharp */
+			phy_write_mmd(phydev, MDIO_MMD_VEND1, 0x23, 0x0886);
+			phy_write_mmd(phydev, MDIO_MMD_VEND1, 0x24, 0x0886);
+			phy_write_mmd(phydev, MDIO_MMD_VEND1, 0x25, 0x0886);
+			phy_write_mmd(phydev, MDIO_MMD_VEND1, 0x26, 0x0886);
+			phy_write_mmd(phydev, MDIO_MMD_VEND1, 0x00, 0x0195);
+			phy_write_mmd(phydev, MDIO_MMD_VEND1, 0x01, 0x01cb);
+			phy_write_mmd(phydev, MDIO_MMD_VEND1, 0x02, 0x01c2);
+			phy_write_mmd(phydev, MDIO_MMD_VEND1, 0x03, 0x0108);
+			phy_write_mmd(phydev, MDIO_MMD_VEND1, 0x04, 0x0211);
+			phy_write_mmd(phydev, MDIO_MMD_VEND1, 0x05, 0x0205);
+			phy_write_mmd(phydev, MDIO_MMD_VEND1, 0x06, 0x0387);
+			phy_write_mmd(phydev, MDIO_MMD_VEND1, 0x07, 0x03ce);
+			phy_write_mmd(phydev, MDIO_MMD_VEND1, 0x08, 0x03c3);
+			phy_write_mmd(phydev, MDIO_MMD_VEND1, 0x0a, 0x0010);
+			phy_write_mmd(phydev, MDIO_MMD_VEND1, 0x0b, 0x0005);
+		}
+	}
+
+	/* RX Setting */
+	phy_write_mmd(phydev, MDIO_MMD_VEND1, 0x3c, 0xc000);
+	phy_write_mmd(phydev, MDIO_MMD_VEND1, 0x3d, 0x0000);
+	phy_write_mmd(phydev, MDIO_MMD_VEND1, 0x3e, 0xc000);
+
+	/* EEE setting */
+	phy_write_mmd(phydev, MDIO_MMD_AN, 0x3c, 0x0000);
+
+	/* 10M settings */
+	phy_write_mmd(phydev, MDIO_MMD_VEND1, 0x1a3, 0x00d2);
+	phy_write_mmd(phydev, MDIO_MMD_VEND1, 0x1a4, 0x010e);
+	phy_write_mmd(phydev, MDIO_MMD_VEND2, 0x27b, 0x1177);
+	phy_write_mmd(phydev, MDIO_MMD_VEND2, 0x27c, 0x0808);
+
+	phy_select_page(phydev, MTK_PHY_PAGE_EXTENDED_3);
+	__phy_write(phydev, 0x14, 0x190);
+	phy_restore_page(phydev, MTK_PHY_PAGE_STANDARD, 0);
+
+	phy_select_page(phydev, MTK_PHY_PAGE_EXTENDED_1);
+	__phy_write(phydev, 0x14, 0x3a18);
+	phy_restore_page(phydev, MTK_PHY_PAGE_STANDARD, 0);
+
+	phy_write(phydev, 0x9, 0x0600);
+
+	/* EEE keep only Pair A ON */
+	phy_write_mmd(phydev, MDIO_MMD_VEND1, 0x630, 0x006E);
+
+	return 0;
+}
+
+static struct phy_driver mtk_socphy_driver[] = {
+	{
+		PHY_ID_MATCH_EXACT(AIROHA_GPHY_ID_EN7528),
+		.name		= "EcoNet EN7528 PHY",
+		.config_init	= en7528_phy_config_init,
+		.probe		= an7581_phy_probe,
+		.led_blink_set	= mt798x_phy_led_blink_set,
+		.led_brightness_set = mt798x_phy_led_brightness_set,
+		.led_hw_is_supported = mt798x_phy_led_hw_is_supported,
+		.led_hw_control_set = mt798x_phy_led_hw_control_set,
+		.led_hw_control_get = mt798x_phy_led_hw_control_get,
+		.led_polarity_set = an7581_phy_led_polarity_set,
+	},
+	{
+		PHY_ID_MATCH_EXACT(AIROHA_GPHY_ID_AN7581),
+		.name		= "Airoha AN7581 PHY",
+		.config_init	= an7581_phy_config_init,
+		.config_intr	= genphy_no_config_intr,
+		.handle_interrupt = genphy_handle_interrupt_no_ack,
+		.probe		= an7581_phy_probe,
+		.led_blink_set	= mt798x_phy_led_blink_set,
+		.led_brightness_set = mt798x_phy_led_brightness_set,
+		.led_hw_is_supported = mt798x_phy_led_hw_is_supported,
+		.led_hw_control_set = mt798x_phy_led_hw_control_set,
+		.led_hw_control_get = mt798x_phy_led_hw_control_get,
+		.led_polarity_set = an7581_phy_led_polarity_set,
+		.read_page	= mtk_phy_read_page,
+		.write_page	= mtk_phy_write_page,
+	},
+	{
+		PHY_ID_MATCH_EXACT(AIROHA_GPHY_ID_AN7583),
+		.name		= "Airoha AN7583 PHY",
+		.config_init	= an7583_phy_config_init,
+		.probe		= an7581_phy_probe,
+		.led_blink_set	= mt798x_phy_led_blink_set,
+		.led_brightness_set = mt798x_phy_led_brightness_set,
+		.led_hw_is_supported = mt798x_phy_led_hw_is_supported,
+		.led_hw_control_set = mt798x_phy_led_hw_control_set,
+		.led_hw_control_get = mt798x_phy_led_hw_control_get,
+		.led_polarity_set = an7581_phy_led_polarity_set,
+		.read_page	= mtk_phy_read_page,
+		.write_page	= mtk_phy_write_page,
+	},
+};
+
+module_phy_driver(mtk_socphy_driver);
+
+static const struct mdio_device_id __maybe_unused airoha_socphy_tbl[] = {
+	{ PHY_ID_MATCH_EXACT(AIROHA_GPHY_ID_EN7528) },
+	{ PHY_ID_MATCH_EXACT(AIROHA_GPHY_ID_AN7581) },
+	{ PHY_ID_MATCH_EXACT(AIROHA_GPHY_ID_AN7583) },
+	{ }
+};
+
+MODULE_DESCRIPTION("Airoha SoC Gigabit Ethernet PHY driver");
+MODULE_AUTHOR("Christian Marangi <ansuelsmth@gmail.com>");
+MODULE_LICENSE("GPL");
+MODULE_VERSION("01.01.20260306");
+
+MODULE_DEVICE_TABLE(mdio, airoha_socphy_tbl);
diff --git a/drivers/net/phy/mediatek/mtk-ge-soc.c b/drivers/net/phy/mediatek/mtk-ge-soc.c
index 0041300d4f101..4132ac4035835 100644
--- a/drivers/net/phy/mediatek/mtk-ge-soc.c
+++ b/drivers/net/phy/mediatek/mtk-ge-soc.c
@@ -11,331 +11,10 @@
 
 #include "../phylib.h"
 #include "mtk.h"
+#include "mtk-ge-soc.h"
 
 #define MTK_PHY_MAX_LEDS			2
 
-#define MTK_GPHY_ID_MT7981			0x03a29461
-#define MTK_GPHY_ID_MT7988			0x03a29481
-#define MTK_GPHY_ID_EN7528			0x03a29491
-#define MTK_GPHY_ID_AN7581			0x03a294c1
-#define MTK_GPHY_ID_AN7583			0xc0ff0420
-
-#define MTK_EXT_PAGE_ACCESS			0x1f
-#define MTK_PHY_PAGE_STANDARD			0x0000
-#define MTK_PHY_PAGE_EXTENDED_3			0x0003
-
-#define MTK_PHY_LPI_REG_14			0x14
-#define MTK_PHY_LPI_WAKE_TIMER_1000_MASK	GENMASK(8, 0)
-
-#define MTK_PHY_LPI_REG_1c			0x1c
-#define MTK_PHY_SMI_DET_ON_THRESH_MASK		GENMASK(13, 8)
-
-#define MTK_PHY_PAGE_EXTENDED_2A30		0x2a30
-
-/* Registers on Token Ring debug nodes */
-/* ch_addr = 0x0, node_addr = 0x7, data_addr = 0x15 */
-/* NormMseLoThresh */
-#define NORMAL_MSE_LO_THRESH_MASK		GENMASK(15, 8)
-
-/* ch_addr = 0x0, node_addr = 0xf, data_addr = 0x3c */
-/* RemAckCntLimitCtrl */
-#define REMOTE_ACK_COUNT_LIMIT_CTRL_MASK	GENMASK(2, 1)
-
-/* ch_addr = 0x1, node_addr = 0xd, data_addr = 0x20 */
-/* VcoSlicerThreshBitsHigh */
-#define VCO_SLICER_THRESH_HIGH_MASK		GENMASK(23, 0)
-
-/* ch_addr = 0x1, node_addr = 0xf, data_addr = 0x0 */
-/* DfeTailEnableVgaThresh1000 */
-#define DFE_TAIL_EANBLE_VGA_TRHESH_1000		GENMASK(5, 1)
-
-/* ch_addr = 0x1, node_addr = 0xf, data_addr = 0x1 */
-/* MrvlTrFix100Kp */
-#define MRVL_TR_FIX_100KP_MASK			GENMASK(22, 20)
-/* MrvlTrFix100Kf */
-#define MRVL_TR_FIX_100KF_MASK			GENMASK(19, 17)
-/* MrvlTrFix1000Kp */
-#define MRVL_TR_FIX_1000KP_MASK			GENMASK(16, 14)
-/* MrvlTrFix1000Kf */
-#define MRVL_TR_FIX_1000KF_MASK			GENMASK(13, 11)
-
-/* ch_addr = 0x1, node_addr = 0xf, data_addr = 0x12 */
-/* VgaDecRate */
-#define VGA_DECIMATION_RATE_MASK		GENMASK(8, 5)
-
-/* ch_addr = 0x1, node_addr = 0xf, data_addr = 0x17 */
-/* SlvDSPreadyTime */
-#define SLAVE_DSP_READY_TIME_MASK		GENMASK(22, 15)
-/* MasDSPreadyTime */
-#define MASTER_DSP_READY_TIME_MASK		GENMASK(14, 7)
-
-/* ch_addr = 0x1, node_addr = 0xf, data_addr = 0x18 */
-/* EnabRandUpdTrig */
-#define ENABLE_RANDOM_UPDOWN_COUNTER_TRIGGER	BIT(8)
-
-/* ch_addr = 0x1, node_addr = 0xf, data_addr = 0x20 */
-/* ResetSyncOffset */
-#define RESET_SYNC_OFFSET_MASK			GENMASK(11, 8)
-
-/* ch_addr = 0x2, node_addr = 0xd, data_addr = 0x0 */
-/* FfeUpdGainForceVal */
-#define FFE_UPDATE_GAIN_FORCE_VAL_MASK		GENMASK(9, 7)
-/* FfeUpdGainForce */
-#define FFE_UPDATE_GAIN_FORCE			BIT(6)
-
-/* ch_addr = 0x2, node_addr = 0xd, data_addr = 0x3 */
-/* TrFreeze */
-#define TR_FREEZE_MASK				GENMASK(11, 0)
-
-/* ch_addr = 0x2, node_addr = 0xd, data_addr = 0x6 */
-/* SS: Steady-state, KP: Proportional Gain */
-/* SSTrKp100 */
-#define SS_TR_KP100_MASK			GENMASK(21, 19)
-/* SSTrKf100 */
-#define SS_TR_KF100_MASK			GENMASK(18, 16)
-/* SSTrKp1000Mas */
-#define SS_TR_KP1000_MASTER_MASK		GENMASK(15, 13)
-/* SSTrKf1000Mas */
-#define SS_TR_KF1000_MASTER_MASK		GENMASK(12, 10)
-/* SSTrKp1000Slv */
-#define SS_TR_KP1000_SLAVE_MASK			GENMASK(9, 7)
-/* SSTrKf1000Slv */
-#define SS_TR_KF1000_SLAVE_MASK			GENMASK(6, 4)
-
-/* ch_addr = 0x2, node_addr = 0xd, data_addr = 0x8 */
-/* clear this bit if wanna select from AFE */
-/* Regsigdet_sel_1000 */
-#define EEE1000_SELECT_SIGNAL_DETECTION_FROM_DFE	BIT(4)
-
-/* ch_addr = 0x2, node_addr = 0xd, data_addr = 0xd */
-/* RegEEE_st2TrKf1000 */
-#define EEE1000_STAGE2_TR_KF_MASK		GENMASK(13, 11)
-
-/* ch_addr = 0x2, node_addr = 0xd, data_addr = 0xf */
-/* RegEEE_slv_waketr_timer_tar */
-#define SLAVE_WAKETR_TIMER_MASK			GENMASK(20, 11)
-/* RegEEE_slv_remtx_timer_tar */
-#define SLAVE_REMTX_TIMER_MASK			GENMASK(10, 1)
-
-/* ch_addr = 0x2, node_addr = 0xd, data_addr = 0x10 */
-/* RegEEE_slv_wake_int_timer_tar */
-#define SLAVE_WAKEINT_TIMER_MASK		GENMASK(10, 1)
-
-/* ch_addr = 0x2, node_addr = 0xd, data_addr = 0x14 */
-/* RegEEE_trfreeze_timer2 */
-#define TR_FREEZE_TIMER2_MASK			GENMASK(9, 0)
-
-/* ch_addr = 0x2, node_addr = 0xd, data_addr = 0x1c */
-/* RegEEE100Stg1_tar */
-#define EEE100_LPSYNC_STAGE1_UPDATE_TIMER_MASK	GENMASK(8, 0)
-
-/* ch_addr = 0x2, node_addr = 0xd, data_addr = 0x25 */
-/* REGEEE_wake_slv_tr_wait_dfesigdet_en */
-#define WAKE_SLAVE_TR_WAIT_DFE_DETECTION_EN	BIT(11)
-
-#define ANALOG_INTERNAL_OPERATION_MAX_US	20
-#define TXRESERVE_MIN				0
-#define TXRESERVE_MAX				7
-
-#define MTK_PHY_ANARG_RG			0x10
-#define   MTK_PHY_TCLKOFFSET_MASK		GENMASK(12, 8)
-
-/* Registers on MDIO_MMD_VEND1 */
-#define MTK_PHY_TXVLD_DA_RG			0x12
-#define   MTK_PHY_DA_TX_I2MPB_A_GBE_MASK	GENMASK(15, 10)
-#define   MTK_PHY_DA_TX_I2MPB_A_TBT_MASK	GENMASK(5, 0)
-
-#define MTK_PHY_TX_I2MPB_TEST_MODE_A2		0x16
-#define   MTK_PHY_DA_TX_I2MPB_A_HBT_MASK	GENMASK(15, 10)
-#define   MTK_PHY_DA_TX_I2MPB_A_TST_MASK	GENMASK(5, 0)
-
-#define MTK_PHY_TX_I2MPB_TEST_MODE_B1		0x17
-#define   MTK_PHY_DA_TX_I2MPB_B_GBE_MASK	GENMASK(13, 8)
-#define   MTK_PHY_DA_TX_I2MPB_B_TBT_MASK	GENMASK(5, 0)
-
-#define MTK_PHY_TX_I2MPB_TEST_MODE_B2		0x18
-#define   MTK_PHY_DA_TX_I2MPB_B_HBT_MASK	GENMASK(13, 8)
-#define   MTK_PHY_DA_TX_I2MPB_B_TST_MASK	GENMASK(5, 0)
-
-#define MTK_PHY_TX_I2MPB_TEST_MODE_C1		0x19
-#define   MTK_PHY_DA_TX_I2MPB_C_GBE_MASK	GENMASK(13, 8)
-#define   MTK_PHY_DA_TX_I2MPB_C_TBT_MASK	GENMASK(5, 0)
-
-#define MTK_PHY_TX_I2MPB_TEST_MODE_C2		0x20
-#define   MTK_PHY_DA_TX_I2MPB_C_HBT_MASK	GENMASK(13, 8)
-#define   MTK_PHY_DA_TX_I2MPB_C_TST_MASK	GENMASK(5, 0)
-
-#define MTK_PHY_TX_I2MPB_TEST_MODE_D1		0x21
-#define   MTK_PHY_DA_TX_I2MPB_D_GBE_MASK	GENMASK(13, 8)
-#define   MTK_PHY_DA_TX_I2MPB_D_TBT_MASK	GENMASK(5, 0)
-
-#define MTK_PHY_TX_I2MPB_TEST_MODE_D2		0x22
-#define   MTK_PHY_DA_TX_I2MPB_D_HBT_MASK	GENMASK(13, 8)
-#define   MTK_PHY_DA_TX_I2MPB_D_TST_MASK	GENMASK(5, 0)
-
-#define MTK_PHY_RXADC_CTRL_RG7			0xc6
-#define   MTK_PHY_DA_AD_BUF_BIAS_LP_MASK	GENMASK(9, 8)
-
-#define MTK_PHY_RXADC_CTRL_RG9			0xc8
-#define   MTK_PHY_DA_RX_PSBN_TBT_MASK		GENMASK(14, 12)
-#define   MTK_PHY_DA_RX_PSBN_HBT_MASK		GENMASK(10, 8)
-#define   MTK_PHY_DA_RX_PSBN_GBE_MASK		GENMASK(6, 4)
-#define   MTK_PHY_DA_RX_PSBN_LP_MASK		GENMASK(2, 0)
-
-#define MTK_PHY_LDO_OUTPUT_V			0xd7
-
-#define MTK_PHY_RG_ANA_CAL_RG0			0xdb
-#define   MTK_PHY_RG_CAL_CKINV			BIT(12)
-#define   MTK_PHY_RG_ANA_CALEN			BIT(8)
-#define   MTK_PHY_RG_ZCALEN_A			BIT(0)
-
-#define MTK_PHY_RG_ANA_CAL_RG1			0xdc
-#define   MTK_PHY_RG_ZCALEN_B			BIT(12)
-#define   MTK_PHY_RG_ZCALEN_C			BIT(8)
-#define   MTK_PHY_RG_ZCALEN_D			BIT(4)
-#define   MTK_PHY_RG_TXVOS_CALEN		BIT(0)
-
-#define MTK_PHY_RG_ANA_CAL_RG5			0xe0
-#define   MTK_PHY_RG_REXT_TRIM_MASK		GENMASK(13, 8)
-
-#define MTK_PHY_RG_TX_FILTER			0xfe
-
-#define MTK_PHY_RG_LPI_PCS_DSP_CTRL_REG120	0x120
-#define   MTK_PHY_LPI_SIG_EN_LO_THRESH1000_MASK	GENMASK(12, 8)
-#define   MTK_PHY_LPI_SIG_EN_HI_THRESH1000_MASK	GENMASK(4, 0)
-
-#define MTK_PHY_RG_LPI_PCS_DSP_CTRL_REG122	0x122
-#define   MTK_PHY_LPI_NORM_MSE_HI_THRESH1000_MASK	GENMASK(7, 0)
-
-#define MTK_PHY_RG_TESTMUX_ADC_CTRL		0x144
-#define   MTK_PHY_RG_TXEN_DIG_MASK		GENMASK(5, 5)
-
-#define MTK_PHY_RG_CR_TX_AMP_OFFSET_A_B		0x172
-#define   MTK_PHY_CR_TX_AMP_OFFSET_A_MASK	GENMASK(13, 8)
-#define   MTK_PHY_CR_TX_AMP_OFFSET_B_MASK	GENMASK(6, 0)
-
-#define MTK_PHY_RG_CR_TX_AMP_OFFSET_C_D		0x173
-#define   MTK_PHY_CR_TX_AMP_OFFSET_C_MASK	GENMASK(13, 8)
-#define   MTK_PHY_CR_TX_AMP_OFFSET_D_MASK	GENMASK(6, 0)
-
-#define MTK_PHY_RG_AD_CAL_COMP			0x17a
-#define   MTK_PHY_AD_CAL_COMP_OUT_MASK		GENMASK(8, 8)
-
-#define MTK_PHY_RG_AD_CAL_CLK			0x17b
-#define   MTK_PHY_DA_CAL_CLK			BIT(0)
-
-#define MTK_PHY_RG_AD_CALIN			0x17c
-#define   MTK_PHY_DA_CALIN_FLAG			BIT(0)
-
-#define MTK_PHY_RG_DASN_DAC_IN0_A		0x17d
-#define   MTK_PHY_DASN_DAC_IN0_A_MASK		GENMASK(9, 0)
-
-#define MTK_PHY_RG_DASN_DAC_IN0_B		0x17e
-#define   MTK_PHY_DASN_DAC_IN0_B_MASK		GENMASK(9, 0)
-
-#define MTK_PHY_RG_DASN_DAC_IN0_C		0x17f
-#define   MTK_PHY_DASN_DAC_IN0_C_MASK		GENMASK(9, 0)
-
-#define MTK_PHY_RG_DASN_DAC_IN0_D		0x180
-#define   MTK_PHY_DASN_DAC_IN0_D_MASK		GENMASK(9, 0)
-
-#define MTK_PHY_RG_DASN_DAC_IN1_A		0x181
-#define   MTK_PHY_DASN_DAC_IN1_A_MASK		GENMASK(9, 0)
-
-#define MTK_PHY_RG_DASN_DAC_IN1_B		0x182
-#define   MTK_PHY_DASN_DAC_IN1_B_MASK		GENMASK(9, 0)
-
-#define MTK_PHY_RG_DASN_DAC_IN1_C		0x183
-#define   MTK_PHY_DASN_DAC_IN1_C_MASK		GENMASK(9, 0)
-
-#define MTK_PHY_RG_DASN_DAC_IN1_D		0x184
-#define   MTK_PHY_DASN_DAC_IN1_D_MASK		GENMASK(9, 0)
-
-#define MTK_PHY_RG_DEV1E_REG19b			0x19b
-#define   MTK_PHY_BYPASS_DSP_LPI_READY		BIT(8)
-
-#define MTK_PHY_RG_LP_IIR2_K1_L			0x22a
-#define MTK_PHY_RG_LP_IIR2_K1_U			0x22b
-#define MTK_PHY_RG_LP_IIR2_K2_L			0x22c
-#define MTK_PHY_RG_LP_IIR2_K2_U			0x22d
-#define MTK_PHY_RG_LP_IIR2_K3_L			0x22e
-#define MTK_PHY_RG_LP_IIR2_K3_U			0x22f
-#define MTK_PHY_RG_LP_IIR2_K4_L			0x230
-#define MTK_PHY_RG_LP_IIR2_K4_U			0x231
-#define MTK_PHY_RG_LP_IIR2_K5_L			0x232
-#define MTK_PHY_RG_LP_IIR2_K5_U			0x233
-
-#define MTK_PHY_RG_DEV1E_REG234			0x234
-#define   MTK_PHY_TR_OPEN_LOOP_EN_MASK		GENMASK(0, 0)
-#define   MTK_PHY_LPF_X_AVERAGE_MASK		GENMASK(7, 4)
-#define   MTK_PHY_TR_LP_IIR_EEE_EN		BIT(12)
-
-#define MTK_PHY_RG_LPF_CNT_VAL			0x235
-
-#define MTK_PHY_RG_DEV1E_REG238			0x238
-#define   MTK_PHY_LPI_SLV_SEND_TX_TIMER_MASK	GENMASK(8, 0)
-#define   MTK_PHY_LPI_SLV_SEND_TX_EN		BIT(12)
-
-#define MTK_PHY_RG_DEV1E_REG239			0x239
-#define   MTK_PHY_LPI_SEND_LOC_TIMER_MASK	GENMASK(8, 0)
-#define   MTK_PHY_LPI_TXPCS_LOC_RCV		BIT(12)
-
-#define MTK_PHY_RG_DEV1E_REG27C			0x27c
-#define   MTK_PHY_VGASTATE_FFE_THR_ST1_MASK	GENMASK(12, 8)
-#define MTK_PHY_RG_DEV1E_REG27D			0x27d
-#define   MTK_PHY_VGASTATE_FFE_THR_ST2_MASK	GENMASK(4, 0)
-
-#define MTK_PHY_RG_DEV1E_REG2C7			0x2c7
-#define   MTK_PHY_MAX_GAIN_MASK			GENMASK(4, 0)
-#define   MTK_PHY_MIN_GAIN_MASK			GENMASK(12, 8)
-
-#define MTK_PHY_RG_DEV1E_REG2D1			0x2d1
-#define   MTK_PHY_VCO_SLICER_THRESH_BITS_HIGH_EEE_MASK	GENMASK(7, 0)
-#define   MTK_PHY_LPI_SKIP_SD_SLV_TR		BIT(8)
-#define   MTK_PHY_LPI_TR_READY			BIT(9)
-#define   MTK_PHY_LPI_VCO_EEE_STG0_EN		BIT(10)
-
-#define MTK_PHY_RG_DEV1E_REG323			0x323
-#define   MTK_PHY_EEE_WAKE_MAS_INT_DC		BIT(0)
-#define   MTK_PHY_EEE_WAKE_SLV_INT_DC		BIT(4)
-
-#define MTK_PHY_RG_DEV1E_REG324			0x324
-#define   MTK_PHY_SMI_DETCNT_MAX_MASK		GENMASK(5, 0)
-#define   MTK_PHY_SMI_DET_MAX_EN		BIT(8)
-
-#define MTK_PHY_RG_DEV1E_REG326			0x326
-#define   MTK_PHY_LPI_MODE_SD_ON		BIT(0)
-#define   MTK_PHY_RESET_RANDUPD_CNT		BIT(1)
-#define   MTK_PHY_TREC_UPDATE_ENAB_CLR		BIT(2)
-#define   MTK_PHY_LPI_QUIT_WAIT_DFE_SIG_DET_OFF	BIT(4)
-#define   MTK_PHY_TR_READY_SKIP_AFE_WAKEUP	BIT(5)
-
-#define MTK_PHY_LDO_PUMP_EN_PAIRAB		0x502
-#define MTK_PHY_LDO_PUMP_EN_PAIRCD		0x503
-
-#define MTK_PHY_DA_TX_R50_PAIR_A		0x53d
-#define MTK_PHY_DA_TX_R50_PAIR_B		0x53e
-#define MTK_PHY_DA_TX_R50_PAIR_C		0x53f
-#define MTK_PHY_DA_TX_R50_PAIR_D		0x540
-
-/* Registers on MDIO_MMD_VEND2 */
-#define MTK_PHY_LED1_DEFAULT_POLARITIES		BIT(1)
-
-/* LED basic control register, part of the same LED block as the LED0/LED1
- * control registers above. The air_en8811h driver describes the same
- * register as AIR_PHY_LED_BCR.
- */
-#define MTK_PHY_LED_BCR				0x21
-#define   MTK_PHY_LED_BCR_CLK_EN		BIT(3)
-#define   MTK_PHY_LED_BCR_EXT_CTRL		BIT(15)
-
-#define MTK_PHY_RG_BG_RASEL			0x115
-#define   MTK_PHY_RG_BG_RASEL_MASK		GENMASK(2, 0)
-
-/* 'boottrap' register reflecting the configuration of the 4 PHY LEDs */
-#define RG_GPIO_MISC_TPBANK0			0x6f0
-#define   RG_GPIO_MISC_TPBANK0_BOOTMODE		GENMASK(11, 8)
-
 /* These macro privides efuse parsing for internal phy. */
 #define EFS_DA_TX_I2MPB_A(x)			(((x) >> 0) & GENMASK(5, 0))
 #define EFS_DA_TX_I2MPB_B(x)			(((x) >> 6) & GENMASK(5, 0))
@@ -355,51 +34,16 @@
 #define EFS_RG_BG_RASEL(x)			(((x) >> 4) & GENMASK(2, 0))
 #define EFS_RG_REXT_TRIM(x)			(((x) >> 7) & GENMASK(5, 0))
 
-enum {
-	NO_PAIR,
-	PAIR_A,
-	PAIR_B,
-	PAIR_C,
-	PAIR_D,
-};
-
-enum calibration_mode {
-	EFUSE_K,
-	SW_K
-};
-
-enum CAL_ITEM {
-	REXT,
-	TX_OFFSET,
-	TX_AMP,
-	TX_R50,
-	TX_VCM
-};
-
-enum CAL_MODE {
-	EFUSE_M,
-	SW_M
-};
-
 struct mtk_socphy_shared {
 	u32			boottrap;
 	struct mtk_socphy_priv	priv[4];
 };
 
-/* One calibration cycle consists of:
- * 1.Set DA_CALIN_FLAG high to start calibration. Keep it high
- *   until AD_CAL_COMP is ready to output calibration result.
- * 2.Wait until DA_CAL_CLK is available.
- * 3.Fetch AD_CAL_COMP_OUT.
- */
-static int cal_cycle(struct phy_device *phydev, int devad,
-		     u32 regnum, u16 mask, u16 cal_val)
+int mtk_cal_cycle_wait(struct phy_device *phydev)
 {
 	int reg_val;
 	int ret;
 
-	phy_modify_mmd(phydev, devad, regnum,
-		       mask, cal_val);
 	phy_set_bits_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_RG_AD_CALIN,
 			 MTK_PHY_DA_CALIN_FLAG);
 
@@ -418,7 +62,26 @@ static int cal_cycle(struct phy_device *phydev, int devad,
 	ret = phy_read_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_RG_AD_CAL_COMP);
 	if (ret < 0)
 		return ret;
-	ret = FIELD_GET(MTK_PHY_AD_CAL_COMP_OUT_MASK, ret);
+
+	return FIELD_GET(MTK_PHY_AD_CAL_COMP_OUT_MASK, ret);
+}
+EXPORT_SYMBOL_GPL(mtk_cal_cycle_wait);
+
+/* One calibration cycle consists of:
+ * 1.Set DA_CALIN_FLAG high to start calibration. Keep it high
+ *   until AD_CAL_COMP is ready to output calibration result.
+ * 2.Wait until DA_CAL_CLK is available.
+ * 3.Fetch AD_CAL_COMP_OUT.
+ */
+static int cal_cycle(struct phy_device *phydev, int devad,
+		     u32 regnum, u16 mask, u16 cal_val)
+{
+	int ret;
+
+	phy_modify_mmd(phydev, devad, regnum,
+		       mask, cal_val);
+
+	ret = mtk_cal_cycle_wait(phydev);
 	phydev_dbg(phydev, "cal_val: 0x%x, ret: %d\n", cal_val, ret);
 
 	return ret;
@@ -1224,73 +887,6 @@ static int mt798x_phy_config_init(struct phy_device *phydev)
 	return mt798x_phy_calibration(phydev);
 }
 
-static int mt798x_phy_led_blink_set(struct phy_device *phydev, u8 index,
-				    unsigned long *delay_on,
-				    unsigned long *delay_off)
-{
-	bool blinking = false;
-	int err;
-
-	err = mtk_phy_led_num_dly_cfg(index, delay_on, delay_off, &blinking);
-	if (err < 0)
-		return err;
-
-	err = mtk_phy_hw_led_blink_set(phydev, index, blinking);
-	if (err)
-		return err;
-
-	return mtk_phy_hw_led_on_set(phydev, index, MTK_GPHY_LED_ON_MASK,
-				     false);
-}
-
-static int mt798x_phy_led_brightness_set(struct phy_device *phydev,
-					 u8 index, enum led_brightness value)
-{
-	int err;
-
-	err = mtk_phy_hw_led_blink_set(phydev, index, false);
-	if (err)
-		return err;
-
-	return mtk_phy_hw_led_on_set(phydev, index, MTK_GPHY_LED_ON_MASK,
-				     (value != LED_OFF));
-}
-
-static const unsigned long supported_triggers =
-	BIT(TRIGGER_NETDEV_FULL_DUPLEX) |
-	BIT(TRIGGER_NETDEV_HALF_DUPLEX) |
-	BIT(TRIGGER_NETDEV_LINK)        |
-	BIT(TRIGGER_NETDEV_LINK_10)     |
-	BIT(TRIGGER_NETDEV_LINK_100)    |
-	BIT(TRIGGER_NETDEV_LINK_1000)   |
-	BIT(TRIGGER_NETDEV_RX)          |
-	BIT(TRIGGER_NETDEV_TX);
-
-static int mt798x_phy_led_hw_is_supported(struct phy_device *phydev, u8 index,
-					  unsigned long rules)
-{
-	return mtk_phy_led_hw_is_supported(phydev, index, rules,
-					   supported_triggers);
-}
-
-static int mt798x_phy_led_hw_control_get(struct phy_device *phydev, u8 index,
-					 unsigned long *rules)
-{
-	return mtk_phy_led_hw_ctrl_get(phydev, index, rules,
-				       MTK_GPHY_LED_ON_SET,
-				       MTK_GPHY_LED_RX_BLINK_SET,
-				       MTK_GPHY_LED_TX_BLINK_SET);
-};
-
-static int mt798x_phy_led_hw_control_set(struct phy_device *phydev, u8 index,
-					 unsigned long rules)
-{
-	return mtk_phy_led_hw_ctrl_set(phydev, index, rules,
-				       MTK_GPHY_LED_ON_SET,
-				       MTK_GPHY_LED_RX_BLINK_SET,
-				       MTK_GPHY_LED_TX_BLINK_SET);
-};
-
 static bool mt7988_phy_led_get_polarity(struct phy_device *phydev, int led_num)
 {
 	struct mtk_socphy_shared *priv = phy_package_get_priv(phydev);
@@ -1427,71 +1023,6 @@ static int mt7981_phy_probe(struct phy_device *phydev)
 	return mt798x_phy_calibration(phydev);
 }
 
-static int an7581_phy_probe(struct phy_device *phydev)
-{
-	struct mtk_socphy_priv *priv;
-	struct pinctrl *pinctrl;
-
-	/* Toggle pinctrl to enable PHY LED */
-	pinctrl = devm_pinctrl_get_select(&phydev->mdio.dev, "gbe-led");
-	if (IS_ERR(pinctrl))
-		dev_err(&phydev->mdio.bus->dev,
-			"Failed to setup PHY LED pinctrl\n");
-
-	priv = devm_kzalloc(&phydev->mdio.dev, sizeof(*priv), GFP_KERNEL);
-	if (!priv)
-		return -ENOMEM;
-
-	phydev->priv = priv;
-
-	return 0;
-}
-
-static int an7581_phy_led_polarity_set(struct phy_device *phydev, int index,
-				       unsigned long modes)
-{
-	u16 val = 0;
-	u32 mode;
-
-	if (index >= MTK_PHY_MAX_LEDS)
-		return -EINVAL;
-
-	for_each_set_bit(mode, &modes, __PHY_LED_MODES_NUM) {
-		switch (mode) {
-		case PHY_LED_ACTIVE_LOW:
-			val = MTK_PHY_LED_ON_POLARITY;
-			break;
-		case PHY_LED_ACTIVE_HIGH:
-			break;
-		default:
-			return -EINVAL;
-		}
-	}
-
-	return phy_modify_mmd(phydev, MDIO_MMD_VEND2, index ?
-			      MTK_PHY_LED1_ON_CTRL : MTK_PHY_LED0_ON_CTRL,
-			      MTK_PHY_LED_ON_POLARITY, val);
-}
-
-static int an7583_phy_config_init(struct phy_device *phydev)
-{
-	/* BMCR_PDOWN is enabled by default */
-	return phy_clear_bits(phydev, MII_BMCR, BMCR_PDOWN);
-}
-
-static int en7528_phy_config_init(struct phy_device *phydev)
-{
-	/* The LED controller of the EN7528 powers up with its external
-	 * control disabled, leaving the LED pins dark regardless of what is
-	 * programmed into the LED control registers. Hand the pins over to
-	 * the LED control registers the same way the air_en8811h driver
-	 * does; the mode field of this register is already set out of reset.
-	 */
-	return phy_set_bits_mmd(phydev, MDIO_MMD_VEND2, MTK_PHY_LED_BCR,
-				MTK_PHY_LED_BCR_CLK_EN |
-				MTK_PHY_LED_BCR_EXT_CTRL);
-}
-
 static struct phy_driver mtk_socphy_driver[] = {
 	{
 		PHY_ID_MATCH_EXACT(MTK_GPHY_ID_MT7981),
@@ -1527,43 +1058,6 @@ static struct phy_driver mtk_socphy_driver[] = {
 		.led_hw_control_set = mt798x_phy_led_hw_control_set,
 		.led_hw_control_get = mt798x_phy_led_hw_control_get,
 	},
-	{
-		PHY_ID_MATCH_EXACT(MTK_GPHY_ID_EN7528),
-		.name		= "EcoNet EN7528 PHY",
-		.config_init	= en7528_phy_config_init,
-		.probe		= an7581_phy_probe,
-		.led_blink_set	= mt798x_phy_led_blink_set,
-		.led_brightness_set = mt798x_phy_led_brightness_set,
-		.led_hw_is_supported = mt798x_phy_led_hw_is_supported,
-		.led_hw_control_set = mt798x_phy_led_hw_control_set,
-		.led_hw_control_get = mt798x_phy_led_hw_control_get,
-		.led_polarity_set = an7581_phy_led_polarity_set,
-	},
-	{
-		PHY_ID_MATCH_EXACT(MTK_GPHY_ID_AN7581),
-		.name		= "Airoha AN7581 PHY",
-		.config_intr	= genphy_no_config_intr,
-		.handle_interrupt = genphy_handle_interrupt_no_ack,
-		.probe		= an7581_phy_probe,
-		.led_blink_set	= mt798x_phy_led_blink_set,
-		.led_brightness_set = mt798x_phy_led_brightness_set,
-		.led_hw_is_supported = mt798x_phy_led_hw_is_supported,
-		.led_hw_control_set = mt798x_phy_led_hw_control_set,
-		.led_hw_control_get = mt798x_phy_led_hw_control_get,
-		.led_polarity_set = an7581_phy_led_polarity_set,
-	},
-	{
-		PHY_ID_MATCH_EXACT(MTK_GPHY_ID_AN7583),
-		.name		= "Airoha AN7583 PHY",
-		.config_init	= an7583_phy_config_init,
-		.probe		= an7581_phy_probe,
-		.led_blink_set	= mt798x_phy_led_blink_set,
-		.led_brightness_set = mt798x_phy_led_brightness_set,
-		.led_hw_is_supported = mt798x_phy_led_hw_is_supported,
-		.led_hw_control_set = mt798x_phy_led_hw_control_set,
-		.led_hw_control_get = mt798x_phy_led_hw_control_get,
-		.led_polarity_set = an7581_phy_led_polarity_set,
-	},
 };
 
 module_phy_driver(mtk_socphy_driver);
@@ -1571,9 +1065,6 @@ module_phy_driver(mtk_socphy_driver);
 static const struct mdio_device_id __maybe_unused mtk_socphy_tbl[] = {
 	{ PHY_ID_MATCH_EXACT(MTK_GPHY_ID_MT7981) },
 	{ PHY_ID_MATCH_EXACT(MTK_GPHY_ID_MT7988) },
-	{ PHY_ID_MATCH_EXACT(MTK_GPHY_ID_EN7528) },
-	{ PHY_ID_MATCH_EXACT(MTK_GPHY_ID_AN7581) },
-	{ PHY_ID_MATCH_EXACT(MTK_GPHY_ID_AN7583) },
 	{ }
 };
 
diff --git a/drivers/net/phy/mediatek/mtk-ge-soc.h b/drivers/net/phy/mediatek/mtk-ge-soc.h
new file mode 100644
index 0000000000000..d6baff245deae
--- /dev/null
+++ b/drivers/net/phy/mediatek/mtk-ge-soc.h
@@ -0,0 +1,377 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+
+#ifndef _MTK_GE_SOC_H_
+#define _MTK_GE_SOC_H_
+
+#include <linux/bitfield.h>
+
+#define MTK_GPHY_ID_MT7981			0x03a29461
+#define MTK_GPHY_ID_MT7988			0x03a29481
+#define AIROHA_GPHY_ID_EN7528			0x03a29491
+#define AIROHA_GPHY_ID_AN7581			0x03a294c1
+#define AIROHA_GPHY_ID_AN7583			0xc0ff0420
+
+#define MTK_EXT_PAGE_ACCESS			0x1f
+#define MTK_PHY_PAGE_STANDARD			0x0000
+#define MTK_PHY_PAGE_EXTENDED_1			0x0001
+#define MTK_PHY_PAGE_EXTENDED_3			0x0003
+
+#define MTK_PHY_LPI_REG_14			0x14
+#define MTK_PHY_LPI_WAKE_TIMER_1000_MASK	GENMASK(8, 0)
+
+#define MTK_PHY_LPI_REG_1c			0x1c
+#define MTK_PHY_SMI_DET_ON_THRESH_MASK		GENMASK(13, 8)
+
+#define MTK_PHY_PAGE_EXTENDED_2A30		0x2a30
+
+/* Registers on Token Ring debug nodes */
+/* ch_addr = 0x0, node_addr = 0x7, data_addr = 0x15 */
+/* NormMseLoThresh */
+#define NORMAL_MSE_LO_THRESH_MASK		GENMASK(15, 8)
+
+/* ch_addr = 0x0, node_addr = 0xf, data_addr = 0x3c */
+/* RemAckCntLimitCtrl */
+#define REMOTE_ACK_COUNT_LIMIT_CTRL_MASK	GENMASK(2, 1)
+
+/* ch_addr = 0x1, node_addr = 0xd, data_addr = 0x20 */
+/* VcoSlicerThreshBitsHigh */
+#define VCO_SLICER_THRESH_HIGH_MASK		GENMASK(23, 0)
+
+/* ch_addr = 0x1, node_addr = 0xf, data_addr = 0x0 */
+/* DfeTailEnableVgaThresh1000 */
+#define DFE_TAIL_EANBLE_VGA_TRHESH_1000		GENMASK(5, 1)
+
+/* ch_addr = 0x1, node_addr = 0xf, data_addr = 0x1 */
+/* MrvlTrFix100Kp */
+#define MRVL_TR_FIX_100KP_MASK			GENMASK(22, 20)
+/* MrvlTrFix100Kf */
+#define MRVL_TR_FIX_100KF_MASK			GENMASK(19, 17)
+/* MrvlTrFix1000Kp */
+#define MRVL_TR_FIX_1000KP_MASK			GENMASK(16, 14)
+/* MrvlTrFix1000Kf */
+#define MRVL_TR_FIX_1000KF_MASK			GENMASK(13, 11)
+
+/* ch_addr = 0x1, node_addr = 0xf, data_addr = 0x12 */
+/* VgaDecRate */
+#define VGA_DECIMATION_RATE_MASK		GENMASK(8, 5)
+
+/* ch_addr = 0x1, node_addr = 0xf, data_addr = 0x17 */
+/* SlvDSPreadyTime */
+#define SLAVE_DSP_READY_TIME_MASK		GENMASK(22, 15)
+/* MasDSPreadyTime */
+#define MASTER_DSP_READY_TIME_MASK		GENMASK(14, 7)
+
+/* ch_addr = 0x1, node_addr = 0xf, data_addr = 0x18 */
+/* EnabRandUpdTrig */
+#define ENABLE_RANDOM_UPDOWN_COUNTER_TRIGGER	BIT(8)
+
+/* ch_addr = 0x1, node_addr = 0xf, data_addr = 0x20 */
+/* ResetSyncOffset */
+#define RESET_SYNC_OFFSET_MASK			GENMASK(11, 8)
+
+/* ch_addr = 0x2, node_addr = 0xd, data_addr = 0x0 */
+/* FfeUpdGainForceVal */
+#define FFE_UPDATE_GAIN_FORCE_VAL_MASK		GENMASK(9, 7)
+/* FfeUpdGainForce */
+#define FFE_UPDATE_GAIN_FORCE			BIT(6)
+
+/* ch_addr = 0x2, node_addr = 0xd, data_addr = 0x3 */
+/* TrFreeze */
+#define TR_FREEZE_MASK				GENMASK(11, 0)
+
+/* ch_addr = 0x2, node_addr = 0xd, data_addr = 0x6 */
+/* SS: Steady-state, KP: Proportional Gain */
+/* SSTrKp100 */
+#define SS_TR_KP100_MASK			GENMASK(21, 19)
+/* SSTrKf100 */
+#define SS_TR_KF100_MASK			GENMASK(18, 16)
+/* SSTrKp1000Mas */
+#define SS_TR_KP1000_MASTER_MASK		GENMASK(15, 13)
+/* SSTrKf1000Mas */
+#define SS_TR_KF1000_MASTER_MASK		GENMASK(12, 10)
+/* SSTrKp1000Slv */
+#define SS_TR_KP1000_SLAVE_MASK			GENMASK(9, 7)
+/* SSTrKf1000Slv */
+#define SS_TR_KF1000_SLAVE_MASK			GENMASK(6, 4)
+
+/* ch_addr = 0x2, node_addr = 0xd, data_addr = 0x8 */
+/* clear this bit if wanna select from AFE */
+/* Regsigdet_sel_1000 */
+#define EEE1000_SELECT_SIGNAL_DETECTION_FROM_DFE	BIT(4)
+
+/* ch_addr = 0x2, node_addr = 0xd, data_addr = 0xd */
+/* RegEEE_st2TrKf1000 */
+#define EEE1000_STAGE2_TR_KF_MASK		GENMASK(13, 11)
+
+/* ch_addr = 0x2, node_addr = 0xd, data_addr = 0xf */
+/* RegEEE_slv_waketr_timer_tar */
+#define SLAVE_WAKETR_TIMER_MASK			GENMASK(20, 11)
+/* RegEEE_slv_remtx_timer_tar */
+#define SLAVE_REMTX_TIMER_MASK			GENMASK(10, 1)
+
+/* ch_addr = 0x2, node_addr = 0xd, data_addr = 0x10 */
+/* RegEEE_slv_wake_int_timer_tar */
+#define SLAVE_WAKEINT_TIMER_MASK		GENMASK(10, 1)
+
+/* ch_addr = 0x2, node_addr = 0xd, data_addr = 0x14 */
+/* RegEEE_trfreeze_timer2 */
+#define TR_FREEZE_TIMER2_MASK			GENMASK(9, 0)
+
+/* ch_addr = 0x2, node_addr = 0xd, data_addr = 0x1c */
+/* RegEEE100Stg1_tar */
+#define EEE100_LPSYNC_STAGE1_UPDATE_TIMER_MASK	GENMASK(8, 0)
+
+/* ch_addr = 0x2, node_addr = 0xd, data_addr = 0x25 */
+/* REGEEE_wake_slv_tr_wait_dfesigdet_en */
+#define WAKE_SLAVE_TR_WAIT_DFE_DETECTION_EN	BIT(11)
+
+#define ANALOG_INTERNAL_OPERATION_MAX_US	20
+#define TXRESERVE_MIN				0
+#define TXRESERVE_MAX				7
+
+#define MTK_PHY_ANARG_RG			0x10
+#define   MTK_PHY_TCLKOFFSET_MASK		GENMASK(12, 8)
+
+/* Registers on MDIO_MMD_VEND1 */
+#define MTK_PHY_TXVLD_DA_RG			0x12
+#define   MTK_PHY_DA_TX_I2MPB_A_GBE_MASK	GENMASK(15, 10)
+#define   MTK_PHY_DA_TX_I2MPB_A_TBT_MASK	GENMASK(5, 0)
+
+#define MTK_PHY_TX_I2MPB_TEST_MODE_A2		0x16
+#define   MTK_PHY_DA_TX_I2MPB_A_HBT_MASK	GENMASK(15, 10)
+#define   MTK_PHY_DA_TX_I2MPB_A_TST_MASK	GENMASK(5, 0)
+
+#define MTK_PHY_TX_I2MPB_TEST_MODE_B1		0x17
+#define   MTK_PHY_DA_TX_I2MPB_B_GBE_MASK	GENMASK(13, 8)
+#define   MTK_PHY_DA_TX_I2MPB_B_TBT_MASK	GENMASK(5, 0)
+
+#define MTK_PHY_TX_I2MPB_TEST_MODE_B2		0x18
+#define   MTK_PHY_DA_TX_I2MPB_B_HBT_MASK	GENMASK(13, 8)
+#define   MTK_PHY_DA_TX_I2MPB_B_TST_MASK	GENMASK(5, 0)
+
+#define MTK_PHY_TX_I2MPB_TEST_MODE_C1		0x19
+#define   MTK_PHY_DA_TX_I2MPB_C_GBE_MASK	GENMASK(13, 8)
+#define   MTK_PHY_DA_TX_I2MPB_C_TBT_MASK	GENMASK(5, 0)
+
+#define MTK_PHY_TX_I2MPB_TEST_MODE_C2		0x20
+#define   MTK_PHY_DA_TX_I2MPB_C_HBT_MASK	GENMASK(13, 8)
+#define   MTK_PHY_DA_TX_I2MPB_C_TST_MASK	GENMASK(5, 0)
+
+#define MTK_PHY_TX_I2MPB_TEST_MODE_D1		0x21
+#define   MTK_PHY_DA_TX_I2MPB_D_GBE_MASK	GENMASK(13, 8)
+#define   MTK_PHY_DA_TX_I2MPB_D_TBT_MASK	GENMASK(5, 0)
+
+#define MTK_PHY_TX_I2MPB_TEST_MODE_D2		0x22
+#define   MTK_PHY_DA_TX_I2MPB_D_HBT_MASK	GENMASK(13, 8)
+#define   MTK_PHY_DA_TX_I2MPB_D_TST_MASK	GENMASK(5, 0)
+
+#define MTK_PHY_RXADC_CTRL_RG7			0xc6
+#define   MTK_PHY_DA_AD_BUF_BIAS_LP_MASK	GENMASK(9, 8)
+
+#define MTK_PHY_RXADC_CTRL_RG9			0xc8
+#define   MTK_PHY_DA_RX_PSBN_TBT_MASK		GENMASK(14, 12)
+#define   MTK_PHY_DA_RX_PSBN_HBT_MASK		GENMASK(10, 8)
+#define   MTK_PHY_DA_RX_PSBN_GBE_MASK		GENMASK(6, 4)
+#define   MTK_PHY_DA_RX_PSBN_LP_MASK		GENMASK(2, 0)
+
+#define MTK_PHY_LDO_OUTPUT_V			0xd7
+
+#define MTK_PHY_RG_ANA_CAL_RG0			0xdb
+#define   MTK_PHY_RG_CAL_CKINV			BIT(12)
+#define   MTK_PHY_RG_ANA_CALEN			BIT(8)
+#define   MTK_PHY_RG_REXT_CALEN			BIT(4)
+#define   MTK_PHY_RG_ZCALEN_A			BIT(0)
+
+#define MTK_PHY_RG_ANA_CAL_RG1			0xdc
+#define   MTK_PHY_RG_ZCALEN_B			BIT(12)
+#define   MTK_PHY_RG_ZCALEN_C			BIT(8)
+#define   MTK_PHY_RG_ZCALEN_D			BIT(4)
+#define   MTK_PHY_RG_TXVOS_CALEN		BIT(0)
+
+#define MTK_PHY_RG_ANA_CAL_RG5			0xe0
+#define   MTK_PHY_RG_REXT_TRIM_MASK		GENMASK(13, 8)
+#define   MTK_PHY_RG_REXT_ZCAL_CTRL_MASK	GENMASK(5, 0)
+
+#define MTK_PHY_RG_ANA_CAL_RG6			0xe1
+
+#define MTK_PHY_RG_TX_FILTER			0xfe
+
+#define MTK_PHY_RG_LPI_PCS_DSP_CTRL_REG120	0x120
+#define   MTK_PHY_LPI_SIG_EN_LO_THRESH1000_MASK	GENMASK(12, 8)
+#define   MTK_PHY_LPI_SIG_EN_HI_THRESH1000_MASK	GENMASK(4, 0)
+
+#define MTK_PHY_RG_LPI_PCS_DSP_CTRL_REG122	0x122
+#define   MTK_PHY_LPI_NORM_MSE_HI_THRESH1000_MASK	GENMASK(7, 0)
+
+#define MTK_PHY_RG_TESTMUX_ADC_CTRL		0x144
+#define   MTK_PHY_RG_TXEN_DIG_MASK		GENMASK(5, 5)
+
+#define MTK_PHY_RG_CR_TX_AMP_OFFSET_A_B		0x172
+#define   MTK_PHY_CR_TX_AMP_OFFSET_A_MASK	GENMASK(13, 8)
+#define   MTK_PHY_CR_TX_AMP_OFFSET_B_MASK	GENMASK(6, 0)
+#define   AIROHA_PHY_CR_TX_AMP_OFFSET_B_MASK	GENMASK(5, 0)
+
+#define MTK_PHY_RG_CR_TX_AMP_OFFSET_C_D		0x173
+#define   MTK_PHY_CR_TX_AMP_OFFSET_C_MASK	GENMASK(13, 8)
+#define   MTK_PHY_CR_TX_AMP_OFFSET_D_MASK	GENMASK(6, 0)
+#define   AIROHA_PHY_CR_TX_AMP_OFFSET_D_MASK	GENMASK(5, 0)
+
+#define MTK_PHY_RG_CR_TX_R50_OFFSET_A_B		0x174
+#define   MTK_PHY_CR_TX_R50_OFFSET_A_MASK	GENMASK(13, 8)
+#define   AIROHA_PHY_CR_TX_R50_OFFSET_A_MASK	GENMASK(14, 8)
+#define   MTK_PHY_CR_TX_R50_OFFSET_B_MASK	GENMASK(6, 0)
+
+#define MTK_PHY_RG_CR_TX_R50_OFFSET_C_D		0x175
+#define   MTK_PHY_CR_TX_R50_OFFSET_C_MASK	GENMASK(13, 8)
+#define   AIROHA_PHY_CR_TX_R50_OFFSET_C_MASK	GENMASK(14, 8)
+#define   MTK_PHY_CR_TX_R50_OFFSET_D_MASK	GENMASK(6, 0)
+
+#define MTK_PHY_RG_AD_CAL_COMP			0x17a
+#define   MTK_PHY_AD_CAL_COMP_OUT_MASK		GENMASK(8, 8)
+
+#define MTK_PHY_RG_AD_CAL_CLK			0x17b
+#define   MTK_PHY_DA_CAL_CLK			BIT(0)
+
+#define MTK_PHY_RG_AD_CALIN			0x17c
+#define   MTK_PHY_DA_CALIN_FLAG			BIT(0)
+
+#define MTK_PHY_RG_DASN_DAC_IN0_A		0x17d
+#define   MTK_PHY_DASN_DAC_IN0_A_MASK		GENMASK(9, 0)
+
+#define MTK_PHY_RG_DASN_DAC_IN0_B		0x17e
+#define   MTK_PHY_DASN_DAC_IN0_B_MASK		GENMASK(9, 0)
+
+#define MTK_PHY_RG_DASN_DAC_IN0_C		0x17f
+#define   MTK_PHY_DASN_DAC_IN0_C_MASK		GENMASK(9, 0)
+
+#define MTK_PHY_RG_DASN_DAC_IN0_D		0x180
+#define   MTK_PHY_DASN_DAC_IN0_D_MASK		GENMASK(9, 0)
+
+#define MTK_PHY_RG_DASN_DAC_IN1_A		0x181
+#define   MTK_PHY_DASN_DAC_IN1_A_MASK		GENMASK(9, 0)
+
+#define MTK_PHY_RG_DASN_DAC_IN1_B		0x182
+#define   MTK_PHY_DASN_DAC_IN1_B_MASK		GENMASK(9, 0)
+
+#define MTK_PHY_RG_DASN_DAC_IN1_C		0x183
+#define   MTK_PHY_DASN_DAC_IN1_C_MASK		GENMASK(9, 0)
+
+#define MTK_PHY_RG_DASN_DAC_IN1_D		0x184
+#define   MTK_PHY_DASN_DAC_IN1_D_MASK		GENMASK(9, 0)
+
+#define MTK_PHY_RG_DEV1E_REG19b			0x19b
+#define   MTK_PHY_BYPASS_DSP_LPI_READY		BIT(8)
+
+#define MTK_PHY_RG_LP_IIR2_K1_L			0x22a
+#define MTK_PHY_RG_LP_IIR2_K1_U			0x22b
+#define MTK_PHY_RG_LP_IIR2_K2_L			0x22c
+#define MTK_PHY_RG_LP_IIR2_K2_U			0x22d
+#define MTK_PHY_RG_LP_IIR2_K3_L			0x22e
+#define MTK_PHY_RG_LP_IIR2_K3_U			0x22f
+#define MTK_PHY_RG_LP_IIR2_K4_L			0x230
+#define MTK_PHY_RG_LP_IIR2_K4_U			0x231
+#define MTK_PHY_RG_LP_IIR2_K5_L			0x232
+#define MTK_PHY_RG_LP_IIR2_K5_U			0x233
+
+#define MTK_PHY_RG_DEV1E_REG234			0x234
+#define   MTK_PHY_TR_OPEN_LOOP_EN_MASK		GENMASK(0, 0)
+#define   MTK_PHY_LPF_X_AVERAGE_MASK		GENMASK(7, 4)
+#define   MTK_PHY_TR_LP_IIR_EEE_EN		BIT(12)
+
+#define MTK_PHY_RG_LPF_CNT_VAL			0x235
+
+#define MTK_PHY_RG_DEV1E_REG238			0x238
+#define   MTK_PHY_LPI_SLV_SEND_TX_TIMER_MASK	GENMASK(8, 0)
+#define   MTK_PHY_LPI_SLV_SEND_TX_EN		BIT(12)
+
+#define MTK_PHY_RG_DEV1E_REG239			0x239
+#define   MTK_PHY_LPI_SEND_LOC_TIMER_MASK	GENMASK(8, 0)
+#define   MTK_PHY_LPI_TXPCS_LOC_RCV		BIT(12)
+
+#define MTK_PHY_RG_DEV1E_REG27C			0x27c
+#define   MTK_PHY_VGASTATE_FFE_THR_ST1_MASK	GENMASK(12, 8)
+#define MTK_PHY_RG_DEV1E_REG27D			0x27d
+#define   MTK_PHY_VGASTATE_FFE_THR_ST2_MASK	GENMASK(4, 0)
+
+#define MTK_PHY_RG_DEV1E_REG2C7			0x2c7
+#define   MTK_PHY_MAX_GAIN_MASK			GENMASK(4, 0)
+#define   MTK_PHY_MIN_GAIN_MASK			GENMASK(12, 8)
+
+#define MTK_PHY_RG_DEV1E_REG2D1			0x2d1
+#define   MTK_PHY_VCO_SLICER_THRESH_BITS_HIGH_EEE_MASK	GENMASK(7, 0)
+#define   MTK_PHY_LPI_SKIP_SD_SLV_TR		BIT(8)
+#define   MTK_PHY_LPI_TR_READY			BIT(9)
+#define   MTK_PHY_LPI_VCO_EEE_STG0_EN		BIT(10)
+
+#define MTK_PHY_RG_DEV1E_REG323			0x323
+#define   MTK_PHY_EEE_WAKE_MAS_INT_DC		BIT(0)
+#define   MTK_PHY_EEE_WAKE_SLV_INT_DC		BIT(4)
+
+#define MTK_PHY_RG_DEV1E_REG324			0x324
+#define   MTK_PHY_SMI_DETCNT_MAX_MASK		GENMASK(5, 0)
+#define   MTK_PHY_SMI_DET_MAX_EN		BIT(8)
+
+#define MTK_PHY_RG_DEV1E_REG326			0x326
+#define   MTK_PHY_LPI_MODE_SD_ON		BIT(0)
+#define   MTK_PHY_RESET_RANDUPD_CNT		BIT(1)
+#define   MTK_PHY_TREC_UPDATE_ENAB_CLR		BIT(2)
+#define   MTK_PHY_LPI_QUIT_WAIT_DFE_SIG_DET_OFF	BIT(4)
+#define   MTK_PHY_TR_READY_SKIP_AFE_WAKEUP	BIT(5)
+
+#define MTK_PHY_LDO_PUMP_EN_PAIRAB		0x502
+#define MTK_PHY_LDO_PUMP_EN_PAIRCD		0x503
+
+#define MTK_PHY_DA_TX_R50_PAIR_A		0x53d
+#define MTK_PHY_DA_TX_R50_PAIR_B		0x53e
+#define MTK_PHY_DA_TX_R50_PAIR_C		0x53f
+#define MTK_PHY_DA_TX_R50_PAIR_D		0x540
+
+/* Registers on MDIO_MMD_VEND2 */
+#define MTK_PHY_LED1_DEFAULT_POLARITIES		BIT(1)
+
+/* LED basic control register, part of the same LED block as the LED0/LED1
+ * control registers above. The air_en8811h driver describes the same
+ * register as AIR_PHY_LED_BCR.
+ */
+#define MTK_PHY_LED_BCR				0x21
+#define   MTK_PHY_LED_BCR_CLK_EN		BIT(3)
+#define   MTK_PHY_LED_BCR_EXT_CTRL		BIT(15)
+
+#define MTK_PHY_RG_BG_RASEL			0x115
+#define   MTK_PHY_RG_BG_RASEL_MASK		GENMASK(2, 0)
+
+/* 'boottrap' register reflecting the configuration of the 4 PHY LEDs */
+#define RG_GPIO_MISC_TPBANK0			0x6f0
+#define   RG_GPIO_MISC_TPBANK0_BOOTMODE		GENMASK(11, 8)
+
+enum CAL_ITEM {
+	REXT,
+	TX_OFFSET,
+	TX_AMP,
+	TX_R50,
+	TX_VCM,
+	RX_OFFSET,
+};
+
+enum {
+	NO_PAIR,
+	PAIR_A,
+	PAIR_B,
+	PAIR_C,
+	PAIR_D,
+};
+
+enum calibration_mode {
+	EFUSE_K,
+	SW_K
+};
+
+enum CAL_MODE {
+	EFUSE_M,
+	SW_M
+};
+
+/* MTK GE SoC common functions */
+int mtk_cal_cycle_wait(struct phy_device *phydev);
+
+#endif /* _MTK_GE_SOC_H_ */
diff --git a/drivers/net/phy/mediatek/mtk-phy-lib.c b/drivers/net/phy/mediatek/mtk-phy-lib.c
index 4c4eca870bde1..dc4abd95d73fc 100644
--- a/drivers/net/phy/mediatek/mtk-phy-lib.c
+++ b/drivers/net/phy/mediatek/mtk-phy-lib.c
@@ -36,8 +36,8 @@ static void __mtk_tr_read(struct phy_device *phydev, u8 ch_addr, u8 node_addr,
 		*tr_high, *tr_low);
 }
 
-static void __mtk_tr_write(struct phy_device *phydev, u8 ch_addr, u8 node_addr,
-			   u8 data_addr, u32 tr_data)
+void __mtk_tr_write(struct phy_device *phydev, u8 ch_addr, u8 node_addr,
+		    u8 data_addr, u32 tr_data)
 {
 	__phy_write(phydev, 0x11, tr_data & 0xffff);
 	__phy_write(phydev, 0x12, tr_data >> 16);
@@ -45,6 +45,7 @@ static void __mtk_tr_write(struct phy_device *phydev, u8 ch_addr, u8 node_addr,
 		tr_data >> 16, tr_data & 0xffff);
 	__mtk_tr_access(phydev, false, ch_addr, node_addr, data_addr);
 }
+EXPORT_SYMBOL_GPL(__mtk_tr_write);
 
 void __mtk_tr_modify(struct phy_device *phydev, u8 ch_addr, u8 node_addr,
 		     u8 data_addr, u32 mask, u32 set)
@@ -338,6 +339,78 @@ void mtk_phy_leds_state_init(struct phy_device *phydev)
 }
 EXPORT_SYMBOL_GPL(mtk_phy_leds_state_init);
 
+int mt798x_phy_led_blink_set(struct phy_device *phydev, u8 index,
+			     unsigned long *delay_on,
+			     unsigned long *delay_off)
+{
+	bool blinking = false;
+	int err;
+
+	err = mtk_phy_led_num_dly_cfg(index, delay_on, delay_off, &blinking);
+	if (err < 0)
+		return err;
+
+	err = mtk_phy_hw_led_blink_set(phydev, index, blinking);
+	if (err)
+		return err;
+
+	return mtk_phy_hw_led_on_set(phydev, index, MTK_GPHY_LED_ON_MASK,
+				     false);
+}
+EXPORT_SYMBOL_GPL(mt798x_phy_led_blink_set);
+
+int mt798x_phy_led_brightness_set(struct phy_device *phydev,
+				  u8 index, enum led_brightness value)
+{
+	int err;
+
+	err = mtk_phy_hw_led_blink_set(phydev, index, false);
+	if (err)
+		return err;
+
+	return mtk_phy_hw_led_on_set(phydev, index, MTK_GPHY_LED_ON_MASK,
+				     (value != LED_OFF));
+}
+EXPORT_SYMBOL_GPL(mt798x_phy_led_brightness_set);
+
+static const unsigned long supported_triggers =
+	BIT(TRIGGER_NETDEV_FULL_DUPLEX) |
+	BIT(TRIGGER_NETDEV_HALF_DUPLEX) |
+	BIT(TRIGGER_NETDEV_LINK)        |
+	BIT(TRIGGER_NETDEV_LINK_10)     |
+	BIT(TRIGGER_NETDEV_LINK_100)    |
+	BIT(TRIGGER_NETDEV_LINK_1000)   |
+	BIT(TRIGGER_NETDEV_RX)          |
+	BIT(TRIGGER_NETDEV_TX);
+
+int mt798x_phy_led_hw_is_supported(struct phy_device *phydev, u8 index,
+				   unsigned long rules)
+{
+	return mtk_phy_led_hw_is_supported(phydev, index, rules,
+					   supported_triggers);
+}
+EXPORT_SYMBOL_GPL(mt798x_phy_led_hw_is_supported);
+
+int mt798x_phy_led_hw_control_get(struct phy_device *phydev, u8 index,
+				  unsigned long *rules)
+{
+	return mtk_phy_led_hw_ctrl_get(phydev, index, rules,
+				       MTK_GPHY_LED_ON_SET,
+				       MTK_GPHY_LED_RX_BLINK_SET,
+				       MTK_GPHY_LED_TX_BLINK_SET);
+};
+EXPORT_SYMBOL_GPL(mt798x_phy_led_hw_control_get);
+
+int mt798x_phy_led_hw_control_set(struct phy_device *phydev, u8 index,
+				  unsigned long rules)
+{
+	return mtk_phy_led_hw_ctrl_set(phydev, index, rules,
+				       MTK_GPHY_LED_ON_SET,
+				       MTK_GPHY_LED_RX_BLINK_SET,
+				       MTK_GPHY_LED_TX_BLINK_SET);
+};
+EXPORT_SYMBOL_GPL(mt798x_phy_led_hw_control_set);
+
 MODULE_DESCRIPTION("MediaTek Ethernet PHY driver common");
 MODULE_AUTHOR("Sky Huang <SkyLake.Huang@mediatek.com>");
 MODULE_AUTHOR("Daniel Golle <daniel@makrotopia.org>");
diff --git a/drivers/net/phy/mediatek/mtk.h b/drivers/net/phy/mediatek/mtk.h
index 79e09727b81bc..608e5e3d754f9 100644
--- a/drivers/net/phy/mediatek/mtk.h
+++ b/drivers/net/phy/mediatek/mtk.h
@@ -13,6 +13,7 @@
 
 #define MTK_EXT_PAGE_ACCESS			0x1f
 #define MTK_PHY_PAGE_EXTENDED_1			0x0001
+#define MTK_PHY_PAGE_EXTENDED_3			0x0003
 #define MTK_PHY_PAGE_STANDARD			0x0000
 #define MTK_PHY_PAGE_EXTENDED_52B5		0x52b5
 
@@ -72,6 +73,8 @@ struct mtk_socphy_priv {
 	unsigned long		led_state;
 };
 
+void __mtk_tr_write(struct phy_device *phydev, u8 ch_addr, u8 node_addr,
+		    u8 data_addr, u32 tr_data);
 void __mtk_tr_modify(struct phy_device *phydev, u8 ch_addr, u8 node_addr,
 		     u8 data_addr, u32 mask, u32 set);
 void mtk_tr_modify(struct phy_device *phydev, u8 ch_addr, u8 node_addr,
@@ -101,4 +104,16 @@ int mtk_phy_hw_led_blink_set(struct phy_device *phydev, u8 index,
 			     bool blinking);
 void mtk_phy_leds_state_init(struct phy_device *phydev);
 
+int mt798x_phy_led_blink_set(struct phy_device *phydev, u8 index,
+			     unsigned long *delay_on,
+			     unsigned long *delay_off);
+int mt798x_phy_led_brightness_set(struct phy_device *phydev,
+				  u8 index, enum led_brightness value);
+int mt798x_phy_led_hw_is_supported(struct phy_device *phydev, u8 index,
+				   unsigned long rules);
+int mt798x_phy_led_hw_control_get(struct phy_device *phydev, u8 index,
+				  unsigned long *rules);
+int mt798x_phy_led_hw_control_set(struct phy_device *phydev, u8 index,
+				  unsigned long rules);
+
 #endif /* _MTK_EPHY_H_ */

3/2 2026/10/14 12:04 llm patch-evaluator
0m Model:
gemini-3.8-flash

Args:
null

Results:
null

Tokens:
							input: 58625
							output: 35
							thoughts: 692
						

Thoughts:
**Analyzing the Patch's Reachability on amd64**

Okay, so the target is amd64, and this patch introduces an Airoha Ethernet PHY driver. My immediate concern is reachability. Specifically, I'm looking at `drivers/net/phy/mediatek/airoha-ge-soc.c` and associated changes. It seems to be related to moving PHYs around and refactoring some common code, including adding `__mtk_tr_write` and relocating LED functions.

First, I need to understand what kind of driver this is. It's a PHY driver, indicated by `module_phy_driver` and `phy_driver`. The name `AIROHA_GE_SOC_PHY` suggests it's for built-in Ethernet PHYs on Airoha/MediaTek SoCs, perhaps like the AN7581, AN7583, or EN7528. The dependencies, `ARM64 || ECONET || COMPILE_TEST`, and `ARCH_AIROHA || ECONET || COMPILE_TEST`, along with `select MTK_NET_PHYLIB` and `select PHY_PACKAGE`, suggest this might not be immediately available.

Now, the crucial question: can this code *execute* in a standard virtualized amd64 environment like QEMU or GCE? These types of drivers are probed via the MDIO bus, reading the PHY ID. Can syzkaller or userspace even *instantiate* or communicate with MDIO PHY devices on amd64 within QEMU? That's the gate.

I need to determine if there are MDIO bus emulators, or if MDIO devices can be created or emulated virtually. The core principle is reachability. If this is tied to hardware that isn't emulated in standard QEMU (as defined by "REACHABILITY IS THE PRIMARY GATE" in the instructions), it's not worth fuzzing. The patch specifically calls out structurally unreachable hardware such as vendor-specific PCIe switches and SmartNICs. In fact, unreachable execution paths are listed, as well.

I need to rigorously examine whether an MDIO PHY driver can be accessed on amd64 in a standard QEMU setup. I will examine whether MDIO bus emulators exist, and how MDIO devices are created. Time to hit the kernel source with a grepper search. I need to understand how MDIO drivers are handled, and how MDIO PHYs can be bound or instantiated. The goal is to see if this Airoha code *can* be reached and fuzzed within the constraints of the standard environment.



4/2 2026/10/14 12:04 tool grepper
0m Args:
{
  "Expression": "mdio_bus|phy_driver_register",
  "PathPrefixes": [
    "drivers/net/"
  ]
}

Results:
{
  "Output": "\nFull output is too long, showing 200 out of 2278 lines.\nUse more precise expression or PathPrefixes if possible.\n\nNumber of matching lines per file (95 files in total):\ndrivers/net/dsa/microchip/ksz9477.c:1\ndrivers/net/dsa/microchip/ksz_common.c:3\ndrivers/net/dsa/microchip/ksz_common.h:2\ndrivers/net/dsa/microchip/lan937x_main.c:4\ndrivers/net/dsa/motorcomm/Makefile:1\ndrivers/net/dsa/motorcomm/chip.c:1\ndrivers/net/dsa/motorcomm/mdio_bus.c:1\ndrivers/net/dsa/motorcomm/pcs-921x.c:1\ndrivers/net/dsa/mv88e6xxx/chip.c:28\ndrivers/net/dsa/mv88e6xxx/chip.h:2\ndrivers/net/dsa/mv88e6xxx/global2.c:8\ndrivers/net/dsa/mv88e6xxx/pcs-6352.c:1\ndrivers/net/dsa/mv88e6xxx/pcs-639x.c:2\ndrivers/net/dsa/mv88e6xxx/phy.c:4\ndrivers/net/dsa/netc/netc_main.c:4\ndrivers/net/dsa/ocelot/felix.c:6\ndrivers/net/dsa/ocelot/felix.h:2\ndrivers/net/dsa/ocelot/felix_vsc9959.c:4\ndrivers/net/dsa/ocelot/seville_vsc9953.c:4\ndrivers/net/dsa/qca/qca8k-8xxx.c:6\ndrivers/net/dsa/qca/qca8k-leds.c:2\ndrivers/net/dsa/qca/qca8k.h:1\ndrivers/net/dsa/vitesse-vsc73xx-core.c:4\ndrivers/net/ethernet/apm/xgene-v2/main.h:1\ndrivers/net/ethernet/apm/xgene-v2/mdio.c:17\ndrivers/net/ethernet/apm/xgene/xgene_enet_hw.c:15\ndrivers/net/ethernet/apm/xgene/xgene_enet_main.h:1\ndrivers/net/ethernet/aquantia/atlantic/aq_phy.c:6\ndrivers/net/ethernet/aquantia/atlantic/aq_phy.h:1\ndrivers/net/ethernet/aquantia/atlantic/hw_atl/hw_atl_llh.c:1\ndrivers/net/ethernet/aquantia/atlantic/hw_atl/hw_atl_llh.h:1\ndrivers/net/ethernet/arc/emac.h:2\ndrivers/net/ethernet/arc/emac_mdio.c:2\ndrivers/net/ethernet/broadcom/genet/bcmmii.c:3\ndrivers/net/ethernet/broadcom/tg3.c:30\ndrivers/net/ethernet/broadcom/tg3.h:1\ndrivers/net/ethernet/freescale/enetc/enetc_pf_common.c:2\ndrivers/net/ethernet/hisilicon/hibmcge/hbg_common.h:1\ndrivers/net/ethernet/hisilicon/hibmcge/hbg_mdio.c:14\ndrivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c:2\ndrivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.h:1\ndrivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_mdio.c:16\ndrivers/net/ethernet/marvell/mvmdio.c:3\ndrivers/net/ethernet/mediatek/mtk_eth_soc.c:11\ndrivers/net/ethernet/meta/fbnic/fbnic.h:1\ndrivers/net/ethernet/meta/fbnic/fbnic_mdio.c:1\ndrivers/net/ethernet/meta/fbnic/fbnic_phylink.c:1\ndrivers/net/ethernet/realtek/r8169_phy_config.c:4\ndrivers/net/ethernet/samsung/sxgbe/sxgbe_mdio.c:24\ndrivers/net/ethernet/samsung/sxgbe/sxgbe_platform.c:3\n... and 45 more files\n\ndrivers/net/dsa/microchip/ksz9477.c=321=static int ksz9477_pcs_create(struct ksz_device *dev)\n--\ndrivers/net/dsa/microchip/ksz9477.c-332-\ndrivers/net/dsa/microchip/ksz9477.c:333:\tbus-\u003ename = \"ksz_pcs_mdio_bus\";\ndrivers/net/dsa/microchip/ksz9477.c-334-\tsnprintf(bus-\u003eid, MII_BUS_ID_SIZE, \"%s-pcs\",\n--\ndrivers/net/dsa/microchip/ksz_common.c=2211=int ksz_parent_mdio_read(struct mii_bus *bus, int addr, int regnum)\n--\ndrivers/net/dsa/microchip/ksz_common.c-2214-\ndrivers/net/dsa/microchip/ksz_common.c:2215:\treturn mdiobus_read_nested(dev-\u003eparent_mdio_bus, addr, regnum);\ndrivers/net/dsa/microchip/ksz_common.c-2216-}\n--\ndrivers/net/dsa/microchip/ksz_common.c=2231=int ksz_parent_mdio_write(struct mii_bus *bus, int addr, int regnum, u16 val)\n--\ndrivers/net/dsa/microchip/ksz_common.c-2234-\ndrivers/net/dsa/microchip/ksz_common.c:2235:\treturn mdiobus_write_nested(dev-\u003eparent_mdio_bus, addr, regnum, val);\ndrivers/net/dsa/microchip/ksz_common.c-2236-}\n--\ndrivers/net/dsa/microchip/ksz_common.c=2407=int ksz_mdio_register(struct ksz_device *dev)\n--\ndrivers/net/dsa/microchip/ksz_common.c-2433-\ndrivers/net/dsa/microchip/ksz_common.c:2434:\t\tdev-\u003eparent_mdio_bus = parent_bus;\ndrivers/net/dsa/microchip/ksz_common.c-2435-\t}\n--\ndrivers/net/dsa/microchip/ksz_common.h=208=struct ksz_device {\n--\ndrivers/net/dsa/microchip/ksz_common.h-260-\t/**\ndrivers/net/dsa/microchip/ksz_common.h:261:\t * @parent_mdio_bus: Pointer to the external MDIO bus controller.\ndrivers/net/dsa/microchip/ksz_common.h-262-\t *\n--\ndrivers/net/dsa/microchip/ksz_common.h-267-\t */\ndrivers/net/dsa/microchip/ksz_common.h:268:\tstruct mii_bus *parent_mdio_bus;\ndrivers/net/dsa/microchip/ksz_common.h-269-\n--\ndrivers/net/dsa/microchip/lan937x_main.c=143=static int lan937x_create_phy_addr_map(struct ksz_device *dev, bool side_mdio)\n--\ndrivers/net/dsa/microchip/lan937x_main.c-210-/**\ndrivers/net/dsa/microchip/lan937x_main.c:211: * lan937x_mdio_bus_preinit - Pre-initialize MDIO bus for accessing PHYs.\ndrivers/net/dsa/microchip/lan937x_main.c-212- * @dev: Pointer to device structure.\n--\ndrivers/net/dsa/microchip/lan937x_main.c-226- */\ndrivers/net/dsa/microchip/lan937x_main.c:227:static int lan937x_mdio_bus_preinit(struct ksz_device *dev, bool side_mdio)\ndrivers/net/dsa/microchip/lan937x_main.c-228-{\n--\ndrivers/net/dsa/microchip/lan937x_main.c=685=static int lan937x_mdio_register(struct ksz_device *dev)\n--\ndrivers/net/dsa/microchip/lan937x_main.c-711-\ndrivers/net/dsa/microchip/lan937x_main.c:712:\t\tdev-\u003eparent_mdio_bus = parent_bus;\ndrivers/net/dsa/microchip/lan937x_main.c-713-\t}\n--\ndrivers/net/dsa/microchip/lan937x_main.c-720-\ndrivers/net/dsa/microchip/lan937x_main.c:721:\tret = lan937x_mdio_bus_preinit(dev, !!parent_bus);\ndrivers/net/dsa/microchip/lan937x_main.c-722-\tif (ret)\n--\ndrivers/net/dsa/motorcomm/Makefile=4=yt921x-$(CONFIG_NET_DSA_YT921X_LEDS) += leds.o\ndrivers/net/dsa/motorcomm/Makefile:5:yt921x-objs += mdio_bus.o\ndrivers/net/dsa/motorcomm/Makefile-6-yt921x-objs += mib.o\n--\ndrivers/net/dsa/motorcomm/chip.c-30-#include \"leds.h\"\ndrivers/net/dsa/motorcomm/chip.c:31:#include \"mdio_bus.h\"\ndrivers/net/dsa/motorcomm/chip.c-32-#include \"mib.h\"\n--\ndrivers/net/dsa/motorcomm/mdio_bus.c-8-#include \"chip.h\"\ndrivers/net/dsa/motorcomm/mdio_bus.c:9:#include \"mdio_bus.h\"\ndrivers/net/dsa/motorcomm/mdio_bus.c-10-#include \"smi.h\"\n--\ndrivers/net/dsa/motorcomm/pcs-921x.c-6-#include \"chip.h\"\ndrivers/net/dsa/motorcomm/pcs-921x.c:7:#include \"mdio_bus.h\"\ndrivers/net/dsa/motorcomm/pcs-921x.c-8-#include \"pcs.h\"\n--\ndrivers/net/dsa/mv88e6xxx/chip.c=126=int mv88e6xxx_wait_bit(struct mv88e6xxx_chip *chip, int addr, int reg,\n--\ndrivers/net/dsa/mv88e6xxx/chip.c-132-\ndrivers/net/dsa/mv88e6xxx/chip.c:133:struct mii_bus *mv88e6xxx_default_mdio_bus(struct mv88e6xxx_chip *chip)\ndrivers/net/dsa/mv88e6xxx/chip.c-134-{\ndrivers/net/dsa/mv88e6xxx/chip.c:135:\tstruct mv88e6xxx_mdio_bus *mdio_bus;\ndrivers/net/dsa/mv88e6xxx/chip.c-136-\ndrivers/net/dsa/mv88e6xxx/chip.c:137:\tmdio_bus = list_first_entry_or_null(\u0026chip-\u003emdios,\ndrivers/net/dsa/mv88e6xxx/chip.c:138:\t\t\t\t\t    struct mv88e6xxx_mdio_bus, list);\ndrivers/net/dsa/mv88e6xxx/chip.c:139:\tif (!mdio_bus)\ndrivers/net/dsa/mv88e6xxx/chip.c-140-\t\treturn NULL;\ndrivers/net/dsa/mv88e6xxx/chip.c-141-\ndrivers/net/dsa/mv88e6xxx/chip.c:142:\treturn mdio_bus-\u003ebus;\ndrivers/net/dsa/mv88e6xxx/chip.c-143-}\n--\ndrivers/net/dsa/mv88e6xxx/chip.c=3766=static int mv88e6xxx_mdio_read(struct mii_bus *bus, int phy, int reg)\ndrivers/net/dsa/mv88e6xxx/chip.c-3767-{\ndrivers/net/dsa/mv88e6xxx/chip.c:3768:\tstruct mv88e6xxx_mdio_bus *mdio_bus = bus-\u003epriv;\ndrivers/net/dsa/mv88e6xxx/chip.c:3769:\tstruct mv88e6xxx_chip *chip = mdio_bus-\u003echip;\ndrivers/net/dsa/mv88e6xxx/chip.c-3770-\tu16 prod_id;\n--\ndrivers/net/dsa/mv88e6xxx/chip.c=3792=static int mv88e6xxx_mdio_read_c45(struct mii_bus *bus, int phy, int devad,\n--\ndrivers/net/dsa/mv88e6xxx/chip.c-3794-{\ndrivers/net/dsa/mv88e6xxx/chip.c:3795:\tstruct mv88e6xxx_mdio_bus *mdio_bus = bus-\u003epriv;\ndrivers/net/dsa/mv88e6xxx/chip.c:3796:\tstruct mv88e6xxx_chip *chip = mdio_bus-\u003echip;\ndrivers/net/dsa/mv88e6xxx/chip.c-3797-\tu16 val;\n--\ndrivers/net/dsa/mv88e6xxx/chip.c=3810=static int mv88e6xxx_mdio_write(struct mii_bus *bus, int phy, int reg, u16 val)\ndrivers/net/dsa/mv88e6xxx/chip.c-3811-{\ndrivers/net/dsa/mv88e6xxx/chip.c:3812:\tstruct mv88e6xxx_mdio_bus *mdio_bus = bus-\u003epriv;\ndrivers/net/dsa/mv88e6xxx/chip.c:3813:\tstruct mv88e6xxx_chip *chip = mdio_bus-\u003echip;\ndrivers/net/dsa/mv88e6xxx/chip.c-3814-\tint err;\n--\ndrivers/net/dsa/mv88e6xxx/chip.c=3826=static int mv88e6xxx_mdio_write_c45(struct mii_bus *bus, int phy, int devad,\n--\ndrivers/net/dsa/mv88e6xxx/chip.c-3828-{\ndrivers/net/dsa/mv88e6xxx/chip.c:3829:\tstruct mv88e6xxx_mdio_bus *mdio_bus = bus-\u003epriv;\ndrivers/net/dsa/mv88e6xxx/chip.c:3830:\tstruct mv88e6xxx_chip *chip = mdio_bus-\u003echip;\ndrivers/net/dsa/mv88e6xxx/chip.c-3831-\tint err;\n--\ndrivers/net/dsa/mv88e6xxx/chip.c=3843=static int mv88e6xxx_mdio_register(struct mv88e6xxx_chip *chip,\n--\ndrivers/net/dsa/mv88e6xxx/chip.c-3847-\tstatic int index;\ndrivers/net/dsa/mv88e6xxx/chip.c:3848:\tstruct mv88e6xxx_mdio_bus *mdio_bus;\ndrivers/net/dsa/mv88e6xxx/chip.c-3849-\tstruct mii_bus *bus;\n--\ndrivers/net/dsa/mv88e6xxx/chip.c-3863-\ndrivers/net/dsa/mv88e6xxx/chip.c:3864:\tbus = mdiobus_alloc_size(sizeof(*mdio_bus));\ndrivers/net/dsa/mv88e6xxx/chip.c-3865-\tif (!bus)\n--\ndrivers/net/dsa/mv88e6xxx/chip.c-3867-\ndrivers/net/dsa/mv88e6xxx/chip.c:3868:\tmdio_bus = bus-\u003epriv;\ndrivers/net/dsa/mv88e6xxx/chip.c:3869:\tmdio_bus-\u003ebus = bus;\ndrivers/net/dsa/mv88e6xxx/chip.c:3870:\tmdio_bus-\u003echip = chip;\ndrivers/net/dsa/mv88e6xxx/chip.c:3871:\tINIT_LIST_HEAD(\u0026mdio_bus-\u003elist);\ndrivers/net/dsa/mv88e6xxx/chip.c:3872:\tmdio_bus-\u003eexternal = external;\ndrivers/net/dsa/mv88e6xxx/chip.c-3873-\n--\ndrivers/net/dsa/mv88e6xxx/chip.c-3904-\tif (external)\ndrivers/net/dsa/mv88e6xxx/chip.c:3905:\t\tlist_add_tail(\u0026mdio_bus-\u003elist, \u0026chip-\u003emdios);\ndrivers/net/dsa/mv88e6xxx/chip.c-3906-\telse\ndrivers/net/dsa/mv88e6xxx/chip.c:3907:\t\tlist_add(\u0026mdio_bus-\u003elist, \u0026chip-\u003emdios);\ndrivers/net/dsa/mv88e6xxx/chip.c-3908-\n--\ndrivers/net/dsa/mv88e6xxx/chip.c=3916=static void mv88e6xxx_mdios_unregister(struct mv88e6xxx_chip *chip)\n--\ndrivers/net/dsa/mv88e6xxx/chip.c-3918-{\ndrivers/net/dsa/mv88e6xxx/chip.c:3919:\tstruct mv88e6xxx_mdio_bus *mdio_bus, *p;\ndrivers/net/dsa/mv88e6xxx/chip.c-3920-\tstruct mii_bus *bus;\ndrivers/net/dsa/mv88e6xxx/chip.c-3921-\ndrivers/net/dsa/mv88e6xxx/chip.c:3922:\tlist_for_each_entry_safe(mdio_bus, p, \u0026chip-\u003emdios, list) {\ndrivers/net/dsa/mv88e6xxx/chip.c:3923:\t\tbus = mdio_bus-\u003ebus;\ndrivers/net/dsa/mv88e6xxx/chip.c-3924-\ndrivers/net/dsa/mv88e6xxx/chip.c:3925:\t\tif (!mdio_bus-\u003eexternal)\ndrivers/net/dsa/mv88e6xxx/chip.c-3926-\t\t\tmv88e6xxx_g2_irq_mdio_free(chip, bus);\n--\ndrivers/net/dsa/mv88e6xxx/chip.c=3989=static int mv88e6xxx_setup(struct dsa_switch *ds)\n--\ndrivers/net/dsa/mv88e6xxx/chip.c-4000-\tchip-\u003eds = ds;\ndrivers/net/dsa/mv88e6xxx/chip.c:4001:\tds-\u003euser_mii_bus = mv88e6xxx_default_mdio_bus(chip);\ndrivers/net/dsa/mv88e6xxx/chip.c-4002-\n--\ndrivers/net/dsa/mv88e6xxx/chip.h=488=struct mv88e6xxx_bus_ops {\n--\ndrivers/net/dsa/mv88e6xxx/chip.h-493-\ndrivers/net/dsa/mv88e6xxx/chip.h:494:struct mv88e6xxx_mdio_bus {\ndrivers/net/dsa/mv88e6xxx/chip.h-495-\tstruct mii_bus *bus;\n--\ndrivers/net/dsa/mv88e6xxx/chip.h=873=int mv88e6xxx_wait_bit(struct mv88e6xxx_chip *chip, int addr, int reg,\ndrivers/net/dsa/mv88e6xxx/chip.h-874-\t\t       int bit, int val);\ndrivers/net/dsa/mv88e6xxx/chip.h:875:struct mii_bus *mv88e6xxx_default_mdio_bus(struct mv88e6xxx_chip *chip);\ndrivers/net/dsa/mv88e6xxx/chip.h-876-\n--\ndrivers/net/dsa/mv88e6xxx/global2.c=787=int mv88e6xxx_g2_smi_phy_read_c22(struct mv88e6xxx_chip *chip,\n--\ndrivers/net/dsa/mv88e6xxx/global2.c-790-{\ndrivers/net/dsa/mv88e6xxx/global2.c:791:\tstruct mv88e6xxx_mdio_bus *mdio_bus = bus-\u003epriv;\ndrivers/net/dsa/mv88e6xxx/global2.c:792:\tbool external = mdio_bus-\u003eexternal;\ndrivers/net/dsa/mv88e6xxx/global2.c-793-\n--\ndrivers/net/dsa/mv88e6xxx/global2.c=798=int mv88e6xxx_g2_smi_phy_read_c45(struct mv88e6xxx_chip *chip,\n--\ndrivers/net/dsa/mv88e6xxx/global2.c-801-{\ndrivers/net/dsa/mv88e6xxx/global2.c:802:\tstruct mv88e6xxx_mdio_bus *mdio_bus = bus-\u003epriv;\ndrivers/net/dsa/mv88e6xxx/global2.c:803:\tbool external = mdio_bus-\u003eexternal;\ndrivers/net/dsa/mv88e6xxx/global2.c-804-\n--\ndrivers/net/dsa/mv88e6xxx/global2.c=809=int mv88e6xxx_g2_smi_phy_write_c22(struct mv88e6xxx_chip *chip,\n--\ndrivers/net/dsa/mv88e6xxx/global2.c-812-{\ndrivers/net/dsa/mv88e6xxx/global2.c:813:\tstruct mv88e6xxx_mdio_bus *mdio_bus = bus-\u003epriv;\ndrivers/net/dsa/mv88e6xxx/global2.c:814:\tbool external = mdio_bus-\u003eexternal;\ndrivers/net/dsa/mv88e6xxx/global2.c-815-\n--\ndrivers/net/dsa/mv88e6xxx/global2.c=820=int mv88e6xxx_g2_smi_phy_write_c45(struct mv88e6xxx_chip *chip,\n--\ndrivers/net/dsa/mv88e6xxx/global2.c-823-{\ndrivers/net/dsa/mv88e6xxx/global2.c:824:\tstruct mv88e6xxx_mdio_bus *mdio_bus = bus-\u003epriv;\ndrivers/net/dsa/mv88e6xxx/global2.c:825:\tbool external = mdio_bus-\u003eexternal;\ndrivers/net/dsa/mv88e6xxx/global2.c-826-\n--\ndrivers/net/dsa/mv88e6xxx/pcs-6352.c=324=static int mv88e6352_pcs_init(struct mv88e6xxx_chip *chip, int port)\n--\ndrivers/net/dsa/mv88e6xxx/pcs-6352.c-336-\tirq = mv88e6xxx_serdes_irq_mapping(chip, port);\ndrivers/net/dsa/mv88e6xxx/pcs-6352.c:337:\tbus = mv88e6xxx_default_mdio_bus(chip);\ndrivers/net/dsa/mv88e6xxx/pcs-6352.c-338-\tdev = chip-\u003edev;\n--\ndrivers/net/dsa/mv88e6xxx/pcs-639x.c=549=static int mv88e6390_pcs_init(struct mv88e6xxx_chip *chip, int port)\n--\n\n"
}

5/2 2026/10/14 12:04 llm patch-evaluator
0m Model:
gemini-3.8-flash

Args:
null

Results:
null

Tokens:
							input: 66454
							output: 38
							thoughts: 912
						

Thoughts:
**Analyzing the Reachability of the AIROHA_GE_SOC_PHY Driver for Fuzzing**

Okay, let's break this down. My initial thought is to figure out what `AIROHA_GE_SOC_PHY` actually is. I see it's a driver for Airoha SoC Gigabit Ethernet PHYs, specifically in `drivers/net/phy/mediatek/Kconfig`. The Kconfig entry shows some dependencies: `ARM64 || ECONET || COMPILE_TEST` and `ARCH_AIROHA || ECONET || COMPILE_TEST`.  It seems to select `MTK_NET_PHYLIB` and `PHY_PACKAGE`. The description mentions support for built-in Ethernet PHYs in AN7581 and AN7583 SoCs, with dynamic calibration.

But here's the kicker: the target architecture is amd64, not ARM64 or the other architectures. I can get this to compile on amd64 using `CONFIG_COMPILE_TEST=y`, but compilation doesn't equal reachability. My crucial question is, can this driver *actually be executed* or probed on amd64 within QEMU? This is where reachability becomes the critical consideration.

I need to refer back to our guidelines on fuzzing. Section 1 and 2 are clear on reachability being the primary factor. The guidelines state not to fuzz code that is structurally unreachable in standard virtualized environments.  Section 2 explicitly lists cases where `WorthFuzzing=false`. I specifically recall the negative criteria: "Structurally unreachable hardware: Vendor-specific PCIe switches, SmartNICs, or GPU drivers... requiring physical ASIC/PCIe cards not emulated in standard QEMU" and "Unreachable execution paths: Code paths exclusive to architectures other than the target architecture".

Therefore, the core issue is whether the Airoha SoC Gigabit Ethernet PHY is reachable without the actual SoC/hardware.  I need to understand how `airoha-ge-soc` is probed. I'll check `airoha-ge-soc.c` to look at this. I see that it uses `phy_driver` structures with specific ID matches for different Airoha PHYs (EN7528, AN7581, AN7583). The driver includes `.probe` and `.config_init` functions.  How are these PHY devices actually created and bound to the PHY drivers?  I should now look for relevant functions, like `phy_device_create`, `mdiobus_register`, or `get_phy_device`, to understand the PHY device lifecycle. Based on what I find, I can determine if this driver can be triggered in a standard QEMU setup on amd64, or if it's fundamentally tied to the Airoha SoC and thus unreachable for fuzzing.



6/2 2026/10/14 12:04 tool grepper
0m Args:
{
  "Expression": "get_phy_device|phy_device_create",
  "PathPrefixes": [
    "drivers/net/phy/"
  ]
}

Results:
{
  "Output": "drivers/net/phy/fixed_phy.c=131=struct phy_device *fixed_phy_register(const struct fixed_phy_status *status,\n--\ndrivers/net/phy/fixed_phy.c-152-\ndrivers/net/phy/fixed_phy.c:153:\tphy = get_phy_device(fmb_mii_bus, phy_addr, false);\ndrivers/net/phy/fixed_phy.c-154-\tif (IS_ERR(phy)) {\n--\ndrivers/net/phy/mdio_bus_provider.c=408=static struct phy_device *mdiobus_scan(struct mii_bus *bus, int addr, bool c45)\n--\ndrivers/net/phy/mdio_bus_provider.c-414-\ndrivers/net/phy/mdio_bus_provider.c:415:\tphydev = get_phy_device(bus, addr, c45);\ndrivers/net/phy/mdio_bus_provider.c-416-\tif (IS_ERR(phydev))\n--\ndrivers/net/phy/nxp-tja11xx.c=551=static void tja1102_p1_register(struct work_struct *work)\n--\ndrivers/net/phy/nxp-tja11xx.c-585-\t\t/* Real PHY ID of Port 1 is 0 */\ndrivers/net/phy/nxp-tja11xx.c:586:\t\tphy = phy_device_create(bus, addr, PHY_ID_TJA1102, false, NULL);\ndrivers/net/phy/nxp-tja11xx.c-587-\t\tif (IS_ERR(phy)) {\n--\ndrivers/net/phy/nxp-tja11xx.c-592-\ndrivers/net/phy/nxp-tja11xx.c:593:\t\t/* Overwrite parent device. phy_device_create() set parent to\ndrivers/net/phy/nxp-tja11xx.c-594-\t\t * the mii_bus-\u003edev, which is not correct in case.\n--\ndrivers/net/phy/phy_device.c=638=static int phy_request_driver_module(struct phy_device *dev, u32 phy_id)\n--\ndrivers/net/phy/phy_device.c-657-\ndrivers/net/phy/phy_device.c:658:struct phy_device *phy_device_create(struct mii_bus *bus, int addr, u32 phy_id,\ndrivers/net/phy/phy_device.c-659-\t\t\t\t     bool is_c45,\n--\ndrivers/net/phy/phy_device.c-749-}\ndrivers/net/phy/phy_device.c:750:EXPORT_SYMBOL(phy_device_create);\ndrivers/net/phy/phy_device.c-751-\n--\ndrivers/net/phy/phy_device.c=960=EXPORT_SYMBOL(fwnode_get_phy_id);\n--\ndrivers/net/phy/phy_device.c-962-/**\ndrivers/net/phy/phy_device.c:963: * get_phy_device - reads the specified PHY device and returns its @phy_device\ndrivers/net/phy/phy_device.c-964- *\t\t    struct\n--\ndrivers/net/phy/phy_device.c-980- */\ndrivers/net/phy/phy_device.c:981:struct phy_device *get_phy_device(struct mii_bus *bus, int addr, bool is_c45)\ndrivers/net/phy/phy_device.c-982-{\n--\ndrivers/net/phy/phy_device.c-1006-\t\tif (!r)\ndrivers/net/phy/phy_device.c:1007:\t\t\treturn phy_device_create(bus, addr, phy_id,\ndrivers/net/phy/phy_device.c-1008-\t\t\t\t\t\t true, \u0026c45_ids);\n--\ndrivers/net/phy/phy_device.c-1010-\ndrivers/net/phy/phy_device.c:1011:\treturn phy_device_create(bus, addr, phy_id, is_c45, \u0026c45_ids);\ndrivers/net/phy/phy_device.c-1012-}\ndrivers/net/phy/phy_device.c:1013:EXPORT_SYMBOL(get_phy_device);\ndrivers/net/phy/phy_device.c-1014-\n--\ndrivers/net/phy/sfp.c=2120=static int sfp_sm_probe_phy(struct sfp *sfp, int addr, bool is_c45)\n--\ndrivers/net/phy/sfp.c-2124-\ndrivers/net/phy/sfp.c:2125:\tphy = get_phy_device(sfp-\u003ei2c_mii, addr, is_c45);\ndrivers/net/phy/sfp.c-2126-\tif (phy == ERR_PTR(-ENODEV))\n"
}

7/2 2026/10/14 12:04 llm patch-evaluator
0m Model:
gemini-3.8-flash

Args:
null

Results:
null

Tokens:
							input: 69293
							output: 32
							thoughts: 325
						

Thoughts:
**My Initial Thoughts on PHY Device Registration**

Okay, so I'm thinking about how these PHY devices get created in the kernel. Essentially, there are a few primary ways: first, the MDIO bus gets registered, then it reads those PHY ID registers, and if everything checks out, we use `get_phy_device()` or `phy_device_create()` to set up a `struct phy_device` on the `mdio_bus_type`. Makes sense. Then there are those fixed_phy setups, which are straightforward with their fixed IDs. And finally, SFPs, which come over I2C.

Now, I've got this question... can an MDIO PHY device with a specific ID, say, matching one of those Airoha GPHYs – like `AIROHA_GPHY_ID_EN7528`, `AIROHA_GPHY_ID_AN7581`, or `AIROHA_GPHY_ID_AN7583` – ever actually register or get probed on an amd64 virtual machine? That's the real question. I need some context here. What bus or SoC are these PHYs even associated with?

Right, need to check the device tree or the Ethernet controller for any Airoha EN7581 mentions. That seems like the logical first step. Let's see... I'll check `Documentation/devicetree/bindings/net/airoha,en7581-eth.yaml` in the kernel source. And probably poke around in `drivers/net/ethernet/airoha/` to see what I can find. I’ll start by grepping that directory for anything related to `airoha`. That should give me a good starting point.



8/2 2026/10/14 12:05 tool grepper
0m Args:
{
  "Expression": ".*",
  "PathPrefixes": [
    "drivers/net/ethernet/airoha/"
  ]
}

Results:
{
  "Output": "\nFull output is too long, showing 200 out of 8783 lines.\nUse more precise expression or PathPrefixes if possible.\n\nNumber of matching lines per file (8 files in total):\ndrivers/net/ethernet/airoha/Kconfig:34\ndrivers/net/ethernet/airoha/Makefile:9\ndrivers/net/ethernet/airoha/airoha_eth.c:4307\ndrivers/net/ethernet/airoha/airoha_eth.h:784\ndrivers/net/ethernet/airoha/airoha_npu.c:827\ndrivers/net/ethernet/airoha/airoha_ppe.c:1686\ndrivers/net/ethernet/airoha/airoha_ppe_debugfs.c:185\ndrivers/net/ethernet/airoha/airoha_regs.h:944\n\ndrivers/net/ethernet/airoha/Kconfig:1:# SPDX-License-Identifier: GPL-2.0-only\ndrivers/net/ethernet/airoha/Kconfig:2:config NET_VENDOR_AIROHA\ndrivers/net/ethernet/airoha/Kconfig:3:\tbool \"Airoha devices\"\ndrivers/net/ethernet/airoha/Kconfig:4:\tdepends on ARCH_AIROHA || COMPILE_TEST\ndrivers/net/ethernet/airoha/Kconfig:5:\thelp\ndrivers/net/ethernet/airoha/Kconfig:6:\t  If you have a Airoha SoC with ethernet, say Y.\ndrivers/net/ethernet/airoha/Kconfig:7:\ndrivers/net/ethernet/airoha/Kconfig:8:if NET_VENDOR_AIROHA\ndrivers/net/ethernet/airoha/Kconfig:9:\ndrivers/net/ethernet/airoha/Kconfig:10:config NET_AIROHA_NPU\ndrivers/net/ethernet/airoha/Kconfig:11:\ttristate \"Airoha NPU support\"\ndrivers/net/ethernet/airoha/Kconfig:12:\tselect WANT_DEV_COREDUMP\ndrivers/net/ethernet/airoha/Kconfig:13:\tselect REGMAP_MMIO\ndrivers/net/ethernet/airoha/Kconfig:14:\thelp\ndrivers/net/ethernet/airoha/Kconfig:15:\t  This driver supports Airoha Network Processor (NPU) available\ndrivers/net/ethernet/airoha/Kconfig:16:\t  on the Airoha Soc family.\ndrivers/net/ethernet/airoha/Kconfig:17:\ndrivers/net/ethernet/airoha/Kconfig:18:config NET_AIROHA\ndrivers/net/ethernet/airoha/Kconfig:19:\ttristate \"Airoha SoC Gigabit Ethernet support\"\ndrivers/net/ethernet/airoha/Kconfig:20:\tdepends on NET_DSA || !NET_DSA\ndrivers/net/ethernet/airoha/Kconfig:21:\tselect NET_AIROHA_NPU\ndrivers/net/ethernet/airoha/Kconfig:22:\tselect PAGE_POOL\ndrivers/net/ethernet/airoha/Kconfig:23:\thelp\ndrivers/net/ethernet/airoha/Kconfig:24:\t  This driver supports the gigabit ethernet MACs in the\ndrivers/net/ethernet/airoha/Kconfig:25:\t  Airoha SoC family.\ndrivers/net/ethernet/airoha/Kconfig:26:\ndrivers/net/ethernet/airoha/Kconfig:27:config NET_AIROHA_FLOW_STATS\ndrivers/net/ethernet/airoha/Kconfig:28:\tdefault y\ndrivers/net/ethernet/airoha/Kconfig:29:\tbool \"Airoha flow stats\"\ndrivers/net/ethernet/airoha/Kconfig:30:\tdepends on NET_AIROHA \u0026\u0026 NET_AIROHA_NPU\ndrivers/net/ethernet/airoha/Kconfig:31:\thelp\ndrivers/net/ethernet/airoha/Kconfig:32:\t  Enable Airoha flowtable statistic counters.\ndrivers/net/ethernet/airoha/Kconfig:33:\ndrivers/net/ethernet/airoha/Kconfig:34:endif #NET_VENDOR_AIROHA\n--\ndrivers/net/ethernet/airoha/Makefile:1:# SPDX-License-Identifier: GPL-2.0-only\ndrivers/net/ethernet/airoha/Makefile:2:#\ndrivers/net/ethernet/airoha/Makefile:3:# Airoha for the Mediatek SoCs built-in ethernet macs\ndrivers/net/ethernet/airoha/Makefile:4:#\ndrivers/net/ethernet/airoha/Makefile:5:\ndrivers/net/ethernet/airoha/Makefile:6:obj-$(CONFIG_NET_AIROHA) += airoha-eth.o\ndrivers/net/ethernet/airoha/Makefile:7:airoha-eth-y := airoha_eth.o airoha_ppe.o\ndrivers/net/ethernet/airoha/Makefile:8:airoha-eth-$(CONFIG_DEBUG_FS) += airoha_ppe_debugfs.o\ndrivers/net/ethernet/airoha/Makefile:9:obj-$(CONFIG_NET_AIROHA_NPU) += airoha_npu.o\n--\ndrivers/net/ethernet/airoha/airoha_eth.c:1:// SPDX-License-Identifier: GPL-2.0-only\ndrivers/net/ethernet/airoha/airoha_eth.c:2:/*\ndrivers/net/ethernet/airoha/airoha_eth.c:3: * Copyright (c) 2024 AIROHA Inc\ndrivers/net/ethernet/airoha/airoha_eth.c:4: * Author: Lorenzo Bianconi \u003clorenzo@kernel.org\u003e\ndrivers/net/ethernet/airoha/airoha_eth.c:5: */\ndrivers/net/ethernet/airoha/airoha_eth.c:6:#include \u003clinux/of.h\u003e\ndrivers/net/ethernet/airoha/airoha_eth.c:7:#include \u003clinux/of_net.h\u003e\ndrivers/net/ethernet/airoha/airoha_eth.c:8:#include \u003clinux/of_reserved_mem.h\u003e\ndrivers/net/ethernet/airoha/airoha_eth.c:9:#include \u003clinux/platform_device.h\u003e\ndrivers/net/ethernet/airoha/airoha_eth.c:10:#include \u003clinux/tcp.h\u003e\ndrivers/net/ethernet/airoha/airoha_eth.c:11:#include \u003clinux/u64_stats_sync.h\u003e\ndrivers/net/ethernet/airoha/airoha_eth.c:12:#include \u003cnet/dst_metadata.h\u003e\ndrivers/net/ethernet/airoha/airoha_eth.c:13:#include \u003cnet/ip6_checksum.h\u003e\ndrivers/net/ethernet/airoha/airoha_eth.c:14:#include \u003cnet/page_pool/helpers.h\u003e\ndrivers/net/ethernet/airoha/airoha_eth.c:15:#include \u003cnet/pkt_cls.h\u003e\ndrivers/net/ethernet/airoha/airoha_eth.c:16:#include \u003cnet/tcp.h\u003e\ndrivers/net/ethernet/airoha/airoha_eth.c:17:#include \u003cuapi/linux/ppp_defs.h\u003e\ndrivers/net/ethernet/airoha/airoha_eth.c:18:\ndrivers/net/ethernet/airoha/airoha_eth.c:19:#include \"airoha_regs.h\"\ndrivers/net/ethernet/airoha/airoha_eth.c:20:#include \"airoha_eth.h\"\ndrivers/net/ethernet/airoha/airoha_eth.c:21:\ndrivers/net/ethernet/airoha/airoha_eth.c:22:u32 airoha_rr(void __iomem *base, u32 offset)\ndrivers/net/ethernet/airoha/airoha_eth.c:23:{\ndrivers/net/ethernet/airoha/airoha_eth.c:24:\treturn readl(base + offset);\ndrivers/net/ethernet/airoha/airoha_eth.c:25:}\ndrivers/net/ethernet/airoha/airoha_eth.c:26:\ndrivers/net/ethernet/airoha/airoha_eth.c:27:void airoha_wr(void __iomem *base, u32 offset, u32 val)\ndrivers/net/ethernet/airoha/airoha_eth.c:28:{\ndrivers/net/ethernet/airoha/airoha_eth.c:29:\twritel(val, base + offset);\ndrivers/net/ethernet/airoha/airoha_eth.c:30:}\ndrivers/net/ethernet/airoha/airoha_eth.c:31:\ndrivers/net/ethernet/airoha/airoha_eth.c:32:u32 airoha_rmw(void __iomem *base, u32 offset, u32 mask, u32 val)\ndrivers/net/ethernet/airoha/airoha_eth.c:33:{\ndrivers/net/ethernet/airoha/airoha_eth.c:34:\tval |= (airoha_rr(base, offset) \u0026 ~mask);\ndrivers/net/ethernet/airoha/airoha_eth.c:35:\tairoha_wr(base, offset, val);\ndrivers/net/ethernet/airoha/airoha_eth.c:36:\ndrivers/net/ethernet/airoha/airoha_eth.c:37:\treturn val;\ndrivers/net/ethernet/airoha/airoha_eth.c:38:}\ndrivers/net/ethernet/airoha/airoha_eth.c:39:\ndrivers/net/ethernet/airoha/airoha_eth.c:40:static void airoha_qdma_set_irqmask(struct airoha_irq_bank *irq_bank,\ndrivers/net/ethernet/airoha/airoha_eth.c:41:\t\t\t\t    int index, u32 clear, u32 set)\ndrivers/net/ethernet/airoha/airoha_eth.c:42:{\ndrivers/net/ethernet/airoha/airoha_eth.c:43:\tstruct airoha_qdma *qdma = irq_bank-\u003eqdma;\ndrivers/net/ethernet/airoha/airoha_eth.c:44:\tint bank = irq_bank - \u0026qdma-\u003eirq_banks[0];\ndrivers/net/ethernet/airoha/airoha_eth.c:45:\tunsigned long flags;\ndrivers/net/ethernet/airoha/airoha_eth.c:46:\ndrivers/net/ethernet/airoha/airoha_eth.c:47:\tif (WARN_ON_ONCE(index \u003e= ARRAY_SIZE(irq_bank-\u003eirqmask)))\ndrivers/net/ethernet/airoha/airoha_eth.c:48:\t\treturn;\ndrivers/net/ethernet/airoha/airoha_eth.c:49:\ndrivers/net/ethernet/airoha/airoha_eth.c:50:\tspin_lock_irqsave(\u0026irq_bank-\u003eirq_lock, flags);\ndrivers/net/ethernet/airoha/airoha_eth.c:51:\ndrivers/net/ethernet/airoha/airoha_eth.c:52:\tirq_bank-\u003eirqmask[index] \u0026= ~clear;\ndrivers/net/ethernet/airoha/airoha_eth.c:53:\tirq_bank-\u003eirqmask[index] |= set;\ndrivers/net/ethernet/airoha/airoha_eth.c:54:\tairoha_qdma_wr(qdma, REG_INT_ENABLE(bank, index),\ndrivers/net/ethernet/airoha/airoha_eth.c:55:\t\t       irq_bank-\u003eirqmask[index]);\ndrivers/net/ethernet/airoha/airoha_eth.c:56:\t/* Read irq_enable register in order to guarantee the update above\ndrivers/net/ethernet/airoha/airoha_eth.c:57:\t * completes in the spinlock critical section.\ndrivers/net/ethernet/airoha/airoha_eth.c:58:\t */\ndrivers/net/ethernet/airoha/airoha_eth.c:59:\tairoha_qdma_rr(qdma, REG_INT_ENABLE(bank, index));\ndrivers/net/ethernet/airoha/airoha_eth.c:60:\ndrivers/net/ethernet/airoha/airoha_eth.c:61:\tspin_unlock_irqrestore(\u0026irq_bank-\u003eirq_lock, flags);\ndrivers/net/ethernet/airoha/airoha_eth.c:62:}\ndrivers/net/ethernet/airoha/airoha_eth.c:63:\ndrivers/net/ethernet/airoha/airoha_eth.c:64:static void airoha_qdma_irq_enable(struct airoha_irq_bank *irq_bank,\ndrivers/net/ethernet/airoha/airoha_eth.c:65:\t\t\t\t   int index, u32 mask)\ndrivers/net/ethernet/airoha/airoha_eth.c:66:{\ndrivers/net/ethernet/airoha/airoha_eth.c:67:\tairoha_qdma_set_irqmask(irq_bank, index, 0, mask);\ndrivers/net/ethernet/airoha/airoha_eth.c:68:}\ndrivers/net/ethernet/airoha/airoha_eth.c:69:\ndrivers/net/ethernet/airoha/airoha_eth.c:70:static void airoha_qdma_irq_disable(struct airoha_irq_bank *irq_bank,\ndrivers/net/ethernet/airoha/airoha_eth.c:71:\t\t\t\t    int index, u32 mask)\ndrivers/net/ethernet/airoha/airoha_eth.c:72:{\ndrivers/net/ethernet/airoha/airoha_eth.c:73:\tairoha_qdma_set_irqmask(irq_bank, index, mask, 0);\ndrivers/net/ethernet/airoha/airoha_eth.c:74:}\ndrivers/net/ethernet/airoha/airoha_eth.c:75:\ndrivers/net/ethernet/airoha/airoha_eth.c:76:static int airoha_set_macaddr(struct airoha_gdm_dev *dev, const u8 *addr)\ndrivers/net/ethernet/airoha/airoha_eth.c:77:{\ndrivers/net/ethernet/airoha/airoha_eth.c:78:\tu8 ref_addr[ETH_ALEN] __aligned(2);\ndrivers/net/ethernet/airoha/airoha_eth.c:79:\tstruct airoha_eth *eth = dev-\u003eeth;\ndrivers/net/ethernet/airoha/airoha_eth.c:80:\tu32 reg, val, lmin, lmax;\ndrivers/net/ethernet/airoha/airoha_eth.c:81:\tint i;\ndrivers/net/ethernet/airoha/airoha_eth.c:82:\ndrivers/net/ethernet/airoha/airoha_eth.c:83:\teth_zero_addr(ref_addr);\ndrivers/net/ethernet/airoha/airoha_eth.c:84:\tlmin = (addr[3] \u003c\u003c 16) | (addr[4] \u003c\u003c 8) | addr[5];\ndrivers/net/ethernet/airoha/airoha_eth.c:85:\tlmax = lmin;\ndrivers/net/ethernet/airoha/airoha_eth.c:86:\ndrivers/net/ethernet/airoha/airoha_eth.c:87:\tfor (i = 0; i \u003c ARRAY_SIZE(eth-\u003eports); i++) {\ndrivers/net/ethernet/airoha/airoha_eth.c:88:\t\tstruct airoha_gdm_port *port = eth-\u003eports[i];\ndrivers/net/ethernet/airoha/airoha_eth.c:89:\t\tint j;\ndrivers/net/ethernet/airoha/airoha_eth.c:90:\ndrivers/net/ethernet/airoha/airoha_eth.c:91:\t\tif (!port)\ndrivers/net/ethernet/airoha/airoha_eth.c:92:\t\t\tcontinue;\ndrivers/net/ethernet/airoha/airoha_eth.c:93:\ndrivers/net/ethernet/airoha/airoha_eth.c:94:\t\tfor (j = 0; j \u003c ARRAY_SIZE(port-\u003edevs); j++) {\ndrivers/net/ethernet/airoha/airoha_eth.c:95:\t\t\tstruct airoha_gdm_dev *iter_dev;\ndrivers/net/ethernet/airoha/airoha_eth.c:96:\t\t\tstruct net_device *netdev;\ndrivers/net/ethernet/airoha/airoha_eth.c:97:\ndrivers/net/ethernet/airoha/airoha_eth.c:98:\t\t\titer_dev = port-\u003edevs[j];\ndrivers/net/ethernet/airoha/airoha_eth.c:99:\t\t\tif (!iter_dev || iter_dev == dev)\ndrivers/net/ethernet/airoha/airoha_eth.c:100:\t\t\t\tcontinue;\ndrivers/net/ethernet/airoha/airoha_eth.c:101:\ndrivers/net/ethernet/airoha/airoha_eth.c:102:\t\t\tif (airoha_is_lan_gdm_dev(iter_dev) !=\ndrivers/net/ethernet/airoha/airoha_eth.c:103:\t\t\t    airoha_is_lan_gdm_dev(dev))\ndrivers/net/ethernet/airoha/airoha_eth.c:104:\t\t\t\tcontinue;\ndrivers/net/ethernet/airoha/airoha_eth.c:105:\ndrivers/net/ethernet/airoha/airoha_eth.c:106:\t\t\tnetdev = netdev_from_priv(iter_dev);\ndrivers/net/ethernet/airoha/airoha_eth.c:107:\t\t\tif (netdev-\u003ereg_state != NETREG_REGISTERED)\ndrivers/net/ethernet/airoha/airoha_eth.c:108:\t\t\t\tcontinue;\ndrivers/net/ethernet/airoha/airoha_eth.c:109:\ndrivers/net/ethernet/airoha/airoha_eth.c:110:\t\t\tether_addr_copy(ref_addr, netdev-\u003edev_addr);\ndrivers/net/ethernet/airoha/airoha_eth.c:111:\t\t\tval = (netdev-\u003edev_addr[3] \u003c\u003c 16) |\ndrivers/net/ethernet/airoha/airoha_eth.c:112:\t\t\t      (netdev-\u003edev_addr[4] \u003c\u003c 8) | netdev-\u003edev_addr[5];\ndrivers/net/ethernet/airoha/airoha_eth.c:113:\t\t\tif (val \u003c lmin)\ndrivers/net/ethernet/airoha/airoha_eth.c:114:\t\t\t\tlmin = val;\ndrivers/net/ethernet/airoha/airoha_eth.c:115:\t\t\tif (val \u003e lmax)\ndrivers/net/ethernet/airoha/airoha_eth.c:116:\t\t\t\tlmax = val;\ndrivers/net/ethernet/airoha/airoha_eth.c:117:\t\t}\ndrivers/net/ethernet/airoha/airoha_eth.c:118:\t}\ndrivers/net/ethernet/airoha/airoha_eth.c:119:\ndrivers/net/ethernet/airoha/airoha_eth.c:120:\tif (!is_zero_ether_addr(ref_addr) \u0026\u0026 memcmp(ref_addr, addr, 3)) {\ndrivers/net/ethernet/airoha/airoha_eth.c:121:\t\t/* According to the HW design, hw mac address MSBs must be\ndrivers/net/ethernet/airoha/airoha_eth.c:122:\t\t * the same for each net_device with the same LAN/WAN\ndrivers/net/ethernet/airoha/airoha_eth.c:123:\t\t * configuration.\ndrivers/net/ethernet/airoha/airoha_eth.c:124:\t\t */\ndrivers/net/ethernet/airoha/airoha_eth.c:125:\t\tstruct net_device *netdev = netdev_from_priv(dev);\ndrivers/net/ethernet/airoha/airoha_eth.c:126:\ndrivers/net/ethernet/airoha/airoha_eth.c:127:\t\tdev_warn(eth-\u003edev,\ndrivers/net/ethernet/airoha/airoha_eth.c:128:\t\t\t \"%s: wrong mac addr, MSBs must be %02x:%02x:%02x\\n\",\ndrivers/net/ethernet/airoha/airoha_eth.c:129:\t\t\t netdev-\u003ename, ref_addr[0], ref_addr[1],\ndrivers/net/ethernet/airoha/airoha_eth.c:130:\t\t\t ref_addr[2]);\ndrivers/net/ethernet/airoha/airoha_eth.c:131:\t\tdev_warn(eth-\u003edev, \"FE hw forwarding won't work properly\\n\");\ndrivers/net/ethernet/airoha/airoha_eth.c:132:\ndrivers/net/ethernet/airoha/airoha_eth.c:133:\t\treturn -EINVAL;\ndrivers/net/ethernet/airoha/airoha_eth.c:134:\t}\ndrivers/net/ethernet/airoha/airoha_eth.c:135:\ndrivers/net/ethernet/airoha/airoha_eth.c:136:\treg = airoha_is_lan_gdm_dev(dev) ? REG_FE_LAN_MAC_H : REG_FE_WAN_MAC_H;\ndrivers/net/ethernet/airoha/airoha_eth.c:137:\tval = (addr[0] \u003c\u003c 16) | (addr[1] \u003c\u003c 8) | addr[2];\ndrivers/net/ethernet/airoha/airoha_eth.c:138:\tairoha_fe_wr(eth, reg, val);\ndrivers/net/ethernet/airoha/airoha_eth.c:139:\ndrivers/net/ethernet/airoha/airoha_eth.c:140:\tairoha_fe_wr(eth, REG_FE_MAC_LMIN(reg), lmin);\ndrivers/net/ethernet/airoha/airoha_eth.c:141:\tairoha_fe_wr(eth, REG_FE_MAC_LMAX(reg), lmax);\ndrivers/net/ethernet/airoha/airoha_eth.c:142:\ndrivers/net/ethernet/airoha/airoha_eth.c:143:\tairoha_ppe_init_upd_mem(dev, addr);\ndrivers/net/ethernet/airoha/airoha_eth.c:144:\ndrivers/net/ethernet/airoha/airoha_eth.c:145:\treturn 0;\ndrivers/net/ethernet/airoha/airoha_eth.c:146:}\ndrivers/net/ethernet/airoha/airoha_eth.c:147:\ndrivers/net/ethernet/airoha/airoha_eth.c:148:static void airoha_set_gdm_port_fwd_cfg(struct airoha_eth *eth, u32 addr,\ndrivers/net/ethernet/airoha/airoha_eth.c:149:\t\t\t\t\tu32 val)\ndrivers/net/ethernet/airoha/airoha_eth.c:150:{\ndrivers/net/ethernet/airoha/airoha_eth.c:151:\tairoha_fe_rmw(eth, addr, GDM_OCFQ_MASK,\ndrivers/net/ethernet/airoha/airoha_eth.c:152:\t\t      FIELD_PREP(GDM_OCFQ_MASK, val));\ndrivers/net/ethernet/airoha/airoha_eth.c:153:\tairoha_fe_rmw(eth, addr, GDM_MCFQ_MASK,\ndrivers/net/ethernet/airoha/airoha_eth.c:154:\t\t      FIELD_PREP(GDM_MCFQ_MASK, val));\ndrivers/net/ethernet/airoha/airoha_eth.c:155:\tairoha_fe_rmw(eth, addr, GDM_BCFQ_MASK,\n\n"
}

9/2 2026/10/14 12:05 llm patch-evaluator
0m Model:
gemini-3.8-flash

Args:
null

Results:
null

Tokens:
							input: 76236
							output: 38
							thoughts: 36
						

Thoughts:
Okay, let's dive into this. Here's how I'd approach this task, as if these were my internal thoughts:

**Investigating PHY Connection in airoha_eth.c**

Alright, I need to understand how the PHY is being handled within `airoha_eth.c`. My immediate thought is, "Let's crack open that file and get a visual sense of the landscape." Given my expertise, I already have a mental model of how these network driver components are typically structured. I'll need to identify the exact connection points.

My next step? Let's use `grep`. I'll run a quick search for the term "phy" *within* `airoha_eth.c`. This simple command should quickly pinpoint relevant mentions of the PHY – whether it's related to initialization, configuration, data transfer, or interrupt handling. This gives me my bearings and highlights the specific lines I need to focus on. From there, I can interpret what the code is doing.



10/2 2026/10/14 12:05 tool grepper
0m Args:
{
  "Expression": "phy",
  "PathPrefixes": [
    "drivers/net/ethernet/airoha/airoha_eth.c"
  ]
}

Results:
{
  "Output": "drivers/net/ethernet/airoha/airoha_eth.c=3695=static const struct ethtool_ops airoha_ethtool_ops = {\n--\ndrivers/net/ethernet/airoha/airoha_eth.c-3698-\t.get_rmon_stats\t\t= airoha_ethtool_get_rmon_stats,\ndrivers/net/ethernet/airoha/airoha_eth.c:3699:\t.get_link_ksettings\t= phy_ethtool_get_link_ksettings,\ndrivers/net/ethernet/airoha/airoha_eth.c-3700-\t.get_link\t\t= ethtool_op_get_link,\n"
}

11/2 2026/10/14 12:05 llm patch-evaluator
0m Model:
gemini-3.8-flash

Args:
null

Results:
null

Tokens:
							input: 76712
							output: 34
							thoughts: 65
						

Thoughts:
Here's my analysis of the situation:

**Investigating the Airoha Ethernet Driver Integration**

Okay, so I'm looking at `airoha_eth.c`. The first thing that jumps out is the absence of an MDIO bus registration, or perhaps it's a platform driver situation. I need to clarify that. Before I dive too deep into the code, though, I'm going to take a step back and check the device tree bindings. Let me search for `airoha,en7581-eth.yaml` in `Documentation/devicetree/bindings/`. That's where the real story usually resides. Finding the bindings will guide me in understanding how this driver is *meant* to work with the hardware and other aspects of the system.



12/2 2026/10/14 12:05 tool grepper
0m Args:
{
  "Expression": "airoha.*phy",
  "PathPrefixes": [
    "Documentation/devicetree/bindings/"
  ]
}

Results:
{
  "Output": "Documentation/devicetree/bindings/phy/airoha,en7581-pcie-phy.yaml-3----\nDocumentation/devicetree/bindings/phy/airoha,en7581-pcie-phy.yaml:4:$id: http://devicetree.org/schemas/phy/airoha,en7581-pcie-phy.yaml#\nDocumentation/devicetree/bindings/phy/airoha,en7581-pcie-phy.yaml-5-$schema: http://devicetree.org/meta-schemas/core.yaml#\n--\nDocumentation/devicetree/bindings/phy/airoha,en7581-pcie-phy.yaml=15=properties:\nDocumentation/devicetree/bindings/phy/airoha,en7581-pcie-phy.yaml-16-  compatible:\nDocumentation/devicetree/bindings/phy/airoha,en7581-pcie-phy.yaml:17:    const: airoha,en7581-pcie-phy\nDocumentation/devicetree/bindings/phy/airoha,en7581-pcie-phy.yaml-18-\n--\nDocumentation/devicetree/bindings/phy/airoha,en7581-pcie-phy.yaml=48=examples:\n--\nDocumentation/devicetree/bindings/phy/airoha,en7581-pcie-phy.yaml-56-        phy@11e80000 {\nDocumentation/devicetree/bindings/phy/airoha,en7581-pcie-phy.yaml:57:            compatible = \"airoha,en7581-pcie-phy\";\nDocumentation/devicetree/bindings/phy/airoha,en7581-pcie-phy.yaml-58-            #phy-cells = \u003c0\u003e;\n"
}

13/2 2026/10/14 12:05 llm patch-evaluator
0m Model:
gemini-3.8-flash

Args:
null

Results:
null

Tokens:
							input: 77446
							output: 43
							thoughts: 34
						

Thoughts:
Okay, here's my take on those thoughts, tailored for an expert audience:

**Investigating Device Tree Overlays for AN7581/EN7581/ECONET Support**

Right, so I'm thinking, where are the likely candidates for device tree overlays or base configurations related to, say, AN7581 or its siblings EN7581 or ECONET? My gut feeling is to check within the `arch/arm64/boot/dts` directory, or something analogous if the architecture isn't precisely arm64. That’s the typical place to find device tree source files that describe hardware configurations for those architectures. I need to quickly scan those files for any references or clues. I'm assuming the kernel would have been configured with some support for it, so there *should* be something there. If not, I'll need to dig deeper into the kernel's documentation or the vendor's documentation for pointers on where these device descriptions might reside or how to integrate them. Let's start with the obvious first.



14/2 2026/10/14 12:05 tool grepper
0m Args:
{
  "Expression": "en7581|an7581",
  "PathPrefixes": [
    "arch/arm64/boot/dts/"
  ]
}

Results:
{
  "Output": "arch/arm64/boot/dts/airoha/Makefile-1-# SPDX-License-Identifier: GPL-2.0-only\narch/arm64/boot/dts/airoha/Makefile:2:dtb-$(CONFIG_ARCH_AIROHA) += en7581-evb.dtb\n--\narch/arm64/boot/dts/airoha/en7581-evb.dts-6-\narch/arm64/boot/dts/airoha/en7581-evb.dts:7:#include \"en7581.dtsi\"\narch/arm64/boot/dts/airoha/en7581-evb.dts-8-\narch/arm64/boot/dts/airoha/en7581-evb.dts=9=/ {\narch/arm64/boot/dts/airoha/en7581-evb.dts-10-\tmodel = \"Airoha EN7581 Evaluation Board\";\narch/arm64/boot/dts/airoha/en7581-evb.dts:11:\tcompatible = \"airoha,en7581-evb\", \"airoha,en7581\";\narch/arm64/boot/dts/airoha/en7581-evb.dts-12-\n--\narch/arm64/boot/dts/airoha/en7581-evb.dts=60=\t\treserved-bmt@7e00000 {\n--\narch/arm64/boot/dts/airoha/en7581-evb.dts-67-\narch/arm64/boot/dts/airoha/en7581-evb.dts:68:\u0026en7581_pinctrl {\narch/arm64/boot/dts/airoha/en7581-evb.dts:69:\tgpio-ranges = \u003c\u0026en7581_pinctrl 0 13 47\u003e;\narch/arm64/boot/dts/airoha/en7581-evb.dts-70-\n--\narch/arm64/boot/dts/airoha/en7581.dtsi-5-#include \u003cdt-bindings/clock/en7523-clk.h\u003e\narch/arm64/boot/dts/airoha/en7581.dtsi:6:#include \u003cdt-bindings/reset/airoha,en7581-reset.h\u003e\narch/arm64/boot/dts/airoha/en7581.dtsi-7-\n--\narch/arm64/boot/dts/airoha/en7581.dtsi=153=\t\tspi@1fa10000 {\narch/arm64/boot/dts/airoha/en7581.dtsi:154:\t\t\tcompatible = \"airoha,en7581-snand\";\narch/arm64/boot/dts/airoha/en7581.dtsi-155-\t\t\treg = \u003c0x0 0x1fa10000 0x0 0x140\u003e,\n--\narch/arm64/boot/dts/airoha/en7581.dtsi=176=\t\tscuclk: clock-controller@1fb00000 {\narch/arm64/boot/dts/airoha/en7581.dtsi:177:\t\t\tcompatible = \"airoha,en7581-scu\";\narch/arm64/boot/dts/airoha/en7581.dtsi-178-\t\t\treg = \u003c0x0 0x1fb00000 0x0 0x970\u003e;\n--\narch/arm64/boot/dts/airoha/en7581.dtsi=183=\t\tpbus_csr: syscon@1fbe3400 {\narch/arm64/boot/dts/airoha/en7581.dtsi:184:\t\t\tcompatible = \"airoha,en7581-pbus-csr\", \"syscon\";\narch/arm64/boot/dts/airoha/en7581.dtsi-185-\t\t\treg = \u003c0x0 0x1fbe3400 0x0 0xff\u003e;\n--\narch/arm64/boot/dts/airoha/en7581.dtsi=188=\t\tpciephy: phy@1fa5a000 {\narch/arm64/boot/dts/airoha/en7581.dtsi:189:\t\t\tcompatible = \"airoha,en7581-pcie-phy\";\narch/arm64/boot/dts/airoha/en7581.dtsi-190-\t\t\treg = \u003c0x0 0x1fa5a000 0x0 0xfff\u003e,\n--\narch/arm64/boot/dts/airoha/en7581.dtsi=202=\t\tpcie0: pcie@1fc00000 {\narch/arm64/boot/dts/airoha/en7581.dtsi:203:\t\t\tcompatible = \"airoha,en7581-pcie\";\narch/arm64/boot/dts/airoha/en7581.dtsi-204-\t\t\tdevice_type = \"pci\";\n--\narch/arm64/boot/dts/airoha/en7581.dtsi=245=\t\tpcie1: pcie@1fc20000 {\narch/arm64/boot/dts/airoha/en7581.dtsi:246:\t\t\tcompatible = \"airoha,en7581-pcie\";\narch/arm64/boot/dts/airoha/en7581.dtsi-247-\t\t\tdevice_type = \"pci\";\n--\narch/arm64/boot/dts/airoha/en7581.dtsi=297=\t\trng@1faa1000 {\narch/arm64/boot/dts/airoha/en7581.dtsi:298:\t\t\tcompatible = \"airoha,en7581-trng\";\narch/arm64/boot/dts/airoha/en7581.dtsi-299-\t\t\treg = \u003c0x0 0x1faa1000 0x0 0xc04\u003e;\n--\narch/arm64/boot/dts/airoha/en7581.dtsi=303=\t\tsystem-controller@1fbf0200 {\narch/arm64/boot/dts/airoha/en7581.dtsi:304:\t\t\tcompatible = \"airoha,en7581-gpio-sysctl\", \"syscon\",\narch/arm64/boot/dts/airoha/en7581.dtsi-305-\t\t\t\t     \"simple-mfd\";\n--\narch/arm64/boot/dts/airoha/en7581.dtsi-307-\narch/arm64/boot/dts/airoha/en7581.dtsi:308:\t\t\ten7581_pinctrl: pinctrl {\narch/arm64/boot/dts/airoha/en7581.dtsi:309:\t\t\t\tcompatible = \"airoha,en7581-pinctrl\";\narch/arm64/boot/dts/airoha/en7581.dtsi-310-\n--\narch/arm64/boot/dts/airoha/en7581.dtsi=350=\t\teth: ethernet@1fb50000 {\narch/arm64/boot/dts/airoha/en7581.dtsi:351:\t\t\tcompatible = \"airoha,en7581-eth\";\narch/arm64/boot/dts/airoha/en7581.dtsi-352-\t\t\treg = \u003c0 0x1fb50000 0 0x2600\u003e,\n"
}

15/2 2026/10/14 12:05 llm patch-evaluator
0m Model:
gemini-3.8-flash

Args:
null

Results:
null

Tokens:
							input: 79808
							output: 50
							thoughts: 85
						

Thoughts:
Okay, let's break this down.

**Diving into the EN7581 Device Tree**

Alright, I'm going to take a look at the device tree source for the EN7581. Specifically, I'm starting with line 350 of `arch/arm64/boot/dts/airoha/en7581.dtsi`. That line looks interesting; it's got `airoha,en7581-eth`, which is a key starting point for understanding the Ethernet configuration, I assume. I need to get a better handle on the relevant Ethernet configuration, so I'm going to quickly read through lines 350 to 400. That should give me a good context of what's going on in that section. Time to see what's defined.



16/2 2026/10/14 12:05 tool read-file
0m Args:
{
  "File": "arch/arm64/boot/dts/airoha/en7581.dtsi",
  "FirstLine": 350,
  "LineCount": 60
}

Results:
{
  "Contents": " 350:\t\t\teth: ethernet@1fb50000 {\n 351:\t\t\t\tcompatible = \"airoha,en7581-eth\";\n 352:\t\t\t\treg = \u003c0 0x1fb50000 0 0x2600\u003e,\n 353:\t\t\t\t      \u003c0 0x1fb54000 0 0x2000\u003e,\n 354:\t\t\t\t      \u003c0 0x1fb56000 0 0x2000\u003e;\n 355:\t\t\t\treg-names = \"fe\", \"qdma0\", \"qdma1\";\n 356:\t\n 357:\t\t\t\tresets = \u003c\u0026scuclk EN7581_FE_RST\u003e,\n 358:\t\t\t\t\t \u003c\u0026scuclk EN7581_FE_PDMA_RST\u003e,\n 359:\t\t\t\t\t \u003c\u0026scuclk EN7581_FE_QDMA_RST\u003e,\n 360:\t\t\t\t\t \u003c\u0026scuclk EN7581_XSI_MAC_RST\u003e,\n 361:\t\t\t\t\t \u003c\u0026scuclk EN7581_DUAL_HSI0_MAC_RST\u003e,\n 362:\t\t\t\t\t \u003c\u0026scuclk EN7581_DUAL_HSI1_MAC_RST\u003e,\n 363:\t\t\t\t\t \u003c\u0026scuclk EN7581_HSI_MAC_RST\u003e,\n 364:\t\t\t\t\t \u003c\u0026scuclk EN7581_XFP_MAC_RST\u003e;\n 365:\t\t\t\treset-names = \"fe\", \"pdma\", \"qdma\",\n 366:\t\t\t\t\t      \"xsi-mac\", \"hsi0-mac\", \"hsi1-mac\",\n 367:\t\t\t\t\t      \"hsi-mac\", \"xfp-mac\";\n 368:\t\n 369:\t\t\t\tinterrupts = \u003cGIC_SPI 37 IRQ_TYPE_LEVEL_HIGH\u003e,\n 370:\t\t\t\t\t     \u003cGIC_SPI 55 IRQ_TYPE_LEVEL_HIGH\u003e,\n 371:\t\t\t\t\t     \u003cGIC_SPI 56 IRQ_TYPE_LEVEL_HIGH\u003e,\n 372:\t\t\t\t\t     \u003cGIC_SPI 57 IRQ_TYPE_LEVEL_HIGH\u003e,\n 373:\t\t\t\t\t     \u003cGIC_SPI 38 IRQ_TYPE_LEVEL_HIGH\u003e,\n 374:\t\t\t\t\t     \u003cGIC_SPI 58 IRQ_TYPE_LEVEL_HIGH\u003e,\n 375:\t\t\t\t\t     \u003cGIC_SPI 59 IRQ_TYPE_LEVEL_HIGH\u003e,\n 376:\t\t\t\t\t     \u003cGIC_SPI 60 IRQ_TYPE_LEVEL_HIGH\u003e,\n 377:\t\t\t\t\t     \u003cGIC_SPI 49 IRQ_TYPE_LEVEL_HIGH\u003e,\n 378:\t\t\t\t\t     \u003cGIC_SPI 64 IRQ_TYPE_LEVEL_HIGH\u003e;\n 379:\t\n 380:\t\t\t\tstatus = \"disabled\";\n 381:\t\n 382:\t\t\t\t#address-cells = \u003c1\u003e;\n 383:\t\t\t\t#size-cells = \u003c0\u003e;\n 384:\t\n 385:\t\t\t\tgdm1: ethernet@1 {\n 386:\t\t\t\t\tcompatible = \"airoha,eth-mac\";\n 387:\t\t\t\t\treg = \u003c1\u003e;\n 388:\t\t\t\t\tphy-mode = \"internal\";\n 389:\t\t\t\t\tstatus = \"disabled\";\n 390:\t\n 391:\t\t\t\t\tfixed-link {\n 392:\t\t\t\t\t\tspeed = \u003c10000\u003e;\n 393:\t\t\t\t\t\tfull-duplex;\n 394:\t\t\t\t\t\tpause;\n 395:\t\t\t\t\t};\n 396:\t\t\t\t};\n 397:\t\t\t};\n 398:\t\t};\n 399:\t};\n"
}

17/2 2026/10/14 12:05 llm patch-evaluator
0m Model:
gemini-3.8-flash

Args:
null

Results:
null

Tokens:
							input: 81066
							output: 37
							thoughts: 54
						

Thoughts:
Okay, here's my interpretation of those thoughts, tailored for an expert audience, presented in the first person:

**Initial Assessment and Query Generation**

Alright, so `airoha,en7581` immediately flags as an ARM64 System-on-a-Chip, specifically an Airoha EN7581. That's a decent starting point. The EN7581's architecture tells me quite a bit immediately, but I need more context to understand its precise function.

My mind then quickly jumps to "what about the EN7528?". It's natural to compare and contrast related families. Perhaps there's an association.

To move forward, I should broaden the net. So, I will immediately initiate searches for both `EN7528` and also `ECONET`. The latter may be a related platform or codename. Exploring both names will likely bring the necessary results.



18/2 2026/10/14 12:05 tool grepper
0m Args:
{
  "Expression": "ECONET|en7523|en7528",
  "PathPrefixes": [
    "arch/"
  ]
}

Results:
{
  "Output": "arch/arm/boot/dts/airoha/Makefile=2=dtb-$(CONFIG_ARCH_AIROHA) += \\\narch/arm/boot/dts/airoha/Makefile:3:\ten7523-evb.dtb\n--\narch/arm/boot/dts/airoha/en7523-evb.dts-6-\narch/arm/boot/dts/airoha/en7523-evb.dts:7:#include \"en7523.dtsi\"\narch/arm/boot/dts/airoha/en7523-evb.dts-8-\narch/arm/boot/dts/airoha/en7523-evb.dts=9=/ {\narch/arm/boot/dts/airoha/en7523-evb.dts-10-\tmodel = \"Airoha EN7523 Evaluation Board\";\narch/arm/boot/dts/airoha/en7523-evb.dts:11:\tcompatible = \"airoha,en7523-evb\", \"airoha,en7523\";\narch/arm/boot/dts/airoha/en7523-evb.dts-12-\n--\narch/arm/boot/dts/airoha/en7523.dtsi-5-#include \u003cdt-bindings/gpio/gpio.h\u003e\narch/arm/boot/dts/airoha/en7523.dtsi:6:#include \u003cdt-bindings/clock/en7523-clk.h\u003e\narch/arm/boot/dts/airoha/en7523.dtsi-7-\n--\narch/arm/boot/dts/airoha/en7523.dtsi=89=\tscu: system-controller@1fa20000 {\narch/arm/boot/dts/airoha/en7523.dtsi:90:\t\tcompatible = \"airoha,en7523-scu\";\narch/arm/boot/dts/airoha/en7523.dtsi-91-\t\treg = \u003c0x1fa20000 0x400\u003e,\n--\narch/arm/boot/dts/airoha/en7523.dtsi=129=\tgpio0: gpio@1fbf0200 {\narch/arm/boot/dts/airoha/en7523.dtsi:130:\t\tcompatible = \"airoha,en7523-gpio\";\narch/arm/boot/dts/airoha/en7523.dtsi-131-\t\treg = \u003c0x1fbf0204 0x4\u003e,\n--\narch/arm/boot/dts/airoha/en7523.dtsi=139=\tgpio1: gpio@1fbf0270 {\narch/arm/boot/dts/airoha/en7523.dtsi:140:\t\tcompatible = \"airoha,en7523-gpio\";\narch/arm/boot/dts/airoha/en7523.dtsi-141-\t\treg = \u003c0x1fbf0270 0x4\u003e,\n--\narch/arm/boot/dts/airoha/en7523.dtsi=149=\tpcie0: pcie@1fa91000 {\narch/arm/boot/dts/airoha/en7523.dtsi:150:\t\tcompatible = \"airoha,en7523-pcie\", \"mediatek,mt7622-pcie\";\narch/arm/boot/dts/airoha/en7523.dtsi-151-\t\tdevice_type = \"pci\";\n--\narch/arm/boot/dts/airoha/en7523.dtsi=178=\tpcie1: pcie@1fa92000 {\narch/arm/boot/dts/airoha/en7523.dtsi:179:\t\tcompatible = \"airoha,en7523-pcie\", \"mediatek,mt7622-pcie\";\narch/arm/boot/dts/airoha/en7523.dtsi-180-\t\tdevice_type = \"pci\";\n--\narch/arm/mach-rpc/include/mach/irqs.h-31-#define FIQ_FLOPPYDATA\t\t0\narch/arm/mach-rpc/include/mach/irqs.h:32:#define FIQ_ECONET\t\t2\narch/arm/mach-rpc/include/mach/irqs.h-33-#define FIQ_SERIALPORT\t\t4\n--\narch/arm64/boot/dts/airoha/en7581.dtsi-4-#include \u003cdt-bindings/interrupt-controller/arm-gic.h\u003e\narch/arm64/boot/dts/airoha/en7581.dtsi:5:#include \u003cdt-bindings/clock/en7523-clk.h\u003e\narch/arm64/boot/dts/airoha/en7581.dtsi-6-#include \u003cdt-bindings/reset/airoha,en7581-reset.h\u003e\n--\narch/mips/Kbuild.platforms=13=platform-$(CONFIG_MACH_DECSTATION)\t+= dec/\narch/mips/Kbuild.platforms:14:platform-$(CONFIG_ECONET)\t\t+= econet/\narch/mips/Kbuild.platforms-15-platform-$(CONFIG_MIPS_GENERIC)\t\t+= generic/\n--\narch/mips/Kconfig=358=config MACH_DECSTATION\n--\narch/mips/Kconfig-394-\narch/mips/Kconfig:395:config ECONET\narch/mips/Kconfig-396-\tbool \"EcoNet MIPS family\"\n--\narch/mips/Kconfig-398-\tselect DEBUG_ZBOOT if DEBUG_KERNEL\narch/mips/Kconfig:399:\tselect ECONET_EN751221_TIMER\narch/mips/Kconfig-400-\tselect SYS_SUPPORTS_BIG_ENDIAN\n--\narch/mips/boot/compressed/uart-16550.c-22-\narch/mips/boot/compressed/uart-16550.c:23:#ifdef CONFIG_ECONET\narch/mips/boot/compressed/uart-16550.c-24-#define EN75_UART_BASE\t0x1fbf0003\n--\narch/mips/boot/dts/econet/Makefile-1-# SPDX-License-Identifier: GPL-2.0\narch/mips/boot/dts/econet/Makefile:2:dtb-$(CONFIG_DTB_ECONET_SMARTFIBER_XP8421_B)\t+= en751221_smartfiber_xp8421-b.dtb\n--\narch/mips/boot/dts/econet/en751221.dtsi=82=\tpcie0: pcie@1fb81000 {\narch/mips/boot/dts/econet/en751221.dtsi:83:\t\tcompatible = \"econet,en7528-pcie\";\narch/mips/boot/dts/econet/en751221.dtsi-84-\t\tdevice_type = \"pci\";\n--\narch/mips/boot/dts/econet/en751221.dtsi=124=\tpcie1: pcie@1fb83000 {\narch/mips/boot/dts/econet/en751221.dtsi:125:\t\tcompatible = \"econet,en7528-pcie\";\narch/mips/boot/dts/econet/en751221.dtsi-126-\t\tdevice_type = \"pci\";\n--\narch/mips/configs/econet_en751221_defconfig=34=CONFIG_EXPERT=y\n--\narch/mips/configs/econet_en751221_defconfig-38-# CONFIG_CACHESTAT_SYSCALL is not set\narch/mips/configs/econet_en751221_defconfig:39:CONFIG_ECONET=y\narch/mips/configs/econet_en751221_defconfig-40-CONFIG_CPU_MIPS32_R2=y\n--\narch/mips/configs/econet_en751221_defconfig=212=CONFIG_RESET_CONTROLLER=y\narch/mips/configs/econet_en751221_defconfig:213:CONFIG_PHY_ECONET_PCIE=y\narch/mips/configs/econet_en751221_defconfig-214-# CONFIG_DNOTIFY is not set\n--\narch/mips/econet/Kconfig-1-# SPDX-License-Identifier: GPL-2.0\narch/mips/econet/Kconfig:2:if ECONET\narch/mips/econet/Kconfig-3-\narch/mips/econet/Kconfig=4=choice\narch/mips/econet/Kconfig-5-\tprompt \"EcoNet SoC selection\"\narch/mips/econet/Kconfig:6:\tdefault SOC_ECONET_EN751221\narch/mips/econet/Kconfig-7-\thelp\n--\narch/mips/econet/Kconfig-11-\narch/mips/econet/Kconfig:12:\tconfig SOC_ECONET_EN751221\narch/mips/econet/Kconfig-13-\t\tbool \"EN751221 family\"\narch/mips/econet/Kconfig-14-\t\tselect COMMON_CLK\narch/mips/econet/Kconfig:15:\t\tselect ECONET_EN751221_INTC\narch/mips/econet/Kconfig-16-\t\tselect HAVE_PCI\n--\narch/mips/econet/Kconfig=27=choice\narch/mips/econet/Kconfig-28-\tprompt \"Devicetree selection\"\narch/mips/econet/Kconfig:29:\tdefault DTB_ECONET_NONE\narch/mips/econet/Kconfig-30-\thelp\n--\narch/mips/econet/Kconfig-32-\narch/mips/econet/Kconfig:33:\tconfig DTB_ECONET_NONE\narch/mips/econet/Kconfig-34-\t\tbool \"None\"\narch/mips/econet/Kconfig-35-\narch/mips/econet/Kconfig:36:\tconfig DTB_ECONET_SMARTFIBER_XP8421_B\narch/mips/econet/Kconfig-37-\t\tbool \"EN751221 SmartFiber XP8421-B\"\narch/mips/econet/Kconfig:38:\t\tdepends on SOC_ECONET_EN751221\narch/mips/econet/Kconfig-39-\t\tselect BUILTIN_DTB\n--\narch/mips/econet/Platform-4-# bootloader actually places the kernel.\narch/mips/econet/Platform:5:load-$(CONFIG_ECONET)\t+= 0xffffffff81000000\n"
}

19/2 2026/10/14 12:05 llm patch-evaluator
0m Model:
gemini-3.8-flash

Args:
null

Results:
null

Tokens:
							input: 84210
							output: 33
							thoughts: 1005
						

Thoughts:
**Analyzing Driver Reachability on amd64**

Okay, let's break this down. First, I see that ARCH_AIROHA is either ARM64 or 32-bit ARM, depending on the SoC (Airoha EN7581/EN7523), and ECONET is MIPS (EcoNet EN751221/EN7528). Then, I'm noting the MT7981 and MT7988 references in `mtk-ge-soc.c`, which are MediaTek ARM64 Filogic Wi-Fi router SoCs. Looking at `drivers/net/phy/mediatek/Kconfig`, I see that `MEDIATEK_GE_SOC_PHY` depends on either ARM64 or COMPILE_TEST. This looks like MediaTek built-in Gigabit Ethernet PHY support.

Now, the crucial question: Can any of these drivers *ever* be reached on the target architecture, amd64? This is key, according to the instructions. The prompt is explicit that we *must not* fuzz unreachable code. Specifically, the prompt states, "Structurally unreachable hardware: * Vendor-specific PCIe switches, SmartNICs, or GPU drivers (e.g., mlxsw, pds_core, qed, ionic, amdgpu) requiring physical ASIC/PCIe cards not emulated in standard QEMU. * Unreachable execution paths: * Driver teardown callbacks (.remove, .shutdown, pci_unregister_driver) executed only during physical PCI hot-unplug or manual sysfs driver unbinding. * Code paths exclusive to architectures other than the target architecture."

Can an Ethernet PHY driver be probed in QEMU on amd64? I need to understand how PHY drivers are typically probed: They bind to `struct phy_device` on `mdio_bus_type`. This is created primarily via device tree/ACPI scanning of MDIO buses on SoC Ethernet controllers or platform devices (using `of_mdiobus_register`, `fwnode_mdiobus_register_phy`).  Or, it could be a PCI Ethernet card with an MDIO bus and attached PHY (e.g., Realtek r8169, e1000e).

The critical point is this: Do any virtualized or emulated PCI Ethernet cards or USB devices *have* an Airoha or MediaTek SoC Gigabit Ethernet PHY? No! Realtek uses Realtek PHY (or internal), e1000 uses Intel PHY. And the descriptions of AIROHA_GE_SOC_PHY and MEDIATEK_GE_SOC_PHY are clear. They are for "Airoha SoC built-in Gigabit Ethernet PHYs" and "MediaTek SoC built-in Gigabit Ethernet PHYs." They calibrate dynamically during startup.

These are built-in internal SoC Ethernet PHYs, physically integrated into the silicon of MediaTek and Airoha ARM64/MIPS SoCs (AN7581, AN7583, EN7528, MT7981, MT7988). They *do not* exist on discrete PCIe cards or USB devices.  They are *certainly* not present in standard QEMU on amd64.

Okay, is there a way for userspace to somehow inject an MDIO device via sysfs, netlink, or a mock MDIO bus? I need to check if Linux provides such a userspace interface by grepping for `mdio_bus_type` and `mdiobus_register`. This seems unlikely, but it's worth the check.



20/2 2026/10/14 12:05 tool grepper
0m Args:
{
  "Expression": "mdio_bus_type",
  "PathPrefixes": [
    "drivers/net/phy/"
  ]
}

Results:
{
  "Output": "drivers/net/phy/mdio_bus_provider.c=298=__ATTRIBUTE_GROUPS(mdio_bus_device_statistics);\ndrivers/net/phy/mdio_bus_provider.c-299-\ndrivers/net/phy/mdio_bus_provider.c:300:const struct bus_type mdio_bus_type = {\ndrivers/net/phy/mdio_bus_provider.c-301-\t.name\t\t= \"mdio_bus\",\n--\ndrivers/net/phy/mdio_device.c=119=struct mdio_device *mdio_device_create(struct mii_bus *bus, int addr)\n--\ndrivers/net/phy/mdio_device.c-129-\tmdiodev-\u003edev.parent = \u0026bus-\u003edev;\ndrivers/net/phy/mdio_device.c:130:\tmdiodev-\u003edev.bus = \u0026mdio_bus_type;\ndrivers/net/phy/mdio_device.c-131-\tmdiodev-\u003edevice_free = mdio_device_free;\n--\ndrivers/net/phy/mdio_device.c=285=int mdio_driver_register(struct mdio_driver *drv)\n--\ndrivers/net/phy/mdio_device.c-291-\ndrivers/net/phy/mdio_device.c:292:\tmdiodrv-\u003edriver.bus = \u0026mdio_bus_type;\ndrivers/net/phy/mdio_device.c-293-\tmdiodrv-\u003edriver.probe = mdio_probe;\n--\ndrivers/net/phy/phy_device.c=658=struct phy_device *phy_device_create(struct mii_bus *bus, int addr, u32 phy_id,\n--\ndrivers/net/phy/phy_device.c-672-\tmdiodev-\u003edev.parent = \u0026bus-\u003edev;\ndrivers/net/phy/phy_device.c:673:\tmdiodev-\u003edev.bus = \u0026mdio_bus_type;\ndrivers/net/phy/phy_device.c-674-\tmdiodev-\u003edev.type = \u0026mdio_bus_phy_type;\n--\ndrivers/net/phy/phy_device.c=1171=struct phy_device *phy_connect(struct net_device *dev, const char *bus_id,\n--\ndrivers/net/phy/phy_device.c-1181-\t */\ndrivers/net/phy/phy_device.c:1182:\td = bus_find_device_by_name(\u0026mdio_bus_type, NULL, bus_id);\ndrivers/net/phy/phy_device.c-1183-\tif (!d) {\n--\ndrivers/net/phy/phy_device.c=3587=struct mdio_device *fwnode_mdio_find_device(struct fwnode_handle *fwnode)\n--\ndrivers/net/phy/phy_device.c-3593-\ndrivers/net/phy/phy_device.c:3594:\td = bus_find_device_by_fwnode(\u0026mdio_bus_type, fwnode);\ndrivers/net/phy/phy_device.c-3595-\tif (!d)\n--\ndrivers/net/phy/phy_device.c=3838=static int phy_driver_register(struct phy_driver *new_driver,\n--\ndrivers/net/phy/phy_device.c-3863-\tnew_driver-\u003emdiodrv.driver.name = new_driver-\u003ename;\ndrivers/net/phy/phy_device.c:3864:\tnew_driver-\u003emdiodrv.driver.bus = \u0026mdio_bus_type;\ndrivers/net/phy/phy_device.c-3865-\tnew_driver-\u003emdiodrv.driver.probe = phy_probe;\n--\ndrivers/net/phy/phy_device.c=3952=static int __init phy_init(void)\n--\ndrivers/net/phy/phy_device.c-3959-\ndrivers/net/phy/phy_device.c:3960:\trc = bus_register(\u0026mdio_bus_type);\ndrivers/net/phy/phy_device.c-3961-\tif (rc)\n--\ndrivers/net/phy/phy_device.c-3991-\trtnl_unlock();\ndrivers/net/phy/phy_device.c:3992:\tbus_unregister(\u0026mdio_bus_type);\ndrivers/net/phy/phy_device.c-3993-err_class:\n--\ndrivers/net/phy/phy_device.c=3999=static void __exit phy_exit(void)\n--\ndrivers/net/phy/phy_device.c-4006-\trtnl_unlock();\ndrivers/net/phy/phy_device.c:4007:\tbus_unregister(\u0026mdio_bus_type);\ndrivers/net/phy/phy_device.c-4008-\tclass_unregister(\u0026mdio_bus_class);\n--\ndrivers/net/phy/phylib-internal.h=10=struct phy_device;\ndrivers/net/phy/phylib-internal.h-11-\ndrivers/net/phy/phylib-internal.h:12:extern const struct bus_type mdio_bus_type;\ndrivers/net/phy/phylib-internal.h-13-extern const struct class mdio_bus_class;\n"
}

21/2 2026/10/14 12:05 llm patch-evaluator
0m Model:
gemini-3.8-flash

Args:
null

Results:
null

Tokens:
							input: 87389
							output: 42
							thoughts: 72
						

Thoughts:
Here's my analysis of what I'm looking into, from a systems perspective:

**Investigating Potential Device or Userspace Interaction with the MDIO Bus Provider**

Okay, so I'm diving into the kernel's MDIO bus handling. My immediate goal is to determine if and how new devices, or actions from userspace, might be interacting with the `mdio_bus_type`. I need to understand if there's any device creation or userspace activity happening related to this bus. I'm especially keen on any new device instantiation or configuration related to the MDIO bus.

To get started, I'm going to focus on `drivers/net/phy/mdio_bus_provider.c`. I'm going to start around line 300 in that file. That should give me a good jumping-off point to trace any potentially relevant function calls or data structures. I'll read around that code and see what I find.



22/2 2026/10/14 12:06 tool read-file
0m Args:
{
  "File": "drivers/net/phy/mdio_bus_provider.c",
  "FirstLine": 290,
  "LineCount": 40
}

Results:
{
  "Contents": " 290:\t\t\u0026dev_attr_mdio_bus_device_reads.attr.attr,\n 291:\t\tNULL,\n 292:\t};\n 293:\t\n 294:\tstatic const struct attribute_group mdio_bus_device_statistics_group = {\n 295:\t\t.name\t\t= \"statistics\",\n 296:\t\t.attrs_const\t= mdio_bus_device_statistics_attrs,\n 297:\t};\n 298:\t__ATTRIBUTE_GROUPS(mdio_bus_device_statistics);\n 299:\t\n 300:\tconst struct bus_type mdio_bus_type = {\n 301:\t\t.name\t\t= \"mdio_bus\",\n 302:\t\t.dev_groups\t= mdio_bus_device_statistics_groups,\n 303:\t\t.match\t\t= mdio_bus_match,\n 304:\t\t.uevent\t\t= mdio_uevent,\n 305:\t};\n 306:\t\n 307:\t/**\n 308:\t * mdiobus_alloc_size - allocate a mii_bus structure\n 309:\t * @size: extra amount of memory to allocate for private storage.\n 310:\t * If non-zero, then bus-\u003epriv is points to that memory.\n 311:\t *\n 312:\t * Description: called by a bus driver to allocate an mii_bus\n 313:\t * structure to fill in.\n 314:\t */\n 315:\tstruct mii_bus *mdiobus_alloc_size(size_t size)\n 316:\t{\n 317:\t\tstruct mii_bus *bus;\n 318:\t\tsize_t aligned_size = ALIGN(sizeof(*bus), NETDEV_ALIGN);\n 319:\t\tsize_t alloc_size;\n 320:\t\tint i;\n 321:\t\n 322:\t\t/* If we alloc extra space, it should be aligned */\n 323:\t\tif (size)\n 324:\t\t\talloc_size = aligned_size + size;\n 325:\t\telse\n 326:\t\t\talloc_size = sizeof(*bus);\n 327:\t\n 328:\t\tbus = kzalloc(alloc_size, GFP_KERNEL);\n 329:\t\tif (!bus)\n"
}

23/2 2026/10/14 12:06 llm patch-evaluator
0m Model:
gemini-3.8-flash

Args:
null

Results:
null

Tokens:
							input: 88320
							output: 37
							thoughts: 354
						

Thoughts:
**Analyzing PHY Device Driver Implementations**

Okay, so I'm diving into this PHY device driver situation. The first thing I'm noticing is that the `mdio_bus_type` doesn't seem to have a `new_device` attribute, unlike the I2C bus. That's a key distinction right off the bat. Now, I'm thinking, let's look at how these are handled in the existing implementations. I'll start with `airoha-ge-soc.c` because it's always good to see what's already in place.

I need to see what devices are defined with the `airoha_socphy_tbl`. Right, I'm seeing those AIROHA GPHY IDs – `AIROHA_GPHY_ID_EN7528` (0x03a29491), `AIROHA_GPHY_ID_AN7581` (0x03a294c1), and `AIROHA_GPHY_ID_AN7583` (0xc0ff0420). Now, let's cross-reference this with `mtk-ge-soc.c`, because I remember MediaTek.

Yep, there it is: `MTK_GPHY_ID_MT7981` (0x03a29461) and `MTK_GPHY_ID_MT7988` (0x03a29481). Okay, so both the Airoha and MediaTek SoCs are being addressed here.

Hang on... I should also look at `mtk-phy-lib.c`. I need to understand the relationship between the driver and the physical devices. I see functions like `mt798x_phy_led_blink_set`, `mt798x_phy_led_brightness_set`, and all the other `mt798x_phy_led_*` functions, and then the critical `__mtk_tr_write`. I need to figure out how and where these are being called. That's my next step. Time to check the call sites of these functions, to understand the control flow, so I know how to slot this thing in!



24/2 2026/10/14 12:06 tool grepper
0m Args:
{
  "Expression": "mt798x_phy_led_",
  "PathPrefixes": [
    "drivers/net/phy/"
  ]
}

Results:
{
  "Output": "drivers/net/phy/mediatek/airoha-ge-soc.c=1792=static struct phy_driver mtk_socphy_driver[] = {\n--\ndrivers/net/phy/mediatek/airoha-ge-soc.c-1797-\t\t.probe\t\t= an7581_phy_probe,\ndrivers/net/phy/mediatek/airoha-ge-soc.c:1798:\t\t.led_blink_set\t= mt798x_phy_led_blink_set,\ndrivers/net/phy/mediatek/airoha-ge-soc.c:1799:\t\t.led_brightness_set = mt798x_phy_led_brightness_set,\ndrivers/net/phy/mediatek/airoha-ge-soc.c:1800:\t\t.led_hw_is_supported = mt798x_phy_led_hw_is_supported,\ndrivers/net/phy/mediatek/airoha-ge-soc.c:1801:\t\t.led_hw_control_set = mt798x_phy_led_hw_control_set,\ndrivers/net/phy/mediatek/airoha-ge-soc.c:1802:\t\t.led_hw_control_get = mt798x_phy_led_hw_control_get,\ndrivers/net/phy/mediatek/airoha-ge-soc.c-1803-\t\t.led_polarity_set = an7581_phy_led_polarity_set,\n--\ndrivers/net/phy/mediatek/airoha-ge-soc.c-1811-\t\t.probe\t\t= an7581_phy_probe,\ndrivers/net/phy/mediatek/airoha-ge-soc.c:1812:\t\t.led_blink_set\t= mt798x_phy_led_blink_set,\ndrivers/net/phy/mediatek/airoha-ge-soc.c:1813:\t\t.led_brightness_set = mt798x_phy_led_brightness_set,\ndrivers/net/phy/mediatek/airoha-ge-soc.c:1814:\t\t.led_hw_is_supported = mt798x_phy_led_hw_is_supported,\ndrivers/net/phy/mediatek/airoha-ge-soc.c:1815:\t\t.led_hw_control_set = mt798x_phy_led_hw_control_set,\ndrivers/net/phy/mediatek/airoha-ge-soc.c:1816:\t\t.led_hw_control_get = mt798x_phy_led_hw_control_get,\ndrivers/net/phy/mediatek/airoha-ge-soc.c-1817-\t\t.led_polarity_set = an7581_phy_led_polarity_set,\n--\ndrivers/net/phy/mediatek/airoha-ge-soc.c-1825-\t\t.probe\t\t= an7581_phy_probe,\ndrivers/net/phy/mediatek/airoha-ge-soc.c:1826:\t\t.led_blink_set\t= mt798x_phy_led_blink_set,\ndrivers/net/phy/mediatek/airoha-ge-soc.c:1827:\t\t.led_brightness_set = mt798x_phy_led_brightness_set,\ndrivers/net/phy/mediatek/airoha-ge-soc.c:1828:\t\t.led_hw_is_supported = mt798x_phy_led_hw_is_supported,\ndrivers/net/phy/mediatek/airoha-ge-soc.c:1829:\t\t.led_hw_control_set = mt798x_phy_led_hw_control_set,\ndrivers/net/phy/mediatek/airoha-ge-soc.c:1830:\t\t.led_hw_control_get = mt798x_phy_led_hw_control_get,\ndrivers/net/phy/mediatek/airoha-ge-soc.c-1831-\t\t.led_polarity_set = an7581_phy_led_polarity_set,\n--\ndrivers/net/phy/mediatek/mtk-ge-soc.c=1026=static struct phy_driver mtk_socphy_driver[] = {\n--\ndrivers/net/phy/mediatek/mtk-ge-soc.c-1037-\t\t.write_page\t= mtk_phy_write_page,\ndrivers/net/phy/mediatek/mtk-ge-soc.c:1038:\t\t.led_blink_set\t= mt798x_phy_led_blink_set,\ndrivers/net/phy/mediatek/mtk-ge-soc.c:1039:\t\t.led_brightness_set = mt798x_phy_led_brightness_set,\ndrivers/net/phy/mediatek/mtk-ge-soc.c:1040:\t\t.led_hw_is_supported = mt798x_phy_led_hw_is_supported,\ndrivers/net/phy/mediatek/mtk-ge-soc.c:1041:\t\t.led_hw_control_set = mt798x_phy_led_hw_control_set,\ndrivers/net/phy/mediatek/mtk-ge-soc.c:1042:\t\t.led_hw_control_get = mt798x_phy_led_hw_control_get,\ndrivers/net/phy/mediatek/mtk-ge-soc.c-1043-\t},\n--\ndrivers/net/phy/mediatek/mtk-ge-soc.c-1054-\t\t.write_page\t= mtk_phy_write_page,\ndrivers/net/phy/mediatek/mtk-ge-soc.c:1055:\t\t.led_blink_set\t= mt798x_phy_led_blink_set,\ndrivers/net/phy/mediatek/mtk-ge-soc.c:1056:\t\t.led_brightness_set = mt798x_phy_led_brightness_set,\ndrivers/net/phy/mediatek/mtk-ge-soc.c:1057:\t\t.led_hw_is_supported = mt798x_phy_led_hw_is_supported,\ndrivers/net/phy/mediatek/mtk-ge-soc.c:1058:\t\t.led_hw_control_set = mt798x_phy_led_hw_control_set,\ndrivers/net/phy/mediatek/mtk-ge-soc.c:1059:\t\t.led_hw_control_get = mt798x_phy_led_hw_control_get,\ndrivers/net/phy/mediatek/mtk-ge-soc.c-1060-\t},\n--\ndrivers/net/phy/mediatek/mtk-phy-lib.c=340=EXPORT_SYMBOL_GPL(mtk_phy_leds_state_init);\ndrivers/net/phy/mediatek/mtk-phy-lib.c-341-\ndrivers/net/phy/mediatek/mtk-phy-lib.c:342:int mt798x_phy_led_blink_set(struct phy_device *phydev, u8 index,\ndrivers/net/phy/mediatek/mtk-phy-lib.c-343-\t\t\t     unsigned long *delay_on,\n--\ndrivers/net/phy/mediatek/mtk-phy-lib.c-359-}\ndrivers/net/phy/mediatek/mtk-phy-lib.c:360:EXPORT_SYMBOL_GPL(mt798x_phy_led_blink_set);\ndrivers/net/phy/mediatek/mtk-phy-lib.c-361-\ndrivers/net/phy/mediatek/mtk-phy-lib.c:362:int mt798x_phy_led_brightness_set(struct phy_device *phydev,\ndrivers/net/phy/mediatek/mtk-phy-lib.c-363-\t\t\t\t  u8 index, enum led_brightness value)\n--\ndrivers/net/phy/mediatek/mtk-phy-lib.c-373-}\ndrivers/net/phy/mediatek/mtk-phy-lib.c:374:EXPORT_SYMBOL_GPL(mt798x_phy_led_brightness_set);\ndrivers/net/phy/mediatek/mtk-phy-lib.c-375-\ndrivers/net/phy/mediatek/mtk-phy-lib.c=376=static const unsigned long supported_triggers =\n--\ndrivers/net/phy/mediatek/mtk-phy-lib.c-385-\ndrivers/net/phy/mediatek/mtk-phy-lib.c:386:int mt798x_phy_led_hw_is_supported(struct phy_device *phydev, u8 index,\ndrivers/net/phy/mediatek/mtk-phy-lib.c-387-\t\t\t\t   unsigned long rules)\n--\ndrivers/net/phy/mediatek/mtk-phy-lib.c-391-}\ndrivers/net/phy/mediatek/mtk-phy-lib.c:392:EXPORT_SYMBOL_GPL(mt798x_phy_led_hw_is_supported);\ndrivers/net/phy/mediatek/mtk-phy-lib.c-393-\ndrivers/net/phy/mediatek/mtk-phy-lib.c:394:int mt798x_phy_led_hw_control_get(struct phy_device *phydev, u8 index,\ndrivers/net/phy/mediatek/mtk-phy-lib.c-395-\t\t\t\t  unsigned long *rules)\n--\ndrivers/net/phy/mediatek/mtk-phy-lib.c-401-};\ndrivers/net/phy/mediatek/mtk-phy-lib.c:402:EXPORT_SYMBOL_GPL(mt798x_phy_led_hw_control_get);\ndrivers/net/phy/mediatek/mtk-phy-lib.c-403-\ndrivers/net/phy/mediatek/mtk-phy-lib.c:404:int mt798x_phy_led_hw_control_set(struct phy_device *phydev, u8 index,\ndrivers/net/phy/mediatek/mtk-phy-lib.c-405-\t\t\t\t  unsigned long rules)\n--\ndrivers/net/phy/mediatek/mtk-phy-lib.c-411-};\ndrivers/net/phy/mediatek/mtk-phy-lib.c:412:EXPORT_SYMBOL_GPL(mt798x_phy_led_hw_control_set);\ndrivers/net/phy/mediatek/mtk-phy-lib.c-413-\n--\ndrivers/net/phy/mediatek/mtk.h=105=void mtk_phy_leds_state_init(struct phy_device *phydev);\ndrivers/net/phy/mediatek/mtk.h-106-\ndrivers/net/phy/mediatek/mtk.h:107:int mt798x_phy_led_blink_set(struct phy_device *phydev, u8 index,\ndrivers/net/phy/mediatek/mtk.h-108-\t\t\t     unsigned long *delay_on,\ndrivers/net/phy/mediatek/mtk.h-109-\t\t\t     unsigned long *delay_off);\ndrivers/net/phy/mediatek/mtk.h:110:int mt798x_phy_led_brightness_set(struct phy_device *phydev,\ndrivers/net/phy/mediatek/mtk.h-111-\t\t\t\t  u8 index, enum led_brightness value);\ndrivers/net/phy/mediatek/mtk.h:112:int mt798x_phy_led_hw_is_supported(struct phy_device *phydev, u8 index,\ndrivers/net/phy/mediatek/mtk.h-113-\t\t\t\t   unsigned long rules);\ndrivers/net/phy/mediatek/mtk.h:114:int mt798x_phy_led_hw_control_get(struct phy_device *phydev, u8 index,\ndrivers/net/phy/mediatek/mtk.h-115-\t\t\t\t  unsigned long *rules);\ndrivers/net/phy/mediatek/mtk.h:116:int mt798x_phy_led_hw_control_set(struct phy_device *phydev, u8 index,\ndrivers/net/phy/mediatek/mtk.h-117-\t\t\t\t  unsigned long rules);\n"
}

25/2 2026/10/14 12:06 llm patch-evaluator
0m Model:
gemini-3.8-flash

Args:
null

Results:
null

Tokens:
							input: 92361
							output: 34
							thoughts: 103
						

Thoughts:
Okay, here's my take on those code snippets, thinking through the implications as I'd approach this kind of debugging scenario:

**Digging into PHY LED and TR Write Usage**

Alright, let's see what we've got here.  `mt798x_phy_led_*` - these are definitely PHY driver callbacks. Standard stuff, things like setting the LED blink rate, brightness, all that.  The interesting part is where they're *used*.  It looks like they are **only** used by `mtk_socphy_driver`, and specifically within `airoha-ge-soc.c` and `mtk-ge-soc.c`. That's a pretty limited scope, which is something I need to keep in mind. We might be dealing with a very specific hardware configuration, perhaps. Now, what's this `__mtk_tr_write` function about? It's not immediately obvious what it does just by name, so the next logical step for me is to trace the callers of `__mtk_tr_write`.  That'll give me context. Who *depends* on this function, and what operations might it be tied to? What are the implications of the write operations? Is this a register write, memory write, what is it? I need to understand the control flow that calls this function.



26/2 2026/10/14 12:06 tool grepper
0m Args:
{
  "Expression": "__mtk_tr_write",
  "PathPrefixes": [
    "drivers/net/phy/"
  ]
}

Results:
{
  "Output": "drivers/net/phy/mediatek/airoha-ge-soc.c=1386=static int an7581_phy_config_init(struct phy_device *phydev)\n--\ndrivers/net/phy/mediatek/airoha-ge-soc.c-1499-\tphy_select_page(phydev, MTK_PHY_PAGE_EXTENDED_52B5);\ndrivers/net/phy/mediatek/airoha-ge-soc.c:1500:\t__mtk_tr_write(phydev, 0x0, 0x7, 0x15, 0x0055a0);\ndrivers/net/phy/mediatek/airoha-ge-soc.c:1501:\t__mtk_tr_write(phydev, 0x0, 0x7, 0x17, 0x07ff3f);\ndrivers/net/phy/mediatek/airoha-ge-soc.c:1502:\t__mtk_tr_write(phydev, 0x1, 0xf, 0x0, 0x00001e);\ndrivers/net/phy/mediatek/airoha-ge-soc.c:1503:\t__mtk_tr_write(phydev, 0x1, 0xf, 0x1, 0x6fb90a);\ndrivers/net/phy/mediatek/airoha-ge-soc.c:1504:\t__mtk_tr_write(phydev, 0x1, 0xf, 0x18, 0x0e2f00);\ndrivers/net/phy/mediatek/airoha-ge-soc.c:1505:\t__mtk_tr_write(phydev, 0x1, 0xd, 0x26, 0x444444);\ndrivers/net/phy/mediatek/airoha-ge-soc.c:1506:\t__mtk_tr_write(phydev, 0x2, 0xd, 0x3, 0x000004);\ndrivers/net/phy/mediatek/airoha-ge-soc.c:1507:\t__mtk_tr_write(phydev, 0x2, 0xd, 0x6, 0x2ebaef);\ndrivers/net/phy/mediatek/airoha-ge-soc.c:1508:\t__mtk_tr_write(phydev, 0x2, 0xd, 0x8, 0x00000b);\ndrivers/net/phy/mediatek/airoha-ge-soc.c:1509:\t__mtk_tr_write(phydev, 0x2, 0xd, 0xc, 0x00504d);\ndrivers/net/phy/mediatek/airoha-ge-soc.c:1510:\t__mtk_tr_write(phydev, 0x2, 0xd, 0xd, 0x02314f);\ndrivers/net/phy/mediatek/airoha-ge-soc.c:1511:\t__mtk_tr_write(phydev, 0x2, 0xd, 0xf, 0x003028);\ndrivers/net/phy/mediatek/airoha-ge-soc.c:1512:\t__mtk_tr_write(phydev, 0x2, 0xd, 0x10, 0x00000a);\ndrivers/net/phy/mediatek/airoha-ge-soc.c:1513:\t__mtk_tr_write(phydev, 0x2, 0xd, 0x11, 0x040001);\ndrivers/net/phy/mediatek/airoha-ge-soc.c:1514:\t__mtk_tr_write(phydev, 0x2, 0xd, 0x14, 0x00024a);\ndrivers/net/phy/mediatek/airoha-ge-soc.c:1515:\t__mtk_tr_write(phydev, 0x2, 0xd, 0x1c, 0x003210);\ndrivers/net/phy/mediatek/airoha-ge-soc.c-1516-\tphy_restore_page(phydev, MTK_PHY_PAGE_STANDARD, 0);\n--\ndrivers/net/phy/mediatek/mtk-phy-lib.c=29=static void __mtk_tr_read(struct phy_device *phydev, u8 ch_addr, u8 node_addr,\n--\ndrivers/net/phy/mediatek/mtk-phy-lib.c-38-\ndrivers/net/phy/mediatek/mtk-phy-lib.c:39:void __mtk_tr_write(struct phy_device *phydev, u8 ch_addr, u8 node_addr,\ndrivers/net/phy/mediatek/mtk-phy-lib.c-40-\t\t    u8 data_addr, u32 tr_data)\n--\ndrivers/net/phy/mediatek/mtk-phy-lib.c-47-}\ndrivers/net/phy/mediatek/mtk-phy-lib.c:48:EXPORT_SYMBOL_GPL(__mtk_tr_write);\ndrivers/net/phy/mediatek/mtk-phy-lib.c-49-\ndrivers/net/phy/mediatek/mtk-phy-lib.c=50=void __mtk_tr_modify(struct phy_device *phydev, u8 ch_addr, u8 node_addr,\n--\ndrivers/net/phy/mediatek/mtk-phy-lib.c-59-\ttr_data = (tr_data \u0026 ~mask) | set;\ndrivers/net/phy/mediatek/mtk-phy-lib.c:60:\t__mtk_tr_write(phydev, ch_addr, node_addr, data_addr, tr_data);\ndrivers/net/phy/mediatek/mtk-phy-lib.c-61-}\n--\ndrivers/net/phy/mediatek/mtk.h=72=struct mtk_socphy_priv {\n--\ndrivers/net/phy/mediatek/mtk.h-75-\ndrivers/net/phy/mediatek/mtk.h:76:void __mtk_tr_write(struct phy_device *phydev, u8 ch_addr, u8 node_addr,\ndrivers/net/phy/mediatek/mtk.h-77-\t\t    u8 data_addr, u32 tr_data);\n"
}

27/2 2026/10/14 12:06 llm patch-evaluator
0m Model:
gemini-3.8-flash

Args:
null

Results:
null

Tokens:
							input: 94445
							output: 25
							thoughts: 655
						

Thoughts:
**Analyzing PHY Driver Export and Reachability**

Okay, let's break this down. First, I see that `__mtk_tr_write`, originally a static function within `mtk-phy-lib.c`, has been made accessible to GPL modules. Specifically, `airoha-ge-soc.c` now calls it within `an7581_phy_config_init()`. This suggests a clear move towards modularity and potential reuse of PHY configuration code.

Next, the refactoring of `mtk_cal_cycle_wait` is interesting. The waiting portion of `cal_cycle` was extracted into `mtk_cal_cycle_wait` and exported via `EXPORT_SYMBOL_GPL(mtk_cal_cycle_wait)`. This is a clean separation of concerns, and it's being used by `airoha_cal_cycle` in `airoha-ge-soc.c`, calling `mtk_cal_cycle_wait(phydev_p0)`. The intent here is obviously to have a shared calibration wait function.

Now, a crucial question arises: is this code ever actually *executed* on amd64? This is a point of concern. I'm going to consider reachability. Let's see...

Can any of this code ever be executed on `amd64`?

First, I need to understand what's actually creating these PHY devices. I see specific IDs: `0x03a29461`, `0x03a29481`, `0x03a29491`, `0x03a294c1`, `0xc0ff0420`. These aren't generic IDs. They're tied to the *hardware* itself, read via MDIO. These are SoC-specific IDs and strongly suggest Airoha or MediaTek hardware.

Can QEMU on amd64 emulate these specific Airoha or MediaTek Gigabit Ethernet PHYs? The answer is probably no. QEMU emulates other network interfaces, but not this.

What about USB? Could a USB-to-Ethernet adapter create an MDIO bus? If so, could we inject these specific PHY IDs somehow? Let's consider: do USB Ethernet dongles even use MDIO PHYs? Some *do*, such as those using the ax88179, r8152, or asix chips. However, the ax88179 internal PHY or Broadcom PHY, and r8152 uses its own internal PHY. None of these use MediaTek or Airoha SoC-internal PHYs. They're designed for different architectures.

Wait, can we use a USB device or userspace to create an MDIO bus and inject arbitrary PHY IDs? That's an interesting thought, but unlikely. Let's see if there's any evidence of a USB-to-MDIO adapter in the Linux kernel. I'm going to `grep` the `drivers/net/mdio/` directory for "mdio.*usb" or similar keywords. If that turns up empty, then the chances of this code path ever executing on amd64 are incredibly slim.



28/2 2026/10/14 12:06 tool codesearch-dir-index
0m Args:
{
  "Dir": "drivers/net/mdio/"
}

Results:
{
  "Files": [
    "acpi_mdio.c",
    "fwnode_mdio.c",
    "mdio-airoha.c",
    "mdio-aspeed.c",
    "mdio-bcm-iproc.c",
    "mdio-bcm-unimac.c",
    "mdio-bitbang.c",
    "mdio-cavium.c",
    "mdio-cavium.h",
    "mdio-gpio.c",
    "mdio-hisi-femac.c",
    "mdio-i2c.c",
    "mdio-ipq4019.c",
    "mdio-ipq8064.c",
    "mdio-moxart.c",
    "mdio-mscc-miim.c",
    "mdio-mux-bcm-iproc.c",
    "mdio-mux-bcm6368.c",
    "mdio-mux-gpio.c",
    "mdio-mux-meson-g12a.c",
    "mdio-mux-meson-gxl.c",
    "mdio-mux-mmioreg.c",
    "mdio-mux-multiplexer.c",
    "mdio-mux.c",
    "mdio-mvusb.c",
    "mdio-octeon.c",
    "mdio-pic64hpsc.c",
    "mdio-realtek-rtl9300.c",
    "mdio-regmap.c",
    "mdio-sun4i.c",
    "mdio-thunder.c",
    "mdio-xgene.c",
    "of_mdio.c"
  ],
  "Subdirs": null
}

29/2 2026/10/14 12:06 llm patch-evaluator
0m Model:
gemini-3.8-flash

Args:
null

Results:
null

Tokens:
							input: 96215
							output: 40
							thoughts: 39
						

Thoughts:
Here's my summary, as if I were thinking these thoughts:

**A Quick Code Dive**

Hold on a second! I need to take a look at something… specifically, that `drivers/net/mdio/mdio-mvusb.c` file. Right, let's pull that up. *What exactly is this `mdio-mvusb.c`?* I need to understand what this module is actually doing before I can proceed. Gotta get a handle on the foundation first.



30/2 2026/10/14 12:06 tool read-file
0m Args:
{
  "File": "drivers/net/mdio/mdio-mvusb.c",
  "FirstLine": 1,
  "LineCount": 50
}

Results:
{
  "Contents": "   1:\t// SPDX-License-Identifier: GPL-2.0\n   2:\t\n   3:\t#include \u003clinux/kernel.h\u003e\n   4:\t#include \u003clinux/module.h\u003e\n   5:\t#include \u003clinux/of_mdio.h\u003e\n   6:\t#include \u003clinux/phy.h\u003e\n   7:\t#include \u003clinux/usb.h\u003e\n   8:\t\n   9:\t#define USB_MARVELL_VID\t0x1286\n  10:\t\n  11:\tstatic const struct usb_device_id mvusb_mdio_table[] = {\n  12:\t\t{ USB_DEVICE(USB_MARVELL_VID, 0x1fa4) },\n  13:\t\n  14:\t\t{}\n  15:\t};\n  16:\tMODULE_DEVICE_TABLE(usb, mvusb_mdio_table);\n  17:\t\n  18:\tenum {\n  19:\t\tMVUSB_CMD_PREAMBLE0,\n  20:\t\tMVUSB_CMD_PREAMBLE1,\n  21:\t\tMVUSB_CMD_ADDR,\n  22:\t\tMVUSB_CMD_VAL,\n  23:\t};\n  24:\t\n  25:\tstruct mvusb_mdio {\n  26:\t\tstruct usb_device *udev;\n  27:\t\tstruct mii_bus *mdio;\n  28:\t\n  29:\t\t__le16 buf[4];\n  30:\t};\n  31:\t\n  32:\tstatic int mvusb_mdio_read(struct mii_bus *mdio, int dev, int reg)\n  33:\t{\n  34:\t\tstruct mvusb_mdio *mvusb = mdio-\u003epriv;\n  35:\t\tint err, alen;\n  36:\t\n  37:\t\tmvusb-\u003ebuf[MVUSB_CMD_ADDR] = cpu_to_le16(0xa400 | (dev \u003c\u003c 5) | reg);\n  38:\t\n  39:\t\terr = usb_bulk_msg(mvusb-\u003eudev, usb_sndbulkpipe(mvusb-\u003eudev, 2),\n  40:\t\t\t\t   mvusb-\u003ebuf, 6, \u0026alen, 100);\n  41:\t\tif (err)\n  42:\t\t\treturn err;\n  43:\t\n  44:\t\terr = usb_bulk_msg(mvusb-\u003eudev, usb_rcvbulkpipe(mvusb-\u003eudev, 6),\n  45:\t\t\t\t   \u0026mvusb-\u003ebuf[MVUSB_CMD_VAL], 2, \u0026alen, 100);\n  46:\t\tif (err)\n  47:\t\t\treturn err;\n  48:\t\n  49:\t\treturn le16_to_cpu(mvusb-\u003ebuf[MVUSB_CMD_VAL]);\n  50:\t}\n"
}

31/2 2026/10/14 12:06 llm patch-evaluator
0m Model:
gemini-3.8-flash

Args:
null

Results:
null

Tokens:
							input: 97122
							output: 41
							thoughts: 74
						

Thoughts:
**Diving into `mdio-mvusb.c`**

Alright, let's take a look at this `mdio-mvusb.c` file. Straight away, I see it's dealing with a USB device, specifically with VID 0x1286 and PID 0x1fa4. My initial question is: how does it handle the probing process? Does it call `mdiobus_register` at some point? That's the core of how this type of device interacts with the MDIO subsystem, so that's the first thing I want to confirm. I should probably just read the rest of the file to confirm!



32/2 2026/10/14 12:07 tool read-file
0m Args:
{
  "File": "drivers/net/mdio/mdio-mvusb.c",
  "FirstLine": 51,
  "LineCount": 50
}

Results:
{
  "Contents": "  51:\t\n  52:\tstatic int mvusb_mdio_write(struct mii_bus *mdio, int dev, int reg, u16 val)\n  53:\t{\n  54:\t\tstruct mvusb_mdio *mvusb = mdio-\u003epriv;\n  55:\t\tint alen;\n  56:\t\n  57:\t\tmvusb-\u003ebuf[MVUSB_CMD_ADDR] = cpu_to_le16(0x8000 | (dev \u003c\u003c 5) | reg);\n  58:\t\tmvusb-\u003ebuf[MVUSB_CMD_VAL]  = cpu_to_le16(val);\n  59:\t\n  60:\t\treturn usb_bulk_msg(mvusb-\u003eudev, usb_sndbulkpipe(mvusb-\u003eudev, 2),\n  61:\t\t\t\t    mvusb-\u003ebuf, 8, \u0026alen, 100);\n  62:\t}\n  63:\t\n  64:\tstatic int mvusb_mdio_probe(struct usb_interface *interface,\n  65:\t\t\t\t    const struct usb_device_id *id)\n  66:\t{\n  67:\t\tstruct device *dev = \u0026interface-\u003edev;\n  68:\t\tstruct mvusb_mdio *mvusb;\n  69:\t\tstruct mii_bus *mdio;\n  70:\t\n  71:\t\tmdio = devm_mdiobus_alloc_size(dev, sizeof(*mvusb));\n  72:\t\tif (!mdio)\n  73:\t\t\treturn -ENOMEM;\n  74:\t\n  75:\t\tmvusb = mdio-\u003epriv;\n  76:\t\tmvusb-\u003emdio = mdio;\n  77:\t\tmvusb-\u003eudev = interface_to_usbdev(interface);\n  78:\t\n  79:\t\t/* Reversed from USB PCAPs, no idea what these mean. */\n  80:\t\tmvusb-\u003ebuf[MVUSB_CMD_PREAMBLE0] = cpu_to_le16(0xe800);\n  81:\t\tmvusb-\u003ebuf[MVUSB_CMD_PREAMBLE1] = cpu_to_le16(0x0001);\n  82:\t\n  83:\t\tsnprintf(mdio-\u003eid, MII_BUS_ID_SIZE, \"mvusb-%s\", dev_name(dev));\n  84:\t\tmdio-\u003ename = mdio-\u003eid;\n  85:\t\tmdio-\u003eparent = dev;\n  86:\t\tmdio-\u003eread = mvusb_mdio_read;\n  87:\t\tmdio-\u003ewrite = mvusb_mdio_write;\n  88:\t\n  89:\t\tusb_set_intfdata(interface, mvusb);\n  90:\t\n  91:\t\treturn of_mdiobus_register(mdio, dev-\u003eof_node);\n  92:\t}\n  93:\t\n  94:\tstatic void mvusb_mdio_disconnect(struct usb_interface *interface)\n  95:\t{\n  96:\t\tstruct mvusb_mdio *mvusb = usb_get_intfdata(interface);\n  97:\t\n  98:\t\tmdiobus_unregister(mvusb-\u003emdio);\n  99:\t\tusb_set_intfdata(interface, NULL);\n 100:\t}\n"
}

33/2 2026/10/14 12:07 llm patch-evaluator
0m Model:
gemini-3.8-flash

Args:
null

Results:
null

Tokens:
							input: 98205
							output: 34
							thoughts: 114
						

Thoughts:
**My Analysis of MDIO Bus Registration**

Okay, so I'm looking at this `of_mdiobus_register(mdio, dev->of_node)` function call. The interesting part is what happens when `dev->of_node` is NULL. I know that for USB devices, especially those probed on x86 systems without a device tree, this is *always* the case. That means `of_mdiobus_register` essentially becomes a call to `mdiobus_register(mdio)`.

Now, the crucial question: what does `mdiobus_register(mdio)` *actually* do? Time to dig into the implementation. I'll need to check the `__mdiobus_register` function, which is located in `drivers/net/phy/mdio_bus.c`. That should give me the details I need to understand this registration process fully.



34/2 2026/10/14 12:07 tool grepper
0m Args:
{
  "Expression": "int __mdiobus_register",
  "PathPrefixes": [
    "drivers/net/phy/"
  ]
}

Results:
{
  "Output": "drivers/net/phy/mdio_bus_provider.c=525=static bool mdiobus_prevent_c45_scan(struct mii_bus *bus)\n--\ndrivers/net/phy/mdio_bus_provider.c-552- */\ndrivers/net/phy/mdio_bus_provider.c:553:int __mdiobus_register(struct mii_bus *bus, struct module *owner)\ndrivers/net/phy/mdio_bus_provider.c-554-{\n"
}

35/2 2026/10/14 12:07 llm patch-evaluator
0m Model:
gemini-3.8-flash

Args:
null

Results:
null

Tokens:
							input: 98685
							output: 42
							thoughts: 30
						

Thoughts:
Okay, here's my interpretation of that request, formatted for a technically proficient user:

**Diving into the MDIO Bus Provider Code**

Alright, let's get down to brass tacks. I need to understand the intricacies of how this MDIO bus provider operates, specifically, the interaction between the driver and the physical layer. I'm going to focus my analysis on `drivers/net/phy/mdio_bus_provider.c` and zero in on lines 553 through 610. I expect to find some critical implementations within this range, perhaps related to probe, registration, or interrupt handling, or maybe some key aspects of bus address allocation or device attachment. This section could be where the rubber meets the road, where the abstraction of the MDIO bus translates into concrete actions. I'm looking for the core logic, the "glue" that allows a PHY driver to interact with the MDIO bus. I anticipate seeing the interplay of data structures, function calls and any error handling in this section. I need to understand how the MDIO bus is managing its interaction with the underlying hardware, how resources are allocated, and potential concurrency issues.



36/2 2026/10/14 12:07 tool read-file
0m Args:
{
  "File": "drivers/net/phy/mdio_bus_provider.c",
  "FirstLine": 553,
  "LineCount": 55
}

Results:
{
  "Contents": " 553:\tint __mdiobus_register(struct mii_bus *bus, struct module *owner)\n 554:\t{\n 555:\t\tstruct mdio_device *mdiodev;\n 556:\t\tstruct gpio_desc *gpiod;\n 557:\t\tbool prevent_c45_scan;\n 558:\t\tint i, err;\n 559:\t\n 560:\t\tif (!bus || !bus-\u003ename)\n 561:\t\t\treturn -EINVAL;\n 562:\t\n 563:\t\t/* An access method always needs both read and write operations */\n 564:\t\tif (!!bus-\u003eread != !!bus-\u003ewrite || !!bus-\u003eread_c45 != !!bus-\u003ewrite_c45)\n 565:\t\t\treturn -EINVAL;\n 566:\t\n 567:\t\t/* At least one method is mandatory */\n 568:\t\tif (!bus-\u003eread \u0026\u0026 !bus-\u003eread_c45)\n 569:\t\t\treturn -EINVAL;\n 570:\t\n 571:\t\tif (bus-\u003eparent \u0026\u0026 bus-\u003eparent-\u003eof_node)\n 572:\t\t\tfwnode_set_flag(\u0026bus-\u003eparent-\u003eof_node-\u003efwnode,\n 573:\t\t\t\t\tFWNODE_FLAG_NEEDS_CHILD_BOUND_ON_ADD);\n 574:\t\n 575:\t\tWARN(bus-\u003estate != MDIOBUS_ALLOCATED \u0026\u0026\n 576:\t\t     bus-\u003estate != MDIOBUS_UNREGISTERED,\n 577:\t\t     \"%s: not in ALLOCATED or UNREGISTERED state\\n\", bus-\u003eid);\n 578:\t\n 579:\t\tbus-\u003eowner = owner;\n 580:\t\tbus-\u003edev.parent = bus-\u003eparent;\n 581:\t\tbus-\u003edev.class = \u0026mdio_bus_class;\n 582:\t\tbus-\u003edev.groups = NULL;\n 583:\t\tdev_set_name(\u0026bus-\u003edev, \"%s\", bus-\u003eid);\n 584:\t\n 585:\t\t/* If the bus state is allocated, we're registering a fresh bus\n 586:\t\t * that may have a fwnode associated with it. Grab a reference\n 587:\t\t * to the fwnode. This will be dropped when the bus is released.\n 588:\t\t * If the bus was set to unregistered, it means that the bus was\n 589:\t\t * previously registered, and we've already grabbed a reference.\n 590:\t\t */\n 591:\t\tif (bus-\u003estate == MDIOBUS_ALLOCATED)\n 592:\t\t\tfwnode_handle_get(dev_fwnode(\u0026bus-\u003edev));\n 593:\t\n 594:\t\t/* We need to set state to MDIOBUS_UNREGISTERED to correctly release\n 595:\t\t * the device in mdiobus_free()\n 596:\t\t *\n 597:\t\t * State will be updated later in this function in case of success\n 598:\t\t */\n 599:\t\tbus-\u003estate = MDIOBUS_UNREGISTERED;\n 600:\t\n 601:\t\terr = device_register(\u0026bus-\u003edev);\n 602:\t\tif (err) {\n 603:\t\t\tpr_err(\"mii_bus %s failed to register\\n\", bus-\u003eid);\n 604:\t\t\treturn -EINVAL;\n 605:\t\t}\n 606:\t\n 607:\t\tmutex_init(\u0026bus-\u003emdio_lock);\n"
}

37/2 2026/10/14 12:07 llm patch-evaluator
0m Model:
gemini-3.8-flash

Args:
null

Results:
null

Tokens:
							input: 99906
							output: 42
							thoughts: 46
						

Thoughts:
Here's a summary of my current thought process, as if I were analyzing the code:

**Diving into `__mdiobus_register` in the MDIO Bus Provider**

Okay, I'm digging into `__mdiobus_register` – that's where the magic happens for registering a new MDIO bus, and I need to understand it better. Let's see... I'm going to focus my attention on lines 610 through 660 in `drivers/net/phy/mdio_bus_provider.c`. That section should give me a good overview of the important actions that are being performed as this function works. I want to see how the bus is initialized, how it's linked into the overall system, and any critical error checking that is done. Understanding this area is vital for comprehending the complete MDIO bus architecture and how these crucial interfaces are created.



38/2 2026/10/14 12:07 tool read-file
0m Args:
{
  "File": "drivers/net/phy/mdio_bus_provider.c",
  "FirstLine": 610,
  "LineCount": 50
}

Results:
{
  "Contents": " 610:\t\t/* assert bus level PHY GPIO reset */\n 611:\t\tgpiod = devm_gpiod_get_optional(\u0026bus-\u003edev, \"reset\", GPIOD_OUT_HIGH);\n 612:\t\tif (IS_ERR(gpiod)) {\n 613:\t\t\terr = dev_err_probe(\u0026bus-\u003edev, PTR_ERR(gpiod),\n 614:\t\t\t\t\t    \"mii_bus %s couldn't get reset GPIO\\n\",\n 615:\t\t\t\t\t    bus-\u003eid);\n 616:\t\t\tdevice_del(\u0026bus-\u003edev);\n 617:\t\t\treturn err;\n 618:\t\t} else\tif (gpiod) {\n 619:\t\t\tbus-\u003ereset_gpiod = gpiod;\n 620:\t\t\tfsleep(bus-\u003ereset_delay_us);\n 621:\t\t\tgpiod_set_value_cansleep(gpiod, 0);\n 622:\t\t\tif (bus-\u003ereset_post_delay_us \u003e 0)\n 623:\t\t\t\tfsleep(bus-\u003ereset_post_delay_us);\n 624:\t\t}\n 625:\t\n 626:\t\tif (bus-\u003ereset) {\n 627:\t\t\terr = bus-\u003ereset(bus);\n 628:\t\t\tif (err)\n 629:\t\t\t\tgoto error_reset_gpiod;\n 630:\t\t}\n 631:\t\n 632:\t\tif (bus-\u003eread) {\n 633:\t\t\terr = mdiobus_scan_bus_c22(bus);\n 634:\t\t\tif (err)\n 635:\t\t\t\tgoto error;\n 636:\t\t}\n 637:\t\n 638:\t\tprevent_c45_scan = mdiobus_prevent_c45_scan(bus);\n 639:\t\n 640:\t\tif (!prevent_c45_scan \u0026\u0026 bus-\u003eread_c45) {\n 641:\t\t\terr = mdiobus_scan_bus_c45(bus);\n 642:\t\t\tif (err)\n 643:\t\t\t\tgoto error;\n 644:\t\t}\n 645:\t\n 646:\t\tbus-\u003estate = MDIOBUS_REGISTERED;\n 647:\t\tdev_dbg(\u0026bus-\u003edev, \"probed\\n\");\n 648:\t\treturn 0;\n 649:\t\n 650:\terror:\n 651:\t\tfor (i = 0; i \u003c PHY_MAX_ADDR; i++) {\n 652:\t\t\tmdiodev = bus-\u003emdio_map[i];\n 653:\t\t\tif (!mdiodev)\n 654:\t\t\t\tcontinue;\n 655:\t\n 656:\t\t\tmdiodev-\u003edevice_remove(mdiodev);\n 657:\t\t\tmdiodev-\u003edevice_free(mdiodev);\n 658:\t\t}\n 659:\terror_reset_gpiod:\n"
}

39/2 2026/10/14 12:07 llm patch-evaluator
0m Model:
gemini-3.8-flash

Args:
null

Results:
null

Tokens:
							input: 100958
							output: 46
							thoughts: 752
						

Thoughts:
**A Deep Dive into Potential PHY Probe Vulnerability**

Okay, so here's what's running through my head. `mdiobus_scan_bus_c22(bus)` is scanning addresses 0 to 31 using `get_phy_device`. When syzkaller emulates a USB device (raw_gadget or dummy_hcd with VID 0x1286 / PID 0x1fa4), `mvusb_mdio_probe` gets involved, `mdiobus_register` runs, and USB bulk messages are sent to read MII registers. The interesting part is, if the emulated USB device *returns* the PHY ID for Airoha EN7528/AN7581/AN7583 (like 0x03a294c1, for example), `mdiobus_scan_bus_c22` creates a `phy_device`, which triggers a match with `airoha_socphy_tbl`.

Now, the crucial question becomes: can `an7581_phy_probe` actually get called? I need to check that. So, I look at the `an7581_phy_probe` function directly. I'm focusing on the code:

```c
	ret = devm_phy_package_join(&phydev->mdio.dev, phydev, 0,
				    sizeof(struct airoha_socphy_shared));
	if (ret)
		return ret;

	priv = devm_kzalloc(&phydev->mdio.dev, sizeof(*priv), GFP_KERNEL);
	if (!priv)
		return -ENOMEM;

	if (phydev->mdio.addr == AIROHA_DEFAULT_PORT0_ADDR)
		shared->phydev_p0 = phydev;
```

Hold on, I see something suspicious. I'm looking *very* closely at this code snippet, specifically the `shared` variable. Where is `shared` initialized or assigned within this function?! That seems like a *very* obvious oversight. It's not allocated or initialized within this function. I need to investigate the implications of an uninitialized variable being used. It looks like `shared` comes from the `airoha_socphy_shared` struct! I will now check lines 1360-1380 of `drivers/net/phy/mediatek/airoha-ge-soc.c` to understand the bigger picture of where and how `shared` is intended to be used and initialized. This is definitely worth a closer look. I suspect we have a potentially critical vulnerability here!



40/2 2026/10/14 12:08 tool read-file
0m Args:
{
  "File": "drivers/net/phy/mediatek/airoha-ge-soc.c",
  "FirstLine": 1350,
  "LineCount": 40
}

Results:
{
  "Contents": "1350:\t\t\telse if (reg_1e_174_end \u003e 0x7f)\n1351:\t\t\t\treg_1e_174_end = 0x7f;\n1352:\t\t\tif (reg_1e_175_header \u003c 0)\n1353:\t\t\t\treg_1e_175_header = 0;\n1354:\t\t\telse if (reg_1e_175_header \u003e 0x7f)\n1355:\t\t\t\treg_1e_175_header = 0x7f;\n1356:\t\t\tif (reg_1e_175_end \u003c 0)\n1357:\t\t\t\treg_1e_175_end = 0;\n1358:\t\t\telse if (reg_1e_175_end \u003e 0x7f)\n1359:\t\t\t\treg_1e_175_end = 0x7f;\n1360:\t\t}\n1361:\t\n1362:\t\tphy_write_mmd(phydev, MDIO_MMD_VEND1, 0x12,\n1363:\t\t\t      (reg_1e_12_header * 1024) + reg_1e_12_end);\n1364:\t\tphy_write_mmd(phydev, MDIO_MMD_VEND1, 0x16,\n1365:\t\t\t      (reg_1e_16_header * 1024) + reg_1e_16_end);\n1366:\t\tphy_write_mmd(phydev, MDIO_MMD_VEND1, 0x17,\n1367:\t\t\t      (reg_1e_17_header * 256) + reg_1e_17_end);\n1368:\t\tphy_write_mmd(phydev, MDIO_MMD_VEND1, 0x18,\n1369:\t\t\t      (reg_1e_18_header * 256) + reg_1e_18_end);\n1370:\t\tphy_write_mmd(phydev, MDIO_MMD_VEND1, 0x19,\n1371:\t\t\t      (reg_1e_19_read \u0026 0x00ff) + (reg_1e_19_header * 256));\n1372:\t\tphy_write_mmd(phydev, MDIO_MMD_VEND1, 0x20,\n1373:\t\t\t      (reg_1e_20_read \u0026 0xff00) + reg_1e_20_end);\n1374:\t\tphy_write_mmd(phydev, MDIO_MMD_VEND1, 0x21,\n1375:\t\t\t      (reg_1e_21_read \u0026 0x00ff) + (reg_1e_21_header * 256));\n1376:\t\tphy_write_mmd(phydev, MDIO_MMD_VEND1, 0x22,\n1377:\t\t\t      (reg_1e_22_read \u0026 0xff00) + reg_1e_22_end);\n1378:\t\tphy_write_mmd(phydev, MDIO_MMD_VEND1, 0x174,\n1379:\t\t\t      0x8080 + (reg_1e_174_header * 256) + reg_1e_174_end);\n1380:\t\tphy_write_mmd(phydev, MDIO_MMD_VEND1, 0x175,\n1381:\t\t\t      0x8080 + (reg_1e_175_header * 256) + reg_1e_175_end);\n1382:\t\n1383:\t\treturn 0;\n1384:\t}\n1385:\t\n1386:\tstatic int an7581_phy_config_init(struct phy_device *phydev)\n1387:\t{\n1388:\t\tstruct airoha_socphy_shared *shared = phy_package_get_priv(phydev);\n1389:\t\tstruct phy_device *phydev_p0;\n"
}

41/2 2026/10/14 12:08 llm patch-evaluator
0m Model:
gemini-3.8-flash

Args:
null

Results:
null

Tokens:
							input: 103442
							output: 46
							thoughts: 49
						

Thoughts:
Okay, let's dive into this. Here's how I'd approach this task, as if I were thinking it through:

**Analyzing the `an7581_phy_probe` Function within the airoha-ge-soc Driver**

Right, time to get my hands dirty. I need to understand how the `an7581_phy_probe` function works in the `airoha-ge-soc.c` driver. Specifically, I'm zeroing in on lines 1670 through 1720 of the source code. This is a common entry point to explore the PHY initializaiton flow. I suspect this section contains the core logic for probing and initializing the specific PHY hardware that this driver manages.

I'll be looking for key elements:

*   **Device Matching:** How does the driver identify if the connected PHY is indeed an AN7581? This probably involves checking device IDs or other identifying characteristics, and I need to assess how robust this matching process is.
*   **Resource Allocation:** What resources (registers, memory regions, interrupts, etc.) are being requested from the system for the PHY? Are they being requested in a sane manner?
*   **Driver Initialization:** What initialization steps are being performed? Are they configuring the PHY's operating mode, setting up clocks, and enabling any necessary interfaces? I'll pay close attention to the order of operations as this can be crucial for PHY bring-up.
*   **Error Handling:** Are there checks for errors at each initialization step? What are the recovery or failure mechanisms if something goes wrong? Proper error handling is essential for reliable operation.
*   **PHY Configuration:** Specifically, I'm interested in understanding the PHY's operational parameters. Are there critical configurations to be checked? Does it configure speed and duplex? If so, what method is being used? Is there code that takes into account the potential for different hardware revisions or configurations?

I'm expecting to find a pretty standard PHY probe routine, but I need to quickly identify any potential issues or nuances specific to the Mediatek/Airoha SoC integration. Let's start reading.



42/2 2026/10/14 12:08 tool read-file
0m Args:
{
  "File": "drivers/net/phy/mediatek/airoha-ge-soc.c",
  "FirstLine": 1670,
  "LineCount": 40
}

Results:
{
  "Contents": "1670:\t{\n1671:\t\tstruct airoha_socphy_shared *shared = phy_package_get_priv(phydev);\n1672:\t\tstruct phy_device *phydev_p0;\n1673:\t\tu8 phy_offset;\n1674:\t\tint ret;\n1675:\t\n1676:\t\t/* BMCR_PDOWN is enabled by default */\n1677:\t\tphy_clear_bits(phydev, MII_BMCR, BMCR_PDOWN);\n1678:\t\n1679:\t\tphydev_p0 = shared-\u003ephydev_p0;\n1680:\t\tphy_offset = phydev-\u003emdio.addr - phydev_p0-\u003emdio.addr;\n1681:\t\n1682:\t\t/* FIXME: Read SoC MDI Resister Type if available or default to 5R */\n1683:\t\tshared-\u003emdi_resister_type = MDI_5R;\n1684:\t\n1685:\t\tif (shared-\u003emdi_resister_type == MDI_0R)\n1686:\t\t\tshared-\u003er50_cal_tbl = an7583_zcal_to_r50ohm_0R;\n1687:\t\tif (shared-\u003emdi_resister_type == MDI_5R)\n1688:\t\t\tshared-\u003er50_cal_tbl = an7583_zcal_to_r50ohm_5R;\n1689:\t\tshared-\u003etx_amp_compensation_tbl = \u0026an7583_tx_amp_compensation_tbl;\n1690:\t\n1691:\t\tret = airoha_phy_calib(phydev);\n1692:\t\tif (ret)\n1693:\t\t\treturn ret;\n1694:\t\n1695:\t\tret = airoha_phy_auto_select_transformer(phydev);\n1696:\t\tif (ret)\n1697:\t\t\treturn ret;\n1698:\t\n1699:\t\tret = airoha_phy_tx_amp_compensation(phydev);\n1700:\t\tif (ret)\n1701:\t\t\treturn ret;\n1702:\t\n1703:\t\t/* Enable Idle Mode Power Setting */\n1704:\t\tif (phy_offset == 0) {\n1705:\t\t\tphy_write_mmd(phydev, MDIO_MMD_VEND2, 0x268, 0x07F1);\n1706:\t\t\tphy_write_mmd(phydev, MDIO_MMD_VEND2, 0x703, 0x3111);\n1707:\t\t\tphy_write_mmd(phydev, MDIO_MMD_VEND2, 0x271, 0x3C24);\n1708:\t\t\tphy_write_mmd(phydev, MDIO_MMD_VEND2, 0x701, 0x1023);\n1709:\t\t}\n"
}

43/2 2026/10/14 12:08 llm patch-evaluator
0m Model:
gemini-3.8-flash

Args:
null

Results:
null

Tokens:
							input: 104779
							output: 46
							thoughts: 48
						

Thoughts:
Here's my summary, as if I were thinking these thoughts:

**Analyzing the Airoha PHY Probe Function**

Okay, let's dive into this driver code. I need to understand how the Airoha GE SOC PHY is initialized, specifically the probe function. I'm going to jump straight to lines 1630-1670 in `drivers/net/phy/mediatek/airoha-ge-soc.c`. That should contain the `an7581_phy_probe` function. I'm expecting to see how the driver registers and sets up the PHY during system initialization. I want to see how this implementation handles the specific Mediatek platform and how the hardware resources are handled during the detection and initialization phases. I'm keen to see if they're doing any platform-specific quirk handling, or any unusual power management considerations. I'm looking for the standard PHY probing sequence, but also for anything unique to this particular Mediatek/Airoha combination. Let's see what's in there.



44/2 2026/10/14 12:08 tool read-file
0m Args:
{
  "File": "drivers/net/phy/mediatek/airoha-ge-soc.c",
  "FirstLine": 1630,
  "LineCount": 40
}

Results:
{
  "Contents": "1630:\tstatic int an7581_phy_led_polarity_set(struct phy_device *phydev, int index,\n1631:\t\t\t\t\t       unsigned long modes)\n1632:\t{\n1633:\t\tu16 val = 0;\n1634:\t\tu32 mode;\n1635:\t\n1636:\t\tif (index \u003e= AIROHA_PHY_MAX_LEDS)\n1637:\t\t\treturn -EINVAL;\n1638:\t\n1639:\t\tfor_each_set_bit(mode, \u0026modes, __PHY_LED_MODES_NUM) {\n1640:\t\t\tswitch (mode) {\n1641:\t\t\tcase PHY_LED_ACTIVE_LOW:\n1642:\t\t\t\tval = MTK_PHY_LED_ON_POLARITY;\n1643:\t\t\t\tbreak;\n1644:\t\t\tcase PHY_LED_ACTIVE_HIGH:\n1645:\t\t\t\tbreak;\n1646:\t\t\tdefault:\n1647:\t\t\t\treturn -EINVAL;\n1648:\t\t\t}\n1649:\t\t}\n1650:\t\n1651:\t\treturn phy_modify_mmd(phydev, MDIO_MMD_VEND2, index ?\n1652:\t\t\t\t      MTK_PHY_LED1_ON_CTRL : MTK_PHY_LED0_ON_CTRL,\n1653:\t\t\t\t      MTK_PHY_LED_ON_POLARITY, val);\n1654:\t}\n1655:\t\n1656:\tstatic int en7528_phy_config_init(struct phy_device *phydev)\n1657:\t{\n1658:\t\t/* The LED controller of the EN7528 powers up with its external\n1659:\t\t * control disabled, leaving the LED pins dark regardless of what is\n1660:\t\t * programmed into the LED control registers. Hand the pins over to\n1661:\t\t * the LED control registers the same way the air_en8811h driver\n1662:\t\t * does; the mode field of this register is already set out of reset.\n1663:\t\t */\n1664:\t\treturn phy_set_bits_mmd(phydev, MDIO_MMD_VEND2, MTK_PHY_LED_BCR,\n1665:\t\t\t\t\tMTK_PHY_LED_BCR_CLK_EN |\n1666:\t\t\t\t\tMTK_PHY_LED_BCR_EXT_CTRL);\n1667:\t}\n1668:\t\n1669:\tstatic int an7583_phy_config_init(struct phy_device *phydev)\n"
}

45/2 2026/10/14 12:08 llm patch-evaluator
0m Model:
gemini-3.8-flash

Args:
null

Results:
null

Tokens:
							input: 105780
							output: 46
							thoughts: 35
						

Thoughts:
Okay, here's my interpretation of what's going through my mind, pretending I'm reading those lines of code:

**Diving into the Airoha PHY Driver**

Alright, time to get my hands dirty. Let's zero in on those crucial lines, 1600 through 1635, within the `airoha-ge-soc.c` file of the Mediatek PHY driver. I suspect these lines are probably implementing a specific PHY operation or configuration procedure, given the context. The filename "airoha-ge-soc" indicates this code is definitely for Airoha Gigabit Ethernet SoCs. I'm expecting to find some crucial initialization, perhaps power management tweaks, or some sort of register interaction essential for getting this particular PHY running correctly on a Mediatek system. I'll need to pay close attention to the register addresses and bitfields involved – these are the bread and butter of PHY driver work. I'll be looking for any hints about the specific Mediatek SoC variant the code is targeting, as PHY configurations can be quite different across different platforms. Let's get reading and see what treasures this section holds!



46/2 2026/10/14 12:08 tool read-file
0m Args:
{
  "File": "drivers/net/phy/mediatek/airoha-ge-soc.c",
  "FirstLine": 1600,
  "LineCount": 35
}

Results:
{
  "Contents": "1600:\tstatic int an7581_phy_probe(struct phy_device *phydev)\n1601:\t{\n1602:\t\tstruct airoha_socphy_shared *shared;\n1603:\t\tstruct mtk_socphy_priv *priv;\n1604:\t\tstruct pinctrl *pinctrl;\n1605:\t\tint ret;\n1606:\t\n1607:\t\t/* Toggle pinctrl to enable PHY LED */\n1608:\t\tpinctrl = devm_pinctrl_get_select(\u0026phydev-\u003emdio.dev, \"gbe-led\");\n1609:\t\tif (IS_ERR(pinctrl))\n1610:\t\t\tdev_err(\u0026phydev-\u003emdio.bus-\u003edev,\n1611:\t\t\t\t\"Failed to setup PHY LED pinctrl\\n\");\n1612:\t\n1613:\t\tret = devm_phy_package_join(\u0026phydev-\u003emdio.dev, phydev, 0,\n1614:\t\t\t\t\t    sizeof(struct airoha_socphy_shared));\n1615:\t\tif (ret)\n1616:\t\t\treturn ret;\n1617:\t\n1618:\t\tpriv = devm_kzalloc(\u0026phydev-\u003emdio.dev, sizeof(*priv), GFP_KERNEL);\n1619:\t\tif (!priv)\n1620:\t\t\treturn -ENOMEM;\n1621:\t\n1622:\t\tif (phydev-\u003emdio.addr == AIROHA_DEFAULT_PORT0_ADDR)\n1623:\t\t\tshared-\u003ephydev_p0 = phydev;\n1624:\t\n1625:\t\tphydev-\u003epriv = priv;\n1626:\t\n1627:\t\treturn 0;\n1628:\t}\n1629:\t\n1630:\tstatic int an7581_phy_led_polarity_set(struct phy_device *phydev, int index,\n1631:\t\t\t\t\t       unsigned long modes)\n1632:\t{\n1633:\t\tu16 val = 0;\n1634:\t\tu32 mode;\n"
}

47/2 2026/10/14 12:08 llm patch-evaluator
0m Model:
gemini-3.8-flash

Args:
null

Results:
null

Tokens:
							input: 106663
							output: 35
							thoughts: 2978
						

Thoughts:
**Analyzing a Potential Kernel Crash in an MDIO PHY Driver**

Okay, so I've stumbled upon a potential vulnerability within the `an7581_phy_probe` function of the Airoha SoC Gigabit Ethernet PHY driver. Line 1602 is where things get interesting. I see a `struct airoha_socphy_shared *shared;` declaration, which appears to be a pointer declared on the stack, *uninitialized*. Crucially, it's *never* assigned a value before being dereferenced at line 1623: `shared->phydev_p0 = phydev;`. This screams potential for a null or wild pointer dereference! This will likely cause a kernel panic if this code path is ever reached.

Now, the question is: can this code path *actually* be reached in a fuzzing environment like syzkaller on an amd64 system? My primary focus is on reachability because fuzzing code that isn't reachable is a waste of resources.

The system prompt emphasizes "reachability is the primary gate" for fuzzing. It rules out code that is "Structurally unreachable hardware." Specifically, it states that code that requires physical ASIC/PCIe cards not emulated in standard QEMU should not be fuzzed. It also states that "Code paths exclusive to architectures other than the target architecture" are not to be fuzzed.

The code depends on `ARCH_AIROHA`, meaning it depends on an ARM/ARM64 architecture. My target environment is amd64, so it looks like this code should be skipped. However, there's a workaround:  `CONFIG_COMPILE_TEST=y`.

Let's see if this can be reached. Let's look at how the MDIO bus is accessed in syzkaller. I've noted the `mdio-mvusb.c` driver, specifically its probe function. It's a USB-to-MDIO driver that registers an `mii_bus`.  Syzkaller can connect ANY USB device by specifying its VID/PID and descriptors.

In this scenario, syzkaller could *theoretically* connect a USB device that presents itself as an MDIO device. If it responds with the expected PHYSID values in `mdiobus_scan_bus_c22`, then `phy_device_create`, `phy_device_register`, and `device_add` are called, which eventually leads to a match with `mtk_socphy_driver` by PHY_ID and invokes `an7581_phy_probe`.

However, the real question is whether it's *practical* to connect an *internal SoC* PHY (like the AN7581) to a *Marvell USB-to-MDIO adapter*. The AN7581 is an on-die integrated PHY. The connection makes no sense.

Even if it *were* technically possible to synthesize such a scenario with raw-gadget, this is where the *structural* unreachability comes into play. The `devm_phy_package_join` is called. It is not clear what it does, but even if it succeeded, if the address of the phydev matches `AIROHA_DEFAULT_PORT0_ADDR` (0x9), the uninitialized pointer `shared` is dereferenced.

Given the design of the AN7581, I am highly confident that this vulnerability constitutes "Structurally unreachable hardware" because the code path involving the Airoha SoC Gigabit Ethernet PHY can *only* be reached on the target ARM/ARM64 platform.



48/2 2026/10/14 12:09 tool grepper
0m Args:
{
  "Expression": "devm_phy_package_join",
  "PathPrefixes": [
    "drivers/net/phy/"
  ]
}

Results:
{
  "Output": "drivers/net/phy/bcm54140.c=580=static int bcm54140_probe(struct phy_device *phydev)\n--\ndrivers/net/phy/bcm54140.c-594-\ndrivers/net/phy/bcm54140.c:595:\tdevm_phy_package_join(\u0026phydev-\u003emdio.dev, phydev, priv-\u003ebase_addr, 0);\ndrivers/net/phy/bcm54140.c-596-\n--\ndrivers/net/phy/mediatek/airoha-ge-soc.c=1600=static int an7581_phy_probe(struct phy_device *phydev)\n--\ndrivers/net/phy/mediatek/airoha-ge-soc.c-1612-\ndrivers/net/phy/mediatek/airoha-ge-soc.c:1613:\tret = devm_phy_package_join(\u0026phydev-\u003emdio.dev, phydev, 0,\ndrivers/net/phy/mediatek/airoha-ge-soc.c-1614-\t\t\t\t    sizeof(struct airoha_socphy_shared));\n--\ndrivers/net/phy/mediatek/mtk-ge-soc.c=969=static int mt7988_phy_probe(struct phy_device *phydev)\n--\ndrivers/net/phy/mediatek/mtk-ge-soc.c-977-\ndrivers/net/phy/mediatek/mtk-ge-soc.c:978:\terr = devm_phy_package_join(\u0026phydev-\u003emdio.dev, phydev, 0,\ndrivers/net/phy/mediatek/mtk-ge-soc.c-979-\t\t\t\t    sizeof(struct mtk_socphy_shared));\n--\ndrivers/net/phy/micrel.c=4747=static int lan8814_probe(struct phy_device *phydev)\n--\ndrivers/net/phy/micrel.c-4767-\taddr = lanphy_read_page_reg(phydev, LAN8814_PAGE_COMMON_REGS, 0) \u0026 0x1F;\ndrivers/net/phy/micrel.c:4768:\tdevm_phy_package_join(\u0026phydev-\u003emdio.dev, phydev,\ndrivers/net/phy/micrel.c-4769-\t\t\t      addr, sizeof(struct lan8814_shared_priv));\n--\ndrivers/net/phy/micrel.c=6159=static int lan8842_probe(struct phy_device *phydev)\n--\ndrivers/net/phy/micrel.c-6210-\ndrivers/net/phy/micrel.c:6211:\tret = devm_phy_package_join(\u0026phydev-\u003emdio.dev, phydev, addr,\ndrivers/net/phy/micrel.c-6212-\t\t\t\t    sizeof(struct lan8814_shared_priv));\n--\ndrivers/net/phy/mscc/mscc_main.c=2241=static int vsc85xx_probe_common(struct phy_device *phydev,\n--\ndrivers/net/phy/mscc/mscc_main.c-2266-\t\tvsc8584_get_base_addr(phydev);\ndrivers/net/phy/mscc/mscc_main.c:2267:\t\tret = devm_phy_package_join(\u0026phydev-\u003emdio.dev, phydev,\ndrivers/net/phy/mscc/mscc_main.c-2268-\t\t\t\t\t    vsc8531-\u003ebase_addr,\n--\ndrivers/net/phy/phy_package.c=366=static void devm_phy_package_leave(struct device *dev, void *res)\n--\ndrivers/net/phy/phy_package.c-371-/**\ndrivers/net/phy/phy_package.c:372: * devm_phy_package_join - resource managed phy_package_join()\ndrivers/net/phy/phy_package.c-373- * @dev: device that is registering this PHY package\n--\ndrivers/net/phy/phy_package.c-382- */\ndrivers/net/phy/phy_package.c:383:int devm_phy_package_join(struct device *dev, struct phy_device *phydev,\ndrivers/net/phy/phy_package.c-384-\t\t\t  int base_addr, size_t priv_size)\n--\ndrivers/net/phy/phy_package.c-404-}\ndrivers/net/phy/phy_package.c:405:EXPORT_SYMBOL_GPL(devm_phy_package_join);\ndrivers/net/phy/phy_package.c-406-\n--\ndrivers/net/phy/phylib.h=31=void phy_package_leave(struct phy_device *phydev);\ndrivers/net/phy/phylib.h:32:int devm_phy_package_join(struct device *dev, struct phy_device *phydev,\ndrivers/net/phy/phylib.h-33-\t\t\t  int base_addr, size_t priv_size);\n--\ndrivers/net/phy/realtek/realtek_main.c=2784=static int rtl8224_probe(struct phy_device *phydev)\n--\ndrivers/net/phy/realtek/realtek_main.c-2786-\t/* Chip exposes 4 ports, join all of them in the same package */\ndrivers/net/phy/realtek/realtek_main.c:2787:\treturn devm_phy_package_join(\u0026phydev-\u003emdio.dev, phydev,\ndrivers/net/phy/realtek/realtek_main.c-2788-\t\t\t\t     phydev-\u003emdio.addr \u0026 ~3, 0);\n"
}

49/2 2026/10/14 12:09 llm patch-evaluator
0m Model:
gemini-3.8-flash

Args:
null

Results:
null

Tokens:
							input: 111914
							output: 34
							thoughts: 1947
						

Thoughts:
**Analysis of Airoha and MediaTek SoC PHY Reachability**

Okay, let's break this down. My initial thought was about `devm_phy_package_join` and potential issues if the `shared` structure isn't initialized. The core question, though, is whether the code in `airoha-ge-soc.c` or `mtk-ge-soc.c` is even *reachable* in a standard virtualized environment like GCE or QEMU, particularly on `amd64`. This is the crux of the matter according to the instructions I'm following.

The instructions emphasize that we *must not* fuzz unreachable code. Section 2 defines this as: "Structurally unreachable hardware... requiring physical ASIC/PCIe cards not emulated in standard QEMU" and "Code paths exclusive to architectures other than the target architecture."

Now, let's look at the Kconfig. Both `AIROHA_GE_SOC_PHY` and `MEDIATEK_GE_SOC_PHY` depend on `ARM64 || ECONET || COMPILE_TEST`. Crucially, they *also* depend on `ARCH_AIROHA`, `ECONET`, or `ARCH_MEDIATEK` respectively. The critical point is that on `amd64`, these `ARCH_*` dependencies are *never* met unless `COMPILE_TEST` is active.  This means these drivers are *only* compiled on `amd64` for build robots as test cases, not as functional drivers.

So, the issue is this: Airoha and MediaTek SoC Ethernet PHYs are specifically designed for ARM64 and MIPS architectures. They are built-in Gigabit Ethernet PHYs in Airoha and MediaTek SoCs. They are not PC hardware, and their associated hardware is not emulated in QEMU on an `amd64` host. They are *structurally unreachable*. The Airoha PHY requires a physical Airoha AN7581/AN7583 board (ARM64) or EcoNet EN7528 (MIPS) and similarly for the MediaTek PHY.

I considered a hypothetical scenario involving `mdio-mvusb`, but that's a red herring. `mdio-mvusb` is for Marvell USB-to-MDIO adapters, and syzkaller's USB fuzzer is not set up to simulate MDIO transactions with an Airoha PHY.  It's simply not part of the standard QEMU environment.

Then, analyzing section 2's examples makes it clear this is the case.  Airoha and MediaTek's SoC PHYs require hardware like vendor-specific PCIe switches, and architectures other than amd64. These are both examples of code that should *not* be fuzzed.

Finally, I checked `mtk-ge-soc.c` and saw the same pattern - dependencies on ARM64 and COMPILE_TEST, indicating the same unreachable hardware scenario. I also confirmed this in `mtk-phy-lib.c`. In other words, I've confirmed that these PHYs are not reachable on amd64 in any real or virtual standard setup.



50/2 2026/10/14 12:09 tool grepper
0m Args:
{
  "Expression": "MTK_NET_PHYLIB",
  "PathPrefixes": [
    "drivers/net/phy/"
  ]
}

Results:
{
  "Output": "drivers/net/phy/mediatek/Kconfig=2=config AIROHA_GE_SOC_PHY\n--\ndrivers/net/phy/mediatek/Kconfig-5-\tdepends on ARCH_AIROHA || ECONET || COMPILE_TEST\ndrivers/net/phy/mediatek/Kconfig:6:\tselect MTK_NET_PHYLIB\ndrivers/net/phy/mediatek/Kconfig-7-\tselect PHY_PACKAGE\n--\ndrivers/net/phy/mediatek/Kconfig=15=config MEDIATEK_2P5GE_PHY\n--\ndrivers/net/phy/mediatek/Kconfig-17-\tdepends on (ARM64 \u0026\u0026 ARCH_MEDIATEK) || COMPILE_TEST\ndrivers/net/phy/mediatek/Kconfig:18:\tselect MTK_NET_PHYLIB\ndrivers/net/phy/mediatek/Kconfig-19-\thelp\n--\ndrivers/net/phy/mediatek/Kconfig=26=config MEDIATEK_GE_PHY\ndrivers/net/phy/mediatek/Kconfig-27-\ttristate \"MediaTek Gigabit Ethernet PHYs\"\ndrivers/net/phy/mediatek/Kconfig:28:\tselect MTK_NET_PHYLIB\ndrivers/net/phy/mediatek/Kconfig-29-\thelp\n--\ndrivers/net/phy/mediatek/Kconfig=46=config MEDIATEK_GE_SOC_PHY\n--\ndrivers/net/phy/mediatek/Kconfig-49-\tdepends on (ARCH_MEDIATEK \u0026\u0026 NVMEM_MTK_EFUSE) || COMPILE_TEST\ndrivers/net/phy/mediatek/Kconfig:50:\tselect MTK_NET_PHYLIB\ndrivers/net/phy/mediatek/Kconfig-51-\tselect PHY_PACKAGE\n--\ndrivers/net/phy/mediatek/Kconfig-63-\ndrivers/net/phy/mediatek/Kconfig:64:config MTK_NET_PHYLIB\ndrivers/net/phy/mediatek/Kconfig-65-\ttristate\n--\ndrivers/net/phy/mediatek/Makefile=6=obj-$(CONFIG_MEDIATEK_GE_SOC_PHY)\t+= mtk-ge-soc.o\ndrivers/net/phy/mediatek/Makefile:7:obj-$(CONFIG_MTK_NET_PHYLIB)\t\t+= mtk-phy-lib.o\n"
}

51/2 2026/10/14 12:09 llm patch-evaluator
0m Model:
gemini-3.8-flash

Args:
null

Results:
null

Tokens:
							input: 115156
							output: 38
							thoughts: 66
						

Thoughts:
**Investigating the MEDIATEK_GE_PHY Configuration**

Okay, let's dive in. My initial thought is to zero in on `MEDIATEK_GE_PHY` within the `drivers/net/phy/mediatek/Kconfig` file. I need to refresh my memory, what exactly *is* `MEDIATEK_GE_PHY`? I should probably just reread the relevant section of the config file.

Specifically, I'll direct my attention to lines 20 through 40 in that `Kconfig` file. That's usually where the meat of the description and dependencies are. Hopefully, that will provide the context I'm looking for regarding the MediaTek gigabit ethernet PHY configuration option. I'm expecting to find a clear definition, perhaps some dependency information and certainly the conditions under which this option can be enabled. I want to understand its purpose and how it fits into the broader network subsystem.



52/2 2026/10/14 12:09 tool read-file
0m Args:
{
  "File": "drivers/net/phy/mediatek/Kconfig",
  "FirstLine": 20,
  "LineCount": 25
}

Results:
{
  "Contents": "  20:\t\t  Supports MediaTek SoC built-in 2.5Gb Ethernet PHYs.\n  21:\t\n  22:\t\t  This will load necessary firmware and add appropriate time delay.\n  23:\t\t  Accelerate this procedure through internal pbus instead of MDIO\n  24:\t\t  bus. Certain link-up issues will also be fixed here.\n  25:\t\n  26:\tconfig MEDIATEK_GE_PHY\n  27:\t\ttristate \"MediaTek Gigabit Ethernet PHYs\"\n  28:\t\tselect MTK_NET_PHYLIB\n  29:\t\thelp\n  30:\t\t  Supports the MediaTek non-built-in Gigabit Ethernet PHYs.\n  31:\t\n  32:\t\t  Non-built-in Gigabit Ethernet PHYs include mt7530/mt7531.\n  33:\t\t  You may find mt7530 inside mt7621. This driver shares some\n  34:\t\t  common operations with MediaTek SoC built-in Gigabit\n  35:\t\t  Ethernet PHYs.\n  36:\t\n  37:\tconfig MEDIATEK_FE_SOC_PHY\n  38:\t\ttristate \"MediaTek SoC Fast Ethernet PHYs\"\n  39:\t\tdepends on SOC_MT7620 || COMPILE_TEST\n  40:\t\thelp\n  41:\t\t  Support for MediaTek MT7628 built-in Fast Ethernet PHYs.\n  42:\t\t  This driver only sets an initialization bit required for the PHY\n  43:\t\t  to establish 100 Mbps links. All other PHY operations are handled\n  44:\t\t  by the kernel's generic PHY code.\n"
}

53/2 2026/10/14 12:09 llm patch-evaluator
0m Model:
gemini-3.8-flash

Args:
null

Results:
null

Tokens:
							input: 115875
							output: 53
							thoughts: 205
						

Thoughts:
**Analyzing the mtk-ge.c and mtk-phy-lib.c Interactions**

Okay, let's break this down. The objective is clear: understand the relationship between the `MEDIATEK_GE_PHY` definition, specifically for the mt7530/mt7531 Ethernet switch PHYs, and the changes implemented within `mtk-phy-lib.c`. I need to figure out if `MEDIATEK_GE_PHY` utilizes the modified functions within that library.

First, I need to remind myself what exactly *was* modified in `mtk-phy-lib.c`. Right, I remember: the `__mtk_tr_write` function was made non-static and exported, and the `mt798x_phy_led_*` functions were moved into `mtk-phy-lib.c` and also exported.

Now the core question: does `mtk-ge.c`, the potential consumer of these PHY features, actually *call* either `__mtk_tr_write` or any of the `mt798x_phy_led_*` functions? I'll need to use a grep on `mtk-ge.c` to look for instances of "mt798x_phy_led" and "__mtk_tr_write" to know for certain. That should give me the answer quickly and efficiently.



54/2 2026/10/14 12:09 tool grepper
0m Error:
no matches

Args:
{
  "Expression": "mt798x_phy_led|__mtk_tr_write",
  "PathPrefixes": [
    "drivers/net/phy/mediatek/mtk-ge.c"
  ]
}

Results:
{
  "error": "no matches"
}

55/2 2026/10/14 12:09 llm patch-evaluator
0m Model:
gemini-3.8-flash

Args:
null

Results:
null

Tokens:
							input: 116449
							output: 56
							thoughts: 51
						

Thoughts:
Okay, here's my take on those thoughts, framed as an expert's internal monologue:

**Investigating LED and TR Write Function Calls**

Alright, no luck with `mtk-ge.c`. I was hoping to find some direct calls to either the `mt798x_phy_led_*` functions or that `__mtk_tr_write` function, but it seems that's a dead end in that file. That's not entirely unexpected; sometimes the code organization can be a bit... convoluted. Time to move on and investigate `mtk-2p5ge.c`. Maybe the LED control or TR write functionality for those 2.5G interfaces is handled differently, or perhaps in that file. Let's see what's in there...



56/2 2026/10/14 12:10 tool grepper
0m Error:
no matches

Args:
{
  "Expression": "mt798x_phy_led|__mtk_tr_write",
  "PathPrefixes": [
    "drivers/net/phy/mediatek/mtk-2p5ge.c"
  ]
}

Results:
{
  "error": "no matches"
}

57/2 2026/10/14 12:10 llm patch-evaluator
0m Model:
gemini-3.8-flash

Args:
null

Results:
null

Tokens:
							input: 116737
							output: 55
							thoughts: 30
						

Thoughts:
Okay, here's my take on those thoughts, framed as an expert's internal monologue:

**Digging Deeper: No Luck in the Usual Suspect**

Alright, that's a bust. I was pretty sure the issue wouldn't be in `mtk-2p5ge.c`, but it's always worth a quick double-check. Nothing obvious there. Now, the natural next step is to examine `mtk-fe-soc.c`. Given the likely hardware configuration, and considering what I know about Mediatek's architecture, the front-end SoC implementation seems like the more probable location for the core of the problem. Time to shift my focus there and see what the code reveals.



58/2 2026/10/14 12:10 tool grepper
0m Error:
no matches

Args:
{
  "Expression": "mt798x_phy_led|__mtk_tr_write",
  "PathPrefixes": [
    "drivers/net/phy/mediatek/mtk-fe-soc.c"
  ]
}

Results:
{
  "error": "no matches"
}

59/2 2026/10/14 12:10 llm patch-evaluator
0m Model:
gemini-3.8-flash

Args:
null

Results:
null

Tokens:
							input: 116989
							output: 203
							thoughts: 941
						

Thoughts:
**Analysis of Reachability and Fuzzing Worthiness**

Okay, here's what I've got. I've thoroughly checked the kernel codebase, and these specific functions `mt798x_phy_led_*` are only called by `mtk-ge-soc.c` (MediaTek SoC Gigabit Ethernet PHYs) and `airoha-ge-soc.c` (Airoha SoC Gigabit Ethernet PHYs). Similarly, `__mtk_tr_write` is called exclusively by `mtk-phy-lib.c` and `airoha-ge-soc.c`. Now, both `mtk-ge-soc.c` and `airoha-ge-soc.c` are SoC-specific Ethernet PHY drivers. These drivers are designed for ARM64 (MediaTek and Airoha) and MIPS (EcoNet) architectures, catering to integrated Ethernet PHYs found within specific MediaTek and Airoha network SoCs (MT7981, MT7988, AN7581, AN7583, EN7528).

Crucially, these drivers can't be compiled on amd64 without COMPILE_TEST. They also *require* physical, vendor-specific SoC hardware that isn't emulated in standard QEMU or GCE environments. Thus, this code is *structurally unreachable* on an amd64 system.

Now, let's go over the negative criteria to confirm my assessment. The logic explicitly states to return `WorthFuzzing = false` if *all* modified code falls under one or more categories:

1.  "Structurally unreachable hardware": This *absolutely* applies. These are vendor-specific SoC-integrated Ethernet PHY drivers, requiring specific physical hardware not emulated in standard QEMU.
2.  "Code paths exclusive to architectures other than the target architecture": This also applies. The code is designed for ARM64 and MIPS, not the target architecture, amd64. Even when selectable on amd64 using COMPILE\_TEST, the code paths are not reachable without the underlying hardware.

Therefore, given these factors, I'm confident in concluding that `WorthFuzzing = false`. The code modifications are designed for specialized hardware and architectures that are not accessible on the target amd64 architecture in the default environment.

I'll now prepare the tool call:

*   EnableConfigs: \[ ]
*   FocusSymbols: \[ ]
*   WorthFuzzing: false
*   Reasoning: The patch introduces new PHY drivers (`airoha-ge-soc.c`) and refactors existing MediaTek PHY driver code (`mtk-ge-soc.c`, `mtk-phy-lib.c`) for built-in Ethernet PHYs on Airoha, EcoNet, and MediaTek SoCs. These PHYs are SoC-integrated internal components and are only available on ARM64 and MIPS platforms, not amd64. They require physical vendor-specific SoC hardware not emulated in common virtualization, making the modified code structurally unreachable on amd64.
    The code is not worth fuzzing, and I will call `set-results`.



60/2 2026/10/14 12:10 tool set-results
0m Args:
{
  "EnableConfigs": [],
  "FocusSymbols": [],
  "Reasoning": "The patch adds the Airoha SoC Gigabit Ethernet PHY driver (airoha-ge-soc.c) and refactors shared helper and LED functions across MediaTek/Airoha PHY drivers (mtk-ge-soc.c, mtk-phy-lib.c). These drivers target built-in Gigabit Ethernet PHYs physically integrated into ARM64 (Airoha AN7581/AN7583, MediaTek MT7981/MT7988) and MIPS (EcoNet EN7528) networking SoCs. On the target amd64 architecture, these drivers can only be built with COMPILE_TEST and require physical SoC hardware not emulated in standard QEMU/GCE environments. Because the modified code is structurally unreachable, it does not warrant fuzzing.",
  "WorthFuzzing": false
}

Results:
{
  "EnableConfigs": null,
  "FocusSymbols": [],
  "Reasoning": "The patch adds the Airoha SoC Gigabit Ethernet PHY driver (airoha-ge-soc.c) and refactors shared helper and LED functions across MediaTek/Airoha PHY drivers (mtk-ge-soc.c, mtk-phy-lib.c). These drivers target built-in Gigabit Ethernet PHYs physically integrated into ARM64 (Airoha AN7581/AN7583, MediaTek MT7981/MT7988) and MIPS (EcoNet EN7528) networking SoCs. On the target amd64 architecture, these drivers can only be built with COMPILE_TEST and require physical SoC hardware not emulated in standard QEMU/GCE environments. Because the modified code is structurally unreachable, it does not warrant fuzzing.",
  "WorthFuzzing": false
}

61/1 2026/10/14 12:10 action If
0m Args:
{
  "WorthFuzzing": false
}

Results:
null

LLM Calls Summary:
Total Calls Total Tokens Avg Tokens Total Duration (Seconds) Avg Duration (Seconds)
Tool Calls Summary:
Total Calls Total Duration (Seconds) Avg Duration (Seconds)