Skip to content

drivers: usb: lan78xx: add support to control LED mode register #11

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: lf-6.1.y
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions drivers/net/usb/lan78xx.c
Original file line number Diff line number Diff line change
Expand Up @@ -2410,7 +2410,11 @@ static int lan78xx_phy_init(struct lan78xx_net *dev)

if (phydev->mdio.dev.of_node) {
u32 reg;
u32 led_modes[4];
u16 regval = 0;
int len;
int shifter = 0;
int i;

len = of_property_count_elems_of_size(phydev->mdio.dev.of_node,
"microchip,led-modes",
Expand All @@ -2427,6 +2431,24 @@ static int lan78xx_phy_init(struct lan78xx_net *dev)
(len > 2) * HW_CFG_LED2_EN_ |
(len > 3) * HW_CFG_LED3_EN_;
lan78xx_write_reg(dev, HW_CFG, reg);

/* Sanity check */
len = len > 4 ? 4 : len;

ret = of_property_read_u32_array(phydev->mdio.dev.of_node,
"microchip,led-modes",
led_modes,
len);
if (!ret) {
for(i = 0; i < len; i++) {
regval |= (led_modes[i] << shifter);
shifter += 4;
}
lan78xx_mdiobus_write(dev->mdiobus,
MII_ACC_PHY_ADDR,
MII_IDX_LED_MODE_REG,
regval);
}
}
}

Expand Down
3 changes: 3 additions & 0 deletions drivers/net/usb/lan78xx.h
Original file line number Diff line number Diff line change
Expand Up @@ -604,6 +604,9 @@
#define MII_DATA (0x124)
#define MII_DATA_MASK_ (0x0000FFFF)

#define MII_ACC_PHY_ADDR (1)
#define MII_IDX_LED_MODE_REG (29)

#define MAC_RGMII_ID (0x128)
#define MAC_RGMII_ID_TXC_DELAY_EN_ (0x00000002)
#define MAC_RGMII_ID_RXC_DELAY_EN_ (0x00000001)
Expand Down