Commit 0be9a1e4 authored by Russell King (Oracle)'s avatar Russell King (Oracle) Committed by Paolo Abeni

net: dsa: sja1105: provide own phylink MAC operations

Convert sja1105 to provide its own phylink MAC operations, thus
avoiding the shim layer in DSA's port.c
Signed-off-by: default avatarRussell King (Oracle) <rmk+kernel@armlinux.org.uk>
Reviewed-by: default avatarFlorian Fainelli <florian.fainelli@broadcom.com>
Link: https://lore.kernel.org/r/E1rvIcT-006bQW-S3@rmk-PC.armlinux.org.ukSigned-off-by: default avatarPaolo Abeni <pabeni@redhat.com>
parent bb72159c
...@@ -1358,10 +1358,11 @@ static int sja1105_adjust_port_config(struct sja1105_private *priv, int port, ...@@ -1358,10 +1358,11 @@ static int sja1105_adjust_port_config(struct sja1105_private *priv, int port,
} }
static struct phylink_pcs * static struct phylink_pcs *
sja1105_mac_select_pcs(struct dsa_switch *ds, int port, phy_interface_t iface) sja1105_mac_select_pcs(struct phylink_config *config, phy_interface_t iface)
{ {
struct sja1105_private *priv = ds->priv; struct dsa_port *dp = dsa_phylink_to_port(config);
struct dw_xpcs *xpcs = priv->xpcs[port]; struct sja1105_private *priv = dp->ds->priv;
struct dw_xpcs *xpcs = priv->xpcs[dp->index];
if (xpcs) if (xpcs)
return &xpcs->pcs; return &xpcs->pcs;
...@@ -1369,21 +1370,31 @@ sja1105_mac_select_pcs(struct dsa_switch *ds, int port, phy_interface_t iface) ...@@ -1369,21 +1370,31 @@ sja1105_mac_select_pcs(struct dsa_switch *ds, int port, phy_interface_t iface)
return NULL; return NULL;
} }
static void sja1105_mac_link_down(struct dsa_switch *ds, int port, static void sja1105_mac_config(struct phylink_config *config,
unsigned int mode,
const struct phylink_link_state *state)
{
}
static void sja1105_mac_link_down(struct phylink_config *config,
unsigned int mode, unsigned int mode,
phy_interface_t interface) phy_interface_t interface)
{ {
sja1105_inhibit_tx(ds->priv, BIT(port), true); struct dsa_port *dp = dsa_phylink_to_port(config);
sja1105_inhibit_tx(dp->ds->priv, BIT(dp->index), true);
} }
static void sja1105_mac_link_up(struct dsa_switch *ds, int port, static void sja1105_mac_link_up(struct phylink_config *config,
struct phy_device *phydev,
unsigned int mode, unsigned int mode,
phy_interface_t interface, phy_interface_t interface,
struct phy_device *phydev,
int speed, int duplex, int speed, int duplex,
bool tx_pause, bool rx_pause) bool tx_pause, bool rx_pause)
{ {
struct sja1105_private *priv = ds->priv; struct dsa_port *dp = dsa_phylink_to_port(config);
struct sja1105_private *priv = dp->ds->priv;
int port = dp->index;
sja1105_adjust_port_config(priv, port, speed); sja1105_adjust_port_config(priv, port, speed);
...@@ -3198,6 +3209,13 @@ static void sja1105_teardown(struct dsa_switch *ds) ...@@ -3198,6 +3209,13 @@ static void sja1105_teardown(struct dsa_switch *ds)
sja1105_static_config_free(&priv->static_config); sja1105_static_config_free(&priv->static_config);
} }
static const struct phylink_mac_ops sja1105_phylink_mac_ops = {
.mac_select_pcs = sja1105_mac_select_pcs,
.mac_config = sja1105_mac_config,
.mac_link_up = sja1105_mac_link_up,
.mac_link_down = sja1105_mac_link_down,
};
static const struct dsa_switch_ops sja1105_switch_ops = { static const struct dsa_switch_ops sja1105_switch_ops = {
.get_tag_protocol = sja1105_get_tag_protocol, .get_tag_protocol = sja1105_get_tag_protocol,
.connect_tag_protocol = sja1105_connect_tag_protocol, .connect_tag_protocol = sja1105_connect_tag_protocol,
...@@ -3207,9 +3225,6 @@ static const struct dsa_switch_ops sja1105_switch_ops = { ...@@ -3207,9 +3225,6 @@ static const struct dsa_switch_ops sja1105_switch_ops = {
.port_change_mtu = sja1105_change_mtu, .port_change_mtu = sja1105_change_mtu,
.port_max_mtu = sja1105_get_max_mtu, .port_max_mtu = sja1105_get_max_mtu,
.phylink_get_caps = sja1105_phylink_get_caps, .phylink_get_caps = sja1105_phylink_get_caps,
.phylink_mac_select_pcs = sja1105_mac_select_pcs,
.phylink_mac_link_up = sja1105_mac_link_up,
.phylink_mac_link_down = sja1105_mac_link_down,
.get_strings = sja1105_get_strings, .get_strings = sja1105_get_strings,
.get_ethtool_stats = sja1105_get_ethtool_stats, .get_ethtool_stats = sja1105_get_ethtool_stats,
.get_sset_count = sja1105_get_sset_count, .get_sset_count = sja1105_get_sset_count,
...@@ -3375,6 +3390,7 @@ static int sja1105_probe(struct spi_device *spi) ...@@ -3375,6 +3390,7 @@ static int sja1105_probe(struct spi_device *spi)
ds->dev = dev; ds->dev = dev;
ds->num_ports = priv->info->num_ports; ds->num_ports = priv->info->num_ports;
ds->ops = &sja1105_switch_ops; ds->ops = &sja1105_switch_ops;
ds->phylink_mac_ops = &sja1105_phylink_mac_ops;
ds->priv = priv; ds->priv = priv;
priv->ds = ds; priv->ds = ds;
......
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