Skip to content

Commit

Permalink
ethernet: stmmac: add phy rtl8211f register fixup (armbian#144)
Browse files Browse the repository at this point in the history
Signed-off-by: Feng Zhang <[email protected]>
  • Loading branch information
vamrs-feng authored Jun 29, 2023
1 parent 1f780b2 commit b5bbe5d
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,12 @@
#define STMMAC_ALIGN(x) ALIGN(ALIGN(x, SMP_CACHE_BYTES), 16)
#define TSO_MAX_BUFF_SIZE (SZ_16K - 1)

#define RTL8211F_PHY_ID 0x001cc916
#define RTL8211F_PHY_ID_MASK 0x001fffff
#define RTL8211F_PAGE_SELECT 0x1f
#define RTL8211F_LCR_ADDR 0x10
#define RTL8211F_EEELCR_ADDR 0x11

/* Module parameters */
#define TX_TIMEO 5000
static int watchdog = TX_TIMEO;
Expand Down Expand Up @@ -4986,6 +4992,28 @@ int stmmac_reinit_ringparam(struct net_device *dev, u32 rx_size, u32 tx_size)
return ret;
}

static int phy_rtl8211f_led_fixup(struct phy_device *phydev)
{
u32 val, val2;
/* Switch to Page 0x0d04 */
phy_write(phydev, RTL8211F_PAGE_SELECT, 0x0d04);
/* Set LED1(Green) Link 10/100/1000M + Active, and set LED2(Yellow) Link 10/100/1000M */
val = phy_read(phydev, RTL8211F_LCR_ADDR);
val |= (1<<5);
val |= (1<<8);
val |= (1<<10);
val |= (1<<11);
val &= (~(1<<14));
phy_write(phydev, RTL8211F_LCR_ADDR, val);
/* Disable LED2(Yellow) EEE LED function to keep it on when linked */
val2 = phy_read(phydev, RTL8211F_EEELCR_ADDR);
val2 &= (~(1<<3));
phy_write(phydev, RTL8211F_EEELCR_ADDR, val2);
/* Switch back to the PHY's IEEE Standard Registers. Here it is Page 0 */
phy_write(phydev, RTL8211F_PAGE_SELECT, 0);
return 0;
}

/**
* stmmac_dvr_probe
* @device: device pointer
Expand Down Expand Up @@ -5223,6 +5251,11 @@ int stmmac_dvr_probe(struct device *device,
stmmac_init_fs(ndev);
#endif

ret = phy_register_fixup_for_uid(RTL8211F_PHY_ID, RTL8211F_PHY_ID_MASK, phy_rtl8211f_led_fixup);
if (ret) {
dev_warn(priv->device, "Failed to register fixup for PHY RTL8211F.\n");
}

/* Let pm_runtime_put() disable the clocks.
* If CONFIG_PM is not enabled, the clocks will stay powered.
*/
Expand Down

0 comments on commit b5bbe5d

Please sign in to comment.