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

net: davinci_emac: Get device MAC on 3517

Looks like on 3517 davinci_emac MAC address registers have a
different layout compared to dm816x and am33xx.

Let's add a function to get the 3517 MAC address.
Signed-off-by: default avatarTony Lindgren <tony@atomide.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 9120bd6e
...@@ -31,6 +31,7 @@ davinci_emac: ethernet@0x5c000000 { ...@@ -31,6 +31,7 @@ davinci_emac: ethernet@0x5c000000 {
status = "disabled"; status = "disabled";
reg = <0x5c000000 0x30000>; reg = <0x5c000000 0x30000>;
interrupts = <67 68 69 70>; interrupts = <67 68 69 70>;
syscon = <&omap3_scm_general>;
ti,davinci-ctrl-reg-offset = <0x10000>; ti,davinci-ctrl-reg-offset = <0x10000>;
ti,davinci-ctrl-mod-reg-offset = <0>; ti,davinci-ctrl-mod-reg-offset = <0>;
ti,davinci-ctrl-ram-offset = <0x20000>; ti,davinci-ctrl-ram-offset = <0x20000>;
......
...@@ -52,6 +52,7 @@ ...@@ -52,6 +52,7 @@
#include <linux/dma-mapping.h> #include <linux/dma-mapping.h>
#include <linux/clk.h> #include <linux/clk.h>
#include <linux/platform_device.h> #include <linux/platform_device.h>
#include <linux/regmap.h>
#include <linux/semaphore.h> #include <linux/semaphore.h>
#include <linux/phy.h> #include <linux/phy.h>
#include <linux/bitops.h> #include <linux/bitops.h>
...@@ -65,6 +66,7 @@ ...@@ -65,6 +66,7 @@
#include <linux/of_mdio.h> #include <linux/of_mdio.h>
#include <linux/of_irq.h> #include <linux/of_irq.h>
#include <linux/of_net.h> #include <linux/of_net.h>
#include <linux/mfd/syscon.h>
#include <asm/irq.h> #include <asm/irq.h>
#include <asm/page.h> #include <asm/page.h>
...@@ -1880,6 +1882,33 @@ davinci_emac_of_get_pdata(struct platform_device *pdev, struct emac_priv *priv) ...@@ -1880,6 +1882,33 @@ davinci_emac_of_get_pdata(struct platform_device *pdev, struct emac_priv *priv)
return pdata; return pdata;
} }
static int davinci_emac_3517_get_macid(struct device *dev, u16 offset,
int slave, u8 *mac_addr)
{
u32 macid_lsb;
u32 macid_msb;
struct regmap *syscon;
syscon = syscon_regmap_lookup_by_phandle(dev->of_node, "syscon");
if (IS_ERR(syscon)) {
if (PTR_ERR(syscon) == -ENODEV)
return 0;
return PTR_ERR(syscon);
}
regmap_read(syscon, offset, &macid_lsb);
regmap_read(syscon, offset + 4, &macid_msb);
mac_addr[0] = (macid_msb >> 16) & 0xff;
mac_addr[1] = (macid_msb >> 8) & 0xff;
mac_addr[2] = macid_msb & 0xff;
mac_addr[3] = (macid_lsb >> 16) & 0xff;
mac_addr[4] = (macid_lsb >> 8) & 0xff;
mac_addr[5] = macid_lsb & 0xff;
return 0;
}
static int davinci_emac_try_get_mac(struct platform_device *pdev, static int davinci_emac_try_get_mac(struct platform_device *pdev,
int instance, u8 *mac_addr) int instance, u8 *mac_addr)
{ {
...@@ -1888,7 +1917,11 @@ static int davinci_emac_try_get_mac(struct platform_device *pdev, ...@@ -1888,7 +1917,11 @@ static int davinci_emac_try_get_mac(struct platform_device *pdev,
if (!pdev->dev.of_node) if (!pdev->dev.of_node)
return error; return error;
if (of_device_is_compatible(pdev->dev.of_node, "ti,dm816-emac")) if (of_device_is_compatible(pdev->dev.of_node, "ti,am3517-emac"))
error = davinci_emac_3517_get_macid(&pdev->dev, 0x110,
0, mac_addr);
else if (of_device_is_compatible(pdev->dev.of_node,
"ti,dm816-emac"))
error = cpsw_am33xx_cm_get_macid(&pdev->dev, 0x30, error = cpsw_am33xx_cm_get_macid(&pdev->dev, 0x30,
instance, instance,
mac_addr); mac_addr);
......
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