Skip to content

Commit 8f058a6

Browse files
arinc9kuba-moo
authored andcommitted
net: dsa: mt7530: move enabling disabling core clock to mt7530_pll_setup()
Split the code that enables and disables TRGMII clocks and core clock. Move enabling and disabling core clock to mt7530_pll_setup() as it's supposed to be run there. Add 20 ms delay before enabling the core clock as seen on the U-Boot MediaTek ethernet driver. Change the comment for enabling and disabling TRGMII clocks as the code seems to affect both TXC and RXC. Tested rgmii and trgmii modes of port 6 and rgmii mode of port 5 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") Link: https://source.denx.de/u-boot/u-boot/-/blob/29a48bf9ccba45a5e560bb564bbe76e42629325f/drivers/net/mtk_eth.c#L589 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 8eac009 commit 8f058a6

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

drivers/net/dsa/mt7530.c

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -396,6 +396,9 @@ mt7530_fdb_write(struct mt7530_priv *priv, u16 vid,
396396
/* Set up switch core clock for MT7530 */
397397
static void mt7530_pll_setup(struct mt7530_priv *priv)
398398
{
399+
/* Disable core clock */
400+
core_clear(priv, CORE_TRGMII_GSW_CLK_CG, REG_GSWCK_EN);
401+
399402
/* Disable PLL */
400403
core_write(priv, CORE_GSWPLL_GRP1, 0);
401404

@@ -409,6 +412,11 @@ static void mt7530_pll_setup(struct mt7530_priv *priv)
409412
RG_GSWPLL_EN_PRE |
410413
RG_GSWPLL_POSDIV_200M(2) |
411414
RG_GSWPLL_FBKDIV_200M(32));
415+
416+
udelay(20);
417+
418+
/* Enable core clock */
419+
core_set(priv, CORE_TRGMII_GSW_CLK_CG, REG_GSWCK_EN);
412420
}
413421

414422
/* Setup TX circuit including relevant PAD and driving */
@@ -466,9 +474,8 @@ mt7530_pad_clk_setup(struct dsa_switch *ds, phy_interface_t interface)
466474
mt7530_write(priv, MT7530_TRGMII_TD_ODT(i),
467475
TD_DM_DRVP(8) | TD_DM_DRVN(8));
468476

469-
/* Disable MT7530 core and TRGMII Tx clocks */
470-
core_clear(priv, CORE_TRGMII_GSW_CLK_CG,
471-
REG_GSWCK_EN | REG_TRGMIICK_EN);
477+
/* Disable the MT7530 TRGMII clocks */
478+
core_clear(priv, CORE_TRGMII_GSW_CLK_CG, REG_TRGMIICK_EN);
472479

473480
/* Setup the MT7530 TRGMII Tx Clock */
474481
core_write(priv, CORE_PLL_GROUP5, RG_LCDDS_PCW_NCPO1(ncpo1));
@@ -485,9 +492,8 @@ mt7530_pad_clk_setup(struct dsa_switch *ds, phy_interface_t interface)
485492
RG_LCDDS_PCW_NCPO_CHG | RG_LCCDS_C(3) |
486493
RG_LCDDS_PWDB | RG_LCDDS_ISO_EN);
487494

488-
/* Enable MT7530 core and TRGMII Tx clocks */
489-
core_set(priv, CORE_TRGMII_GSW_CLK_CG,
490-
REG_GSWCK_EN | REG_TRGMIICK_EN);
495+
/* Enable the MT7530 TRGMII clocks */
496+
core_set(priv, CORE_TRGMII_GSW_CLK_CG, REG_TRGMIICK_EN);
491497
} else {
492498
for (i = 0 ; i < NUM_TRGMII_CTRL; i++)
493499
mt7530_rmw(priv, MT7530_TRGMII_RD(i),

0 commit comments

Comments
 (0)