Commit 82fdbb91 authored by Russell King (Oracle)'s avatar Russell King (Oracle) Committed by David S. Miller

net: dsa: ksz8795: convert to phylink_generic_validate()

Populate the supported interfaces and MAC capabilities for the
Microchip KSZ8795 DSA switch and remove the old validate implementation
to allow DSA to use phylink_generic_validate() for this switch driver.
Signed-off-by: default avatarRussell King (Oracle) <rmk+kernel@armlinux.org.uk>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 927c9dae
...@@ -1461,27 +1461,22 @@ static int ksz8_setup(struct dsa_switch *ds) ...@@ -1461,27 +1461,22 @@ static int ksz8_setup(struct dsa_switch *ds)
return 0; return 0;
} }
static void ksz8_validate(struct dsa_switch *ds, int port, static void ksz8_get_caps(struct dsa_switch *ds, int port,
unsigned long *supported, struct phylink_config *config)
struct phylink_link_state *state)
{ {
__ETHTOOL_DECLARE_LINK_MODE_MASK(mask) = { 0, };
struct ksz_device *dev = ds->priv; struct ksz_device *dev = ds->priv;
if (port == dev->cpu_port) { if (port == dev->cpu_port) {
if (state->interface != PHY_INTERFACE_MODE_RMII && __set_bit(PHY_INTERFACE_MODE_RMII,
state->interface != PHY_INTERFACE_MODE_MII && config->supported_interfaces);
state->interface != PHY_INTERFACE_MODE_NA) __set_bit(PHY_INTERFACE_MODE_MII,
goto unsupported; config->supported_interfaces);
} else { } else {
if (state->interface != PHY_INTERFACE_MODE_INTERNAL && __set_bit(PHY_INTERFACE_MODE_INTERNAL,
state->interface != PHY_INTERFACE_MODE_NA) config->supported_interfaces);
goto unsupported;
} }
/* Allow all the expected bits */ config->mac_capabilities = MAC_10 | MAC_100;
phylink_set_port_modes(mask);
phylink_set(mask, Autoneg);
/* Silicon Errata Sheet (DS80000830A): /* Silicon Errata Sheet (DS80000830A):
* "Port 1 does not respond to received flow control PAUSE frames" * "Port 1 does not respond to received flow control PAUSE frames"
...@@ -1489,27 +1484,11 @@ static void ksz8_validate(struct dsa_switch *ds, int port, ...@@ -1489,27 +1484,11 @@ static void ksz8_validate(struct dsa_switch *ds, int port,
* switches. * switches.
*/ */
if (!ksz_is_ksz88x3(dev) || port) if (!ksz_is_ksz88x3(dev) || port)
phylink_set(mask, Pause); config->mac_capabilities |= MAC_SYM_PAUSE;
/* Asym pause is not supported on KSZ8863 and KSZ8873 */ /* Asym pause is not supported on KSZ8863 and KSZ8873 */
if (!ksz_is_ksz88x3(dev)) if (!ksz_is_ksz88x3(dev))
phylink_set(mask, Asym_Pause); config->mac_capabilities |= MAC_ASYM_PAUSE;
/* 10M and 100M are only supported */
phylink_set(mask, 10baseT_Half);
phylink_set(mask, 10baseT_Full);
phylink_set(mask, 100baseT_Half);
phylink_set(mask, 100baseT_Full);
linkmode_and(supported, supported, mask);
linkmode_and(state->advertising, state->advertising, mask);
return;
unsupported:
linkmode_zero(supported);
dev_err(ds->dev, "Unsupported interface: %s, port: %d\n",
phy_modes(state->interface), port);
} }
static const struct dsa_switch_ops ksz8_switch_ops = { static const struct dsa_switch_ops ksz8_switch_ops = {
...@@ -1518,7 +1497,7 @@ static const struct dsa_switch_ops ksz8_switch_ops = { ...@@ -1518,7 +1497,7 @@ static const struct dsa_switch_ops ksz8_switch_ops = {
.setup = ksz8_setup, .setup = ksz8_setup,
.phy_read = ksz_phy_read16, .phy_read = ksz_phy_read16,
.phy_write = ksz_phy_write16, .phy_write = ksz_phy_write16,
.phylink_validate = ksz8_validate, .phylink_get_caps = ksz8_get_caps,
.phylink_mac_link_down = ksz_mac_link_down, .phylink_mac_link_down = ksz_mac_link_down,
.port_enable = ksz_enable_port, .port_enable = ksz_enable_port,
.get_strings = ksz8_get_strings, .get_strings = ksz8_get_strings,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment