Commit 0b086d76 authored by Arınç ÜNAL's avatar Arınç ÜNAL Committed by Jakub Kicinski

net: dsa: mt7530: set PLL frequency and trgmii only when trgmii is used

As my testing on the MCM MT7530 switch on MT7621 SoC shows, setting the PLL
frequency does not affect MII modes other than trgmii on port 5 and port 6.
So the assumption is that the operation here called "setting the PLL
frequency" actually sets the frequency of the TRGMII TX clock.

Make it so that it and the rest of the trgmii setup run only when the
trgmii mode is used.

Tested rgmii and trgmii modes of port 6 on MCM MT7530 on MT7621AT Unielec
U7621-06 and standalone MT7530 on MT7623NI Bananapi BPI-R2.

Fixes: b8f126a8 ("net-next: dsa: add dsa support for Mediatek MT7530 switch")
Tested-by: default avatarArınç ÜNAL <arinc.unal@arinc9.com>
Signed-off-by: default avatarArınç ÜNAL <arinc.unal@arinc9.com>
Link: https://lore.kernel.org/r/20230310073338.5836-2-arinc.unal@arinc9.comSigned-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parent feb03fd1
...@@ -430,8 +430,6 @@ mt7530_pad_clk_setup(struct dsa_switch *ds, phy_interface_t interface) ...@@ -430,8 +430,6 @@ mt7530_pad_clk_setup(struct dsa_switch *ds, phy_interface_t interface)
switch (interface) { switch (interface) {
case PHY_INTERFACE_MODE_RGMII: case PHY_INTERFACE_MODE_RGMII:
trgint = 0; trgint = 0;
/* PLL frequency: 125MHz */
ncpo1 = 0x0c80;
break; break;
case PHY_INTERFACE_MODE_TRGMII: case PHY_INTERFACE_MODE_TRGMII:
trgint = 1; trgint = 1;
...@@ -462,38 +460,40 @@ mt7530_pad_clk_setup(struct dsa_switch *ds, phy_interface_t interface) ...@@ -462,38 +460,40 @@ mt7530_pad_clk_setup(struct dsa_switch *ds, phy_interface_t interface)
mt7530_rmw(priv, MT7530_P6ECR, P6_INTF_MODE_MASK, mt7530_rmw(priv, MT7530_P6ECR, P6_INTF_MODE_MASK,
P6_INTF_MODE(trgint)); P6_INTF_MODE(trgint));
/* Lower Tx Driving for TRGMII path */ if (trgint) {
for (i = 0 ; i < NUM_TRGMII_CTRL ; i++) /* Lower Tx Driving for TRGMII path */
mt7530_write(priv, MT7530_TRGMII_TD_ODT(i), for (i = 0 ; i < NUM_TRGMII_CTRL ; i++)
TD_DM_DRVP(8) | TD_DM_DRVN(8)); mt7530_write(priv, MT7530_TRGMII_TD_ODT(i),
TD_DM_DRVP(8) | TD_DM_DRVN(8));
/* Disable MT7530 core and TRGMII Tx clocks */
core_clear(priv, CORE_TRGMII_GSW_CLK_CG, /* Disable MT7530 core and TRGMII Tx clocks */
REG_GSWCK_EN | REG_TRGMIICK_EN); core_clear(priv, CORE_TRGMII_GSW_CLK_CG,
REG_GSWCK_EN | REG_TRGMIICK_EN);
/* Setup the MT7530 TRGMII Tx Clock */
core_write(priv, CORE_PLL_GROUP5, RG_LCDDS_PCW_NCPO1(ncpo1)); /* Setup the MT7530 TRGMII Tx Clock */
core_write(priv, CORE_PLL_GROUP6, RG_LCDDS_PCW_NCPO0(0)); core_write(priv, CORE_PLL_GROUP5, RG_LCDDS_PCW_NCPO1(ncpo1));
core_write(priv, CORE_PLL_GROUP10, RG_LCDDS_SSC_DELTA(ssc_delta)); core_write(priv, CORE_PLL_GROUP6, RG_LCDDS_PCW_NCPO0(0));
core_write(priv, CORE_PLL_GROUP11, RG_LCDDS_SSC_DELTA1(ssc_delta)); core_write(priv, CORE_PLL_GROUP10, RG_LCDDS_SSC_DELTA(ssc_delta));
core_write(priv, CORE_PLL_GROUP4, core_write(priv, CORE_PLL_GROUP11, RG_LCDDS_SSC_DELTA1(ssc_delta));
RG_SYSPLL_DDSFBK_EN | RG_SYSPLL_BIAS_EN | core_write(priv, CORE_PLL_GROUP4,
RG_SYSPLL_BIAS_LPF_EN); RG_SYSPLL_DDSFBK_EN | RG_SYSPLL_BIAS_EN |
core_write(priv, CORE_PLL_GROUP2, RG_SYSPLL_BIAS_LPF_EN);
RG_SYSPLL_EN_NORMAL | RG_SYSPLL_VODEN | core_write(priv, CORE_PLL_GROUP2,
RG_SYSPLL_POSDIV(1)); RG_SYSPLL_EN_NORMAL | RG_SYSPLL_VODEN |
core_write(priv, CORE_PLL_GROUP7, RG_SYSPLL_POSDIV(1));
RG_LCDDS_PCW_NCPO_CHG | RG_LCCDS_C(3) | core_write(priv, CORE_PLL_GROUP7,
RG_LCDDS_PWDB | RG_LCDDS_ISO_EN); RG_LCDDS_PCW_NCPO_CHG | RG_LCCDS_C(3) |
RG_LCDDS_PWDB | RG_LCDDS_ISO_EN);
/* Enable MT7530 core and TRGMII Tx clocks */
core_set(priv, CORE_TRGMII_GSW_CLK_CG, /* Enable MT7530 core and TRGMII Tx clocks */
REG_GSWCK_EN | REG_TRGMIICK_EN); core_set(priv, CORE_TRGMII_GSW_CLK_CG,
REG_GSWCK_EN | REG_TRGMIICK_EN);
if (!trgint) } else {
for (i = 0 ; i < NUM_TRGMII_CTRL; i++) for (i = 0 ; i < NUM_TRGMII_CTRL; i++)
mt7530_rmw(priv, MT7530_TRGMII_RD(i), mt7530_rmw(priv, MT7530_TRGMII_RD(i),
RD_TAP_MASK, RD_TAP(16)); RD_TAP_MASK, RD_TAP(16));
}
return 0; return 0;
} }
......
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