Skip to content

Commit 62d6d91

Browse files
Russell King (Oracle)Paolo Abeni
authored andcommitted
net: dsa: mt7530: provide own phylink MAC operations
Convert mt753x to provide its own phylink MAC operations, thus avoiding the shim layer in DSA's port.c Signed-off-by: Russell King (Oracle) <[email protected]> Tested-by: Arınç ÜNAL <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Paolo Abeni <[email protected]>
1 parent 94c437e commit 62d6d91

File tree

1 file changed

+29
-17
lines changed

1 file changed

+29
-17
lines changed

drivers/net/dsa/mt7530.c

Lines changed: 29 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2850,28 +2850,34 @@ mt7531_mac_config(struct dsa_switch *ds, int port, unsigned int mode,
28502850
}
28512851

28522852
static struct phylink_pcs *
2853-
mt753x_phylink_mac_select_pcs(struct dsa_switch *ds, int port,
2853+
mt753x_phylink_mac_select_pcs(struct phylink_config *config,
28542854
phy_interface_t interface)
28552855
{
2856-
struct mt7530_priv *priv = ds->priv;
2856+
struct dsa_port *dp = dsa_phylink_to_port(config);
2857+
struct mt7530_priv *priv = dp->ds->priv;
28572858

28582859
switch (interface) {
28592860
case PHY_INTERFACE_MODE_TRGMII:
2860-
return &priv->pcs[port].pcs;
2861+
return &priv->pcs[dp->index].pcs;
28612862
case PHY_INTERFACE_MODE_SGMII:
28622863
case PHY_INTERFACE_MODE_1000BASEX:
28632864
case PHY_INTERFACE_MODE_2500BASEX:
2864-
return priv->ports[port].sgmii_pcs;
2865+
return priv->ports[dp->index].sgmii_pcs;
28652866
default:
28662867
return NULL;
28672868
}
28682869
}
28692870

28702871
static void
2871-
mt753x_phylink_mac_config(struct dsa_switch *ds, int port, unsigned int mode,
2872+
mt753x_phylink_mac_config(struct phylink_config *config, unsigned int mode,
28722873
const struct phylink_link_state *state)
28732874
{
2874-
struct mt7530_priv *priv = ds->priv;
2875+
struct dsa_port *dp = dsa_phylink_to_port(config);
2876+
struct dsa_switch *ds = dp->ds;
2877+
struct mt7530_priv *priv;
2878+
int port = dp->index;
2879+
2880+
priv = ds->priv;
28752881

28762882
if ((port == 5 || port == 6) && priv->info->mac_port_config)
28772883
priv->info->mac_port_config(ds, port, mode, state->interface);
@@ -2881,23 +2887,25 @@ mt753x_phylink_mac_config(struct dsa_switch *ds, int port, unsigned int mode,
28812887
mt7530_set(priv, MT7530_PMCR_P(port), PMCR_EXT_PHY);
28822888
}
28832889

2884-
static void mt753x_phylink_mac_link_down(struct dsa_switch *ds, int port,
2890+
static void mt753x_phylink_mac_link_down(struct phylink_config *config,
28852891
unsigned int mode,
28862892
phy_interface_t interface)
28872893
{
2888-
struct mt7530_priv *priv = ds->priv;
2894+
struct dsa_port *dp = dsa_phylink_to_port(config);
2895+
struct mt7530_priv *priv = dp->ds->priv;
28892896

2890-
mt7530_clear(priv, MT7530_PMCR_P(port), PMCR_LINK_SETTINGS_MASK);
2897+
mt7530_clear(priv, MT7530_PMCR_P(dp->index), PMCR_LINK_SETTINGS_MASK);
28912898
}
28922899

2893-
static void mt753x_phylink_mac_link_up(struct dsa_switch *ds, int port,
2900+
static void mt753x_phylink_mac_link_up(struct phylink_config *config,
2901+
struct phy_device *phydev,
28942902
unsigned int mode,
28952903
phy_interface_t interface,
2896-
struct phy_device *phydev,
28972904
int speed, int duplex,
28982905
bool tx_pause, bool rx_pause)
28992906
{
2900-
struct mt7530_priv *priv = ds->priv;
2907+
struct dsa_port *dp = dsa_phylink_to_port(config);
2908+
struct mt7530_priv *priv = dp->ds->priv;
29012909
u32 mcr;
29022910

29032911
mcr = PMCR_RX_EN | PMCR_TX_EN | PMCR_FORCE_LNK;
@@ -2932,7 +2940,7 @@ static void mt753x_phylink_mac_link_up(struct dsa_switch *ds, int port,
29322940
}
29332941
}
29342942

2935-
mt7530_set(priv, MT7530_PMCR_P(port), mcr);
2943+
mt7530_set(priv, MT7530_PMCR_P(dp->index), mcr);
29362944
}
29372945

29382946
static void mt753x_phylink_get_caps(struct dsa_switch *ds, int port,
@@ -3152,16 +3160,19 @@ const struct dsa_switch_ops mt7530_switch_ops = {
31523160
.port_mirror_add = mt753x_port_mirror_add,
31533161
.port_mirror_del = mt753x_port_mirror_del,
31543162
.phylink_get_caps = mt753x_phylink_get_caps,
3155-
.phylink_mac_select_pcs = mt753x_phylink_mac_select_pcs,
3156-
.phylink_mac_config = mt753x_phylink_mac_config,
3157-
.phylink_mac_link_down = mt753x_phylink_mac_link_down,
3158-
.phylink_mac_link_up = mt753x_phylink_mac_link_up,
31593163
.get_mac_eee = mt753x_get_mac_eee,
31603164
.set_mac_eee = mt753x_set_mac_eee,
31613165
.conduit_state_change = mt753x_conduit_state_change,
31623166
};
31633167
EXPORT_SYMBOL_GPL(mt7530_switch_ops);
31643168

3169+
static const struct phylink_mac_ops mt753x_phylink_mac_ops = {
3170+
.mac_select_pcs = mt753x_phylink_mac_select_pcs,
3171+
.mac_config = mt753x_phylink_mac_config,
3172+
.mac_link_down = mt753x_phylink_mac_link_down,
3173+
.mac_link_up = mt753x_phylink_mac_link_up,
3174+
};
3175+
31653176
const struct mt753x_info mt753x_table[] = {
31663177
[ID_MT7621] = {
31673178
.id = ID_MT7621,
@@ -3239,6 +3250,7 @@ mt7530_probe_common(struct mt7530_priv *priv)
32393250
priv->dev = dev;
32403251
priv->ds->priv = priv;
32413252
priv->ds->ops = &mt7530_switch_ops;
3253+
priv->ds->phylink_mac_ops = &mt753x_phylink_mac_ops;
32423254
mutex_init(&priv->reg_mutex);
32433255
dev_set_drvdata(dev, priv);
32443256

0 commit comments

Comments
 (0)