1 From 645eb2cf211c04496c9f5daca23ab16ce796b0df Mon Sep 17 00:00:00 2001
2 From: Phil Elwell <phil@raspberrypi.org>
3 Date: Tue, 17 Oct 2017 15:04:29 +0100
4 Subject: [PATCH] lan78xx: Enable LEDs and auto-negotiation
6 For applications of the LAN78xx that don't have valid programmed
7 EEPROMs or OTPs, enabling both LEDs and auto-negotiation by default
10 Signed-off-by: Phil Elwell <phil@raspberrypi.org>
12 drivers/net/usb/lan78xx.c | 11 +++++++++++
13 1 file changed, 11 insertions(+)
15 --- a/drivers/net/usb/lan78xx.c
16 +++ b/drivers/net/usb/lan78xx.c
17 @@ -2475,6 +2475,11 @@ static int lan78xx_reset(struct lan78xx_
19 unsigned long timeout;
24 + has_eeprom = !lan78xx_read_eeprom(dev, 0, 0, NULL);
25 + has_otp = !lan78xx_read_otp(dev, 0, 0, NULL);
27 ret = lan78xx_read_reg(dev, HW_CFG, &buf);
29 @@ -2528,6 +2533,9 @@ static int lan78xx_reset(struct lan78xx_
31 ret = lan78xx_read_reg(dev, HW_CFG, &buf);
33 + /* If no valid EEPROM and no valid OTP, enable the LEDs by default */
34 + if (!has_eeprom && !has_otp)
35 + buf |= HW_CFG_LED0_EN_ | HW_CFG_LED1_EN_;
36 ret = lan78xx_write_reg(dev, HW_CFG, buf);
38 ret = lan78xx_read_reg(dev, USB_CFG0, &buf);
39 @@ -2583,6 +2591,9 @@ static int lan78xx_reset(struct lan78xx_
40 buf |= MAC_CR_AUTO_DUPLEX_ | MAC_CR_AUTO_SPEED_;
43 + /* If no valid EEPROM and no valid OTP, enable AUTO negotiation */
44 + if (!has_eeprom && !has_otp)
45 + buf |= MAC_CR_AUTO_DUPLEX_ | MAC_CR_AUTO_SPEED_;
46 ret = lan78xx_write_reg(dev, MAC_CR, buf);
48 ret = lan78xx_read_reg(dev, MAC_TX, &buf);