Merge "[Feature][T106][task-view-944]Support the M22 Nand"
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 f198f26..32cb5a5 100755
--- 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
@@ -1786,12 +1786,46 @@
/*zw.wang add for switching the primary/secondary mode of gmac on 20240118 end */
+/*zw.wang add a new interface to obtain the PHY link status on 20250226 begin*/
+ssize_t phy_pma_link_show(struct device *dev, struct device_attribute *attr,
+ char *buf)
+{
+ int val = 0;
+ struct platform_device *pdev = to_platform_device(dev);
+ if (!pdev) {
+ printk(KERN_ERR "%s : %s pdev : %x \n", __func__, __LINE__,
+ pdev);
+ return -1;
+ }
+ struct net_device *ndev = platform_get_drvdata(pdev);
+ if (!ndev) {
+ printk(KERN_ERR "%s : %s ndev : %x \n", __func__, __LINE__,
+ ndev);
+ return -1;
+ }
+ struct zx29_gmac_dev *priv = (struct zx29_gmac_dev *)netdev_priv(ndev);
+ if (!priv) {
+ printk(KERN_ERR "%s : %s priv : %x \n", __func__, __LINE__,
+ priv);
+ return -1;
+ }
+ mdiobus_write(priv->phydev->mdio.bus, priv->phydev->mdio.addr, 0x0d,0x1);
+ mdiobus_write(priv->phydev->mdio.bus, priv->phydev->mdio.addr, 0x0e,0x1);
+ mdiobus_write(priv->phydev->mdio.bus, priv->phydev->mdio.addr, 0x0d,0x4000 | 0x1);
+ val = mdiobus_read(priv->phydev->mdio.bus, priv->phydev->mdio.addr,0x0e);
+ sprintf(buf, "link : %s\n", (val & BIT(2)) ? "yes":"no");
+ return strlen(buf);
+}
+
+/*zw.wang add a new interface to obtain the PHY link status on 20250226 end*/
+
static DEVICE_ATTR(gmac_test, 0664, show_fun, store_fun);
static DEVICE_ATTR(mdio_test, 0664, mdio_show, mdio_store);
static DEVICE_ATTR(free_mdio, 0664, free_mdio_show, free_mdio_store);
static DEVICE_ATTR(debug_on, 0664, debug_on_show, debug_on_store);
static DEVICE_ATTR(gmac_power, 0664, gmac_power_show, gmac_power_store);//jb.qi add for gamc power down on 20231116
static DEVICE_ATTR(gmac_master_or_slave, 0664, gmac_master_or_slave_show, gmac_master_or_slave_store);//zw.wang add for switching the primary/secondary mode of gmac on 20240118
+static DEVICE_ATTR_RO(phy_pma_link); //zw.wang add a new interface to obtain the PHY link status on 20250226
static int zx29_gmac_probe(struct platform_device *pdev)
{
@@ -1820,6 +1854,7 @@
device_create_file(&pdev->dev, &dev_attr_debug_on);
device_create_file(&pdev->dev, &dev_attr_gmac_power);//jb.qi add for gamc power down on 20231116
device_create_file(&pdev->dev, &dev_attr_gmac_master_or_slave);//zw.wang add for switching the primary/secondary mode of gmac on 20240118
+ device_create_file(&pdev->dev, &dev_attr_phy_pma_link); //zw.wang add a new interface to obtain the PHY link status on 20250226
prv = netdev_priv(ndev);
memset(prv, 0, sizeof(*prv));
@@ -2092,6 +2127,7 @@
device_remove_file(&pdev->dev, &dev_attr_debug_on);
device_remove_file(&pdev->dev, &dev_attr_gmac_power);//jb.qi add for gamc power down on 20231116
device_remove_file(&pdev->dev, &dev_attr_gmac_master_or_slave);//zw.wang add for switching the primary/secondary mode of gmac on 20240118
+ device_remove_file(&pdev->dev, &dev_attr_phy_pma_link); //zw.wang add a new interface to obtain the PHY link status on 20250226
}
return 0;
}