From patchwork Sat Jun 18 15:19:13 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shawn Guo X-Patchwork-Id: 893162 Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) by demeter2.kernel.org (8.14.4/8.14.4) with ESMTP id p5IFAvsg024688 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Sat, 18 Jun 2011 15:11:18 GMT Received: from canuck.infradead.org ([2001:4978:20e::1]) by merlin.infradead.org with esmtps (Exim 4.76 #1 (Red Hat Linux)) id 1QXxAY-0005RA-Vx; Sat, 18 Jun 2011 15:10:43 +0000 Received: from localhost ([127.0.0.1] helo=canuck.infradead.org) by canuck.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1QXxAY-00065f-5F; Sat, 18 Jun 2011 15:10:42 +0000 Received: from mail-iy0-f177.google.com ([209.85.210.177]) by canuck.infradead.org with esmtps (Exim 4.76 #1 (Red Hat Linux)) id 1QXxAM-0005yd-3b for linux-arm-kernel@lists.infradead.org; Sat, 18 Jun 2011 15:10:31 +0000 Received: by mail-iy0-f177.google.com with SMTP id 15so115371iyn.36 for ; Sat, 18 Jun 2011 08:10:29 -0700 (PDT) Received: by 10.42.197.3 with SMTP id ei3mr3532272icb.78.1308409829517; Sat, 18 Jun 2011 08:10:29 -0700 (PDT) Received: from localhost.localdomain ([114.216.149.215]) by mx.google.com with ESMTPS id s2sm3709438icw.5.2011.06.18.08.10.09 (version=TLSv1/SSLv3 cipher=OTHER); Sat, 18 Jun 2011 08:10:28 -0700 (PDT) From: Shawn Guo To: linux-arm-kernel@lists.infradead.org Subject: [PATCH 2/3] net/fec: add device tree support Date: Sat, 18 Jun 2011 23:19:13 +0800 Message-Id: <1308410354-21387-3-git-send-email-shawn.guo@linaro.org> X-Mailer: git-send-email 1.7.4.1 In-Reply-To: <1308410354-21387-1-git-send-email-shawn.guo@linaro.org> References: <1308410354-21387-1-git-send-email-shawn.guo@linaro.org> X-CRM114-Version: 20090807-BlameThorstenAndJenny ( TRE 0.7.6 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20110618_111030_359482_C813B7DC X-CRM114-Status: GOOD ( 15.43 ) X-Spam-Score: -0.7 (/) X-Spam-Report: SpamAssassin version 3.3.1 on canuck.infradead.org summary: Content analysis details: (-0.7 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [209.85.210.177 listed in list.dnswl.org] Cc: patches@linaro.org, netdev@vger.kernel.org, devicetree-discuss@lists.ozlabs.org, Jason Liu , linux-kernel@vger.kernel.org, Shawn Guo , "David S. Miller" X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: linux-arm-kernel-bounces@lists.infradead.org Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter2.kernel.org [140.211.167.43]); Sat, 18 Jun 2011 15:11:18 +0000 (UTC) It adds device tree data parsing support for fec driver. Signed-off-by: Jason Liu Signed-off-by: Shawn Guo Cc: David S. Miller Acked-by: Grant Likely --- Documentation/devicetree/bindings/net/fsl-fec.txt | 14 ++++++++++ drivers/net/fec.c | 28 +++++++++++++++++++++ 2 files changed, 42 insertions(+), 0 deletions(-) create mode 100644 Documentation/devicetree/bindings/net/fsl-fec.txt diff --git a/Documentation/devicetree/bindings/net/fsl-fec.txt b/Documentation/devicetree/bindings/net/fsl-fec.txt new file mode 100644 index 0000000..705111d --- /dev/null +++ b/Documentation/devicetree/bindings/net/fsl-fec.txt @@ -0,0 +1,14 @@ +* Freescale Fast Ethernet Controller (FEC) + +Required properties: +- compatible : should be "fsl,-fec", "fsl,fec" +- reg : address and length of the register set for the device +- interrupts : should contain fec interrupt + +Example: + +fec@83fec000 { + compatible = "fsl,imx51-fec", "fsl,fec"; + reg = <0x83fec000 0x4000>; + interrupts = <87>; +}; diff --git a/drivers/net/fec.c b/drivers/net/fec.c index 885d8ba..ef3d175 100644 --- a/drivers/net/fec.c +++ b/drivers/net/fec.c @@ -44,6 +44,8 @@ #include #include #include +#include +#include #include @@ -78,6 +80,26 @@ static struct platform_device_id fec_devtype[] = { { } }; +#ifdef CONFIG_OF +static const struct of_device_id fec_dt_ids[] = { + { .compatible = "fsl,fec", .data = &fec_devtype[0], }, + {}, +}; + +static const struct of_device_id * +fec_get_of_device_id(struct platform_device *pdev) +{ + return of_match_device(fec_dt_ids, &pdev->dev); +} +#else +#define fec_dt_ids NULL +static inline struct of_device_id * +fec_get_of_device_id(struct platform_device *pdev) +{ + return NULL; +} +#endif + static unsigned char macaddr[ETH_ALEN]; module_param_array(macaddr, byte, NULL, 0); MODULE_PARM_DESC(macaddr, "FEC Ethernet MAC address"); @@ -1363,6 +1385,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 = fec_get_of_device_id(pdev); + if (of_id) + pdev->id_entry = (struct platform_device_id *) of_id->data; r = platform_get_resource(pdev, IORESOURCE_MEM, 0); if (!r) @@ -1531,6 +1558,7 @@ static struct platform_driver fec_driver = { #ifdef CONFIG_PM .pm = &fec_pm_ops, #endif + .of_match_table = fec_dt_ids, }, .id_table = fec_devtype, .probe = fec_probe,