Skip to content

Commit d7a1a14

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 4cbf8ad commit d7a1a14

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

drivers/net/usb/lan78xx.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3248,6 +3248,11 @@ static int lan78xx_reset(struct lan78xx_net *dev)
32483248
unsigned long timeout;
32493249
int ret;
32503250
u32 buf;
3251+
bool has_eeprom;
3252+
bool has_otp;
3253+
3254+
has_eeprom = !lan78xx_read_eeprom(dev, 0, 0, NULL);
3255+
has_otp = !lan78xx_read_otp(dev, 0, 0, NULL);
32513256

32523257
ret = lan78xx_read_reg(dev, HW_CFG, &buf);
32533258
if (ret < 0)
@@ -3318,6 +3323,10 @@ static int lan78xx_reset(struct lan78xx_net *dev)
33183323
buf |= HW_CFG_CLK125_EN_;
33193324
buf |= HW_CFG_REFCLK25_EN_;
33203325

3326+
/* If no valid EEPROM and no valid OTP, enable the LEDs by default */
3327+
if (!has_eeprom && !has_otp)
3328+
buf |= HW_CFG_LED0_EN_ | HW_CFG_LED1_EN_;
3329+
33213330
ret = lan78xx_write_reg(dev, HW_CFG, buf);
33223331
if (ret < 0)
33233332
return ret;
@@ -3410,6 +3419,10 @@ static int lan78xx_reset(struct lan78xx_net *dev)
34103419
if (dev->chipid == ID_REV_CHIP_ID_7801_)
34113420
buf &= ~MAC_CR_GMII_EN_;
34123421

3422+
/* If no valid EEPROM and no valid OTP, enable AUTO negotiation */
3423+
if (!has_eeprom && !has_otp)
3424+
buf |= MAC_CR_AUTO_DUPLEX_ | MAC_CR_AUTO_SPEED_;
3425+
34133426
ret = lan78xx_write_reg(dev, MAC_CR, buf);
34143427
if (ret < 0)
34153428
return ret;

0 commit comments

Comments
 (0)