c70d40a677dd11cefd71d16f2e91e70d55fc1f28
[openwrt/openwrt.git] / target / linux / generic / patches-3.14 / 071-net-phy-override-PHY-reset.patch
1 commit 9df81dd7583d14862d0cfb673a941b261f3b2112
2 Author: Florian Fainelli <f.fainelli@gmail.com>
3 Date: Mon Feb 17 13:34:03 2014 -0800
4
5 net: phy: allow PHY drivers to implement their own software reset
6
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.
13
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>
17
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
21
22 int phy_init_hw(struct phy_device *phydev)
23 {
24 - int ret;
25 + int ret = 0;
26
27 if (!phydev->drv || !phydev->drv->config_init)
28 return 0;
29
30 - ret = genphy_soft_reset(phydev);
31 + if (phydev->drv->soft_reset)
32 + ret = phydev->drv->soft_reset(phydev);
33 + else
34 + ret = genphy_soft_reset(phydev);
35 +
36 if (ret < 0)
37 return ret;
38
39 @@ -1092,6 +1096,12 @@ static int genphy_config_init(struct phy
40 return 0;
41 }
42
43 +static int gen10g_soft_reset(struct phy_device *phydev)
44 +{
45 + /* Do nothing for now */
46 + return 0;
47 +}
48 +
49 static int gen10g_config_init(struct phy_device *phydev)
50 {
51 /* Temporarily just say we support everything */
52 @@ -1266,6 +1276,7 @@ static struct phy_driver genphy_driver[]
53 .phy_id = 0xffffffff,
54 .phy_id_mask = 0xffffffff,
55 .name = "Generic PHY",
56 + .soft_reset = genphy_soft_reset,
57 .config_init = genphy_config_init,
58 .features = 0,
59 .config_aneg = genphy_config_aneg,
60 @@ -1277,6 +1288,7 @@ static struct phy_driver genphy_driver[]
61 .phy_id = 0xffffffff,
62 .phy_id_mask = 0xffffffff,
63 .name = "Generic 10G PHY",
64 + .soft_reset = gen10g_soft_reset,
65 .config_init = gen10g_config_init,
66 .features = 0,
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 {
71 u32 flags;
72
73 /*
74 + * Called to issue a PHY software reset
75 + */
76 + int (*soft_reset)(struct phy_device *phydev);
77 +
78 + /*
79 * Called to initialize the PHY,
80 * including after a reset
81 */