Commit 566bd54b authored by Lukas Wunner's avatar Lukas Wunner Committed by David S. Miller

net: ks8851: Support DT-provided MAC address

Allow the boot loader to specify the MAC address in the device tree
to override the EEPROM, or in case no EEPROM is present.

Cc: Ben Dooks <ben@simtec.co.uk>
Cc: Tristram Ha <tristram.ha@micrel.com>
Cc: David J. Choi <david.choi@micrel.com>
Signed-off-by: default avatarLukas Wunner <lukas@wunner.de>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent e2948dd1
...@@ -28,6 +28,7 @@ ...@@ -28,6 +28,7 @@
#include <linux/spi/spi.h> #include <linux/spi/spi.h>
#include <linux/gpio.h> #include <linux/gpio.h>
#include <linux/of_gpio.h> #include <linux/of_gpio.h>
#include <linux/of_net.h>
#include "ks8851.h" #include "ks8851.h"
...@@ -407,15 +408,23 @@ static void ks8851_read_mac_addr(struct net_device *dev) ...@@ -407,15 +408,23 @@ static void ks8851_read_mac_addr(struct net_device *dev)
* @ks: The device structure * @ks: The device structure
* *
* Get or create the initial mac address for the device and then set that * Get or create the initial mac address for the device and then set that
* into the station address register. If there is an EEPROM present, then * into the station address register. A mac address supplied in the device
* tree takes precedence. Otherwise, if there is an EEPROM present, then
* we try that. If no valid mac address is found we use eth_random_addr() * we try that. If no valid mac address is found we use eth_random_addr()
* to create a new one. * to create a new one.
*/ */
static void ks8851_init_mac(struct ks8851_net *ks) static void ks8851_init_mac(struct ks8851_net *ks)
{ {
struct net_device *dev = ks->netdev; struct net_device *dev = ks->netdev;
const u8 *mac_addr;
mac_addr = of_get_mac_address(ks->spidev->dev.of_node);
if (mac_addr) {
memcpy(dev->dev_addr, mac_addr, ETH_ALEN);
ks8851_write_mac_addr(dev);
return;
}
/* first, try reading what we've got already */
if (ks->rc_ccr & CCR_EEPROM) { if (ks->rc_ccr & CCR_EEPROM) {
ks8851_read_mac_addr(dev); ks8851_read_mac_addr(dev);
if (is_valid_ether_addr(dev->dev_addr)) if (is_valid_ether_addr(dev->dev_addr))
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment