@@ -519,14 +519,27 @@ static int vsc85xx_mac_if_set(struct phy_device *phydev,
519
519
* * 2.0 ns (which causes the data to be sampled at exactly half way between
520
520
* clock transitions at 1000 Mbps) if delays should be enabled
521
521
*/
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 )
525
525
{
526
526
u16 rgmii_rx_delay_pos = ffs (rgmii_rx_delay_mask ) - 1 ;
527
527
u16 rgmii_tx_delay_pos = ffs (rgmii_tx_delay_mask ) - 1 ;
528
528
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 ;
530
543
531
544
if (phydev -> interface == PHY_INTERFACE_MODE_RGMII_RXID ||
532
545
phydev -> interface == PHY_INTERFACE_MODE_RGMII_ID )
@@ -535,29 +548,20 @@ static int vsc85xx_rgmii_set_skews(struct phy_device *phydev, u32 rgmii_cntl,
535
548
phydev -> interface == PHY_INTERFACE_MODE_RGMII_ID )
536
549
reg_val |= RGMII_CLK_DELAY_2_0_NS << rgmii_tx_delay_pos ;
537
550
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 );
542
554
543
555
return rc ;
544
556
}
545
557
546
558
static int vsc85xx_default_config (struct phy_device * phydev )
547
559
{
548
- int rc ;
549
-
550
560
phydev -> mdix_ctrl = ETH_TP_MDI_AUTO ;
551
561
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 );
561
565
}
562
566
563
567
static int vsc85xx_get_tunable (struct phy_device * phydev ,
@@ -1754,13 +1758,11 @@ static int vsc8584_config_init(struct phy_device *phydev)
1754
1758
if (ret )
1755
1759
return ret ;
1756
1760
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 ;
1764
1766
1765
1767
ret = genphy_soft_reset (phydev );
1766
1768
if (ret )
0 commit comments