Merge "[Bugfix][T106BUG-439]Customer chooses phy c22/c45 issues on"
diff --git a/cap/zx297520v3/sources/meta-zxic/recipes-kernel/linux/files/zx297520v3/linux-5_10-vehicle_dc_ref-normal-defconfig b/cap/zx297520v3/sources/meta-zxic/recipes-kernel/linux/files/zx297520v3/linux-5_10-vehicle_dc_ref-normal-defconfig
index ad47afa..3e5ab07 100755
--- a/cap/zx297520v3/sources/meta-zxic/recipes-kernel/linux/files/zx297520v3/linux-5_10-vehicle_dc_ref-normal-defconfig
+++ b/cap/zx297520v3/sources/meta-zxic/recipes-kernel/linux/files/zx297520v3/linux-5_10-vehicle_dc_ref-normal-defconfig
@@ -1398,6 +1398,9 @@
 CONFIG_MDIO_BUS=y
 CONFIG_OF_MDIO=y
 CONFIG_MDIO_DEVRES=y
+# zw.wang Customer chooses phy c22/c45 issues on 20240301 start
+CONFIG_MDIO_C45=y
+# zw.wang Customer chooses phy c22/c45 issues on 20240301 end
 # CONFIG_MDIO_BITBANG is not set
 # CONFIG_MDIO_BCM_UNIMAC is not set
 # CONFIG_MDIO_HISI_FEMAC is not set
diff --git a/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/drivers/net/ethernet/zte/zx29_gmac.c b/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/drivers/net/ethernet/zte/zx29_gmac.c
index 556f9c4..797ec4d 100644
--- a/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/drivers/net/ethernet/zte/zx29_gmac.c
+++ b/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/drivers/net/ethernet/zte/zx29_gmac.c
@@ -1647,7 +1647,7 @@
 	ret = gpio_request(prv->gpio_power[0], "gmac_power"); /* gpio 83/124 */

 	gpio_direction_output(prv->gpio_power[0], 1);

 	mdelay(15);

-#ifdef _USE_VEHICLE_DC_REF

+#ifdef CONFIG_MDIO_C45 //zw.wang Customer chooses phy c22/c45 issues on 20240301
 	prv->gpio_power[1] = of_get_gpio_flags(pdev->dev.of_node, 1, &flags);

 	ret = gpio_request(prv->gpio_power[1], "phy_rst"); /* gpio 63 */

 	gpio_direction_output(prv->gpio_power[1], 0);

@@ -1854,7 +1854,7 @@
 		free_netdev(ndev);

 	    platform_set_drvdata(pdev, NULL);

 

-#ifdef _USE_VEHICLE_DC_REF

+#ifdef CONFIG_MDIO_C45 //zw.wang Customer chooses phy c22/c45 issues on 20240301
 		gpio_free(priv->gpio_power[1]);

 #endif

 		gpio_direction_output(priv->gpio_power[0], 0);

diff --git a/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/drivers/net/phy/Kconfig b/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/drivers/net/phy/Kconfig
index 7db7c8c..a0bf99d 100644
--- a/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/drivers/net/phy/Kconfig
+++ b/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/drivers/net/phy/Kconfig
@@ -314,6 +314,13 @@
 	  the Reduced Gigabit Media Independent Interface(RGMII) between
 	  Ethernet physical media devices and the Gigabit Ethernet controller.
 
+# zw.wang Customer chooses phy c22/c45 issues on 20240301 start
+config MDIO_C45
+	bool "Switch between c22 and c45"
+	default n
+	help
+	  It is disabled by default. The value is C45 if yes, and C22 if N.
+# zw.wang Customer chooses phy c22/c45 issues on 20240301 end
 endif # PHYLIB
 
 config MICREL_KS8995MA
diff --git a/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/drivers/net/phy/phy_device.c b/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/drivers/net/phy/phy_device.c
index da7365f..a868814 100644
--- a/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/drivers/net/phy/phy_device.c
+++ b/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/drivers/net/phy/phy_device.c
@@ -793,7 +793,7 @@
 
 	/* Grab the bits from PHYIR1, and put them in the upper half */
 //	phy_reg = mdiobus_read(bus, addr, MII_PHYSID1);
-#ifdef _USE_VEHICLE_DC_REF
+#ifdef CONFIG_MDIO_C45 //zw.wang Customer chooses phy c22/c45 issues on 20240301
     mdiobus_write(bus, addr, 0x0d, 1);
     mdiobus_write(bus, addr, 0x0e, 2);
     mdiobus_write(bus, addr, 0x0d, 0x4000 | 1);
@@ -810,7 +810,7 @@
 
 	/* Grab the bits from PHYIR2, and put them in the lower half */
 //	phy_reg = mdiobus_read(bus, addr, MII_PHYSID2);
-#ifdef _USE_VEHICLE_DC_REF	
+#ifdef CONFIG_MDIO_C45	
     mdiobus_write(bus, addr, 0x0d, 1);
     mdiobus_write(bus, addr, 0x0e, 3);
     mdiobus_write(bus, addr, 0x0d, 0x4000 | 1);
@@ -825,7 +825,7 @@
 
 	*phy_id |= phy_reg;
 
-#ifdef _USE_VEHICLE_DC_REF	
+#ifdef CONFIG_MDIO_C45	
     printk("[%s] read with c45 phy id:0x%x\n", __func__, *phy_id);
 #else
     printk("[%s] read with c22 phy id:0x%x\n", __func__, *phy_id);