Skip to content

Commit 8d5be2c

Browse files
CHKDSK88kuba-moo
authored andcommitted
net: dsa: vsc73xx: speed up MDIO bus to max allowed value
According to the datasheet, the VSC73xx family's maximum internal MDIO bus speed is 20 MHz. It also allows disabling the preamble. This commit sets the MDIO clock prescaler to the minimum value and disables the preamble to speed up MDIO operations. It doesn't affect the external bus because it's configured in a different subblock. Signed-off-by: Pawel Dembicki <[email protected]> Reviewed-by: Andrew Lunn <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent 7e51d21 commit 8d5be2c

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

drivers/net/dsa/vitesse-vsc73xx-core.c

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,9 @@
4040
#define VSC73XX_BLOCK_ARBITER 0x5 /* Only subblock 0 */
4141
#define VSC73XX_BLOCK_SYSTEM 0x7 /* Only subblock 0 */
4242

43+
/* MII Block subblock */
44+
#define VSC73XX_BLOCK_MII_INTERNAL 0x0 /* Internal MDIO subblock */
45+
4346
#define CPU_PORT 6 /* CPU port */
4447

4548
/* MAC Block registers */
@@ -224,6 +227,11 @@
224227
#define VSC73XX_MII_STAT 0x0
225228
#define VSC73XX_MII_CMD 0x1
226229
#define VSC73XX_MII_DATA 0x2
230+
#define VSC73XX_MII_MPRES 0x3
231+
232+
#define VSC73XX_MII_MPRES_NOPREAMBLE BIT(6)
233+
#define VSC73XX_MII_MPRES_PRESCALEVAL GENMASK(5, 0)
234+
#define VSC73XX_MII_PRESCALEVAL_MIN 3 /* min allowed mdio clock prescaler */
227235

228236
/* Arbiter block 5 registers */
229237
#define VSC73XX_ARBEMPTY 0x0c
@@ -748,7 +756,7 @@ static int vsc73xx_configure_rgmii_port_delay(struct dsa_switch *ds)
748756
static int vsc73xx_setup(struct dsa_switch *ds)
749757
{
750758
struct vsc73xx *vsc = ds->priv;
751-
int i, ret;
759+
int i, ret, val;
752760

753761
dev_info(vsc->dev, "set up the switch\n");
754762

@@ -821,6 +829,15 @@ static int vsc73xx_setup(struct dsa_switch *ds)
821829

822830
mdelay(50);
823831

832+
/* Disable preamble and use maximum allowed clock for the internal
833+
* mdio bus, used for communication with internal PHYs only.
834+
*/
835+
val = VSC73XX_MII_MPRES_NOPREAMBLE |
836+
FIELD_PREP(VSC73XX_MII_MPRES_PRESCALEVAL,
837+
VSC73XX_MII_PRESCALEVAL_MIN);
838+
vsc73xx_write(vsc, VSC73XX_BLOCK_MII, VSC73XX_BLOCK_MII_INTERNAL,
839+
VSC73XX_MII_MPRES, val);
840+
824841
/* Release reset from the internal PHYs */
825842
vsc73xx_write(vsc, VSC73XX_BLOCK_SYSTEM, 0, VSC73XX_GLORESET,
826843
VSC73XX_GLORESET_PHY_RESET);

0 commit comments

Comments
 (0)