Commit 2f771399 authored by Steve Lin's avatar Steve Lin Committed by David S. Miller

net: ethernet: bgmac: Allow MAC address to be specified in DTB

Allows the BCMA version of the bgmac driver to obtain MAC address
from the device tree.  If no MAC address is specified there, then
the previous behavior (obtaining MAC address from SPROM) is
used.
Signed-off-by: default avatarSteve Lin <steven.lin1@broadcom.com>
Reviewed-by: default avatarFlorian Fainelli <f.fainelli@gmail.com>
Acked-by: default avatarJon Mason <jon.mason@broadcom.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 01ac2994
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
#include <linux/bcma/bcma.h> #include <linux/bcma/bcma.h>
#include <linux/brcmphy.h> #include <linux/brcmphy.h>
#include <linux/etherdevice.h> #include <linux/etherdevice.h>
#include <linux/of_net.h>
#include "bgmac.h" #include "bgmac.h"
static inline bool bgmac_is_bcm4707_family(struct bcma_device *core) static inline bool bgmac_is_bcm4707_family(struct bcma_device *core)
...@@ -114,7 +115,7 @@ static int bgmac_probe(struct bcma_device *core) ...@@ -114,7 +115,7 @@ static int bgmac_probe(struct bcma_device *core)
struct ssb_sprom *sprom = &core->bus->sprom; struct ssb_sprom *sprom = &core->bus->sprom;
struct mii_bus *mii_bus; struct mii_bus *mii_bus;
struct bgmac *bgmac; struct bgmac *bgmac;
u8 *mac; const u8 *mac = NULL;
int err; int err;
bgmac = bgmac_alloc(&core->dev); bgmac = bgmac_alloc(&core->dev);
...@@ -127,21 +128,27 @@ static int bgmac_probe(struct bcma_device *core) ...@@ -127,21 +128,27 @@ static int bgmac_probe(struct bcma_device *core)
bcma_set_drvdata(core, bgmac); bcma_set_drvdata(core, bgmac);
switch (core->core_unit) { if (bgmac->dev->of_node)
case 0: mac = of_get_mac_address(bgmac->dev->of_node);
mac = sprom->et0mac;
break; /* If no MAC address assigned via device tree, check SPROM */
case 1: if (!mac) {
mac = sprom->et1mac; switch (core->core_unit) {
break; case 0:
case 2: mac = sprom->et0mac;
mac = sprom->et2mac; break;
break; case 1:
default: mac = sprom->et1mac;
dev_err(bgmac->dev, "Unsupported core_unit %d\n", break;
core->core_unit); case 2:
err = -ENOTSUPP; mac = sprom->et2mac;
goto err; break;
default:
dev_err(bgmac->dev, "Unsupported core_unit %d\n",
core->core_unit);
err = -ENOTSUPP;
goto err;
}
} }
ether_addr_copy(bgmac->net_dev->dev_addr, mac); ether_addr_copy(bgmac->net_dev->dev_addr, mac);
......
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