lantiq: clarify VG3503J name
[oweals/openwrt.git] / target / linux / mvebu / patches-4.9 / 427-phylink-add-EEE-support.patch
1 From: Russell King <rmk+kernel@arm.linux.org.uk>
2 Date: Thu, 1 Oct 2015 21:19:53 +0100
3 Subject: [PATCH] phylink: add EEE support
4
5 Add EEE hooks to phylink to allow the phylib EEE functions for the
6 connected phy to be safely accessed.
7
8 Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
9 ---
10
11 --- a/drivers/net/ethernet/marvell/mvneta.c
12 +++ b/drivers/net/ethernet/marvell/mvneta.c
13 @@ -3306,7 +3306,8 @@ static void mvneta_mac_link_down(struct
14         }
15  }
16  
17 -static void mvneta_mac_link_up(struct net_device *ndev, unsigned int mode)
18 +static void mvneta_mac_link_up(struct net_device *ndev, unsigned int mode,
19 +                              struct phy_device *phy)
20  {
21         struct mvneta_port *pp = netdev_priv(ndev);
22         u32 val;
23 --- a/drivers/net/phy/phylink.c
24 +++ b/drivers/net/phy/phylink.c
25 @@ -379,7 +379,8 @@ static void phylink_resolve(struct work_
26                         if (pl->phydev)
27                                 phylink_mac_config(pl, &link_state);
28  
29 -                       pl->ops->mac_link_up(ndev, pl->link_an_mode);
30 +                       pl->ops->mac_link_up(ndev, pl->link_an_mode,
31 +                                            pl->phydev);
32  
33                         netif_carrier_on(ndev);
34  
35 @@ -929,6 +930,58 @@ int phylink_ethtool_set_pauseparam(struc
36  }
37  EXPORT_SYMBOL_GPL(phylink_ethtool_set_pauseparam);
38  
39 +int phylink_init_eee(struct phylink *pl, bool clk_stop_enable)
40 +{
41 +       int ret = -EPROTONOSUPPORT;
42 +
43 +       mutex_lock(&pl->config_mutex);
44 +       if (pl->phydev)
45 +               ret = phy_init_eee(pl->phydev, clk_stop_enable);
46 +       mutex_unlock(&pl->config_mutex);
47 +
48 +       return ret;
49 +}
50 +EXPORT_SYMBOL_GPL(phylink_init_eee);
51 +
52 +int phylink_get_eee_err(struct phylink *pl)
53 +{
54 +       int ret = 0;
55 +
56 +       mutex_lock(&pl->config_mutex);
57 +       if (pl->phydev)
58 +               ret = phy_get_eee_err(pl->phydev);
59 +       mutex_unlock(&pl->config_mutex);
60 +
61 +       return ret;
62 +}
63 +EXPORT_SYMBOL_GPL(phylink_get_eee_err);
64 +
65 +int phylink_ethtool_get_eee(struct phylink *pl, struct ethtool_eee *eee)
66 +{
67 +       int ret = -EOPNOTSUPP;
68 +
69 +       mutex_lock(&pl->config_mutex);
70 +       if (pl->phydev)
71 +               ret = phy_ethtool_get_eee(pl->phydev, eee);
72 +       mutex_unlock(&pl->config_mutex);
73 +
74 +       return ret;
75 +}
76 +EXPORT_SYMBOL_GPL(phylink_ethtool_get_eee);
77 +
78 +int phylink_ethtool_set_eee(struct phylink *pl, struct ethtool_eee *eee)
79 +{
80 +       int ret = -EOPNOTSUPP;
81 +
82 +       mutex_lock(&pl->config_mutex);
83 +       if (pl->phydev)
84 +               ret = phy_ethtool_set_eee(pl->phydev, eee);
85 +       mutex_unlock(&pl->config_mutex);
86 +
87 +       return ret;
88 +}
89 +EXPORT_SYMBOL_GPL(phylink_ethtool_set_eee);
90 +
91  /* This emulates MII registers for a fixed-mode phy operating as per the
92   * passed in state. "aneg" defines if we report negotiation is possible.
93   *
94 --- a/include/linux/phylink.h
95 +++ b/include/linux/phylink.h
96 @@ -70,7 +70,8 @@ struct phylink_mac_ops {
97         void (*mac_an_restart)(struct net_device *, unsigned int mode);
98  
99         void (*mac_link_down)(struct net_device *, unsigned int mode);
100 -       void (*mac_link_up)(struct net_device *, unsigned int mode);
101 +       void (*mac_link_up)(struct net_device *, unsigned int mode,
102 +                           struct phy_device *);
103  };
104  
105  struct phylink *phylink_create(struct net_device *, struct device_node *,
106 @@ -95,6 +96,10 @@ void phylink_ethtool_get_pauseparam(stru
107                                     struct ethtool_pauseparam *);
108  int phylink_ethtool_set_pauseparam(struct phylink *,
109                                    struct ethtool_pauseparam *);
110 +int phylink_init_eee(struct phylink *, bool);
111 +int phylink_get_eee_err(struct phylink *);
112 +int phylink_ethtool_get_eee(struct phylink *, struct ethtool_eee *);
113 +int phylink_ethtool_set_eee(struct phylink *, struct ethtool_eee *);
114  int phylink_mii_ioctl(struct phylink *, struct ifreq *, int);
115  
116  int phylink_set_link(struct phylink *pl, unsigned int mode, u8 port,