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