Merge "[qca-ssdk]: support suspend/resume function in phy driver"
diff --git a/src/init/ssdk_init.c b/src/init/ssdk_init.c
index eb6c820..6f297da 100755
--- a/src/init/ssdk_init.c
+++ b/src/init/ssdk_init.c
@@ -1781,6 +1781,38 @@
return 0;
}
+int qca_phy_suspend(struct phy_device *phydev)
+{
+ struct mii_bus *bus = phydev->bus;
+ int val = 0;
+ int addr;
+
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,9,0))
+ addr = phydev->mdio.addr;
+#else
+ addr = phydev->addr;
+#endif
+
+ val = mdiobus_read(bus, addr, MII_BMCR);
+ return mdiobus_write(bus, addr, MII_BMCR, (u16)(val | BMCR_PDOWN));
+}
+
+int qca_phy_resume(struct phy_device *phydev)
+{
+ struct mii_bus *bus = phydev->bus;
+ int val = 0;
+ int addr;
+
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,9,0))
+ addr = phydev->mdio.addr;
+#else
+ addr = phydev->addr;
+#endif
+
+ val = mdiobus_read(bus, addr, MII_BMCR);
+ return mdiobus_write(bus, addr, MII_BMCR, (u16)(val & ~BMCR_PDOWN));
+}
+
static int
qca_phy_probe(struct phy_device *pdev)
{
@@ -1834,6 +1866,8 @@
.config_init= &qca_phy_config_init,
.config_aneg= &qca_phy_config_aneg,
.read_status= &qca_phy_read_status,
+ .suspend = qca_phy_suspend,
+ .resume = qca_phy_resume,
.features = PHY_BASIC_FEATURES,
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,9,0))
.mdiodrv.driver = { .owner = THIS_MODULE },