diff options
author | David S. Miller <davem@davemloft.net> | 2015-09-01 00:48:03 +0300 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2015-09-01 00:48:03 +0300 |
commit | 684511ac2eeb015b7a9a46c575543566e1b1fb7c (patch) | |
tree | e755ec8c049139469d67a5f239002ec68c743113 /net | |
parent | 6ea3c9d5b042edf14eac1e21af21c41f81f3491e (diff) | |
parent | bc0f4a87fc7e45642455682f281de2131cde9695 (diff) | |
download | linux-684511ac2eeb015b7a9a46c575543566e1b1fb7c.tar.xz |
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')
-rw-r--r-- | net/dsa/dsa.c | 43 |
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); #endif /* CONFIG_NET_DSA_HWMON */ /* basic switch operations **************************************************/ +static int dsa_cpu_dsa_setup(struct dsa_switch *ds, struct net_device *master) +{ + struct dsa_chip_data *cd = ds->pd; + struct device_node *port_dn; + struct phy_device *phydev; + int ret, port, mode; + + for (port = 0; port < DSA_MAX_PORTS; port++) { + if (!(dsa_is_cpu_port(ds, port) || dsa_is_dsa_port(ds, port))) + continue; + + port_dn = cd->port_dn[port]; + if (of_phy_is_fixed_link(port_dn)) { + ret = of_phy_register_fixed_link(port_dn); + if (ret) { + netdev_err(master, + "failed to register fixed PHY\n"); + return ret; + } + phydev = of_phy_find_device(port_dn); + + mode = of_get_phy_mode(port_dn); + if (mode < 0) + mode = PHY_INTERFACE_MODE_NA; + phydev->interface = mode; + + genphy_config_init(phydev); + genphy_read_status(phydev); + if (ds->drv->adjust_link) + ds->drv->adjust_link(ds, port, phydev); + } + } + return 0; +} + static int dsa_switch_setup_one(struct dsa_switch *ds, struct device *parent) { struct dsa_switch_driver *drv = ds->drv; @@ -297,6 +332,14 @@ static int dsa_switch_setup_one(struct dsa_switch *ds, struct device *parent) } } + /* Perform configuration of the CPU and DSA ports */ + ret = dsa_cpu_dsa_setup(ds, dst->master_netdev); + if (ret < 0) { + netdev_err(dst->master_netdev, "[%d] : can't configure CPU and DSA ports\n", + index); + ret = 0; + } + #ifdef CONFIG_NET_DSA_HWMON /* If the switch provides a temperature sensor, * register with hardware monitoring subsystem. |