kernel: bump 4.19 to 4.19.101
[openwrt/openwrt.git] / target / linux / brcm2708 / patches-4.19 / 950-0032-lan78xx-Enable-LEDs-and-auto-negotiation.patch
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
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 @@ -2477,6 +2477,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 @@ -2530,6 +2535,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 @@ -2585,6 +2593,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);