summaryrefslogtreecommitdiffstats
path: root/bcm2837-lan78xx-fixes.patch
diff options
context:
space:
mode:
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);
m">1.13.4 or higher.</p> <p>Recording the priority is now a simple matter of adding the respective field to the template. It now looks like this:</p> <p align="center"> <code>$template TraditionalFormatWithPRI,&quot;%PRI-text%: %timegenerated% %HOSTNAME% %syslogtag%%msg:::drop-last-lf%\n&quot;</code> </p> <p>Now we have the right template - but how to write it to a file? You probably have a line like this in your syslog.conf:</p> <p align="center"><code>*.* -/var/log/messages.log</code></p> <p>It does not specify a template. Consequently, rsyslog uses the traditional format. In order to use some other format, simply specify the template after the semicolon:</p> <p align="center"><code>*.* -/var/log/messages.log;TraditionalFormatWithPRI</code></p> <p>That's all you need to do. There is one common pitfall: you need to define the template before you use it in a selector line. Otherwise, you will receive an error.</p> <p>Once you have applied the changes, you need to restart or HUP rsyslogd. It will then pick the new configuration.</p> <h2>What if I do not want rsyslogd to be the standard syslogd?</h2> <p>If you do not want to switch to rsyslog, you can still use it as a setup aid. A little bit of configuration is required.</p> <ol> <li>Download, make and install rsyslog</li> <li>copy your syslog.conf over to rsyslog.conf</li> <li>add the template described above to it; select the file that should use it</li> <li>stop your regular syslog daemon for the time being</li> <li>run rsyslogd (you may even do this interactively by calling it with the -n additional option from a shell)</li> <li>stop rsyslogd (press ctrl-c when running interactively)</li> <li>restart your regular syslogd</li> </ol> <p>That's it - you can now review the priorities.</p> <h2>Some Sample Data</h2> <p>Below is some sample data created with the template specified above. Note the priority recording at the start of each line.</p> <p> <code>kern.info&lt;6&gt;: Jun 15 18:10:38 host kernel: PCI: Sharing IRQ 11 with 00:04.0<br> kern.info&lt;6&gt;: Jun 15 18:10:38 host kernel: PCI: Sharing IRQ 11 with 01:00.0<br> kern.warn&lt;4&gt;: Jun 15 18:10:38 host kernel: Yenta IRQ list 06b8, PCI irq11<br> kern.warn&lt;4&gt;: Jun 15 18:10:38 host kernel: Socket status: 30000006<br> kern.warn&lt;4&gt;: Jun 15 18:10:38 host kernel: Yenta IRQ list 06b8, PCI irq11<br> kern.warn&lt;4&gt;: Jun 15 18:10:38 host kernel: Socket status: 30000010<br> kern.info&lt;6&gt;: Jun 15 18:10:38 host kernel: cs: IO port probe 0x0c00-0x0cff: clean.<br> kern.info&lt;6&gt;: Jun 15 18:10:38 host kernel: cs: IO port probe 0x0100-0x04ff: excluding 0x100-0x107 0x378-0x37f 0x4d0-0x4d7<br> kern.info&lt;6&gt;: Jun 15 18:10:38 host kernel: cs: IO port probe 0x0a00-0x0aff: clean.<br> local7.notice&lt;189&gt;: Jun 15 18:17:24 host dd: 1+0 records out<br> local7.notice&lt;189&gt;: Jun 15 18:17:24 host random: Saving random seed: succeeded<br> local7.notice&lt;189&gt;: Jun 15 18:17:25 host portmap: portmap shutdown succeeded<br> local7.notice&lt;189&gt;: Jun 15 18:17:25 host network: Shutting down interface eth1: succeeded<br> local7.notice&lt;189&gt;: Jun 15 18:17:25 host network: Shutting down loopback interface: succeeded<br> local7.notice&lt;189&gt;: Jun 15 18:17:25 host pcmcia: Shutting down PCMCIA services: cardmgr<br> user.notice&lt;13&gt;: Jun 15 18:17:25 host /etc/hotplug/net.agent: NET unregister event not supported<br> local7.notice&lt;189&gt;: Jun 15 18:17:27 host pcmcia: modules.<br> local7.notice&lt;189&gt;: Jun 15 18:17:29 host rc: Stopping pcmcia: succeeded<br> local7.notice&lt;189&gt;: Jun 15 18:17:30 host rc: Starting killall: succeeded<br> syslog.info&lt;46&gt;: Jun 15 18:17:33 host [origin software=&quot;rsyslogd&quot; swVersion=&quot;1.13.3&quot; x-pid=&quot;2464&quot;] exiting on signal 15.<br> syslog.info&lt;46&gt;: Jun 18 10:55:47 host [origin software=&quot;rsyslogd&quot; swVersion=&quot;1.13.3&quot; x-pid=&quot;2367&quot;][x-configInfo udpReception=&quot;Yes&quot; udpPort=&quot;514&quot; tcpReception=&quot;Yes&quot; tcpPort=&quot;1470&quot;] restart<br> user.notice&lt;13&gt;: Jun 18 10:55:50 host rger: test<br> syslog.info&lt;46&gt;: Jun 18 10:55:52 host [origin software=&quot;rsyslogd&quot; swVersion=&quot;1.13.3&quot; x-pid=&quot;2367&quot;] exiting on signal 2.</code></p> <h2>Feedback Requested</h2> <P>I would appreciate feedback on this paper. If you have additional ideas, comments or find bugs, please <a href="mailto:rgerhards@adiscon.com">let me know</a>.</P> <h2>References and Additional Material</h2> <ul> <li><a href="http://www.rsyslog.com">www.rsyslog.com</a> - the rsyslog site</li> </ul> <h2>Revision History</h2> <ul> <li>2007-06-18 * <a href="http://www.adiscon.com/en/people/rainer-gerhards.php">Rainer Gerhards</a> * initial version created</li> </ul> <h2>Copyright</h2> <p>Copyright (c) 2007 <a href="http://www.adiscon.com/en/people/rainer-gerhards.php">Rainer Gerhards</a> and <a href="http://www.adiscon.com/en/">Adiscon</a>.</p> <p>Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2 or any later version published by the Free Software Foundation; with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts. A copy of the license can be viewed at <a href="http://www.gnu.org/copyleft/fdl.html">