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
6 Add support for reading module EEPROMs through phylink.
8 Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
9 Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
11 drivers/net/phy/phylink.c | 66 +++++++++++++++++++++++++++++++++++++++++++++++
12 include/linux/phylink.h | 12 +++++++++
13 2 files changed, 78 insertions(+)
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;
22 + const struct phylink_module_ops *module_ops;
26 static const char *phylink_an_mode_str(unsigned int mode)
27 @@ -819,6 +822,36 @@ int phylink_ethtool_set_pauseparam(struc
29 EXPORT_SYMBOL_GPL(phylink_ethtool_set_pauseparam);
31 +int phylink_ethtool_get_module_info(struct phylink *pl,
32 + struct ethtool_modinfo *modinfo)
34 + int ret = -EOPNOTSUPP;
36 + mutex_lock(&pl->config_mutex);
38 + ret = pl->module_ops->get_module_info(pl->module_data,
40 + mutex_unlock(&pl->config_mutex);
44 +EXPORT_SYMBOL_GPL(phylink_ethtool_get_module_info);
46 +int phylink_ethtool_get_module_eeprom(struct phylink *pl,
47 + struct ethtool_eeprom *ee, u8 *buf)
49 + int ret = -EOPNOTSUPP;
51 + mutex_lock(&pl->config_mutex);
53 + ret = pl->module_ops->get_module_eeprom(pl->module_data, ee,
55 + mutex_unlock(&pl->config_mutex);
59 +EXPORT_SYMBOL_GPL(phylink_ethtool_get_module_eeprom);
61 int phylink_init_eee(struct phylink *pl, bool clk_stop_enable)
63 int ret = -EPROTONOSUPPORT;
64 @@ -1016,6 +1049,39 @@ EXPORT_SYMBOL_GPL(phylink_mii_ioctl);
68 +int phylink_register_module(struct phylink *pl, void *data,
69 + const struct phylink_module_ops *ops)
73 + mutex_lock(&pl->config_mutex);
74 + if (!pl->module_ops) {
75 + pl->module_ops = ops;
76 + pl->module_data = data;
79 + mutex_unlock(&pl->config_mutex);
83 +EXPORT_SYMBOL_GPL(phylink_register_module);
85 +int phylink_unregister_module(struct phylink *pl, void *data)
89 + mutex_lock(&pl->config_mutex);
90 + if (pl->module_data == data) {
91 + pl->module_ops = NULL;
92 + pl->module_data = NULL;
95 + mutex_unlock(&pl->config_mutex);
99 +EXPORT_SYMBOL_GPL(phylink_unregister_module);
101 void phylink_disable(struct phylink *pl)
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 *);
110 +struct phylink_module_ops {
111 + int (*get_module_info)(void *, struct ethtool_modinfo *);
112 + int (*get_module_eeprom)(void *, struct ethtool_eeprom *, u8 *);
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);
131 +int phylink_register_module(struct phylink *, void *,
132 + const struct phylink_module_ops *);
133 +int phylink_unregister_module(struct phylink *, void *);
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);