1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * emac_arc.c - ARC EMAC specific glue layer
5 * Copyright (C) 2014 Romain Perier
7 * Romain Perier <romain.perier@gmail.com>
10 #include <linux/etherdevice.h>
11 #include <linux/module.h>
12 #include <linux/of_net.h>
13 #include <linux/platform_device.h>
17 #define DRV_NAME "emac_arc"
18 #define DRV_VERSION "1.0"
20 static int emac_arc_probe(struct platform_device
*pdev
)
22 struct device
*dev
= &pdev
->dev
;
23 struct net_device
*ndev
;
24 struct arc_emac_priv
*priv
;
30 ndev
= alloc_etherdev(sizeof(struct arc_emac_priv
));
33 platform_set_drvdata(pdev
, ndev
);
34 SET_NETDEV_DEV(ndev
, dev
);
36 priv
= netdev_priv(ndev
);
37 priv
->drv_name
= DRV_NAME
;
38 priv
->drv_version
= DRV_VERSION
;
40 interface
= of_get_phy_mode(dev
->of_node
);
42 interface
= PHY_INTERFACE_MODE_MII
;
44 priv
->clk
= devm_clk_get(dev
, "hclk");
45 if (IS_ERR(priv
->clk
)) {
46 dev_err(dev
, "failed to retrieve host clock from device tree\n");
51 err
= arc_emac_probe(ndev
, interface
);
58 static int emac_arc_remove(struct platform_device
*pdev
)
60 struct net_device
*ndev
= platform_get_drvdata(pdev
);
63 err
= arc_emac_remove(ndev
);
68 static const struct of_device_id emac_arc_dt_ids
[] = {
69 { .compatible
= "snps,arc-emac" },
72 MODULE_DEVICE_TABLE(of
, emac_arc_dt_ids
);
74 static struct platform_driver emac_arc_driver
= {
75 .probe
= emac_arc_probe
,
76 .remove
= emac_arc_remove
,
79 .of_match_table
= emac_arc_dt_ids
,
83 module_platform_driver(emac_arc_driver
);
85 MODULE_AUTHOR("Romain Perier <romain.perier@gmail.com>");
86 MODULE_DESCRIPTION("ARC EMAC platform driver");
87 MODULE_LICENSE("GPL");