From e31f62df47e89b1654322308120b742d96fd95f4 Mon Sep 17 00:00:00 2001 From: Fugang Duan Date: Mon, 27 Jul 2015 15:40:00 +0800 Subject: [PATCH] MLK-10919 net: phy: micrel: add ksz8081 resume function Add ksz8081 resume function since the phy has some non-standard register init process that has some fixup. Signed-off-by: Fugang Duan (cherry picked from commit: 65c6e997b8e020b9e87d1af23c94c15c13e3d2e3) --- drivers/net/phy/micrel.c | 18 +++++++++++++++++- drivers/net/phy/phy_device.c | 3 ++- include/linux/phy.h | 1 + 3 files changed, 20 insertions(+), 2 deletions(-) diff --git a/drivers/net/phy/micrel.c b/drivers/net/phy/micrel.c index 2032a6de026b..52c24ac5d751 100644 --- a/drivers/net/phy/micrel.c +++ b/drivers/net/phy/micrel.c @@ -788,6 +788,22 @@ static int kszphy_probe(struct phy_device *phydev) return 0; } +static int ksz8081_resume(struct phy_device *phydev) +{ + int value; + + mutex_lock(&phydev->lock); + value = phy_read(phydev, MII_BMCR); + phy_write(phydev, MII_BMCR, value & ~BMCR_PDOWN); + + value = phy_scan_fixups(phydev); + if (value < 0) + return value; + mutex_unlock(&phydev->lock); + + return 0; +} + static struct phy_driver ksphy_driver[] = { { .phy_id = PHY_ID_KS8737, @@ -936,7 +952,7 @@ static struct phy_driver ksphy_driver[] = { .get_strings = kszphy_get_strings, .get_stats = kszphy_get_stats, .suspend = kszphy_suspend, - .resume = kszphy_resume, + .resume = ksz8081_resume, }, { .phy_id = PHY_ID_KSZ8061, .name = "Micrel KSZ8061", diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c index bf02f8e4648a..74690cd3c493 100644 --- a/drivers/net/phy/phy_device.c +++ b/drivers/net/phy/phy_device.c @@ -252,7 +252,7 @@ static int phy_needs_fixup(struct phy_device *phydev, struct phy_fixup *fixup) } /* Runs any matching fixups for this phydev */ -static int phy_scan_fixups(struct phy_device *phydev) +int phy_scan_fixups(struct phy_device *phydev) { struct phy_fixup *fixup; @@ -272,6 +272,7 @@ static int phy_scan_fixups(struct phy_device *phydev) return 0; } +EXPORT_SYMBOL(phy_scan_fixups); static int phy_bus_match(struct device *dev, struct device_driver *drv) { diff --git a/include/linux/phy.h b/include/linux/phy.h index 867110c9d707..cc374eb47c26 100644 --- a/include/linux/phy.h +++ b/include/linux/phy.h @@ -833,6 +833,7 @@ void phy_print_status(struct phy_device *phydev); void phy_device_free(struct phy_device *phydev); int phy_set_max_speed(struct phy_device *phydev, u32 max_speed); +int phy_scan_fixups(struct phy_device *phydev); int phy_register_fixup(const char *bus_id, u32 phy_uid, u32 phy_uid_mask, int (*run)(struct phy_device *)); int phy_register_fixup_for_id(const char *bus_id, -- 2.17.1