Skip to content

Commit

Permalink
net: phy: adin: Add flag to allow enabling of 1000base-t retrain
Browse files Browse the repository at this point in the history
The PHY contains a retrain function which if enabled, retrains the
1000base-t link when the receiver status becomes not okay. If disabled,
the link will simply drop. This retrain function should be enabled in
order to be IEEE compliant, but is disabled by default on the PHY due to
FLD being enabled by default.

Add a device tree flag which can be used to enable the function on the
PHY when desired.

Signed-off-by: Ken Sloat <ken.s@variscite.com>
  • Loading branch information
ksloat committed Apr 6, 2023
1 parent e6d4d67 commit 51d341c
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions drivers/net/phy/adin.c
Expand Up @@ -80,6 +80,8 @@
#define ADIN1300_FLD_SLCR_IN_INVLD_1000_EN BIT(0)
#define ADIN1300_CLOCK_STOP_REG 0x9400
#define ADIN1300_LPI_WAKE_ERR_CNT_REG 0xa000
#define ADIN1300_B_1000_RTRN_EN_REG 0xa001
#define ADIN1300_B_1000_RTRN_EN BIT(0)

#define ADIN1300_CDIAG_RUN 0xba1b
#define ADIN1300_CDIAG_RUN_EN BIT(0)
Expand Down Expand Up @@ -505,6 +507,18 @@ static int adin_fast_down_disable(struct phy_device *phydev)
return 0;
}

static int adin_enable_retrain(struct phy_device *phydev)
{
struct device *dev = &phydev->mdio.dev;

if (device_property_read_bool(dev, "adi,1000base-t-retrain-en"))
return phy_set_bits_mmd(phydev, MDIO_MMD_VEND1,
ADIN1300_B_1000_RTRN_EN_REG,
ADIN1300_B_1000_RTRN_EN);

return 0;
}

static int adin_config_init(struct phy_device *phydev)
{
int rc;
Expand All @@ -531,6 +545,10 @@ static int adin_config_init(struct phy_device *phydev)
if (rc < 0)
return rc;

rc = adin_enable_retrain(phydev);
if (rc < 0)
return rc;

phydev_dbg(phydev, "PHY is using mode '%s'\n",
phy_modes(phydev->interface));

Expand Down

0 comments on commit 51d341c

Please sign in to comment.