kernel: bump kernel 4.4 to 4.4.129 for 17.01
[openwrt/openwrt.git] / target / linux / mvebu / patches-4.4 / 144-phylink-add-module-EEPROM-support.patch
1 From 5419ccb638aa5c353ea88815e98953d9fc02e6ca Mon Sep 17 00:00:00 2001
2 From: Russell King <rmk+kernel@arm.linux.org.uk>
3 Date: Thu, 1 Oct 2015 23:10:05 +0100
4 Subject: [PATCH 732/744] phylink: add module EEPROM support
5
6 Add support for reading module EEPROMs through phylink.
7
8 Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
9 Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
10 ---
11 drivers/net/phy/phylink.c | 66 +++++++++++++++++++++++++++++++++++++++++++++++
12 include/linux/phylink.h | 12 +++++++++
13 2 files changed, 78 insertions(+)
14
15 --- a/drivers/net/phy/phylink.c
16 +++ b/drivers/net/phy/phylink.c
17 @@ -60,6 +60,9 @@ struct phylink {
18 struct work_struct resolve;
19
20 bool mac_link_up;
21 +
22 + const struct phylink_module_ops *module_ops;
23 + void *module_data;
24 };
25
26 static const char *phylink_an_mode_str(unsigned int mode)
27 @@ -819,6 +822,36 @@ int phylink_ethtool_set_pauseparam(struc
28 }
29 EXPORT_SYMBOL_GPL(phylink_ethtool_set_pauseparam);
30
31 +int phylink_ethtool_get_module_info(struct phylink *pl,
32 + struct ethtool_modinfo *modinfo)
33 +{
34 + int ret = -EOPNOTSUPP;
35 +
36 + mutex_lock(&pl->config_mutex);
37 + if (pl->module_ops)
38 + ret = pl->module_ops->get_module_info(pl->module_data,
39 + modinfo);
40 + mutex_unlock(&pl->config_mutex);
41 +
42 + return ret;
43 +}
44 +EXPORT_SYMBOL_GPL(phylink_ethtool_get_module_info);
45 +
46 +int phylink_ethtool_get_module_eeprom(struct phylink *pl,
47 + struct ethtool_eeprom *ee, u8 *buf)
48 +{
49 + int ret = -EOPNOTSUPP;
50 +
51 + mutex_lock(&pl->config_mutex);
52 + if (pl->module_ops)
53 + ret = pl->module_ops->get_module_eeprom(pl->module_data, ee,
54 + buf);
55 + mutex_unlock(&pl->config_mutex);
56 +
57 + return ret;
58 +}
59 +EXPORT_SYMBOL_GPL(phylink_ethtool_get_module_eeprom);
60 +
61 int phylink_init_eee(struct phylink *pl, bool clk_stop_enable)
62 {
63 int ret = -EPROTONOSUPPORT;
64 @@ -1016,6 +1049,39 @@ EXPORT_SYMBOL_GPL(phylink_mii_ioctl);
65
66
67
68 +int phylink_register_module(struct phylink *pl, void *data,
69 + const struct phylink_module_ops *ops)
70 +{
71 + int ret = -EBUSY;
72 +
73 + mutex_lock(&pl->config_mutex);
74 + if (!pl->module_ops) {
75 + pl->module_ops = ops;
76 + pl->module_data = data;
77 + ret = 0;
78 + }
79 + mutex_unlock(&pl->config_mutex);
80 +
81 + return ret;
82 +}
83 +EXPORT_SYMBOL_GPL(phylink_register_module);
84 +
85 +int phylink_unregister_module(struct phylink *pl, void *data)
86 +{
87 + int ret = -EINVAL;
88 +
89 + mutex_lock(&pl->config_mutex);
90 + if (pl->module_data == data) {
91 + pl->module_ops = NULL;
92 + pl->module_data = NULL;
93 + ret = 0;
94 + }
95 + mutex_unlock(&pl->config_mutex);
96 +
97 + return ret;
98 +}
99 +EXPORT_SYMBOL_GPL(phylink_unregister_module);
100 +
101 void phylink_disable(struct phylink *pl)
102 {
103 set_bit(PHYLINK_DISABLE_LINK, &pl->phylink_disable_state);
104 --- a/include/linux/phylink.h
105 +++ b/include/linux/phylink.h
106 @@ -55,6 +55,11 @@ struct phylink_mac_ops {
107 struct phy_device *);
108 };
109
110 +struct phylink_module_ops {
111 + int (*get_module_info)(void *, struct ethtool_modinfo *);
112 + int (*get_module_eeprom)(void *, struct ethtool_eeprom *, u8 *);
113 +};
114 +
115 struct phylink *phylink_create(struct net_device *, struct device_node *,
116 phy_interface_t iface, const struct phylink_mac_ops *ops);
117 void phylink_destroy(struct phylink *);
118 @@ -75,12 +80,19 @@ void phylink_ethtool_get_pauseparam(stru
119 struct ethtool_pauseparam *);
120 int phylink_ethtool_set_pauseparam(struct phylink *,
121 struct ethtool_pauseparam *);
122 +int phylink_ethtool_get_module_info(struct phylink *, struct ethtool_modinfo *);
123 +int phylink_ethtool_get_module_eeprom(struct phylink *,
124 + struct ethtool_eeprom *, u8 *);
125 int phylink_init_eee(struct phylink *, bool);
126 int phylink_get_eee_err(struct phylink *);
127 int phylink_ethtool_get_eee(struct phylink *, struct ethtool_eee *);
128 int phylink_ethtool_set_eee(struct phylink *, struct ethtool_eee *);
129 int phylink_mii_ioctl(struct phylink *, struct ifreq *, int);
130
131 +int phylink_register_module(struct phylink *, void *,
132 + const struct phylink_module_ops *);
133 +int phylink_unregister_module(struct phylink *, void *);
134 +
135 void phylink_set_link_port(struct phylink *pl, u32 support, u8 port);
136 int phylink_set_link_an_mode(struct phylink *pl, unsigned int mode);
137 void phylink_disable(struct phylink *pl);