70b50750a06bb839a540b8d35b48a7e3eb661a2b
[openwrt/openwrt.git] / target / linux / sunxi / patches-3.13 / 192-stmmac-use-platform-data-with-compat.patch
1 From 34722924d416c3521de2bc8d10dfcd07a55135ea Mon Sep 17 00:00:00 2001
2 From: Chen-Yu Tsai <wens@csie.org>
3 Date: Sat, 7 Dec 2013 01:29:36 +0800
4 Subject: [PATCH] net: stmmac: Use platform data tied with compatible strings
5
6 Signed-off-by: Chen-Yu Tsai <wens@csie.org>
7 ---
8 .../net/ethernet/stmicro/stmmac/stmmac_platform.c | 29 ++++++++++++++--------
9 1 file changed, 19 insertions(+), 10 deletions(-)
10
11 diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c
12 index 74c7aef..df3fd1c 100644
13 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c
14 +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c
15 @@ -26,8 +26,19 @@
16 #include <linux/io.h>
17 #include <linux/of.h>
18 #include <linux/of_net.h>
19 +#include <linux/of_device.h>
20 #include "stmmac.h"
21
22 +static const struct of_device_id stmmac_dt_ids[] = {
23 + { .compatible = "st,spear600-gmac"},
24 + { .compatible = "snps,dwmac-3.610"},
25 + { .compatible = "snps,dwmac-3.70a"},
26 + { .compatible = "snps,dwmac-3.710"},
27 + { .compatible = "snps,dwmac"},
28 + { /* sentinel */ }
29 +};
30 +MODULE_DEVICE_TABLE(of, stmmac_dt_ids);
31 +
32 #ifdef CONFIG_OF
33 static int stmmac_probe_config_dt(struct platform_device *pdev,
34 struct plat_stmmacenet_data *plat,
35 @@ -35,10 +46,18 @@ static int stmmac_probe_config_dt(struct platform_device *pdev,
36 {
37 struct device_node *np = pdev->dev.of_node;
38 struct stmmac_dma_cfg *dma_cfg;
39 + const struct of_device_id *device;
40
41 if (!np)
42 return -ENODEV;
43
44 + device = of_match_device(stmmac_dt_ids, &pdev->dev);
45 + if (!device)
46 + return -ENODEV;
47 +
48 + if (device->data)
49 + memcpy(plat, device->data, sizeof(*plat));
50 +
51 *mac = of_get_mac_address(np);
52 plat->interface = of_get_phy_mode(np);
53
54 @@ -257,16 +276,6 @@ int stmmac_pltfr_restore(struct device *dev)
55 static const struct dev_pm_ops stmmac_pltfr_pm_ops;
56 #endif /* CONFIG_PM */
57
58 -static const struct of_device_id stmmac_dt_ids[] = {
59 - { .compatible = "st,spear600-gmac"},
60 - { .compatible = "snps,dwmac-3.610"},
61 - { .compatible = "snps,dwmac-3.70a"},
62 - { .compatible = "snps,dwmac-3.710"},
63 - { .compatible = "snps,dwmac"},
64 - { /* sentinel */ }
65 -};
66 -MODULE_DEVICE_TABLE(of, stmmac_dt_ids);
67 -
68 struct platform_driver stmmac_pltfr_driver = {
69 .probe = stmmac_pltfr_probe,
70 .remove = stmmac_pltfr_remove,
71 --
72 1.8.5.1
73