Browse Source

[smsc95xx] Fetch MAC from device tree for Raspberry Pi

Signed-off-by: Michael Brown <mcb30@ipxe.org>
tags/v1.20.1
Michael Brown 5 years ago
parent
commit
83e0f9f377
1 changed files with 31 additions and 0 deletions
  1. 31
    0
      src/drivers/net/smsc95xx.c

+ 31
- 0
src/drivers/net/smsc95xx.c View File

@@ -33,6 +33,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
33 33
 #include <ipxe/profile.h>
34 34
 #include <ipxe/base16.h>
35 35
 #include <ipxe/smbios.h>
36
+#include <ipxe/fdt.h>
36 37
 #include "smsc95xx.h"
37 38
 
38 39
 /** @file
@@ -158,6 +159,32 @@ static int smsc95xx_vm3_fetch_mac ( struct smscusb_device *smscusb ) {
158 159
 	return 0;
159 160
 }
160 161
 
162
+/**
163
+ * Fetch MAC address from device tree
164
+ *
165
+ * @v smscusb		SMSC USB device
166
+ * @ret rc		Return status code
167
+ */
168
+static int smsc95xx_fdt_fetch_mac ( struct smscusb_device *smscusb ) {
169
+	struct net_device *netdev = smscusb->netdev;
170
+	unsigned int offset;
171
+	int rc;
172
+
173
+	/* Look for "ethernet[0]" alias */
174
+	if ( ( rc = fdt_alias ( "ethernet", &offset ) != 0 ) &&
175
+	     ( rc = fdt_alias ( "ethernet0", &offset ) != 0 ) ) {
176
+		return rc;
177
+	}
178
+
179
+	/* Fetch MAC address */
180
+	if ( ( rc = fdt_mac ( offset, netdev ) ) != 0 )
181
+		return rc;
182
+
183
+	DBGC ( smscusb, "SMSC95XX %p using FDT MAC %s\n",
184
+	       smscusb, eth_ntoa ( netdev->hw_addr ) );
185
+	return 0;
186
+}
187
+
161 188
 /**
162 189
  * Fetch MAC address
163 190
  *
@@ -173,6 +200,10 @@ static int smsc95xx_fetch_mac ( struct smscusb_device *smscusb ) {
173 200
 					       SMSC95XX_E2P_BASE ) ) == 0 )
174 201
 		return 0;
175 202
 
203
+	/* Read MAC address from device tree */
204
+	if ( ( rc = smsc95xx_fdt_fetch_mac ( smscusb ) ) == 0 )
205
+		return 0;
206
+
176 207
 	/* Construct MAC address for Honeywell VM3, if applicable */
177 208
 	if ( ( rc = smsc95xx_vm3_fetch_mac ( smscusb ) ) == 0 )
178 209
 		return 0;

Loading…
Cancel
Save