summaryrefslogtreecommitdiffstats
path: root/bcm2837-lan78xx-fixes.patch
diff options
context:
space:
mode:
authorPeter Robinson <pbrobinson@gmail.com>2018-04-02 18:38:27 +0100
committerPeter Robinson <pbrobinson@gmail.com>2018-04-02 18:38:27 +0100
commit494688df849923c1b0651c7ffc5fc6d6835364f1 (patch)
tree4829273e6395169fe5c78034138a280aba043144 /bcm2837-lan78xx-fixes.patch
parent8b84f3eb40216f8e3ac3df6e8f8609cae61cf7a3 (diff)
downloadkernel-494688df849923c1b0651c7ffc5fc6d6835364f1.tar.gz
kernel-494688df849923c1b0651c7ffc5fc6d6835364f1.tar.xz
kernel-494688df849923c1b0651c7ffc5fc6d6835364f1.zip
Improvements for the Raspberry Pi 3+, Fixes and minor improvements to Raspberry Pi 2/3
Diffstat (limited to 'bcm2837-lan78xx-fixes.patch')
-rw-r--r--bcm2837-lan78xx-fixes.patch108
1 files changed, 108 insertions, 0 deletions
diff --git a/bcm2837-lan78xx-fixes.patch b/bcm2837-lan78xx-fixes.patch
new file mode 100644
index 000000000..f877ac15b
--- /dev/null
+++ b/bcm2837-lan78xx-fixes.patch
@@ -0,0 +1,108 @@
+From 6ed88d188a8240ba44da6578eab7d17e036d0e61 Mon Sep 17 00:00:00 2001
+From: Phil Elwell <phil@raspberrypi.org>
+Date: Tue, 17 Oct 2017 15:04:29 +0100
+Subject: [PATCH] lan78xx: Enable LEDs if no valid EEPROM or OTP
+
+For applications of the LAN78xx that don't have valid programmed
+EEPROMs or OTPs, enabling both LEDs by default seems reasonable.
+
+Signed-off-by: Phil Elwell <phil@raspberrypi.org>
+---
+ drivers/net/usb/lan78xx.c | 6 ++++++
+ 1 file changed, 6 insertions(+)
+
+diff --git a/drivers/net/usb/lan78xx.c b/drivers/net/usb/lan78xx.c
+index a21039852f8d..cd20ce4ed87d 100644
+--- a/drivers/net/usb/lan78xx.c
++++ b/drivers/net/usb/lan78xx.c
+@@ -2414,6 +2414,12 @@ static int lan78xx_reset(struct lan78xx_net *dev)
+
+ ret = lan78xx_read_reg(dev, HW_CFG, &buf);
+ buf |= HW_CFG_MEF_;
++
++ /* If no valid EEPROM and no valid OTP, enable the LEDs by default */
++ if (lan78xx_read_eeprom(dev, 0, 0, NULL) &&
++ lan78xx_read_otp(dev, 0, 0, NULL))
++ buf |= HW_CFG_LED0_EN_ | HW_CFG_LED1_EN_;
++
+ ret = lan78xx_write_reg(dev, HW_CFG, buf);
+
+ ret = lan78xx_read_reg(dev, USB_CFG0, &buf);
+From f8a798bb45ae15cbec980c8e921eb377fd1a3df6 Mon Sep 17 00:00:00 2001
+From: Phil Elwell <phil@raspberrypi.org>
+Date: Tue, 28 Nov 2017 12:02:37 +0000
+Subject: [PATCH] lan78xx: Correctly indicate invalid OTP
+
+lan78xx_read_otp tries to return -EINVAL in the event of invalid OTP
+content, but the value gets overwritten before it is returned and the
+read goes ahead anyway. Make the read conditional as it should be
+and preserve the error code.
+
+Signed-off-by: Phil Elwell <phil@raspberrypi.org>
+---
+ drivers/net/usb/lan78xx.c | 3 ++-
+ 1 file changed, 2 insertions(+), 1 deletion(-)
+
+diff --git a/drivers/net/usb/lan78xx.c b/drivers/net/usb/lan78xx.c
+index cd20ce4ed87d..b270935f3f8d 100644
+--- a/drivers/net/usb/lan78xx.c
++++ b/drivers/net/usb/lan78xx.c
+@@ -929,7 +929,8 @@ static int lan78xx_read_otp(struct lan78xx_net *dev, u32 offset,
+ offset += 0x100;
+ else
+ ret = -EINVAL;
+- ret = lan78xx_read_raw_otp(dev, offset, length, data);
++ if (!ret)
++ ret = lan78xx_read_raw_otp(dev, offset, length, data);
+ }
+
+ return ret;
+From 4a4710f3847cd087e150f83382dffd92e09d9914 Mon Sep 17 00:00:00 2001
+From: Phil Elwell <phil@raspberrypi.org>
+Date: Sat, 17 Mar 2018 00:10:02 +0100
+Subject: [PATCH] lan78xx: Read MAC address from DT if present
+
+There is a standard mechanism for locating and using a MAC address from
+the Device Tree. Use this facility in the lan78xx driver to support
+applications without programmed EEPROM or OTP.
+
+Signed-off-by: Phil Elwell <phil@raspberrypi.org>
+---
+ drivers/net/usb/lan78xx.c | 10 ++++++++++
+ 1 file changed, 10 insertions(+)
+
+diff --git a/drivers/net/usb/lan78xx.c b/drivers/net/usb/lan78xx.c
+index 60a604cc7647..a21039852f8d 100644
+--- a/drivers/net/usb/lan78xx.c
++++ b/drivers/net/usb/lan78xx.c
+@@ -36,6 +36,7 @@
+ #include <linux/irq.h>
+ #include <linux/irqchip/chained_irq.h>
+ #include <linux/microchipphy.h>
++#include <linux/of_net.h>
+ #include <linux/phy.h>
+ #include "lan78xx.h"
+
+@@ -1639,6 +1640,14 @@ static void lan78xx_init_mac_address(struct lan78xx_net *dev)
+ u32 addr_lo, addr_hi;
+ int ret;
+ u8 addr[6];
++ const u8 *mac_addr;
++
++ /* maybe the boot loader passed the MAC address in devicetree */
++ mac_addr = of_get_mac_address(dev->udev->dev.of_node);
++ if (mac_addr) {
++ ether_addr_copy(addr, mac_addr);
++ goto set_mac_addr;
++ }
+
+ ret = lan78xx_read_reg(dev, RX_ADDRL, &addr_lo);
+ ret = lan78xx_read_reg(dev, RX_ADDRH, &addr_hi);
+@@ -1667,6 +1676,7 @@ static void lan78xx_init_mac_address(struct lan78xx_net *dev)
+ "MAC address set to random addr");
+ }
+
++set_mac_addr:
+ addr_lo = addr[0] | (addr[1] << 8) |
+ (addr[2] << 16) | (addr[3] << 24);
+ addr_hi = addr[4] | (addr[5] << 8);