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