Skip to content

Commit 0b086d7

Browse files
arinc9kuba-moo
authored andcommitted
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: b8f126a ("net-next: dsa: add dsa support for Mediatek MT7530 switch") Tested-by: Arınç ÜNAL <[email protected]> Signed-off-by: Arınç ÜNAL <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent feb03fd commit 0b086d7

File tree

1 file changed

+31
-31
lines changed

1 file changed

+31
-31
lines changed

drivers/net/dsa/mt7530.c

Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -430,8 +430,6 @@ mt7530_pad_clk_setup(struct dsa_switch *ds, phy_interface_t interface)
430430
switch (interface) {
431431
case PHY_INTERFACE_MODE_RGMII:
432432
trgint = 0;
433-
/* PLL frequency: 125MHz */
434-
ncpo1 = 0x0c80;
435433
break;
436434
case PHY_INTERFACE_MODE_TRGMII:
437435
trgint = 1;
@@ -462,38 +460,40 @@ mt7530_pad_clk_setup(struct dsa_switch *ds, phy_interface_t interface)
462460
mt7530_rmw(priv, MT7530_P6ECR, P6_INTF_MODE_MASK,
463461
P6_INTF_MODE(trgint));
464462

465-
/* Lower Tx Driving for TRGMII path */
466-
for (i = 0 ; i < NUM_TRGMII_CTRL ; i++)
467-
mt7530_write(priv, MT7530_TRGMII_TD_ODT(i),
468-
TD_DM_DRVP(8) | TD_DM_DRVN(8));
469-
470-
/* Disable MT7530 core and TRGMII Tx clocks */
471-
core_clear(priv, CORE_TRGMII_GSW_CLK_CG,
472-
REG_GSWCK_EN | REG_TRGMIICK_EN);
473-
474-
/* Setup the MT7530 TRGMII Tx Clock */
475-
core_write(priv, CORE_PLL_GROUP5, RG_LCDDS_PCW_NCPO1(ncpo1));
476-
core_write(priv, CORE_PLL_GROUP6, RG_LCDDS_PCW_NCPO0(0));
477-
core_write(priv, CORE_PLL_GROUP10, RG_LCDDS_SSC_DELTA(ssc_delta));
478-
core_write(priv, CORE_PLL_GROUP11, RG_LCDDS_SSC_DELTA1(ssc_delta));
479-
core_write(priv, CORE_PLL_GROUP4,
480-
RG_SYSPLL_DDSFBK_EN | RG_SYSPLL_BIAS_EN |
481-
RG_SYSPLL_BIAS_LPF_EN);
482-
core_write(priv, CORE_PLL_GROUP2,
483-
RG_SYSPLL_EN_NORMAL | RG_SYSPLL_VODEN |
484-
RG_SYSPLL_POSDIV(1));
485-
core_write(priv, CORE_PLL_GROUP7,
486-
RG_LCDDS_PCW_NCPO_CHG | RG_LCCDS_C(3) |
487-
RG_LCDDS_PWDB | RG_LCDDS_ISO_EN);
488-
489-
/* Enable MT7530 core and TRGMII Tx clocks */
490-
core_set(priv, CORE_TRGMII_GSW_CLK_CG,
491-
REG_GSWCK_EN | REG_TRGMIICK_EN);
492-
493-
if (!trgint)
463+
if (trgint) {
464+
/* Lower Tx Driving for TRGMII path */
465+
for (i = 0 ; i < NUM_TRGMII_CTRL ; i++)
466+
mt7530_write(priv, MT7530_TRGMII_TD_ODT(i),
467+
TD_DM_DRVP(8) | TD_DM_DRVN(8));
468+
469+
/* Disable MT7530 core and TRGMII Tx clocks */
470+
core_clear(priv, CORE_TRGMII_GSW_CLK_CG,
471+
REG_GSWCK_EN | REG_TRGMIICK_EN);
472+
473+
/* Setup the MT7530 TRGMII Tx Clock */
474+
core_write(priv, CORE_PLL_GROUP5, RG_LCDDS_PCW_NCPO1(ncpo1));
475+
core_write(priv, CORE_PLL_GROUP6, RG_LCDDS_PCW_NCPO0(0));
476+
core_write(priv, CORE_PLL_GROUP10, RG_LCDDS_SSC_DELTA(ssc_delta));
477+
core_write(priv, CORE_PLL_GROUP11, RG_LCDDS_SSC_DELTA1(ssc_delta));
478+
core_write(priv, CORE_PLL_GROUP4,
479+
RG_SYSPLL_DDSFBK_EN | RG_SYSPLL_BIAS_EN |
480+
RG_SYSPLL_BIAS_LPF_EN);
481+
core_write(priv, CORE_PLL_GROUP2,
482+
RG_SYSPLL_EN_NORMAL | RG_SYSPLL_VODEN |
483+
RG_SYSPLL_POSDIV(1));
484+
core_write(priv, CORE_PLL_GROUP7,
485+
RG_LCDDS_PCW_NCPO_CHG | RG_LCCDS_C(3) |
486+
RG_LCDDS_PWDB | RG_LCDDS_ISO_EN);
487+
488+
/* Enable MT7530 core and TRGMII Tx clocks */
489+
core_set(priv, CORE_TRGMII_GSW_CLK_CG,
490+
REG_GSWCK_EN | REG_TRGMIICK_EN);
491+
} else {
494492
for (i = 0 ; i < NUM_TRGMII_CTRL; i++)
495493
mt7530_rmw(priv, MT7530_TRGMII_RD(i),
496494
RD_TAP_MASK, RD_TAP(16));
495+
}
496+
497497
return 0;
498498
}
499499

0 commit comments

Comments
 (0)