aboutsummaryrefslogtreecommitdiffstats
path: root/net/dsa
diff options
context:
space:
mode:
authorAndrew Lunn <andrew@lunn.ch>2015-08-31 09:56:49 -0400
committerDavid S. Miller <davem@davemloft.net>2015-08-31 17:48:02 -0400
commit39b0c705195e9409dc8a40cc82b11d81405a4a4b (patch)
tree8c25a7a4b8bd5067aa5a270ff3049d88a12febb0 /net/dsa
parent34b31da486a5e4eda9ff548ebf6dc3adc167bd0c (diff)
net: dsa: Allow configuration of CPU & DSA port speeds/duplex
By default, DSA and CPU ports are configured to the maximum speed the switch supports. However there can be use cases where the peer devices port is slower. Allow a fixed-link property to be used with the DSA and CPU port in the device tree, and use this information to configure the port. Signed-off-by: Andrew Lunn <andrew@lunn.ch> Reviewed-by: Florian Fainelli <f.fainelli@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/dsa')
-rw-r--r--net/dsa/dsa.c37
1 files changed, 37 insertions, 0 deletions
diff --git a/net/dsa/dsa.c b/net/dsa/dsa.c
index 053eb2b8e682..afff17341b73 100644
--- a/net/dsa/dsa.c
+++ b/net/dsa/dsa.c
@@ -176,6 +176,35 @@ __ATTRIBUTE_GROUPS(dsa_hwmon);
176#endif /* CONFIG_NET_DSA_HWMON */ 176#endif /* CONFIG_NET_DSA_HWMON */
177 177
178/* basic switch operations **************************************************/ 178/* basic switch operations **************************************************/
179static int dsa_cpu_dsa_setup(struct dsa_switch *ds, struct net_device *master)
180{
181 struct dsa_chip_data *cd = ds->pd;
182 struct device_node *port_dn;
183 struct phy_device *phydev;
184 int ret, port;
185
186 for (port = 0; port < DSA_MAX_PORTS; port++) {
187 if (!(dsa_is_cpu_port(ds, port) || dsa_is_dsa_port(ds, port)))
188 continue;
189
190 port_dn = cd->port_dn[port];
191 if (of_phy_is_fixed_link(port_dn)) {
192 ret = of_phy_register_fixed_link(port_dn);
193 if (ret) {
194 netdev_err(master,
195 "failed to register fixed PHY\n");
196 return ret;
197 }
198 phydev = of_phy_find_device(port_dn);
199 genphy_config_init(phydev);
200 genphy_read_status(phydev);
201 if (ds->drv->adjust_link)
202 ds->drv->adjust_link(ds, port, phydev);
203 }
204 }
205 return 0;
206}
207
179static int dsa_switch_setup_one(struct dsa_switch *ds, struct device *parent) 208static int dsa_switch_setup_one(struct dsa_switch *ds, struct device *parent)
180{ 209{
181 struct dsa_switch_driver *drv = ds->drv; 210 struct dsa_switch_driver *drv = ds->drv;
@@ -297,6 +326,14 @@ static int dsa_switch_setup_one(struct dsa_switch *ds, struct device *parent)
297 } 326 }
298 } 327 }
299 328
329 /* Perform configuration of the CPU and DSA ports */
330 ret = dsa_cpu_dsa_setup(ds, dst->master_netdev);
331 if (ret < 0) {
332 netdev_err(dst->master_netdev, "[%d] : can't configure CPU and DSA ports\n",
333 index);
334 ret = 0;
335 }
336
300#ifdef CONFIG_NET_DSA_HWMON 337#ifdef CONFIG_NET_DSA_HWMON
301 /* If the switch provides a temperature sensor, 338 /* If the switch provides a temperature sensor,
302 * register with hardware monitoring subsystem. 339 * register with hardware monitoring subsystem.