Parcourir la source

[smscusb] Fetch MAC from device tree for Raspberry Pi Model B+

Signed-off-by: Michael Brown <mcb30@ipxe.org>
tags/v1.20.1
Michael Brown il y a 5 ans
Parent
révision
f4cc5834ef
4 fichiers modifiés avec 41 ajouts et 29 suppressions
  1. 4
    0
      src/drivers/net/lan78xx.c
  2. 2
    29
      src/drivers/net/smsc95xx.c
  3. 34
    0
      src/drivers/net/smscusb.c
  4. 1
    0
      src/drivers/net/smscusb.h

+ 4
- 0
src/drivers/net/lan78xx.c Voir le fichier

@@ -97,6 +97,10 @@ static int lan78xx_fetch_mac ( struct smscusb_device *smscusb ) {
97 97
 	if ( ( rc = smscusb_otp_fetch_mac ( smscusb, LAN78XX_OTP_BASE ) ) == 0 )
98 98
 		return 0;
99 99
 
100
+	/* Read MAC address from device tree, if present */
101
+	if ( ( rc = smscusb_fdt_fetch_mac ( smscusb ) ) == 0 )
102
+		return 0;
103
+
100 104
 	/* Otherwise, generate a random MAC address */
101 105
 	eth_random_addr ( netdev->hw_addr );
102 106
 	DBGC ( smscusb, "LAN78XX %p using random MAC %s\n",

+ 2
- 29
src/drivers/net/smsc95xx.c Voir le fichier

@@ -33,7 +33,6 @@ 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>
37 36
 #include "smsc95xx.h"
38 37
 
39 38
 /** @file
@@ -159,32 +158,6 @@ static int smsc95xx_vm3_fetch_mac ( struct smscusb_device *smscusb ) {
159 158
 	return 0;
160 159
 }
161 160
 
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
-
188 161
 /**
189 162
  * Fetch MAC address
190 163
  *
@@ -200,8 +173,8 @@ static int smsc95xx_fetch_mac ( struct smscusb_device *smscusb ) {
200 173
 					       SMSC95XX_E2P_BASE ) ) == 0 )
201 174
 		return 0;
202 175
 
203
-	/* Read MAC address from device tree */
204
-	if ( ( rc = smsc95xx_fdt_fetch_mac ( smscusb ) ) == 0 )
176
+	/* Read MAC address from device tree, if present */
177
+	if ( ( rc = smscusb_fdt_fetch_mac ( smscusb ) ) == 0 )
205 178
 		return 0;
206 179
 
207 180
 	/* Construct MAC address for Honeywell VM3, if applicable */

+ 34
- 0
src/drivers/net/smscusb.c Voir le fichier

@@ -30,6 +30,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
30 30
 #include <ipxe/usbnet.h>
31 31
 #include <ipxe/ethernet.h>
32 32
 #include <ipxe/profile.h>
33
+#include <ipxe/fdt.h>
33 34
 #include "smscusb.h"
34 35
 
35 36
 /** @file
@@ -439,6 +440,39 @@ int smscusb_otp_fetch_mac ( struct smscusb_device *smscusb,
439 440
 	return 0;
440 441
 }
441 442
 
443
+/******************************************************************************
444
+ *
445
+ * Device tree
446
+ *
447
+ ******************************************************************************
448
+ */
449
+
450
+/**
451
+ * Fetch MAC address from device tree
452
+ *
453
+ * @v smscusb		SMSC USB device
454
+ * @ret rc		Return status code
455
+ */
456
+int smscusb_fdt_fetch_mac ( struct smscusb_device *smscusb ) {
457
+	struct net_device *netdev = smscusb->netdev;
458
+	unsigned int offset;
459
+	int rc;
460
+
461
+	/* Look for "ethernet[0]" alias */
462
+	if ( ( rc = fdt_alias ( "ethernet", &offset ) != 0 ) &&
463
+	     ( rc = fdt_alias ( "ethernet0", &offset ) != 0 ) ) {
464
+		return rc;
465
+	}
466
+
467
+	/* Fetch MAC address */
468
+	if ( ( rc = fdt_mac ( offset, netdev ) ) != 0 )
469
+		return rc;
470
+
471
+	DBGC ( smscusb, "SMSCUSB %p using FDT MAC %s\n",
472
+	       smscusb, eth_ntoa ( netdev->hw_addr ) );
473
+	return 0;
474
+}
475
+
442 476
 /******************************************************************************
443 477
  *
444 478
  * MII access

+ 1
- 0
src/drivers/net/smscusb.h Voir le fichier

@@ -287,6 +287,7 @@ extern int smscusb_eeprom_fetch_mac ( struct smscusb_device *smscusb,
287 287
 				      unsigned int e2p_base );
288 288
 extern int smscusb_otp_fetch_mac ( struct smscusb_device *smscusb,
289 289
 				   unsigned int otp_base );
290
+extern int smscusb_fdt_fetch_mac ( struct smscusb_device *smscusb );
290 291
 extern int smscusb_mii_check_link ( struct smscusb_device *smscusb );
291 292
 extern int smscusb_mii_open ( struct smscusb_device *smscusb,
292 293
 			      unsigned int phy_mask, unsigned int intrs );

Chargement…
Annuler
Enregistrer