if ( ( rc = smscusb_otp_fetch_mac ( smscusb, LAN78XX_OTP_BASE ) ) == 0 )
return 0;
+ /* Read MAC address from device tree, if present */
+ if ( ( rc = smscusb_fdt_fetch_mac ( smscusb ) ) == 0 )
+ return 0;
+
/* Otherwise, generate a random MAC address */
eth_random_addr ( netdev->hw_addr );
DBGC ( smscusb, "LAN78XX %p using random MAC %s\n",
#include <ipxe/profile.h>
#include <ipxe/base16.h>
#include <ipxe/smbios.h>
-#include <ipxe/fdt.h>
#include "smsc95xx.h"
/** @file
return 0;
}
-/**
- * Fetch MAC address from device tree
- *
- * @v smscusb SMSC USB device
- * @ret rc Return status code
- */
-static int smsc95xx_fdt_fetch_mac ( struct smscusb_device *smscusb ) {
- struct net_device *netdev = smscusb->netdev;
- unsigned int offset;
- int rc;
-
- /* Look for "ethernet[0]" alias */
- if ( ( rc = fdt_alias ( "ethernet", &offset ) != 0 ) &&
- ( rc = fdt_alias ( "ethernet0", &offset ) != 0 ) ) {
- return rc;
- }
-
- /* Fetch MAC address */
- if ( ( rc = fdt_mac ( offset, netdev ) ) != 0 )
- return rc;
-
- DBGC ( smscusb, "SMSC95XX %p using FDT MAC %s\n",
- smscusb, eth_ntoa ( netdev->hw_addr ) );
- return 0;
-}
-
/**
* Fetch MAC address
*
SMSC95XX_E2P_BASE ) ) == 0 )
return 0;
- /* Read MAC address from device tree */
- if ( ( rc = smsc95xx_fdt_fetch_mac ( smscusb ) ) == 0 )
+ /* Read MAC address from device tree, if present */
+ if ( ( rc = smscusb_fdt_fetch_mac ( smscusb ) ) == 0 )
return 0;
/* Construct MAC address for Honeywell VM3, if applicable */
#include <ipxe/usbnet.h>
#include <ipxe/ethernet.h>
#include <ipxe/profile.h>
+#include <ipxe/fdt.h>
#include "smscusb.h"
/** @file
return 0;
}
+/******************************************************************************
+ *
+ * Device tree
+ *
+ ******************************************************************************
+ */
+
+/**
+ * Fetch MAC address from device tree
+ *
+ * @v smscusb SMSC USB device
+ * @ret rc Return status code
+ */
+int smscusb_fdt_fetch_mac ( struct smscusb_device *smscusb ) {
+ struct net_device *netdev = smscusb->netdev;
+ unsigned int offset;
+ int rc;
+
+ /* Look for "ethernet[0]" alias */
+ if ( ( rc = fdt_alias ( "ethernet", &offset ) != 0 ) &&
+ ( rc = fdt_alias ( "ethernet0", &offset ) != 0 ) ) {
+ return rc;
+ }
+
+ /* Fetch MAC address */
+ if ( ( rc = fdt_mac ( offset, netdev ) ) != 0 )
+ return rc;
+
+ DBGC ( smscusb, "SMSCUSB %p using FDT MAC %s\n",
+ smscusb, eth_ntoa ( netdev->hw_addr ) );
+ return 0;
+}
+
/******************************************************************************
*
* MII access
unsigned int e2p_base );
extern int smscusb_otp_fetch_mac ( struct smscusb_device *smscusb,
unsigned int otp_base );
+extern int smscusb_fdt_fetch_mac ( struct smscusb_device *smscusb );
extern int smscusb_mii_check_link ( struct smscusb_device *smscusb );
extern int smscusb_mii_open ( struct smscusb_device *smscusb,
unsigned int phy_mask, unsigned int intrs );