From patchwork Wed Mar 16 15:51:41 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Hui X-Patchwork-Id: 639 Return-Path: Delivered-To: unknown Received: from imap.gmail.com (74.125.159.109) by localhost6.localdomain6 with IMAP4-SSL; 08 Jun 2011 14:44:18 -0000 Delivered-To: patches@linaro.org Received: by 10.151.46.5 with SMTP id y5cs12096ybj; Wed, 16 Mar 2011 08:52:35 -0700 (PDT) Received: by 10.150.148.21 with SMTP id v21mr227897ybd.354.1300290755225; Wed, 16 Mar 2011 08:52:35 -0700 (PDT) Received: from mail-pv0-f178.google.com (mail-pv0-f178.google.com [74.125.83.178]) by mx.google.com with ESMTPS id p18si12831017ybk.103.2011.03.16.08.52.34 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 16 Mar 2011 08:52:35 -0700 (PDT) Received-SPF: neutral (google.com: 74.125.83.178 is neither permitted nor denied by best guess record for domain of jason.hui@linaro.org) client-ip=74.125.83.178; Authentication-Results: mx.google.com; spf=neutral (google.com: 74.125.83.178 is neither permitted nor denied by best guess record for domain of jason.hui@linaro.org) smtp.mail=jason.hui@linaro.org Received: by mail-pv0-f178.google.com with SMTP id 7so400776pvg.37 for ; Wed, 16 Mar 2011 08:52:34 -0700 (PDT) Received: by 10.143.86.8 with SMTP id o8mr72837wfl.360.1300290754645; Wed, 16 Mar 2011 08:52:34 -0700 (PDT) Received: from localhost.localdomain ([116.231.118.83]) by mx.google.com with ESMTPS id d35sm1312535wfj.9.2011.03.16.08.52.30 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 16 Mar 2011 08:52:34 -0700 (PDT) From: Jason Liu To: devicetree-discuss@lists.ozlabs.org Cc: linaro-dev@lists.linaro.org, patches@linaro.org, grant.likely@linaro.org Subject: [PATCH V5 4/4] net/fec: add device tree matching support Date: Wed, 16 Mar 2011 23:51:41 +0800 Message-Id: <1300290701-9433-5-git-send-email-jason.hui@linaro.org> X-Mailer: git-send-email 1.7.0.4 In-Reply-To: <1300290701-9433-1-git-send-email-jason.hui@linaro.org> References: <1300290701-9433-1-git-send-email-jason.hui@linaro.org> Signed-off-by: Jason Liu --- .../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@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 #include #include +#include +#include #include @@ -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,