aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/ethernet
diff options
context:
space:
mode:
authorTony Lindgren <tony@atomide.com>2015-01-28 14:33:05 -0500
committerDavid S. Miller <davem@davemloft.net>2015-01-30 20:42:01 -0500
commit9120bd6e9f779d921450ec53cea02eff07003eae (patch)
tree379d30c613d0287e1c491b915841393c158bba1e /drivers/net/ethernet
parente5a49c1e3b189c744770e04d2b46ec7ca37d604c (diff)
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: Tony Lindgren <tony@atomide.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/ethernet')
-rw-r--r--drivers/net/ethernet/ti/davinci_emac.c23
1 files changed, 22 insertions, 1 deletions
diff --git a/drivers/net/ethernet/ti/davinci_emac.c b/drivers/net/ethernet/ti/davinci_emac.c
index 5fae4354722c..a7169384ff6e 100644
--- a/drivers/net/ethernet/ti/davinci_emac.c
+++ b/drivers/net/ethernet/ti/davinci_emac.c
@@ -69,6 +69,7 @@
69#include <asm/irq.h> 69#include <asm/irq.h>
70#include <asm/page.h> 70#include <asm/page.h>
71 71
72#include "cpsw.h"
72#include "davinci_cpdma.h" 73#include "davinci_cpdma.h"
73 74
74static int debug_level; 75static int debug_level;
@@ -1838,7 +1839,7 @@ davinci_emac_of_get_pdata(struct platform_device *pdev, struct emac_priv *priv)
1838 if (!is_valid_ether_addr(pdata->mac_addr)) { 1839 if (!is_valid_ether_addr(pdata->mac_addr)) {
1839 mac_addr = of_get_mac_address(np); 1840 mac_addr = of_get_mac_address(np);
1840 if (mac_addr) 1841 if (mac_addr)
1841 memcpy(pdata->mac_addr, mac_addr, ETH_ALEN); 1842 ether_addr_copy(pdata->mac_addr, mac_addr);
1842 } 1843 }
1843 1844
1844 of_property_read_u32(np, "ti,davinci-ctrl-reg-offset", 1845 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 return pdata; 1880 return pdata;
1880} 1881}
1881 1882
1883static int davinci_emac_try_get_mac(struct platform_device *pdev,
1884 int instance, u8 *mac_addr)
1885{
1886 int error = -EINVAL;
1887
1888 if (!pdev->dev.of_node)
1889 return error;
1890
1891 if (of_device_is_compatible(pdev->dev.of_node, "ti,dm816-emac"))
1892 error = cpsw_am33xx_cm_get_macid(&pdev->dev, 0x30,
1893 instance,
1894 mac_addr);
1895
1896 return error;
1897}
1898
1882/** 1899/**
1883 * davinci_emac_probe - EMAC device probe 1900 * davinci_emac_probe - EMAC device probe
1884 * @pdev: The DaVinci EMAC device that we are removing 1901 * @pdev: The DaVinci EMAC device that we are removing
@@ -2009,6 +2026,10 @@ static int davinci_emac_probe(struct platform_device *pdev)
2009 } 2026 }
2010 ndev->irq = res->start; 2027 ndev->irq = res->start;
2011 2028
2029 rc = davinci_emac_try_get_mac(pdev, res_ctrl ? 0 : 1, priv->mac_addr);
2030 if (!rc)
2031 ether_addr_copy(ndev->dev_addr, priv->mac_addr);
2032
2012 if (!is_valid_ether_addr(priv->mac_addr)) { 2033 if (!is_valid_ether_addr(priv->mac_addr)) {
2013 /* Use random MAC if none passed */ 2034 /* Use random MAC if none passed */
2014 eth_hw_addr_random(ndev); 2035 eth_hw_addr_random(ndev);