diff options
author | Tony Lindgren <tony@atomide.com> | 2015-01-28 14:33:06 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2015-01-30 20:42:01 -0500 |
commit | f276c0ce5d9256bb87e65f88ddea28a6a5eafdb2 (patch) | |
tree | a474f07c34c34cfa63a1b18ab83bd03a57ab3239 /drivers/net/ethernet/ti | |
parent | 9120bd6e9f779d921450ec53cea02eff07003eae (diff) |
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: Tony Lindgren <tony@atomide.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/ethernet/ti')
-rw-r--r-- | drivers/net/ethernet/ti/davinci_emac.c | 35 |
1 files changed, 34 insertions, 1 deletions
diff --git a/drivers/net/ethernet/ti/davinci_emac.c b/drivers/net/ethernet/ti/davinci_emac.c index a7169384ff6e..aeebc0a7bf47 100644 --- a/drivers/net/ethernet/ti/davinci_emac.c +++ b/drivers/net/ethernet/ti/davinci_emac.c | |||
@@ -52,6 +52,7 @@ | |||
52 | #include <linux/dma-mapping.h> | 52 | #include <linux/dma-mapping.h> |
53 | #include <linux/clk.h> | 53 | #include <linux/clk.h> |
54 | #include <linux/platform_device.h> | 54 | #include <linux/platform_device.h> |
55 | #include <linux/regmap.h> | ||
55 | #include <linux/semaphore.h> | 56 | #include <linux/semaphore.h> |
56 | #include <linux/phy.h> | 57 | #include <linux/phy.h> |
57 | #include <linux/bitops.h> | 58 | #include <linux/bitops.h> |
@@ -65,6 +66,7 @@ | |||
65 | #include <linux/of_mdio.h> | 66 | #include <linux/of_mdio.h> |
66 | #include <linux/of_irq.h> | 67 | #include <linux/of_irq.h> |
67 | #include <linux/of_net.h> | 68 | #include <linux/of_net.h> |
69 | #include <linux/mfd/syscon.h> | ||
68 | 70 | ||
69 | #include <asm/irq.h> | 71 | #include <asm/irq.h> |
70 | #include <asm/page.h> | 72 | #include <asm/page.h> |
@@ -1880,6 +1882,33 @@ davinci_emac_of_get_pdata(struct platform_device *pdev, struct emac_priv *priv) | |||
1880 | return pdata; | 1882 | return pdata; |
1881 | } | 1883 | } |
1882 | 1884 | ||
1885 | static int davinci_emac_3517_get_macid(struct device *dev, u16 offset, | ||
1886 | int slave, u8 *mac_addr) | ||
1887 | { | ||
1888 | u32 macid_lsb; | ||
1889 | u32 macid_msb; | ||
1890 | struct regmap *syscon; | ||
1891 | |||
1892 | syscon = syscon_regmap_lookup_by_phandle(dev->of_node, "syscon"); | ||
1893 | if (IS_ERR(syscon)) { | ||
1894 | if (PTR_ERR(syscon) == -ENODEV) | ||
1895 | return 0; | ||
1896 | return PTR_ERR(syscon); | ||
1897 | } | ||
1898 | |||
1899 | regmap_read(syscon, offset, &macid_lsb); | ||
1900 | regmap_read(syscon, offset + 4, &macid_msb); | ||
1901 | |||
1902 | mac_addr[0] = (macid_msb >> 16) & 0xff; | ||
1903 | mac_addr[1] = (macid_msb >> 8) & 0xff; | ||
1904 | mac_addr[2] = macid_msb & 0xff; | ||
1905 | mac_addr[3] = (macid_lsb >> 16) & 0xff; | ||
1906 | mac_addr[4] = (macid_lsb >> 8) & 0xff; | ||
1907 | mac_addr[5] = macid_lsb & 0xff; | ||
1908 | |||
1909 | return 0; | ||
1910 | } | ||
1911 | |||
1883 | static int davinci_emac_try_get_mac(struct platform_device *pdev, | 1912 | static int davinci_emac_try_get_mac(struct platform_device *pdev, |
1884 | int instance, u8 *mac_addr) | 1913 | int instance, u8 *mac_addr) |
1885 | { | 1914 | { |
@@ -1888,7 +1917,11 @@ static int davinci_emac_try_get_mac(struct platform_device *pdev, | |||
1888 | if (!pdev->dev.of_node) | 1917 | if (!pdev->dev.of_node) |
1889 | return error; | 1918 | return error; |
1890 | 1919 | ||
1891 | if (of_device_is_compatible(pdev->dev.of_node, "ti,dm816-emac")) | 1920 | if (of_device_is_compatible(pdev->dev.of_node, "ti,am3517-emac")) |
1921 | error = davinci_emac_3517_get_macid(&pdev->dev, 0x110, | ||
1922 | 0, mac_addr); | ||
1923 | else if (of_device_is_compatible(pdev->dev.of_node, | ||
1924 | "ti,dm816-emac")) | ||
1892 | error = cpsw_am33xx_cm_get_macid(&pdev->dev, 0x30, | 1925 | error = cpsw_am33xx_cm_get_macid(&pdev->dev, 0x30, |
1893 | instance, | 1926 | instance, |
1894 | mac_addr); | 1927 | mac_addr); |