Skip to content

Commit

Permalink
net: phy: broadcom: Remove unused flags
Browse files Browse the repository at this point in the history
We have a number of unused flags defined today and since we are scarce
on space and may need to introduce new flags in the future remove and
shift every existing flag down into a contiguous assignment.
PHY_BCM_FLAGS_MODE_1000BX was only used internally for the BCM54616S
PHY, so we allocate a driver private structure instead to store that
flag instead of canibalizing one from phydev->dev_flags for that
purpose.

Signed-off-by: Florian Fainelli <[email protected]>
Reviewed-by: Vladimir Oltean <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
  • Loading branch information
ffainelli authored and davem330 committed Feb 15, 2021
1 parent 133bf7b commit 17d3a83
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 16 deletions.
19 changes: 16 additions & 3 deletions drivers/net/phy/broadcom.c
Original file line number Diff line number Diff line change
Expand Up @@ -381,10 +381,21 @@ static int bcm5481_config_aneg(struct phy_device *phydev)
return ret;
}

struct bcm54616s_phy_priv {
bool mode_1000bx_en;
};

static int bcm54616s_probe(struct phy_device *phydev)
{
struct bcm54616s_phy_priv *priv;
int val, intf_sel;

priv = devm_kzalloc(&phydev->mdio.dev, sizeof(*priv), GFP_KERNEL);
if (!priv)
return -ENOMEM;

phydev->priv = priv;

val = bcm_phy_read_shadow(phydev, BCM54XX_SHD_MODE);
if (val < 0)
return val;
Expand All @@ -407,7 +418,7 @@ static int bcm54616s_probe(struct phy_device *phydev)
* 1000BASE-X configuration.
*/
if (!(val & BCM54616S_100FX_MODE))
phydev->dev_flags |= PHY_BCM_FLAGS_MODE_1000BX;
priv->mode_1000bx_en = true;

phydev->port = PORT_FIBRE;
}
Expand All @@ -417,10 +428,11 @@ static int bcm54616s_probe(struct phy_device *phydev)

static int bcm54616s_config_aneg(struct phy_device *phydev)
{
struct bcm54616s_phy_priv *priv = phydev->priv;
int ret;

/* Aneg firstly. */
if (phydev->dev_flags & PHY_BCM_FLAGS_MODE_1000BX)
if (priv->mode_1000bx_en)
ret = genphy_c37_config_aneg(phydev);
else
ret = genphy_config_aneg(phydev);
Expand All @@ -433,9 +445,10 @@ static int bcm54616s_config_aneg(struct phy_device *phydev)

static int bcm54616s_read_status(struct phy_device *phydev)
{
struct bcm54616s_phy_priv *priv = phydev->priv;
int err;

if (phydev->dev_flags & PHY_BCM_FLAGS_MODE_1000BX)
if (priv->mode_1000bx_en)
err = genphy_c37_read_status(phydev);
else
err = genphy_read_status(phydev);
Expand Down
21 changes: 8 additions & 13 deletions include/linux/brcmphy.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,19 +61,14 @@
#define PHY_BCM_OUI_5 0x03625e00
#define PHY_BCM_OUI_6 0xae025000

#define PHY_BCM_FLAGS_MODE_COPPER 0x00000001
#define PHY_BCM_FLAGS_MODE_1000BX 0x00000002
#define PHY_BCM_FLAGS_INTF_SGMII 0x00000010
#define PHY_BCM_FLAGS_INTF_XAUI 0x00000020
#define PHY_BRCM_WIRESPEED_ENABLE 0x00000100
#define PHY_BRCM_AUTO_PWRDWN_ENABLE 0x00000200
#define PHY_BRCM_RX_REFCLK_UNUSED 0x00000400
#define PHY_BRCM_STD_IBND_DISABLE 0x00000800
#define PHY_BRCM_EXT_IBND_RX_ENABLE 0x00001000
#define PHY_BRCM_EXT_IBND_TX_ENABLE 0x00002000
#define PHY_BRCM_CLEAR_RGMII_MODE 0x00004000
#define PHY_BRCM_DIS_TXCRXC_NOENRGY 0x00008000
#define PHY_BRCM_EN_MASTER_MODE 0x00010000
#define PHY_BRCM_AUTO_PWRDWN_ENABLE 0x00000001
#define PHY_BRCM_RX_REFCLK_UNUSED 0x00000002
#define PHY_BRCM_STD_IBND_DISABLE 0x00000004
#define PHY_BRCM_EXT_IBND_RX_ENABLE 0x00000008
#define PHY_BRCM_EXT_IBND_TX_ENABLE 0x00000010
#define PHY_BRCM_CLEAR_RGMII_MODE 0x00000020
#define PHY_BRCM_DIS_TXCRXC_NOENRGY 0x00000040
#define PHY_BRCM_EN_MASTER_MODE 0x00000080

/* Broadcom BCM7xxx specific workarounds */
#define PHY_BRCM_7XXX_REV(x) (((x) >> 8) & 0xff)
Expand Down

0 comments on commit 17d3a83

Please sign in to comment.