6799a07d78b49878dd6af02fad51f4d4b6ce0a66
[openwrt/openwrt.git] / target / linux / bcm27xx / patches-5.4 / 950-0030-lan78xx-Enable-LEDs-and-auto-negotiation.patch
1 From e91aa9302b0d3f9730983d0f1b168a081aab6236 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
5
6 For applications of the LAN78xx that don't have valid programmed
7 EEPROMs or OTPs, enabling both LEDs and auto-negotiation by default
8 seems reasonable.
9
10 Signed-off-by: Phil Elwell <phil@raspberrypi.org>
11 ---
12 drivers/net/usb/lan78xx.c | 11 +++++++++++
13 1 file changed, 11 insertions(+)
14
15 --- a/drivers/net/usb/lan78xx.c
16 +++ b/drivers/net/usb/lan78xx.c
17 @@ -2465,6 +2465,11 @@ static int lan78xx_reset(struct lan78xx_
18 int ret = 0;
19 unsigned long timeout;
20 u8 sig;
21 + bool has_eeprom;
22 + bool has_otp;
23 +
24 + has_eeprom = !lan78xx_read_eeprom(dev, 0, 0, NULL);
25 + has_otp = !lan78xx_read_otp(dev, 0, 0, NULL);
26
27 ret = lan78xx_read_reg(dev, HW_CFG, &buf);
28 buf |= HW_CFG_LRST_;
29 @@ -2518,6 +2523,9 @@ static int lan78xx_reset(struct lan78xx_
30
31 ret = lan78xx_read_reg(dev, HW_CFG, &buf);
32 buf |= HW_CFG_MEF_;
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);
37
38 ret = lan78xx_read_reg(dev, USB_CFG0, &buf);
39 @@ -2573,6 +2581,9 @@ static int lan78xx_reset(struct lan78xx_
40 buf |= MAC_CR_AUTO_DUPLEX_ | MAC_CR_AUTO_SPEED_;
41 }
42 }
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);
47
48 ret = lan78xx_read_reg(dev, MAC_TX, &buf);