[PATCH V5 4/4] net/fec: add device tree matching support

Jason Liu jason.hui at linaro.org
Thu Mar 17 02:51:41 EST 2011


Signed-off-by: Jason Liu <jason.hui at linaro.org>
---
 .../devicetree/bindings/net/fsl-imx-fec.txt        |   17 +++++++++++++++++
 drivers/net/fec.c                                  |   17 +++++++++++++++++
 2 files changed, 34 insertions(+), 0 deletions(-)

diff --git a/Documentation/devicetree/bindings/net/fsl-imx-fec.txt b/Documentation/devicetree/bindings/net/fsl-imx-fec.txt
new file mode 100644
index 0000000..cff97cf
--- /dev/null
+++ b/Documentation/devicetree/bindings/net/fsl-imx-fec.txt
@@ -0,0 +1,17 @@
+* FEC (Fast Ethernet Controller)
+
+Required properties:
+- compatible : "fsl,imx51-fec".
+- reg : Offset and length of the register set for the device.
+- interrupts : should contain uart interrupt.
+- fec_clk-clock : the fec clock input information.
+
+Example:
+
+fec at ec000 {
+	compatible = "fsl,imx51-fec";
+	reg = <0xec000 0x1000>;
+	interrupts = <0x57>;
+	fec_clk-clock = <&fec_clk>, "fec";
+} ;
+
diff --git a/drivers/net/fec.c b/drivers/net/fec.c
index 2a71373..b6b7446 100644
--- a/drivers/net/fec.c
+++ b/drivers/net/fec.c
@@ -44,6 +44,8 @@
 #include <linux/platform_device.h>
 #include <linux/phy.h>
 #include <linux/fec.h>
+#include <linux/of.h>
+#include <linux/of_device.h>
 
 #include <asm/cacheflush.h>
 
@@ -77,6 +79,13 @@ static struct platform_device_id fec_devtype[] = {
 	}
 };
 
+#ifdef CONFIG_OF
+static const struct of_device_id fec_dt_ids[] = {
+	{ .compatible = "fsl,imx51-fec", .data = &fec_devtype[0], },
+	{},
+};
+#endif
+
 static unsigned char macaddr[ETH_ALEN];
 module_param_array(macaddr, byte, NULL, 0);
 MODULE_PARM_DESC(macaddr, "FEC Ethernet MAC address");
@@ -1366,6 +1375,11 @@ fec_probe(struct platform_device *pdev)
 	struct net_device *ndev;
 	int i, irq, ret = 0;
 	struct resource *r;
+	const struct of_device_id *of_id;
+
+	of_id = of_match_device(fec_dt_ids, &pdev->dev);
+	if (of_id)
+		pdev->id_entry = (struct platform_device_id *)of_id->data;
 
 	r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
 	if (!r)
@@ -1530,6 +1544,9 @@ static struct platform_driver fec_driver = {
 #ifdef CONFIG_PM
 		.pm	= &fec_pm_ops,
 #endif
+#ifdef CONFIG_OF
+		.of_match_table = fec_dt_ids,
+#endif
 	},
 	.id_table = fec_devtype,
 	.probe	= fec_probe,
-- 
1.7.1



More information about the devicetree-discuss mailing list