kernel: update 3.14 to 3.14.30
[openwrt.git] / target / linux / generic / patches-3.14 / 070-net-phy-move-PHY-software-reset.patch
1 commit 797ac07137d9ae8572008e21e6123a9ae17dae50
2 Author: Florian Fainelli <f.fainelli@gmail.com>
3 Date:   Mon Feb 17 13:34:02 2014 -0800
4
5     net: phy: move PHY software reset to genphy_soft_reset
6     
7     As pointed out by Shaohui, this function is generic for 10/100/1000
8     PHYs, but 10G PHYs might have a slightly different reset sequence which
9     prevents most of them from using this function.
10     
11     Move the BMCR_RESET based software resent sequence to
12     genphy_soft_reset() in preparation for allowing PHY drivers to implement
13     a soft_reset() callback.
14     
15     Reported-by: Shaohui Xie <Shaohui.Xie@freescale.com>
16     Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
17     Signed-off-by: David S. Miller <davem@davemloft.net>
18
19 --- a/drivers/net/phy/phy_device.c
20 +++ b/drivers/net/phy/phy_device.c
21 @@ -539,11 +539,7 @@ int phy_init_hw(struct phy_device *phyde
22         if (!phydev->drv || !phydev->drv->config_init)
23                 return 0;
24  
25 -       ret = phy_write(phydev, MII_BMCR, BMCR_RESET);
26 -       if (ret < 0)
27 -               return ret;
28 -
29 -       ret = phy_poll_reset(phydev);
30 +       ret = genphy_soft_reset(phydev);
31         if (ret < 0)
32                 return ret;
33  
34 @@ -1029,6 +1025,27 @@ static int gen10g_read_status(struct phy
35         return 0;
36  }
37  
38 +/**
39 + * genphy_soft_reset - software reset the PHY via BMCR_RESET bit
40 + * @phydev: target phy_device struct
41 + *
42 + * Description: Perform a software PHY reset using the standard
43 + * BMCR_RESET bit and poll for the reset bit to be cleared.
44 + *
45 + * Returns: 0 on success, < 0 on failure
46 + */
47 +int genphy_soft_reset(struct phy_device *phydev)
48 +{
49 +       int ret;
50 +
51 +       ret = phy_write(phydev, MII_BMCR, BMCR_RESET);
52 +       if (ret < 0)
53 +               return ret;
54 +
55 +       return phy_poll_reset(phydev);
56 +}
57 +EXPORT_SYMBOL(genphy_soft_reset);
58 +
59  static int genphy_config_init(struct phy_device *phydev)
60  {
61         int val;
62 --- a/include/linux/phy.h
63 +++ b/include/linux/phy.h
64 @@ -616,6 +616,7 @@ int genphy_update_link(struct phy_device
65  int genphy_read_status(struct phy_device *phydev);
66  int genphy_suspend(struct phy_device *phydev);
67  int genphy_resume(struct phy_device *phydev);
68 +int genphy_soft_reset(struct phy_device *phydev);
69  void phy_driver_unregister(struct phy_driver *drv);
70  void phy_drivers_unregister(struct phy_driver *drv, int n);
71  int phy_driver_register(struct phy_driver *new_driver);