Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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: Steve Lin <steven.lin1@broadcom.com>
Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
Acked-by: Jon Mason <jon.mason@broadcom.com>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Steve Lin and committed by
David S. Miller
2f771399 01ac2994

+23 -16
+23 -16
drivers/net/ethernet/broadcom/bgmac-bcma.c
··· 11 11 #include <linux/bcma/bcma.h> 12 12 #include <linux/brcmphy.h> 13 13 #include <linux/etherdevice.h> 14 + #include <linux/of_net.h> 14 15 #include "bgmac.h" 15 16 16 17 static inline bool bgmac_is_bcm4707_family(struct bcma_device *core) ··· 115 114 struct ssb_sprom *sprom = &core->bus->sprom; 116 115 struct mii_bus *mii_bus; 117 116 struct bgmac *bgmac; 118 - u8 *mac; 117 + const u8 *mac = NULL; 119 118 int err; 120 119 121 120 bgmac = bgmac_alloc(&core->dev); ··· 128 127 129 128 bcma_set_drvdata(core, bgmac); 130 129 131 - switch (core->core_unit) { 132 - case 0: 133 - mac = sprom->et0mac; 134 - break; 135 - case 1: 136 - mac = sprom->et1mac; 137 - break; 138 - case 2: 139 - mac = sprom->et2mac; 140 - break; 141 - default: 142 - dev_err(bgmac->dev, "Unsupported core_unit %d\n", 143 - core->core_unit); 144 - err = -ENOTSUPP; 145 - goto err; 130 + if (bgmac->dev->of_node) 131 + mac = of_get_mac_address(bgmac->dev->of_node); 132 + 133 + /* If no MAC address assigned via device tree, check SPROM */ 134 + if (!mac) { 135 + switch (core->core_unit) { 136 + case 0: 137 + mac = sprom->et0mac; 138 + break; 139 + case 1: 140 + mac = sprom->et1mac; 141 + break; 142 + case 2: 143 + mac = sprom->et2mac; 144 + break; 145 + default: 146 + dev_err(bgmac->dev, "Unsupported core_unit %d\n", 147 + core->core_unit); 148 + err = -ENOTSUPP; 149 + goto err; 150 + } 146 151 } 147 152 148 153 ether_addr_copy(bgmac->net_dev->dev_addr, mac);