Skip to content

Commit 79fb218

Browse files
ffainellidavem330
authored andcommitted
net: phy: broadcom: Fix bcm_write_exp()
On newer PHYs, we need to select the expansion register to write with setting bits [11:8] to 0xf. This was done correctly by bcm7xxx.c prior to being migrated to generic code under bcm-phy-lib.c which unfortunately used the older implementation from the BCM54xx days. Fix this by creating an inline stub: bcm_write_exp_sel() which adds the correct value (MII_BCM54XX_EXP_SEL_ER) and update both the Cygnus PHY and BCM7xxx PHY drivers which require setting these bits. broadcom.c is unchanged because some PHYs even use a different selector method, so let them specify it directly (e.g: SerDes secondary selector). Fixes: a1cba56 ("net: phy: Add Broadcom phy library for common interfaces") Signed-off-by: Florian Fainelli <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 733a969 commit 79fb218

File tree

3 files changed

+12
-5
lines changed

3 files changed

+12
-5
lines changed

drivers/net/phy/bcm-cygnus.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,17 +61,17 @@ static int bcm_cygnus_afe_config(struct phy_device *phydev)
6161
return rc;
6262

6363
/* make rcal=100, since rdb default is 000 */
64-
rc = bcm_phy_write_exp(phydev, MII_BRCM_CORE_EXPB1, 0x10);
64+
rc = bcm_phy_write_exp_sel(phydev, MII_BRCM_CORE_EXPB1, 0x10);
6565
if (rc < 0)
6666
return rc;
6767

6868
/* CORE_EXPB0, Reset R_CAL/RC_CAL Engine */
69-
rc = bcm_phy_write_exp(phydev, MII_BRCM_CORE_EXPB0, 0x10);
69+
rc = bcm_phy_write_exp_sel(phydev, MII_BRCM_CORE_EXPB0, 0x10);
7070
if (rc < 0)
7171
return rc;
7272

7373
/* CORE_EXPB0, Disable Reset R_CAL/RC_CAL Engine */
74-
rc = bcm_phy_write_exp(phydev, MII_BRCM_CORE_EXPB0, 0x00);
74+
rc = bcm_phy_write_exp_sel(phydev, MII_BRCM_CORE_EXPB0, 0x00);
7575

7676
return 0;
7777
}

drivers/net/phy/bcm-phy-lib.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,18 @@
1414
#ifndef _LINUX_BCM_PHY_LIB_H
1515
#define _LINUX_BCM_PHY_LIB_H
1616

17+
#include <linux/brcmphy.h>
1718
#include <linux/phy.h>
1819

1920
int bcm_phy_write_exp(struct phy_device *phydev, u16 reg, u16 val);
2021
int bcm_phy_read_exp(struct phy_device *phydev, u16 reg);
2122

23+
static inline int bcm_phy_write_exp_sel(struct phy_device *phydev,
24+
u16 reg, u16 val)
25+
{
26+
return bcm_phy_write_exp(phydev, reg | MII_BCM54XX_EXP_SEL_ER, val);
27+
}
28+
2229
int bcm54xx_auxctl_write(struct phy_device *phydev, u16 regnum, u16 val);
2330
int bcm54xx_auxctl_read(struct phy_device *phydev, u16 regnum);
2431

drivers/net/phy/bcm7xxx.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,10 +65,10 @@ struct bcm7xxx_phy_priv {
6565
static void r_rc_cal_reset(struct phy_device *phydev)
6666
{
6767
/* Reset R_CAL/RC_CAL Engine */
68-
bcm_phy_write_exp(phydev, 0x00b0, 0x0010);
68+
bcm_phy_write_exp_sel(phydev, 0x00b0, 0x0010);
6969

7070
/* Disable Reset R_AL/RC_CAL Engine */
71-
bcm_phy_write_exp(phydev, 0x00b0, 0x0000);
71+
bcm_phy_write_exp_sel(phydev, 0x00b0, 0x0000);
7272
}
7373

7474
static int bcm7xxx_28nm_b0_afe_config_init(struct phy_device *phydev)

0 commit comments

Comments
 (0)