AI Trajectory


Trajectory: (Expand/Collapse All)
Seq Timestamp Type Name Duration
0/0 2026/10/15 18:34 flow patch-triage
2m Args:
null

Results:
{
  "EnableConfigs": null,
  "FocusSymbols": [],
  "KMSANReasoning": "",
  "NeedsKMSAN": false,
  "Reasoning": "The patch series adds support for the Motorcomm YT8824 Ethernet PHY (a 4-port 2.5G physical PHY package configured via Device Tree) and introduces a generic C45 helper (genphy_c45_template_testmode) exclusively called by this driver. Physical Ethernet PHY chips such as the Motorcomm YT8824 are hardware ASICs requiring physical MDIO buses and Device Tree bindings not emulated or present in standard QEMU/GCE amd64 virtualization environments. Therefore, the modified code is structurally unreachable for fuzzing.",
  "WorthFuzzing": false
}

1/1 2026/10/15 18:34 action read-patch-diff
0m Args:
null

Results:
{
  "PatchDiff": "commit 92e6c4dfb3f2a0093be48bfd0c0031e6c28d0cb4\nAuthor: syz-cluster \u003ctriage@syzkaller.com\u003e\nDate:   Thu Oct 15 18:34:13 2026 +0000\n\n    syz-cluster: applied patch under review\n\ndiff --git a/Documentation/devicetree/bindings/net/motorcomm,yt8824.yaml b/Documentation/devicetree/bindings/net/motorcomm,yt8824.yaml\nnew file mode 100644\nindex 0000000000000..4c67f8afcf27a\n--- /dev/null\n+++ b/Documentation/devicetree/bindings/net/motorcomm,yt8824.yaml\n@@ -0,0 +1,78 @@\n+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)\n+%YAML 1.2\n+---\n+$id: http://devicetree.org/schemas/net/motorcomm,yt8824.yaml#\n+$schema: http://devicetree.org/meta-schemas/core.yaml#\n+\n+title: MotorComm YT8824 Ethernet PHY\n+\n+maintainers:\n+  - Kyle Switch \u003ckyle.switch@motor-comm.com\u003e\n+\n+description:\n+  Motorcomm YT8824 Ethernet PHY is a PHY package of 4 PHYs.\n+\n+$ref: ethernet-phy-package.yaml#\n+\n+properties:\n+  compatible:\n+    enum:\n+      - motorcomm,yt8824-package\n+\n+  motorcomm,package-mode:\n+    description: |\n+      PHY package can be configured in 2 modes:\n+      - internal: YT8824 is embedded in the switch, using\n+        an internal interface to the MAC.\n+      - 10g-qxgmii: YT8824 is a standalone external PHY,\n+        connected via 10G QXGMII.\n+    $ref: /schemas/types.yaml#/definitions/string\n+    enum: [ internal, 10g-qxgmii ]\n+\n+  reg:\n+    description:\n+      The absolute MDIO address of the YT8824 shared top extend\n+      register block.\n+      For internal mode, this is fixed at 9;\n+      For external mode, it is the base MDIO address of the four\n+      member PHYs plus 4, where base is typically 0x0.\n+      Note that this is NOT the reg of the first member PHY.\n+\n+required:\n+  - compatible\n+  - motorcomm,package-mode\n+  - reg\n+\n+unevaluatedProperties: false\n+\n+examples:\n+  - |\n+    mdio {\n+        #address-cells = \u003c1\u003e;\n+        #size-cells = \u003c0\u003e;\n+\n+        ethernet-phy-package@9 {\n+            #address-cells = \u003c1\u003e;\n+            #size-cells = \u003c0\u003e;\n+            compatible = \"motorcomm,yt8824-package\";\n+            reg = \u003c9\u003e;\n+\n+            motorcomm,package-mode = \"internal\";\n+\n+            ethernet-phy@4 {\n+                reg = \u003c4\u003e;\n+            };\n+\n+            ethernet-phy@5 {\n+                reg = \u003c5\u003e;\n+            };\n+\n+            ethernet-phy@6 {\n+                reg = \u003c6\u003e;\n+            };\n+\n+            ethernet-phy@7 {\n+                reg = \u003c7\u003e;\n+            };\n+        };\n+    };\ndiff --git a/MAINTAINERS b/MAINTAINERS\nindex 509b35b5a0e7a..572f6b26ae6d9 100644\n--- a/MAINTAINERS\n+++ b/MAINTAINERS\n@@ -18427,8 +18427,10 @@ F:\tdrivers/net/ethernet/stmicro/stmmac/dwmac-motorcomm.c\n \n MOTORCOMM PHY DRIVER\n M:\tFrank \u003cFrank.Sae@motor-comm.com\u003e\n+M:\tKyle Switch \u003ckyle.switch@motor-comm.com\u003e\n L:\tnetdev@vger.kernel.org\n S:\tMaintained\n+F:\tDocumentation/devicetree/bindings/net/motorcomm,yt8824.yaml\n F:\tDocumentation/devicetree/bindings/net/motorcomm,yt8xxx.yaml\n F:\tdrivers/net/phy/motorcomm.c\n \ndiff --git a/drivers/net/phy/Kconfig b/drivers/net/phy/Kconfig\nindex d3835597e3795..996d75afed446 100644\n--- a/drivers/net/phy/Kconfig\n+++ b/drivers/net/phy/Kconfig\n@@ -361,9 +361,10 @@ config MICROSEMI_PHY\n \n config MOTORCOMM_PHY\n \ttristate \"Motorcomm PHYs\"\n+\tselect PHY_PACKAGE\n \thelp\n \t  Enables support for Motorcomm network PHYs.\n-\t  Currently supports YT85xx Gigabit Ethernet PHYs.\n+\t  Currently supports YT85xx Gigabit Ethernet PHYs and YT8824 4 * 2.5G PHY.\n \n config NATIONAL_PHY\n \ttristate \"National Semiconductor PHYs\"\ndiff --git a/drivers/net/phy/motorcomm.c b/drivers/net/phy/motorcomm.c\nindex 90a4f86f2758b..47f2e19f233db 100644\n--- a/drivers/net/phy/motorcomm.c\n+++ b/drivers/net/phy/motorcomm.c\n@@ -1,24 +1,31 @@\n // SPDX-License-Identifier: GPL-2.0+\n /*\n- * Motorcomm 8511/8521/8522/8531/8531S/8821 PHY driver.\n+ * Motorcomm 8511/8521/8522/8531/8531S/8821/8824 PHY driver.\n  *\n  * Author: Peter Geis \u003cpgwipeout@gmail.com\u003e\n  * Author: Frank \u003cFrank.Sae@motor-comm.com\u003e\n+ * Author: Kyle \u003ckyle.switch@motor-comm.com\u003e\n  */\n \n #include \u003clinux/clk.h\u003e\n #include \u003clinux/etherdevice.h\u003e\n #include \u003clinux/kernel.h\u003e\n+#include \u003clinux/mdio.h\u003e\n #include \u003clinux/module.h\u003e\n+#include \u003clinux/of.h\u003e\n+#include \u003clinux/of_net.h\u003e\n #include \u003clinux/phy.h\u003e\n #include \u003clinux/property.h\u003e\n \n+#include \"phylib.h\"\n+\n #define PHY_ID_YT8511\t\t0x0000010a\n #define PHY_ID_YT8521\t\t0x0000011a\n #define PHY_ID_YT8522\t\t0x4f51e928\n #define PHY_ID_YT8531\t\t0x4f51e91b\n #define PHY_ID_YT8531S\t\t0x4f51e91a\n #define PHY_ID_YT8821\t\t0x4f51ea19\n+#define PHY_ID_YT8824\t\t0x4f51e8b8\n /* YT8521/YT8531S/YT8821 Register Overview\n  *\tUTP Register space\t|\tFIBER Register space\n  *  ------------------------------------------------------------\n@@ -30,6 +37,18 @@\n  *  ------------------------------------------------------------\n  */\n \n+/* YT8824 Register Overview\n+ * UTP Register space\t| SERDES Register space\n+ *  ------------------------------------------------------------\n+ * | UTP MII\t\t| SERDES MII\t\t|\n+ * | UTP MMD\t\t|\t\t\t|\n+ * | UTP Extended\t| SERDES Extended\t|\n+ * | UTP Top Extended\t| SERDES Top Extended\t|\n+ *  ------------------------------------------------------------\n+ * |   Common Top Extended\t\t\t|\n+ *  ------------------------------------------------------------\n+ */\n+\n /* 0x10 ~ 0x15 , 0x1E and 0x1F are common MII registers of yt phy */\n \n /* Specific Function Control Register */\n@@ -381,6 +400,226 @@\n #define YT8821_CHIP_MODE_AUTO_BX2500_SGMII\t0\n #define YT8821_CHIP_MODE_FORCE_BX2500\t\t1\n \n+#define YT8824_RSSR_SPACE_MASK\t\t\tBIT(0)\n+#define YT8824_RSSR_SERDES_SPACE\t\t(0x1)\n+#define YT8824_RSSR_UTP_SPACE\t\t\t(0x0)\n+#define YT8824_SDS_CFG_MIN_PRE_MASK\t\tGENMASK(3, 0)\n+#define YT8824_SDS_EN_FILL_PRE\t\t\tBIT(13)\n+#define YT8824_SDS_TX_PRE_PADDING\t\t(0x7)\n+\n+/* PHY8824 UTP init registers */\n+#define YT8824_WRITE_PROTECT_CAL_REG\t\t0x1\n+#define YT8824_WRITE_PROTECT\t\t\tBIT(0)\n+#define YT8824_PLL_VCO_ATEMP_REG\t\t0xa20e\n+#define YT8824_PLL_VCO_SEL_CURRENT\t\tGENMASK(7, 4)\n+#define YT8824_PLL_VCO_SEL_CURRENT_B\t\t0xb\n+#define YT8824_PLL_PFD_CTRL_REG\t\t\t0xa20a\n+#define YT8824_PLL_VCO_ICOSTANT\t\t\tGENMASK(9, 4)\n+#define YT8824_PLL_VCO_ATEMP_1_REG\t\t0xa20c\n+#define YT8824_PLL_VCO_IPTAT\t\t\tGENMASK(5, 0)\n+#define YT8824_PLL_DAC_0_REG\t\t\t0xa2b6\n+#define YT8824_PLL_DAC_RST\t\t\tBIT(10)\n+#define YT8824_IF_CTRL_REG\t\t\t0xa003\n+#define YT8824_U0_U1_ENABLE_ODD_PREAMBLE\tGENMASK(1, 0)\n+#define YT8824_IDLE_CTRL_REG\t\t\t0x3d0\n+#define YT8824_IDLE_DETECT\t\t\tBIT(9)\n+#define YT8824_TRACE_GAIN_THR_REG\t\t0x372\n+#define YT8824_TRACE_LNG_GAIN_THR_2500\t\tGENMASK(14, 8)\n+#define YT8824_TRACE_MED_GAIN_THR_2500\t\tGENMASK(6, 0)\n+#define YT8824_PRM_LONG_REG\t\t\t0x37C\n+#define YT8824_PRM_LARGE_SLAVE_2500\t\tGENMASK(10, 0)\n+#define YT8824_PRM_SMALL_REG\t\t\t0x388\n+#define YT8824_PRM_SMALL_LNG_2500\t\tGENMASK(10, 0)\n+#define YT8824_FAST_RETRAIN_REG\t\t\t0x359\n+#define YT8824_LINK_FAIL_SIG\t\t\tGENMASK(13, 8)\n+#define YT8824_EN_GATE_CTRL_REG\t\t\t0xc\n+#define YT8824_EN_GATE_GMII_CLK\t\t\tBIT(0)\n+#define YT8824_DAC_CFG_REG\t\t\t0xa2fa\n+#define YT8824_POWER_SAVE\t\t\tGENMASK(15, 0)\n+#define YT8824_DAC_BIAS_CFG_REG\t\t\t0x4e2\n+#define YT8824_DAC_BIAS_CFG_2500\t\tGENMASK(9, 5)\n+#define YT8824_DAC_IMID_CFG_REG\t\t\t0x47e\n+#define YT8824_DAC_IMID_CH2\t\t\tGENMASK(6, 0)\n+#define YT8824_DAC_IMID_CH3\t\t\tGENMASK(14, 8)\n+#define YT8824_DAC_IMID_CFG1_REG\t\t0x47f\n+#define YT8824_DAC_IMID_CH0\t\t\tGENMASK(6, 0)\n+#define YT8824_DAC_IMID_CH1\t\t\tGENMASK(14, 8)\n+#define YT8824_DAC_IMSB_CFG_REG\t\t\t0x480\n+#define YT8824_DAC_IMSB_CH2\t\t\tGENMASK(6, 0)\n+#define YT8824_DAC_IMSB_CH3\t\t\tGENMASK(14, 8)\n+#define YT8824_DAC_IMSB_CFG1_REG\t\t0x481\n+#define YT8824_DAC_IMSB_CH0\t\t\tGENMASK(6, 0)\n+#define YT8824_DAC_IMSB_CH1\t\t\tGENMASK(14, 8)\n+#define YT8824_TRACE_LNG_GAIN_REG\t\t0x336\n+#define YT8824_TRACE_LNG_GAIN_THR\t\tGENMASK(14, 8)\n+#define YT8824_TRACE_MED_GAIN_REG\t\t0x340\n+#define YT8824_TRACE_MED_GAIN_THR\t\tGENMASK(6, 0)\n+#define YT8824_DAC_IMID_CH2_CH3_CFG_ORG_REG\t0x46e\n+#define YT8824_DAC_IMID_CH3_ORG\t\t\tGENMASK(14, 8)\n+#define YT8824_DAC_IMID_CH2_ORG\t\t\tGENMASK(6, 0)\n+#define YT8824_DAC_IMID_CH0_CH1_CFG_ORG_REG\t0x46f\n+#define YT8824_DAC_IMID_CH1_ORG\t\t\tGENMASK(14, 8)\n+#define YT8824_DAC_IMID_CH0_ORG\t\t\tGENMASK(6, 0)\n+#define YT8824_DAC_IMSB_CH2_CH3_CFG_ORG_REG\t0x470\n+#define YT8824_DAC_IMSB_CH3_ORG\t\t\tGENMASK(14, 8)\n+#define YT8824_DAC_IMSB_CH2_ORG\t\t\tGENMASK(6, 0)\n+#define YT8824_DAC_IMSB_CH0_CH1_CFG_ORG_REG\t0x471\n+#define YT8824_DAC_IMSB_CH1_ORG\t\t\tGENMASK(14, 8)\n+#define YT8824_DAC_IMSB_CH0_ORG\t\t\tGENMASK(6, 0)\n+#define YT8824_TRACE_LNG_GAIN_100_REG\t\t0x030b\n+#define YT8824_TRACE_LNG_GAIN_THR_100\t\tGENMASK(14, 8)\n+#define YT8824_TRACE_MED_GAIN_THR_100\t\tGENMASK(6, 0)\n+#define YT8824_CABLE_VSHT_REG\t\t\t0x071f\n+#define YT8824_CABLE_VSHT_THR_S\t\t\tGENMASK(6, 0)\n+#define YT8824_DAC_LPFIL_CH2_CH3_ADJ_REG\t0x046b\n+#define YT8824_DAC_LPFIL_ADJ_CH3_10\t\tGENMASK(12, 8)\n+#define YT8824_DAC_LPFIL_ADJ_CH2_10\t\tGENMASK(4, 0)\n+#define YT8824_DAC_LPFIL_CH0_CH1_ADJ_REG\t0x046c\n+#define YT8824_DAC_LPFIL_ADJ_CH1_10\t\tGENMASK(12, 8)\n+#define YT8824_DAC_LPFIL_ADJ_CH0_10\t\tGENMASK(4, 0)\n+#define YT8824_DAC_IMID_CFG_CH2_CH3_10_ORG\t0x0466\n+#define YT8824_DAC_IMID_CFG_CH3_10_ORG\t\tGENMASK(14, 8)\n+#define YT8824_DAC_IMID_CFG_CH2_10_ORG\t\tGENMASK(6, 0)\n+#define YT8824_DAC_IMID_CFG_CH0_CH1_10_ORG\t0x0467\n+#define YT8824_DAC_IMID_CFG_CH1_10_ORG\t\tGENMASK(14, 8)\n+#define YT8824_DAC_IMID_CFG_CH0_10_ORG\t\tGENMASK(6, 0)\n+#define YT8824_DAC_IMSB_CFG_CH2_CH3_10_ORG\t0x0468\n+#define YT8824_DAC_IMSB_CFG_CH3_10_ORG\t\tGENMASK(14, 8)\n+#define YT8824_DAC_IMSB_CFG_CH2_10_ORG\t\tGENMASK(6, 0)\n+#define YT8824_DAC_IMSB_CFG_CH0_CH1_10_ORG\t0x0469\n+#define YT8824_DAC_IMSB_CFG_CH1_10_ORG\t\tGENMASK(14, 8)\n+#define YT8824_DAC_IMSB_CFG_CH0_10_ORG\t\tGENMASK(6, 0)\n+#define YT8824_FFE_REG\t\t\t\t0x034a\n+#define YT8824_WAIT_TO_1000\t\t\tGENMASK(15, 8)\n+#define YT8824_FFE_SUM_THRES\t\t\tGENMASK(2, 0)\n+#define YT8824_EN_GATE_REG\t\t\t0x00f8\n+#define YT8824_EN_GATE_PHYDBG\t\t\tBIT(10)\n+#define YT8824_EN_GATE_BT1000\t\t\tBIT(9)\n+#define YT8824_CNT_REG\t\t\t\t0x0059\n+#define YT8824_CNT_ERR_AUTO\t\t\tBIT(14)\n+#define YT8824_PRM_LARGE_MASTER_REG\t\t0x032c\n+#define YT8824_PRM_LARGE_MASTER_1000\t\tGENMASK(10, 0)\n+#define YT8824_PRM_LARGE_SLAVE_REG\t\t0x032d\n+#define YT8824_PRM_LARGE_SLAVE_1000\t\tGENMASK(10, 0)\n+#define YT8824_SIG_GONE_REG\t\t\t0x032e\n+#define YT8824_SIG_GONE_THR_1000\t\tGENMASK(7, 0)\n+#define YT8824_EC_NX_TRAIN_COARSE_REG\t\t0x0322\n+#define YT8824_EC_NX_TRAIN_COARSE_TO_1000\tGENMASK(7, 0)\n+#define YT8824_VGA_IN_LPF2_CAP_REG\t\t0x04d3\n+#define YT8824_VGA_IN_LPF2_CAP_OTHER\t\tGENMASK(7, 4)\n+#define YT8824_VGA_IN_LPF1_CAP_REG\t\t0x04d2\n+#define YT8824_VGA_IN_LPF1_CAP_OTHER\t\tGENMASK(7, 4)\n+#define YT8824_LDPC_LFER_FAIL_REG\t\t0x00c8\n+#define YT8824_LDPC_FAIL_THR\t\t\tGENMASK(15, 8)\n+#define YT8824_LFER_FAIL_THR\t\t\tGENMASK(7, 0)\n+#define YT8824_FR_REQ_REG\t\t\t0x00be\n+#define YT8824_FR_REQ_THR\t\t\tGENMASK(4, 0)\n+#define YT8824_GN_MU_COARSE_REG\t\t\t0x037a\n+#define YT8824_PRM_SMALL_SHT_2500\t\tGENMASK(10, 0)\n+#define YT8824_DAC_AMP_ADJ_REG\t\t\t0x0482\n+#define YT8824_DAC_AMP_ADJ_CH3_PBO0_2500\tGENMASK(15, 12)\n+#define YT8824_DAC_AMP_ADJ_CH2_PBO0_2500\tGENMASK(11, 8)\n+#define YT8824_DAC_AMP_ADJ_CH1_PBO0_2500\tGENMASK(7, 4)\n+#define YT8824_DAC_AMP_ADJ_CH0_PBO0_2500\tGENMASK(3, 0)\n+#define YT8824_P0_DAC_BIAS_CAS_CH3_CH2_REG\t0xa2d5\n+#define YT8824_P0_DAC_BIAS_CAS_CFG_CH3\t\tGENMASK(12, 8)\n+#define YT8824_P0_DAC_BIAS_CAS_CFG_CH2\t\tGENMASK(4, 0)\n+#define YT8824_P0_DAC_BIAS_CAS_CH1_CH0_REG\t0xa2d6\n+#define YT8824_P0_DAC_BIAS_CAS_CFG_CH1\t\tGENMASK(12, 8)\n+#define YT8824_P0_DAC_BIAS_CAS_CFG_CH0\t\tGENMASK(4, 0)\n+#define YT8824_P1_DAC_BIAS_CAS_CH3_CH2_REG\t0xa2d7\n+#define YT8824_P1_DAC_BIAS_CAS_CFG_CH3\t\tGENMASK(12, 8)\n+#define YT8824_P1_DAC_BIAS_CAS_CFG_CH2\t\tGENMASK(4, 0)\n+#define YT8824_P1_DAC_BIAS_CAS_CH1_CH0_REG\t0xa2d8\n+#define YT8824_P1_DAC_BIAS_CAS_CFG_CH1\t\tGENMASK(12, 8)\n+#define YT8824_P1_DAC_BIAS_CAS_CFG_CH0\t\tGENMASK(4, 0)\n+#define YT8824_P01_PLL_EN_REG\t\t\t0xa218\n+#define YT8824_CSR_EFUSE_BYPASS_ANALOG_SECOND_RESET\tBIT(6)\n+#define YT8824_CSR_EFUSE_BYPASS_PLL_TXRX_RESET\t\tBIT(5)\n+#define YT8824_U0_CSR_RESET_REG\t\t\t0xa01d\n+#define YT8824_U0_CSR_RESETB_TX_CH0\t\tBIT(3)\n+#define YT8824_U0_CSR_RESETB_TX_CH1\t\tBIT(2)\n+#define YT8824_U0_CSR_RESETB_TX_CH2\t\tBIT(1)\n+#define YT8824_U0_CSR_RESETB_TX_CH3\t\tBIT(0)\n+#define YT8824_U1_CSR_RESET_REG\t\t\t0xa01e\n+#define YT8824_U1_CSR_RESETB_TX_CH0\t\tBIT(3)\n+#define YT8824_U1_CSR_RESETB_TX_CH1\t\tBIT(2)\n+#define YT8824_U1_CSR_RESETB_TX_CH2\t\tBIT(1)\n+#define YT8824_U1_CSR_RESETB_TX_CH3\t\tBIT(0)\n+/* External PHY8824 serdes init registers */\n+#define YT8824_SERDES_PLL_CTRL1_REG\t\t0xa13e\n+#define YT8824_SERDES_PLL_CTRL2_REG\t\t0xa13f\n+#define YT8824_SERDES_PLL_CTRL3_REG\t\t0xa140\n+#define YT8824_WRITE_PROTECT_REG\t\t0x4be\n+#define YT8824_SERDES_REG_WR_PRT\t\tBIT(2)\n+#define YT8824_CSR_CTRL_REG\t\t\t0x49f\n+#define YT8824_CSR_PCS_GLB_RST_BYPASS\t\tBIT(10)\n+#define YT8824_CSR_SG_MODE_RST_BYPASS\t\tBIT(9)\n+#define YT8824_CSR_US_GLB_RESET_N\t\tBIT(7)\n+#define YT8824_CSR_PCS_BEF_TRAINING_DONE_RST_BYPASS\tBIT(2)\n+#define YT8824_CSR_PMA_CTRL_REG\t\t\t0x4a9\n+#define YT8824_CSR_WATCH_DOG_ALL_BYPASS\t\tBIT(7)\n+#define YT8824_CDR_CTRL_REG\t\t\t0x406\n+#define YT8824_CDR_MODE\t\t\t\tBIT(11)\n+#define YT8824_CSR_PLL_VCO_CTRL_REG\t\t0x438\n+#define YT8824_CSR_PLL_VCO_SEL_VCO2_CURRENT\tGENMASK(15, 12)\n+#define YT8824_CSR_PLL_VCO_ATEMP_R\t\tGENMASK(2, 0)\n+#define YT8824_CSR_PLL_DIVLDO_CTRL_REG\t\t0x439\n+#define YT8824_CSR_PLL_VCO_SEL_VCO2_RM_R\tGENMASK(1, 0)\n+#define YT8824_CSR_PLL_FBDIV_REG\t\t0x043a\n+#define YT8824_CSR_PLL_FBDIV_SYNC_SELB\t\tBIT(1)\n+#define YT8824_CSR_PLL_SPARE_CTRL_REG\t\t0x042a\n+#define YT8824_CSR_PLL_SPARE\t\t\tGENMASK(15, 0)\n+#define YT8824_CDR_MANUAL_REG\t\t\t0x0491\n+#define YT8824_VDAC_AMP_THR_LNG\t\t\tGENMASK(6, 0)\n+#define YT8824_TRAINING_CTRL_REG\t\t0x0492\n+#define YT8824_VDAC_AMP_THR_MED\t\t\tGENMASK(14, 8)\n+#define YT8824_VDAC_AMP_THR_SHT\t\t\tGENMASK(7, 0)\n+#define YT8824_EOM_CTRL_REG\t\t\t0x0454\n+#define YT8824_EOD_DURATION_SEL\t\t\tGENMASK(11, 8)\n+#define YT8824_EOD_VTH\t\t\t\tGENMASK(6, 0)\n+#define YT8824_PGA_GAIN_CTRL_REG\t\t0x0497\n+#define YT8824_CDR_OFFSET_ERR_WTH\t\tGENMASK(14, 8)\n+#define YT8824_PGA_GAIN_MAX\t\t\tGENMASK(6, 4)\n+#define YT8824_PGA_GAIN_INIT\t\t\tGENMASK(2, 0)\n+#define YT8824_EOD_CTRL_REG\t\t\t0x04cd\n+#define YT8824_EOD_ERR_CNT_THR\t\t\tGENMASK(15, 0)\n+#define YT8824_CSR_AFE_CTRL_REG\t\t\t0x04af\n+#define YT8824_CSR_AFE_VCM_CFG\t\t\tGENMASK(10, 8)\n+#define YT8824_CSR_AFE_MANUAL_CTRL_1P25G\tBIT(4)\n+#define YT8824_CSR_AFE_MANUAL_CTRL_3P125G\tBIT(3)\n+#define YT8824_CSR_AFE_MANUAL_CTRL_10P3125G\tBIT(2)\n+#define YT8824_DFE_CTRL_REG\t\t\t0x048a\n+#define YT8824_DFE_TAP_POLARITY\t\t\tBIT(12)\n+#define YT8824_DFE_IDAC_TUNE\t\t\tGENMASK(11, 10)\n+#define YT8824_CSR_CDR_CTRL_REG\t\t\t0x0408\n+#define YT8824_CSR_CDR_OFFSET_DATA\t\tGENMASK(14, 8)\n+#define YT8824_DFE_VDAC_CODE_REG\t\t0x04d6\n+#define YT8824_DFE_VDAC_CODE_THR\t\t\tGENMASK(6, 0)\n+#define YT8824_RX_SPARE_CTRL_REG\t\t0x044f\n+#define YT8824_RX_SPARE_REG\t\t\tGENMASK(15, 0)\n+#define YT8824_DFE_VDAC_CTRL_REG\t\t0x048e\n+#define YT8824_DFE_VDAC_TUNE\t\t\tGENMASK(11, 10)\n+#define YT8824_DFE_VDAC_SEL\t\t\tGENMASK(9, 8)\n+#define YT8824_CSR_TX_PRE_REG\t\t\t0x000d\n+#define YT8824_CSR_TX_PRE_SEL\t\t\tGENMASK(4, 0)\n+#define YT8824_CSR_AFE_CTRL1_REG\t\t0x04b0\n+#define YT8824_CSR_AFE_CTLE_BW\t\t\tGENMASK(6, 4)\n+#define YT8824_CSR_AFE_CTRL2_REG\t\t0x04b1\n+#define YT8824_CSR_AFE_PGA_BW\t\t\tGENMASK(14, 12)\n+#define YT8824_CSR_AFE_BUF_BW\t\t\tGENMASK(6, 4)\n+#define YT8824_CSR_DCC_CAL_CTRL_REG\t\t0x0003\n+#define YT8824_CUR_TX_SEQ\t\t\tGENMASK(15, 12)\n+#define YT8824_CUR_RX_SEQ\t\t\tGENMASK(11, 8)\n+#define YT8824_CALIB_SEQ_FINISH\t\t\tBIT(1)\n+#define YT8824_CALIB_SEQ_SW_RST\t\t\tBIT(0)\n+#define YT8824_RESTART_CAL_CTRL_REG\t\t0x2000\n+#define YT8824_DAC_TRIM_MAIN_CFG_REG\t\t0x429\n+#define YT8824_PLL_VCO_CFG_REG\t\t\t0x441\n+#define YT8824_TX_MUX_CH3_CH2_REG\t\t0x42b\n+#define YT8824_C1_COARSE_CFG_REG\t\t0x4b4\n+#define YT8824_FFE_CTRL_REG\t\t\t0x4b5\n+\n struct yt8521_priv {\n \t/* combo_advertising is used for case of YT8521 in combo mode,\n \t * this means that yt8521 may work in utp or fiber mode which depends\n@@ -399,6 +638,14 @@ struct yt8521_priv {\n \tu8 reg_page;\n };\n \n+struct yt8824_shared_priv {\n+\tphy_interface_t package_mode;\n+\t/* shared_lock used to UTPs operation isolation during swap reg space */\n+\tstruct mutex shared_lock;\n+\t/* true once the package-wide SERDES init has been done */\n+\tbool sds_initialized;\n+};\n+\n /**\n  * ytphy_read_ext() - read a PHY's extended register\n  * @phydev: a pointer to a \u0026struct phy_device\n@@ -437,6 +684,70 @@ static int ytphy_read_ext_with_lock(struct phy_device *phydev, u16 regnum)\n \treturn ret;\n }\n \n+/**\n+ * ytphy_read_top_ext() - read a PHY's top extended register for YT8824\n+ * @phydev: a pointer to a \u0026struct phy_device\n+ * @regnum: register number to read\n+ *\n+ * Returns: the value of regnum reg or negative error code\n+ */\n+static int ytphy_read_top_ext(struct phy_device *phydev, u16 regnum)\n+{\n+\tint ret;\n+\n+\tlockdep_assert_held(\u0026phydev-\u003emdio.bus-\u003emdio_lock);\n+\tret = __phy_package_write(phydev, 0, YTPHY_PAGE_SELECT, regnum);\n+\tif (ret \u003c 0)\n+\t\treturn ret;\n+\n+\treturn __phy_package_read(phydev, 0, YTPHY_PAGE_DATA);\n+}\n+\n+/**\n+ * ytphy_write_top_ext() - write a PHY's top extended register for YT8824\n+ * @phydev: a pointer to a \u0026struct phy_device\n+ * @regnum: register number to write\n+ * @val: register val to write\n+ *\n+ * Returns: 0 or negative error code\n+ */\n+static int ytphy_write_top_ext(struct phy_device *phydev, u16 regnum,\n+\t\t\t       u16 val)\n+{\n+\tint ret;\n+\n+\tlockdep_assert_held(\u0026phydev-\u003emdio.bus-\u003emdio_lock);\n+\tret = __phy_package_write(phydev, 0, YTPHY_PAGE_SELECT, regnum);\n+\tif (ret \u003c 0)\n+\t\treturn ret;\n+\n+\treturn __phy_package_write(phydev, 0, YTPHY_PAGE_DATA, val);\n+}\n+\n+/**\n+ * phy8824_page_write_with_lock() - write page for YT8824\n+ * @phydev: a pointer to a \u0026struct phy_device\n+ * @page: reg page(YT8824_RSSR_SERDES_SPACE/YT8824_RSSR_UTP_SPACE).\n+ *\n+ * Returns: 0 or negative error code\n+ */\n+static int phy8824_page_write_with_lock(struct phy_device *phydev, int page)\n+{\n+\tint ret;\n+\n+\tphy_lock_mdio_bus(phydev);\n+\tret = ytphy_read_top_ext(phydev, YT8521_REG_SPACE_SELECT_REG);\n+\tif (ret \u003c 0)\n+\t\tgoto err;\n+\tret \u0026= ~YT8824_RSSR_SPACE_MASK;\n+\tret |= (page \u0026 YT8824_RSSR_SPACE_MASK);\n+\tret = ytphy_write_top_ext(phydev, YT8521_REG_SPACE_SELECT_REG, ret);\n+\n+err:\n+\tphy_unlock_mdio_bus(phydev);\n+\treturn ret;\n+}\n+\n /**\n  * ytphy_write_ext() - write a PHY's extended register\n  * @phydev: a pointer to a \u0026struct phy_device\n@@ -622,15 +933,1165 @@ static int ytphy_set_wol(struct phy_device *phydev, struct ethtool_wolinfo *wol)\n \t\tmask = YTPHY_WCR_ENABLE | YTPHY_WCR_INTR_SEL;\n \t\tret = ytphy_modify_ext(phydev, YTPHY_WOL_CONFIG_REG, mask, 0);\n \n-\t\t/* Disable WOL interrupt */\n-\t\tret = __phy_modify(phydev, YTPHY_INTERRUPT_ENABLE_REG,\n-\t\t\t\t   YTPHY_IER_WOL, 0);\n+\t\t/* Disable WOL interrupt */\n+\t\tret = __phy_modify(phydev, YTPHY_INTERRUPT_ENABLE_REG,\n+\t\t\t\t   YTPHY_IER_WOL, 0);\n+\t\tif (ret \u003c 0)\n+\t\t\tgoto err_restore_page;\n+\t}\n+\n+err_restore_page:\n+\treturn phy_restore_page(phydev, old_page, ret);\n+}\n+\n+/**\n+ * yt8824_read_page() - read PHY8824 reg page\n+ * @phydev: a pointer to a \u0026struct phy_device\n+ *\n+ * Returns: current reg space of yt8824 (YT8824_RSSR_SERDES_SPACE/\n+ * YT8824_RSSR_UTP_SPACE) or negative errno code\n+ */\n+static int yt8824_read_page(struct phy_device *phydev)\n+{\n+\tint old_page;\n+\n+\told_page = ytphy_read_top_ext(phydev, YT8521_REG_SPACE_SELECT_REG);\n+\tif (old_page \u003c 0)\n+\t\treturn old_page;\n+\n+\treturn old_page \u0026 YT8824_RSSR_SPACE_MASK;\n+};\n+\n+/**\n+ * yt8824_write_page() - write reg page\n+ * @phydev: a pointer to a \u0026struct phy_device\n+ * @page: Reg page(YT8824_RSSR_SERDES_SPACE/YT8824_RSSR_UTP_SPACE) to write.\n+ *\n+ * Returns: 0 or negative errno code\n+ */\n+static int yt8824_write_page(struct phy_device *phydev, int page)\n+{\n+\tint old_page;\n+\tu16 data;\n+\n+\told_page = ytphy_read_top_ext(phydev, YT8521_REG_SPACE_SELECT_REG);\n+\tif (old_page \u003c 0)\n+\t\treturn old_page;\n+\tdata = old_page \u0026 (~YT8824_RSSR_SPACE_MASK);\n+\tdata |= page;\n+\n+\treturn ytphy_write_top_ext(phydev, YT8521_REG_SPACE_SELECT_REG, data);\n+};\n+\n+/**\n+ * yt8824_utp_set_template_test_mode() - config YT8824 UTP test mode.\n+ * @phydev: a pointer to a \u0026struct phy_device\n+ * @test_mode: template test mode from normal, testmode1 to testmode7\n+ *\n+ * Returns: 0 or negative errno code\n+ */\n+static int yt8824_utp_set_template_test_mode(struct phy_device *phydev,\n+\t\t\t\t\t     u16 test_mode)\n+{\n+\tint ret;\n+\n+\tret = phy8824_page_write_with_lock(phydev, YT8824_RSSR_UTP_SPACE);\n+\tif (ret \u003c 0)\n+\t\treturn ret;\n+\n+\treturn genphy_c45_template_testmode(phydev, test_mode);\n+}\n+\n+/**\n+ * yt8824_sds_isolate_paged() - enable YT8824 serdes isolate.\n+ * @phydev: a pointer to a \u0026struct phy_device\n+ *\n+ * Returns: 0 or negative errno code\n+ */\n+static int yt8824_sds_isolate_paged(struct phy_device *phydev)\n+{\n+\tint old_page = YT8824_RSSR_UTP_SPACE;\n+\tint ret = 0;\n+\n+\told_page = phy_select_page(phydev, YT8824_RSSR_SERDES_SPACE);\n+\tif (old_page \u003c 0)\n+\t\tgoto err_restore_page;\n+\n+\t/* enable sds isolate */\n+\tret = __phy_modify(phydev, MII_BMCR, BMCR_ISOLATE, BMCR_ISOLATE);\n+\n+err_restore_page:\n+\treturn phy_restore_page(phydev, old_page, ret);\n+}\n+\n+/**\n+ * yt8824_utp_softreset_paged() - config YT8824 UTP softreset.\n+ * @phydev: a pointer to a \u0026struct phy_device\n+ *\n+ * Returns: 0 or negative errno code\n+ */\n+static int yt8824_utp_softreset_paged(struct phy_device *phydev)\n+{\n+\tint ret = 0;\n+\tint val;\n+\n+\tret = phy8824_page_write_with_lock(phydev, YT8824_RSSR_UTP_SPACE);\n+\tif (ret \u003c 0)\n+\t\treturn ret;\n+\tret = phy_modify(phydev, MII_BMCR, BMCR_RESET, BMCR_RESET);\n+\tif (ret \u003c 0)\n+\t\treturn ret;\n+\t/* wait until softreset done. */\n+\treturn phy_read_poll_timeout(phydev, MII_BMCR, val, !(val \u0026 BMCR_RESET),\n+\t\t\t\t     50000, 600000, true);\n+}\n+\n+/**\n+ * yt8824_sds_isolate_and_softreset_paged() - disable YT8824 serdes isolate\n+ * and sds softreset.\n+ * @phydev: a pointer to a \u0026struct phy_device\n+ *\n+ * Returns: 0 or negative errno code\n+ */\n+static int yt8824_sds_isolate_and_softreset_paged(struct phy_device *phydev)\n+{\n+\tint old_page = YT8824_RSSR_UTP_SPACE;\n+\tint val = 0;\n+\tint ret = -1;\n+\n+\told_page = phy_select_page(phydev, YT8824_RSSR_SERDES_SPACE);\n+\tif (old_page \u003c 0)\n+\t\tgoto err_restore_page;\n+\n+\t/* sds softreset and disable isolate */\n+\tret = __phy_modify(phydev, MII_BMCR, BMCR_RESET | BMCR_ISOLATE,\n+\t\t\t   BMCR_RESET \u0026 ~BMCR_ISOLATE);\n+\tif (ret \u003c 0)\n+\t\tgoto err_restore_page;\n+\n+\t/* poll while still holding the lock */\n+\tret = read_poll_timeout(__phy_read, val,\n+\t\t\t\t(val \u003c 0) || !(val \u0026 BMCR_RESET), 50000, 600000,\n+\t\t\t\ttrue, phydev, MII_BMCR);\n+\tif (val \u003c 0)\n+\t\tret = val;\n+\n+err_restore_page:\n+\treturn phy_restore_page(phydev, old_page, ret);\n+}\n+\n+/**\n+ * yt8824_restore_working_status() - called to do store working status\n+ * @phydev: a pointer to a \u0026struct phy_device\n+ * @ret: operation's return code\n+ *\n+ * Returns: 0 or negative errno code\n+ */\n+static int yt8824_restore_working_status(struct phy_device *phydev, int ret)\n+{\n+\tstruct yt8824_shared_priv *priv = phy_package_get_priv(phydev);\n+\tint r;\n+\n+\tr = yt8824_utp_set_template_test_mode(phydev,\n+\t\t\t\t\t      MDIO_PMA_10GBT_TESTMODE_NORMAL);\n+\tif (ret \u003e= 0 \u0026\u0026 r \u003c 0)\n+\t\tret = r;\n+\tif (priv-\u003epackage_mode != PHY_INTERFACE_MODE_INTERNAL) {\n+\t\tr = yt8824_sds_isolate_and_softreset_paged(phydev);\n+\t\tif (ret \u003e= 0 \u0026\u0026 r \u003c 0)\n+\t\t\tret = r;\n+\t}\n+\n+\treturn ret;\n+}\n+\n+/**\n+ * yt8824_soft_reset() - called to do PHY software reset\n+ * @phydev: a pointer to a \u0026struct phy_device\n+ *\n+ * Returns: 0 or negative errno code\n+ */\n+static int yt8824_soft_reset(struct phy_device *phydev)\n+{\n+\tstruct yt8824_shared_priv *priv = phy_package_get_priv(phydev);\n+\tint ret;\n+\n+\tmutex_lock(\u0026priv-\u003eshared_lock);\n+\tif (priv-\u003epackage_mode == PHY_INTERFACE_MODE_INTERNAL) {\n+\t\tret = yt8824_utp_set_template_test_mode(phydev,\n+\t\t\t\t\t\t\tMDIO_PMA_10GBT_TESTMODE_1);\n+\t\tif (ret \u003c 0)\n+\t\t\tgoto retry;\n+\n+\t\tret = yt8824_utp_softreset_paged(phydev);\n+\t\tif (ret \u003c 0)\n+\t\t\tgoto retry;\n+\n+\t\tret = yt8824_utp_set_template_test_mode(phydev,\n+\t\t\t\t\t\t\tMDIO_PMA_10GBT_TESTMODE_NORMAL);\n+\t\tif (ret \u003c 0)\n+\t\t\tgoto retry;\n+\t} else {\n+\t\tret = yt8824_utp_set_template_test_mode(phydev,\n+\t\t\t\t\t\t\tMDIO_PMA_10GBT_TESTMODE_1);\n+\t\tif (ret \u003c 0)\n+\t\t\tgoto retry;\n+\n+\t\tret = yt8824_sds_isolate_paged(phydev);\n+\t\tif (ret \u003c 0)\n+\t\t\tgoto retry;\n+\n+\t\tret = yt8824_utp_softreset_paged(phydev);\n+\t\tif (ret \u003c 0)\n+\t\t\tgoto retry;\n+\n+\t\tret = yt8824_utp_set_template_test_mode(phydev,\n+\t\t\t\t\t\t\tMDIO_PMA_10GBT_TESTMODE_NORMAL);\n+\t\tif (ret \u003c 0)\n+\t\t\tgoto retry;\n+\n+\t\tret = yt8824_sds_isolate_and_softreset_paged(phydev);\n+\t\tif (ret \u003c 0)\n+\t\t\tgoto retry;\n+\t}\n+\tmutex_unlock(\u0026priv-\u003eshared_lock);\n+\treturn ret;\n+retry:\n+\tret = yt8824_restore_working_status(phydev, ret);\n+\tmutex_unlock(\u0026priv-\u003eshared_lock);\n+\n+\treturn ret;\n+}\n+\n+/**\n+ * yt8824_config_utp_init_paged() - config external phy8824 utp init\n+ * @phydev: target phy_device struct\n+ *\n+ * Returns: 0 or negative errno code\n+ */\n+static int yt8824_config_utp_init_paged(struct phy_device *phydev)\n+{\n+\tint ctrl = 0;\n+\tint mask = 0;\n+\tint ret = 0;\n+\tint val = 0;\n+\tint r;\n+\n+\tret = phy8824_page_write_with_lock(phydev, YT8824_RSSR_UTP_SPACE);\n+\tif (ret \u003c 0)\n+\t\treturn ret;\n+\n+\tret = phy_modify(phydev, MII_BMCR, BMCR_PDOWN, BMCR_PDOWN);\n+\tif (ret \u003c 0)\n+\t\tgoto err_restore;\n+\n+\t/* write protecting */\n+\tmask = YT8824_WRITE_PROTECT;\n+\tctrl = YT8824_WRITE_PROTECT;\n+\tret = ytphy_modify_ext_with_lock(phydev,\n+\t\t\t\t\t YT8824_WRITE_PROTECT_CAL_REG,\n+\t\t\t\t\t mask, ctrl);\n+\tif (ret \u003c 0)\n+\t\tgoto err_restore;\n+\n+\t/* PLL calibration */\n+\tctrl = FIELD_PREP(YT8824_PLL_VCO_SEL_CURRENT, 0xb);\n+\tmask = YT8824_PLL_VCO_SEL_CURRENT;\n+\tret = ytphy_modify_ext_with_lock(phydev,\n+\t\t\t\t\t YT8824_PLL_VCO_ATEMP_REG,\n+\t\t\t\t\t mask, ctrl);\n+\tif (ret \u003c 0)\n+\t\tgoto err_restore;\n+\n+\tctrl = FIELD_PREP(YT8824_PLL_VCO_ICOSTANT, 0xf);\n+\tmask = YT8824_PLL_VCO_ICOSTANT;\n+\tret = ytphy_modify_ext_with_lock(phydev,\n+\t\t\t\t\t YT8824_PLL_PFD_CTRL_REG,\n+\t\t\t\t\t mask, ctrl);\n+\tif (ret \u003c 0)\n+\t\tgoto err_restore;\n+\n+\tctrl = FIELD_PREP(YT8824_PLL_VCO_IPTAT, 0xf);\n+\tmask = YT8824_PLL_VCO_IPTAT;\n+\tret = ytphy_modify_ext_with_lock(phydev,\n+\t\t\t\t\t YT8824_PLL_VCO_ATEMP_1_REG,\n+\t\t\t\t\t mask, ctrl);\n+\tif (ret \u003c 0)\n+\t\tgoto err_restore;\n+\n+\tctrl = FIELD_PREP(YT8824_PLL_DAC_RST, 0);\n+\tmask = YT8824_PLL_DAC_RST;\n+\tret = ytphy_modify_ext_with_lock(phydev,\n+\t\t\t\t\t YT8824_PLL_DAC_0_REG,\n+\t\t\t\t\t mask, ctrl);\n+\tif (ret \u003c 0)\n+\t\tgoto err_restore;\n+\n+\tctrl = FIELD_PREP(YT8824_PLL_DAC_RST, 1);\n+\tmask = YT8824_PLL_DAC_RST;\n+\tret = ytphy_modify_ext_with_lock(phydev,\n+\t\t\t\t\t YT8824_PLL_DAC_0_REG,\n+\t\t\t\t\t mask, ctrl);\n+\tif (ret \u003c 0)\n+\t\tgoto err_restore;\n+\n+\t/* enable nibble */\n+\tctrl = FIELD_PREP(YT8824_U0_U1_ENABLE_ODD_PREAMBLE, 3);\n+\tmask = YT8824_U0_U1_ENABLE_ODD_PREAMBLE;\n+\tret = ytphy_modify_ext_with_lock(phydev,\n+\t\t\t\t\t YT8824_IF_CTRL_REG,\n+\t\t\t\t\t mask, ctrl);\n+\tif (ret \u003c 0)\n+\t\tgoto err_restore;\n+\n+\t/* idle err detect enable */\n+\tctrl = YT8824_IDLE_DETECT;\n+\tmask = YT8824_IDLE_DETECT;\n+\tret = ytphy_modify_ext_with_lock(phydev,\n+\t\t\t\t\t YT8824_IDLE_CTRL_REG,\n+\t\t\t\t\t mask, ctrl);\n+\tif (ret \u003c 0)\n+\t\tgoto err_restore;\n+\n+\t/* optimized 2.5G long cable performance */\n+\tctrl = FIELD_PREP(YT8824_TRACE_LNG_GAIN_THR_2500, 0x50);\n+\tctrl |= FIELD_PREP(YT8824_TRACE_MED_GAIN_THR_2500, 0x38);\n+\tmask = YT8824_TRACE_LNG_GAIN_THR_2500 |\n+\t       YT8824_TRACE_MED_GAIN_THR_2500;\n+\tret = ytphy_modify_ext_with_lock(phydev,\n+\t\t\t\t\t YT8824_TRACE_GAIN_THR_REG,\n+\t\t\t\t\t mask, ctrl);\n+\tif (ret \u003c 0)\n+\t\tgoto err_restore;\n+\n+\tctrl = FIELD_PREP(YT8824_PRM_LARGE_SLAVE_2500, 0x68);\n+\tmask = YT8824_PRM_LARGE_SLAVE_2500;\n+\tret = ytphy_modify_ext_with_lock(phydev,\n+\t\t\t\t\t YT8824_PRM_LONG_REG,\n+\t\t\t\t\t mask, ctrl);\n+\tif (ret \u003c 0)\n+\t\tgoto err_restore;\n+\n+\tctrl = FIELD_PREP(YT8824_PRM_SMALL_LNG_2500, 0xa0);\n+\tmask = YT8824_PRM_SMALL_LNG_2500;\n+\tret = ytphy_modify_ext_with_lock(phydev,\n+\t\t\t\t\t YT8824_PRM_SMALL_REG,\n+\t\t\t\t\t mask, ctrl);\n+\tif (ret \u003c 0)\n+\t\tgoto err_restore;\n+\n+\t/* optimized fast retrain */\n+\tctrl = FIELD_PREP(YT8824_LINK_FAIL_SIG, 0x21);\n+\tmask = YT8824_LINK_FAIL_SIG;\n+\tret = ytphy_modify_ext_with_lock(phydev,\n+\t\t\t\t\t YT8824_FAST_RETRAIN_REG,\n+\t\t\t\t\t mask, ctrl);\n+\tif (ret \u003c 0)\n+\t\tgoto err_restore;\n+\n+\tctrl = FIELD_PREP(YT8824_EN_GATE_GMII_CLK, 0);\n+\tmask = YT8824_EN_GATE_GMII_CLK;\n+\tret = ytphy_modify_ext_with_lock(phydev,\n+\t\t\t\t\t YT8824_EN_GATE_CTRL_REG,\n+\t\t\t\t\t mask, ctrl);\n+\tif (ret \u003c 0)\n+\t\tgoto err_restore;\n+\n+\t/* 2.5G template tone */\n+\tctrl = FIELD_PREP(YT8824_POWER_SAVE, 0x83);\n+\tmask = YT8824_POWER_SAVE;\n+\tret = ytphy_modify_ext_with_lock(phydev,\n+\t\t\t\t\t YT8824_DAC_CFG_REG,\n+\t\t\t\t\t mask, ctrl);\n+\tif (ret \u003c 0)\n+\t\tgoto err_restore;\n+\n+\tctrl = FIELD_PREP(YT8824_DAC_BIAS_CFG_2500, 0xa);\n+\tmask = YT8824_DAC_BIAS_CFG_2500;\n+\tret = ytphy_modify_ext_with_lock(phydev,\n+\t\t\t\t\t YT8824_DAC_BIAS_CFG_REG,\n+\t\t\t\t\t mask, ctrl);\n+\tif (ret \u003c 0)\n+\t\tgoto err_restore;\n+\n+\t/* optimized 2.5G template */\n+\tctrl = FIELD_PREP(YT8824_DAC_IMID_CH2, 0x39);\n+\tctrl |= FIELD_PREP(YT8824_DAC_IMID_CH3, 0x39);\n+\tmask = YT8824_DAC_IMID_CH2 | YT8824_DAC_IMID_CH3;\n+\tret = ytphy_modify_ext_with_lock(phydev,\n+\t\t\t\t\t YT8824_DAC_IMID_CFG_REG,\n+\t\t\t\t\t mask, ctrl);\n+\tif (ret \u003c 0)\n+\t\tgoto err_restore;\n+\n+\tctrl = FIELD_PREP(YT8824_DAC_IMID_CH0, 0x39);\n+\tctrl |= FIELD_PREP(YT8824_DAC_IMID_CH1, 0x39);\n+\tmask = YT8824_DAC_IMID_CH0 | YT8824_DAC_IMID_CH1;\n+\tret = ytphy_modify_ext_with_lock(phydev,\n+\t\t\t\t\t YT8824_DAC_IMID_CFG1_REG,\n+\t\t\t\t\t mask, ctrl);\n+\tif (ret \u003c 0)\n+\t\tgoto err_restore;\n+\n+\tctrl = FIELD_PREP(YT8824_DAC_IMSB_CH2, 0x39);\n+\tctrl |= FIELD_PREP(YT8824_DAC_IMSB_CH3, 0x39);\n+\tmask = YT8824_DAC_IMSB_CH2 | YT8824_DAC_IMSB_CH3;\n+\tret = ytphy_modify_ext_with_lock(phydev,\n+\t\t\t\t\t YT8824_DAC_IMSB_CFG_REG,\n+\t\t\t\t\t mask, ctrl);\n+\tif (ret \u003c 0)\n+\t\tgoto err_restore;\n+\n+\tctrl = FIELD_PREP(YT8824_DAC_IMSB_CH0, 0x39);\n+\tctrl |= FIELD_PREP(YT8824_DAC_IMSB_CH1, 0x39);\n+\tmask = YT8824_DAC_IMSB_CH0 | YT8824_DAC_IMSB_CH1;\n+\tret = ytphy_modify_ext_with_lock(phydev,\n+\t\t\t\t\t YT8824_DAC_IMSB_CFG1_REG,\n+\t\t\t\t\t mask, ctrl);\n+\tif (ret \u003c 0)\n+\t\tgoto err_restore;\n+\n+\t/* optimized 1000M cable length threshold */\n+\tctrl = FIELD_PREP(YT8824_TRACE_LNG_GAIN_THR, 0x2b);\n+\tmask = YT8824_TRACE_LNG_GAIN_THR;\n+\tret = ytphy_modify_ext_with_lock(phydev,\n+\t\t\t\t\t YT8824_TRACE_LNG_GAIN_REG,\n+\t\t\t\t\t mask, ctrl);\n+\tif (ret \u003c 0)\n+\t\tgoto err_restore;\n+\n+\tctrl = FIELD_PREP(YT8824_TRACE_MED_GAIN_THR, 0x1d);\n+\tmask = YT8824_TRACE_MED_GAIN_THR;\n+\tret = ytphy_modify_ext_with_lock(phydev,\n+\t\t\t\t\t YT8824_TRACE_MED_GAIN_REG,\n+\t\t\t\t\t mask, ctrl);\n+\tif (ret \u003c 0)\n+\t\tgoto err_restore;\n+\n+\t/* 100M template amplitude */\n+\tctrl = FIELD_PREP(YT8824_DAC_IMID_CH3_ORG, 0x45);\n+\tctrl |= FIELD_PREP(YT8824_DAC_IMID_CH2_ORG, 0x45);\n+\tmask = YT8824_DAC_IMID_CH3_ORG | YT8824_DAC_IMID_CH2_ORG;\n+\tret = ytphy_modify_ext_with_lock(phydev,\n+\t\t\t\t\t YT8824_DAC_IMID_CH2_CH3_CFG_ORG_REG,\n+\t\t\t\t\t mask, ctrl);\n+\tif (ret \u003c 0)\n+\t\tgoto err_restore;\n+\n+\tctrl = FIELD_PREP(YT8824_DAC_IMID_CH1_ORG, 0x45);\n+\tctrl |= FIELD_PREP(YT8824_DAC_IMID_CH0_ORG, 0x45);\n+\tmask = YT8824_DAC_IMID_CH1_ORG | YT8824_DAC_IMID_CH0_ORG;\n+\tret = ytphy_modify_ext_with_lock(phydev,\n+\t\t\t\t\t YT8824_DAC_IMID_CH0_CH1_CFG_ORG_REG,\n+\t\t\t\t\t mask, ctrl);\n+\tif (ret \u003c 0)\n+\t\tgoto err_restore;\n+\n+\tctrl = FIELD_PREP(YT8824_DAC_IMSB_CH3_ORG, 0x45);\n+\tctrl |= FIELD_PREP(YT8824_DAC_IMSB_CH2_ORG, 0x45);\n+\tmask = YT8824_DAC_IMSB_CH2_ORG | YT8824_DAC_IMSB_CH3_ORG;\n+\tret = ytphy_modify_ext_with_lock(phydev,\n+\t\t\t\t\t YT8824_DAC_IMSB_CH2_CH3_CFG_ORG_REG,\n+\t\t\t\t\t mask, ctrl);\n+\tif (ret \u003c 0)\n+\t\tgoto err_restore;\n+\n+\tctrl = FIELD_PREP(YT8824_DAC_IMSB_CH1_ORG, 0x45);\n+\tctrl |= FIELD_PREP(YT8824_DAC_IMSB_CH0_ORG, 0x45);\n+\tmask = YT8824_DAC_IMSB_CH1_ORG | YT8824_DAC_IMSB_CH0_ORG;\n+\tret = ytphy_modify_ext_with_lock(phydev,\n+\t\t\t\t\t YT8824_DAC_IMSB_CH0_CH1_CFG_ORG_REG,\n+\t\t\t\t\t mask, ctrl);\n+\tif (ret \u003c 0)\n+\t\tgoto err_restore;\n+\n+\t/* optimized 100M cable length threshold */\n+\tctrl = FIELD_PREP(YT8824_TRACE_LNG_GAIN_THR_100, 0x2A);\n+\tctrl |= FIELD_PREP(YT8824_TRACE_MED_GAIN_THR_100, 0x1D);\n+\tmask = YT8824_TRACE_LNG_GAIN_THR_100 | YT8824_TRACE_MED_GAIN_THR_100;\n+\tret = ytphy_modify_ext_with_lock(phydev,\n+\t\t\t\t\t YT8824_TRACE_LNG_GAIN_100_REG,\n+\t\t\t\t\t mask, ctrl);\n+\tif (ret \u003c 0)\n+\t\tgoto err_restore;\n+\n+\tctrl = FIELD_PREP(YT8824_CABLE_VSHT_THR_S, 0x36);\n+\tmask = YT8824_CABLE_VSHT_THR_S;\n+\tret = ytphy_modify_ext_with_lock(phydev, YT8824_CABLE_VSHT_REG,\n+\t\t\t\t\t mask, ctrl);\n+\tif (ret \u003c 0)\n+\t\tgoto err_restore;\n+\n+\t/* 10M template amplitude */\n+\tctrl = FIELD_PREP(YT8824_DAC_LPFIL_ADJ_CH3_10, 0x18);\n+\tctrl |= FIELD_PREP(YT8824_DAC_LPFIL_ADJ_CH2_10, 0x18);\n+\tmask = YT8824_DAC_LPFIL_ADJ_CH3_10 | YT8824_DAC_LPFIL_ADJ_CH2_10;\n+\tret = ytphy_modify_ext_with_lock(phydev,\n+\t\t\t\t\t YT8824_DAC_LPFIL_CH2_CH3_ADJ_REG,\n+\t\t\t\t\t mask, ctrl);\n+\tif (ret \u003c 0)\n+\t\tgoto err_restore;\n+\n+\tctrl = FIELD_PREP(YT8824_DAC_LPFIL_ADJ_CH1_10, 0x18);\n+\tctrl |= FIELD_PREP(YT8824_DAC_LPFIL_ADJ_CH0_10, 0x18);\n+\tmask = YT8824_DAC_LPFIL_ADJ_CH1_10 | YT8824_DAC_LPFIL_ADJ_CH0_10;\n+\tret = ytphy_modify_ext_with_lock(phydev,\n+\t\t\t\t\t YT8824_DAC_LPFIL_CH0_CH1_ADJ_REG,\n+\t\t\t\t\t mask, ctrl);\n+\tif (ret \u003c 0)\n+\t\tgoto err_restore;\n+\n+\t/* optimized 10M cable length threshold */\n+\tctrl = FIELD_PREP(YT8824_DAC_IMID_CFG_CH3_10_ORG, 0x6C);\n+\tctrl |= FIELD_PREP(YT8824_DAC_IMID_CFG_CH2_10_ORG, 0x6C);\n+\tmask = YT8824_DAC_IMID_CFG_CH3_10_ORG | YT8824_DAC_IMID_CFG_CH2_10_ORG;\n+\tret = ytphy_modify_ext_with_lock(phydev,\n+\t\t\t\t\t YT8824_DAC_IMID_CFG_CH2_CH3_10_ORG,\n+\t\t\t\t\t mask, ctrl);\n+\tif (ret \u003c 0)\n+\t\tgoto err_restore;\n+\n+\tctrl = FIELD_PREP(YT8824_DAC_IMID_CFG_CH1_10_ORG, 0x6C);\n+\tctrl |= FIELD_PREP(YT8824_DAC_IMID_CFG_CH0_10_ORG, 0x6C);\n+\tmask = YT8824_DAC_IMID_CFG_CH1_10_ORG | YT8824_DAC_IMID_CFG_CH0_10_ORG;\n+\tret = ytphy_modify_ext_with_lock(phydev,\n+\t\t\t\t\t YT8824_DAC_IMID_CFG_CH0_CH1_10_ORG,\n+\t\t\t\t\t mask, ctrl);\n+\tif (ret \u003c 0)\n+\t\tgoto err_restore;\n+\n+\t/* optimized DAC IMSB config for CH2/CH3 */\n+\tctrl = FIELD_PREP(YT8824_DAC_IMSB_CFG_CH3_10_ORG, 0x6C);\n+\tctrl |= FIELD_PREP(YT8824_DAC_IMSB_CFG_CH2_10_ORG, 0x6C);\n+\tmask = YT8824_DAC_IMSB_CFG_CH3_10_ORG | YT8824_DAC_IMSB_CFG_CH2_10_ORG;\n+\tret = ytphy_modify_ext_with_lock(phydev,\n+\t\t\t\t\t YT8824_DAC_IMSB_CFG_CH2_CH3_10_ORG,\n+\t\t\t\t\t mask, ctrl);\n+\tif (ret \u003c 0)\n+\t\tgoto err_restore;\n+\n+\t/* optimized DAC IMSB config for CH0/CH1 */\n+\tctrl = FIELD_PREP(YT8824_DAC_IMSB_CFG_CH1_10_ORG, 0x6C);\n+\tctrl |= FIELD_PREP(YT8824_DAC_IMSB_CFG_CH0_10_ORG, 0x6C);\n+\tmask = YT8824_DAC_IMSB_CFG_CH1_10_ORG | YT8824_DAC_IMSB_CFG_CH0_10_ORG;\n+\tret = ytphy_modify_ext_with_lock(phydev,\n+\t\t\t\t\t YT8824_DAC_IMSB_CFG_CH0_CH1_10_ORG,\n+\t\t\t\t\t mask, ctrl);\n+\tif (ret \u003c 0)\n+\t\tgoto err_restore;\n+\n+\t/* optimize utp 1000M performance */\n+\tctrl = FIELD_PREP(YT8824_WAIT_TO_1000, 0xFF);\n+\tmask = YT8824_WAIT_TO_1000;\n+\tret = ytphy_modify_ext_with_lock(phydev, YT8824_FFE_REG, mask, ctrl);\n+\tif (ret \u003c 0)\n+\t\tgoto err_restore;\n+\n+\tctrl = FIELD_PREP(YT8824_EN_GATE_PHYDBG, 0);\n+\tctrl |= FIELD_PREP(YT8824_EN_GATE_BT1000, 0);\n+\tmask = YT8824_EN_GATE_PHYDBG | YT8824_EN_GATE_BT1000;\n+\tret = ytphy_modify_ext_with_lock(phydev, YT8824_EN_GATE_REG,\n+\t\t\t\t\t mask, ctrl);\n+\tif (ret \u003c 0)\n+\t\tgoto err_restore;\n+\n+\tctrl = FIELD_PREP(YT8824_CNT_ERR_AUTO, 1);\n+\tmask = YT8824_CNT_ERR_AUTO;\n+\tret = ytphy_modify_ext_with_lock(phydev, YT8824_CNT_REG, mask, ctrl);\n+\tif (ret \u003c 0)\n+\t\tgoto err_restore;\n+\n+\tctrl = FIELD_PREP(YT8824_PRM_LARGE_MASTER_1000, 0x94);\n+\tmask = YT8824_PRM_LARGE_MASTER_1000;\n+\tret = ytphy_modify_ext_with_lock(phydev, YT8824_PRM_LARGE_MASTER_REG,\n+\t\t\t\t\t mask, ctrl);\n+\tif (ret \u003c 0)\n+\t\tgoto err_restore;\n+\n+\tctrl = FIELD_PREP(YT8824_PRM_LARGE_SLAVE_1000, 0x094);\n+\tmask = YT8824_PRM_LARGE_SLAVE_1000;\n+\tret = ytphy_modify_ext_with_lock(phydev, YT8824_PRM_LARGE_SLAVE_REG,\n+\t\t\t\t\t mask, ctrl);\n+\tif (ret \u003c 0)\n+\t\tgoto err_restore;\n+\n+\tctrl = FIELD_PREP(YT8824_SIG_GONE_THR_1000, 0x08);\n+\tmask = YT8824_SIG_GONE_THR_1000;\n+\tret = ytphy_modify_ext_with_lock(phydev, YT8824_SIG_GONE_REG,\n+\t\t\t\t\t mask, ctrl);\n+\tif (ret \u003c 0)\n+\t\tgoto err_restore;\n+\n+\tctrl = FIELD_PREP(YT8824_EC_NX_TRAIN_COARSE_TO_1000, 0x40);\n+\tmask = YT8824_EC_NX_TRAIN_COARSE_TO_1000;\n+\tret = ytphy_modify_ext_with_lock(phydev, YT8824_EC_NX_TRAIN_COARSE_REG,\n+\t\t\t\t\t mask, ctrl);\n+\tif (ret \u003c 0)\n+\t\tgoto err_restore;\n+\n+\tctrl = FIELD_PREP(YT8824_VGA_IN_LPF2_CAP_OTHER, 0x2);\n+\tmask = YT8824_VGA_IN_LPF2_CAP_OTHER;\n+\tret = ytphy_modify_ext_with_lock(phydev, YT8824_VGA_IN_LPF2_CAP_REG,\n+\t\t\t\t\t mask, ctrl);\n+\tif (ret \u003c 0)\n+\t\tgoto err_restore;\n+\n+\tctrl = FIELD_PREP(YT8824_VGA_IN_LPF1_CAP_OTHER, 0x2);\n+\tmask = YT8824_VGA_IN_LPF1_CAP_OTHER;\n+\tret = ytphy_modify_ext_with_lock(phydev, YT8824_VGA_IN_LPF1_CAP_REG,\n+\t\t\t\t\t mask, ctrl);\n+\tif (ret \u003c 0)\n+\t\tgoto err_restore;\n+\n+\t/* optimized EMC CS */\n+\tctrl = FIELD_PREP(YT8824_LDPC_FAIL_THR, 0xFF);\n+\tctrl |= FIELD_PREP(YT8824_LFER_FAIL_THR, 0xFF);\n+\tmask = YT8824_LDPC_FAIL_THR | YT8824_LFER_FAIL_THR;\n+\tret = ytphy_modify_ext_with_lock(phydev, YT8824_LDPC_LFER_FAIL_REG,\n+\t\t\t\t\t mask, ctrl);\n+\tif (ret \u003c 0)\n+\t\tgoto err_restore;\n+\n+\tctrl = FIELD_PREP(YT8824_FR_REQ_THR, 0x06);\n+\tmask = YT8824_FR_REQ_THR;\n+\tret = ytphy_modify_ext_with_lock(phydev, YT8824_FR_REQ_REG, mask, ctrl);\n+\tif (ret \u003c 0)\n+\t\tgoto err_restore;\n+\n+\tctrl = FIELD_PREP(YT8824_PRM_SMALL_SHT_2500, 0x0FF);\n+\tmask = YT8824_PRM_SMALL_SHT_2500;\n+\tret = ytphy_modify_ext_with_lock(phydev, YT8824_GN_MU_COARSE_REG,\n+\t\t\t\t\t mask, ctrl);\n+\tif (ret \u003c 0)\n+\t\tgoto err_restore;\n+\n+\t/* optimized EMC RE */\n+\tctrl = FIELD_PREP(YT8824_DAC_AMP_ADJ_CH3_PBO0_2500, 0xF);\n+\tctrl |= FIELD_PREP(YT8824_DAC_AMP_ADJ_CH2_PBO0_2500, 0xF);\n+\tctrl |= FIELD_PREP(YT8824_DAC_AMP_ADJ_CH1_PBO0_2500, 0xF);\n+\tctrl |= FIELD_PREP(YT8824_DAC_AMP_ADJ_CH0_PBO0_2500, 0xF);\n+\tmask = YT8824_DAC_AMP_ADJ_CH3_PBO0_2500 |\n+\t       YT8824_DAC_AMP_ADJ_CH2_PBO0_2500 |\n+\t       YT8824_DAC_AMP_ADJ_CH1_PBO0_2500 |\n+\t       YT8824_DAC_AMP_ADJ_CH0_PBO0_2500;\n+\tret = ytphy_modify_ext_with_lock(phydev,\n+\t\t\t\t\t YT8824_DAC_AMP_ADJ_REG,\n+\t\t\t\t\t mask, ctrl);\n+\tif (ret \u003c 0)\n+\t\tgoto err_restore;\n+\n+\tctrl = FIELD_PREP(YT8824_P0_DAC_BIAS_CAS_CFG_CH3, 0x1F);\n+\tctrl |= FIELD_PREP(YT8824_P0_DAC_BIAS_CAS_CFG_CH2, 0x1F);\n+\tmask = YT8824_P0_DAC_BIAS_CAS_CFG_CH3 | YT8824_P0_DAC_BIAS_CAS_CFG_CH2;\n+\tret = ytphy_modify_ext_with_lock(phydev,\n+\t\t\t\t\t YT8824_P0_DAC_BIAS_CAS_CH3_CH2_REG,\n+\t\t\t\t\t mask, ctrl);\n+\tif (ret \u003c 0)\n+\t\tgoto err_restore;\n+\n+\tctrl = FIELD_PREP(YT8824_P0_DAC_BIAS_CAS_CFG_CH1, 0x1F);\n+\tctrl |= FIELD_PREP(YT8824_P0_DAC_BIAS_CAS_CFG_CH0, 0x1F);\n+\tmask = YT8824_P0_DAC_BIAS_CAS_CFG_CH1 | YT8824_P0_DAC_BIAS_CAS_CFG_CH0;\n+\tret = ytphy_modify_ext_with_lock(phydev,\n+\t\t\t\t\t YT8824_P0_DAC_BIAS_CAS_CH1_CH0_REG,\n+\t\t\t\t\t mask, ctrl);\n+\tif (ret \u003c 0)\n+\t\tgoto err_restore;\n+\n+\tctrl = FIELD_PREP(YT8824_P1_DAC_BIAS_CAS_CFG_CH3, 0x1F);\n+\tctrl |= FIELD_PREP(YT8824_P1_DAC_BIAS_CAS_CFG_CH2, 0x1F);\n+\tmask = YT8824_P1_DAC_BIAS_CAS_CFG_CH3 | YT8824_P1_DAC_BIAS_CAS_CFG_CH2;\n+\tret = ytphy_modify_ext_with_lock(phydev,\n+\t\t\t\t\t YT8824_P1_DAC_BIAS_CAS_CH3_CH2_REG,\n+\t\t\t\t\t mask, ctrl);\n+\tif (ret \u003c 0)\n+\t\tgoto err_restore;\n+\n+\tctrl = FIELD_PREP(YT8824_P1_DAC_BIAS_CAS_CFG_CH1, 0x1F);\n+\tctrl |= FIELD_PREP(YT8824_P1_DAC_BIAS_CAS_CFG_CH0, 0x1F);\n+\tmask = YT8824_P1_DAC_BIAS_CAS_CFG_CH1 | YT8824_P1_DAC_BIAS_CAS_CFG_CH0;\n+\tret = ytphy_modify_ext_with_lock(phydev,\n+\t\t\t\t\t YT8824_P1_DAC_BIAS_CAS_CH1_CH0_REG,\n+\t\t\t\t\t mask, ctrl);\n+\tif (ret \u003c 0)\n+\t\tgoto err_restore;\n+\n+\tctrl = FIELD_PREP(YT8824_CSR_EFUSE_BYPASS_ANALOG_SECOND_RESET, 1);\n+\tctrl |= FIELD_PREP(YT8824_CSR_EFUSE_BYPASS_PLL_TXRX_RESET, 1);\n+\tmask  = YT8824_CSR_EFUSE_BYPASS_ANALOG_SECOND_RESET |\n+\t\tYT8824_CSR_EFUSE_BYPASS_PLL_TXRX_RESET;\n+\tret = ytphy_modify_ext_with_lock(phydev,\n+\t\t\t\t\t YT8824_P01_PLL_EN_REG,\n+\t\t\t\t\t mask, ctrl);\n+\tif (ret \u003c 0)\n+\t\tgoto err_restore;\n+\n+\tctrl = FIELD_PREP(YT8824_U0_CSR_RESETB_TX_CH0, 0);\n+\tctrl |= FIELD_PREP(YT8824_U0_CSR_RESETB_TX_CH1, 0);\n+\tctrl |= FIELD_PREP(YT8824_U0_CSR_RESETB_TX_CH2, 0);\n+\tctrl |= FIELD_PREP(YT8824_U0_CSR_RESETB_TX_CH3, 0);\n+\tmask  = YT8824_U0_CSR_RESETB_TX_CH0 | YT8824_U0_CSR_RESETB_TX_CH1 |\n+\t\tYT8824_U0_CSR_RESETB_TX_CH2 | YT8824_U0_CSR_RESETB_TX_CH3;\n+\tret = ytphy_modify_ext_with_lock(phydev, YT8824_U0_CSR_RESET_REG,\n+\t\t\t\t\t mask, ctrl);\n+\tif (ret \u003c 0)\n+\t\tgoto err_restore;\n+\n+\tctrl = FIELD_PREP(YT8824_U1_CSR_RESETB_TX_CH0, 0);\n+\tctrl |= FIELD_PREP(YT8824_U1_CSR_RESETB_TX_CH1, 0);\n+\tctrl |= FIELD_PREP(YT8824_U1_CSR_RESETB_TX_CH2, 0);\n+\tctrl |= FIELD_PREP(YT8824_U1_CSR_RESETB_TX_CH3, 0);\n+\tmask = YT8824_U1_CSR_RESETB_TX_CH0 | YT8824_U1_CSR_RESETB_TX_CH1 |\n+\t       YT8824_U1_CSR_RESETB_TX_CH2 | YT8824_U1_CSR_RESETB_TX_CH3;\n+\tret = ytphy_modify_ext_with_lock(phydev, YT8824_U1_CSR_RESET_REG,\n+\t\t\t\t\t mask, ctrl);\n+\tif (ret \u003c 0)\n+\t\tgoto err_restore;\n+\n+\tctrl = FIELD_PREP(YT8824_U0_CSR_RESETB_TX_CH0, 1);\n+\tctrl |= FIELD_PREP(YT8824_U0_CSR_RESETB_TX_CH1, 1);\n+\tctrl |= FIELD_PREP(YT8824_U0_CSR_RESETB_TX_CH2, 1);\n+\tctrl |= FIELD_PREP(YT8824_U0_CSR_RESETB_TX_CH3, 1);\n+\tmask = YT8824_U0_CSR_RESETB_TX_CH0 | YT8824_U0_CSR_RESETB_TX_CH1 |\n+\t       YT8824_U0_CSR_RESETB_TX_CH2 | YT8824_U0_CSR_RESETB_TX_CH3;\n+\tret = ytphy_modify_ext_with_lock(phydev, YT8824_U0_CSR_RESET_REG,\n+\t\t\t\t\t mask, ctrl);\n+\tif (ret \u003c 0)\n+\t\tgoto err_restore;\n+\n+\tctrl = FIELD_PREP(YT8824_U1_CSR_RESETB_TX_CH0, 1);\n+\tctrl |= FIELD_PREP(YT8824_U1_CSR_RESETB_TX_CH1, 1);\n+\tctrl |= FIELD_PREP(YT8824_U1_CSR_RESETB_TX_CH2, 1);\n+\tctrl |= FIELD_PREP(YT8824_U1_CSR_RESETB_TX_CH3, 1);\n+\tmask = YT8824_U1_CSR_RESETB_TX_CH0 | YT8824_U1_CSR_RESETB_TX_CH1 |\n+\t       YT8824_U1_CSR_RESETB_TX_CH2 | YT8824_U1_CSR_RESETB_TX_CH3;\n+\tret = ytphy_modify_ext_with_lock(phydev, YT8824_U1_CSR_RESET_REG,\n+\t\t\t\t\t mask, ctrl);\n+\tif (ret \u003c 0)\n+\t\tgoto err_restore;\n+\t/* reset */\n+\tret = genphy_c45_template_testmode(phydev, MDIO_PMA_10GBT_TESTMODE_1);\n+\tif (ret \u003c 0)\n+\t\tgoto err_restore_normal;\n+\n+\tret = phy_modify(phydev, MII_BMCR, BMCR_RESET | BMCR_ANENABLE,\n+\t\t\t BMCR_RESET | BMCR_ANENABLE);\n+\tif (ret \u003c 0)\n+\t\tgoto err_restore_normal;\n+\tret = phy_read_poll_timeout(phydev, MII_BMCR, val, !(val \u0026 BMCR_RESET),\n+\t\t\t\t    50000, 600000, true);\n+\tif (ret \u003c 0)\n+\t\tgoto err_restore_normal;\n+\n+\tret = genphy_c45_template_testmode(phydev,\n+\t\t\t\t\t   MDIO_PMA_10GBT_TESTMODE_NORMAL);\n+\tif (ret \u003c 0)\n+\t\tgoto err_restore_normal;\n+\treturn 0;\n+\n+err_restore:\n+\tr = phy_modify(phydev, MII_BMCR, BMCR_PDOWN, 0);\n+\tif (ret \u003e= 0 \u0026\u0026 r \u003c 0)\n+\t\tret = r;\n+\treturn ret;\n+\n+err_restore_normal:\n+\tr = genphy_c45_template_testmode(phydev,\n+\t\t\t\t\t MDIO_PMA_10GBT_TESTMODE_NORMAL);\n+\tif (ret \u003e= 0 \u0026\u0026 r \u003c 0)\n+\t\tret = r;\n+\tr = phy_modify(phydev, MII_BMCR, BMCR_PDOWN, 0);\n+\tif (ret \u003e= 0 \u0026\u0026 r \u003c 0)\n+\t\tret = r;\n+\treturn ret;\n+}\n+\n+/**\n+ * yt8824_extern_sds_softreset() - config external phy8824 sds softrest\n+ * @phydev: target phy_device struct\n+ *\n+ *\n+ * Returns: 0 or negative errno code\n+ */\n+static int yt8824_extern_sds_softreset(struct phy_device *phydev)\n+{\n+\tint old_page = YT8824_RSSR_UTP_SPACE;\n+\tint ret = -1;\n+\tint val = 0;\n+\n+\told_page = phy_select_page(phydev, YT8824_RSSR_SERDES_SPACE);\n+\tif (old_page \u003c 0)\n+\t\tgoto err_restore_page;\n+\n+\t/* TX preamble padded to 8; RX IPG always \u003e 8 */\n+\tret = __phy_read(phydev, MII_RESV1);\n+\tif (ret \u003c 0)\n+\t\tgoto err_restore_page;\n+\tret \u0026= ~YT8824_SDS_CFG_MIN_PRE_MASK;\n+\tret |= YT8824_SDS_TX_PRE_PADDING;\n+\tret |= YT8824_SDS_EN_FILL_PRE;\n+\tret = __phy_write(phydev, MII_RESV1, ret);\n+\tif (ret \u003c 0)\n+\t\tgoto err_restore_page;\n+\n+\tret = __phy_modify(phydev, MII_BMCR, BMCR_RESET | BMCR_ANENABLE,\n+\t\t\t   BMCR_RESET | BMCR_ANENABLE);\n+\tif (ret \u003c 0)\n+\t\tgoto err_restore_page;\n+\t/* poll while still holding the lock; __phy_read takes no lock */\n+\tret = read_poll_timeout(__phy_read, val,\n+\t\t\t\t(val \u003c 0) || !(val \u0026 BMCR_RESET), 50000, 600000,\n+\t\t\t\ttrue, phydev, MII_BMCR);\n+\tif (val \u003c 0)\n+\t\tret = val;\n+\n+err_restore_page:\n+\treturn phy_restore_page(phydev, old_page, ret);\n+}\n+\n+/**\n+ * yt8824_extern_config_sds_init_paged() - config external phy8824 sds init\n+ * @phydev: target phy_device struct\n+ *\n+ *\n+ * Returns: 0 or negative errno code\n+ */\n+static int yt8824_extern_config_sds_init_paged(struct phy_device *phydev)\n+{\n+\tint old_page = YT8824_RSSR_UTP_SPACE;\n+\tint val_1, val_2, val_3, tmp;\n+\tint ctrl = 0;\n+\tint mask = 0;\n+\tint ret = -1;\n+\n+\told_page = phy_select_page(phydev, YT8824_RSSR_SERDES_SPACE);\n+\tif (old_page \u003c 0)\n+\t\tgoto err_restore_page;\n+\n+\t/* read efuse */\n+\tret = ytphy_read_top_ext(phydev, YT8824_SERDES_PLL_CTRL1_REG);\n+\tif (ret \u003c 0)\n+\t\tgoto err_restore_page;\n+\telse\n+\t\tval_1 = ret;\n+\n+\tret = ytphy_read_top_ext(phydev, YT8824_SERDES_PLL_CTRL2_REG);\n+\tif (ret \u003c 0)\n+\t\tgoto err_restore_page;\n+\telse\n+\t\tval_2 = ret;\n+\n+\tret = ytphy_read_top_ext(phydev, YT8824_SERDES_PLL_CTRL3_REG);\n+\tif (ret \u003c 0)\n+\t\tgoto err_restore_page;\n+\telse\n+\t\tval_3 = ret;\n+\n+\t/* Serdes optimization */\n+\tctrl = FIELD_PREP(YT8824_SERDES_REG_WR_PRT, 1);\n+\tmask = YT8824_SERDES_REG_WR_PRT;\n+\tret = ytphy_modify_ext(phydev, YT8824_WRITE_PROTECT_REG, mask, ctrl);\n+\tif (ret \u003c 0)\n+\t\tgoto err_restore_page;\n+\n+\tctrl = FIELD_PREP(YT8824_CSR_PCS_GLB_RST_BYPASS, 1);\n+\tctrl |= FIELD_PREP(YT8824_CSR_SG_MODE_RST_BYPASS, 1);\n+\tctrl |= FIELD_PREP(YT8824_CSR_US_GLB_RESET_N, 0);\n+\tctrl |= FIELD_PREP(YT8824_CSR_PCS_BEF_TRAINING_DONE_RST_BYPASS, 1);\n+\tmask = YT8824_CSR_PCS_GLB_RST_BYPASS | YT8824_CSR_SG_MODE_RST_BYPASS |\n+\t       YT8824_CSR_US_GLB_RESET_N |\n+\t       YT8824_CSR_PCS_BEF_TRAINING_DONE_RST_BYPASS;\n+\tret = ytphy_modify_ext(phydev, YT8824_CSR_CTRL_REG, mask, ctrl);\n+\tif (ret \u003c 0)\n+\t\tgoto err_restore_page;\n+\n+\tctrl = FIELD_PREP(YT8824_CSR_WATCH_DOG_ALL_BYPASS, 1);\n+\tmask = YT8824_CSR_WATCH_DOG_ALL_BYPASS;\n+\tret = ytphy_modify_ext(phydev, YT8824_CSR_PMA_CTRL_REG, mask, ctrl);\n+\tif (ret \u003c 0)\n+\t\tgoto err_restore_page;\n+\n+\t/* analog CDR */\n+\tctrl = FIELD_PREP(YT8824_CDR_MODE, 1);\n+\tmask = YT8824_CDR_MODE;\n+\tret = ytphy_modify_ext(phydev, YT8824_CDR_CTRL_REG, mask, ctrl);\n+\tif (ret \u003c 0)\n+\t\tgoto err_restore_page;\n+\n+\t/* optimized VCO */\n+\tctrl = FIELD_PREP(YT8824_CSR_PLL_VCO_SEL_VCO2_CURRENT, 0x9);\n+\tctrl |= FIELD_PREP(YT8824_CSR_PLL_VCO_ATEMP_R, 0x4);\n+\tmask = YT8824_CSR_PLL_VCO_SEL_VCO2_CURRENT | YT8824_CSR_PLL_VCO_ATEMP_R;\n+\tret = ytphy_modify_ext(phydev, YT8824_CSR_PLL_VCO_CTRL_REG, mask, ctrl);\n+\tif (ret \u003c 0)\n+\t\tgoto err_restore_page;\n+\n+\tctrl = FIELD_PREP(YT8824_CSR_PLL_VCO_SEL_VCO2_RM_R, 0x0);\n+\tmask = YT8824_CSR_PLL_VCO_SEL_VCO2_RM_R;\n+\tret = ytphy_modify_ext(phydev, YT8824_CSR_PLL_DIVLDO_CTRL_REG,\n+\t\t\t       mask, ctrl);\n+\tif (ret \u003c 0)\n+\t\tgoto err_restore_page;\n+\n+\t/* optimized PLL lock */\n+\tret = ytphy_read_ext(phydev, YT8824_DAC_TRIM_MAIN_CFG_REG);\n+\tif (ret \u003c 0)\n+\t\tgoto err_restore_page;\n+\n+\tret \u0026= ~(BIT(13) | BIT(12));\n+\ttmp = (val_1 \u0026 (BIT(7) | BIT(6))) \u003e\u003e 6;\n+\tret |= (tmp \u003c\u003c 12);\n+\tret = ytphy_write_ext(phydev, YT8824_DAC_TRIM_MAIN_CFG_REG, ret);\n+\tif (ret \u003c 0)\n+\t\tgoto err_restore_page;\n+\n+\tret = ytphy_read_ext(phydev, YT8824_PLL_VCO_CFG_REG);\n+\tif (ret \u003c 0)\n+\t\tgoto err_restore_page;\n+\n+\tret \u0026= ~(BIT(1) | BIT(0));\n+\ttmp = (val_1 \u0026 (BIT(5) | BIT(4))) \u003e\u003e 4;\n+\tret |= tmp;\n+\tret = ytphy_write_ext(phydev, YT8824_PLL_VCO_CFG_REG, ret);\n+\tif (ret \u003c 0)\n+\t\tgoto err_restore_page;\n+\n+\tret = ytphy_read_ext(phydev, YT8824_TX_MUX_CH3_CH2_REG);\n+\tif (ret \u003c 0)\n+\t\tgoto err_restore_page;\n+\n+\tret \u0026= ~(BIT(13) | BIT(12));\n+\ttmp = (val_3 \u0026 (BIT(1) | BIT(0)));\n+\tret |= (tmp \u003c\u003c 12);\n+\tret = ytphy_write_ext(phydev, YT8824_TX_MUX_CH3_CH2_REG, ret);\n+\tif (ret \u003c 0)\n+\t\tgoto err_restore_page;\n+\n+\tctrl = FIELD_PREP(YT8824_CSR_PLL_FBDIV_SYNC_SELB, 1);\n+\tmask = YT8824_CSR_PLL_FBDIV_SYNC_SELB;\n+\tret = ytphy_modify_ext(phydev, YT8824_CSR_PLL_FBDIV_REG, mask, ctrl);\n+\tif (ret \u003c 0)\n+\t\tgoto err_restore_page;\n+\n+\tctrl = FIELD_PREP(YT8824_CSR_PLL_SPARE, 0xf070);\n+\tmask = YT8824_CSR_PLL_SPARE;\n+\tret = ytphy_modify_ext(phydev, YT8824_CSR_PLL_SPARE_CTRL_REG,\n+\t\t\t       mask, ctrl);\n+\tif (ret \u003c 0)\n+\t\tgoto err_restore_page;\n+\n+\t/* cable length threshold */\n+\tctrl = FIELD_PREP(YT8824_VDAC_AMP_THR_LNG, 0x7F);\n+\tmask = YT8824_VDAC_AMP_THR_LNG;\n+\tret = ytphy_modify_ext(phydev, YT8824_CDR_MANUAL_REG, mask, ctrl);\n+\tif (ret \u003c 0)\n+\t\tgoto err_restore_page;\n+\n+\tctrl = FIELD_PREP(YT8824_VDAC_AMP_THR_MED, 0x7F);\n+\tctrl |= FIELD_PREP(YT8824_VDAC_AMP_THR_SHT, 0x7F);\n+\tmask = YT8824_VDAC_AMP_THR_MED | YT8824_VDAC_AMP_THR_SHT;\n+\tret = ytphy_modify_ext(phydev, YT8824_TRAINING_CTRL_REG, mask, ctrl);\n+\tif (ret \u003c 0)\n+\t\tgoto err_restore_page;\n+\n+\t/* Serdes training threshold */\n+\tctrl = FIELD_PREP(YT8824_EOD_DURATION_SEL, 0xF);\n+\tctrl |= FIELD_PREP(YT8824_EOD_VTH, 0x14);\n+\tmask = YT8824_EOD_DURATION_SEL | YT8824_EOD_VTH;\n+\tret = ytphy_modify_ext(phydev, YT8824_EOM_CTRL_REG, mask, ctrl);\n+\tif (ret \u003c 0)\n+\t\tgoto err_restore_page;\n+\n+\tctrl = FIELD_PREP(YT8824_CDR_OFFSET_ERR_WTH, 0x0A);\n+\tctrl |= FIELD_PREP(YT8824_PGA_GAIN_MAX, 0x4);\n+\tctrl |= FIELD_PREP(YT8824_PGA_GAIN_INIT, 0x4);\n+\tmask = YT8824_CDR_OFFSET_ERR_WTH | YT8824_PGA_GAIN_MAX |\n+\t       YT8824_PGA_GAIN_INIT;\n+\tret = ytphy_modify_ext(phydev, YT8824_PGA_GAIN_CTRL_REG, mask, ctrl);\n+\tif (ret \u003c 0)\n+\t\tgoto err_restore_page;\n+\n+\t/* digital eye diagram of SerDes */\n+\tctrl = FIELD_PREP(YT8824_EOD_ERR_CNT_THR, 0x0000);\n+\tmask = YT8824_EOD_ERR_CNT_THR;\n+\tret = ytphy_modify_ext(phydev, YT8824_EOD_CTRL_REG, mask, ctrl);\n+\tif (ret \u003c 0)\n+\t\tgoto err_restore_page;\n+\n+\t/* Serdes LDO */\n+\tret = ytphy_read_ext(phydev, YT8824_FFE_CTRL_REG);\n+\tif (ret \u003c 0)\n+\t\tgoto err_restore_page;\n+\n+\tret \u0026= ~(BIT(6) | BIT(5) | BIT(4));\n+\ttmp = (val_2 \u0026 (BIT(4) | BIT(3) | BIT(2))) \u003e\u003e 2;\n+\tret |= (tmp \u003c\u003c 4);\n+\tret = ytphy_write_ext(phydev, YT8824_FFE_CTRL_REG, ret);\n+\tif (ret \u003c 0)\n+\t\tgoto err_restore_page;\n+\n+\tret = ytphy_read_ext(phydev, YT8824_C1_COARSE_CFG_REG);\n+\tif (ret \u003c 0)\n+\t\tgoto err_restore_page;\n+\n+\tret \u0026= ~(BIT(10) | BIT(9) | BIT(8));\n+\ttmp = (val_2 \u0026 (BIT(7) | BIT(6) | BIT(5))) \u003e\u003e 5;\n+\tret |= (tmp \u003c\u003c 8);\n+\tret = ytphy_write_ext(phydev, YT8824_C1_COARSE_CFG_REG, ret);\n+\tif (ret \u003c 0)\n+\t\tgoto err_restore_page;\n+\n+\t/* optimized Serdes RX */\n+\tctrl = FIELD_PREP(YT8824_CSR_AFE_VCM_CFG, 0x5);\n+\tctrl |= FIELD_PREP(YT8824_CSR_AFE_MANUAL_CTRL_1P25G, 0);\n+\tctrl |= FIELD_PREP(YT8824_CSR_AFE_MANUAL_CTRL_3P125G, 0);\n+\tmask = YT8824_CSR_AFE_VCM_CFG | YT8824_CSR_AFE_MANUAL_CTRL_1P25G |\n+\t       YT8824_CSR_AFE_MANUAL_CTRL_3P125G;\n+\tret = ytphy_modify_ext(phydev, YT8824_CSR_AFE_CTRL_REG, mask, ctrl);\n+\tif (ret \u003c 0)\n+\t\tgoto err_restore_page;\n+\n+\tctrl = FIELD_PREP(YT8824_DFE_TAP_POLARITY, 1);\n+\tctrl |= FIELD_PREP(YT8824_DFE_IDAC_TUNE, 0x3);\n+\tmask = YT8824_DFE_TAP_POLARITY | YT8824_DFE_IDAC_TUNE;\n+\tret = ytphy_modify_ext(phydev, YT8824_DFE_CTRL_REG, mask, ctrl);\n+\tif (ret \u003c 0)\n+\t\tgoto err_restore_page;\n+\n+\tctrl = FIELD_PREP(YT8824_CSR_CDR_OFFSET_DATA, 0x7C);\n+\tmask = YT8824_CSR_CDR_OFFSET_DATA;\n+\tret = ytphy_modify_ext(phydev, YT8824_CSR_CDR_CTRL_REG, mask, ctrl);\n+\tif (ret \u003c 0)\n+\t\tgoto err_restore_page;\n+\n+\tctrl = FIELD_PREP(YT8824_DFE_VDAC_CODE_THR, 0x7F);\n+\tmask = YT8824_DFE_VDAC_CODE_THR;\n+\tret = ytphy_modify_ext(phydev, YT8824_DFE_VDAC_CODE_REG, mask, ctrl);\n+\tif (ret \u003c 0)\n+\t\tgoto err_restore_page;\n+\n+\tctrl = FIELD_PREP(YT8824_RX_SPARE_REG, 0xff08);\n+\tmask = YT8824_RX_SPARE_REG;\n+\tret = ytphy_modify_ext(phydev, YT8824_RX_SPARE_CTRL_REG, mask, ctrl);\n+\tif (ret \u003c 0)\n+\t\tgoto err_restore_page;\n+\n+\t/* optimized Serdes TX */\n+\tctrl = FIELD_PREP(YT8824_DFE_VDAC_TUNE, 0x1);\n+\tctrl |= FIELD_PREP(YT8824_DFE_VDAC_SEL, 0x0);\n+\tmask = YT8824_DFE_VDAC_TUNE | YT8824_DFE_VDAC_SEL;\n+\tret = ytphy_modify_ext(phydev, YT8824_DFE_VDAC_CTRL_REG, mask, ctrl);\n+\tif (ret \u003c 0)\n+\t\tgoto err_restore_page;\n+\n+\tctrl = FIELD_PREP(YT8824_CSR_TX_PRE_SEL, 0x6);\n+\tmask = YT8824_CSR_TX_PRE_SEL;\n+\tret = ytphy_modify_ext(phydev, YT8824_CSR_TX_PRE_REG, mask, ctrl);\n+\tif (ret \u003c 0)\n+\t\tgoto err_restore_page;\n+\n+\t/* Serdes manual config */\n+\tctrl = FIELD_PREP(YT8824_CSR_AFE_CTLE_BW, 0x0);\n+\tmask = YT8824_CSR_AFE_CTLE_BW;\n+\tret = ytphy_modify_ext(phydev, YT8824_CSR_AFE_CTRL1_REG, mask, ctrl);\n+\tif (ret \u003c 0)\n+\t\tgoto err_restore_page;\n+\n+\tctrl = FIELD_PREP(YT8824_CSR_AFE_PGA_BW, 0x7);\n+\tctrl |= FIELD_PREP(YT8824_CSR_AFE_BUF_BW, 0x7);\n+\tmask = YT8824_CSR_AFE_PGA_BW | YT8824_CSR_AFE_BUF_BW;\n+\tret = ytphy_modify_ext(phydev, YT8824_CSR_AFE_CTRL2_REG, mask, ctrl);\n+\tif (ret \u003c 0)\n+\t\tgoto err_restore_page;\n+\n+\tctrl = FIELD_PREP(YT8824_CSR_AFE_MANUAL_CTRL_10P3125G, 0x1);\n+\tmask = YT8824_CSR_AFE_MANUAL_CTRL_10P3125G;\n+\tret = ytphy_modify_ext(phydev, YT8824_CSR_AFE_CTRL_REG, mask, ctrl);\n+\tif (ret \u003c 0)\n+\t\tgoto err_restore_page;\n+\n+\t/* restart calibration */\n+\tctrl = FIELD_PREP(YT8824_CUR_TX_SEQ, 0x5);\n+\tctrl |= FIELD_PREP(YT8824_CUR_RX_SEQ, 0x6);\n+\tctrl |= FIELD_PREP(YT8824_CALIB_SEQ_FINISH, 1);\n+\tctrl |= FIELD_PREP(YT8824_CALIB_SEQ_SW_RST, 1);\n+\tmask = YT8824_CUR_TX_SEQ | YT8824_CUR_RX_SEQ |\n+\t       YT8824_CALIB_SEQ_FINISH | YT8824_CALIB_SEQ_SW_RST;\n+\tret = ytphy_modify_ext(phydev, YT8824_CSR_DCC_CAL_CTRL_REG, mask, ctrl);\n+\tif (ret \u003c 0)\n+\t\tgoto err_restore_page;\n+\n+\tctrl = FIELD_PREP(YT8824_VDAC_AMP_THR_MED, 0x7F);\n+\tctrl |= FIELD_PREP(YT8824_VDAC_AMP_THR_SHT, 0xFF);\n+\tmask = YT8824_VDAC_AMP_THR_MED | YT8824_VDAC_AMP_THR_SHT;\n+\tret = ytphy_modify_ext(phydev, YT8824_TRAINING_CTRL_REG, mask, ctrl);\n+\tif (ret \u003c 0)\n+\t\tgoto err_restore_page;\n+\n+\tctrl = FIELD_PREP(YT8824_VDAC_AMP_THR_MED, 0x7F);\n+\tctrl |= FIELD_PREP(YT8824_VDAC_AMP_THR_SHT, 0x7F);\n+\tmask = YT8824_VDAC_AMP_THR_MED | YT8824_VDAC_AMP_THR_SHT;\n+\tret = ytphy_modify_ext(phydev, YT8824_TRAINING_CTRL_REG, mask, ctrl);\n+\tif (ret \u003c 0)\n+\t\tgoto err_restore_page;\n+\n+\t/* restart to calibration */\n+\tret = ytphy_write_ext(phydev, YT8824_RESTART_CAL_CTRL_REG, 0x0040);\n+\tif (ret \u003c 0)\n+\t\tgoto err_restore_page;\n+\n+\tret = ytphy_write_ext(phydev, YT8824_RESTART_CAL_CTRL_REG, 0x0);\n+\tif (ret \u003c 0)\n+\t\tgoto err_restore_page;\n+\n+err_restore_page:\n+\treturn phy_restore_page(phydev, old_page, ret);\n+}\n+\n+/**\n+ * yt8824_config_init() - phy initializatioin\n+ * @phydev: a pointer to a \u0026struct phy_device\n+ *\n+ * Returns: 0 or negative errno code\n+ */\n+static int yt8824_config_init(struct phy_device *phydev)\n+{\n+\tstruct yt8824_shared_priv *priv = phy_package_get_priv(phydev);\n+\tint ret;\n+\n+\tmutex_lock(\u0026priv-\u003eshared_lock);\n+\tif (priv-\u003epackage_mode == PHY_INTERFACE_MODE_INTERNAL) {\n+\t\tret = yt8824_config_utp_init_paged(phydev);\n+\t\tif (ret \u003c 0)\n+\t\t\tgoto err;\n+\t} else {\n+\t\tif (!priv-\u003esds_initialized) {\n+\t\t\tret = yt8824_extern_config_sds_init_paged(phydev);\n+\t\t\tif (ret \u003c 0)\n+\t\t\t\tgoto err;\n+\t\t\tpriv-\u003esds_initialized = true;\n+\t\t}\n+\t\t/*\n+\t\t * Configuring the MII registers of the SDS,\n+\t\t * which are private to each channel.\n+\t\t */\n+\t\tret = yt8824_extern_sds_softreset(phydev);\n+\t\tif (ret \u003c 0)\n+\t\t\tgoto err;\n+\n+\t\tret = yt8824_config_utp_init_paged(phydev);\n \t\tif (ret \u003c 0)\n-\t\t\tgoto err_restore_page;\n+\t\t\tgoto err;\n \t}\n+\tmutex_unlock(\u0026priv-\u003eshared_lock);\n+\tret = yt8824_soft_reset(phydev);\n \n-err_restore_page:\n-\treturn phy_restore_page(phydev, old_page, ret);\n+\tphydev_dbg(phydev, \"%s done, phy addr: %d\\n\", __func__,\n+\t\t   phydev-\u003emdio.addr);\n+\treturn ret;\n+err:\n+\tmutex_unlock(\u0026priv-\u003eshared_lock);\n+\treturn ret;\n }\n \n static int yt8531_set_wol(struct phy_device *phydev,\n@@ -3104,6 +4565,450 @@ static int yt8821_resume(struct phy_device *phydev)\n \treturn yt8821_modify_utp_fiber_bmcr(phydev, BMCR_PDOWN, 0);\n }\n \n+/**\n+ * yt8824_get_features - read mmd register to get 2.5G capability\n+ * @phydev: target phy_device struct\n+ *\n+ * Returns: 0 or negative errno code\n+ */\n+static int yt8824_get_features(struct phy_device *phydev)\n+{\n+\tstruct yt8824_shared_priv *priv = phy_package_get_priv(phydev);\n+\tint ret;\n+\n+\tmutex_lock(\u0026priv-\u003eshared_lock);\n+\tret = phy8824_page_write_with_lock(phydev, YT8824_RSSR_UTP_SPACE);\n+\tif (ret \u003c 0)\n+\t\tgoto err;\n+\tret = yt8821_get_features(phydev);\n+\n+err:\n+\tmutex_unlock(\u0026priv-\u003eshared_lock);\n+\treturn ret;\n+}\n+\n+/**\n+ * yt8824_aneg_done()  - check negotiation state.\n+ * @phydev: a pointer to a \u0026struct phy_device\n+ *\n+ * Returns: auto-negotiation complete status or negative errno code\n+ */\n+static int yt8824_aneg_done(struct phy_device *phydev)\n+{\n+\tstruct yt8824_shared_priv *priv = phy_package_get_priv(phydev);\n+\tint auto_neg;\n+\tint ret;\n+\n+\tmutex_lock(\u0026priv-\u003eshared_lock);\n+\tret = phy8824_page_write_with_lock(phydev, YT8824_RSSR_UTP_SPACE);\n+\tif (ret \u003c 0)\n+\t\tgoto err;\n+\n+\tret = phy_read(phydev, MII_BMSR);\n+\tif (ret \u003c 0)\n+\t\tgoto err;\n+\tmutex_unlock(\u0026priv-\u003eshared_lock);\n+\tauto_neg = !!(ret \u0026 BMSR_ANEGCOMPLETE);\n+\n+\tphydev_dbg(phydev, \"%s, phy addr: %d, auto negotiation done: %d\\n\",\n+\t\t   __func__, phydev-\u003emdio.addr, auto_neg);\n+\treturn auto_neg;\n+err:\n+\tmutex_unlock(\u0026priv-\u003eshared_lock);\n+\treturn ret;\n+}\n+\n+/**\n+ * yt8824_read_status_paged() -  determines the speed and duplex of one page\n+ * @phydev: a pointer to a \u0026struct phy_device\n+ *\n+ * Returns: 0 or negative errno code\n+ */\n+static int yt8824_read_status_paged(struct phy_device *phydev)\n+{\n+\tint ret;\n+\tint val;\n+\n+\tret = phy8824_page_write_with_lock(phydev, YT8824_RSSR_UTP_SPACE);\n+\tif (ret \u003c 0)\n+\t\treturn ret;\n+\n+\tret = genphy_read_status(phydev);\n+\tif (ret \u003c 0)\n+\t\treturn ret;\n+\n+\tif (phydev-\u003eautoneg == AUTONEG_ENABLE \u0026\u0026 phydev-\u003eautoneg_complete) {\n+\t\tret = genphy_c45_read_lpa(phydev);\n+\t\tif (ret \u003c 0)\n+\t\t\treturn ret;\n+\t}\n+\n+\tif (!phydev-\u003elink) {\n+\t\tphydev-\u003espeed = SPEED_UNKNOWN;\n+\t\tphydev-\u003eduplex = DUPLEX_UNKNOWN;\n+\t\tif (phydev-\u003eautoneg == AUTONEG_ENABLE)\n+\t\t\tphy_resolve_aneg_pause(phydev);\n+\t\treturn 0;\n+\t}\n+\n+\tret = phy_read(phydev, YTPHY_SPECIFIC_STATUS_REG);\n+\tif (ret \u003c 0)\n+\t\treturn ret;\n+\n+\tval = ret;\n+\n+\tyt8821_adjust_status(phydev, val);\n+\n+\tif (phydev-\u003eautoneg == AUTONEG_ENABLE)\n+\t\tphy_resolve_aneg_pause(phydev);\n+\n+\treturn 0;\n+}\n+\n+/**\n+ * yt8824_read_status() -  determines the negotiated speed and duplex\n+ * @phydev: a pointer to a \u0026struct phy_device\n+ *\n+ * Returns: 0 or negative errno code\n+ */\n+static int yt8824_read_status(struct phy_device *phydev)\n+{\n+\tstruct yt8824_shared_priv *priv = phy_package_get_priv(phydev);\n+\tint ret;\n+\n+\tmutex_lock(\u0026priv-\u003eshared_lock);\n+\tret = yt8824_read_status_paged(phydev);\n+\tmutex_unlock(\u0026priv-\u003eshared_lock);\n+\n+\treturn ret;\n+}\n+\n+/**\n+ * yt8824_utp_power_on(): utp power on.\n+ * @phydev: a pointer to a \u0026struct phy_device\n+ *\n+ * Returns: 0 or negative errno code\n+ */\n+static int yt8824_utp_power_on(struct phy_device *phydev)\n+{\n+\tint ret = 0;\n+\n+\tret = phy8824_page_write_with_lock(phydev, YT8824_RSSR_UTP_SPACE);\n+\tif (ret \u003c 0)\n+\t\treturn ret;\n+\n+\treturn phy_modify(phydev, MII_BMCR, BMCR_PDOWN | BMCR_ISOLATE, 0x0);\n+}\n+\n+/**\n+ * yt8824_utp_power_down(): utp power down.\n+ * @phydev: a pointer to a \u0026struct phy_device\n+ *\n+ * Returns: 0 or negative errno code\n+ */\n+static int yt8824_utp_power_down(struct phy_device *phydev)\n+{\n+\tint ret;\n+\n+\tret = phy8824_page_write_with_lock(phydev, YT8824_RSSR_UTP_SPACE);\n+\tif (ret \u003c 0)\n+\t\treturn ret;\n+\n+\treturn phy_modify(phydev, MII_BMCR, BMCR_PDOWN, BMCR_PDOWN);\n+}\n+\n+/**\n+ * yt8824_power_on()  - set utp power on.\n+ * @phydev: a pointer to a \u0026struct phy_device\n+ *\n+ * NOTE: need WA like softreset\n+ *\n+ * Returns: 0 or negative errno code\n+ */\n+static int yt8824_power_on(struct phy_device *phydev)\n+{\n+\tstruct yt8824_shared_priv *priv = phy_package_get_priv(phydev);\n+\tint ret;\n+\tint r;\n+\n+\tif (priv-\u003epackage_mode == PHY_INTERFACE_MODE_INTERNAL) {\n+\t\tret = yt8824_utp_set_template_test_mode(phydev,\n+\t\t\t\t\t\t\tMDIO_PMA_10GBT_TESTMODE_1);\n+\t\tif (ret \u003c 0)\n+\t\t\tgoto retry;\n+\n+\t\tret = yt8824_utp_power_on(phydev);\n+\t\tif (ret \u003c 0)\n+\t\t\tgoto retry;\n+\n+\t\tret = yt8824_utp_set_template_test_mode(phydev,\n+\t\t\t\t\t\t\tMDIO_PMA_10GBT_TESTMODE_NORMAL);\n+\t\tif (ret \u003c 0)\n+\t\t\tgoto retry;\n+\t} else {\n+\t\tret = yt8824_utp_set_template_test_mode(phydev,\n+\t\t\t\t\t\t\tMDIO_PMA_10GBT_TESTMODE_1);\n+\t\tif (ret \u003c 0)\n+\t\t\tgoto retry;\n+\n+\t\tret = yt8824_sds_isolate_paged(phydev);\n+\t\tif (ret \u003c 0)\n+\t\t\tgoto retry;\n+\n+\t\tret = yt8824_utp_power_on(phydev);\n+\t\tif (ret \u003c 0)\n+\t\t\tgoto retry;\n+\n+\t\tret = yt8824_utp_set_template_test_mode(phydev,\n+\t\t\t\t\t\t\tMDIO_PMA_10GBT_TESTMODE_NORMAL);\n+\t\tif (ret \u003c 0)\n+\t\t\tgoto retry;\n+\n+\t\tret = yt8824_sds_isolate_and_softreset_paged(phydev);\n+\t\tif (ret \u003c 0)\n+\t\t\tgoto retry;\n+\t}\n+\treturn 0;\n+\n+retry:\n+\t/*\n+\t * If the PHY up operation succeeds but the subsequent operation\n+\t * fails, revert to the default state.\n+\t */\n+\tr = yt8824_utp_power_down(phydev);\n+\tif (ret \u003e= 0 \u0026\u0026 r \u003c 0)\n+\t\tret = r;\n+\tret = yt8824_restore_working_status(phydev, ret);\n+\treturn ret;\n+}\n+\n+/**\n+ * yt8824_resume() - resume the hardware\n+ * @phydev: a pointer to a \u0026struct phy_device\n+ *\n+ * Returns: 0 or negative errno code\n+ */\n+static int yt8824_resume(struct phy_device *phydev)\n+{\n+\tstruct yt8824_shared_priv *priv = phy_package_get_priv(phydev);\n+\tint ret;\n+\n+\tmutex_lock(\u0026priv-\u003eshared_lock);\n+\tret = yt8824_power_on(phydev);\n+\tmutex_unlock(\u0026priv-\u003eshared_lock);\n+\n+\treturn ret;\n+}\n+\n+/**\n+ * yt8824_power_down()  - set utp power down.\n+ * @phydev: a pointer to a \u0026struct phy_device\n+ *\n+ * NOTE: need WA like softreset\n+ *\n+ * Returns: 0 or negative errno code\n+ */\n+static int yt8824_power_down(struct phy_device *phydev)\n+{\n+\tstruct yt8824_shared_priv *priv = phy_package_get_priv(phydev);\n+\tint ret;\n+\tint r;\n+\n+\tif (priv-\u003epackage_mode == PHY_INTERFACE_MODE_INTERNAL) {\n+\t\tret = yt8824_utp_set_template_test_mode(phydev,\n+\t\t\t\t\t\t\tMDIO_PMA_10GBT_TESTMODE_1);\n+\t\tif (ret \u003c 0)\n+\t\t\tgoto retry;\n+\n+\t\tret = yt8824_utp_power_down(phydev);\n+\t\tif (ret \u003c 0)\n+\t\t\tgoto retry;\n+\n+\t\tret = yt8824_utp_set_template_test_mode(phydev,\n+\t\t\t\t\t\t\tMDIO_PMA_10GBT_TESTMODE_NORMAL);\n+\t\tif (ret \u003c 0)\n+\t\t\tgoto retry;\n+\t} else {\n+\t\tret = yt8824_utp_set_template_test_mode(phydev,\n+\t\t\t\t\t\t\tMDIO_PMA_10GBT_TESTMODE_1);\n+\t\tif (ret \u003c 0)\n+\t\t\tgoto retry;\n+\n+\t\tret = yt8824_sds_isolate_paged(phydev);\n+\t\tif (ret \u003c 0)\n+\t\t\tgoto retry;\n+\n+\t\tret = yt8824_utp_power_down(phydev);\n+\t\tif (ret \u003c 0)\n+\t\t\tgoto retry;\n+\n+\t\tret = yt8824_utp_set_template_test_mode(phydev,\n+\t\t\t\t\t\t\tMDIO_PMA_10GBT_TESTMODE_NORMAL);\n+\t\tif (ret \u003c 0)\n+\t\t\tgoto retry;\n+\n+\t\tret = yt8824_sds_isolate_and_softreset_paged(phydev);\n+\t\tif (ret \u003c 0)\n+\t\t\tgoto retry;\n+\t}\n+\treturn 0;\n+\n+retry:\n+\t/*\n+\t * If the PHY down operation succeeds but the subsequent operation\n+\t * fails, revert to the default state.\n+\t */\n+\tr = yt8824_utp_power_on(phydev);\n+\tif (ret \u003e= 0 \u0026\u0026 r \u003c 0)\n+\t\tret = r;\n+\tret = yt8824_restore_working_status(phydev, ret);\n+\treturn ret;\n+}\n+\n+/**\n+ * yt8824_suspend() - suspend the hardware\n+ * @phydev: a pointer to a \u0026struct phy_device\n+ *\n+ * Returns: 0 or negative errno code\n+ */\n+static int yt8824_suspend(struct phy_device *phydev)\n+{\n+\tstruct yt8824_shared_priv *priv = phy_package_get_priv(phydev);\n+\tint ret;\n+\n+\tmutex_lock(\u0026priv-\u003eshared_lock);\n+\tret = yt8824_power_down(phydev);\n+\tmutex_unlock(\u0026priv-\u003eshared_lock);\n+\n+\treturn ret;\n+}\n+\n+/**\n+ * yt8824_config_aneg() - config negotiation\n+ * @phydev: a pointer to a \u0026struct phy_device\n+ *\n+ * Returns: 0 or negative errno code\n+ */\n+static int yt8824_config_aneg(struct phy_device *phydev)\n+{\n+\tstruct yt8824_shared_priv *priv = phy_package_get_priv(phydev);\n+\tint phy_ctrl = 0;\n+\tint ret;\n+\n+\tmutex_lock(\u0026priv-\u003eshared_lock);\n+\tret = phy8824_page_write_with_lock(phydev, YT8824_RSSR_UTP_SPACE);\n+\tif (ret \u003c 0)\n+\t\tgoto err;\n+\n+\t/*\n+\t * Only advertise 2.5G when autoneg is enabled, or when 2.5G is\n+\t * explicitly forced.  When a different speed is forced, clear\n+\t * ADV2_5G so a 2.5G-capable link partner cannot negotiate 2.5G.\n+\t * __genphy_config_aneg() only rewrites the\n+\t * clause 22 registers on the forced-speed path, so it will not\n+\t * clear this bit.\n+\t */\n+\tif ((phydev-\u003eautoneg == AUTONEG_ENABLE ||\n+\t     phydev-\u003espeed == SPEED_2500) \u0026\u0026\n+\t    linkmode_test_bit(ETHTOOL_LINK_MODE_2500baseT_Full_BIT,\n+\t\t\t      phydev-\u003eadvertising))\n+\t\tphy_ctrl = MDIO_AN_10GBT_CTRL_ADV2_5G;\n+\n+\tret = phy_modify_mmd_changed(phydev, MDIO_MMD_AN, MDIO_AN_10GBT_CTRL,\n+\t\t\t\t     MDIO_AN_10GBT_CTRL_ADV2_5G, phy_ctrl);\n+\tif (ret \u003c 0)\n+\t\tgoto err;\n+\n+\tret = __genphy_config_aneg(phydev, ret);\n+\n+err:\n+\tmutex_unlock(\u0026priv-\u003eshared_lock);\n+\treturn ret;\n+}\n+\n+/**\n+ * phy_mode_check() - check if mode names the PHY interface.\n+ * @mode: PHY interface mode string\n+ * @interface: PHY interface mode to compare against\n+ *\n+ * Return: true if @mode matches @interface, false otherwise.\n+ */\n+static bool phy_mode_check(const char *mode, int interface)\n+{\n+\treturn !strcasecmp(mode, phy_modes(interface));\n+}\n+\n+/**\n+ * yt8824_phy_package_probe_once()  - init phy package for phy8824.\n+ * @phydev: a pointer to a \u0026struct phy_device\n+ *\n+ * Returns: 0 or negative errno code\n+ */\n+static int yt8824_phy_package_probe_once(struct phy_device *phydev)\n+{\n+\tstruct yt8824_shared_priv *priv = phy_package_get_priv(phydev);\n+\tstruct device_node *np = phy_package_get_node(phydev);\n+\tconst char *mode;\n+\n+\tif (!priv || !np) {\n+\t\tphydev_err(phydev, \"%s: missing shared priv or DT node\\n\",\n+\t\t\t   __func__);\n+\t\treturn -EINVAL;\n+\t}\n+\t/* Initialise shared lock for YT8824 */\n+\tmutex_init(\u0026priv-\u003eshared_lock);\n+\tpriv-\u003esds_initialized = false;\n+\tpriv-\u003epackage_mode = PHY_INTERFACE_MODE_INTERNAL;\n+\tif (!of_property_read_string(np, \"motorcomm,package-mode\",\n+\t\t\t\t     \u0026mode)) {\n+\t\tif (phy_mode_check(mode, PHY_INTERFACE_MODE_INTERNAL)) {\n+\t\t\tpriv-\u003epackage_mode = PHY_INTERFACE_MODE_INTERNAL;\n+\t\t} else if (phy_mode_check(mode,\n+\t\t\t\t\t  PHY_INTERFACE_MODE_10G_QXGMII)) {\n+\t\t\tpriv-\u003epackage_mode = PHY_INTERFACE_MODE_10G_QXGMII;\n+\t\t} else {\n+\t\t\tphydev_err(phydev, \"unsupported package-mode %s\\n\",\n+\t\t\t\t   mode);\n+\t\t\treturn -EINVAL;\n+\t\t}\n+\t} else {\n+\t\tphydev_err(phydev, \"missing package-mode in PHY package node.\\n\");\n+\t\treturn -EINVAL;\n+\t}\n+\n+\treturn 0;\n+}\n+\n+/**\n+ * yt8824_probe() - phy8824 probe.\n+ * @phydev: a pointer to a \u0026struct phy_device\n+ *\n+ * Returns: 0 or negative errno code\n+ */\n+static int yt8824_probe(struct phy_device *phydev)\n+{\n+\tstruct device *dev = \u0026phydev-\u003emdio.dev;\n+\tstruct yt8824_shared_priv *shared_priv;\n+\tint ret;\n+\n+\tret = devm_of_phy_package_join(dev, phydev, sizeof(*shared_priv));\n+\tif (ret)\n+\t\treturn ret;\n+\n+\t/* Ensure other PHY probes wait for shared mutex initialization. */\n+\tphy_package_lock(phydev);\n+\tif (phy_package_probe_once(phydev)) {\n+\t\tret = yt8824_phy_package_probe_once(phydev);\n+\t\tif (ret) {\n+\t\t\tphy_package_unlock(phydev);\n+\t\t\treturn ret;\n+\t\t}\n+\t}\n+\tphy_package_unlock(phydev);\n+\n+\treturn 0;\n+}\n+\n static struct phy_driver motorcomm_phy_drvs[] = {\n \t{\n \t\tPHY_ID_MATCH_EXACT(PHY_ID_YT8511),\n@@ -3190,13 +5095,29 @@ static struct phy_driver motorcomm_phy_drvs[] = {\n \t\t.suspend\t\t= yt8821_suspend,\n \t\t.resume\t\t\t= yt8821_resume,\n \t},\n+\t{\n+\t\tPHY_ID_MATCH_EXACT(PHY_ID_YT8824),\n+\t\t.name = \"YT8824 Quad Ports 2.5Gbps Ethernet\",\n+\t\t.get_features = yt8824_get_features,\n+\t\t.read_page = yt8824_read_page,\n+\t\t.write_page = yt8824_write_page,\n+\t\t.probe = yt8824_probe,\n+\t\t.config_aneg = yt8824_config_aneg,\n+\t\t.aneg_done = yt8824_aneg_done,\n+\t\t.config_init = yt8824_config_init,\n+\t\t.read_status = yt8824_read_status,\n+\t\t.soft_reset = yt8824_soft_reset,\n+\t\t.suspend = yt8824_suspend,\n+\t\t.resume = yt8824_resume,\n+\t},\n };\n \n module_phy_driver(motorcomm_phy_drvs);\n \n-MODULE_DESCRIPTION(\"Motorcomm 8511/8521/8531/8531S/8821 PHY driver\");\n+MODULE_DESCRIPTION(\"Motorcomm 8511/8521/8531/8531S/8821/8824 PHY driver\");\n MODULE_AUTHOR(\"Peter Geis\");\n MODULE_AUTHOR(\"Frank\");\n+MODULE_AUTHOR(\"Kyle\");\n MODULE_LICENSE(\"GPL\");\n \n static const struct mdio_device_id __maybe_unused motorcomm_tbl[] = {\n@@ -3206,6 +5127,7 @@ static const struct mdio_device_id __maybe_unused motorcomm_tbl[] = {\n \t{ PHY_ID_MATCH_EXACT(PHY_ID_YT8531) },\n \t{ PHY_ID_MATCH_EXACT(PHY_ID_YT8531S) },\n \t{ PHY_ID_MATCH_EXACT(PHY_ID_YT8821) },\n+\t{ PHY_ID_MATCH_EXACT(PHY_ID_YT8824) },\n \t{ /* sentinel */ }\n };\n \ndiff --git a/drivers/net/phy/phy-c45.c b/drivers/net/phy/phy-c45.c\nindex 870920311f9a0..c5f5753f7194b 100644\n--- a/drivers/net/phy/phy-c45.c\n+++ b/drivers/net/phy/phy-c45.c\n@@ -1408,6 +1408,29 @@ int genphy_c45_fast_retrain(struct phy_device *phydev, bool enable)\n }\n EXPORT_SYMBOL_GPL(genphy_c45_fast_retrain);\n \n+/**\n+ * genphy_c45_template_testmode - configure template testmode registers\n+ * @phydev: target phy_device struct\n+ * @test_mode: testmode includes Normal to Test mode 7\n+ *\n+ * Description: Set template testmode include Normal to Test mode 7\n+ *\n+ * Return: 0 on success, or a negative error code on failure (e.g. register\n+ * read/write error).\n+ */\n+int genphy_c45_template_testmode(struct phy_device *phydev, u16 test_mode)\n+{\n+\tu16 ctrl;\n+\n+\tif (test_mode \u003e MDIO_PMA_10GBT_TESTMODE_7)\n+\t\treturn -EOPNOTSUPP;\n+\n+\tctrl = FIELD_PREP(MDIO_PMA_10GBT_TESTMODE_MASK, test_mode);\n+\treturn phy_modify_mmd(phydev, MDIO_MMD_PMAPMD, MDIO_PMA_10GBT_TESTMODE,\n+\t\t\t      MDIO_PMA_10GBT_TESTMODE_MASK, ctrl);\n+}\n+EXPORT_SYMBOL_GPL(genphy_c45_template_testmode);\n+\n /**\n  * genphy_c45_plca_get_cfg - get PLCA configuration from standard registers\n  * @phydev: target phy_device struct\ndiff --git a/include/linux/phy.h b/include/linux/phy.h\nindex 7c5098a0dd6cd..b9dee2655e6ba 100644\n--- a/include/linux/phy.h\n+++ b/include/linux/phy.h\n@@ -2357,6 +2357,7 @@ int genphy_c45_loopback(struct phy_device *phydev, bool enable, int speed);\n int genphy_c45_pma_resume(struct phy_device *phydev);\n int genphy_c45_pma_suspend(struct phy_device *phydev);\n int genphy_c45_fast_retrain(struct phy_device *phydev, bool enable);\n+int genphy_c45_template_testmode(struct phy_device *phydev, u16 test_mode);\n int genphy_c45_plca_get_cfg(struct phy_device *phydev,\n \t\t\t    struct phy_plca_cfg *plca_cfg);\n int genphy_c45_plca_set_cfg(struct phy_device *phydev,\ndiff --git a/include/uapi/linux/mdio.h b/include/uapi/linux/mdio.h\nindex 06f4bc3c20c71..353ca13c64fca 100644\n--- a/include/uapi/linux/mdio.h\n+++ b/include/uapi/linux/mdio.h\n@@ -63,6 +63,7 @@\n /* Media-dependent registers. */\n #define MDIO_PMA_10GBT_SWAPPOL\t130\t/* 10GBASE-T pair swap \u0026 polarity */\n #define MDIO_PMA_10GBT_TXPWR\t131\t/* 10GBASE-T TX power control */\n+#define MDIO_PMA_10GBT_TESTMODE 132 /* Test mode control */\n #define MDIO_PMA_10GBT_SNR\t133\t/* 10GBASE-T SNR margin, lane A.\n \t\t\t\t\t * Lanes B-D are numbered 134-136. */\n #define MDIO_PMA_10GBR_FSRT_CSR\t147\t/* 10GBASE-R fast retrain status and control */\n@@ -320,6 +321,17 @@\n /* PMA 10GBASE-R Fast Retrain status and control register. */\n #define MDIO_PMA_10GBR_FSRT_ENABLE\t0x0001\t/* Fast retrain enable */\n \n+/* PMA 10GBASE-T Template Test Mode Register*/\n+#define MDIO_PMA_10GBT_TESTMODE_MASK GENMASK(15, 13) /* Template test mode */\n+#define MDIO_PMA_10GBT_TESTMODE_NORMAL 0x0 /* Template Normal */\n+#define MDIO_PMA_10GBT_TESTMODE_1 0x1 /* Template TestMode1 */\n+#define MDIO_PMA_10GBT_TESTMODE_2 0x2 /* Template TestMode2 */\n+#define MDIO_PMA_10GBT_TESTMODE_3 0x3 /* Template TestMode3 */\n+#define MDIO_PMA_10GBT_TESTMODE_4 0x4 /* Template TestMode4 */\n+#define MDIO_PMA_10GBT_TESTMODE_5 0x5 /* Template TestMode5 */\n+#define MDIO_PMA_10GBT_TESTMODE_6 0x6 /* Template TestMode6 */\n+#define MDIO_PMA_10GBT_TESTMODE_7 0x7 /* Template TestMode7 */\n+\n /* PCS 10GBASE-R/-T status register 1. */\n #define MDIO_PCS_10GBRT_STAT1_BLKLK\t0x0001\t/* Block lock attained */\n \n"
}

2/1 2026/10/15 18:34 agent patch-evaluator
2m Model:
core

Args:
null

Results:
{
  "EnableConfigs": null,
  "FocusSymbols": [],
  "Reasoning": "The patch series adds support for the Motorcomm YT8824 Ethernet PHY (a 4-port 2.5G physical PHY package configured via Device Tree) and introduces a generic C45 helper (genphy_c45_template_testmode) exclusively called by this driver. Physical Ethernet PHY chips such as the Motorcomm YT8824 are hardware ASICs requiring physical MDIO buses and Device Tree bindings not emulated or present in standard QEMU/GCE amd64 virtualization environments. Therefore, the modified code is structurally unreachable for 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 92e6c4dfb3f2a0093be48bfd0c0031e6c28d0cb4
Author: syz-cluster <triage@syzkaller.com>
Date:   Thu Oct 15 18:34:13 2026 +0000

    syz-cluster: applied patch under review

diff --git a/Documentation/devicetree/bindings/net/motorcomm,yt8824.yaml b/Documentation/devicetree/bindings/net/motorcomm,yt8824.yaml
new file mode 100644
index 0000000000000..4c67f8afcf27a
--- /dev/null
+++ b/Documentation/devicetree/bindings/net/motorcomm,yt8824.yaml
@@ -0,0 +1,78 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/net/motorcomm,yt8824.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: MotorComm YT8824 Ethernet PHY
+
+maintainers:
+  - Kyle Switch <kyle.switch@motor-comm.com>
+
+description:
+  Motorcomm YT8824 Ethernet PHY is a PHY package of 4 PHYs.
+
+$ref: ethernet-phy-package.yaml#
+
+properties:
+  compatible:
+    enum:
+      - motorcomm,yt8824-package
+
+  motorcomm,package-mode:
+    description: |
+      PHY package can be configured in 2 modes:
+      - internal: YT8824 is embedded in the switch, using
+        an internal interface to the MAC.
+      - 10g-qxgmii: YT8824 is a standalone external PHY,
+        connected via 10G QXGMII.
+    $ref: /schemas/types.yaml#/definitions/string
+    enum: [ internal, 10g-qxgmii ]
+
+  reg:
+    description:
+      The absolute MDIO address of the YT8824 shared top extend
+      register block.
+      For internal mode, this is fixed at 9;
+      For external mode, it is the base MDIO address of the four
+      member PHYs plus 4, where base is typically 0x0.
+      Note that this is NOT the reg of the first member PHY.
+
+required:
+  - compatible
+  - motorcomm,package-mode
+  - reg
+
+unevaluatedProperties: false
+
+examples:
+  - |
+    mdio {
+        #address-cells = <1>;
+        #size-cells = <0>;
+
+        ethernet-phy-package@9 {
+            #address-cells = <1>;
+            #size-cells = <0>;
+            compatible = "motorcomm,yt8824-package";
+            reg = <9>;
+
+            motorcomm,package-mode = "internal";
+
+            ethernet-phy@4 {
+                reg = <4>;
+            };
+
+            ethernet-phy@5 {
+                reg = <5>;
+            };
+
+            ethernet-phy@6 {
+                reg = <6>;
+            };
+
+            ethernet-phy@7 {
+                reg = <7>;
+            };
+        };
+    };
diff --git a/MAINTAINERS b/MAINTAINERS
index 509b35b5a0e7a..572f6b26ae6d9 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -18427,8 +18427,10 @@ F:	drivers/net/ethernet/stmicro/stmmac/dwmac-motorcomm.c
 
 MOTORCOMM PHY DRIVER
 M:	Frank <Frank.Sae@motor-comm.com>
+M:	Kyle Switch <kyle.switch@motor-comm.com>
 L:	netdev@vger.kernel.org
 S:	Maintained
+F:	Documentation/devicetree/bindings/net/motorcomm,yt8824.yaml
 F:	Documentation/devicetree/bindings/net/motorcomm,yt8xxx.yaml
 F:	drivers/net/phy/motorcomm.c
 
diff --git a/drivers/net/phy/Kconfig b/drivers/net/phy/Kconfig
index d3835597e3795..996d75afed446 100644
--- a/drivers/net/phy/Kconfig
+++ b/drivers/net/phy/Kconfig
@@ -361,9 +361,10 @@ config MICROSEMI_PHY
 
 config MOTORCOMM_PHY
 	tristate "Motorcomm PHYs"
+	select PHY_PACKAGE
 	help
 	  Enables support for Motorcomm network PHYs.
-	  Currently supports YT85xx Gigabit Ethernet PHYs.
+	  Currently supports YT85xx Gigabit Ethernet PHYs and YT8824 4 * 2.5G PHY.
 
 config NATIONAL_PHY
 	tristate "National Semiconductor PHYs"
diff --git a/drivers/net/phy/motorcomm.c b/drivers/net/phy/motorcomm.c
index 90a4f86f2758b..47f2e19f233db 100644
--- a/drivers/net/phy/motorcomm.c
+++ b/drivers/net/phy/motorcomm.c
@@ -1,24 +1,31 @@
 // SPDX-License-Identifier: GPL-2.0+
 /*
- * Motorcomm 8511/8521/8522/8531/8531S/8821 PHY driver.
+ * Motorcomm 8511/8521/8522/8531/8531S/8821/8824 PHY driver.
  *
  * Author: Peter Geis <pgwipeout@gmail.com>
  * Author: Frank <Frank.Sae@motor-comm.com>
+ * Author: Kyle <kyle.switch@motor-comm.com>
  */
 
 #include <linux/clk.h>
 #include <linux/etherdevice.h>
 #include <linux/kernel.h>
+#include <linux/mdio.h>
 #include <linux/module.h>
+#include <linux/of.h>
+#include <linux/of_net.h>
 #include <linux/phy.h>
 #include <linux/property.h>
 
+#include "phylib.h"
+
 #define PHY_ID_YT8511		0x0000010a
 #define PHY_ID_YT8521		0x0000011a
 #define PHY_ID_YT8522		0x4f51e928
 #define PHY_ID_YT8531		0x4f51e91b
 #define PHY_ID_YT8531S		0x4f51e91a
 #define PHY_ID_YT8821		0x4f51ea19
+#define PHY_ID_YT8824		0x4f51e8b8
 /* YT8521/YT8531S/YT8821 Register Overview
  *	UTP Register space	|	FIBER Register space
  *  ------------------------------------------------------------
@@ -30,6 +37,18 @@
  *  ------------------------------------------------------------
  */
 
+/* YT8824 Register Overview
+ * UTP Register space	| SERDES Register space
+ *  ------------------------------------------------------------
+ * | UTP MII		| SERDES MII		|
+ * | UTP MMD		|			|
+ * | UTP Extended	| SERDES Extended	|
+ * | UTP Top Extended	| SERDES Top Extended	|
+ *  ------------------------------------------------------------
+ * |   Common Top Extended			|
+ *  ------------------------------------------------------------
+ */
+
 /* 0x10 ~ 0x15 , 0x1E and 0x1F are common MII registers of yt phy */
 
 /* Specific Function Control Register */
@@ -381,6 +400,226 @@
 #define YT8821_CHIP_MODE_AUTO_BX2500_SGMII	0
 #define YT8821_CHIP_MODE_FORCE_BX2500		1
 
+#define YT8824_RSSR_SPACE_MASK			BIT(0)
+#define YT8824_RSSR_SERDES_SPACE		(0x1)
+#define YT8824_RSSR_UTP_SPACE			(0x0)
+#define YT8824_SDS_CFG_MIN_PRE_MASK		GENMASK(3, 0)
+#define YT8824_SDS_EN_FILL_PRE			BIT(13)
+#define YT8824_SDS_TX_PRE_PADDING		(0x7)
+
+/* PHY8824 UTP init registers */
+#define YT8824_WRITE_PROTECT_CAL_REG		0x1
+#define YT8824_WRITE_PROTECT			BIT(0)
+#define YT8824_PLL_VCO_ATEMP_REG		0xa20e
+#define YT8824_PLL_VCO_SEL_CURRENT		GENMASK(7, 4)
+#define YT8824_PLL_VCO_SEL_CURRENT_B		0xb
+#define YT8824_PLL_PFD_CTRL_REG			0xa20a
+#define YT8824_PLL_VCO_ICOSTANT			GENMASK(9, 4)
+#define YT8824_PLL_VCO_ATEMP_1_REG		0xa20c
+#define YT8824_PLL_VCO_IPTAT			GENMASK(5, 0)
+#define YT8824_PLL_DAC_0_REG			0xa2b6
+#define YT8824_PLL_DAC_RST			BIT(10)
+#define YT8824_IF_CTRL_REG			0xa003
+#define YT8824_U0_U1_ENABLE_ODD_PREAMBLE	GENMASK(1, 0)
+#define YT8824_IDLE_CTRL_REG			0x3d0
+#define YT8824_IDLE_DETECT			BIT(9)
+#define YT8824_TRACE_GAIN_THR_REG		0x372
+#define YT8824_TRACE_LNG_GAIN_THR_2500		GENMASK(14, 8)
+#define YT8824_TRACE_MED_GAIN_THR_2500		GENMASK(6, 0)
+#define YT8824_PRM_LONG_REG			0x37C
+#define YT8824_PRM_LARGE_SLAVE_2500		GENMASK(10, 0)
+#define YT8824_PRM_SMALL_REG			0x388
+#define YT8824_PRM_SMALL_LNG_2500		GENMASK(10, 0)
+#define YT8824_FAST_RETRAIN_REG			0x359
+#define YT8824_LINK_FAIL_SIG			GENMASK(13, 8)
+#define YT8824_EN_GATE_CTRL_REG			0xc
+#define YT8824_EN_GATE_GMII_CLK			BIT(0)
+#define YT8824_DAC_CFG_REG			0xa2fa
+#define YT8824_POWER_SAVE			GENMASK(15, 0)
+#define YT8824_DAC_BIAS_CFG_REG			0x4e2
+#define YT8824_DAC_BIAS_CFG_2500		GENMASK(9, 5)
+#define YT8824_DAC_IMID_CFG_REG			0x47e
+#define YT8824_DAC_IMID_CH2			GENMASK(6, 0)
+#define YT8824_DAC_IMID_CH3			GENMASK(14, 8)
+#define YT8824_DAC_IMID_CFG1_REG		0x47f
+#define YT8824_DAC_IMID_CH0			GENMASK(6, 0)
+#define YT8824_DAC_IMID_CH1			GENMASK(14, 8)
+#define YT8824_DAC_IMSB_CFG_REG			0x480
+#define YT8824_DAC_IMSB_CH2			GENMASK(6, 0)
+#define YT8824_DAC_IMSB_CH3			GENMASK(14, 8)
+#define YT8824_DAC_IMSB_CFG1_REG		0x481
+#define YT8824_DAC_IMSB_CH0			GENMASK(6, 0)
+#define YT8824_DAC_IMSB_CH1			GENMASK(14, 8)
+#define YT8824_TRACE_LNG_GAIN_REG		0x336
+#define YT8824_TRACE_LNG_GAIN_THR		GENMASK(14, 8)
+#define YT8824_TRACE_MED_GAIN_REG		0x340
+#define YT8824_TRACE_MED_GAIN_THR		GENMASK(6, 0)
+#define YT8824_DAC_IMID_CH2_CH3_CFG_ORG_REG	0x46e
+#define YT8824_DAC_IMID_CH3_ORG			GENMASK(14, 8)
+#define YT8824_DAC_IMID_CH2_ORG			GENMASK(6, 0)
+#define YT8824_DAC_IMID_CH0_CH1_CFG_ORG_REG	0x46f
+#define YT8824_DAC_IMID_CH1_ORG			GENMASK(14, 8)
+#define YT8824_DAC_IMID_CH0_ORG			GENMASK(6, 0)
+#define YT8824_DAC_IMSB_CH2_CH3_CFG_ORG_REG	0x470
+#define YT8824_DAC_IMSB_CH3_ORG			GENMASK(14, 8)
+#define YT8824_DAC_IMSB_CH2_ORG			GENMASK(6, 0)
+#define YT8824_DAC_IMSB_CH0_CH1_CFG_ORG_REG	0x471
+#define YT8824_DAC_IMSB_CH1_ORG			GENMASK(14, 8)
+#define YT8824_DAC_IMSB_CH0_ORG			GENMASK(6, 0)
+#define YT8824_TRACE_LNG_GAIN_100_REG		0x030b
+#define YT8824_TRACE_LNG_GAIN_THR_100		GENMASK(14, 8)
+#define YT8824_TRACE_MED_GAIN_THR_100		GENMASK(6, 0)
+#define YT8824_CABLE_VSHT_REG			0x071f
+#define YT8824_CABLE_VSHT_THR_S			GENMASK(6, 0)
+#define YT8824_DAC_LPFIL_CH2_CH3_ADJ_REG	0x046b
+#define YT8824_DAC_LPFIL_ADJ_CH3_10		GENMASK(12, 8)
+#define YT8824_DAC_LPFIL_ADJ_CH2_10		GENMASK(4, 0)
+#define YT8824_DAC_LPFIL_CH0_CH1_ADJ_REG	0x046c
+#define YT8824_DAC_LPFIL_ADJ_CH1_10		GENMASK(12, 8)
+#define YT8824_DAC_LPFIL_ADJ_CH0_10		GENMASK(4, 0)
+#define YT8824_DAC_IMID_CFG_CH2_CH3_10_ORG	0x0466
+#define YT8824_DAC_IMID_CFG_CH3_10_ORG		GENMASK(14, 8)
+#define YT8824_DAC_IMID_CFG_CH2_10_ORG		GENMASK(6, 0)
+#define YT8824_DAC_IMID_CFG_CH0_CH1_10_ORG	0x0467
+#define YT8824_DAC_IMID_CFG_CH1_10_ORG		GENMASK(14, 8)
+#define YT8824_DAC_IMID_CFG_CH0_10_ORG		GENMASK(6, 0)
+#define YT8824_DAC_IMSB_CFG_CH2_CH3_10_ORG	0x0468
+#define YT8824_DAC_IMSB_CFG_CH3_10_ORG		GENMASK(14, 8)
+#define YT8824_DAC_IMSB_CFG_CH2_10_ORG		GENMASK(6, 0)
+#define YT8824_DAC_IMSB_CFG_CH0_CH1_10_ORG	0x0469
+#define YT8824_DAC_IMSB_CFG_CH1_10_ORG		GENMASK(14, 8)
+#define YT8824_DAC_IMSB_CFG_CH0_10_ORG		GENMASK(6, 0)
+#define YT8824_FFE_REG				0x034a
+#define YT8824_WAIT_TO_1000			GENMASK(15, 8)
+#define YT8824_FFE_SUM_THRES			GENMASK(2, 0)
+#define YT8824_EN_GATE_REG			0x00f8
+#define YT8824_EN_GATE_PHYDBG			BIT(10)
+#define YT8824_EN_GATE_BT1000			BIT(9)
+#define YT8824_CNT_REG				0x0059
+#define YT8824_CNT_ERR_AUTO			BIT(14)
+#define YT8824_PRM_LARGE_MASTER_REG		0x032c
+#define YT8824_PRM_LARGE_MASTER_1000		GENMASK(10, 0)
+#define YT8824_PRM_LARGE_SLAVE_REG		0x032d
+#define YT8824_PRM_LARGE_SLAVE_1000		GENMASK(10, 0)
+#define YT8824_SIG_GONE_REG			0x032e
+#define YT8824_SIG_GONE_THR_1000		GENMASK(7, 0)
+#define YT8824_EC_NX_TRAIN_COARSE_REG		0x0322
+#define YT8824_EC_NX_TRAIN_COARSE_TO_1000	GENMASK(7, 0)
+#define YT8824_VGA_IN_LPF2_CAP_REG		0x04d3
+#define YT8824_VGA_IN_LPF2_CAP_OTHER		GENMASK(7, 4)
+#define YT8824_VGA_IN_LPF1_CAP_REG		0x04d2
+#define YT8824_VGA_IN_LPF1_CAP_OTHER		GENMASK(7, 4)
+#define YT8824_LDPC_LFER_FAIL_REG		0x00c8
+#define YT8824_LDPC_FAIL_THR			GENMASK(15, 8)
+#define YT8824_LFER_FAIL_THR			GENMASK(7, 0)
+#define YT8824_FR_REQ_REG			0x00be
+#define YT8824_FR_REQ_THR			GENMASK(4, 0)
+#define YT8824_GN_MU_COARSE_REG			0x037a
+#define YT8824_PRM_SMALL_SHT_2500		GENMASK(10, 0)
+#define YT8824_DAC_AMP_ADJ_REG			0x0482
+#define YT8824_DAC_AMP_ADJ_CH3_PBO0_2500	GENMASK(15, 12)
+#define YT8824_DAC_AMP_ADJ_CH2_PBO0_2500	GENMASK(11, 8)
+#define YT8824_DAC_AMP_ADJ_CH1_PBO0_2500	GENMASK(7, 4)
+#define YT8824_DAC_AMP_ADJ_CH0_PBO0_2500	GENMASK(3, 0)
+#define YT8824_P0_DAC_BIAS_CAS_CH3_CH2_REG	0xa2d5
+#define YT8824_P0_DAC_BIAS_CAS_CFG_CH3		GENMASK(12, 8)
+#define YT8824_P0_DAC_BIAS_CAS_CFG_CH2		GENMASK(4, 0)
+#define YT8824_P0_DAC_BIAS_CAS_CH1_CH0_REG	0xa2d6
+#define YT8824_P0_DAC_BIAS_CAS_CFG_CH1		GENMASK(12, 8)
+#define YT8824_P0_DAC_BIAS_CAS_CFG_CH0		GENMASK(4, 0)
+#define YT8824_P1_DAC_BIAS_CAS_CH3_CH2_REG	0xa2d7
+#define YT8824_P1_DAC_BIAS_CAS_CFG_CH3		GENMASK(12, 8)
+#define YT8824_P1_DAC_BIAS_CAS_CFG_CH2		GENMASK(4, 0)
+#define YT8824_P1_DAC_BIAS_CAS_CH1_CH0_REG	0xa2d8
+#define YT8824_P1_DAC_BIAS_CAS_CFG_CH1		GENMASK(12, 8)
+#define YT8824_P1_DAC_BIAS_CAS_CFG_CH0		GENMASK(4, 0)
+#define YT8824_P01_PLL_EN_REG			0xa218
+#define YT8824_CSR_EFUSE_BYPASS_ANALOG_SECOND_RESET	BIT(6)
+#define YT8824_CSR_EFUSE_BYPASS_PLL_TXRX_RESET		BIT(5)
+#define YT8824_U0_CSR_RESET_REG			0xa01d
+#define YT8824_U0_CSR_RESETB_TX_CH0		BIT(3)
+#define YT8824_U0_CSR_RESETB_TX_CH1		BIT(2)
+#define YT8824_U0_CSR_RESETB_TX_CH2		BIT(1)
+#define YT8824_U0_CSR_RESETB_TX_CH3		BIT(0)
+#define YT8824_U1_CSR_RESET_REG			0xa01e
+#define YT8824_U1_CSR_RESETB_TX_CH0		BIT(3)
+#define YT8824_U1_CSR_RESETB_TX_CH1		BIT(2)
+#define YT8824_U1_CSR_RESETB_TX_CH2		BIT(1)
+#define YT8824_U1_CSR_RESETB_TX_CH3		BIT(0)
+/* External PHY8824 serdes init registers */
+#define YT8824_SERDES_PLL_CTRL1_REG		0xa13e
+#define YT8824_SERDES_PLL_CTRL2_REG		0xa13f
+#define YT8824_SERDES_PLL_CTRL3_REG		0xa140
+#define YT8824_WRITE_PROTECT_REG		0x4be
+#define YT8824_SERDES_REG_WR_PRT		BIT(2)
+#define YT8824_CSR_CTRL_REG			0x49f
+#define YT8824_CSR_PCS_GLB_RST_BYPASS		BIT(10)
+#define YT8824_CSR_SG_MODE_RST_BYPASS		BIT(9)
+#define YT8824_CSR_US_GLB_RESET_N		BIT(7)
+#define YT8824_CSR_PCS_BEF_TRAINING_DONE_RST_BYPASS	BIT(2)
+#define YT8824_CSR_PMA_CTRL_REG			0x4a9
+#define YT8824_CSR_WATCH_DOG_ALL_BYPASS		BIT(7)
+#define YT8824_CDR_CTRL_REG			0x406
+#define YT8824_CDR_MODE				BIT(11)
+#define YT8824_CSR_PLL_VCO_CTRL_REG		0x438
+#define YT8824_CSR_PLL_VCO_SEL_VCO2_CURRENT	GENMASK(15, 12)
+#define YT8824_CSR_PLL_VCO_ATEMP_R		GENMASK(2, 0)
+#define YT8824_CSR_PLL_DIVLDO_CTRL_REG		0x439
+#define YT8824_CSR_PLL_VCO_SEL_VCO2_RM_R	GENMASK(1, 0)
+#define YT8824_CSR_PLL_FBDIV_REG		0x043a
+#define YT8824_CSR_PLL_FBDIV_SYNC_SELB		BIT(1)
+#define YT8824_CSR_PLL_SPARE_CTRL_REG		0x042a
+#define YT8824_CSR_PLL_SPARE			GENMASK(15, 0)
+#define YT8824_CDR_MANUAL_REG			0x0491
+#define YT8824_VDAC_AMP_THR_LNG			GENMASK(6, 0)
+#define YT8824_TRAINING_CTRL_REG		0x0492
+#define YT8824_VDAC_AMP_THR_MED			GENMASK(14, 8)
+#define YT8824_VDAC_AMP_THR_SHT			GENMASK(7, 0)
+#define YT8824_EOM_CTRL_REG			0x0454
+#define YT8824_EOD_DURATION_SEL			GENMASK(11, 8)
+#define YT8824_EOD_VTH				GENMASK(6, 0)
+#define YT8824_PGA_GAIN_CTRL_REG		0x0497
+#define YT8824_CDR_OFFSET_ERR_WTH		GENMASK(14, 8)
+#define YT8824_PGA_GAIN_MAX			GENMASK(6, 4)
+#define YT8824_PGA_GAIN_INIT			GENMASK(2, 0)
+#define YT8824_EOD_CTRL_REG			0x04cd
+#define YT8824_EOD_ERR_CNT_THR			GENMASK(15, 0)
+#define YT8824_CSR_AFE_CTRL_REG			0x04af
+#define YT8824_CSR_AFE_VCM_CFG			GENMASK(10, 8)
+#define YT8824_CSR_AFE_MANUAL_CTRL_1P25G	BIT(4)
+#define YT8824_CSR_AFE_MANUAL_CTRL_3P125G	BIT(3)
+#define YT8824_CSR_AFE_MANUAL_CTRL_10P3125G	BIT(2)
+#define YT8824_DFE_CTRL_REG			0x048a
+#define YT8824_DFE_TAP_POLARITY			BIT(12)
+#define YT8824_DFE_IDAC_TUNE			GENMASK(11, 10)
+#define YT8824_CSR_CDR_CTRL_REG			0x0408
+#define YT8824_CSR_CDR_OFFSET_DATA		GENMASK(14, 8)
+#define YT8824_DFE_VDAC_CODE_REG		0x04d6
+#define YT8824_DFE_VDAC_CODE_THR			GENMASK(6, 0)
+#define YT8824_RX_SPARE_CTRL_REG		0x044f
+#define YT8824_RX_SPARE_REG			GENMASK(15, 0)
+#define YT8824_DFE_VDAC_CTRL_REG		0x048e
+#define YT8824_DFE_VDAC_TUNE			GENMASK(11, 10)
+#define YT8824_DFE_VDAC_SEL			GENMASK(9, 8)
+#define YT8824_CSR_TX_PRE_REG			0x000d
+#define YT8824_CSR_TX_PRE_SEL			GENMASK(4, 0)
+#define YT8824_CSR_AFE_CTRL1_REG		0x04b0
+#define YT8824_CSR_AFE_CTLE_BW			GENMASK(6, 4)
+#define YT8824_CSR_AFE_CTRL2_REG		0x04b1
+#define YT8824_CSR_AFE_PGA_BW			GENMASK(14, 12)
+#define YT8824_CSR_AFE_BUF_BW			GENMASK(6, 4)
+#define YT8824_CSR_DCC_CAL_CTRL_REG		0x0003
+#define YT8824_CUR_TX_SEQ			GENMASK(15, 12)
+#define YT8824_CUR_RX_SEQ			GENMASK(11, 8)
+#define YT8824_CALIB_SEQ_FINISH			BIT(1)
+#define YT8824_CALIB_SEQ_SW_RST			BIT(0)
+#define YT8824_RESTART_CAL_CTRL_REG		0x2000
+#define YT8824_DAC_TRIM_MAIN_CFG_REG		0x429
+#define YT8824_PLL_VCO_CFG_REG			0x441
+#define YT8824_TX_MUX_CH3_CH2_REG		0x42b
+#define YT8824_C1_COARSE_CFG_REG		0x4b4
+#define YT8824_FFE_CTRL_REG			0x4b5
+
 struct yt8521_priv {
 	/* combo_advertising is used for case of YT8521 in combo mode,
 	 * this means that yt8521 may work in utp or fiber mode which depends
@@ -399,6 +638,14 @@ struct yt8521_priv {
 	u8 reg_page;
 };
 
+struct yt8824_shared_priv {
+	phy_interface_t package_mode;
+	/* shared_lock used to UTPs operation isolation during swap reg space */
+	struct mutex shared_lock;
+	/* true once the package-wide SERDES init has been done */
+	bool sds_initialized;
+};
+
 /**
  * ytphy_read_ext() - read a PHY's extended register
  * @phydev: a pointer to a &struct phy_device
@@ -437,6 +684,70 @@ static int ytphy_read_ext_with_lock(struct phy_device *phydev, u16 regnum)
 	return ret;
 }
 
+/**
+ * ytphy_read_top_ext() - read a PHY's top extended register for YT8824
+ * @phydev: a pointer to a &struct phy_device
+ * @regnum: register number to read
+ *
+ * Returns: the value of regnum reg or negative error code
+ */
+static int ytphy_read_top_ext(struct phy_device *phydev, u16 regnum)
+{
+	int ret;
+
+	lockdep_assert_held(&phydev->mdio.bus->mdio_lock);
+	ret = __phy_package_write(phydev, 0, YTPHY_PAGE_SELECT, regnum);
+	if (ret < 0)
+		return ret;
+
+	return __phy_package_read(phydev, 0, YTPHY_PAGE_DATA);
+}
+
+/**
+ * ytphy_write_top_ext() - write a PHY's top extended register for YT8824
+ * @phydev: a pointer to a &struct phy_device
+ * @regnum: register number to write
+ * @val: register val to write
+ *
+ * Returns: 0 or negative error code
+ */
+static int ytphy_write_top_ext(struct phy_device *phydev, u16 regnum,
+			       u16 val)
+{
+	int ret;
+
+	lockdep_assert_held(&phydev->mdio.bus->mdio_lock);
+	ret = __phy_package_write(phydev, 0, YTPHY_PAGE_SELECT, regnum);
+	if (ret < 0)
+		return ret;
+
+	return __phy_package_write(phydev, 0, YTPHY_PAGE_DATA, val);
+}
+
+/**
+ * phy8824_page_write_with_lock() - write page for YT8824
+ * @phydev: a pointer to a &struct phy_device
+ * @page: reg page(YT8824_RSSR_SERDES_SPACE/YT8824_RSSR_UTP_SPACE).
+ *
+ * Returns: 0 or negative error code
+ */
+static int phy8824_page_write_with_lock(struct phy_device *phydev, int page)
+{
+	int ret;
+
+	phy_lock_mdio_bus(phydev);
+	ret = ytphy_read_top_ext(phydev, YT8521_REG_SPACE_SELECT_REG);
+	if (ret < 0)
+		goto err;
+	ret &= ~YT8824_RSSR_SPACE_MASK;
+	ret |= (page & YT8824_RSSR_SPACE_MASK);
+	ret = ytphy_write_top_ext(phydev, YT8521_REG_SPACE_SELECT_REG, ret);
+
+err:
+	phy_unlock_mdio_bus(phydev);
+	return ret;
+}
+
 /**
  * ytphy_write_ext() - write a PHY's extended register
  * @phydev: a pointer to a &struct phy_device
@@ -622,15 +933,1165 @@ static int ytphy_set_wol(struct phy_device *phydev, struct ethtool_wolinfo *wol)
 		mask = YTPHY_WCR_ENABLE | YTPHY_WCR_INTR_SEL;
 		ret = ytphy_modify_ext(phydev, YTPHY_WOL_CONFIG_REG, mask, 0);
 
-		/* Disable WOL interrupt */
-		ret = __phy_modify(phydev, YTPHY_INTERRUPT_ENABLE_REG,
-				   YTPHY_IER_WOL, 0);
+		/* Disable WOL interrupt */
+		ret = __phy_modify(phydev, YTPHY_INTERRUPT_ENABLE_REG,
+				   YTPHY_IER_WOL, 0);
+		if (ret < 0)
+			goto err_restore_page;
+	}
+
+err_restore_page:
+	return phy_restore_page(phydev, old_page, ret);
+}
+
+/**
+ * yt8824_read_page() - read PHY8824 reg page
+ * @phydev: a pointer to a &struct phy_device
+ *
+ * Returns: current reg space of yt8824 (YT8824_RSSR_SERDES_SPACE/
+ * YT8824_RSSR_UTP_SPACE) or negative errno code
+ */
+static int yt8824_read_page(struct phy_device *phydev)
+{
+	int old_page;
+
+	old_page = ytphy_read_top_ext(phydev, YT8521_REG_SPACE_SELECT_REG);
+	if (old_page < 0)
+		return old_page;
+
+	return old_page & YT8824_RSSR_SPACE_MASK;
+};
+
+/**
+ * yt8824_write_page() - write reg page
+ * @phydev: a pointer to a &struct phy_device
+ * @page: Reg page(YT8824_RSSR_SERDES_SPACE/YT8824_RSSR_UTP_SPACE) to write.
+ *
+ * Returns: 0 or negative errno code
+ */
+static int yt8824_write_page(struct phy_device *phydev, int page)
+{
+	int old_page;
+	u16 data;
+
+	old_page = ytphy_read_top_ext(phydev, YT8521_REG_SPACE_SELECT_REG);
+	if (old_page < 0)
+		return old_page;
+	data = old_page & (~YT8824_RSSR_SPACE_MASK);
+	data |= page;
+
+	return ytphy_write_top_ext(phydev, YT8521_REG_SPACE_SELECT_REG, data);
+};
+
+/**
+ * yt8824_utp_set_template_test_mode() - config YT8824 UTP test mode.
+ * @phydev: a pointer to a &struct phy_device
+ * @test_mode: template test mode from normal, testmode1 to testmode7
+ *
+ * Returns: 0 or negative errno code
+ */
+static int yt8824_utp_set_template_test_mode(struct phy_device *phydev,
+					     u16 test_mode)
+{
+	int ret;
+
+	ret = phy8824_page_write_with_lock(phydev, YT8824_RSSR_UTP_SPACE);
+	if (ret < 0)
+		return ret;
+
+	return genphy_c45_template_testmode(phydev, test_mode);
+}
+
+/**
+ * yt8824_sds_isolate_paged() - enable YT8824 serdes isolate.
+ * @phydev: a pointer to a &struct phy_device
+ *
+ * Returns: 0 or negative errno code
+ */
+static int yt8824_sds_isolate_paged(struct phy_device *phydev)
+{
+	int old_page = YT8824_RSSR_UTP_SPACE;
+	int ret = 0;
+
+	old_page = phy_select_page(phydev, YT8824_RSSR_SERDES_SPACE);
+	if (old_page < 0)
+		goto err_restore_page;
+
+	/* enable sds isolate */
+	ret = __phy_modify(phydev, MII_BMCR, BMCR_ISOLATE, BMCR_ISOLATE);
+
+err_restore_page:
+	return phy_restore_page(phydev, old_page, ret);
+}
+
+/**
+ * yt8824_utp_softreset_paged() - config YT8824 UTP softreset.
+ * @phydev: a pointer to a &struct phy_device
+ *
+ * Returns: 0 or negative errno code
+ */
+static int yt8824_utp_softreset_paged(struct phy_device *phydev)
+{
+	int ret = 0;
+	int val;
+
+	ret = phy8824_page_write_with_lock(phydev, YT8824_RSSR_UTP_SPACE);
+	if (ret < 0)
+		return ret;
+	ret = phy_modify(phydev, MII_BMCR, BMCR_RESET, BMCR_RESET);
+	if (ret < 0)
+		return ret;
+	/* wait until softreset done. */
+	return phy_read_poll_timeout(phydev, MII_BMCR, val, !(val & BMCR_RESET),
+				     50000, 600000, true);
+}
+
+/**
+ * yt8824_sds_isolate_and_softreset_paged() - disable YT8824 serdes isolate
+ * and sds softreset.
+ * @phydev: a pointer to a &struct phy_device
+ *
+ * Returns: 0 or negative errno code
+ */
+static int yt8824_sds_isolate_and_softreset_paged(struct phy_device *phydev)
+{
+	int old_page = YT8824_RSSR_UTP_SPACE;
+	int val = 0;
+	int ret = -1;
+
+	old_page = phy_select_page(phydev, YT8824_RSSR_SERDES_SPACE);
+	if (old_page < 0)
+		goto err_restore_page;
+
+	/* sds softreset and disable isolate */
+	ret = __phy_modify(phydev, MII_BMCR, BMCR_RESET | BMCR_ISOLATE,
+			   BMCR_RESET & ~BMCR_ISOLATE);
+	if (ret < 0)
+		goto err_restore_page;
+
+	/* poll while still holding the lock */
+	ret = read_poll_timeout(__phy_read, val,
+				(val < 0) || !(val & BMCR_RESET), 50000, 600000,
+				true, phydev, MII_BMCR);
+	if (val < 0)
+		ret = val;
+
+err_restore_page:
+	return phy_restore_page(phydev, old_page, ret);
+}
+
+/**
+ * yt8824_restore_working_status() - called to do store working status
+ * @phydev: a pointer to a &struct phy_device
+ * @ret: operation's return code
+ *
+ * Returns: 0 or negative errno code
+ */
+static int yt8824_restore_working_status(struct phy_device *phydev, int ret)
+{
+	struct yt8824_shared_priv *priv = phy_package_get_priv(phydev);
+	int r;
+
+	r = yt8824_utp_set_template_test_mode(phydev,
+					      MDIO_PMA_10GBT_TESTMODE_NORMAL);
+	if (ret >= 0 && r < 0)
+		ret = r;
+	if (priv->package_mode != PHY_INTERFACE_MODE_INTERNAL) {
+		r = yt8824_sds_isolate_and_softreset_paged(phydev);
+		if (ret >= 0 && r < 0)
+			ret = r;
+	}
+
+	return ret;
+}
+
+/**
+ * yt8824_soft_reset() - called to do PHY software reset
+ * @phydev: a pointer to a &struct phy_device
+ *
+ * Returns: 0 or negative errno code
+ */
+static int yt8824_soft_reset(struct phy_device *phydev)
+{
+	struct yt8824_shared_priv *priv = phy_package_get_priv(phydev);
+	int ret;
+
+	mutex_lock(&priv->shared_lock);
+	if (priv->package_mode == PHY_INTERFACE_MODE_INTERNAL) {
+		ret = yt8824_utp_set_template_test_mode(phydev,
+							MDIO_PMA_10GBT_TESTMODE_1);
+		if (ret < 0)
+			goto retry;
+
+		ret = yt8824_utp_softreset_paged(phydev);
+		if (ret < 0)
+			goto retry;
+
+		ret = yt8824_utp_set_template_test_mode(phydev,
+							MDIO_PMA_10GBT_TESTMODE_NORMAL);
+		if (ret < 0)
+			goto retry;
+	} else {
+		ret = yt8824_utp_set_template_test_mode(phydev,
+							MDIO_PMA_10GBT_TESTMODE_1);
+		if (ret < 0)
+			goto retry;
+
+		ret = yt8824_sds_isolate_paged(phydev);
+		if (ret < 0)
+			goto retry;
+
+		ret = yt8824_utp_softreset_paged(phydev);
+		if (ret < 0)
+			goto retry;
+
+		ret = yt8824_utp_set_template_test_mode(phydev,
+							MDIO_PMA_10GBT_TESTMODE_NORMAL);
+		if (ret < 0)
+			goto retry;
+
+		ret = yt8824_sds_isolate_and_softreset_paged(phydev);
+		if (ret < 0)
+			goto retry;
+	}
+	mutex_unlock(&priv->shared_lock);
+	return ret;
+retry:
+	ret = yt8824_restore_working_status(phydev, ret);
+	mutex_unlock(&priv->shared_lock);
+
+	return ret;
+}
+
+/**
+ * yt8824_config_utp_init_paged() - config external phy8824 utp init
+ * @phydev: target phy_device struct
+ *
+ * Returns: 0 or negative errno code
+ */
+static int yt8824_config_utp_init_paged(struct phy_device *phydev)
+{
+	int ctrl = 0;
+	int mask = 0;
+	int ret = 0;
+	int val = 0;
+	int r;
+
+	ret = phy8824_page_write_with_lock(phydev, YT8824_RSSR_UTP_SPACE);
+	if (ret < 0)
+		return ret;
+
+	ret = phy_modify(phydev, MII_BMCR, BMCR_PDOWN, BMCR_PDOWN);
+	if (ret < 0)
+		goto err_restore;
+
+	/* write protecting */
+	mask = YT8824_WRITE_PROTECT;
+	ctrl = YT8824_WRITE_PROTECT;
+	ret = ytphy_modify_ext_with_lock(phydev,
+					 YT8824_WRITE_PROTECT_CAL_REG,
+					 mask, ctrl);
+	if (ret < 0)
+		goto err_restore;
+
+	/* PLL calibration */
+	ctrl = FIELD_PREP(YT8824_PLL_VCO_SEL_CURRENT, 0xb);
+	mask = YT8824_PLL_VCO_SEL_CURRENT;
+	ret = ytphy_modify_ext_with_lock(phydev,
+					 YT8824_PLL_VCO_ATEMP_REG,
+					 mask, ctrl);
+	if (ret < 0)
+		goto err_restore;
+
+	ctrl = FIELD_PREP(YT8824_PLL_VCO_ICOSTANT, 0xf);
+	mask = YT8824_PLL_VCO_ICOSTANT;
+	ret = ytphy_modify_ext_with_lock(phydev,
+					 YT8824_PLL_PFD_CTRL_REG,
+					 mask, ctrl);
+	if (ret < 0)
+		goto err_restore;
+
+	ctrl = FIELD_PREP(YT8824_PLL_VCO_IPTAT, 0xf);
+	mask = YT8824_PLL_VCO_IPTAT;
+	ret = ytphy_modify_ext_with_lock(phydev,
+					 YT8824_PLL_VCO_ATEMP_1_REG,
+					 mask, ctrl);
+	if (ret < 0)
+		goto err_restore;
+
+	ctrl = FIELD_PREP(YT8824_PLL_DAC_RST, 0);
+	mask = YT8824_PLL_DAC_RST;
+	ret = ytphy_modify_ext_with_lock(phydev,
+					 YT8824_PLL_DAC_0_REG,
+					 mask, ctrl);
+	if (ret < 0)
+		goto err_restore;
+
+	ctrl = FIELD_PREP(YT8824_PLL_DAC_RST, 1);
+	mask = YT8824_PLL_DAC_RST;
+	ret = ytphy_modify_ext_with_lock(phydev,
+					 YT8824_PLL_DAC_0_REG,
+					 mask, ctrl);
+	if (ret < 0)
+		goto err_restore;
+
+	/* enable nibble */
+	ctrl = FIELD_PREP(YT8824_U0_U1_ENABLE_ODD_PREAMBLE, 3);
+	mask = YT8824_U0_U1_ENABLE_ODD_PREAMBLE;
+	ret = ytphy_modify_ext_with_lock(phydev,
+					 YT8824_IF_CTRL_REG,
+					 mask, ctrl);
+	if (ret < 0)
+		goto err_restore;
+
+	/* idle err detect enable */
+	ctrl = YT8824_IDLE_DETECT;
+	mask = YT8824_IDLE_DETECT;
+	ret = ytphy_modify_ext_with_lock(phydev,
+					 YT8824_IDLE_CTRL_REG,
+					 mask, ctrl);
+	if (ret < 0)
+		goto err_restore;
+
+	/* optimized 2.5G long cable performance */
+	ctrl = FIELD_PREP(YT8824_TRACE_LNG_GAIN_THR_2500, 0x50);
+	ctrl |= FIELD_PREP(YT8824_TRACE_MED_GAIN_THR_2500, 0x38);
+	mask = YT8824_TRACE_LNG_GAIN_THR_2500 |
+	       YT8824_TRACE_MED_GAIN_THR_2500;
+	ret = ytphy_modify_ext_with_lock(phydev,
+					 YT8824_TRACE_GAIN_THR_REG,
+					 mask, ctrl);
+	if (ret < 0)
+		goto err_restore;
+
+	ctrl = FIELD_PREP(YT8824_PRM_LARGE_SLAVE_2500, 0x68);
+	mask = YT8824_PRM_LARGE_SLAVE_2500;
+	ret = ytphy_modify_ext_with_lock(phydev,
+					 YT8824_PRM_LONG_REG,
+					 mask, ctrl);
+	if (ret < 0)
+		goto err_restore;
+
+	ctrl = FIELD_PREP(YT8824_PRM_SMALL_LNG_2500, 0xa0);
+	mask = YT8824_PRM_SMALL_LNG_2500;
+	ret = ytphy_modify_ext_with_lock(phydev,
+					 YT8824_PRM_SMALL_REG,
+					 mask, ctrl);
+	if (ret < 0)
+		goto err_restore;
+
+	/* optimized fast retrain */
+	ctrl = FIELD_PREP(YT8824_LINK_FAIL_SIG, 0x21);
+	mask = YT8824_LINK_FAIL_SIG;
+	ret = ytphy_modify_ext_with_lock(phydev,
+					 YT8824_FAST_RETRAIN_REG,
+					 mask, ctrl);
+	if (ret < 0)
+		goto err_restore;
+
+	ctrl = FIELD_PREP(YT8824_EN_GATE_GMII_CLK, 0);
+	mask = YT8824_EN_GATE_GMII_CLK;
+	ret = ytphy_modify_ext_with_lock(phydev,
+					 YT8824_EN_GATE_CTRL_REG,
+					 mask, ctrl);
+	if (ret < 0)
+		goto err_restore;
+
+	/* 2.5G template tone */
+	ctrl = FIELD_PREP(YT8824_POWER_SAVE, 0x83);
+	mask = YT8824_POWER_SAVE;
+	ret = ytphy_modify_ext_with_lock(phydev,
+					 YT8824_DAC_CFG_REG,
+					 mask, ctrl);
+	if (ret < 0)
+		goto err_restore;
+
+	ctrl = FIELD_PREP(YT8824_DAC_BIAS_CFG_2500, 0xa);
+	mask = YT8824_DAC_BIAS_CFG_2500;
+	ret = ytphy_modify_ext_with_lock(phydev,
+					 YT8824_DAC_BIAS_CFG_REG,
+					 mask, ctrl);
+	if (ret < 0)
+		goto err_restore;
+
+	/* optimized 2.5G template */
+	ctrl = FIELD_PREP(YT8824_DAC_IMID_CH2, 0x39);
+	ctrl |= FIELD_PREP(YT8824_DAC_IMID_CH3, 0x39);
+	mask = YT8824_DAC_IMID_CH2 | YT8824_DAC_IMID_CH3;
+	ret = ytphy_modify_ext_with_lock(phydev,
+					 YT8824_DAC_IMID_CFG_REG,
+					 mask, ctrl);
+	if (ret < 0)
+		goto err_restore;
+
+	ctrl = FIELD_PREP(YT8824_DAC_IMID_CH0, 0x39);
+	ctrl |= FIELD_PREP(YT8824_DAC_IMID_CH1, 0x39);
+	mask = YT8824_DAC_IMID_CH0 | YT8824_DAC_IMID_CH1;
+	ret = ytphy_modify_ext_with_lock(phydev,
+					 YT8824_DAC_IMID_CFG1_REG,
+					 mask, ctrl);
+	if (ret < 0)
+		goto err_restore;
+
+	ctrl = FIELD_PREP(YT8824_DAC_IMSB_CH2, 0x39);
+	ctrl |= FIELD_PREP(YT8824_DAC_IMSB_CH3, 0x39);
+	mask = YT8824_DAC_IMSB_CH2 | YT8824_DAC_IMSB_CH3;
+	ret = ytphy_modify_ext_with_lock(phydev,
+					 YT8824_DAC_IMSB_CFG_REG,
+					 mask, ctrl);
+	if (ret < 0)
+		goto err_restore;
+
+	ctrl = FIELD_PREP(YT8824_DAC_IMSB_CH0, 0x39);
+	ctrl |= FIELD_PREP(YT8824_DAC_IMSB_CH1, 0x39);
+	mask = YT8824_DAC_IMSB_CH0 | YT8824_DAC_IMSB_CH1;
+	ret = ytphy_modify_ext_with_lock(phydev,
+					 YT8824_DAC_IMSB_CFG1_REG,
+					 mask, ctrl);
+	if (ret < 0)
+		goto err_restore;
+
+	/* optimized 1000M cable length threshold */
+	ctrl = FIELD_PREP(YT8824_TRACE_LNG_GAIN_THR, 0x2b);
+	mask = YT8824_TRACE_LNG_GAIN_THR;
+	ret = ytphy_modify_ext_with_lock(phydev,
+					 YT8824_TRACE_LNG_GAIN_REG,
+					 mask, ctrl);
+	if (ret < 0)
+		goto err_restore;
+
+	ctrl = FIELD_PREP(YT8824_TRACE_MED_GAIN_THR, 0x1d);
+	mask = YT8824_TRACE_MED_GAIN_THR;
+	ret = ytphy_modify_ext_with_lock(phydev,
+					 YT8824_TRACE_MED_GAIN_REG,
+					 mask, ctrl);
+	if (ret < 0)
+		goto err_restore;
+
+	/* 100M template amplitude */
+	ctrl = FIELD_PREP(YT8824_DAC_IMID_CH3_ORG, 0x45);
+	ctrl |= FIELD_PREP(YT8824_DAC_IMID_CH2_ORG, 0x45);
+	mask = YT8824_DAC_IMID_CH3_ORG | YT8824_DAC_IMID_CH2_ORG;
+	ret = ytphy_modify_ext_with_lock(phydev,
+					 YT8824_DAC_IMID_CH2_CH3_CFG_ORG_REG,
+					 mask, ctrl);
+	if (ret < 0)
+		goto err_restore;
+
+	ctrl = FIELD_PREP(YT8824_DAC_IMID_CH1_ORG, 0x45);
+	ctrl |= FIELD_PREP(YT8824_DAC_IMID_CH0_ORG, 0x45);
+	mask = YT8824_DAC_IMID_CH1_ORG | YT8824_DAC_IMID_CH0_ORG;
+	ret = ytphy_modify_ext_with_lock(phydev,
+					 YT8824_DAC_IMID_CH0_CH1_CFG_ORG_REG,
+					 mask, ctrl);
+	if (ret < 0)
+		goto err_restore;
+
+	ctrl = FIELD_PREP(YT8824_DAC_IMSB_CH3_ORG, 0x45);
+	ctrl |= FIELD_PREP(YT8824_DAC_IMSB_CH2_ORG, 0x45);
+	mask = YT8824_DAC_IMSB_CH2_ORG | YT8824_DAC_IMSB_CH3_ORG;
+	ret = ytphy_modify_ext_with_lock(phydev,
+					 YT8824_DAC_IMSB_CH2_CH3_CFG_ORG_REG,
+					 mask, ctrl);
+	if (ret < 0)
+		goto err_restore;
+
+	ctrl = FIELD_PREP(YT8824_DAC_IMSB_CH1_ORG, 0x45);
+	ctrl |= FIELD_PREP(YT8824_DAC_IMSB_CH0_ORG, 0x45);
+	mask = YT8824_DAC_IMSB_CH1_ORG | YT8824_DAC_IMSB_CH0_ORG;
+	ret = ytphy_modify_ext_with_lock(phydev,
+					 YT8824_DAC_IMSB_CH0_CH1_CFG_ORG_REG,
+					 mask, ctrl);
+	if (ret < 0)
+		goto err_restore;
+
+	/* optimized 100M cable length threshold */
+	ctrl = FIELD_PREP(YT8824_TRACE_LNG_GAIN_THR_100, 0x2A);
+	ctrl |= FIELD_PREP(YT8824_TRACE_MED_GAIN_THR_100, 0x1D);
+	mask = YT8824_TRACE_LNG_GAIN_THR_100 | YT8824_TRACE_MED_GAIN_THR_100;
+	ret = ytphy_modify_ext_with_lock(phydev,
+					 YT8824_TRACE_LNG_GAIN_100_REG,
+					 mask, ctrl);
+	if (ret < 0)
+		goto err_restore;
+
+	ctrl = FIELD_PREP(YT8824_CABLE_VSHT_THR_S, 0x36);
+	mask = YT8824_CABLE_VSHT_THR_S;
+	ret = ytphy_modify_ext_with_lock(phydev, YT8824_CABLE_VSHT_REG,
+					 mask, ctrl);
+	if (ret < 0)
+		goto err_restore;
+
+	/* 10M template amplitude */
+	ctrl = FIELD_PREP(YT8824_DAC_LPFIL_ADJ_CH3_10, 0x18);
+	ctrl |= FIELD_PREP(YT8824_DAC_LPFIL_ADJ_CH2_10, 0x18);
+	mask = YT8824_DAC_LPFIL_ADJ_CH3_10 | YT8824_DAC_LPFIL_ADJ_CH2_10;
+	ret = ytphy_modify_ext_with_lock(phydev,
+					 YT8824_DAC_LPFIL_CH2_CH3_ADJ_REG,
+					 mask, ctrl);
+	if (ret < 0)
+		goto err_restore;
+
+	ctrl = FIELD_PREP(YT8824_DAC_LPFIL_ADJ_CH1_10, 0x18);
+	ctrl |= FIELD_PREP(YT8824_DAC_LPFIL_ADJ_CH0_10, 0x18);
+	mask = YT8824_DAC_LPFIL_ADJ_CH1_10 | YT8824_DAC_LPFIL_ADJ_CH0_10;
+	ret = ytphy_modify_ext_with_lock(phydev,
+					 YT8824_DAC_LPFIL_CH0_CH1_ADJ_REG,
+					 mask, ctrl);
+	if (ret < 0)
+		goto err_restore;
+
+	/* optimized 10M cable length threshold */
+	ctrl = FIELD_PREP(YT8824_DAC_IMID_CFG_CH3_10_ORG, 0x6C);
+	ctrl |= FIELD_PREP(YT8824_DAC_IMID_CFG_CH2_10_ORG, 0x6C);
+	mask = YT8824_DAC_IMID_CFG_CH3_10_ORG | YT8824_DAC_IMID_CFG_CH2_10_ORG;
+	ret = ytphy_modify_ext_with_lock(phydev,
+					 YT8824_DAC_IMID_CFG_CH2_CH3_10_ORG,
+					 mask, ctrl);
+	if (ret < 0)
+		goto err_restore;
+
+	ctrl = FIELD_PREP(YT8824_DAC_IMID_CFG_CH1_10_ORG, 0x6C);
+	ctrl |= FIELD_PREP(YT8824_DAC_IMID_CFG_CH0_10_ORG, 0x6C);
+	mask = YT8824_DAC_IMID_CFG_CH1_10_ORG | YT8824_DAC_IMID_CFG_CH0_10_ORG;
+	ret = ytphy_modify_ext_with_lock(phydev,
+					 YT8824_DAC_IMID_CFG_CH0_CH1_10_ORG,
+					 mask, ctrl);
+	if (ret < 0)
+		goto err_restore;
+
+	/* optimized DAC IMSB config for CH2/CH3 */
+	ctrl = FIELD_PREP(YT8824_DAC_IMSB_CFG_CH3_10_ORG, 0x6C);
+	ctrl |= FIELD_PREP(YT8824_DAC_IMSB_CFG_CH2_10_ORG, 0x6C);
+	mask = YT8824_DAC_IMSB_CFG_CH3_10_ORG | YT8824_DAC_IMSB_CFG_CH2_10_ORG;
+	ret = ytphy_modify_ext_with_lock(phydev,
+					 YT8824_DAC_IMSB_CFG_CH2_CH3_10_ORG,
+					 mask, ctrl);
+	if (ret < 0)
+		goto err_restore;
+
+	/* optimized DAC IMSB config for CH0/CH1 */
+	ctrl = FIELD_PREP(YT8824_DAC_IMSB_CFG_CH1_10_ORG, 0x6C);
+	ctrl |= FIELD_PREP(YT8824_DAC_IMSB_CFG_CH0_10_ORG, 0x6C);
+	mask = YT8824_DAC_IMSB_CFG_CH1_10_ORG | YT8824_DAC_IMSB_CFG_CH0_10_ORG;
+	ret = ytphy_modify_ext_with_lock(phydev,
+					 YT8824_DAC_IMSB_CFG_CH0_CH1_10_ORG,
+					 mask, ctrl);
+	if (ret < 0)
+		goto err_restore;
+
+	/* optimize utp 1000M performance */
+	ctrl = FIELD_PREP(YT8824_WAIT_TO_1000, 0xFF);
+	mask = YT8824_WAIT_TO_1000;
+	ret = ytphy_modify_ext_with_lock(phydev, YT8824_FFE_REG, mask, ctrl);
+	if (ret < 0)
+		goto err_restore;
+
+	ctrl = FIELD_PREP(YT8824_EN_GATE_PHYDBG, 0);
+	ctrl |= FIELD_PREP(YT8824_EN_GATE_BT1000, 0);
+	mask = YT8824_EN_GATE_PHYDBG | YT8824_EN_GATE_BT1000;
+	ret = ytphy_modify_ext_with_lock(phydev, YT8824_EN_GATE_REG,
+					 mask, ctrl);
+	if (ret < 0)
+		goto err_restore;
+
+	ctrl = FIELD_PREP(YT8824_CNT_ERR_AUTO, 1);
+	mask = YT8824_CNT_ERR_AUTO;
+	ret = ytphy_modify_ext_with_lock(phydev, YT8824_CNT_REG, mask, ctrl);
+	if (ret < 0)
+		goto err_restore;
+
+	ctrl = FIELD_PREP(YT8824_PRM_LARGE_MASTER_1000, 0x94);
+	mask = YT8824_PRM_LARGE_MASTER_1000;
+	ret = ytphy_modify_ext_with_lock(phydev, YT8824_PRM_LARGE_MASTER_REG,
+					 mask, ctrl);
+	if (ret < 0)
+		goto err_restore;
+
+	ctrl = FIELD_PREP(YT8824_PRM_LARGE_SLAVE_1000, 0x094);
+	mask = YT8824_PRM_LARGE_SLAVE_1000;
+	ret = ytphy_modify_ext_with_lock(phydev, YT8824_PRM_LARGE_SLAVE_REG,
+					 mask, ctrl);
+	if (ret < 0)
+		goto err_restore;
+
+	ctrl = FIELD_PREP(YT8824_SIG_GONE_THR_1000, 0x08);
+	mask = YT8824_SIG_GONE_THR_1000;
+	ret = ytphy_modify_ext_with_lock(phydev, YT8824_SIG_GONE_REG,
+					 mask, ctrl);
+	if (ret < 0)
+		goto err_restore;
+
+	ctrl = FIELD_PREP(YT8824_EC_NX_TRAIN_COARSE_TO_1000, 0x40);
+	mask = YT8824_EC_NX_TRAIN_COARSE_TO_1000;
+	ret = ytphy_modify_ext_with_lock(phydev, YT8824_EC_NX_TRAIN_COARSE_REG,
+					 mask, ctrl);
+	if (ret < 0)
+		goto err_restore;
+
+	ctrl = FIELD_PREP(YT8824_VGA_IN_LPF2_CAP_OTHER, 0x2);
+	mask = YT8824_VGA_IN_LPF2_CAP_OTHER;
+	ret = ytphy_modify_ext_with_lock(phydev, YT8824_VGA_IN_LPF2_CAP_REG,
+					 mask, ctrl);
+	if (ret < 0)
+		goto err_restore;
+
+	ctrl = FIELD_PREP(YT8824_VGA_IN_LPF1_CAP_OTHER, 0x2);
+	mask = YT8824_VGA_IN_LPF1_CAP_OTHER;
+	ret = ytphy_modify_ext_with_lock(phydev, YT8824_VGA_IN_LPF1_CAP_REG,
+					 mask, ctrl);
+	if (ret < 0)
+		goto err_restore;
+
+	/* optimized EMC CS */
+	ctrl = FIELD_PREP(YT8824_LDPC_FAIL_THR, 0xFF);
+	ctrl |= FIELD_PREP(YT8824_LFER_FAIL_THR, 0xFF);
+	mask = YT8824_LDPC_FAIL_THR | YT8824_LFER_FAIL_THR;
+	ret = ytphy_modify_ext_with_lock(phydev, YT8824_LDPC_LFER_FAIL_REG,
+					 mask, ctrl);
+	if (ret < 0)
+		goto err_restore;
+
+	ctrl = FIELD_PREP(YT8824_FR_REQ_THR, 0x06);
+	mask = YT8824_FR_REQ_THR;
+	ret = ytphy_modify_ext_with_lock(phydev, YT8824_FR_REQ_REG, mask, ctrl);
+	if (ret < 0)
+		goto err_restore;
+
+	ctrl = FIELD_PREP(YT8824_PRM_SMALL_SHT_2500, 0x0FF);
+	mask = YT8824_PRM_SMALL_SHT_2500;
+	ret = ytphy_modify_ext_with_lock(phydev, YT8824_GN_MU_COARSE_REG,
+					 mask, ctrl);
+	if (ret < 0)
+		goto err_restore;
+
+	/* optimized EMC RE */
+	ctrl = FIELD_PREP(YT8824_DAC_AMP_ADJ_CH3_PBO0_2500, 0xF);
+	ctrl |= FIELD_PREP(YT8824_DAC_AMP_ADJ_CH2_PBO0_2500, 0xF);
+	ctrl |= FIELD_PREP(YT8824_DAC_AMP_ADJ_CH1_PBO0_2500, 0xF);
+	ctrl |= FIELD_PREP(YT8824_DAC_AMP_ADJ_CH0_PBO0_2500, 0xF);
+	mask = YT8824_DAC_AMP_ADJ_CH3_PBO0_2500 |
+	       YT8824_DAC_AMP_ADJ_CH2_PBO0_2500 |
+	       YT8824_DAC_AMP_ADJ_CH1_PBO0_2500 |
+	       YT8824_DAC_AMP_ADJ_CH0_PBO0_2500;
+	ret = ytphy_modify_ext_with_lock(phydev,
+					 YT8824_DAC_AMP_ADJ_REG,
+					 mask, ctrl);
+	if (ret < 0)
+		goto err_restore;
+
+	ctrl = FIELD_PREP(YT8824_P0_DAC_BIAS_CAS_CFG_CH3, 0x1F);
+	ctrl |= FIELD_PREP(YT8824_P0_DAC_BIAS_CAS_CFG_CH2, 0x1F);
+	mask = YT8824_P0_DAC_BIAS_CAS_CFG_CH3 | YT8824_P0_DAC_BIAS_CAS_CFG_CH2;
+	ret = ytphy_modify_ext_with_lock(phydev,
+					 YT8824_P0_DAC_BIAS_CAS_CH3_CH2_REG,
+					 mask, ctrl);
+	if (ret < 0)
+		goto err_restore;
+
+	ctrl = FIELD_PREP(YT8824_P0_DAC_BIAS_CAS_CFG_CH1, 0x1F);
+	ctrl |= FIELD_PREP(YT8824_P0_DAC_BIAS_CAS_CFG_CH0, 0x1F);
+	mask = YT8824_P0_DAC_BIAS_CAS_CFG_CH1 | YT8824_P0_DAC_BIAS_CAS_CFG_CH0;
+	ret = ytphy_modify_ext_with_lock(phydev,
+					 YT8824_P0_DAC_BIAS_CAS_CH1_CH0_REG,
+					 mask, ctrl);
+	if (ret < 0)
+		goto err_restore;
+
+	ctrl = FIELD_PREP(YT8824_P1_DAC_BIAS_CAS_CFG_CH3, 0x1F);
+	ctrl |= FIELD_PREP(YT8824_P1_DAC_BIAS_CAS_CFG_CH2, 0x1F);
+	mask = YT8824_P1_DAC_BIAS_CAS_CFG_CH3 | YT8824_P1_DAC_BIAS_CAS_CFG_CH2;
+	ret = ytphy_modify_ext_with_lock(phydev,
+					 YT8824_P1_DAC_BIAS_CAS_CH3_CH2_REG,
+					 mask, ctrl);
+	if (ret < 0)
+		goto err_restore;
+
+	ctrl = FIELD_PREP(YT8824_P1_DAC_BIAS_CAS_CFG_CH1, 0x1F);
+	ctrl |= FIELD_PREP(YT8824_P1_DAC_BIAS_CAS_CFG_CH0, 0x1F);
+	mask = YT8824_P1_DAC_BIAS_CAS_CFG_CH1 | YT8824_P1_DAC_BIAS_CAS_CFG_CH0;
+	ret = ytphy_modify_ext_with_lock(phydev,
+					 YT8824_P1_DAC_BIAS_CAS_CH1_CH0_REG,
+					 mask, ctrl);
+	if (ret < 0)
+		goto err_restore;
+
+	ctrl = FIELD_PREP(YT8824_CSR_EFUSE_BYPASS_ANALOG_SECOND_RESET, 1);
+	ctrl |= FIELD_PREP(YT8824_CSR_EFUSE_BYPASS_PLL_TXRX_RESET, 1);
+	mask  = YT8824_CSR_EFUSE_BYPASS_ANALOG_SECOND_RESET |
+		YT8824_CSR_EFUSE_BYPASS_PLL_TXRX_RESET;
+	ret = ytphy_modify_ext_with_lock(phydev,
+					 YT8824_P01_PLL_EN_REG,
+					 mask, ctrl);
+	if (ret < 0)
+		goto err_restore;
+
+	ctrl = FIELD_PREP(YT8824_U0_CSR_RESETB_TX_CH0, 0);
+	ctrl |= FIELD_PREP(YT8824_U0_CSR_RESETB_TX_CH1, 0);
+	ctrl |= FIELD_PREP(YT8824_U0_CSR_RESETB_TX_CH2, 0);
+	ctrl |= FIELD_PREP(YT8824_U0_CSR_RESETB_TX_CH3, 0);
+	mask  = YT8824_U0_CSR_RESETB_TX_CH0 | YT8824_U0_CSR_RESETB_TX_CH1 |
+		YT8824_U0_CSR_RESETB_TX_CH2 | YT8824_U0_CSR_RESETB_TX_CH3;
+	ret = ytphy_modify_ext_with_lock(phydev, YT8824_U0_CSR_RESET_REG,
+					 mask, ctrl);
+	if (ret < 0)
+		goto err_restore;
+
+	ctrl = FIELD_PREP(YT8824_U1_CSR_RESETB_TX_CH0, 0);
+	ctrl |= FIELD_PREP(YT8824_U1_CSR_RESETB_TX_CH1, 0);
+	ctrl |= FIELD_PREP(YT8824_U1_CSR_RESETB_TX_CH2, 0);
+	ctrl |= FIELD_PREP(YT8824_U1_CSR_RESETB_TX_CH3, 0);
+	mask = YT8824_U1_CSR_RESETB_TX_CH0 | YT8824_U1_CSR_RESETB_TX_CH1 |
+	       YT8824_U1_CSR_RESETB_TX_CH2 | YT8824_U1_CSR_RESETB_TX_CH3;
+	ret = ytphy_modify_ext_with_lock(phydev, YT8824_U1_CSR_RESET_REG,
+					 mask, ctrl);
+	if (ret < 0)
+		goto err_restore;
+
+	ctrl = FIELD_PREP(YT8824_U0_CSR_RESETB_TX_CH0, 1);
+	ctrl |= FIELD_PREP(YT8824_U0_CSR_RESETB_TX_CH1, 1);
+	ctrl |= FIELD_PREP(YT8824_U0_CSR_RESETB_TX_CH2, 1);
+	ctrl |= FIELD_PREP(YT8824_U0_CSR_RESETB_TX_CH3, 1);
+	mask = YT8824_U0_CSR_RESETB_TX_CH0 | YT8824_U0_CSR_RESETB_TX_CH1 |
+	       YT8824_U0_CSR_RESETB_TX_CH2 | YT8824_U0_CSR_RESETB_TX_CH3;
+	ret = ytphy_modify_ext_with_lock(phydev, YT8824_U0_CSR_RESET_REG,
+					 mask, ctrl);
+	if (ret < 0)
+		goto err_restore;
+
+	ctrl = FIELD_PREP(YT8824_U1_CSR_RESETB_TX_CH0, 1);
+	ctrl |= FIELD_PREP(YT8824_U1_CSR_RESETB_TX_CH1, 1);
+	ctrl |= FIELD_PREP(YT8824_U1_CSR_RESETB_TX_CH2, 1);
+	ctrl |= FIELD_PREP(YT8824_U1_CSR_RESETB_TX_CH3, 1);
+	mask = YT8824_U1_CSR_RESETB_TX_CH0 | YT8824_U1_CSR_RESETB_TX_CH1 |
+	       YT8824_U1_CSR_RESETB_TX_CH2 | YT8824_U1_CSR_RESETB_TX_CH3;
+	ret = ytphy_modify_ext_with_lock(phydev, YT8824_U1_CSR_RESET_REG,
+					 mask, ctrl);
+	if (ret < 0)
+		goto err_restore;
+	/* reset */
+	ret = genphy_c45_template_testmode(phydev, MDIO_PMA_10GBT_TESTMODE_1);
+	if (ret < 0)
+		goto err_restore_normal;
+
+	ret = phy_modify(phydev, MII_BMCR, BMCR_RESET | BMCR_ANENABLE,
+			 BMCR_RESET | BMCR_ANENABLE);
+	if (ret < 0)
+		goto err_restore_normal;
+	ret = phy_read_poll_timeout(phydev, MII_BMCR, val, !(val & BMCR_RESET),
+				    50000, 600000, true);
+	if (ret < 0)
+		goto err_restore_normal;
+
+	ret = genphy_c45_template_testmode(phydev,
+					   MDIO_PMA_10GBT_TESTMODE_NORMAL);
+	if (ret < 0)
+		goto err_restore_normal;
+	return 0;
+
+err_restore:
+	r = phy_modify(phydev, MII_BMCR, BMCR_PDOWN, 0);
+	if (ret >= 0 && r < 0)
+		ret = r;
+	return ret;
+
+err_restore_normal:
+	r = genphy_c45_template_testmode(phydev,
+					 MDIO_PMA_10GBT_TESTMODE_NORMAL);
+	if (ret >= 0 && r < 0)
+		ret = r;
+	r = phy_modify(phydev, MII_BMCR, BMCR_PDOWN, 0);
+	if (ret >= 0 && r < 0)
+		ret = r;
+	return ret;
+}
+
+/**
+ * yt8824_extern_sds_softreset() - config external phy8824 sds softrest
+ * @phydev: target phy_device struct
+ *
+ *
+ * Returns: 0 or negative errno code
+ */
+static int yt8824_extern_sds_softreset(struct phy_device *phydev)
+{
+	int old_page = YT8824_RSSR_UTP_SPACE;
+	int ret = -1;
+	int val = 0;
+
+	old_page = phy_select_page(phydev, YT8824_RSSR_SERDES_SPACE);
+	if (old_page < 0)
+		goto err_restore_page;
+
+	/* TX preamble padded to 8; RX IPG always > 8 */
+	ret = __phy_read(phydev, MII_RESV1);
+	if (ret < 0)
+		goto err_restore_page;
+	ret &= ~YT8824_SDS_CFG_MIN_PRE_MASK;
+	ret |= YT8824_SDS_TX_PRE_PADDING;
+	ret |= YT8824_SDS_EN_FILL_PRE;
+	ret = __phy_write(phydev, MII_RESV1, ret);
+	if (ret < 0)
+		goto err_restore_page;
+
+	ret = __phy_modify(phydev, MII_BMCR, BMCR_RESET | BMCR_ANENABLE,
+			   BMCR_RESET | BMCR_ANENABLE);
+	if (ret < 0)
+		goto err_restore_page;
+	/* poll while still holding the lock; __phy_read takes no lock */
+	ret = read_poll_timeout(__phy_read, val,
+				(val < 0) || !(val & BMCR_RESET), 50000, 600000,
+				true, phydev, MII_BMCR);
+	if (val < 0)
+		ret = val;
+
+err_restore_page:
+	return phy_restore_page(phydev, old_page, ret);
+}
+
+/**
+ * yt8824_extern_config_sds_init_paged() - config external phy8824 sds init
+ * @phydev: target phy_device struct
+ *
+ *
+ * Returns: 0 or negative errno code
+ */
+static int yt8824_extern_config_sds_init_paged(struct phy_device *phydev)
+{
+	int old_page = YT8824_RSSR_UTP_SPACE;
+	int val_1, val_2, val_3, tmp;
+	int ctrl = 0;
+	int mask = 0;
+	int ret = -1;
+
+	old_page = phy_select_page(phydev, YT8824_RSSR_SERDES_SPACE);
+	if (old_page < 0)
+		goto err_restore_page;
+
+	/* read efuse */
+	ret = ytphy_read_top_ext(phydev, YT8824_SERDES_PLL_CTRL1_REG);
+	if (ret < 0)
+		goto err_restore_page;
+	else
+		val_1 = ret;
+
+	ret = ytphy_read_top_ext(phydev, YT8824_SERDES_PLL_CTRL2_REG);
+	if (ret < 0)
+		goto err_restore_page;
+	else
+		val_2 = ret;
+
+	ret = ytphy_read_top_ext(phydev, YT8824_SERDES_PLL_CTRL3_REG);
+	if (ret < 0)
+		goto err_restore_page;
+	else
+		val_3 = ret;
+
+	/* Serdes optimization */
+	ctrl = FIELD_PREP(YT8824_SERDES_REG_WR_PRT, 1);
+	mask = YT8824_SERDES_REG_WR_PRT;
+	ret = ytphy_modify_ext(phydev, YT8824_WRITE_PROTECT_REG, mask, ctrl);
+	if (ret < 0)
+		goto err_restore_page;
+
+	ctrl = FIELD_PREP(YT8824_CSR_PCS_GLB_RST_BYPASS, 1);
+	ctrl |= FIELD_PREP(YT8824_CSR_SG_MODE_RST_BYPASS, 1);
+	ctrl |= FIELD_PREP(YT8824_CSR_US_GLB_RESET_N, 0);
+	ctrl |= FIELD_PREP(YT8824_CSR_PCS_BEF_TRAINING_DONE_RST_BYPASS, 1);
+	mask = YT8824_CSR_PCS_GLB_RST_BYPASS | YT8824_CSR_SG_MODE_RST_BYPASS |
+	       YT8824_CSR_US_GLB_RESET_N |
+	       YT8824_CSR_PCS_BEF_TRAINING_DONE_RST_BYPASS;
+	ret = ytphy_modify_ext(phydev, YT8824_CSR_CTRL_REG, mask, ctrl);
+	if (ret < 0)
+		goto err_restore_page;
+
+	ctrl = FIELD_PREP(YT8824_CSR_WATCH_DOG_ALL_BYPASS, 1);
+	mask = YT8824_CSR_WATCH_DOG_ALL_BYPASS;
+	ret = ytphy_modify_ext(phydev, YT8824_CSR_PMA_CTRL_REG, mask, ctrl);
+	if (ret < 0)
+		goto err_restore_page;
+
+	/* analog CDR */
+	ctrl = FIELD_PREP(YT8824_CDR_MODE, 1);
+	mask = YT8824_CDR_MODE;
+	ret = ytphy_modify_ext(phydev, YT8824_CDR_CTRL_REG, mask, ctrl);
+	if (ret < 0)
+		goto err_restore_page;
+
+	/* optimized VCO */
+	ctrl = FIELD_PREP(YT8824_CSR_PLL_VCO_SEL_VCO2_CURRENT, 0x9);
+	ctrl |= FIELD_PREP(YT8824_CSR_PLL_VCO_ATEMP_R, 0x4);
+	mask = YT8824_CSR_PLL_VCO_SEL_VCO2_CURRENT | YT8824_CSR_PLL_VCO_ATEMP_R;
+	ret = ytphy_modify_ext(phydev, YT8824_CSR_PLL_VCO_CTRL_REG, mask, ctrl);
+	if (ret < 0)
+		goto err_restore_page;
+
+	ctrl = FIELD_PREP(YT8824_CSR_PLL_VCO_SEL_VCO2_RM_R, 0x0);
+	mask = YT8824_CSR_PLL_VCO_SEL_VCO2_RM_R;
+	ret = ytphy_modify_ext(phydev, YT8824_CSR_PLL_DIVLDO_CTRL_REG,
+			       mask, ctrl);
+	if (ret < 0)
+		goto err_restore_page;
+
+	/* optimized PLL lock */
+	ret = ytphy_read_ext(phydev, YT8824_DAC_TRIM_MAIN_CFG_REG);
+	if (ret < 0)
+		goto err_restore_page;
+
+	ret &= ~(BIT(13) | BIT(12));
+	tmp = (val_1 & (BIT(7) | BIT(6))) >> 6;
+	ret |= (tmp << 12);
+	ret = ytphy_write_ext(phydev, YT8824_DAC_TRIM_MAIN_CFG_REG, ret);
+	if (ret < 0)
+		goto err_restore_page;
+
+	ret = ytphy_read_ext(phydev, YT8824_PLL_VCO_CFG_REG);
+	if (ret < 0)
+		goto err_restore_page;
+
+	ret &= ~(BIT(1) | BIT(0));
+	tmp = (val_1 & (BIT(5) | BIT(4))) >> 4;
+	ret |= tmp;
+	ret = ytphy_write_ext(phydev, YT8824_PLL_VCO_CFG_REG, ret);
+	if (ret < 0)
+		goto err_restore_page;
+
+	ret = ytphy_read_ext(phydev, YT8824_TX_MUX_CH3_CH2_REG);
+	if (ret < 0)
+		goto err_restore_page;
+
+	ret &= ~(BIT(13) | BIT(12));
+	tmp = (val_3 & (BIT(1) | BIT(0)));
+	ret |= (tmp << 12);
+	ret = ytphy_write_ext(phydev, YT8824_TX_MUX_CH3_CH2_REG, ret);
+	if (ret < 0)
+		goto err_restore_page;
+
+	ctrl = FIELD_PREP(YT8824_CSR_PLL_FBDIV_SYNC_SELB, 1);
+	mask = YT8824_CSR_PLL_FBDIV_SYNC_SELB;
+	ret = ytphy_modify_ext(phydev, YT8824_CSR_PLL_FBDIV_REG, mask, ctrl);
+	if (ret < 0)
+		goto err_restore_page;
+
+	ctrl = FIELD_PREP(YT8824_CSR_PLL_SPARE, 0xf070);
+	mask = YT8824_CSR_PLL_SPARE;
+	ret = ytphy_modify_ext(phydev, YT8824_CSR_PLL_SPARE_CTRL_REG,
+			       mask, ctrl);
+	if (ret < 0)
+		goto err_restore_page;
+
+	/* cable length threshold */
+	ctrl = FIELD_PREP(YT8824_VDAC_AMP_THR_LNG, 0x7F);
+	mask = YT8824_VDAC_AMP_THR_LNG;
+	ret = ytphy_modify_ext(phydev, YT8824_CDR_MANUAL_REG, mask, ctrl);
+	if (ret < 0)
+		goto err_restore_page;
+
+	ctrl = FIELD_PREP(YT8824_VDAC_AMP_THR_MED, 0x7F);
+	ctrl |= FIELD_PREP(YT8824_VDAC_AMP_THR_SHT, 0x7F);
+	mask = YT8824_VDAC_AMP_THR_MED | YT8824_VDAC_AMP_THR_SHT;
+	ret = ytphy_modify_ext(phydev, YT8824_TRAINING_CTRL_REG, mask, ctrl);
+	if (ret < 0)
+		goto err_restore_page;
+
+	/* Serdes training threshold */
+	ctrl = FIELD_PREP(YT8824_EOD_DURATION_SEL, 0xF);
+	ctrl |= FIELD_PREP(YT8824_EOD_VTH, 0x14);
+	mask = YT8824_EOD_DURATION_SEL | YT8824_EOD_VTH;
+	ret = ytphy_modify_ext(phydev, YT8824_EOM_CTRL_REG, mask, ctrl);
+	if (ret < 0)
+		goto err_restore_page;
+
+	ctrl = FIELD_PREP(YT8824_CDR_OFFSET_ERR_WTH, 0x0A);
+	ctrl |= FIELD_PREP(YT8824_PGA_GAIN_MAX, 0x4);
+	ctrl |= FIELD_PREP(YT8824_PGA_GAIN_INIT, 0x4);
+	mask = YT8824_CDR_OFFSET_ERR_WTH | YT8824_PGA_GAIN_MAX |
+	       YT8824_PGA_GAIN_INIT;
+	ret = ytphy_modify_ext(phydev, YT8824_PGA_GAIN_CTRL_REG, mask, ctrl);
+	if (ret < 0)
+		goto err_restore_page;
+
+	/* digital eye diagram of SerDes */
+	ctrl = FIELD_PREP(YT8824_EOD_ERR_CNT_THR, 0x0000);
+	mask = YT8824_EOD_ERR_CNT_THR;
+	ret = ytphy_modify_ext(phydev, YT8824_EOD_CTRL_REG, mask, ctrl);
+	if (ret < 0)
+		goto err_restore_page;
+
+	/* Serdes LDO */
+	ret = ytphy_read_ext(phydev, YT8824_FFE_CTRL_REG);
+	if (ret < 0)
+		goto err_restore_page;
+
+	ret &= ~(BIT(6) | BIT(5) | BIT(4));
+	tmp = (val_2 & (BIT(4) | BIT(3) | BIT(2))) >> 2;
+	ret |= (tmp << 4);
+	ret = ytphy_write_ext(phydev, YT8824_FFE_CTRL_REG, ret);
+	if (ret < 0)
+		goto err_restore_page;
+
+	ret = ytphy_read_ext(phydev, YT8824_C1_COARSE_CFG_REG);
+	if (ret < 0)
+		goto err_restore_page;
+
+	ret &= ~(BIT(10) | BIT(9) | BIT(8));
+	tmp = (val_2 & (BIT(7) | BIT(6) | BIT(5))) >> 5;
+	ret |= (tmp << 8);
+	ret = ytphy_write_ext(phydev, YT8824_C1_COARSE_CFG_REG, ret);
+	if (ret < 0)
+		goto err_restore_page;
+
+	/* optimized Serdes RX */
+	ctrl = FIELD_PREP(YT8824_CSR_AFE_VCM_CFG, 0x5);
+	ctrl |= FIELD_PREP(YT8824_CSR_AFE_MANUAL_CTRL_1P25G, 0);
+	ctrl |= FIELD_PREP(YT8824_CSR_AFE_MANUAL_CTRL_3P125G, 0);
+	mask = YT8824_CSR_AFE_VCM_CFG | YT8824_CSR_AFE_MANUAL_CTRL_1P25G |
+	       YT8824_CSR_AFE_MANUAL_CTRL_3P125G;
+	ret = ytphy_modify_ext(phydev, YT8824_CSR_AFE_CTRL_REG, mask, ctrl);
+	if (ret < 0)
+		goto err_restore_page;
+
+	ctrl = FIELD_PREP(YT8824_DFE_TAP_POLARITY, 1);
+	ctrl |= FIELD_PREP(YT8824_DFE_IDAC_TUNE, 0x3);
+	mask = YT8824_DFE_TAP_POLARITY | YT8824_DFE_IDAC_TUNE;
+	ret = ytphy_modify_ext(phydev, YT8824_DFE_CTRL_REG, mask, ctrl);
+	if (ret < 0)
+		goto err_restore_page;
+
+	ctrl = FIELD_PREP(YT8824_CSR_CDR_OFFSET_DATA, 0x7C);
+	mask = YT8824_CSR_CDR_OFFSET_DATA;
+	ret = ytphy_modify_ext(phydev, YT8824_CSR_CDR_CTRL_REG, mask, ctrl);
+	if (ret < 0)
+		goto err_restore_page;
+
+	ctrl = FIELD_PREP(YT8824_DFE_VDAC_CODE_THR, 0x7F);
+	mask = YT8824_DFE_VDAC_CODE_THR;
+	ret = ytphy_modify_ext(phydev, YT8824_DFE_VDAC_CODE_REG, mask, ctrl);
+	if (ret < 0)
+		goto err_restore_page;
+
+	ctrl = FIELD_PREP(YT8824_RX_SPARE_REG, 0xff08);
+	mask = YT8824_RX_SPARE_REG;
+	ret = ytphy_modify_ext(phydev, YT8824_RX_SPARE_CTRL_REG, mask, ctrl);
+	if (ret < 0)
+		goto err_restore_page;
+
+	/* optimized Serdes TX */
+	ctrl = FIELD_PREP(YT8824_DFE_VDAC_TUNE, 0x1);
+	ctrl |= FIELD_PREP(YT8824_DFE_VDAC_SEL, 0x0);
+	mask = YT8824_DFE_VDAC_TUNE | YT8824_DFE_VDAC_SEL;
+	ret = ytphy_modify_ext(phydev, YT8824_DFE_VDAC_CTRL_REG, mask, ctrl);
+	if (ret < 0)
+		goto err_restore_page;
+
+	ctrl = FIELD_PREP(YT8824_CSR_TX_PRE_SEL, 0x6);
+	mask = YT8824_CSR_TX_PRE_SEL;
+	ret = ytphy_modify_ext(phydev, YT8824_CSR_TX_PRE_REG, mask, ctrl);
+	if (ret < 0)
+		goto err_restore_page;
+
+	/* Serdes manual config */
+	ctrl = FIELD_PREP(YT8824_CSR_AFE_CTLE_BW, 0x0);
+	mask = YT8824_CSR_AFE_CTLE_BW;
+	ret = ytphy_modify_ext(phydev, YT8824_CSR_AFE_CTRL1_REG, mask, ctrl);
+	if (ret < 0)
+		goto err_restore_page;
+
+	ctrl = FIELD_PREP(YT8824_CSR_AFE_PGA_BW, 0x7);
+	ctrl |= FIELD_PREP(YT8824_CSR_AFE_BUF_BW, 0x7);
+	mask = YT8824_CSR_AFE_PGA_BW | YT8824_CSR_AFE_BUF_BW;
+	ret = ytphy_modify_ext(phydev, YT8824_CSR_AFE_CTRL2_REG, mask, ctrl);
+	if (ret < 0)
+		goto err_restore_page;
+
+	ctrl = FIELD_PREP(YT8824_CSR_AFE_MANUAL_CTRL_10P3125G, 0x1);
+	mask = YT8824_CSR_AFE_MANUAL_CTRL_10P3125G;
+	ret = ytphy_modify_ext(phydev, YT8824_CSR_AFE_CTRL_REG, mask, ctrl);
+	if (ret < 0)
+		goto err_restore_page;
+
+	/* restart calibration */
+	ctrl = FIELD_PREP(YT8824_CUR_TX_SEQ, 0x5);
+	ctrl |= FIELD_PREP(YT8824_CUR_RX_SEQ, 0x6);
+	ctrl |= FIELD_PREP(YT8824_CALIB_SEQ_FINISH, 1);
+	ctrl |= FIELD_PREP(YT8824_CALIB_SEQ_SW_RST, 1);
+	mask = YT8824_CUR_TX_SEQ | YT8824_CUR_RX_SEQ |
+	       YT8824_CALIB_SEQ_FINISH | YT8824_CALIB_SEQ_SW_RST;
+	ret = ytphy_modify_ext(phydev, YT8824_CSR_DCC_CAL_CTRL_REG, mask, ctrl);
+	if (ret < 0)
+		goto err_restore_page;
+
+	ctrl = FIELD_PREP(YT8824_VDAC_AMP_THR_MED, 0x7F);
+	ctrl |= FIELD_PREP(YT8824_VDAC_AMP_THR_SHT, 0xFF);
+	mask = YT8824_VDAC_AMP_THR_MED | YT8824_VDAC_AMP_THR_SHT;
+	ret = ytphy_modify_ext(phydev, YT8824_TRAINING_CTRL_REG, mask, ctrl);
+	if (ret < 0)
+		goto err_restore_page;
+
+	ctrl = FIELD_PREP(YT8824_VDAC_AMP_THR_MED, 0x7F);
+	ctrl |= FIELD_PREP(YT8824_VDAC_AMP_THR_SHT, 0x7F);
+	mask = YT8824_VDAC_AMP_THR_MED | YT8824_VDAC_AMP_THR_SHT;
+	ret = ytphy_modify_ext(phydev, YT8824_TRAINING_CTRL_REG, mask, ctrl);
+	if (ret < 0)
+		goto err_restore_page;
+
+	/* restart to calibration */
+	ret = ytphy_write_ext(phydev, YT8824_RESTART_CAL_CTRL_REG, 0x0040);
+	if (ret < 0)
+		goto err_restore_page;
+
+	ret = ytphy_write_ext(phydev, YT8824_RESTART_CAL_CTRL_REG, 0x0);
+	if (ret < 0)
+		goto err_restore_page;
+
+err_restore_page:
+	return phy_restore_page(phydev, old_page, ret);
+}
+
+/**
+ * yt8824_config_init() - phy initializatioin
+ * @phydev: a pointer to a &struct phy_device
+ *
+ * Returns: 0 or negative errno code
+ */
+static int yt8824_config_init(struct phy_device *phydev)
+{
+	struct yt8824_shared_priv *priv = phy_package_get_priv(phydev);
+	int ret;
+
+	mutex_lock(&priv->shared_lock);
+	if (priv->package_mode == PHY_INTERFACE_MODE_INTERNAL) {
+		ret = yt8824_config_utp_init_paged(phydev);
+		if (ret < 0)
+			goto err;
+	} else {
+		if (!priv->sds_initialized) {
+			ret = yt8824_extern_config_sds_init_paged(phydev);
+			if (ret < 0)
+				goto err;
+			priv->sds_initialized = true;
+		}
+		/*
+		 * Configuring the MII registers of the SDS,
+		 * which are private to each channel.
+		 */
+		ret = yt8824_extern_sds_softreset(phydev);
+		if (ret < 0)
+			goto err;
+
+		ret = yt8824_config_utp_init_paged(phydev);
 		if (ret < 0)
-			goto err_restore_page;
+			goto err;
 	}
+	mutex_unlock(&priv->shared_lock);
+	ret = yt8824_soft_reset(phydev);
 
-err_restore_page:
-	return phy_restore_page(phydev, old_page, ret);
+	phydev_dbg(phydev, "%s done, phy addr: %d\n", __func__,
+		   phydev->mdio.addr);
+	return ret;
+err:
+	mutex_unlock(&priv->shared_lock);
+	return ret;
 }
 
 static int yt8531_set_wol(struct phy_device *phydev,
@@ -3104,6 +4565,450 @@ static int yt8821_resume(struct phy_device *phydev)
 	return yt8821_modify_utp_fiber_bmcr(phydev, BMCR_PDOWN, 0);
 }
 
+/**
+ * yt8824_get_features - read mmd register to get 2.5G capability
+ * @phydev: target phy_device struct
+ *
+ * Returns: 0 or negative errno code
+ */
+static int yt8824_get_features(struct phy_device *phydev)
+{
+	struct yt8824_shared_priv *priv = phy_package_get_priv(phydev);
+	int ret;
+
+	mutex_lock(&priv->shared_lock);
+	ret = phy8824_page_write_with_lock(phydev, YT8824_RSSR_UTP_SPACE);
+	if (ret < 0)
+		goto err;
+	ret = yt8821_get_features(phydev);
+
+err:
+	mutex_unlock(&priv->shared_lock);
+	return ret;
+}
+
+/**
+ * yt8824_aneg_done()  - check negotiation state.
+ * @phydev: a pointer to a &struct phy_device
+ *
+ * Returns: auto-negotiation complete status or negative errno code
+ */
+static int yt8824_aneg_done(struct phy_device *phydev)
+{
+	struct yt8824_shared_priv *priv = phy_package_get_priv(phydev);
+	int auto_neg;
+	int ret;
+
+	mutex_lock(&priv->shared_lock);
+	ret = phy8824_page_write_with_lock(phydev, YT8824_RSSR_UTP_SPACE);
+	if (ret < 0)
+		goto err;
+
+	ret = phy_read(phydev, MII_BMSR);
+	if (ret < 0)
+		goto err;
+	mutex_unlock(&priv->shared_lock);
+	auto_neg = !!(ret & BMSR_ANEGCOMPLETE);
+
+	phydev_dbg(phydev, "%s, phy addr: %d, auto negotiation done: %d\n",
+		   __func__, phydev->mdio.addr, auto_neg);
+	return auto_neg;
+err:
+	mutex_unlock(&priv->shared_lock);
+	return ret;
+}
+
+/**
+ * yt8824_read_status_paged() -  determines the speed and duplex of one page
+ * @phydev: a pointer to a &struct phy_device
+ *
+ * Returns: 0 or negative errno code
+ */
+static int yt8824_read_status_paged(struct phy_device *phydev)
+{
+	int ret;
+	int val;
+
+	ret = phy8824_page_write_with_lock(phydev, YT8824_RSSR_UTP_SPACE);
+	if (ret < 0)
+		return ret;
+
+	ret = genphy_read_status(phydev);
+	if (ret < 0)
+		return ret;
+
+	if (phydev->autoneg == AUTONEG_ENABLE && phydev->autoneg_complete) {
+		ret = genphy_c45_read_lpa(phydev);
+		if (ret < 0)
+			return ret;
+	}
+
+	if (!phydev->link) {
+		phydev->speed = SPEED_UNKNOWN;
+		phydev->duplex = DUPLEX_UNKNOWN;
+		if (phydev->autoneg == AUTONEG_ENABLE)
+			phy_resolve_aneg_pause(phydev);
+		return 0;
+	}
+
+	ret = phy_read(phydev, YTPHY_SPECIFIC_STATUS_REG);
+	if (ret < 0)
+		return ret;
+
+	val = ret;
+
+	yt8821_adjust_status(phydev, val);
+
+	if (phydev->autoneg == AUTONEG_ENABLE)
+		phy_resolve_aneg_pause(phydev);
+
+	return 0;
+}
+
+/**
+ * yt8824_read_status() -  determines the negotiated speed and duplex
+ * @phydev: a pointer to a &struct phy_device
+ *
+ * Returns: 0 or negative errno code
+ */
+static int yt8824_read_status(struct phy_device *phydev)
+{
+	struct yt8824_shared_priv *priv = phy_package_get_priv(phydev);
+	int ret;
+
+	mutex_lock(&priv->shared_lock);
+	ret = yt8824_read_status_paged(phydev);
+	mutex_unlock(&priv->shared_lock);
+
+	return ret;
+}
+
+/**
+ * yt8824_utp_power_on(): utp power on.
+ * @phydev: a pointer to a &struct phy_device
+ *
+ * Returns: 0 or negative errno code
+ */
+static int yt8824_utp_power_on(struct phy_device *phydev)
+{
+	int ret = 0;
+
+	ret = phy8824_page_write_with_lock(phydev, YT8824_RSSR_UTP_SPACE);
+	if (ret < 0)
+		return ret;
+
+	return phy_modify(phydev, MII_BMCR, BMCR_PDOWN | BMCR_ISOLATE, 0x0);
+}
+
+/**
+ * yt8824_utp_power_down(): utp power down.
+ * @phydev: a pointer to a &struct phy_device
+ *
+ * Returns: 0 or negative errno code
+ */
+static int yt8824_utp_power_down(struct phy_device *phydev)
+{
+	int ret;
+
+	ret = phy8824_page_write_with_lock(phydev, YT8824_RSSR_UTP_SPACE);
+	if (ret < 0)
+		return ret;
+
+	return phy_modify(phydev, MII_BMCR, BMCR_PDOWN, BMCR_PDOWN);
+}
+
+/**
+ * yt8824_power_on()  - set utp power on.
+ * @phydev: a pointer to a &struct phy_device
+ *
+ * NOTE: need WA like softreset
+ *
+ * Returns: 0 or negative errno code
+ */
+static int yt8824_power_on(struct phy_device *phydev)
+{
+	struct yt8824_shared_priv *priv = phy_package_get_priv(phydev);
+	int ret;
+	int r;
+
+	if (priv->package_mode == PHY_INTERFACE_MODE_INTERNAL) {
+		ret = yt8824_utp_set_template_test_mode(phydev,
+							MDIO_PMA_10GBT_TESTMODE_1);
+		if (ret < 0)
+			goto retry;
+
+		ret = yt8824_utp_power_on(phydev);
+		if (ret < 0)
+			goto retry;
+
+		ret = yt8824_utp_set_template_test_mode(phydev,
+							MDIO_PMA_10GBT_TESTMODE_NORMAL);
+		if (ret < 0)
+			goto retry;
+	} else {
+		ret = yt8824_utp_set_template_test_mode(phydev,
+							MDIO_PMA_10GBT_TESTMODE_1);
+		if (ret < 0)
+			goto retry;
+
+		ret = yt8824_sds_isolate_paged(phydev);
+		if (ret < 0)
+			goto retry;
+
+		ret = yt8824_utp_power_on(phydev);
+		if (ret < 0)
+			goto retry;
+
+		ret = yt8824_utp_set_template_test_mode(phydev,
+							MDIO_PMA_10GBT_TESTMODE_NORMAL);
+		if (ret < 0)
+			goto retry;
+
+		ret = yt8824_sds_isolate_and_softreset_paged(phydev);
+		if (ret < 0)
+			goto retry;
+	}
+	return 0;
+
+retry:
+	/*
+	 * If the PHY up operation succeeds but the subsequent operation
+	 * fails, revert to the default state.
+	 */
+	r = yt8824_utp_power_down(phydev);
+	if (ret >= 0 && r < 0)
+		ret = r;
+	ret = yt8824_restore_working_status(phydev, ret);
+	return ret;
+}
+
+/**
+ * yt8824_resume() - resume the hardware
+ * @phydev: a pointer to a &struct phy_device
+ *
+ * Returns: 0 or negative errno code
+ */
+static int yt8824_resume(struct phy_device *phydev)
+{
+	struct yt8824_shared_priv *priv = phy_package_get_priv(phydev);
+	int ret;
+
+	mutex_lock(&priv->shared_lock);
+	ret = yt8824_power_on(phydev);
+	mutex_unlock(&priv->shared_lock);
+
+	return ret;
+}
+
+/**
+ * yt8824_power_down()  - set utp power down.
+ * @phydev: a pointer to a &struct phy_device
+ *
+ * NOTE: need WA like softreset
+ *
+ * Returns: 0 or negative errno code
+ */
+static int yt8824_power_down(struct phy_device *phydev)
+{
+	struct yt8824_shared_priv *priv = phy_package_get_priv(phydev);
+	int ret;
+	int r;
+
+	if (priv->package_mode == PHY_INTERFACE_MODE_INTERNAL) {
+		ret = yt8824_utp_set_template_test_mode(phydev,
+							MDIO_PMA_10GBT_TESTMODE_1);
+		if (ret < 0)
+			goto retry;
+
+		ret = yt8824_utp_power_down(phydev);
+		if (ret < 0)
+			goto retry;
+
+		ret = yt8824_utp_set_template_test_mode(phydev,
+							MDIO_PMA_10GBT_TESTMODE_NORMAL);
+		if (ret < 0)
+			goto retry;
+	} else {
+		ret = yt8824_utp_set_template_test_mode(phydev,
+							MDIO_PMA_10GBT_TESTMODE_1);
+		if (ret < 0)
+			goto retry;
+
+		ret = yt8824_sds_isolate_paged(phydev);
+		if (ret < 0)
+			goto retry;
+
+		ret = yt8824_utp_power_down(phydev);
+		if (ret < 0)
+			goto retry;
+
+		ret = yt8824_utp_set_template_test_mode(phydev,
+							MDIO_PMA_10GBT_TESTMODE_NORMAL);
+		if (ret < 0)
+			goto retry;
+
+		ret = yt8824_sds_isolate_and_softreset_paged(phydev);
+		if (ret < 0)
+			goto retry;
+	}
+	return 0;
+
+retry:
+	/*
+	 * If the PHY down operation succeeds but the subsequent operation
+	 * fails, revert to the default state.
+	 */
+	r = yt8824_utp_power_on(phydev);
+	if (ret >= 0 && r < 0)
+		ret = r;
+	ret = yt8824_restore_working_status(phydev, ret);
+	return ret;
+}
+
+/**
+ * yt8824_suspend() - suspend the hardware
+ * @phydev: a pointer to a &struct phy_device
+ *
+ * Returns: 0 or negative errno code
+ */
+static int yt8824_suspend(struct phy_device *phydev)
+{
+	struct yt8824_shared_priv *priv = phy_package_get_priv(phydev);
+	int ret;
+
+	mutex_lock(&priv->shared_lock);
+	ret = yt8824_power_down(phydev);
+	mutex_unlock(&priv->shared_lock);
+
+	return ret;
+}
+
+/**
+ * yt8824_config_aneg() - config negotiation
+ * @phydev: a pointer to a &struct phy_device
+ *
+ * Returns: 0 or negative errno code
+ */
+static int yt8824_config_aneg(struct phy_device *phydev)
+{
+	struct yt8824_shared_priv *priv = phy_package_get_priv(phydev);
+	int phy_ctrl = 0;
+	int ret;
+
+	mutex_lock(&priv->shared_lock);
+	ret = phy8824_page_write_with_lock(phydev, YT8824_RSSR_UTP_SPACE);
+	if (ret < 0)
+		goto err;
+
+	/*
+	 * Only advertise 2.5G when autoneg is enabled, or when 2.5G is
+	 * explicitly forced.  When a different speed is forced, clear
+	 * ADV2_5G so a 2.5G-capable link partner cannot negotiate 2.5G.
+	 * __genphy_config_aneg() only rewrites the
+	 * clause 22 registers on the forced-speed path, so it will not
+	 * clear this bit.
+	 */
+	if ((phydev->autoneg == AUTONEG_ENABLE ||
+	     phydev->speed == SPEED_2500) &&
+	    linkmode_test_bit(ETHTOOL_LINK_MODE_2500baseT_Full_BIT,
+			      phydev->advertising))
+		phy_ctrl = MDIO_AN_10GBT_CTRL_ADV2_5G;
+
+	ret = phy_modify_mmd_changed(phydev, MDIO_MMD_AN, MDIO_AN_10GBT_CTRL,
+				     MDIO_AN_10GBT_CTRL_ADV2_5G, phy_ctrl);
+	if (ret < 0)
+		goto err;
+
+	ret = __genphy_config_aneg(phydev, ret);
+
+err:
+	mutex_unlock(&priv->shared_lock);
+	return ret;
+}
+
+/**
+ * phy_mode_check() - check if mode names the PHY interface.
+ * @mode: PHY interface mode string
+ * @interface: PHY interface mode to compare against
+ *
+ * Return: true if @mode matches @interface, false otherwise.
+ */
+static bool phy_mode_check(const char *mode, int interface)
+{
+	return !strcasecmp(mode, phy_modes(interface));
+}
+
+/**
+ * yt8824_phy_package_probe_once()  - init phy package for phy8824.
+ * @phydev: a pointer to a &struct phy_device
+ *
+ * Returns: 0 or negative errno code
+ */
+static int yt8824_phy_package_probe_once(struct phy_device *phydev)
+{
+	struct yt8824_shared_priv *priv = phy_package_get_priv(phydev);
+	struct device_node *np = phy_package_get_node(phydev);
+	const char *mode;
+
+	if (!priv || !np) {
+		phydev_err(phydev, "%s: missing shared priv or DT node\n",
+			   __func__);
+		return -EINVAL;
+	}
+	/* Initialise shared lock for YT8824 */
+	mutex_init(&priv->shared_lock);
+	priv->sds_initialized = false;
+	priv->package_mode = PHY_INTERFACE_MODE_INTERNAL;
+	if (!of_property_read_string(np, "motorcomm,package-mode",
+				     &mode)) {
+		if (phy_mode_check(mode, PHY_INTERFACE_MODE_INTERNAL)) {
+			priv->package_mode = PHY_INTERFACE_MODE_INTERNAL;
+		} else if (phy_mode_check(mode,
+					  PHY_INTERFACE_MODE_10G_QXGMII)) {
+			priv->package_mode = PHY_INTERFACE_MODE_10G_QXGMII;
+		} else {
+			phydev_err(phydev, "unsupported package-mode %s\n",
+				   mode);
+			return -EINVAL;
+		}
+	} else {
+		phydev_err(phydev, "missing package-mode in PHY package node.\n");
+		return -EINVAL;
+	}
+
+	return 0;
+}
+
+/**
+ * yt8824_probe() - phy8824 probe.
+ * @phydev: a pointer to a &struct phy_device
+ *
+ * Returns: 0 or negative errno code
+ */
+static int yt8824_probe(struct phy_device *phydev)
+{
+	struct device *dev = &phydev->mdio.dev;
+	struct yt8824_shared_priv *shared_priv;
+	int ret;
+
+	ret = devm_of_phy_package_join(dev, phydev, sizeof(*shared_priv));
+	if (ret)
+		return ret;
+
+	/* Ensure other PHY probes wait for shared mutex initialization. */
+	phy_package_lock(phydev);
+	if (phy_package_probe_once(phydev)) {
+		ret = yt8824_phy_package_probe_once(phydev);
+		if (ret) {
+			phy_package_unlock(phydev);
+			return ret;
+		}
+	}
+	phy_package_unlock(phydev);
+
+	return 0;
+}
+
 static struct phy_driver motorcomm_phy_drvs[] = {
 	{
 		PHY_ID_MATCH_EXACT(PHY_ID_YT8511),
@@ -3190,13 +5095,29 @@ static struct phy_driver motorcomm_phy_drvs[] = {
 		.suspend		= yt8821_suspend,
 		.resume			= yt8821_resume,
 	},
+	{
+		PHY_ID_MATCH_EXACT(PHY_ID_YT8824),
+		.name = "YT8824 Quad Ports 2.5Gbps Ethernet",
+		.get_features = yt8824_get_features,
+		.read_page = yt8824_read_page,
+		.write_page = yt8824_write_page,
+		.probe = yt8824_probe,
+		.config_aneg = yt8824_config_aneg,
+		.aneg_done = yt8824_aneg_done,
+		.config_init = yt8824_config_init,
+		.read_status = yt8824_read_status,
+		.soft_reset = yt8824_soft_reset,
+		.suspend = yt8824_suspend,
+		.resume = yt8824_resume,
+	},
 };
 
 module_phy_driver(motorcomm_phy_drvs);
 
-MODULE_DESCRIPTION("Motorcomm 8511/8521/8531/8531S/8821 PHY driver");
+MODULE_DESCRIPTION("Motorcomm 8511/8521/8531/8531S/8821/8824 PHY driver");
 MODULE_AUTHOR("Peter Geis");
 MODULE_AUTHOR("Frank");
+MODULE_AUTHOR("Kyle");
 MODULE_LICENSE("GPL");
 
 static const struct mdio_device_id __maybe_unused motorcomm_tbl[] = {
@@ -3206,6 +5127,7 @@ static const struct mdio_device_id __maybe_unused motorcomm_tbl[] = {
 	{ PHY_ID_MATCH_EXACT(PHY_ID_YT8531) },
 	{ PHY_ID_MATCH_EXACT(PHY_ID_YT8531S) },
 	{ PHY_ID_MATCH_EXACT(PHY_ID_YT8821) },
+	{ PHY_ID_MATCH_EXACT(PHY_ID_YT8824) },
 	{ /* sentinel */ }
 };
 
diff --git a/drivers/net/phy/phy-c45.c b/drivers/net/phy/phy-c45.c
index 870920311f9a0..c5f5753f7194b 100644
--- a/drivers/net/phy/phy-c45.c
+++ b/drivers/net/phy/phy-c45.c
@@ -1408,6 +1408,29 @@ int genphy_c45_fast_retrain(struct phy_device *phydev, bool enable)
 }
 EXPORT_SYMBOL_GPL(genphy_c45_fast_retrain);
 
+/**
+ * genphy_c45_template_testmode - configure template testmode registers
+ * @phydev: target phy_device struct
+ * @test_mode: testmode includes Normal to Test mode 7
+ *
+ * Description: Set template testmode include Normal to Test mode 7
+ *
+ * Return: 0 on success, or a negative error code on failure (e.g. register
+ * read/write error).
+ */
+int genphy_c45_template_testmode(struct phy_device *phydev, u16 test_mode)
+{
+	u16 ctrl;
+
+	if (test_mode > MDIO_PMA_10GBT_TESTMODE_7)
+		return -EOPNOTSUPP;
+
+	ctrl = FIELD_PREP(MDIO_PMA_10GBT_TESTMODE_MASK, test_mode);
+	return phy_modify_mmd(phydev, MDIO_MMD_PMAPMD, MDIO_PMA_10GBT_TESTMODE,
+			      MDIO_PMA_10GBT_TESTMODE_MASK, ctrl);
+}
+EXPORT_SYMBOL_GPL(genphy_c45_template_testmode);
+
 /**
  * genphy_c45_plca_get_cfg - get PLCA configuration from standard registers
  * @phydev: target phy_device struct
diff --git a/include/linux/phy.h b/include/linux/phy.h
index 7c5098a0dd6cd..b9dee2655e6ba 100644
--- a/include/linux/phy.h
+++ b/include/linux/phy.h
@@ -2357,6 +2357,7 @@ int genphy_c45_loopback(struct phy_device *phydev, bool enable, int speed);
 int genphy_c45_pma_resume(struct phy_device *phydev);
 int genphy_c45_pma_suspend(struct phy_device *phydev);
 int genphy_c45_fast_retrain(struct phy_device *phydev, bool enable);
+int genphy_c45_template_testmode(struct phy_device *phydev, u16 test_mode);
 int genphy_c45_plca_get_cfg(struct phy_device *phydev,
 			    struct phy_plca_cfg *plca_cfg);
 int genphy_c45_plca_set_cfg(struct phy_device *phydev,
diff --git a/include/uapi/linux/mdio.h b/include/uapi/linux/mdio.h
index 06f4bc3c20c71..353ca13c64fca 100644
--- a/include/uapi/linux/mdio.h
+++ b/include/uapi/linux/mdio.h
@@ -63,6 +63,7 @@
 /* Media-dependent registers. */
 #define MDIO_PMA_10GBT_SWAPPOL	130	/* 10GBASE-T pair swap & polarity */
 #define MDIO_PMA_10GBT_TXPWR	131	/* 10GBASE-T TX power control */
+#define MDIO_PMA_10GBT_TESTMODE 132 /* Test mode control */
 #define MDIO_PMA_10GBT_SNR	133	/* 10GBASE-T SNR margin, lane A.
 					 * Lanes B-D are numbered 134-136. */
 #define MDIO_PMA_10GBR_FSRT_CSR	147	/* 10GBASE-R fast retrain status and control */
@@ -320,6 +321,17 @@
 /* PMA 10GBASE-R Fast Retrain status and control register. */
 #define MDIO_PMA_10GBR_FSRT_ENABLE	0x0001	/* Fast retrain enable */
 
+/* PMA 10GBASE-T Template Test Mode Register*/
+#define MDIO_PMA_10GBT_TESTMODE_MASK GENMASK(15, 13) /* Template test mode */
+#define MDIO_PMA_10GBT_TESTMODE_NORMAL 0x0 /* Template Normal */
+#define MDIO_PMA_10GBT_TESTMODE_1 0x1 /* Template TestMode1 */
+#define MDIO_PMA_10GBT_TESTMODE_2 0x2 /* Template TestMode2 */
+#define MDIO_PMA_10GBT_TESTMODE_3 0x3 /* Template TestMode3 */
+#define MDIO_PMA_10GBT_TESTMODE_4 0x4 /* Template TestMode4 */
+#define MDIO_PMA_10GBT_TESTMODE_5 0x5 /* Template TestMode5 */
+#define MDIO_PMA_10GBT_TESTMODE_6 0x6 /* Template TestMode6 */
+#define MDIO_PMA_10GBT_TESTMODE_7 0x7 /* Template TestMode7 */
+
 /* PCS 10GBASE-R/-T status register 1. */
 #define MDIO_PCS_10GBRT_STAT1_BLKLK	0x0001	/* Block lock attained */
 

3/2 2026/10/15 18:34 llm patch-evaluator
0m Model:
gemini-3.8-flash

Args:
null

Results:
null

Tokens:
							input: 37185
							output: 25
							thoughts: 1057
						

Thoughts:
**Fuzzing Evaluation: YT8824 Ethernet PHY Driver**

Okay, so the task is to determine if this patch, which adds support for the Motorcomm YT8824 2.5G Ethernet PHY, warrants fuzzing with Syzkaller. Let's break this down. First, I need to understand what's changed. The patch introduces a new driver for a quad-port 2.5G Ethernet PHY. It includes:

*   **Documentation:**  A Device Tree binding for the YT8824. This is good; it means this device can be specified at boot time.
*   **MAINTAINERS:** The MAINTAINERS file updated, making the device's maintainers clear.
*   **Kconfig:**  Changes to the Kconfig file, including a `select PHY_PACKAGE` option and a description update.
*   **The Core Driver (`motorcomm.c`):** This is where the real meat of it is.  New helper functions are added for register access, power management, auto-negotiation, and various PHY-specific operations (e.g., UTP configuration, SDS isolation, soft resets). Several functions are added to enable paged register accesses. The driver itself is a `struct phy_driver`. This is a *lot* of new code.
*   **phy-c45.c:** Added `genphy_c45_template_testmode` to support test mode configurations.
*   **Header Files:** Updates to `phy.h` and `mdio.h` to export the new function and define registers.

So, this patch adds significant new functionality, which involves register manipulation, PHY initialization, auto-negotiation, power management, and probably interrupt handling (based on the `YTPHY_INTERRUPT_ENABLE_REG` and WOL modifications).

Now, the crucial question: can we reach this code effectively in a virtualized fuzzing environment?  Specifically, the standard QEMU setup on amd64.  The YT8824 is an Ethernet PHY.  PHY drivers are *MDIO* devices. The driver itself is instantiated as `struct phy_driver`. Can a user-space process instantiate a PHY driver? This is important. Can we probe these devices without needing *actual* Motorcomm YT8824 hardware?

I need to quickly assess if the kernel includes some sort of MDIO emulation or virtual PHY functionality, which would allow us to at least *instantiate* this driver and potentially exercise some of its code paths in a standard setup. I'm thinking I should run a quick `grepper` query in the kernel source to look for "mdio emulation" or look for pseudo-devices in `phylib` or `mdio`. My goal is to see if there's any way to simulate or access MDIO/PHY devices without specific hardware dependencies. If I can at least *probe* this driver in QEMU, that's a good starting point. If I can do that, then fuzzing makes sense. If this is tied to specific hardware and there's *no* emulation, then it's going to be a hard sell for Syzkaller unless we want to get really involved in hardware setup.



4/2 2026/10/15 18:34 tool grepper
0m Args:
{
  "Expression": "genphy_c45_template_testmode"
}

Results:
{
  "Output": "drivers/net/phy/motorcomm.c=993=static int yt8824_utp_set_template_test_mode(struct phy_device *phydev,\n--\ndrivers/net/phy/motorcomm.c-1001-\ndrivers/net/phy/motorcomm.c:1002:\treturn genphy_c45_template_testmode(phydev, test_mode);\ndrivers/net/phy/motorcomm.c-1003-}\n--\ndrivers/net/phy/motorcomm.c=1172=static int yt8824_config_utp_init_paged(struct phy_device *phydev)\n--\ndrivers/net/phy/motorcomm.c-1672-\t/* reset */\ndrivers/net/phy/motorcomm.c:1673:\tret = genphy_c45_template_testmode(phydev, MDIO_PMA_10GBT_TESTMODE_1);\ndrivers/net/phy/motorcomm.c-1674-\tif (ret \u003c 0)\n--\ndrivers/net/phy/motorcomm.c-1685-\ndrivers/net/phy/motorcomm.c:1686:\tret = genphy_c45_template_testmode(phydev,\ndrivers/net/phy/motorcomm.c-1687-\t\t\t\t\t   MDIO_PMA_10GBT_TESTMODE_NORMAL);\n--\ndrivers/net/phy/motorcomm.c-1698-err_restore_normal:\ndrivers/net/phy/motorcomm.c:1699:\tr = genphy_c45_template_testmode(phydev,\ndrivers/net/phy/motorcomm.c-1700-\t\t\t\t\t MDIO_PMA_10GBT_TESTMODE_NORMAL);\n--\ndrivers/net/phy/phy-c45.c=1409=EXPORT_SYMBOL_GPL(genphy_c45_fast_retrain);\n--\ndrivers/net/phy/phy-c45.c-1411-/**\ndrivers/net/phy/phy-c45.c:1412: * genphy_c45_template_testmode - configure template testmode registers\ndrivers/net/phy/phy-c45.c-1413- * @phydev: target phy_device struct\n--\ndrivers/net/phy/phy-c45.c-1420- */\ndrivers/net/phy/phy-c45.c:1421:int genphy_c45_template_testmode(struct phy_device *phydev, u16 test_mode)\ndrivers/net/phy/phy-c45.c-1422-{\n--\ndrivers/net/phy/phy-c45.c-1431-}\ndrivers/net/phy/phy-c45.c:1432:EXPORT_SYMBOL_GPL(genphy_c45_template_testmode);\ndrivers/net/phy/phy-c45.c-1433-\n--\ninclude/linux/phy.h=2359=int genphy_c45_fast_retrain(struct phy_device *phydev, bool enable);\ninclude/linux/phy.h:2360:int genphy_c45_template_testmode(struct phy_device *phydev, u16 test_mode);\ninclude/linux/phy.h-2361-int genphy_c45_plca_get_cfg(struct phy_device *phydev,\n"
}

5/2 2026/10/15 18:34 llm patch-evaluator
0m Model:
gemini-3.8-flash

Args:
null

Results:
null

Tokens:
							input: 39830
							output: 24
							thoughts: 541
						

Thoughts:
**My Analysis of `genphy_c45_template_testmode` and its Usage**

Okay, let's break this down. First, `genphy_c45_template_testmode` is added to `drivers/net/phy/phy-c45.c`, which initially seems straightforward. But its only *explicit* call appears to be within the `yt8824_*` functions in `drivers/net/phy/motorcomm.c`. That raises a key question: is it *only* used there? I've confirmed that, yes, it seems to be exclusively called within `motorcomm.c`.

Now, the natural follow-up is: can we even *instantiate* a `motorcomm` PHY or any PHY device with `PHY_ID_YT8824`? The instantiation process is crucial. I need to understand how these PHY devices are brought to life. Linux phylib provides two main paths. The primary method involves probing over the MDIO bus. The MDIO bus scans PHY addresses (0..31), reading the MII_PHYSID1 and MII_PHYSID2 registers, and matching the driver's `phy_driver.phy_id` with the device's `phy_driver.phy_id_mask`. The other route is via the Device Tree (`of_mdiobus_register`).

Aha! This is where `yt8824_probe` becomes interesting. Looking at this `yt8824_probe` it appears that the PHY device's package mode is pulled directly from the device tree and this is checked via the following code:

```c
static int yt8824_phy_package_probe_once(struct phy_device *phydev)
{
	struct yt8824_shared_priv *priv = phy_package_get_priv(phydev);
	struct device_node *np = phy_package_get_node(phydev);
	const char *mode;

	if (!priv || !np) {
		phydev_err(phydev, "%s: missing shared priv or DT node\n",
			   __func__);
		return -EINVAL;
	}
...
	if (!of_property_read_string(np, "motorcomm,package-mode",
				     &mode)) {
...
```

And then here:
```c
static int yt8824_probe(struct phy_device *phydev)
{
	struct device *dev = &phydev->mdio.dev;
	struct yt8824_shared_priv *shared_priv;
	int ret;

	ret = devm_of_phy_package_join(dev, phydev, sizeof(*shared_priv));
	if (ret)
		return ret;
```

This is where the Device Tree comes back into play, the use of `devm_of_phy_package_join` is important. I need to understand the role of `devm_of_phy_package_join` to see how these PHYs are connected.



6/2 2026/10/15 18:34 tool grepper
0m Args:
{
  "Expression": "devm_of_phy_package_join"
}

Results:
{
  "Output": "drivers/net/phy/motorcomm.c=4988=static int yt8824_probe(struct phy_device *phydev)\n--\ndrivers/net/phy/motorcomm.c-4993-\ndrivers/net/phy/motorcomm.c:4994:\tret = devm_of_phy_package_join(dev, phydev, sizeof(*shared_priv));\ndrivers/net/phy/motorcomm.c-4995-\tif (ret)\n--\ndrivers/net/phy/phy_package.c=405=EXPORT_SYMBOL_GPL(devm_phy_package_join);\n--\ndrivers/net/phy/phy_package.c-407-/**\ndrivers/net/phy/phy_package.c:408: * devm_of_phy_package_join - resource managed of_phy_package_join()\ndrivers/net/phy/phy_package.c-409- * @dev: device that is registering this PHY package\n--\ndrivers/net/phy/phy_package.c-416- */\ndrivers/net/phy/phy_package.c:417:int devm_of_phy_package_join(struct device *dev, struct phy_device *phydev,\ndrivers/net/phy/phy_package.c-418-\t\t\t     size_t priv_size)\n--\ndrivers/net/phy/phy_package.c-438-}\ndrivers/net/phy/phy_package.c:439:EXPORT_SYMBOL_GPL(devm_of_phy_package_join);\ndrivers/net/phy/phy_package.c-440-\n--\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);\ndrivers/net/phy/phylib.h:34:int devm_of_phy_package_join(struct device *dev, struct phy_device *phydev,\ndrivers/net/phy/phylib.h-35-\t\t\t     size_t priv_size);\n--\ndrivers/net/phy/qcom/qca807x.c=694=static int qca807x_probe(struct phy_device *phydev)\n--\ndrivers/net/phy/qcom/qca807x.c-701-\ndrivers/net/phy/qcom/qca807x.c:702:\tret = devm_of_phy_package_join(dev, phydev, sizeof(*shared_priv));\ndrivers/net/phy/qcom/qca807x.c-703-\tif (ret)\n--\ndrivers/net/phy/xpowers/acx00.c=195=static int acx00_ephy_init_package(struct phy_device *phydev,\n--\ndrivers/net/phy/xpowers/acx00.c-235-\ndrivers/net/phy/xpowers/acx00.c:236:\tret = devm_of_phy_package_join(dev, phydev, 0);\ndrivers/net/phy/xpowers/acx00.c-237-\tif (ret)\n"
}

7/2 2026/10/15 18:34 llm patch-evaluator
0m Model:
gemini-3.8-flash

Args:
null

Results:
null

Tokens:
							input: 41903
							output: 39
							thoughts: 30
						

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

**Diving into `devm_of_phy_package_join` in `phy_package.c`**

Alright, let's get into the nitty-gritty. I'm focusing on `drivers/net/phy/phy_package.c`, specifically around `devm_of_phy_package_join`. I need to refresh my memory on the device tree integration for PHY packages. My immediate thought is, "What's the context here? How does this function fit within the overall PHY driver initialization and teardown?" I'm expecting this is where we're binding PHY instances to the package, likely based on DT entries. Is it using the standard `of_device_id` tables or a custom mechanism? And what kind of resource management is being handled with `devm_`? Are we ensuring proper PHY registration, power management, and clock handling, all managed using the device resource management APIs? I'm curious about the error handling - what happens if a PHY isn't found, or if there's a problem with the DT bindings? Does it fall back, or error out hard? I want to understand how it's handling potential circular dependencies, and if any precautions are being taken to prevent those issues. I'll need to pay close attention to the memory allocation and deallocation to ensure no leaks, and that the resources are properly freed when the device is unbound. And finally, I'll need to cross-reference this with the documentation to see if there are any specific guidelines or limitations associated with this function.



8/2 2026/10/15 18:34 tool read-file
0m Args:
{
  "File": "drivers/net/phy/phy_package.c",
  "FirstLine": 400,
  "LineCount": 45
}

Results:
{
  "Contents": " 400:\t\t\tdevres_free(ptr);\n 401:\t\t}\n 402:\t\n 403:\t\treturn ret;\n 404:\t}\n 405:\tEXPORT_SYMBOL_GPL(devm_phy_package_join);\n 406:\t\n 407:\t/**\n 408:\t * devm_of_phy_package_join - resource managed of_phy_package_join()\n 409:\t * @dev: device that is registering this PHY package\n 410:\t * @phydev: target phy_device struct\n 411:\t * @priv_size: if non-zero allocate this amount of bytes for private data\n 412:\t *\n 413:\t * Managed of_phy_package_join(). Shared storage fetched by this function,\n 414:\t * phy_package_leave() is automatically called on driver detach. See\n 415:\t * of_phy_package_join() for more information.\n 416:\t */\n 417:\tint devm_of_phy_package_join(struct device *dev, struct phy_device *phydev,\n 418:\t\t\t\t     size_t priv_size)\n 419:\t{\n 420:\t\tstruct phy_device **ptr;\n 421:\t\tint ret;\n 422:\t\n 423:\t\tptr = devres_alloc(devm_phy_package_leave, sizeof(*ptr),\n 424:\t\t\t\t   GFP_KERNEL);\n 425:\t\tif (!ptr)\n 426:\t\t\treturn -ENOMEM;\n 427:\t\n 428:\t\tret = of_phy_package_join(phydev, priv_size);\n 429:\t\n 430:\t\tif (!ret) {\n 431:\t\t\t*ptr = phydev;\n 432:\t\t\tdevres_add(dev, ptr);\n 433:\t\t} else {\n 434:\t\t\tdevres_free(ptr);\n 435:\t\t}\n 436:\t\n 437:\t\treturn ret;\n 438:\t}\n 439:\tEXPORT_SYMBOL_GPL(devm_of_phy_package_join);\n 440:\t\n 441:\tMODULE_DESCRIPTION(\"PHY package support\");\n 442:\tMODULE_LICENSE(\"GPL\");\n"
}

9/2 2026/10/15 18:34 llm patch-evaluator
0m Model:
gemini-3.8-flash

Args:
null

Results:
null

Tokens:
							input: 42930
							output: 39
							thoughts: 16
						

Thoughts:
Okay, here's my attempt at summarizing the thought process, tailored for an expert audience, and written in the first person:

**Analyzing `of_phy_package_join` Functionality**

Alright, let's dive into this `of_phy_package_join` function. My initial thought process involves a careful unpacking of the function's naming conventions. The "of" suggests an OpenFlow context, so I'm immediately picturing the data structures and control messages associated with that protocol. "Phy" implies a physical layer component, hinting that this function might be dealing with the interaction between the OpenFlow controller and the underlying physical network infrastructure—potentially even hardware. The "package_join" aspect really solidifies this. I'm assuming it relates to bringing new physical resources, perhaps network interface cards, switches, or even entire physical links, into an OpenFlow management domain. It’s likely involved in the admission and registration phases of a new physical entity.

My mind immediately begins to generate some key questions: what specific information is being exchanged? Does it involve authentication? How does the controller verify the physical device's capabilities and identity? What security measures are in place? Is there a process for discovering these physical components within the network, or does this function work after the device has been made known? How is the hardware represented within the controller and what data structures are associated with it? This also makes me consider different implementations. Is it a synchronous or asynchronous event, is the underlying transport reliable, and how can the behaviour be tuned? Is it a single device or a set of devices?

I'm mentally mapping this function's place in the broader OpenFlow framework: where does it sit relative to the switch discovery process, the table configuration, the flow installation, and the event handling? Is this a core functionality, or something more esoteric? The implementation details could be critical. Does it employ standard OpenFlow messages, proprietary extensions, or a combination of both? Looking at a codebase, I'd need to consider how this function interacts with the device, and the other methods, to verify what it is doing, and what it does not do.



10/2 2026/10/15 18:35 tool read-file
0m Args:
{
  "File": "drivers/net/phy/phy_package.c",
  "FirstLine": 310,
  "LineCount": 50
}

Results:
{
  "Contents": " 310:\t\t\treturn -EINVAL;\n 311:\t\n 312:\t\tif (!of_node_name_eq(package_node, \"ethernet-phy-package\")) {\n 313:\t\t\tret = -EINVAL;\n 314:\t\t\tgoto exit;\n 315:\t\t}\n 316:\t\n 317:\t\tif (of_property_read_u32(package_node, \"reg\", \u0026base_addr)) {\n 318:\t\t\tret = -EINVAL;\n 319:\t\t\tgoto exit;\n 320:\t\t}\n 321:\t\n 322:\t\tret = phy_package_join(phydev, base_addr, priv_size);\n 323:\t\tif (ret)\n 324:\t\t\tgoto exit;\n 325:\t\n 326:\t\tphydev-\u003eshared-\u003enp = package_node;\n 327:\t\n 328:\t\treturn 0;\n 329:\texit:\n 330:\t\tof_node_put(package_node);\n 331:\t\treturn ret;\n 332:\t}\n 333:\tEXPORT_SYMBOL_GPL(of_phy_package_join);\n 334:\t\n 335:\t/**\n 336:\t * phy_package_leave - leave a common PHY group\n 337:\t * @phydev: target phy_device struct\n 338:\t *\n 339:\t * This leaves a PHY group created by phy_package_join(). If this phydev\n 340:\t * was the last user of the shared data between the group, this data is\n 341:\t * freed. Resets the phydev-\u003eshared pointer to NULL.\n 342:\t */\n 343:\tvoid phy_package_leave(struct phy_device *phydev)\n 344:\t{\n 345:\t\tstruct phy_package_shared *shared = phydev-\u003eshared;\n 346:\t\tstruct mii_bus *bus = phydev-\u003emdio.bus;\n 347:\t\n 348:\t\tif (!shared)\n 349:\t\t\treturn;\n 350:\t\n 351:\t\t/* Decrease the node refcount on leave if present */\n 352:\t\tif (shared-\u003enp)\n 353:\t\t\tof_node_put(shared-\u003enp);\n 354:\t\n 355:\t\tif (refcount_dec_and_mutex_lock(\u0026shared-\u003erefcnt, \u0026bus-\u003eshared_lock)) {\n 356:\t\t\tbus-\u003eshared[shared-\u003ebase_addr] = NULL;\n 357:\t\t\tmutex_unlock(\u0026bus-\u003eshared_lock);\n 358:\t\t\tkfree(shared-\u003epriv);\n 359:\t\t\tkfree(shared);\n"
}

11/2 2026/10/15 18:35 llm patch-evaluator
0m Model:
gemini-3.8-flash

Args:
null

Results:
null

Tokens:
							input: 44152
							output: 39
							thoughts: 33
						

Thoughts:
Here's a summary of my thought process, as requested:

**Diving into `of_phy_package_join`**

Okay, let's dissect this `of_phy_package_join` function. I need to get a clear picture of what's happening internally. My first step is to zero in on the core logic. Lines 280-315 of `phy_package.c` should contain the meat of the operation – the most critical segment of the function. I'll read through that section carefully, paying close attention to any conditionals, loops, memory allocations, and data structure interactions. I'm looking for the key algorithm, how data is processed, and any potential bottlenecks or areas of optimization. Let's see what gems are hidden in those lines!



12/2 2026/10/15 18:35 tool read-file
0m Args:
{
  "File": "drivers/net/phy/phy_package.c",
  "FirstLine": 280,
  "LineCount": 40
}

Results:
{
  "Contents": " 280:\t * @phydev: target phy_device struct\n 281:\t * @priv_size: if non-zero allocate this amount of bytes for private data\n 282:\t *\n 283:\t * This is a variant of phy_package_join for PHY package defined in DT.\n 284:\t *\n 285:\t * The parent node of the @phydev is checked as a valid PHY package node\n 286:\t * structure (by matching the node name \"ethernet-phy-package\") and the\n 287:\t * base_addr for the PHY package is passed to phy_package_join.\n 288:\t *\n 289:\t * With this configuration the shared struct will also have the np value\n 290:\t * filled to use additional DT defined properties in PHY specific\n 291:\t * probe_once and config_init_once PHY package OPs.\n 292:\t *\n 293:\t * Returns \u003c 0 on error, 0 on success. Esp. calling phy_package_join()\n 294:\t * with the same cookie but a different priv_size is an error. Or a parent\n 295:\t * node is not detected or is not valid or doesn't match the expected node\n 296:\t * name for PHY package.\n 297:\t */\n 298:\tint of_phy_package_join(struct phy_device *phydev, size_t priv_size)\n 299:\t{\n 300:\t\tstruct device_node *node = phydev-\u003emdio.dev.of_node;\n 301:\t\tstruct device_node *package_node;\n 302:\t\tu32 base_addr;\n 303:\t\tint ret;\n 304:\t\n 305:\t\tif (!node)\n 306:\t\t\treturn -EINVAL;\n 307:\t\n 308:\t\tpackage_node = of_get_parent(node);\n 309:\t\tif (!package_node)\n 310:\t\t\treturn -EINVAL;\n 311:\t\n 312:\t\tif (!of_node_name_eq(package_node, \"ethernet-phy-package\")) {\n 313:\t\t\tret = -EINVAL;\n 314:\t\t\tgoto exit;\n 315:\t\t}\n 316:\t\n 317:\t\tif (of_property_read_u32(package_node, \"reg\", \u0026base_addr)) {\n 318:\t\t\tret = -EINVAL;\n 319:\t\t\tgoto exit;\n"
}

13/2 2026/10/15 18:35 llm patch-evaluator
0m Model:
gemini-3.8-flash

Args:
null

Results:
null

Tokens:
							input: 45052
							output: 31
							thoughts: 975
						

Thoughts:
**Analyzing the Reachability of an Ethernet PHY Driver in Syzkaller**

Okay, so I'm looking at this `of_phy_package_join` function, and it immediately throws an error if it doesn't find a Device Tree node. That's a red flag for `amd64`, since Device Tree isn't typically used there; ACPI is the standard. Even on ARM/embedded systems, it needs an `ethernet-phy-package` DT node. My first thought is, can Syzkaller *even* create or modify Device Tree overlays at runtime? I know it runs on x86_64, which doesn't natively use DT.

Then it hits me: Forget DT for a second. Can *any* MDIO bus or PHY device be created or accessed at all in Syzkaller or standard virtualized environments like QEMU or GCE? That's the core question here.

Time to revisit the fuzzing guidelines. Section 1 stresses that reachability is paramount. We can only fuzz code that *executes* in these environments, using software-emulated devices. Section 2 is the killer: we return `WorthFuzzing=false` if the code falls into several categories including "Structurally unreachable hardware."

Now, let's connect the dots. Is this Motorcomm YT8824 Ethernet PHY structurally unreachable? It's a 4-port 2.5G PHY chip, so my next question is, what hardware *does* it run on? Then, crucially, does QEMU emulate it? QEMU has internal PHY emulations or emulates popular network adapters like e1000, virtio-net, etc, but does it do so with the YT8824?

No. QEMU does not emulate the Motorcomm YT8824 PHY. QEMU's emulated PHYs are integrated with other devices.

Now, a more remote thought, can USB network adapters use external PHYs or the motorcomm PHY? Time to search the kernel for any references to `PHY_ID_YT8824` or any code that attaches Motorcomm PHYs. That'll be the next step.



14/2 2026/10/15 18:35 tool grepper
0m Args:
{
  "Expression": "PHY_ID_YT8824|PHY_ID_YT85"
}

Results:
{
  "Output": "drivers/net/phy/motorcomm.c-21-\ndrivers/net/phy/motorcomm.c:22:#define PHY_ID_YT8511\t\t0x0000010a\ndrivers/net/phy/motorcomm.c:23:#define PHY_ID_YT8521\t\t0x0000011a\ndrivers/net/phy/motorcomm.c:24:#define PHY_ID_YT8522\t\t0x4f51e928\ndrivers/net/phy/motorcomm.c:25:#define PHY_ID_YT8531\t\t0x4f51e91b\ndrivers/net/phy/motorcomm.c:26:#define PHY_ID_YT8531S\t\t0x4f51e91a\ndrivers/net/phy/motorcomm.c-27-#define PHY_ID_YT8821\t\t0x4f51ea19\ndrivers/net/phy/motorcomm.c:28:#define PHY_ID_YT8824\t\t0x4f51e8b8\ndrivers/net/phy/motorcomm.c-29-/* YT8521/YT8531S/YT8821 Register Overview\n--\ndrivers/net/phy/motorcomm.c=2357=static int ytphy_rgmii_clk_delay_config(struct phy_device *phydev)\n--\ndrivers/net/phy/motorcomm.c-2388-\tcase PHY_INTERFACE_MODE_GMII:\ndrivers/net/phy/motorcomm.c:2389:\t\tif (phydev-\u003edrv-\u003ephy_id != PHY_ID_YT8531S)\ndrivers/net/phy/motorcomm.c-2390-\t\t\treturn -EOPNOTSUPP;\n--\ndrivers/net/phy/motorcomm.c=2530=static int yt8521_probe(struct phy_device *phydev)\n--\ndrivers/net/phy/motorcomm.c-2589-\ndrivers/net/phy/motorcomm.c:2590:\tif (phydev-\u003edrv-\u003ephy_id == PHY_ID_YT8521) {\ndrivers/net/phy/motorcomm.c-2591-\t\tswitch (freq) {\n--\ndrivers/net/phy/motorcomm.c-2616-\t\t}\ndrivers/net/phy/motorcomm.c:2617:\t} else if (phydev-\u003edrv-\u003ephy_id == PHY_ID_YT8531S) {\ndrivers/net/phy/motorcomm.c-2618-\t\tswitch (freq) {\n--\ndrivers/net/phy/motorcomm.c=5012=static struct phy_driver motorcomm_phy_drvs[] = {\ndrivers/net/phy/motorcomm.c-5013-\t{\ndrivers/net/phy/motorcomm.c:5014:\t\tPHY_ID_MATCH_EXACT(PHY_ID_YT8511),\ndrivers/net/phy/motorcomm.c-5015-\t\t.name\t\t= \"YT8511 Gigabit Ethernet\",\n--\ndrivers/net/phy/motorcomm.c-5022-\t{\ndrivers/net/phy/motorcomm.c:5023:\t\tPHY_ID_MATCH_EXACT(PHY_ID_YT8521),\ndrivers/net/phy/motorcomm.c-5024-\t\t.name\t\t= \"YT8521 Gigabit Ethernet\",\n--\ndrivers/net/phy/motorcomm.c-5042-\t{\ndrivers/net/phy/motorcomm.c:5043:\t\tPHY_ID_MATCH_EXACT(PHY_ID_YT8522),\ndrivers/net/phy/motorcomm.c-5044-\t\t.name\t\t= \"YT8522 100 Megabit Ethernet\",\n--\ndrivers/net/phy/motorcomm.c-5050-\t{\ndrivers/net/phy/motorcomm.c:5051:\t\tPHY_ID_MATCH_EXACT(PHY_ID_YT8531),\ndrivers/net/phy/motorcomm.c-5052-\t\t.name\t\t= \"YT8531 Gigabit Ethernet\",\n--\ndrivers/net/phy/motorcomm.c-5064-\t{\ndrivers/net/phy/motorcomm.c:5065:\t\tPHY_ID_MATCH_EXACT(PHY_ID_YT8531S),\ndrivers/net/phy/motorcomm.c-5066-\t\t.name\t\t= \"YT8531S Gigabit Ethernet\",\n--\ndrivers/net/phy/motorcomm.c-5098-\t{\ndrivers/net/phy/motorcomm.c:5099:\t\tPHY_ID_MATCH_EXACT(PHY_ID_YT8824),\ndrivers/net/phy/motorcomm.c-5100-\t\t.name = \"YT8824 Quad Ports 2.5Gbps Ethernet\",\n--\ndrivers/net/phy/motorcomm.c=5123=static const struct mdio_device_id __maybe_unused motorcomm_tbl[] = {\ndrivers/net/phy/motorcomm.c:5124:\t{ PHY_ID_MATCH_EXACT(PHY_ID_YT8511) },\ndrivers/net/phy/motorcomm.c:5125:\t{ PHY_ID_MATCH_EXACT(PHY_ID_YT8521) },\ndrivers/net/phy/motorcomm.c:5126:\t{ PHY_ID_MATCH_EXACT(PHY_ID_YT8522) },\ndrivers/net/phy/motorcomm.c:5127:\t{ PHY_ID_MATCH_EXACT(PHY_ID_YT8531) },\ndrivers/net/phy/motorcomm.c:5128:\t{ PHY_ID_MATCH_EXACT(PHY_ID_YT8531S) },\ndrivers/net/phy/motorcomm.c-5129-\t{ PHY_ID_MATCH_EXACT(PHY_ID_YT8821) },\ndrivers/net/phy/motorcomm.c:5130:\t{ PHY_ID_MATCH_EXACT(PHY_ID_YT8824) },\ndrivers/net/phy/motorcomm.c-5131-\t{ /* sentinel */ }\n"
}

15/2 2026/10/15 18:35 llm patch-evaluator
0m Model:
gemini-3.8-flash

Args:
null

Results:
null

Tokens:
							input: 48100
							output: 19
							thoughts: 29
						

Thoughts:
Here's my thought process, as if I were considering this myself:

**Investigating `dwmac-motorcomm.c`**

Okay, first things first, I need to understand what this file, `dwmac-motorcomm.c`, actually *is* and if it even touches anything relevant to my current focus. Is this some kind of driver? A helper module? A piece of middleware? The "dwmac" part suggests something related to a Digital Wideband MAC or similar, which often deals with networking or communication interfaces. The "motorcomm" part might be a custom name or related to Motor Communications. I'll need to figure out the context.

My immediate next step is to either look at the file's contents, cross-reference its included headers, or maybe grep for it in relevant areas of the codebase to see how it's used. Finding other source files that call it is the best starting point. Let's see if it's being *used* anywhere - that'll give me clues about its purpose and function. If it's a driver, it should be registered in the system some how. Otherwise it would be an unused file.



16/2 2026/10/15 18:35 tool grepper
0m Args:
{
  "Expression": "dwmac-motorcomm"
}

Results:
{
  "Output": "MAINTAINERS=18425=S:\tMaintained\nMAINTAINERS:18426:F:\tdrivers/net/ethernet/stmicro/stmmac/dwmac-motorcomm.c\nMAINTAINERS-18427-\n--\ndrivers/net/ethernet/stmicro/stmmac/Makefile=53=obj-$(CONFIG_DWMAC_LOONGSON)\t+= dwmac-loongson.o\ndrivers/net/ethernet/stmicro/stmmac/Makefile:54:obj-$(CONFIG_DWMAC_MOTORCOMM)\t+= dwmac-motorcomm.o\ndrivers/net/ethernet/stmicro/stmmac/Makefile-55-stmmac-pci-objs:= stmmac_pci.o\n--\ndrivers/net/ethernet/stmicro/stmmac/dwmac-motorcomm.c-21-\ndrivers/net/ethernet/stmicro/stmmac/dwmac-motorcomm.c:22:#define DRIVER_NAME \"dwmac-motorcomm\"\ndrivers/net/ethernet/stmicro/stmmac/dwmac-motorcomm.c-23-\n"
}

17/2 2026/10/15 18:35 llm patch-evaluator
0m Model:
gemini-3.8-flash

Args:
null

Results:
null

Tokens:
							input: 48686
							output: 47
							thoughts: 16
						

Thoughts:
Okay, let's dive into this. Here's my take on those thoughts, as if they're my own:

**Investigating `dwmac-motorcomm.c`**

Alright, let's get down to brass tacks. I've got `dwmac-motorcomm.c` in front of me. The name alone hints at a connection to a specific, perhaps specialized, instance of a DWMAC (DesignWare MAC) controller, likely from MotorComm. Given my understanding of these devices, I suspect this file holds the driver code for a MotorComm Ethernet PHY or perhaps the specific configuration options that enable it to interface effectively with a particular SoC. I'll need to figure out exactly what functions and data structures it defines, how it handles initialization and interrupt routines. I'm especially interested in how it differs from a generic DWMAC driver, and if there are specific register accesses to the PHY or anything like that. I'm prepared to dissect the code and identify the hardware-specific details, paying close attention to any unique error handling or power management routines that might be present. Let's start with a quick overview of the file and then dive into the key functions.



18/2 2026/10/15 18:35 tool read-file
0m Args:
{
  "File": "drivers/net/ethernet/stmicro/stmmac/dwmac-motorcomm.c",
  "FirstLine": 1,
  "LineCount": 60
}

Results:
{
  "Contents": "   1:\t// SPDX-License-Identifier: GPL-2.0-only\n   2:\t/*\n   3:\t * DWMAC glue driver for Motorcomm PCI Ethernet controllers\n   4:\t *\n   5:\t * Copyright (c) 2025-2026 Yao Zi \u003cme@ziyao.cc\u003e\n   6:\t */\n   7:\t\n   8:\t#include \u003clinux/bits.h\u003e\n   9:\t#include \u003clinux/delay.h\u003e\n  10:\t#include \u003clinux/dev_printk.h\u003e\n  11:\t#include \u003clinux/io.h\u003e\n  12:\t#include \u003clinux/iopoll.h\u003e\n  13:\t#include \u003clinux/module.h\u003e\n  14:\t#include \u003clinux/pci.h\u003e\n  15:\t#include \u003clinux/slab.h\u003e\n  16:\t#include \u003clinux/stmmac.h\u003e\n  17:\t\n  18:\t#include \"dwmac4.h\"\n  19:\t#include \"stmmac.h\"\n  20:\t#include \"stmmac_libpci.h\"\n  21:\t\n  22:\t#define DRIVER_NAME \"dwmac-motorcomm\"\n  23:\t\n  24:\t#define PCI_VENDOR_ID_MOTORCOMM\t\t\t0x1f0a\n  25:\t\n  26:\t/* Register definition */\n  27:\t#define EPHY_CTRL\t\t\t\t0x1004\n  28:\t/* Clearing this bit asserts resets for internal MDIO bus and PHY */\n  29:\t#define  EPHY_MDIO_PHY_RESET\t\t\tBIT(0)\n  30:\t#define OOB_WOL_CTRL\t\t\t\t0x1010\n  31:\t#define  OOB_WOL_CTRL_DIS\t\t\tBIT(0)\n  32:\t#define MGMT_INT_CTRL0\t\t\t\t0x1100\n  33:\t#define INT_MODERATION\t\t\t\t0x1108\n  34:\t#define  INT_MODERATION_RX\t\t\tGENMASK(11, 0)\n  35:\t#define  INT_MODERATION_TX\t\t\tGENMASK(27, 16)\n  36:\t#define EFUSE_OP_CTRL_0\t\t\t\t0x1500\n  37:\t#define  EFUSE_OP_MODE\t\t\t\tGENMASK(1, 0)\n  38:\t#define   EFUSE_OP_ROW_READ\t\t\t0x1\n  39:\t#define  EFUSE_OP_START\t\t\t\tBIT(2)\n  40:\t#define  EFUSE_OP_ADDR\t\t\t\tGENMASK(15, 8)\n  41:\t#define EFUSE_OP_CTRL_1\t\t\t\t0x1504\n  42:\t#define  EFUSE_OP_DONE\t\t\t\tBIT(1)\n  43:\t#define  EFUSE_OP_RD_DATA\t\t\tGENMASK(31, 24)\n  44:\t#define SYS_RESET\t\t\t\t0x152c\n  45:\t#define  SYS_RESET_RESET\t\t\tBIT(31)\n  46:\t#define GMAC_OFFSET\t\t\t\t0x2000\n  47:\t\n  48:\t/* Constants */\n  49:\t#define EFUSE_READ_TIMEOUT_US\t\t\t20000\n  50:\t#define EFUSE_PATCH_REGION_OFFSET\t\t18\n  51:\t#define EFUSE_PATCH_MAX_NUM\t\t\t39\n  52:\t#define EFUSE_ADDR_MACA0LR\t\t\t0x1520\n  53:\t#define EFUSE_ADDR_MACA0HR\t\t\t0x1524\n  54:\t\n  55:\tstruct motorcomm_efuse_patch {\n  56:\t\t__le16 addr;\n  57:\t\t__le32 data;\n  58:\t} __packed;\n  59:\t\n  60:\tstruct dwmac_motorcomm_priv {\n"
}

19/2 2026/10/15 18:35 llm patch-evaluator
0m Model:
gemini-3.8-flash

Args:
null

Results:
null

Tokens:
							input: 50006
							output: 49
							thoughts: 94
						

Thoughts:
Okay, here's my take on those thoughts, framed for an expert like myself:

**Diving into the Motorcomm Ethernet Controller Driver**

Alright, so I'm looking at `dwmac-motorcomm.c` – a PCI Ethernet controller driver designed specifically for Motorcomm PCI devices. Specifically, it's keyed to vendor ID `0x1f0a`. A quick scan tells me that it's leaning heavily on the `stmmac` framework, which naturally implies an MDIO bus scan under the hood. Now, before I go any further, I want to confirm precisely which PCI devices are supported and how. Let's head over to lines 200 through 260 of `dwmac-motorcomm.c`, and get a good look at the PCI device ID checks. That'll be the definitive list of what this driver actually *covers*. Gotta make sure my assumptions are on point before digging deeper.



20/2 2026/10/15 18:35 tool read-file
0m Args:
{
  "File": "drivers/net/ethernet/stmicro/stmmac/dwmac-motorcomm.c",
  "FirstLine": 200,
  "LineCount": 50
}

Results:
{
  "Contents": " 200:\t\t */\n 201:\t\tmotorcomm_deassert_mdio_phy_reset(priv);\n 202:\t\tmotorcomm_init(priv);\n 203:\t\n 204:\t\treturn 0;\n 205:\t}\n 206:\t\n 207:\tstatic struct plat_stmmacenet_data *\n 208:\tmotorcomm_default_plat_data(struct pci_dev *pdev)\n 209:\t{\n 210:\t\tstruct plat_stmmacenet_data *plat;\n 211:\t\tstruct device *dev = \u0026pdev-\u003edev;\n 212:\t\n 213:\t\tplat = stmmac_plat_dat_alloc(dev);\n 214:\t\tif (!plat)\n 215:\t\t\treturn NULL;\n 216:\t\n 217:\t\tplat-\u003emdio_bus_data = devm_kzalloc(dev, sizeof(*plat-\u003emdio_bus_data),\n 218:\t\t\t\t\t\t   GFP_KERNEL);\n 219:\t\tif (!plat-\u003emdio_bus_data)\n 220:\t\t\treturn NULL;\n 221:\t\n 222:\t\tplat-\u003eaxi = devm_kzalloc(dev, sizeof(*plat-\u003eaxi), GFP_KERNEL);\n 223:\t\tif (!plat-\u003eaxi)\n 224:\t\t\treturn NULL;\n 225:\t\n 226:\t\tplat-\u003edma_cfg-\u003epbl\t\t= DEFAULT_DMA_PBL;\n 227:\t\tplat-\u003edma_cfg-\u003epblx8\t\t= true;\n 228:\t\tplat-\u003edma_cfg-\u003etxpbl\t\t= 32;\n 229:\t\tplat-\u003edma_cfg-\u003erxpbl\t\t= 32;\n 230:\t\tplat-\u003edma_cfg-\u003eeame\t\t= true;\n 231:\t\tplat-\u003edma_cfg-\u003emixed_burst\t= true;\n 232:\t\n 233:\t\tplat-\u003eaxi-\u003eaxi_wr_osr_lmt\t= 1;\n 234:\t\tplat-\u003eaxi-\u003eaxi_rd_osr_lmt\t= 1;\n 235:\t\tplat-\u003eaxi-\u003eaxi_blen_regval\t= DMA_AXI_BLEN4 | DMA_AXI_BLEN8 |\n 236:\t\t\t\t\t\t  DMA_AXI_BLEN16 | DMA_AXI_BLEN32;\n 237:\t\n 238:\t\tplat-\u003ebus_id\t\t= pci_dev_id(pdev);\n 239:\t\tplat-\u003ephy_interface\t= PHY_INTERFACE_MODE_GMII;\n 240:\t\t/*\n 241:\t\t * YT6801 requires an 25MHz clock input/oscillator to function, which\n 242:\t\t * is likely the source of CSR clock.\n 243:\t\t */\n 244:\t\tplat-\u003eclk_csr\t\t= STMMAC_CSR_20_35M;\n 245:\t\tplat-\u003etx_coe\t\t= 1;\n 246:\t\tplat-\u003erx_coe\t\t= 1;\n 247:\t\tplat-\u003eclk_ref_rate\t= 125000000;\n 248:\t\tplat-\u003ecore_type\t\t= DWMAC_CORE_GMAC4;\n 249:\t\tplat-\u003esuspend\t\t= stmmac_pci_plat_suspend;\n"
}

21/2 2026/10/15 18:35 llm patch-evaluator
0m Model:
gemini-3.8-flash

Args:
null

Results:
null

Tokens:
							input: 51230
							output: 24
							thoughts: 438
						

Thoughts:
**Analyzing the Motorcomm Ethernet Controller and PHY**

Okay, so I'm looking at this YT6801 – that's a PCI Ethernet controller, a physical piece of hardware. The problem is, QEMU isn't emulating this specific device. Not ideal. Then there's the YT8824. This one's interesting because it's a PHY chip, and it's configured using Device Tree bindings. I'm seeing the bindings documentation, `Documentation/devicetree/bindings/net/motorcomm,yt8824.yaml`, which describes it as a PHY package with four PHYs, indicated with `compatible: "motorcomm,yt8824-package"`.

I'm digging into `yt8824_probe`, and `devm_of_phy_package_join` is the key function here. It seems to need a Device Tree node with `ethernet-phy-package` and a `reg` property. And that's where I'm hitting a wall. On amd64, there's no Device Tree, and I can't construct DT nodes for an `ethernet-phy-package` through userspace syscalls. `devm_of_phy_package_join` is going to return `-EINVAL` without the DT.

More fundamentally, I'm starting to wonder, is there *any* virtual or software device in this setup that could possibly instantiate a `phy_device` with the `PHY_ID_YT8824`? That's what I need to figure out. I need to find a way to create a `phy_device`. Let's check for any virtual MDIO or PHY devices in the kernel or syzkaller. I need to search for how they're created. Specifically, I'll search for `alloc_mdio_bitbang`, `mdio_gpio`, or any other mentions of virtual MDIO.



22/2 2026/10/15 18:35 tool grepper
0m Args:
{
  "Expression": "mdio_gpio|mdio_bitbang"
}

Results:
{
  "Output": "\nFull output is too long, showing 200 out of 266 lines.\nUse more precise expression or PathPrefixes if possible.\n\nNumber of matching lines per file (13 files in total):\narch/arm/boot/dts/broadcom/bcm2711.dtsi:2\narch/arm/boot/dts/nxp/imx/imx51-zii-rdu1.dts:2\narch/arm/boot/dts/nxp/imx/imx51-zii-scu2-mezz.dts:2\narch/arm64/boot/dts/freescale/imx8mq-zii-ultra.dtsi:2\narch/powerpc/platforms/82xx/ep8248e.c:2\ndrivers/net/ethernet/8390/ax88796.c:6\ndrivers/net/ethernet/freescale/fs_enet/mii-bitbang.c:3\ndrivers/net/ethernet/renesas/ravb_main.c:3\ndrivers/net/ethernet/renesas/sh_eth.c:3\ndrivers/net/ethernet/ti/davinci_mdio.c:2\ndrivers/net/mdio/mdio-bitbang.c:4\ndrivers/net/mdio/mdio-gpio.c:34\ninclude/linux/mdio-bitbang.h:2\n\narch/arm/boot/dts/broadcom/bcm2711.dtsi=938=\t\tpin-irq {\n--\narch/arm/boot/dts/broadcom/bcm2711.dtsi-942-\t};\narch/arm/boot/dts/broadcom/bcm2711.dtsi:943:\trgmii_mdio_gpio28: rgmii-mdio-gpio28 {\narch/arm/boot/dts/broadcom/bcm2711.dtsi-944-\t\tpins-mdio {\n--\narch/arm/boot/dts/broadcom/bcm2711.dtsi-949-\t};\narch/arm/boot/dts/broadcom/bcm2711.dtsi:950:\trgmii_mdio_gpio37: rgmii-mdio-gpio37 {\narch/arm/boot/dts/broadcom/bcm2711.dtsi-951-\t\tpins-mdio {\n--\narch/arm/boot/dts/nxp/imx/imx51-zii-rdu1.dts=24=\taliases {\narch/arm/boot/dts/nxp/imx/imx51-zii-rdu1.dts:25:\t\tmdio-gpio0 = \u0026mdio_gpio;\narch/arm/boot/dts/nxp/imx/imx51-zii-rdu1.dts-26-\t\trtc0 = \u0026ds1341;\n--\narch/arm/boot/dts/nxp/imx/imx51-zii-rdu1.dts=154=\t\teeprom@0 {\n--\narch/arm/boot/dts/nxp/imx/imx51-zii-rdu1.dts-162-\narch/arm/boot/dts/nxp/imx/imx51-zii-rdu1.dts:163:\tmdio_gpio: mdio {\narch/arm/boot/dts/nxp/imx/imx51-zii-rdu1.dts-164-\t\tcompatible = \"virtual,mdio-gpio\";\n--\narch/arm/boot/dts/nxp/imx/imx51-zii-scu2-mezz.dts=25=\taliases {\narch/arm/boot/dts/nxp/imx/imx51-zii-scu2-mezz.dts:26:\t\tmdio-gpio0 = \u0026mdio_gpio;\narch/arm/boot/dts/nxp/imx/imx51-zii-scu2-mezz.dts-27-\t};\n--\narch/arm/boot/dts/nxp/imx/imx51-zii-scu2-mezz.dts=29=\tusb_vbus: regulator-usb-vbus {\n--\narch/arm/boot/dts/nxp/imx/imx51-zii-scu2-mezz.dts-39-\narch/arm/boot/dts/nxp/imx/imx51-zii-scu2-mezz.dts:40:\tmdio_gpio: mdio {\narch/arm/boot/dts/nxp/imx/imx51-zii-scu2-mezz.dts-41-\t\tcompatible = \"virtual,mdio-gpio\";\n--\narch/arm64/boot/dts/freescale/imx8mq-zii-ultra.dtsi=18=\tmdio0: mdio {\n--\narch/arm64/boot/dts/freescale/imx8mq-zii-ultra.dtsi-20-\t\tpinctrl-names = \"default\";\narch/arm64/boot/dts/freescale/imx8mq-zii-ultra.dtsi:21:\t\tpinctrl-0 = \u003c\u0026pinctrl_mdio_bitbang\u003e, \u003c\u0026pinctrl_fec1_phy_reset\u003e;\narch/arm64/boot/dts/freescale/imx8mq-zii-ultra.dtsi-22-\t\tgpios = \u003c\u0026gpio1 13 GPIO_ACTIVE_HIGH\u003e, /* MDC */\n--\narch/arm64/boot/dts/freescale/imx8mq-zii-ultra.dtsi=677=\t\t\tMX8MQ_IOMUXC_I2C4_SDA_I2C4_SDA\t\t\t0x400000a2\n--\narch/arm64/boot/dts/freescale/imx8mq-zii-ultra.dtsi-680-\narch/arm64/boot/dts/freescale/imx8mq-zii-ultra.dtsi:681:\tpinctrl_mdio_bitbang: bitbangmdiogrp {\narch/arm64/boot/dts/freescale/imx8mq-zii-ultra.dtsi-682-\t\tfsl,pins = \u003c\n--\narch/powerpc/platforms/82xx/ep8248e.c=109=static int ep8248e_mdio_probe(struct platform_device *ofdev)\n--\narch/powerpc/platforms/82xx/ep8248e.c-124-\narch/powerpc/platforms/82xx/ep8248e.c:125:\tbus = alloc_mdio_bitbang(\u0026ep8248e_mdio_ctrl);\narch/powerpc/platforms/82xx/ep8248e.c-126-\tif (!bus)\n--\narch/powerpc/platforms/82xx/ep8248e.c-138-err_free_bus:\narch/powerpc/platforms/82xx/ep8248e.c:139:\tfree_mdio_bitbang(bus);\narch/powerpc/platforms/82xx/ep8248e.c-140-\treturn ret;\n--\ndrivers/net/ethernet/8390/ax88796.c=459=static int ax_mii_init(struct net_device *dev)\n--\ndrivers/net/ethernet/8390/ax88796.c-467-\tax-\u003eaddr_memr = ei_local-\u003emem + AX_MEMR;\ndrivers/net/ethernet/8390/ax88796.c:468:\tax-\u003emii_bus = alloc_mdio_bitbang(\u0026ax-\u003ebb_ctrl);\ndrivers/net/ethernet/8390/ax88796.c-469-\tif (!ax-\u003emii_bus) {\n--\ndrivers/net/ethernet/8390/ax88796.c-480-\tif (err)\ndrivers/net/ethernet/8390/ax88796.c:481:\t\tgoto out_free_mdio_bitbang;\ndrivers/net/ethernet/8390/ax88796.c-482-\n--\ndrivers/net/ethernet/8390/ax88796.c-484-\ndrivers/net/ethernet/8390/ax88796.c:485: out_free_mdio_bitbang:\ndrivers/net/ethernet/8390/ax88796.c:486:\tfree_mdio_bitbang(ax-\u003emii_bus);\ndrivers/net/ethernet/8390/ax88796.c-487- out:\n--\ndrivers/net/ethernet/8390/ax88796.c=491=static int ax_open(struct net_device *dev)\n--\ndrivers/net/ethernet/8390/ax88796.c-534-\tmdiobus_unregister(ax-\u003emii_bus);\ndrivers/net/ethernet/8390/ax88796.c:535:\tfree_mdio_bitbang(ax-\u003emii_bus);\ndrivers/net/ethernet/8390/ax88796.c-536- failed_mii:\n--\ndrivers/net/ethernet/8390/ax88796.c=540=static int ax_close(struct net_device *dev)\n--\ndrivers/net/ethernet/8390/ax88796.c-557-\tmdiobus_unregister(ax-\u003emii_bus);\ndrivers/net/ethernet/8390/ax88796.c:558:\tfree_mdio_bitbang(ax-\u003emii_bus);\ndrivers/net/ethernet/8390/ax88796.c-559-\treturn 0;\n--\ndrivers/net/ethernet/freescale/fs_enet/mii-bitbang.c=149=static int fs_enet_mdio_probe(struct platform_device *ofdev)\n--\ndrivers/net/ethernet/freescale/fs_enet/mii-bitbang.c-160-\ndrivers/net/ethernet/freescale/fs_enet/mii-bitbang.c:161:\tnew_bus = alloc_mdio_bitbang(\u0026bitbang-\u003ectrl);\ndrivers/net/ethernet/freescale/fs_enet/mii-bitbang.c-162-\tif (!new_bus)\n--\ndrivers/net/ethernet/freescale/fs_enet/mii-bitbang.c-184-out_free_bus:\ndrivers/net/ethernet/freescale/fs_enet/mii-bitbang.c:185:\tfree_mdio_bitbang(new_bus);\ndrivers/net/ethernet/freescale/fs_enet/mii-bitbang.c-186-out_free_priv:\n--\ndrivers/net/ethernet/freescale/fs_enet/mii-bitbang.c=192=static void fs_enet_mdio_remove(struct platform_device *ofdev)\n--\ndrivers/net/ethernet/freescale/fs_enet/mii-bitbang.c-197-\tmdiobus_unregister(bus);\ndrivers/net/ethernet/freescale/fs_enet/mii-bitbang.c:198:\tfree_mdio_bitbang(bus);\ndrivers/net/ethernet/freescale/fs_enet/mii-bitbang.c-199-\tiounmap(bitbang-\u003edir);\n--\ndrivers/net/ethernet/renesas/ravb_main.c=2596=static int ravb_mdio_init(struct ravb_private *priv)\n--\ndrivers/net/ethernet/renesas/ravb_main.c-2608-\t/* MII controller setting */\ndrivers/net/ethernet/renesas/ravb_main.c:2609:\tpriv-\u003emii_bus = alloc_mdio_bitbang(\u0026priv-\u003emdiobb);\ndrivers/net/ethernet/renesas/ravb_main.c-2610-\tif (!priv-\u003emii_bus)\n--\ndrivers/net/ethernet/renesas/ravb_main.c-2640-out_free_bus:\ndrivers/net/ethernet/renesas/ravb_main.c:2641:\tfree_mdio_bitbang(priv-\u003emii_bus);\ndrivers/net/ethernet/renesas/ravb_main.c-2642-\treturn error;\n--\ndrivers/net/ethernet/renesas/ravb_main.c=2646=static int ravb_mdio_release(struct ravb_private *priv)\n--\ndrivers/net/ethernet/renesas/ravb_main.c-2651-\t/* Free bitbang info */\ndrivers/net/ethernet/renesas/ravb_main.c:2652:\tfree_mdio_bitbang(priv-\u003emii_bus);\ndrivers/net/ethernet/renesas/ravb_main.c-2653-\n--\ndrivers/net/ethernet/renesas/sh_eth.c=3034=static int sh_mdio_release(struct sh_eth_private *mdp)\n--\ndrivers/net/ethernet/renesas/sh_eth.c-3039-\t/* free bitbang info */\ndrivers/net/ethernet/renesas/sh_eth.c:3040:\tfree_mdio_bitbang(mdp-\u003emii_bus);\ndrivers/net/ethernet/renesas/sh_eth.c-3041-\n--\ndrivers/net/ethernet/renesas/sh_eth.c=3091=static int sh_mdio_init(struct sh_eth_private *mdp,\n--\ndrivers/net/ethernet/renesas/sh_eth.c-3111-\t/* MII controller setting */\ndrivers/net/ethernet/renesas/sh_eth.c:3112:\tmdp-\u003emii_bus = alloc_mdio_bitbang(\u0026bitbang-\u003ectrl);\ndrivers/net/ethernet/renesas/sh_eth.c-3113-\tif (!mdp-\u003emii_bus)\n--\ndrivers/net/ethernet/renesas/sh_eth.c-3146-out_free_bus:\ndrivers/net/ethernet/renesas/sh_eth.c:3147:\tfree_mdio_bitbang(mdp-\u003emii_bus);\ndrivers/net/ethernet/renesas/sh_eth.c-3148-\treturn ret;\n--\ndrivers/net/ethernet/ti/davinci_mdio.c=537=static int davinci_mdio_probe(struct platform_device *pdev)\n--\ndrivers/net/ethernet/ti/davinci_mdio.c-566-\tif (data-\u003emanual_mode)\ndrivers/net/ethernet/ti/davinci_mdio.c:567:\t\tdata-\u003ebus = alloc_mdio_bitbang(\u0026data-\u003ebb_ctrl);\ndrivers/net/ethernet/ti/davinci_mdio.c-568-\telse\n--\ndrivers/net/ethernet/ti/davinci_mdio.c=661=static void davinci_mdio_remove(struct platform_device *pdev)\n--\ndrivers/net/ethernet/ti/davinci_mdio.c-668-\t\tif (data-\u003emanual_mode)\ndrivers/net/ethernet/ti/davinci_mdio.c:669:\t\t\tfree_mdio_bitbang(data-\u003ebus);\ndrivers/net/ethernet/ti/davinci_mdio.c-670-\t}\n--\ndrivers/net/mdio/mdio-bitbang.c=229=EXPORT_SYMBOL(mdiobb_write_c45);\ndrivers/net/mdio/mdio-bitbang.c-230-\ndrivers/net/mdio/mdio-bitbang.c:231:struct mii_bus *alloc_mdio_bitbang(struct mdiobb_ctrl *ctrl)\ndrivers/net/mdio/mdio-bitbang.c-232-{\n--\ndrivers/net/mdio/mdio-bitbang.c-253-}\ndrivers/net/mdio/mdio-bitbang.c:254:EXPORT_SYMBOL(alloc_mdio_bitbang);\ndrivers/net/mdio/mdio-bitbang.c-255-\ndrivers/net/mdio/mdio-bitbang.c:256:void free_mdio_bitbang(struct mii_bus *bus)\ndrivers/net/mdio/mdio-bitbang.c-257-{\n--\ndrivers/net/mdio/mdio-bitbang.c-262-}\ndrivers/net/mdio/mdio-bitbang.c:263:EXPORT_SYMBOL(free_mdio_bitbang);\ndrivers/net/mdio/mdio-bitbang.c-264-\n--\ndrivers/net/mdio/mdio-gpio.c-31-\ndrivers/net/mdio/mdio-gpio.c:32:struct mdio_gpio_info {\ndrivers/net/mdio/mdio-gpio.c-33-\tstruct mdiobb_ctrl ctrl;\n--\ndrivers/net/mdio/mdio-gpio.c-36-\ndrivers/net/mdio/mdio-gpio.c:37:static int mdio_gpio_get_data(struct device *dev,\ndrivers/net/mdio/mdio-gpio.c:38:\t\t\t      struct mdio_gpio_info *bitbang)\ndrivers/net/mdio/mdio-gpio.c-39-{\n--\ndrivers/net/mdio/mdio-gpio.c=55=static void mdio_dir(struct mdiobb_ctrl *ctrl, int dir)\ndrivers/net/mdio/mdio-gpio.c-56-{\ndrivers/net/mdio/mdio-gpio.c:57:\tstruct mdio_gpio_info *bitbang =\ndrivers/net/mdio/mdio-gpio.c:58:\t\tcontainer_of(ctrl, struct mdio_gpio_info, ctrl);\ndrivers/net/mdio/mdio-gpio.c-59-\n--\ndrivers/net/mdio/mdio-gpio.c=76=static int mdio_get(struct mdiobb_ctrl *ctrl)\ndrivers/net/mdio/mdio-gpio.c-77-{\ndrivers/net/mdio/mdio-gpio.c:78:\tstruct mdio_gpio_info *bitbang =\ndrivers/net/mdio/mdio-gpio.c:79:\t\tcontainer_of(ctrl, struct mdio_gpio_info, ctrl);\ndrivers/net/mdio/mdio-gpio.c-80-\n--\ndrivers/net/mdio/mdio-gpio.c=84=static void mdio_set(struct mdiobb_ctrl *ctrl, int what)\ndrivers/net/mdio/mdio-gpio.c-85-{\ndrivers/net/mdio/mdio-gpio.c:86:\tstruct mdio_gpio_info *bitbang =\ndrivers/net/mdio/mdio-gpio.c:87:\t\tcontainer_of(ctrl, struct mdio_gpio_info, ctrl);\ndrivers/net/mdio/mdio-gpio.c-88-\n--\ndrivers/net/mdio/mdio-gpio.c=95=static void mdc_set(struct mdiobb_ctrl *ctrl, int what)\ndrivers/net/mdio/mdio-gpio.c-96-{\ndrivers/net/mdio/mdio-gpio.c:97:\tstruct mdio_gpio_info *bitbang =\ndrivers/net/mdio/mdio-gpio.c:98:\t\tcontainer_of(ctrl, struct mdio_gpio_info, ctrl);\ndrivers/net/mdio/mdio-gpio.c-99-\n--\ndrivers/net/mdio/mdio-gpio.c-102-\ndrivers/net/mdio/mdio-gpio.c:103:static const struct mdiobb_ops mdio_gpio_ops = {\ndrivers/net/mdio/mdio-gpio.c-104-\t.owner = THIS_MODULE,\n--\ndrivers/net/mdio/mdio-gpio.c-110-\ndrivers/net/mdio/mdio-gpio.c:111:static struct mii_bus *mdio_gpio_bus_init(struct device *dev,\ndrivers/net/mdio/mdio-gpio.c:112:\t\t\t\t\t  struct mdio_gpio_info *bitbang,\ndrivers/net/mdio/mdio-gpio.c-113-\t\t\t\t\t  int bus_id)\n--\ndrivers/net/mdio/mdio-gpio.c-116-\ndrivers/net/mdio/mdio-gpio.c:117:\tbitbang-\u003ectrl.ops = \u0026mdio_gpio_ops;\ndrivers/net/mdio/mdio-gpio.c-118-\ndrivers/net/mdio/mdio-gpio.c:119:\tnew_bus = alloc_mdio_bitbang(\u0026bitbang-\u003ectrl);\n\n"
}

23/2 2026/10/15 18:35 llm patch-evaluator
0m Model:
gemini-3.8-flash

Args:
null

Results:
null

Tokens:
							input: 57501
							output: 28
							thoughts: 961
						

Thoughts:
**WorthFuzzing Decision for Motorcomm PHY Driver**

Okay, let's break this down. My goal is to determine if `drivers/net/phy/motorcomm.c` and specifically the YT8824 PHY driver, are worth fuzzing. The guidelines are clear: I need to determine if this code is *reachable* in a standard virtualized environment like QEMU or Google Compute Engine (GCE), which primarily use software-emulated devices. The negative criteria are my gate.

First, I need to understand what this driver *does*. It's an Ethernet PHY driver for Motorcomm PHYs, specifically the YT8824, which is a physical Ethernet transceiver supporting 4x 2.5Gbps. So, to even execute any code in this driver, several conditions must be met:

1.  An MDIO bus must detect a PHY with PHY ID 0x4f51e8b8 *or* it has to be declared via Device Tree with the `motorcomm,yt8824` compatible string.
2.  The probe sequence (`yt8824_probe`) calls `devm_of_phy_package_join`, which then does a Device Tree traversal to find necessary properties, especially a "reg" property to identify the PHY. This also relies on the "ethernet-phy-package" node. The Driver needs the `motorcomm,package-mode` from a device-tree entry.

Now, the crucial question: can I achieve this *within* QEMU or GCE? The answer seems to be a resounding "no." QEMU does *not* emulate a Motorcomm YT8824 PHY. GCE relies on virtual devices like virtio-net and Google Virtual Ethernet (GVE) – they do not incorporate physical PHYs or MDIO buses.

Could USB gadgets help here? While USB gadgets can emulate network devices (CDC ECM/NCM/RNDIS, etc.), they create *virtual* network interfaces. They don't expose a physical PHY or an MDIO bus that I could use to communicate with this driver.

What about creating a mock MDIO device through sysfs or some other mechanism to satisfy the required bus? I need to search the kernel code for any existing mocks. If there were a way to simulate this, I might be able to create an execution path. I will need to search for "mdio" in the kernel drivers and networking code, and perhaps syzkaller, to see if there's any precedent.

Based on the evidence so far, I'm leaning heavily towards this code being *structurally unreachable* in the standard fuzzing environments. This means I'd probably need a physical setup with a Motorcomm YT8824 PHY connected to an MDIO bus to trigger the execution paths. Therefore, the answer will likely be `WorthFuzzing=false`, based on the guidelines. I need to be sure there's no way to create or emulate this setup before I make a final decision, however.



24/2 2026/10/15 18:36 tool grepper
0m Error:
no matches

Args:
{
  "Expression": "mock_mdio|dummy_mdio|mdio_mock"
}

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

25/2 2026/10/15 18:36 llm patch-evaluator
0m Model:
gemini-3.8-flash

Args:
null

Results:
null

Tokens:
							input: 59148
							output: 33
							thoughts: 37
						

Thoughts:
Okay, let's dive into this. Here's how I'd approach that problem, as if it were my thought process:

**Investigating User-Space Interface for MDIO/PHY**

Alright, before I go any further, I need to understand how much control user-space actually has over the MDIO bus and the PHY devices. My initial thought is to check for any user-space creation or configuration interfaces that have been implemented. I’m thinking along the lines of things like ConfigFS, that's always a good place to start, or maybe even IOCTL calls specific to these devices. Have the kernel developers provided a direct avenue for user-space to manipulate and interact with the MDIO bus and attached PHYs? That would be the best case, and I need to determine if it exists before proceeding down a different path.



26/2 2026/10/15 18:36 tool grepper
0m Error:
no matches

Args:
{
  "Expression": "class_create\\(.*mdio",
  "PathPrefixes": [
    "drivers/net/phy"
  ]
}

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

27/2 2026/10/15 18:36 llm patch-evaluator
0m Model:
gemini-3.8-flash

Args:
null

Results:
null

Tokens:
							input: 59408
							output: 31
							thoughts: 29
						

Thoughts:
Okay, let's dive into this. Here's how I'd approach summarizing the prompt:

**Investigating MDIO Bus Device Registration**

Alright, let's get down to brass tacks. I need to understand how these `mdio_bus` devices are being registered within the kernel, specifically focusing on the `drivers/net/phy/mdio_bus.c` file. This is crucial for debugging and modifying any PHY-related behavior down the line. I want to trace the registration process itself - how are the device structures initialized, and what mechanisms are employed to make them known to the system? I'll probably look for function calls like `mdiobus_register()` or similar, and I'll likely need to trace the data structures involved, such as the `mdio_bus` struct. It's time to dig into the code and see what's really happening. I'll focus on how the driver interacts with the core MDIO bus infrastructure. I suspect there will be some interesting interplay between the platform-specific MDIO bus initialization and the device registration logic itself.



28/2 2026/10/15 18:36 tool grepper
0m Args:
{
  "Expression": "mdiobus_register",
  "PathPrefixes": [
    "drivers/net/phy"
  ]
}

Results:
{
  "Output": "drivers/net/phy/fixed_phy.c=195=static int __init fixed_mdio_bus_init(void)\n--\ndrivers/net/phy/fixed_phy.c-208-\ndrivers/net/phy/fixed_phy.c:209:\tret = mdiobus_register(fmb_mii_bus);\ndrivers/net/phy/fixed_phy.c-210-\tif (ret)\n--\ndrivers/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-539-/**\ndrivers/net/phy/mdio_bus_provider.c:540: * __mdiobus_register - bring up all the PHYs on a given bus and attach them to bus\ndrivers/net/phy/mdio_bus_provider.c-541- * @bus: target mii_bus\n--\ndrivers/net/phy/mdio_bus_provider.c-545- *   on a given bus, and attach them to the bus. Drivers should use\ndrivers/net/phy/mdio_bus_provider.c:546: *   mdiobus_register() rather than __mdiobus_register() unless they\ndrivers/net/phy/mdio_bus_provider.c-547- *   need to pass a specific owner module. MDIO devices which are not\ndrivers/net/phy/mdio_bus_provider.c-548- *   PHYs will not be brought up by this function. They are expected\ndrivers/net/phy/mdio_bus_provider.c:549: *   to be explicitly listed in DT and instantiated by of_mdiobus_register().\ndrivers/net/phy/mdio_bus_provider.c-550- *\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--\ndrivers/net/phy/mdio_bus_provider.c-666-}\ndrivers/net/phy/mdio_bus_provider.c:667:EXPORT_SYMBOL(__mdiobus_register);\ndrivers/net/phy/mdio_bus_provider.c-668-\n--\ndrivers/net/phy/mdio_bus_provider.c=734=EXPORT_SYMBOL(mdio_find_bus);\n--\ndrivers/net/phy/mdio_bus_provider.c-745- * Because the association of a device_node and mii_bus is made via\ndrivers/net/phy/mdio_bus_provider.c:746: * of_mdiobus_register(), the mii_bus cannot be found before it is\ndrivers/net/phy/mdio_bus_provider.c:747: * registered with of_mdiobus_register().\ndrivers/net/phy/mdio_bus_provider.c-748- *\n--\ndrivers/net/phy/mdio_device.c=151=int mdio_device_register(struct mdio_device *mdiodev)\n--\ndrivers/net/phy/mdio_device.c-156-\ndrivers/net/phy/mdio_device.c:157:\terr = mdiobus_register_device(mdiodev);\ndrivers/net/phy/mdio_device.c-158-\tif (err)\n--\ndrivers/net/phy/mdio_device.c=189=EXPORT_SYMBOL(mdio_device_remove);\ndrivers/net/phy/mdio_device.c-190-\ndrivers/net/phy/mdio_device.c:191:int mdiobus_register_device(struct mdio_device *mdiodev)\ndrivers/net/phy/mdio_device.c-192-{\n--\ndrivers/net/phy/mdio_devres.c=56=static int mdiobus_devres_match(struct device *dev,\n--\ndrivers/net/phy/mdio_devres.c-65-/**\ndrivers/net/phy/mdio_devres.c:66: * __devm_mdiobus_register - Resource-managed variant of mdiobus_register()\ndrivers/net/phy/mdio_devres.c-67- * @dev:\tDevice to register mii_bus for\n--\ndrivers/net/phy/mdio_devres.c-72- */\ndrivers/net/phy/mdio_devres.c:73:int __devm_mdiobus_register(struct device *dev, struct mii_bus *bus,\ndrivers/net/phy/mdio_devres.c-74-\t\t\t    struct module *owner)\n--\ndrivers/net/phy/mdio_devres.c-86-\ndrivers/net/phy/mdio_devres.c:87:\tret = __mdiobus_register(bus, owner);\ndrivers/net/phy/mdio_devres.c-88-\tif (ret) {\n--\ndrivers/net/phy/mdio_devres.c-96-}\ndrivers/net/phy/mdio_devres.c:97:EXPORT_SYMBOL(__devm_mdiobus_register);\ndrivers/net/phy/mdio_devres.c-98-\n--\ndrivers/net/phy/mdio_devres.c-100-/**\ndrivers/net/phy/mdio_devres.c:101: * __devm_of_mdiobus_register - Resource managed variant of of_mdiobus_register()\ndrivers/net/phy/mdio_devres.c-102- * @dev:\tDevice to register mii_bus for\n--\ndrivers/net/phy/mdio_devres.c-106- */\ndrivers/net/phy/mdio_devres.c:107:int __devm_of_mdiobus_register(struct device *dev, struct mii_bus *mdio,\ndrivers/net/phy/mdio_devres.c-108-\t\t\t       struct device_node *np, struct module *owner)\n--\ndrivers/net/phy/mdio_devres.c-120-\ndrivers/net/phy/mdio_devres.c:121:\tret = __of_mdiobus_register(mdio, np, owner);\ndrivers/net/phy/mdio_devres.c-122-\tif (ret) {\n--\ndrivers/net/phy/mdio_devres.c-130-}\ndrivers/net/phy/mdio_devres.c:131:EXPORT_SYMBOL(__devm_of_mdiobus_register);\ndrivers/net/phy/mdio_devres.c-132-#endif /* CONFIG_OF_MDIO */\n--\ndrivers/net/phy/phy_device.c=1019=int phy_device_register(struct phy_device *phydev)\n--\ndrivers/net/phy/phy_device.c-1022-\ndrivers/net/phy/phy_device.c:1023:\terr = mdiobus_register_device(\u0026phydev-\u003emdio);\ndrivers/net/phy/phy_device.c-1024-\tif (err)\n--\ndrivers/net/phy/phylib-internal.h=26=int phy_scan_fixups(struct phy_device *phydev);\ndrivers/net/phy/phylib-internal.h-27-\ndrivers/net/phy/phylib-internal.h:28:int mdiobus_register_device(struct mdio_device *mdiodev);\ndrivers/net/phy/phylib-internal.h-29-int mdiobus_unregister_device(struct mdio_device *mdiodev);\n--\ndrivers/net/phy/sfp.c=985=static int sfp_i2c_mdiobus_create(struct sfp *sfp)\n--\ndrivers/net/phy/sfp.c-996-\ndrivers/net/phy/sfp.c:997:\tret = mdiobus_register(i2c_mii);\ndrivers/net/phy/sfp.c-998-\tif (ret \u003c 0) {\n"
}

29/2 2026/10/15 18:36 llm patch-evaluator
0m Model:
gemini-3.8-flash

Args:
null

Results:
null

Tokens:
							input: 61782
							output: 37
							thoughts: 509
						

Thoughts:
**Analyzing the Motorcomm YT8824 PHY Driver Patch**

Okay, let's break this down. First, it seems like we're dealing with the addition of a new driver for the Motorcomm YT8824 PHY, which is an ASIC hardware transceiver. My initial thought process is to understand what is being added, and where. I know the basics: `fixed_mdio_bus_init` deals with fixed PHY devices, which are generally used for fixed links. The `sfp` mechanism uses I2C for SFP modules. Everything else, the real PHY devices, requires actual hardware controllers with an MDIO bus. So this YT8824 is a real hardware PHY.

Now, let's examine the patch itself. The changes are quite clear:

1.  We have the Device Tree (DT) binding documentation added in `Documentation/devicetree/bindings/net/motorcomm,yt8824.yaml`. Excellent, important for device discoverability.

2.  There's an update to the `MAINTAINERS` file, which is crucial for assigning responsibility and ensuring future updates.

3.  The Kconfig file in `drivers/net/phy/Kconfig` is updated. That tells me that the driver will be selectable during the kernel configuration stage.

4.  The core of the work resides in `drivers/net/phy/motorcomm.c`. A driver implementation for the YT8824 is added. So we are getting the driver functionality.

Now, I spot a seemingly small modification within `ytphy_set_wol`. That function is crucial for configuring Wake-On-LAN (WOL) capabilities, and specifically the interrupt mechanism. I am noticing a change. The original code disables WOL interrupts using `__phy_modify`, but now there is an `err_restore_page` label. I need to be sure the function is reachable.
Let's trace where that `ytphy_set_wol` function is being called from!



30/2 2026/10/15 18:36 tool grepper
0m Args:
{
  "Expression": "ytphy_set_wol",
  "PathPrefixes": [
    "drivers/net/phy/motorcomm.c"
  ]
}

Results:
{
  "Output": "drivers/net/phy/motorcomm.c=848=static void ytphy_get_wol(struct phy_device *phydev,\n--\ndrivers/net/phy/motorcomm.c-864-/**\ndrivers/net/phy/motorcomm.c:865: * ytphy_set_wol() - turn wake-on-lan on or off\ndrivers/net/phy/motorcomm.c-866- * @phydev: a pointer to a \u0026struct phy_device\n--\ndrivers/net/phy/motorcomm.c-874- */\ndrivers/net/phy/motorcomm.c:875:static int ytphy_set_wol(struct phy_device *phydev, struct ethtool_wolinfo *wol)\ndrivers/net/phy/motorcomm.c-876-{\n--\ndrivers/net/phy/motorcomm.c=5012=static struct phy_driver motorcomm_phy_drvs[] = {\n--\ndrivers/net/phy/motorcomm.c-5029-\t\t.get_wol\t= ytphy_get_wol,\ndrivers/net/phy/motorcomm.c:5030:\t\t.set_wol\t= ytphy_set_wol,\ndrivers/net/phy/motorcomm.c-5031-\t\t.config_aneg\t= yt8521_config_aneg,\n--\ndrivers/net/phy/motorcomm.c-5071-\t\t.get_wol\t= ytphy_get_wol,\ndrivers/net/phy/motorcomm.c:5072:\t\t.set_wol\t= ytphy_set_wol,\ndrivers/net/phy/motorcomm.c-5073-\t\t.config_aneg\t= yt8521_config_aneg,\n--\ndrivers/net/phy/motorcomm.c-5087-\t\t.get_wol\t\t= ytphy_get_wol,\ndrivers/net/phy/motorcomm.c:5088:\t\t.set_wol\t\t= ytphy_set_wol,\ndrivers/net/phy/motorcomm.c-5089-\t\t.config_aneg\t\t= genphy_config_aneg,\n"
}

31/2 2026/10/15 18:36 llm patch-evaluator
0m Model:
gemini-3.8-flash

Args:
null

Results:
null

Tokens:
							input: 63294
							output: 151
							thoughts: 991
						

Thoughts:
**WorthFuzzing Analysis for Motorcomm PHY Drivers**

Okay, let's break this down. My initial focus is on the `ytphy_set_wol` function, which is the `.set_wol` method for the Motorcomm PHY drivers, specifically the YT8521, YT8531S, and YT8821. All of these are Motorcomm PHY chips.  I should also consider the `genphy_c45_template_testmode` function in `drivers/net/phy/phy-c45.c`. Checking its calls, I see it's only used within `motorcomm.c`, specifically `yt8824_utp_set_template_test_mode` and `yt8824_config_utp_init_paged`. Nowhere else in the kernel.

Now, let's revisit the negative criteria from Section 2.  The key question is: does this fall into one of the "WorthFuzzing=false" categories?

Given the details, it's pretty clear that this falls under "Structurally unreachable hardware." Specifically, the Motorcomm YT8824 PHY driver. The reasoning is as follows:

1.  `Documentation/devicetree/bindings/net/motorcomm,yt8824.yaml` is, obviously, just documentation. Non-executable.
2.  `MAINTAINERS` is also non-executable.
3.  `drivers/net/phy/Kconfig` is a Kconfig file. Non-executable.
4.  `include/linux/phy.h` and `include/uapi/linux/mdio.h` are header definitions. Non-executable.
5.  `drivers/net/phy/phy-c45.c` is the location of the `genphy_c45_template_testmode` helper, which is exported. However, this helper is only called by the Motorcomm YT8824 PHY driver in `drivers/net/phy/motorcomm.c`.
6.  `drivers/net/phy/motorcomm.c` contains the driver for the Motorcomm Ethernet PHYs. Critically, these (specifically YT8824) *require* physical hardware (an ASIC) and Device Tree integration (`motorcomm,yt8824-package`). This hardware is *not* present or emulated in standard QEMU or GCE environments on amd64.

Can syzkaller interact with these Motorcomm PHYs? No. Syzkaller runs in standard QEMU/GCE VMs on amd64. There's no physical Motorcomm Ethernet PHY attached, QEMU doesn't emulate these PHYs, and phylib PHY drivers cannot be bound to virtual interfaces like tun/tap, veth, or dummy. The code is structurally unreachable.

Therefore, `WorthFuzzing` should be `false`. `FocusSymbols` and `EnableConfigs` can remain empty lists. The concise explanation is that the code is structurally unreachable because it requires physical Motorcomm Ethernet PHY hardware (ASIC), which is not present or emulated in standard QEMU/GCE amd64 environments. The generic helper is only called by this driver; furthermore, DT bindings and MAINTAINERS changes are non-executable.

Time to call `set-results`.



32/2 2026/10/15 18:36 tool set-results
0m Args:
{
  "EnableConfigs": [],
  "FocusSymbols": [],
  "Reasoning": "The patch series adds support for the Motorcomm YT8824 Ethernet PHY (a 4-port 2.5G physical PHY package configured via Device Tree) and introduces a generic C45 helper (genphy_c45_template_testmode) exclusively called by this driver. Physical Ethernet PHY chips such as the Motorcomm YT8824 are hardware ASICs requiring physical MDIO buses and Device Tree bindings not emulated or present in standard QEMU/GCE amd64 virtualization environments. Therefore, the modified code is structurally unreachable for fuzzing.",
  "WorthFuzzing": false
}

Results:
{
  "EnableConfigs": null,
  "FocusSymbols": [],
  "Reasoning": "The patch series adds support for the Motorcomm YT8824 Ethernet PHY (a 4-port 2.5G physical PHY package configured via Device Tree) and introduces a generic C45 helper (genphy_c45_template_testmode) exclusively called by this driver. Physical Ethernet PHY chips such as the Motorcomm YT8824 are hardware ASICs requiring physical MDIO buses and Device Tree bindings not emulated or present in standard QEMU/GCE amd64 virtualization environments. Therefore, the modified code is structurally unreachable for fuzzing.",
  "WorthFuzzing": false
}

33/1 2026/10/15 18:36 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)