bcm27xx: add support for linux v5.15
[openwrt/staging/noltari.git] / target / linux / bcm27xx / patches-5.15 / 950-0055-lan78xx-Enable-LEDs-and-auto-negotiation.patch
1 From ec6fe1f3510a68ea742758b1cd806a5a08fed7ae 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 | 12 ++++++++++++
13 1 file changed, 12 insertions(+)
14
15 --- a/drivers/net/usb/lan78xx.c
16 +++ b/drivers/net/usb/lan78xx.c
17 @@ -2716,6 +2716,11 @@ static int lan78xx_reset(struct lan78xx_
18 int ret;
19 u32 buf;
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 if (ret < 0)
29 @@ -2797,6 +2802,10 @@ static int lan78xx_reset(struct lan78xx_
30
31 buf |= HW_CFG_MEF_;
32
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 +
37 ret = lan78xx_write_reg(dev, HW_CFG, buf);
38 if (ret < 0)
39 return ret;
40 @@ -2895,6 +2904,9 @@ static int lan78xx_reset(struct lan78xx_
41 buf |= MAC_CR_AUTO_DUPLEX_ | MAC_CR_AUTO_SPEED_;
42 }
43 }
44 + /* If no valid EEPROM and no valid OTP, enable AUTO negotiation */
45 + if (!has_eeprom && !has_otp)
46 + buf |= MAC_CR_AUTO_DUPLEX_ | MAC_CR_AUTO_SPEED_;
47 ret = lan78xx_write_reg(dev, MAC_CR, buf);
48 if (ret < 0)
49 return ret;