1 commit 9df81dd7583d14862d0cfb673a941b261f3b2112
2 Author: Florian Fainelli <f.fainelli@gmail.com>
3 Date: Mon Feb 17 13:34:03 2014 -0800
5 net: phy: allow PHY drivers to implement their own software reset
7 As pointed out by Shaohui, most 10G PHYs out there have a non-standard
8 compliant software reset sequence, eventually something much more
9 complex than just toggling the BMCR_RESET bit. Allow PHY driver to
10 implement their own soft_reset() callback to deal with that. If no
11 callback is provided, call into genphy_soft_reset() which makes sure the
12 existing behavior is kept intact.
14 Reported-by: Shaohui Xie <Shaohui.Xie@freescale.com>
15 Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
16 Signed-off-by: David S. Miller <davem@davemloft.net>
18 --- a/drivers/net/phy/phy_device.c
19 +++ b/drivers/net/phy/phy_device.c
20 @@ -534,12 +534,16 @@ static int phy_poll_reset(struct phy_dev
22 int phy_init_hw(struct phy_device *phydev)
27 if (!phydev->drv || !phydev->drv->config_init)
30 - ret = genphy_soft_reset(phydev);
31 + if (phydev->drv->soft_reset)
32 + ret = phydev->drv->soft_reset(phydev);
34 + ret = genphy_soft_reset(phydev);
39 @@ -1092,6 +1096,12 @@ static int genphy_config_init(struct phy
43 +static int gen10g_soft_reset(struct phy_device *phydev)
45 + /* Do nothing for now */
49 static int gen10g_config_init(struct phy_device *phydev)
51 /* Temporarily just say we support everything */
52 @@ -1266,6 +1276,7 @@ static struct phy_driver genphy_driver[]
54 .phy_id_mask = 0xffffffff,
55 .name = "Generic PHY",
56 + .soft_reset = genphy_soft_reset,
57 .config_init = genphy_config_init,
59 .config_aneg = genphy_config_aneg,
60 @@ -1277,6 +1288,7 @@ static struct phy_driver genphy_driver[]
62 .phy_id_mask = 0xffffffff,
63 .name = "Generic 10G PHY",
64 + .soft_reset = gen10g_soft_reset,
65 .config_init = gen10g_config_init,
67 .config_aneg = gen10g_config_aneg,
68 --- a/include/linux/phy.h
69 +++ b/include/linux/phy.h
70 @@ -394,6 +394,11 @@ struct phy_driver {
74 + * Called to issue a PHY software reset
76 + int (*soft_reset)(struct phy_device *phydev);
79 * Called to initialize the PHY,
80 * including after a reset