Commit 9452c8b4 authored by Paolo Abeni's avatar Paolo Abeni

Merge branch 'mt7530-dsa-subdriver-improvements-act-iii'

 says:

====================
MT7530 DSA Subdriver Improvements Act III

This is the third patch series with the goal of simplifying the MT7530 DSA
subdriver and improving support for MT7530, MT7531, and the switch on the
MT7988 SoC.

I have done a simple ping test to confirm basic communication on all switch
ports on MCM and standalone MT7530, and MT7531 switch with this patch
series applied.

MT7621 Unielec, MCM MT7530:

rgmii-only-gmac0-mt7621-unielec-u7621-06-16m.dtb
gmac0-and-gmac1-mt7621-unielec-u7621-06-16m.dtb

tftpboot 0x80008000 mips-uzImage.bin; tftpboot 0x83000000 mips-rootfs.cpio.uboot; tftpboot 0x83f00000 $dtb; bootm 0x80008000 0x83000000 0x83f00000

MT7622 Bananapi, MT7531:

gmac0-and-gmac1-mt7622-bananapi-bpi-r64.dtb

tftpboot 0x40000000 arm64-Image; tftpboot 0x45000000 arm64-rootfs.cpio.uboot; tftpboot 0x4a000000 $dtb; booti 0x40000000 0x45000000 0x4a000000

MT7623 Bananapi, standalone MT7530:

rgmii-only-gmac0-mt7623n-bananapi-bpi-r2.dtb
gmac0-and-gmac1-mt7623n-bananapi-bpi-r2.dtb

tftpboot 0x80008000 arm-zImage; tftpboot 0x83000000 arm-rootfs.cpio.uboot; tftpboot 0x83f00000 $dtb; bootz 0x80008000 0x83000000 0x83f00000

This patch series is the continuation of the patch series linked below.

https://lore.kernel.org/r/20230522121532.86610-1-arinc.unal@arinc9.comSigned-off-by: default avatarArınç ÜNAL <arinc.unal@arinc9.com>
---
Changes in v3:
- Patch 8
  - Explain properly the behaviour of setting link down on all ports at
    setup.
  - Split the changes for simplifying the link settings operations out to
    another patch.
- Link to v2: https://lore.kernel.org/r/20240216-for-netnext-mt7530-improvements-3-v2-0-094cae3ff23b@arinc9.com

Changes in v2:
- Patch 8
  - Use a single mt7530_rmw() instead of two mt7530_clear() and
    mt7530_set() commands.
- Link to v1: https://lore.kernel.org/r/20240208-for-netnext-mt7530-improvements-3-v1-0-d7c1cfd502ca@arinc9.com
====================

Link: https://lore.kernel.org/r/20240301-for-netnext-mt7530-improvements-3-v3-0-449f4f166454@arinc9.comSigned-off-by: default avatarPaolo Abeni <pabeni@redhat.com>
parents 6702d60d b04097c7
...@@ -966,18 +966,10 @@ mt753x_trap_frames(struct mt7530_priv *priv) ...@@ -966,18 +966,10 @@ mt753x_trap_frames(struct mt7530_priv *priv)
MT753X_R0E_PORT_FW(MT753X_BPDU_CPU_ONLY)); MT753X_R0E_PORT_FW(MT753X_BPDU_CPU_ONLY));
} }
static int static void
mt753x_cpu_port_enable(struct dsa_switch *ds, int port) mt753x_cpu_port_enable(struct dsa_switch *ds, int port)
{ {
struct mt7530_priv *priv = ds->priv; struct mt7530_priv *priv = ds->priv;
int ret;
/* Setup max capability of CPU port at first */
if (priv->info->cpu_port_config) {
ret = priv->info->cpu_port_config(ds, port);
if (ret)
return ret;
}
/* Enable Mediatek header mode on the cpu port */ /* Enable Mediatek header mode on the cpu port */
mt7530_write(priv, MT7530_PVC_P(port), mt7530_write(priv, MT7530_PVC_P(port),
...@@ -1003,8 +995,6 @@ mt753x_cpu_port_enable(struct dsa_switch *ds, int port) ...@@ -1003,8 +995,6 @@ mt753x_cpu_port_enable(struct dsa_switch *ds, int port)
/* Set to fallback mode for independent VLAN learning */ /* Set to fallback mode for independent VLAN learning */
mt7530_rmw(priv, MT7530_PCR_P(port), PCR_PORT_VLAN_MASK, mt7530_rmw(priv, MT7530_PCR_P(port), PCR_PORT_VLAN_MASK,
MT7530_PORT_FALLBACK_MODE); MT7530_PORT_FALLBACK_MODE);
return 0;
} }
static int static int
...@@ -1028,7 +1018,6 @@ mt7530_port_enable(struct dsa_switch *ds, int port, ...@@ -1028,7 +1018,6 @@ mt7530_port_enable(struct dsa_switch *ds, int port,
priv->ports[port].enable = true; priv->ports[port].enable = true;
mt7530_rmw(priv, MT7530_PCR_P(port), PCR_MATRIX_MASK, mt7530_rmw(priv, MT7530_PCR_P(port), PCR_MATRIX_MASK,
priv->ports[port].pm); priv->ports[port].pm);
mt7530_clear(priv, MT7530_PMCR_P(port), PMCR_LINK_SETTINGS_MASK);
mutex_unlock(&priv->reg_mutex); mutex_unlock(&priv->reg_mutex);
...@@ -1048,7 +1037,6 @@ mt7530_port_disable(struct dsa_switch *ds, int port) ...@@ -1048,7 +1037,6 @@ mt7530_port_disable(struct dsa_switch *ds, int port)
priv->ports[port].enable = false; priv->ports[port].enable = false;
mt7530_rmw(priv, MT7530_PCR_P(port), PCR_MATRIX_MASK, mt7530_rmw(priv, MT7530_PCR_P(port), PCR_MATRIX_MASK,
PCR_MATRIX_CLR); PCR_MATRIX_CLR);
mt7530_clear(priv, MT7530_PMCR_P(port), PMCR_LINK_SETTINGS_MASK);
mutex_unlock(&priv->reg_mutex); mutex_unlock(&priv->reg_mutex);
} }
...@@ -2055,7 +2043,7 @@ mt7530_setup_irq(struct mt7530_priv *priv) ...@@ -2055,7 +2043,7 @@ mt7530_setup_irq(struct mt7530_priv *priv)
} }
/* This register must be set for MT7530 to properly fire interrupts */ /* This register must be set for MT7530 to properly fire interrupts */
if (priv->id != ID_MT7531) if (priv->id == ID_MT7530 || priv->id == ID_MT7621)
mt7530_set(priv, MT7530_TOP_SIG_CTRL, TOP_SIG_CTRL_NORMAL); mt7530_set(priv, MT7530_TOP_SIG_CTRL, TOP_SIG_CTRL_NORMAL);
ret = request_threaded_irq(priv->irq, NULL, mt7530_irq_thread_fn, ret = request_threaded_irq(priv->irq, NULL, mt7530_irq_thread_fn,
...@@ -2261,14 +2249,18 @@ mt7530_setup(struct dsa_switch *ds) ...@@ -2261,14 +2249,18 @@ mt7530_setup(struct dsa_switch *ds)
val |= MHWTRAP_MANUAL; val |= MHWTRAP_MANUAL;
mt7530_write(priv, MT7530_MHWTRAP, val); mt7530_write(priv, MT7530_MHWTRAP, val);
priv->p6_interface = PHY_INTERFACE_MODE_NA;
mt753x_trap_frames(priv); mt753x_trap_frames(priv);
/* Enable and reset MIB counters */ /* Enable and reset MIB counters */
mt7530_mib_reset(ds); mt7530_mib_reset(ds);
for (i = 0; i < MT7530_NUM_PORTS; i++) { for (i = 0; i < MT7530_NUM_PORTS; i++) {
/* Clear link settings and enable force mode to force link down
* on all ports until they're enabled later.
*/
mt7530_rmw(priv, MT7530_PMCR_P(i), PMCR_LINK_SETTINGS_MASK |
PMCR_FORCE_MODE, PMCR_FORCE_MODE);
/* Disable forwarding by default on all ports */ /* Disable forwarding by default on all ports */
mt7530_rmw(priv, MT7530_PCR_P(i), PCR_MATRIX_MASK, mt7530_rmw(priv, MT7530_PCR_P(i), PCR_MATRIX_MASK,
PCR_MATRIX_CLR); PCR_MATRIX_CLR);
...@@ -2277,9 +2269,7 @@ mt7530_setup(struct dsa_switch *ds) ...@@ -2277,9 +2269,7 @@ mt7530_setup(struct dsa_switch *ds)
mt7530_set(priv, MT7530_PSC_P(i), SA_DIS); mt7530_set(priv, MT7530_PSC_P(i), SA_DIS);
if (dsa_is_cpu_port(ds, i)) { if (dsa_is_cpu_port(ds, i)) {
ret = mt753x_cpu_port_enable(ds, i); mt753x_cpu_port_enable(ds, i);
if (ret)
return ret;
} else { } else {
mt7530_port_disable(ds, i); mt7530_port_disable(ds, i);
...@@ -2373,6 +2363,12 @@ mt7531_setup_common(struct dsa_switch *ds) ...@@ -2373,6 +2363,12 @@ mt7531_setup_common(struct dsa_switch *ds)
UNU_FFP_MASK); UNU_FFP_MASK);
for (i = 0; i < MT7530_NUM_PORTS; i++) { for (i = 0; i < MT7530_NUM_PORTS; i++) {
/* Clear link settings and enable force mode to force link down
* on all ports until they're enabled later.
*/
mt7530_rmw(priv, MT7530_PMCR_P(i), PMCR_LINK_SETTINGS_MASK |
MT7531_FORCE_MODE, MT7531_FORCE_MODE);
/* Disable forwarding by default on all ports */ /* Disable forwarding by default on all ports */
mt7530_rmw(priv, MT7530_PCR_P(i), PCR_MATRIX_MASK, mt7530_rmw(priv, MT7530_PCR_P(i), PCR_MATRIX_MASK,
PCR_MATRIX_CLR); PCR_MATRIX_CLR);
...@@ -2383,9 +2379,7 @@ mt7531_setup_common(struct dsa_switch *ds) ...@@ -2383,9 +2379,7 @@ mt7531_setup_common(struct dsa_switch *ds)
mt7530_set(priv, MT7531_DBG_CNT(i), MT7531_DIS_CLR); mt7530_set(priv, MT7531_DBG_CNT(i), MT7531_DIS_CLR);
if (dsa_is_cpu_port(ds, i)) { if (dsa_is_cpu_port(ds, i)) {
ret = mt753x_cpu_port_enable(ds, i); mt753x_cpu_port_enable(ds, i);
if (ret)
return ret;
} else { } else {
mt7530_port_disable(ds, i); mt7530_port_disable(ds, i);
...@@ -2451,14 +2445,12 @@ mt7531_setup(struct dsa_switch *ds) ...@@ -2451,14 +2445,12 @@ mt7531_setup(struct dsa_switch *ds)
val = mt7530_read(priv, MT7531_TOP_SIG_SR); val = mt7530_read(priv, MT7531_TOP_SIG_SR);
priv->p5_sgmii = !!(val & PAD_DUAL_SGMII_EN); priv->p5_sgmii = !!(val & PAD_DUAL_SGMII_EN);
/* all MACs must be forced link-down before sw reset */ /* Force link down on all ports before internal reset */
for (i = 0; i < MT7530_NUM_PORTS; i++) for (i = 0; i < MT7530_NUM_PORTS; i++)
mt7530_write(priv, MT7530_PMCR_P(i), MT7531_FORCE_LNK); mt7530_write(priv, MT7530_PMCR_P(i), MT7531_FORCE_LNK);
/* Reset the switch through internal reset */ /* Reset the switch through internal reset */
mt7530_write(priv, MT7530_SYS_CTRL, mt7530_write(priv, MT7530_SYS_CTRL, SYS_CTRL_SW_RST | SYS_CTRL_REG_RST);
SYS_CTRL_PHY_RST | SYS_CTRL_SW_RST |
SYS_CTRL_REG_RST);
if (!priv->p5_sgmii) { if (!priv->p5_sgmii) {
mt7531_pll_setup(priv); mt7531_pll_setup(priv);
...@@ -2476,10 +2468,6 @@ mt7531_setup(struct dsa_switch *ds) ...@@ -2476,10 +2468,6 @@ mt7531_setup(struct dsa_switch *ds)
mt7530_rmw(priv, MT7531_GPIO_MODE0, MT7531_GPIO0_MASK, mt7530_rmw(priv, MT7531_GPIO_MODE0, MT7531_GPIO0_MASK,
MT7531_GPIO0_INTERRUPT); MT7531_GPIO0_INTERRUPT);
/* Let phylink decide the interface later. */
priv->p5_interface = PHY_INTERFACE_MODE_NA;
priv->p6_interface = PHY_INTERFACE_MODE_NA;
/* Enable PHY core PLL, since phy_device has not yet been created /* Enable PHY core PLL, since phy_device has not yet been created
* provided for phy_[read,write]_mmd_indirect is called, we provide * provided for phy_[read,write]_mmd_indirect is called, we provide
* our own mt7531_ind_mmd_phy_[read,write] to complete this * our own mt7531_ind_mmd_phy_[read,write] to complete this
...@@ -2589,7 +2577,7 @@ static void mt7988_mac_port_get_caps(struct dsa_switch *ds, int port, ...@@ -2589,7 +2577,7 @@ static void mt7988_mac_port_get_caps(struct dsa_switch *ds, int port,
} }
} }
static int static void
mt7530_mac_config(struct dsa_switch *ds, int port, unsigned int mode, mt7530_mac_config(struct dsa_switch *ds, int port, unsigned int mode,
phy_interface_t interface) phy_interface_t interface)
{ {
...@@ -2599,22 +2587,14 @@ mt7530_mac_config(struct dsa_switch *ds, int port, unsigned int mode, ...@@ -2599,22 +2587,14 @@ mt7530_mac_config(struct dsa_switch *ds, int port, unsigned int mode,
mt7530_setup_port5(priv->ds, interface); mt7530_setup_port5(priv->ds, interface);
else if (port == 6) else if (port == 6)
mt7530_setup_port6(priv->ds, interface); mt7530_setup_port6(priv->ds, interface);
return 0;
} }
static int mt7531_rgmii_setup(struct mt7530_priv *priv, u32 port, static void mt7531_rgmii_setup(struct mt7530_priv *priv, u32 port,
phy_interface_t interface, phy_interface_t interface,
struct phy_device *phydev) struct phy_device *phydev)
{ {
u32 val; u32 val;
if (priv->p5_sgmii) {
dev_err(priv->dev, "RGMII mode is not available for port %d\n",
port);
return -EINVAL;
}
val = mt7530_read(priv, MT7531_CLKGEN_CTRL); val = mt7530_read(priv, MT7531_CLKGEN_CTRL);
val |= GP_CLK_EN; val |= GP_CLK_EN;
val &= ~GP_MODE_MASK; val &= ~GP_MODE_MASK;
...@@ -2642,31 +2622,14 @@ static int mt7531_rgmii_setup(struct mt7530_priv *priv, u32 port, ...@@ -2642,31 +2622,14 @@ static int mt7531_rgmii_setup(struct mt7530_priv *priv, u32 port,
case PHY_INTERFACE_MODE_RGMII_ID: case PHY_INTERFACE_MODE_RGMII_ID:
break; break;
default: default:
return -EINVAL; break;
} }
} }
mt7530_write(priv, MT7531_CLKGEN_CTRL, val);
return 0;
}
static bool mt753x_is_mac_port(u32 port) mt7530_write(priv, MT7531_CLKGEN_CTRL, val);
{
return (port == 5 || port == 6);
}
static int
mt7988_mac_config(struct dsa_switch *ds, int port, unsigned int mode,
phy_interface_t interface)
{
if (dsa_is_cpu_port(ds, port) &&
interface == PHY_INTERFACE_MODE_INTERNAL)
return 0;
return -EINVAL;
} }
static int static void
mt7531_mac_config(struct dsa_switch *ds, int port, unsigned int mode, mt7531_mac_config(struct dsa_switch *ds, int port, unsigned int mode,
phy_interface_t interface) phy_interface_t interface)
{ {
...@@ -2674,39 +2637,11 @@ mt7531_mac_config(struct dsa_switch *ds, int port, unsigned int mode, ...@@ -2674,39 +2637,11 @@ mt7531_mac_config(struct dsa_switch *ds, int port, unsigned int mode,
struct phy_device *phydev; struct phy_device *phydev;
struct dsa_port *dp; struct dsa_port *dp;
if (!mt753x_is_mac_port(port)) { if (phy_interface_mode_is_rgmii(interface)) {
dev_err(priv->dev, "port %d is not a MAC port\n", port);
return -EINVAL;
}
switch (interface) {
case PHY_INTERFACE_MODE_RGMII:
case PHY_INTERFACE_MODE_RGMII_ID:
case PHY_INTERFACE_MODE_RGMII_RXID:
case PHY_INTERFACE_MODE_RGMII_TXID:
dp = dsa_to_port(ds, port); dp = dsa_to_port(ds, port);
phydev = dp->user->phydev; phydev = dp->user->phydev;
return mt7531_rgmii_setup(priv, port, interface, phydev); mt7531_rgmii_setup(priv, port, interface, phydev);
case PHY_INTERFACE_MODE_SGMII:
case PHY_INTERFACE_MODE_NA:
case PHY_INTERFACE_MODE_1000BASEX:
case PHY_INTERFACE_MODE_2500BASEX:
/* handled in SGMII PCS driver */
return 0;
default:
return -EINVAL;
} }
return -EINVAL;
}
static int
mt753x_mac_config(struct dsa_switch *ds, int port, unsigned int mode,
const struct phylink_link_state *state)
{
struct mt7530_priv *priv = ds->priv;
return priv->info->mac_port_config(ds, port, mode, state->interface);
} }
static struct phylink_pcs * static struct phylink_pcs *
...@@ -2732,52 +2667,13 @@ mt753x_phylink_mac_config(struct dsa_switch *ds, int port, unsigned int mode, ...@@ -2732,52 +2667,13 @@ mt753x_phylink_mac_config(struct dsa_switch *ds, int port, unsigned int mode,
const struct phylink_link_state *state) const struct phylink_link_state *state)
{ {
struct mt7530_priv *priv = ds->priv; struct mt7530_priv *priv = ds->priv;
u32 mcr_cur, mcr_new;
switch (port) { if ((port == 5 || port == 6) && priv->info->mac_port_config)
case 0 ... 4: priv->info->mac_port_config(ds, port, mode, state->interface);
if (state->interface != PHY_INTERFACE_MODE_GMII &&
state->interface != PHY_INTERFACE_MODE_INTERNAL)
goto unsupported;
break;
case 5:
if (priv->p5_interface == state->interface)
break;
if (mt753x_mac_config(ds, port, mode, state) < 0)
goto unsupported;
if (priv->p5_intf_sel != P5_DISABLED)
priv->p5_interface = state->interface;
break;
case 6:
if (priv->p6_interface == state->interface)
break;
if (mt753x_mac_config(ds, port, mode, state) < 0)
goto unsupported;
priv->p6_interface = state->interface;
break;
default:
unsupported:
dev_err(ds->dev, "%s: unsupported %s port: %i\n",
__func__, phy_modes(state->interface), port);
return;
}
mcr_cur = mt7530_read(priv, MT7530_PMCR_P(port));
mcr_new = mcr_cur;
mcr_new &= ~PMCR_LINK_SETTINGS_MASK;
mcr_new |= PMCR_IFG_XMIT(1) | PMCR_MAC_MODE | PMCR_BACKOFF_EN |
PMCR_BACKPR_EN | PMCR_FORCE_MODE_ID(priv->id);
/* Are we connected to external phy */ /* Are we connected to external phy */
if (port == 5 && dsa_is_user_port(ds, 5)) if (port == 5 && dsa_is_user_port(ds, 5))
mcr_new |= PMCR_EXT_PHY; mt7530_set(priv, MT7530_PMCR_P(port), PMCR_EXT_PHY);
if (mcr_new != mcr_cur)
mt7530_write(priv, MT7530_PMCR_P(port), mcr_new);
} }
static void mt753x_phylink_mac_link_down(struct dsa_switch *ds, int port, static void mt753x_phylink_mac_link_down(struct dsa_switch *ds, int port,
...@@ -2801,17 +2697,10 @@ static void mt753x_phylink_mac_link_up(struct dsa_switch *ds, int port, ...@@ -2801,17 +2697,10 @@ static void mt753x_phylink_mac_link_up(struct dsa_switch *ds, int port,
mcr = PMCR_RX_EN | PMCR_TX_EN | PMCR_FORCE_LNK; mcr = PMCR_RX_EN | PMCR_TX_EN | PMCR_FORCE_LNK;
/* MT753x MAC works in 1G full duplex mode for all up-clocked
* variants.
*/
if (interface == PHY_INTERFACE_MODE_TRGMII ||
(phy_interface_mode_is_8023z(interface))) {
speed = SPEED_1000;
duplex = DUPLEX_FULL;
}
switch (speed) { switch (speed) {
case SPEED_1000: case SPEED_1000:
case SPEED_2500:
case SPEED_10000:
mcr |= PMCR_FORCE_SPEED_1000; mcr |= PMCR_FORCE_SPEED_1000;
break; break;
case SPEED_100: case SPEED_100:
...@@ -2829,6 +2718,7 @@ static void mt753x_phylink_mac_link_up(struct dsa_switch *ds, int port, ...@@ -2829,6 +2718,7 @@ static void mt753x_phylink_mac_link_up(struct dsa_switch *ds, int port,
if (mode == MLO_AN_PHY && phydev && phy_init_eee(phydev, false) >= 0) { if (mode == MLO_AN_PHY && phydev && phy_init_eee(phydev, false) >= 0) {
switch (speed) { switch (speed) {
case SPEED_1000: case SPEED_1000:
case SPEED_2500:
mcr |= PMCR_FORCE_EEE1G; mcr |= PMCR_FORCE_EEE1G;
break; break;
case SPEED_100: case SPEED_100:
...@@ -2840,63 +2730,6 @@ static void mt753x_phylink_mac_link_up(struct dsa_switch *ds, int port, ...@@ -2840,63 +2730,6 @@ static void mt753x_phylink_mac_link_up(struct dsa_switch *ds, int port,
mt7530_set(priv, MT7530_PMCR_P(port), mcr); mt7530_set(priv, MT7530_PMCR_P(port), mcr);
} }
static int
mt7531_cpu_port_config(struct dsa_switch *ds, int port)
{
struct mt7530_priv *priv = ds->priv;
phy_interface_t interface;
int speed;
int ret;
switch (port) {
case 5:
if (!priv->p5_sgmii)
interface = PHY_INTERFACE_MODE_RGMII;
else
interface = PHY_INTERFACE_MODE_2500BASEX;
priv->p5_interface = interface;
break;
case 6:
interface = PHY_INTERFACE_MODE_2500BASEX;
priv->p6_interface = interface;
break;
default:
return -EINVAL;
}
if (interface == PHY_INTERFACE_MODE_2500BASEX)
speed = SPEED_2500;
else
speed = SPEED_1000;
ret = mt7531_mac_config(ds, port, MLO_AN_FIXED, interface);
if (ret)
return ret;
mt7530_write(priv, MT7530_PMCR_P(port),
PMCR_CPU_PORT_SETTING(priv->id));
mt753x_phylink_mac_link_up(ds, port, MLO_AN_FIXED, interface, NULL,
speed, DUPLEX_FULL, true, true);
return 0;
}
static int
mt7988_cpu_port_config(struct dsa_switch *ds, int port)
{
struct mt7530_priv *priv = ds->priv;
mt7530_write(priv, MT7530_PMCR_P(port),
PMCR_CPU_PORT_SETTING(priv->id));
mt753x_phylink_mac_link_up(ds, port, MLO_AN_FIXED,
PHY_INTERFACE_MODE_INTERNAL, NULL,
SPEED_10000, DUPLEX_FULL, true, true);
return 0;
}
static void mt753x_phylink_get_caps(struct dsa_switch *ds, int port, static void mt753x_phylink_get_caps(struct dsa_switch *ds, int port,
struct phylink_config *config) struct phylink_config *config)
{ {
...@@ -2979,17 +2812,9 @@ static int ...@@ -2979,17 +2812,9 @@ static int
mt753x_setup(struct dsa_switch *ds) mt753x_setup(struct dsa_switch *ds)
{ {
struct mt7530_priv *priv = ds->priv; struct mt7530_priv *priv = ds->priv;
int i, ret; int ret = priv->info->sw_setup(ds);
int i;
/* Initialise the PCS devices */
for (i = 0; i < priv->ds->num_ports; i++) {
priv->pcs[i].pcs.ops = priv->info->pcs_ops;
priv->pcs[i].pcs.neg_mode = true;
priv->pcs[i].priv = priv;
priv->pcs[i].port = i;
}
ret = priv->info->sw_setup(ds);
if (ret) if (ret)
return ret; return ret;
...@@ -3001,6 +2826,14 @@ mt753x_setup(struct dsa_switch *ds) ...@@ -3001,6 +2826,14 @@ mt753x_setup(struct dsa_switch *ds)
if (ret && priv->irq) if (ret && priv->irq)
mt7530_free_irq_common(priv); mt7530_free_irq_common(priv);
/* Initialise the PCS devices */
for (i = 0; i < priv->ds->num_ports; i++) {
priv->pcs[i].pcs.ops = priv->info->pcs_ops;
priv->pcs[i].pcs.neg_mode = true;
priv->pcs[i].priv = priv;
priv->pcs[i].port = i;
}
if (priv->create_sgmii) { if (priv->create_sgmii) {
ret = priv->create_sgmii(priv); ret = priv->create_sgmii(priv);
if (ret && priv->irq) if (ret && priv->irq)
...@@ -3155,7 +2988,6 @@ const struct mt753x_info mt753x_table[] = { ...@@ -3155,7 +2988,6 @@ const struct mt753x_info mt753x_table[] = {
.phy_write_c22 = mt7531_ind_c22_phy_write, .phy_write_c22 = mt7531_ind_c22_phy_write,
.phy_read_c45 = mt7531_ind_c45_phy_read, .phy_read_c45 = mt7531_ind_c45_phy_read,
.phy_write_c45 = mt7531_ind_c45_phy_write, .phy_write_c45 = mt7531_ind_c45_phy_write,
.cpu_port_config = mt7531_cpu_port_config,
.mac_port_get_caps = mt7531_mac_port_get_caps, .mac_port_get_caps = mt7531_mac_port_get_caps,
.mac_port_config = mt7531_mac_config, .mac_port_config = mt7531_mac_config,
}, },
...@@ -3167,9 +2999,7 @@ const struct mt753x_info mt753x_table[] = { ...@@ -3167,9 +2999,7 @@ const struct mt753x_info mt753x_table[] = {
.phy_write_c22 = mt7531_ind_c22_phy_write, .phy_write_c22 = mt7531_ind_c22_phy_write,
.phy_read_c45 = mt7531_ind_c45_phy_read, .phy_read_c45 = mt7531_ind_c45_phy_read,
.phy_write_c45 = mt7531_ind_c45_phy_write, .phy_write_c45 = mt7531_ind_c45_phy_write,
.cpu_port_config = mt7988_cpu_port_config,
.mac_port_get_caps = mt7988_mac_port_get_caps, .mac_port_get_caps = mt7988_mac_port_get_caps,
.mac_port_config = mt7988_mac_config,
}, },
}; };
EXPORT_SYMBOL_GPL(mt753x_table); EXPORT_SYMBOL_GPL(mt753x_table);
...@@ -3197,8 +3027,7 @@ mt7530_probe_common(struct mt7530_priv *priv) ...@@ -3197,8 +3027,7 @@ mt7530_probe_common(struct mt7530_priv *priv)
* properly. * properly.
*/ */
if (!priv->info->sw_setup || !priv->info->phy_read_c22 || if (!priv->info->sw_setup || !priv->info->phy_read_c22 ||
!priv->info->phy_write_c22 || !priv->info->mac_port_get_caps || !priv->info->phy_write_c22 || !priv->info->mac_port_get_caps)
!priv->info->mac_port_config)
return -EINVAL; return -EINVAL;
priv->id = priv->info->id; priv->id = priv->info->id;
......
...@@ -304,20 +304,11 @@ enum mt7530_vlan_port_acc_frm { ...@@ -304,20 +304,11 @@ enum mt7530_vlan_port_acc_frm {
MT7531_FORCE_DPX | \ MT7531_FORCE_DPX | \
MT7531_FORCE_RX_FC | \ MT7531_FORCE_RX_FC | \
MT7531_FORCE_TX_FC) MT7531_FORCE_TX_FC)
#define PMCR_FORCE_MODE_ID(id) ((((id) == ID_MT7531) || ((id) == ID_MT7988)) ? \
MT7531_FORCE_MODE : PMCR_FORCE_MODE)
#define PMCR_LINK_SETTINGS_MASK (PMCR_TX_EN | PMCR_FORCE_SPEED_1000 | \ #define PMCR_LINK_SETTINGS_MASK (PMCR_TX_EN | PMCR_FORCE_SPEED_1000 | \
PMCR_RX_EN | PMCR_FORCE_SPEED_100 | \ PMCR_RX_EN | PMCR_FORCE_SPEED_100 | \
PMCR_TX_FC_EN | PMCR_RX_FC_EN | \ PMCR_TX_FC_EN | PMCR_RX_FC_EN | \
PMCR_FORCE_FDX | PMCR_FORCE_LNK | \ PMCR_FORCE_FDX | PMCR_FORCE_LNK | \
PMCR_FORCE_EEE1G | PMCR_FORCE_EEE100) PMCR_FORCE_EEE1G | PMCR_FORCE_EEE100)
#define PMCR_CPU_PORT_SETTING(id) (PMCR_FORCE_MODE_ID((id)) | \
PMCR_IFG_XMIT(1) | PMCR_MAC_MODE | \
PMCR_BACKOFF_EN | PMCR_BACKPR_EN | \
PMCR_TX_EN | PMCR_RX_EN | \
PMCR_TX_FC_EN | PMCR_RX_FC_EN | \
PMCR_FORCE_SPEED_1000 | \
PMCR_FORCE_FDX | PMCR_FORCE_LNK)
#define MT7530_PMEEECR_P(x) (0x3004 + (x) * 0x100) #define MT7530_PMEEECR_P(x) (0x3004 + (x) * 0x100)
#define WAKEUP_TIME_1000(x) (((x) & 0xFF) << 24) #define WAKEUP_TIME_1000(x) (((x) & 0xFF) << 24)
...@@ -724,13 +715,12 @@ struct mt753x_info { ...@@ -724,13 +715,12 @@ struct mt753x_info {
int regnum); int regnum);
int (*phy_write_c45)(struct mt7530_priv *priv, int port, int devad, int (*phy_write_c45)(struct mt7530_priv *priv, int port, int devad,
int regnum, u16 val); int regnum, u16 val);
int (*cpu_port_config)(struct dsa_switch *ds, int port);
void (*mac_port_get_caps)(struct dsa_switch *ds, int port, void (*mac_port_get_caps)(struct dsa_switch *ds, int port,
struct phylink_config *config); struct phylink_config *config);
void (*mac_port_validate)(struct dsa_switch *ds, int port, void (*mac_port_validate)(struct dsa_switch *ds, int port,
phy_interface_t interface, phy_interface_t interface,
unsigned long *supported); unsigned long *supported);
int (*mac_port_config)(struct dsa_switch *ds, int port, void (*mac_port_config)(struct dsa_switch *ds, int port,
unsigned int mode, unsigned int mode,
phy_interface_t interface); phy_interface_t interface);
}; };
...@@ -750,7 +740,6 @@ struct mt753x_info { ...@@ -750,7 +740,6 @@ struct mt753x_info {
* @ports: Holding the state among ports * @ports: Holding the state among ports
* @reg_mutex: The lock for protecting among process accessing * @reg_mutex: The lock for protecting among process accessing
* registers * registers
* @p6_interface Holding the current port 6 interface
* @p5_intf_sel: Holding the current port 5 interface select * @p5_intf_sel: Holding the current port 5 interface select
* @p5_sgmii: Flag for distinguishing if port 5 of the MT7531 switch * @p5_sgmii: Flag for distinguishing if port 5 of the MT7531 switch
* has got SGMII * has got SGMII
...@@ -772,8 +761,6 @@ struct mt7530_priv { ...@@ -772,8 +761,6 @@ struct mt7530_priv {
const struct mt753x_info *info; const struct mt753x_info *info;
unsigned int id; unsigned int id;
bool mcm; bool mcm;
phy_interface_t p6_interface;
phy_interface_t p5_interface;
enum p5_interface_select p5_intf_sel; enum p5_interface_select p5_intf_sel;
bool p5_sgmii; bool p5_sgmii;
u8 mirror_rx; u8 mirror_rx;
......
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