aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Documentation/devicetree/bindings/net/davinci_emac.txt41
-rw-r--r--drivers/net/ethernet/ti/davinci_emac.c89
2 files changed, 129 insertions, 1 deletions
diff --git a/Documentation/devicetree/bindings/net/davinci_emac.txt b/Documentation/devicetree/bindings/net/davinci_emac.txt
new file mode 100644
index 000000000000..48b259e29e87
--- /dev/null
+++ b/Documentation/devicetree/bindings/net/davinci_emac.txt
@@ -0,0 +1,41 @@
1* Texas Instruments Davinci EMAC
2
3This file provides information, what the device node
4for the davinci_emac interface contains.
5
6Required properties:
7- compatible: "ti,davinci-dm6467-emac";
8- reg: Offset and length of the register set for the device
9- ti,davinci-ctrl-reg-offset: offset to control register
10- ti,davinci-ctrl-mod-reg-offset: offset to control module register
11- ti,davinci-ctrl-ram-offset: offset to control module ram
12- ti,davinci-ctrl-ram-size: size of control module ram
13- ti,davinci-rmii-en: use RMII
14- ti,davinci-no-bd-ram: has the emac controller BD RAM
15- phy-handle: Contains a phandle to an Ethernet PHY.
16 if not, davinci_emac driver defaults to 100/FULL
17- interrupts: interrupt mapping for the davinci emac interrupts sources:
18 4 sources: <Receive Threshold Interrupt
19 Receive Interrupt
20 Transmit Interrupt
21 Miscellaneous Interrupt>
22
23Optional properties:
24- local-mac-address : 6 bytes, mac address
25
26Example (enbw_cmc board):
27 eth0: emac@1e20000 {
28 compatible = "ti,davinci-dm6467-emac";
29 reg = <0x220000 0x4000>;
30 ti,davinci-ctrl-reg-offset = <0x3000>;
31 ti,davinci-ctrl-mod-reg-offset = <0x2000>;
32 ti,davinci-ctrl-ram-offset = <0>;
33 ti,davinci-ctrl-ram-size = <0x2000>;
34 local-mac-address = [ 00 00 00 00 00 00 ];
35 interrupts = <33
36 34
37 35
38 36
39 >;
40 interrupt-parent = <&intc>;
41 };
diff --git a/drivers/net/ethernet/ti/davinci_emac.c b/drivers/net/ethernet/ti/davinci_emac.c
index ab0bbb78699a..b298ab071e3d 100644
--- a/drivers/net/ethernet/ti/davinci_emac.c
+++ b/drivers/net/ethernet/ti/davinci_emac.c
@@ -58,6 +58,12 @@
58#include <linux/io.h> 58#include <linux/io.h>
59#include <linux/uaccess.h> 59#include <linux/uaccess.h>
60#include <linux/davinci_emac.h> 60#include <linux/davinci_emac.h>
61#include <linux/of.h>
62#include <linux/of_address.h>
63#include <linux/of_irq.h>
64#include <linux/of_net.h>
65
66#include <mach/mux.h>
61 67
62#include <asm/irq.h> 68#include <asm/irq.h>
63#include <asm/page.h> 69#include <asm/page.h>
@@ -339,6 +345,9 @@ struct emac_priv {
339 u32 rx_addr_type; 345 u32 rx_addr_type;
340 atomic_t cur_tx; 346 atomic_t cur_tx;
341 const char *phy_id; 347 const char *phy_id;
348#ifdef CONFIG_OF
349 struct device_node *phy_node;
350#endif
342 struct phy_device *phydev; 351 struct phy_device *phydev;
343 spinlock_t lock; 352 spinlock_t lock;
344 /*platform specific members*/ 353 /*platform specific members*/
@@ -1760,6 +1769,77 @@ static const struct net_device_ops emac_netdev_ops = {
1760#endif 1769#endif
1761}; 1770};
1762 1771
1772#ifdef CONFIG_OF
1773static struct emac_platform_data
1774 *davinci_emac_of_get_pdata(struct platform_device *pdev,
1775 struct emac_priv *priv)
1776{
1777 struct device_node *np;
1778 struct emac_platform_data *pdata = NULL;
1779 const u8 *mac_addr;
1780 u32 data;
1781 int ret;
1782
1783 pdata = pdev->dev.platform_data;
1784 if (!pdata) {
1785 pdata = devm_kzalloc(&pdev->dev, sizeof(*pdata), GFP_KERNEL);
1786 if (!pdata)
1787 goto nodata;
1788 }
1789
1790 np = pdev->dev.of_node;
1791 if (!np)
1792 goto nodata;
1793 else
1794 pdata->version = EMAC_VERSION_2;
1795
1796 if (!is_valid_ether_addr(pdata->mac_addr)) {
1797 mac_addr = of_get_mac_address(np);
1798 if (mac_addr)
1799 memcpy(pdata->mac_addr, mac_addr, ETH_ALEN);
1800 }
1801
1802 ret = of_property_read_u32(np, "ti,davinci-ctrl-reg-offset", &data);
1803 if (!ret)
1804 pdata->ctrl_reg_offset = data;
1805
1806 ret = of_property_read_u32(np, "ti,davinci-ctrl-mod-reg-offset",
1807 &data);
1808 if (!ret)
1809 pdata->ctrl_mod_reg_offset = data;
1810
1811 ret = of_property_read_u32(np, "ti,davinci-ctrl-ram-offset", &data);
1812 if (!ret)
1813 pdata->ctrl_ram_offset = data;
1814
1815 ret = of_property_read_u32(np, "ti,davinci-ctrl-ram-size", &data);
1816 if (!ret)
1817 pdata->ctrl_ram_size = data;
1818
1819 ret = of_property_read_u32(np, "ti,davinci-rmii-en", &data);
1820 if (!ret)
1821 pdata->rmii_en = data;
1822
1823 ret = of_property_read_u32(np, "ti,davinci-no-bd-ram", &data);
1824 if (!ret)
1825 pdata->no_bd_ram = data;
1826
1827 priv->phy_node = of_parse_phandle(np, "phy-handle", 0);
1828 if (!priv->phy_node)
1829 pdata->phy_id = "";
1830
1831 pdev->dev.platform_data = pdata;
1832nodata:
1833 return pdata;
1834}
1835#else
1836static struct emac_platform_data
1837 *davinci_emac_of_get_pdata(struct platform_device *pdev,
1838 struct emac_priv *priv)
1839{
1840 return pdev->dev.platform_data;
1841}
1842#endif
1763/** 1843/**
1764 * davinci_emac_probe - EMAC device probe 1844 * davinci_emac_probe - EMAC device probe
1765 * @pdev: The DaVinci EMAC device that we are removing 1845 * @pdev: The DaVinci EMAC device that we are removing
@@ -1802,7 +1882,7 @@ static int __devinit davinci_emac_probe(struct platform_device *pdev)
1802 1882
1803 spin_lock_init(&priv->lock); 1883 spin_lock_init(&priv->lock);
1804 1884
1805 pdata = pdev->dev.platform_data; 1885 pdata = davinci_emac_of_get_pdata(pdev, priv);
1806 if (!pdata) { 1886 if (!pdata) {
1807 dev_err(&pdev->dev, "no platform data\n"); 1887 dev_err(&pdev->dev, "no platform data\n");
1808 rc = -ENODEV; 1888 rc = -ENODEV;
@@ -2013,12 +2093,19 @@ static const struct dev_pm_ops davinci_emac_pm_ops = {
2013 .resume = davinci_emac_resume, 2093 .resume = davinci_emac_resume,
2014}; 2094};
2015 2095
2096static const struct of_device_id davinci_emac_of_match[] = {
2097 {.compatible = "ti,davinci-dm6467-emac", },
2098 {},
2099};
2100MODULE_DEVICE_TABLE(of, davinci_emac_of_match);
2101
2016/* davinci_emac_driver: EMAC platform driver structure */ 2102/* davinci_emac_driver: EMAC platform driver structure */
2017static struct platform_driver davinci_emac_driver = { 2103static struct platform_driver davinci_emac_driver = {
2018 .driver = { 2104 .driver = {
2019 .name = "davinci_emac", 2105 .name = "davinci_emac",
2020 .owner = THIS_MODULE, 2106 .owner = THIS_MODULE,
2021 .pm = &davinci_emac_pm_ops, 2107 .pm = &davinci_emac_pm_ops,
2108 .of_match_table = of_match_ptr(davinci_emac_of_match),
2022 }, 2109 },
2023 .probe = davinci_emac_probe, 2110 .probe = davinci_emac_probe,
2024 .remove = __devexit_p(davinci_emac_remove), 2111 .remove = __devexit_p(davinci_emac_remove),