Skip to content

Commit

Permalink
arc_emac: write initial MAC address from devicetree to hw
Browse files Browse the repository at this point in the history
The MAC address retrieved from dt was not actually written to the
hardware. This meant proper communication was only possible after
changing the MAC address.

Fix that by always writing the mac address during probing.

Signed-off-by: Max Schwarz <max.schwarz@online.de>
Acked-by: Heiko Stuebner <heiko@sntech.de>
Tested-by: Heiko Stuebner <heiko@sntech.de>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Max Schwarz authored and David S. Miller committed Apr 22, 2014
1 parent 78541c1 commit 235a251
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions drivers/net/ethernet/arc/emac_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -574,6 +574,18 @@ static int arc_emac_tx(struct sk_buff *skb, struct net_device *ndev)
return NETDEV_TX_OK;
}

static void arc_emac_set_address_internal(struct net_device *ndev)
{
struct arc_emac_priv *priv = netdev_priv(ndev);
unsigned int addr_low, addr_hi;

addr_low = le32_to_cpu(*(__le32 *) &ndev->dev_addr[0]);
addr_hi = le16_to_cpu(*(__le16 *) &ndev->dev_addr[4]);

arc_reg_set(priv, R_ADDRL, addr_low);
arc_reg_set(priv, R_ADDRH, addr_hi);
}

/**
* arc_emac_set_address - Set the MAC address for this device.
* @ndev: Pointer to net_device structure.
Expand All @@ -587,9 +599,7 @@ static int arc_emac_tx(struct sk_buff *skb, struct net_device *ndev)
*/
static int arc_emac_set_address(struct net_device *ndev, void *p)
{
struct arc_emac_priv *priv = netdev_priv(ndev);
struct sockaddr *addr = p;
unsigned int addr_low, addr_hi;

if (netif_running(ndev))
return -EBUSY;
Expand All @@ -599,11 +609,7 @@ static int arc_emac_set_address(struct net_device *ndev, void *p)

memcpy(ndev->dev_addr, addr->sa_data, ndev->addr_len);

addr_low = le32_to_cpu(*(__le32 *) &ndev->dev_addr[0]);
addr_hi = le16_to_cpu(*(__le16 *) &ndev->dev_addr[4]);

arc_reg_set(priv, R_ADDRL, addr_low);
arc_reg_set(priv, R_ADDRH, addr_hi);
arc_emac_set_address_internal(ndev);

return 0;
}
Expand Down Expand Up @@ -713,6 +719,7 @@ static int arc_emac_probe(struct platform_device *pdev)
else
eth_hw_addr_random(ndev);

arc_emac_set_address_internal(ndev);
dev_info(&pdev->dev, "MAC address is now %pM\n", ndev->dev_addr);

/* Do 1 allocation instead of 2 separate ones for Rx and Tx BD rings */
Expand Down

0 comments on commit 235a251

Please sign in to comment.