96fb3da5b0d3f764ecb4d9549e86fea80d346245
[librecmc/librecmc.git] /
1 From: Florian Fainelli <f.fainelli@gmail.com>
2 Date: Tue, 22 Nov 2016 11:40:56 -0800
3 Subject: [PATCH] net: phy: broadcom: Allow enabling or disabling of EEE
4
5 In preparation for adding support for Wirespeed/downshift, we need to
6 change bcm_phy_eee_enable() to allow enabling or disabling EEE, so make
7 the function take an extra enable/disable boolean parameter and rename
8 it to illustrate it sets EEE, not necessarily just enables it.
9
10 Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
11 Signed-off-by: David S. Miller <davem@davemloft.net>
12 ---
13
14 --- a/drivers/net/phy/bcm7xxx.c
15 +++ b/drivers/net/phy/bcm7xxx.c
16 @@ -199,7 +199,7 @@ static int bcm7xxx_28nm_config_init(stru
17         if (ret)
18                 return ret;
19  
20 -       ret = bcm_phy_enable_eee(phydev);
21 +       ret = bcm_phy_set_eee(phydev, true);
22         if (ret)
23                 return ret;
24  
25 --- a/drivers/net/phy/bcm-cygnus.c
26 +++ b/drivers/net/phy/bcm-cygnus.c
27 @@ -104,7 +104,7 @@ static int bcm_cygnus_config_init(struct
28                 return rc;
29  
30         /* Advertise EEE */
31 -       rc = bcm_phy_enable_eee(phydev);
32 +       rc = bcm_phy_set_eee(phydev, true);
33         if (rc)
34                 return rc;
35  
36 --- a/drivers/net/phy/bcm-phy-lib.c
37 +++ b/drivers/net/phy/bcm-phy-lib.c
38 @@ -195,7 +195,7 @@ int bcm_phy_enable_apd(struct phy_device
39  }
40  EXPORT_SYMBOL_GPL(bcm_phy_enable_apd);
41  
42 -int bcm_phy_enable_eee(struct phy_device *phydev)
43 +int bcm_phy_set_eee(struct phy_device *phydev, bool enable)
44  {
45         int val;
46  
47 @@ -205,7 +205,10 @@ int bcm_phy_enable_eee(struct phy_device
48         if (val < 0)
49                 return val;
50  
51 -       val |= LPI_FEATURE_EN | LPI_FEATURE_EN_DIG1000X;
52 +       if (enable)
53 +               val |= LPI_FEATURE_EN | LPI_FEATURE_EN_DIG1000X;
54 +       else
55 +               val &= ~(LPI_FEATURE_EN | LPI_FEATURE_EN_DIG1000X);
56  
57         phy_write_mmd_indirect(phydev, BRCM_CL45VEN_EEE_CONTROL,
58                                MDIO_MMD_AN, (u32)val);
59 @@ -216,14 +219,17 @@ int bcm_phy_enable_eee(struct phy_device
60         if (val < 0)
61                 return val;
62  
63 -       val |= (MDIO_AN_EEE_ADV_100TX | MDIO_AN_EEE_ADV_1000T);
64 +       if (enable)
65 +               val |= (MDIO_AN_EEE_ADV_100TX | MDIO_AN_EEE_ADV_1000T);
66 +       else
67 +               val &= ~(MDIO_AN_EEE_ADV_100TX | MDIO_AN_EEE_ADV_1000T);
68  
69         phy_write_mmd_indirect(phydev, BCM_CL45VEN_EEE_ADV,
70                                MDIO_MMD_AN, (u32)val);
71  
72         return 0;
73  }
74 -EXPORT_SYMBOL_GPL(bcm_phy_enable_eee);
75 +EXPORT_SYMBOL_GPL(bcm_phy_set_eee);
76  
77  MODULE_DESCRIPTION("Broadcom PHY Library");
78  MODULE_LICENSE("GPL v2");
79 --- a/drivers/net/phy/bcm-phy-lib.h
80 +++ b/drivers/net/phy/bcm-phy-lib.h
81 @@ -36,5 +36,5 @@ int bcm_phy_config_intr(struct phy_devic
82  
83  int bcm_phy_enable_apd(struct phy_device *phydev, bool dll_pwr_down);
84  
85 -int bcm_phy_enable_eee(struct phy_device *phydev);
86 +int bcm_phy_set_eee(struct phy_device *phydev, bool enable);
87  #endif /* _LINUX_BCM_PHY_LIB_H */