aboutsummaryrefslogtreecommitdiffstats
path: root/net/dsa/dsa.c
diff options
context:
space:
mode:
authorDavid S. Miller <davem@davemloft.net>2015-08-31 17:48:03 -0400
committerDavid S. Miller <davem@davemloft.net>2015-08-31 17:48:03 -0400
commit684511ac2eeb015b7a9a46c575543566e1b1fb7c (patch)
treee755ec8c049139469d67a5f239002ec68c743113 /net/dsa/dsa.c
parent6ea3c9d5b042edf14eac1e21af21c41f81f3491e (diff)
parentbc0f4a87fc7e45642455682f281de2131cde9695 (diff)
Merge branch 'dsa-port-config'
Andrew Lunn says: ==================== DSA port configuration and status This patchset allows various switch port settings to be configured and port status to be sampled. Some of these patches have been posted before. The first three patches provide infrastructure for configuring a switch ports link speed and duplex from a fixed_link phy. Patch four then uses this infrastructure to allow the CPU and DSA ports of a switch to be configured using a fixed-link property in the device tree. Patches five and six allow a phy-mode property to be specified in the device tree, and allow this to be used for configuring RGMII delays. Patches seven through nine allow link status, for example that of an SFP module, to be read from a gpio. Changes since v1: Rewrite 9/9 so that it hopefully does not regression on 868a4215be9a6d80 ("net: phy: fixed_phy: handle link-down case") ==================== Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/dsa/dsa.c')
-rw-r--r--net/dsa/dsa.c43
1 files changed, 43 insertions, 0 deletions
diff --git a/net/dsa/dsa.c b/net/dsa/dsa.c
index 053eb2b8e682..76e3800765f8 100644
--- a/net/dsa/dsa.c
+++ b/net/dsa/dsa.c
@@ -176,6 +176,41 @@ __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, mode;
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
200 mode = of_get_phy_mode(port_dn);
201 if (mode < 0)
202 mode = PHY_INTERFACE_MODE_NA;
203 phydev->interface = mode;
204
205 genphy_config_init(phydev);
206 genphy_read_status(phydev);
207 if (ds->drv->adjust_link)
208 ds->drv->adjust_link(ds, port, phydev);
209 }
210 }
211 return 0;
212}
213
179static int dsa_switch_setup_one(struct dsa_switch *ds, struct device *parent) 214static int dsa_switch_setup_one(struct dsa_switch *ds, struct device *parent)
180{ 215{
181 struct dsa_switch_driver *drv = ds->drv; 216 struct dsa_switch_driver *drv = ds->drv;
@@ -297,6 +332,14 @@ static int dsa_switch_setup_one(struct dsa_switch *ds, struct device *parent)
297 } 332 }
298 } 333 }
299 334
335 /* Perform configuration of the CPU and DSA ports */
336 ret = dsa_cpu_dsa_setup(ds, dst->master_netdev);
337 if (ret < 0) {
338 netdev_err(dst->master_netdev, "[%d] : can't configure CPU and DSA ports\n",
339 index);
340 ret = 0;
341 }
342
300#ifdef CONFIG_NET_DSA_HWMON 343#ifdef CONFIG_NET_DSA_HWMON
301 /* If the switch provides a temperature sensor, 344 /* If the switch provides a temperature sensor,
302 * register with hardware monitoring subsystem. 345 * register with hardware monitoring subsystem.