Commit 9120bd6e authored by Tony Lindgren's avatar Tony Lindgren Committed by David S. Miller

net: davinci_emac: Get device dm816x MAC address using the cpsw code

At least on dm81xx, we can get the davinci_emac MAC address the same
way as on am33xx cpsw.

Let's also use ether_addr_copy() for davinci_emac while at it.

Cc: Brian Hutchinson <b.hutchman@gmail.com>
Cc: Felipe Balbi <balbi@ti.com>
Signed-off-by: default avatarTony Lindgren <tony@atomide.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent e5a49c1e
...@@ -69,6 +69,7 @@ ...@@ -69,6 +69,7 @@
#include <asm/irq.h> #include <asm/irq.h>
#include <asm/page.h> #include <asm/page.h>
#include "cpsw.h"
#include "davinci_cpdma.h" #include "davinci_cpdma.h"
static int debug_level; static int debug_level;
...@@ -1838,7 +1839,7 @@ davinci_emac_of_get_pdata(struct platform_device *pdev, struct emac_priv *priv) ...@@ -1838,7 +1839,7 @@ davinci_emac_of_get_pdata(struct platform_device *pdev, struct emac_priv *priv)
if (!is_valid_ether_addr(pdata->mac_addr)) { if (!is_valid_ether_addr(pdata->mac_addr)) {
mac_addr = of_get_mac_address(np); mac_addr = of_get_mac_address(np);
if (mac_addr) if (mac_addr)
memcpy(pdata->mac_addr, mac_addr, ETH_ALEN); ether_addr_copy(pdata->mac_addr, mac_addr);
} }
of_property_read_u32(np, "ti,davinci-ctrl-reg-offset", of_property_read_u32(np, "ti,davinci-ctrl-reg-offset",
...@@ -1879,6 +1880,22 @@ davinci_emac_of_get_pdata(struct platform_device *pdev, struct emac_priv *priv) ...@@ -1879,6 +1880,22 @@ davinci_emac_of_get_pdata(struct platform_device *pdev, struct emac_priv *priv)
return pdata; return pdata;
} }
static int davinci_emac_try_get_mac(struct platform_device *pdev,
int instance, u8 *mac_addr)
{
int error = -EINVAL;
if (!pdev->dev.of_node)
return error;
if (of_device_is_compatible(pdev->dev.of_node, "ti,dm816-emac"))
error = cpsw_am33xx_cm_get_macid(&pdev->dev, 0x30,
instance,
mac_addr);
return error;
}
/** /**
* davinci_emac_probe - EMAC device probe * davinci_emac_probe - EMAC device probe
* @pdev: The DaVinci EMAC device that we are removing * @pdev: The DaVinci EMAC device that we are removing
...@@ -2009,6 +2026,10 @@ static int davinci_emac_probe(struct platform_device *pdev) ...@@ -2009,6 +2026,10 @@ static int davinci_emac_probe(struct platform_device *pdev)
} }
ndev->irq = res->start; ndev->irq = res->start;
rc = davinci_emac_try_get_mac(pdev, res_ctrl ? 0 : 1, priv->mac_addr);
if (!rc)
ether_addr_copy(ndev->dev_addr, priv->mac_addr);
if (!is_valid_ether_addr(priv->mac_addr)) { if (!is_valid_ether_addr(priv->mac_addr)) {
/* Use random MAC if none passed */ /* Use random MAC if none passed */
eth_hw_addr_random(ndev); eth_hw_addr_random(ndev);
......
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