Skip to content

Commit 23baa58

Browse files
Phil Elwellpopcornmix
authored andcommitted
lan78xx: Enable LEDs and auto-negotiation
For applications of the LAN78xx that don't have valid programmed EEPROMs or OTPs, enabling both LEDs and auto-negotiation by default seems reasonable. Signed-off-by: Phil Elwell <phil@raspberrypi.org>
1 parent 84f84b5 commit 23baa58

1 file changed

Lines changed: 11 additions & 0 deletions

File tree

‎drivers/net/usb/lan78xx.c‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2457,6 +2457,11 @@ static int lan78xx_reset(struct lan78xx_net *dev)
24572457
int ret = 0;
24582458
unsigned long timeout;
24592459
u8 sig;
2460+
bool has_eeprom;
2461+
bool has_otp;
2462+
2463+
has_eeprom = !lan78xx_read_eeprom(dev, 0, 0, NULL);
2464+
has_otp = !lan78xx_read_otp(dev, 0, 0, NULL);
24602465

24612466
ret = lan78xx_read_reg(dev, HW_CFG, &buf);
24622467
buf |= HW_CFG_LRST_;
@@ -2510,6 +2515,9 @@ static int lan78xx_reset(struct lan78xx_net *dev)
25102515

25112516
ret = lan78xx_read_reg(dev, HW_CFG, &buf);
25122517
buf |= HW_CFG_MEF_;
2518+
/* If no valid EEPROM and no valid OTP, enable the LEDs by default */
2519+
if (!has_eeprom && !has_otp)
2520+
buf |= HW_CFG_LED0_EN_ | HW_CFG_LED1_EN_;
25132521
ret = lan78xx_write_reg(dev, HW_CFG, buf);
25142522

25152523
ret = lan78xx_read_reg(dev, USB_CFG0, &buf);
@@ -2565,6 +2573,9 @@ static int lan78xx_reset(struct lan78xx_net *dev)
25652573
buf |= MAC_CR_AUTO_DUPLEX_ | MAC_CR_AUTO_SPEED_;
25662574
}
25672575
}
2576+
/* If no valid EEPROM and no valid OTP, enable AUTO negotiation */
2577+
if (!has_eeprom && !has_otp)
2578+
buf |= MAC_CR_AUTO_DUPLEX_ | MAC_CR_AUTO_SPEED_;
25682579
ret = lan78xx_write_reg(dev, MAC_CR, buf);
25692580

25702581
ret = lan78xx_read_reg(dev, MAC_TX, &buf);

0 commit comments

Comments
 (0)