@@ -74,27 +74,40 @@ static int bcm54612e_config_init(struct phy_device *phydev)
7474 return 0 ;
7575}
7676
77- static int bcm54810_config (struct phy_device * phydev )
77+ static int bcm5481x_config (struct phy_device * phydev )
7878{
7979 int rc , val ;
8080
81- val = bcm_phy_read_exp (phydev , BCM54810_EXP_BROADREACH_LRE_MISC_CTL );
82- val &= ~BCM54810_EXP_BROADREACH_LRE_MISC_CTL_EN ;
83- rc = bcm_phy_write_exp (phydev , BCM54810_EXP_BROADREACH_LRE_MISC_CTL ,
84- val );
85- if (rc < 0 )
86- return rc ;
87-
81+ /* handling PHY's internal RX clock delay */
8882 val = bcm54xx_auxctl_read (phydev , MII_BCM54XX_AUXCTL_SHDWSEL_MISC );
89- val &= ~MII_BCM54XX_AUXCTL_SHDWSEL_MISC_RGMII_SKEW_EN ;
9083 val |= MII_BCM54XX_AUXCTL_MISC_WREN ;
84+ if (phydev -> interface == PHY_INTERFACE_MODE_RGMII ||
85+ phydev -> interface == PHY_INTERFACE_MODE_RGMII_TXID ) {
86+ /* Disable RGMII RXC-RXD skew */
87+ val &= ~MII_BCM54XX_AUXCTL_SHDWSEL_MISC_RGMII_SKEW_EN ;
88+ }
89+ if (phydev -> interface == PHY_INTERFACE_MODE_RGMII_ID ||
90+ phydev -> interface == PHY_INTERFACE_MODE_RGMII_RXID ) {
91+ /* Enable RGMII RXC-RXD skew */
92+ val |= MII_BCM54XX_AUXCTL_SHDWSEL_MISC_RGMII_SKEW_EN ;
93+ }
9194 rc = bcm54xx_auxctl_write (phydev , MII_BCM54XX_AUXCTL_SHDWSEL_MISC ,
9295 val );
9396 if (rc < 0 )
9497 return rc ;
9598
99+ /* handling PHY's internal TX clock delay */
96100 val = bcm_phy_read_shadow (phydev , BCM54810_SHD_CLK_CTL );
97- val &= ~BCM54810_SHD_CLK_CTL_GTXCLK_EN ;
101+ if (phydev -> interface == PHY_INTERFACE_MODE_RGMII ||
102+ phydev -> interface == PHY_INTERFACE_MODE_RGMII_RXID ) {
103+ /* Disable internal TX clock delay */
104+ val &= ~BCM54810_SHD_CLK_CTL_GTXCLK_EN ;
105+ }
106+ if (phydev -> interface == PHY_INTERFACE_MODE_RGMII_ID ||
107+ phydev -> interface == PHY_INTERFACE_MODE_RGMII_TXID ) {
108+ /* Enable internal TX clock delay */
109+ val |= BCM54810_SHD_CLK_CTL_GTXCLK_EN ;
110+ }
98111 rc = bcm_phy_write_shadow (phydev , BCM54810_SHD_CLK_CTL , val );
99112 if (rc < 0 )
100113 return rc ;
@@ -244,7 +257,7 @@ static void bcm54xx_adjust_rxrefclk(struct phy_device *phydev)
244257
245258static int bcm54xx_config_init (struct phy_device * phydev )
246259{
247- int reg , err ;
260+ int reg , err , val ;
248261
249262 reg = phy_read (phydev , MII_BCM54XX_ECR );
250263 if (reg < 0 )
@@ -283,8 +296,14 @@ static int bcm54xx_config_init(struct phy_device *phydev)
283296 if (err )
284297 return err ;
285298 } else if (BRCM_PHY_MODEL (phydev ) == PHY_ID_BCM54810 ) {
286- err = bcm54810_config (phydev );
287- if (err )
299+ /* For BCM54810, we need to disable BroadR-Reach function */
300+ val = bcm_phy_read_exp (phydev ,
301+ BCM54810_EXP_BROADREACH_LRE_MISC_CTL );
302+ val &= ~BCM54810_EXP_BROADREACH_LRE_MISC_CTL_EN ;
303+ err = bcm_phy_write_exp (phydev ,
304+ BCM54810_EXP_BROADREACH_LRE_MISC_CTL ,
305+ val );
306+ if (err < 0 )
288307 return err ;
289308 }
290309
@@ -392,29 +411,7 @@ static int bcm5481_config_aneg(struct phy_device *phydev)
392411 ret = genphy_config_aneg (phydev );
393412
394413 /* Then we can set up the delay. */
395- if (phydev -> interface == PHY_INTERFACE_MODE_RGMII_RXID ) {
396- u16 reg ;
397-
398- /*
399- * There is no BCM5481 specification available, so down
400- * here is everything we know about "register 0x18". This
401- * at least helps BCM5481 to successfully receive packets
402- * on MPC8360E-RDK board. Peter Barada <peterb@logicpd.com>
403- * says: "This sets delay between the RXD and RXC signals
404- * instead of using trace lengths to achieve timing".
405- */
406-
407- /* Set RDX clk delay. */
408- reg = 0x7 | (0x7 << 12 );
409- phy_write (phydev , 0x18 , reg );
410-
411- reg = phy_read (phydev , 0x18 );
412- /* Set RDX-RXC skew. */
413- reg |= (1 << 8 );
414- /* Write bits 14:0. */
415- reg |= (1 << 15 );
416- phy_write (phydev , 0x18 , reg );
417- }
414+ bcm5481x_config (phydev );
418415
419416 if (of_property_read_bool (np , "enet-phy-lane-swap" )) {
420417 /* Lane Swap - Undocumented register...magic! */
0 commit comments