1 --- a/drivers/net/ethernet/marvell/sky2.c
2 +++ b/drivers/net/ethernet/marvell/sky2.c
4 #include <linux/prefetch.h>
5 #include <linux/debugfs.h>
7 +#include <linux/of_device.h>
8 +#include <linux/of_net.h>
12 @@ -4748,6 +4750,7 @@ static struct net_device *sky2_init_netd
14 struct sky2_port *sky2;
15 struct net_device *dev = alloc_etherdev(sizeof(*sky2));
16 + unsigned char *iap, tmpaddr[ETH_ALEN];
20 @@ -4802,8 +4805,36 @@ static struct net_device *sky2_init_netd
22 dev->features |= dev->hw_features;
25 + * try to get mac address in the following order:
26 + * 1) from device tree data
27 + * 2) from internal registers set by bootloader
31 + struct device_node *np;
32 + np = of_find_node_by_path("/aliases");
34 + const char *path = of_get_property(np, "sky2", NULL);
36 + np = of_find_node_by_path(path);
38 + path = of_get_mac_address(np);
40 + iap = (unsigned char *) path;
45 + * 2) mac registers set by bootloader
47 + if (!iap || !is_valid_ether_addr(iap)) {
48 + memcpy_fromio(&tmpaddr, hw->regs + B2_MAC_1 + port * 8, ETH_ALEN);
52 /* read the mac address */
53 - memcpy_fromio(dev->dev_addr, hw->regs + B2_MAC_1 + port * 8, ETH_ALEN);
54 + memcpy(dev->dev_addr, iap, ETH_ALEN);