Commit a1e55f51 authored by Jakub Kicinski's avatar Jakub Kicinski

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

Arınç ÜNAL says:

====================
MT7530 DSA Subdriver Improvements Act II

This is the second 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>
====================

Link: https://lore.kernel.org/r/20240206-for-netnext-mt7530-improvements-2-v5-0-d7d92a185cb1@arinc9.comSigned-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parents c885b95c b43990bc
...@@ -414,31 +414,30 @@ mt753x_preferred_default_local_cpu_port(struct dsa_switch *ds) ...@@ -414,31 +414,30 @@ mt753x_preferred_default_local_cpu_port(struct dsa_switch *ds)
} }
/* Setup port 6 interface mode and TRGMII TX circuit */ /* Setup port 6 interface mode and TRGMII TX circuit */
static int static void
mt7530_pad_clk_setup(struct dsa_switch *ds, phy_interface_t interface) mt7530_setup_port6(struct dsa_switch *ds, phy_interface_t interface)
{ {
struct mt7530_priv *priv = ds->priv; struct mt7530_priv *priv = ds->priv;
u32 ncpo1, ssc_delta, trgint, xtal; u32 ncpo1, ssc_delta, xtal;
xtal = mt7530_read(priv, MT7530_MHWTRAP) & HWTRAP_XTAL_MASK; /* Disable the MT7530 TRGMII clocks */
core_clear(priv, CORE_TRGMII_GSW_CLK_CG, REG_TRGMIICK_EN);
if (xtal == HWTRAP_XTAL_20MHZ) { if (interface == PHY_INTERFACE_MODE_RGMII) {
dev_err(priv->dev, mt7530_rmw(priv, MT7530_P6ECR, P6_INTF_MODE_MASK,
"%s: MT7530 with a 20MHz XTAL is not supported!\n", P6_INTF_MODE(0));
__func__); return;
return -EINVAL;
} }
switch (interface) { mt7530_rmw(priv, MT7530_P6ECR, P6_INTF_MODE_MASK, P6_INTF_MODE(1));
case PHY_INTERFACE_MODE_RGMII:
trgint = 0; xtal = mt7530_read(priv, MT7530_MHWTRAP) & HWTRAP_XTAL_MASK;
break;
case PHY_INTERFACE_MODE_TRGMII:
trgint = 1;
if (xtal == HWTRAP_XTAL_25MHZ) if (xtal == HWTRAP_XTAL_25MHZ)
ssc_delta = 0x57; ssc_delta = 0x57;
else else
ssc_delta = 0x87; ssc_delta = 0x87;
if (priv->id == ID_MT7621) { if (priv->id == ID_MT7621) {
/* PLL frequency: 125MHz: 1.0GBit */ /* PLL frequency: 125MHz: 1.0GBit */
if (xtal == HWTRAP_XTAL_40MHZ) if (xtal == HWTRAP_XTAL_40MHZ)
...@@ -451,46 +450,21 @@ mt7530_pad_clk_setup(struct dsa_switch *ds, phy_interface_t interface) ...@@ -451,46 +450,21 @@ mt7530_pad_clk_setup(struct dsa_switch *ds, phy_interface_t interface)
if (xtal == HWTRAP_XTAL_25MHZ) if (xtal == HWTRAP_XTAL_25MHZ)
ncpo1 = 0x1400; ncpo1 = 0x1400;
} }
break;
default:
dev_err(priv->dev, "xMII interface %d not supported\n",
interface);
return -EINVAL;
}
mt7530_rmw(priv, MT7530_P6ECR, P6_INTF_MODE_MASK,
P6_INTF_MODE(trgint));
if (trgint) {
/* Disable the MT7530 TRGMII clocks */
core_clear(priv, CORE_TRGMII_GSW_CLK_CG, REG_TRGMIICK_EN);
/* Setup the MT7530 TRGMII Tx Clock */ /* Setup the MT7530 TRGMII Tx Clock */
core_write(priv, CORE_PLL_GROUP5, RG_LCDDS_PCW_NCPO1(ncpo1)); core_write(priv, CORE_PLL_GROUP5, RG_LCDDS_PCW_NCPO1(ncpo1));
core_write(priv, CORE_PLL_GROUP6, RG_LCDDS_PCW_NCPO0(0)); core_write(priv, CORE_PLL_GROUP6, RG_LCDDS_PCW_NCPO0(0));
core_write(priv, CORE_PLL_GROUP10, RG_LCDDS_SSC_DELTA(ssc_delta)); core_write(priv, CORE_PLL_GROUP10, RG_LCDDS_SSC_DELTA(ssc_delta));
core_write(priv, CORE_PLL_GROUP11, RG_LCDDS_SSC_DELTA1(ssc_delta)); core_write(priv, CORE_PLL_GROUP11, RG_LCDDS_SSC_DELTA1(ssc_delta));
core_write(priv, CORE_PLL_GROUP4, core_write(priv, CORE_PLL_GROUP4, RG_SYSPLL_DDSFBK_EN |
RG_SYSPLL_DDSFBK_EN | RG_SYSPLL_BIAS_EN | RG_SYSPLL_BIAS_EN | RG_SYSPLL_BIAS_LPF_EN);
RG_SYSPLL_BIAS_LPF_EN); core_write(priv, CORE_PLL_GROUP2, RG_SYSPLL_EN_NORMAL |
core_write(priv, CORE_PLL_GROUP2, RG_SYSPLL_VODEN | RG_SYSPLL_POSDIV(1));
RG_SYSPLL_EN_NORMAL | RG_SYSPLL_VODEN | core_write(priv, CORE_PLL_GROUP7, RG_LCDDS_PCW_NCPO_CHG |
RG_SYSPLL_POSDIV(1)); RG_LCCDS_C(3) | RG_LCDDS_PWDB | RG_LCDDS_ISO_EN);
core_write(priv, CORE_PLL_GROUP7,
RG_LCDDS_PCW_NCPO_CHG | RG_LCCDS_C(3) |
RG_LCDDS_PWDB | RG_LCDDS_ISO_EN);
/* Enable the MT7530 TRGMII clocks */ /* Enable the MT7530 TRGMII clocks */
core_set(priv, CORE_TRGMII_GSW_CLK_CG, REG_TRGMIICK_EN); core_set(priv, CORE_TRGMII_GSW_CLK_CG, REG_TRGMIICK_EN);
}
return 0;
}
static int
mt7531_pad_setup(struct dsa_switch *ds, phy_interface_t interface)
{
return 0;
} }
static void static void
...@@ -943,9 +917,7 @@ static void mt7530_setup_port5(struct dsa_switch *ds, phy_interface_t interface) ...@@ -943,9 +917,7 @@ static void mt7530_setup_port5(struct dsa_switch *ds, phy_interface_t interface)
val &= ~MHWTRAP_P5_DIS; val &= ~MHWTRAP_P5_DIS;
break; break;
default: default:
dev_err(ds->dev, "Unsupported p5_intf_sel %d\n", break;
priv->p5_intf_sel);
goto unlock_exit;
} }
/* Setup RGMII settings */ /* Setup RGMII settings */
...@@ -975,7 +947,6 @@ static void mt7530_setup_port5(struct dsa_switch *ds, phy_interface_t interface) ...@@ -975,7 +947,6 @@ static void mt7530_setup_port5(struct dsa_switch *ds, phy_interface_t interface)
dev_dbg(ds->dev, "Setup P5, HWTRAP=0x%x, intf_sel=%s, phy-mode=%s\n", dev_dbg(ds->dev, "Setup P5, HWTRAP=0x%x, intf_sel=%s, phy-mode=%s\n",
val, p5_intf_modes(priv->p5_intf_sel), phy_modes(interface)); val, p5_intf_modes(priv->p5_intf_sel), phy_modes(interface));
unlock_exit:
mutex_unlock(&priv->reg_mutex); mutex_unlock(&priv->reg_mutex);
} }
...@@ -2262,6 +2233,12 @@ mt7530_setup(struct dsa_switch *ds) ...@@ -2262,6 +2233,12 @@ mt7530_setup(struct dsa_switch *ds)
return -ENODEV; return -ENODEV;
} }
if ((val & HWTRAP_XTAL_MASK) == HWTRAP_XTAL_20MHZ) {
dev_err(priv->dev,
"MT7530 with a 20MHz XTAL is not supported!\n");
return -EINVAL;
}
/* 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_PHY_RST | SYS_CTRL_SW_RST | SYS_CTRL_PHY_RST | SYS_CTRL_SW_RST |
...@@ -2596,11 +2573,9 @@ static void mt7531_mac_port_get_caps(struct dsa_switch *ds, int port, ...@@ -2596,11 +2573,9 @@ static void mt7531_mac_port_get_caps(struct dsa_switch *ds, int port,
static void mt7988_mac_port_get_caps(struct dsa_switch *ds, int port, static void mt7988_mac_port_get_caps(struct dsa_switch *ds, int port,
struct phylink_config *config) struct phylink_config *config)
{ {
phy_interface_zero(config->supported_interfaces);
switch (port) { switch (port) {
/* Ports which are connected to switch PHYs. There is no MII pinout. */ /* Ports which are connected to switch PHYs. There is no MII pinout. */
case 0 ... 4: case 0 ... 3:
__set_bit(PHY_INTERFACE_MODE_INTERNAL, __set_bit(PHY_INTERFACE_MODE_INTERNAL,
config->supported_interfaces); config->supported_interfaces);
break; break;
...@@ -2614,25 +2589,16 @@ static void mt7988_mac_port_get_caps(struct dsa_switch *ds, int port, ...@@ -2614,25 +2589,16 @@ static void mt7988_mac_port_get_caps(struct dsa_switch *ds, int port,
} }
} }
static int
mt753x_pad_setup(struct dsa_switch *ds, const struct phylink_link_state *state)
{
struct mt7530_priv *priv = ds->priv;
return priv->info->pad_setup(ds, state->interface);
}
static int static int
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)
{ {
struct mt7530_priv *priv = ds->priv; struct mt7530_priv *priv = ds->priv;
/* Only need to setup port5. */ if (port == 5)
if (port != 5)
return 0;
mt7530_setup_port5(priv->ds, interface); mt7530_setup_port5(priv->ds, interface);
else if (port == 6)
mt7530_setup_port6(priv->ds, interface);
return 0; return 0;
} }
...@@ -2788,8 +2754,6 @@ mt753x_phylink_mac_config(struct dsa_switch *ds, int port, unsigned int mode, ...@@ -2788,8 +2754,6 @@ mt753x_phylink_mac_config(struct dsa_switch *ds, int port, unsigned int mode,
if (priv->p6_interface == state->interface) if (priv->p6_interface == state->interface)
break; break;
mt753x_pad_setup(ds, state);
if (mt753x_mac_config(ds, port, mode, state) < 0) if (mt753x_mac_config(ds, port, mode, state) < 0)
goto unsupported; goto unsupported;
...@@ -3106,11 +3070,6 @@ mt753x_conduit_state_change(struct dsa_switch *ds, ...@@ -3106,11 +3070,6 @@ mt753x_conduit_state_change(struct dsa_switch *ds,
mt7530_rmw(priv, MT7530_MFC, CPU_EN | CPU_PORT_MASK, val); mt7530_rmw(priv, MT7530_MFC, CPU_EN | CPU_PORT_MASK, val);
} }
static int mt7988_pad_setup(struct dsa_switch *ds, phy_interface_t interface)
{
return 0;
}
static int mt7988_setup(struct dsa_switch *ds) static int mt7988_setup(struct dsa_switch *ds)
{ {
struct mt7530_priv *priv = ds->priv; struct mt7530_priv *priv = ds->priv;
...@@ -3174,7 +3133,6 @@ const struct mt753x_info mt753x_table[] = { ...@@ -3174,7 +3133,6 @@ const struct mt753x_info mt753x_table[] = {
.phy_write_c22 = mt7530_phy_write_c22, .phy_write_c22 = mt7530_phy_write_c22,
.phy_read_c45 = mt7530_phy_read_c45, .phy_read_c45 = mt7530_phy_read_c45,
.phy_write_c45 = mt7530_phy_write_c45, .phy_write_c45 = mt7530_phy_write_c45,
.pad_setup = mt7530_pad_clk_setup,
.mac_port_get_caps = mt7530_mac_port_get_caps, .mac_port_get_caps = mt7530_mac_port_get_caps,
.mac_port_config = mt7530_mac_config, .mac_port_config = mt7530_mac_config,
}, },
...@@ -3186,7 +3144,6 @@ const struct mt753x_info mt753x_table[] = { ...@@ -3186,7 +3144,6 @@ const struct mt753x_info mt753x_table[] = {
.phy_write_c22 = mt7530_phy_write_c22, .phy_write_c22 = mt7530_phy_write_c22,
.phy_read_c45 = mt7530_phy_read_c45, .phy_read_c45 = mt7530_phy_read_c45,
.phy_write_c45 = mt7530_phy_write_c45, .phy_write_c45 = mt7530_phy_write_c45,
.pad_setup = mt7530_pad_clk_setup,
.mac_port_get_caps = mt7530_mac_port_get_caps, .mac_port_get_caps = mt7530_mac_port_get_caps,
.mac_port_config = mt7530_mac_config, .mac_port_config = mt7530_mac_config,
}, },
...@@ -3198,7 +3155,6 @@ const struct mt753x_info mt753x_table[] = { ...@@ -3198,7 +3155,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,
.pad_setup = mt7531_pad_setup,
.cpu_port_config = mt7531_cpu_port_config, .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,
...@@ -3211,7 +3167,6 @@ const struct mt753x_info mt753x_table[] = { ...@@ -3211,7 +3167,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,
.pad_setup = mt7988_pad_setup,
.cpu_port_config = mt7988_cpu_port_config, .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, .mac_port_config = mt7988_mac_config,
...@@ -3241,9 +3196,8 @@ mt7530_probe_common(struct mt7530_priv *priv) ...@@ -3241,9 +3196,8 @@ mt7530_probe_common(struct mt7530_priv *priv)
/* Sanity check if these required device operations are filled /* Sanity check if these required device operations are filled
* properly. * properly.
*/ */
if (!priv->info->sw_setup || !priv->info->pad_setup || if (!priv->info->sw_setup || !priv->info->phy_read_c22 ||
!priv->info->phy_read_c22 || !priv->info->phy_write_c22 || !priv->info->phy_write_c22 || !priv->info->mac_port_get_caps ||
!priv->info->mac_port_get_caps ||
!priv->info->mac_port_config) !priv->info->mac_port_config)
return -EINVAL; return -EINVAL;
......
...@@ -704,8 +704,6 @@ struct mt753x_pcs { ...@@ -704,8 +704,6 @@ struct mt753x_pcs {
* @phy_write_c22: Holding the way writing PHY port using C22 * @phy_write_c22: Holding the way writing PHY port using C22
* @phy_read_c45: Holding the way reading PHY port using C45 * @phy_read_c45: Holding the way reading PHY port using C45
* @phy_write_c45: Holding the way writing PHY port using C45 * @phy_write_c45: Holding the way writing PHY port using C45
* @pad_setup: Holding the way setting up the bus pad for a certain
* MAC port
* @phy_mode_supported: Check if the PHY type is being supported on a certain * @phy_mode_supported: Check if the PHY type is being supported on a certain
* port * port
* @mac_port_validate: Holding the way to set addition validate type for a * @mac_port_validate: Holding the way to set addition validate type for a
...@@ -726,7 +724,6 @@ struct mt753x_info { ...@@ -726,7 +724,6 @@ 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 (*pad_setup)(struct dsa_switch *ds, phy_interface_t interface);
int (*cpu_port_config)(struct dsa_switch *ds, int port); 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);
......
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