Skip to content

Commit 71460c9

Browse files
david-mlekuba-moo
authored andcommitted
net: phy: mscc: enable VSC8501/2 RGMII RX clock
By default the VSC8501 and VSC8502 RGMII/GMII/MII RX_CLK output is disabled. To allow packet forwarding towards the MAC it needs to be enabled. For other PHYs supported by this driver the clock output is enabled by default. Fixes: d316986 ("net: phy: mscc: add support for VSC8502") Signed-off-by: David Epping <[email protected]> Reviewed-by: Russell King (Oracle) <[email protected]> Reviewed-by: Vladimir Oltean <[email protected]> Signed-off-by: Jakub Kicinski <[email protected]>
1 parent 7df0b33 commit 71460c9

File tree

2 files changed

+29
-26
lines changed

2 files changed

+29
-26
lines changed

drivers/net/phy/mscc/mscc.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,7 @@ enum rgmii_clock_delay {
179179
#define VSC8502_RGMII_CNTL 20
180180
#define VSC8502_RGMII_RX_DELAY_MASK 0x0070
181181
#define VSC8502_RGMII_TX_DELAY_MASK 0x0007
182+
#define VSC8502_RGMII_RX_CLK_DISABLE 0x0800
182183

183184
#define MSCC_PHY_WOL_LOWER_MAC_ADDR 21
184185
#define MSCC_PHY_WOL_MID_MAC_ADDR 22

drivers/net/phy/mscc/mscc_main.c

Lines changed: 28 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -519,14 +519,27 @@ static int vsc85xx_mac_if_set(struct phy_device *phydev,
519519
* * 2.0 ns (which causes the data to be sampled at exactly half way between
520520
* clock transitions at 1000 Mbps) if delays should be enabled
521521
*/
522-
static int vsc85xx_rgmii_set_skews(struct phy_device *phydev, u32 rgmii_cntl,
523-
u16 rgmii_rx_delay_mask,
524-
u16 rgmii_tx_delay_mask)
522+
static int vsc85xx_update_rgmii_cntl(struct phy_device *phydev, u32 rgmii_cntl,
523+
u16 rgmii_rx_delay_mask,
524+
u16 rgmii_tx_delay_mask)
525525
{
526526
u16 rgmii_rx_delay_pos = ffs(rgmii_rx_delay_mask) - 1;
527527
u16 rgmii_tx_delay_pos = ffs(rgmii_tx_delay_mask) - 1;
528528
u16 reg_val = 0;
529-
int rc;
529+
u16 mask = 0;
530+
int rc = 0;
531+
532+
/* For traffic to pass, the VSC8502 family needs the RX_CLK disable bit
533+
* to be unset for all PHY modes, so do that as part of the paged
534+
* register modification.
535+
* For some family members (like VSC8530/31/40/41) this bit is reserved
536+
* and read-only, and the RX clock is enabled by default.
537+
*/
538+
if (rgmii_cntl == VSC8502_RGMII_CNTL)
539+
mask |= VSC8502_RGMII_RX_CLK_DISABLE;
540+
541+
if (phy_interface_is_rgmii(phydev))
542+
mask |= rgmii_rx_delay_mask | rgmii_tx_delay_mask;
530543

531544
if (phydev->interface == PHY_INTERFACE_MODE_RGMII_RXID ||
532545
phydev->interface == PHY_INTERFACE_MODE_RGMII_ID)
@@ -535,29 +548,20 @@ static int vsc85xx_rgmii_set_skews(struct phy_device *phydev, u32 rgmii_cntl,
535548
phydev->interface == PHY_INTERFACE_MODE_RGMII_ID)
536549
reg_val |= RGMII_CLK_DELAY_2_0_NS << rgmii_tx_delay_pos;
537550

538-
rc = phy_modify_paged(phydev, MSCC_PHY_PAGE_EXTENDED_2,
539-
rgmii_cntl,
540-
rgmii_rx_delay_mask | rgmii_tx_delay_mask,
541-
reg_val);
551+
if (mask)
552+
rc = phy_modify_paged(phydev, MSCC_PHY_PAGE_EXTENDED_2,
553+
rgmii_cntl, mask, reg_val);
542554

543555
return rc;
544556
}
545557

546558
static int vsc85xx_default_config(struct phy_device *phydev)
547559
{
548-
int rc;
549-
550560
phydev->mdix_ctrl = ETH_TP_MDI_AUTO;
551561

552-
if (phy_interface_mode_is_rgmii(phydev->interface)) {
553-
rc = vsc85xx_rgmii_set_skews(phydev, VSC8502_RGMII_CNTL,
554-
VSC8502_RGMII_RX_DELAY_MASK,
555-
VSC8502_RGMII_TX_DELAY_MASK);
556-
if (rc)
557-
return rc;
558-
}
559-
560-
return 0;
562+
return vsc85xx_update_rgmii_cntl(phydev, VSC8502_RGMII_CNTL,
563+
VSC8502_RGMII_RX_DELAY_MASK,
564+
VSC8502_RGMII_TX_DELAY_MASK);
561565
}
562566

563567
static int vsc85xx_get_tunable(struct phy_device *phydev,
@@ -1754,13 +1758,11 @@ static int vsc8584_config_init(struct phy_device *phydev)
17541758
if (ret)
17551759
return ret;
17561760

1757-
if (phy_interface_is_rgmii(phydev)) {
1758-
ret = vsc85xx_rgmii_set_skews(phydev, VSC8572_RGMII_CNTL,
1759-
VSC8572_RGMII_RX_DELAY_MASK,
1760-
VSC8572_RGMII_TX_DELAY_MASK);
1761-
if (ret)
1762-
return ret;
1763-
}
1761+
ret = vsc85xx_update_rgmii_cntl(phydev, VSC8572_RGMII_CNTL,
1762+
VSC8572_RGMII_RX_DELAY_MASK,
1763+
VSC8572_RGMII_TX_DELAY_MASK);
1764+
if (ret)
1765+
return ret;
17641766

17651767
ret = genphy_soft_reset(phydev);
17661768
if (ret)

0 commit comments

Comments
 (0)