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: 2041 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id 3D81223F45 for ; Sat, 18 Jun 2011 15:10:40 +0000 (UTC) Received: from mail-vx0-f180.google.com (mail-vx0-f180.google.com [209.85.220.180]) by fiordland.canonical.com (Postfix) with ESMTP id 0CA5FA185F4 for ; Sat, 18 Jun 2011 15:10:39 +0000 (UTC) Received: by vxd7 with SMTP id 7so1269245vxd.11 for ; Sat, 18 Jun 2011 08:10:39 -0700 (PDT) Received: by 10.52.175.197 with SMTP id cc5mr932341vdc.287.1308409830776; Sat, 18 Jun 2011 08:10:30 -0700 (PDT) X-Forwarded-To: linaro-patchwork@canonical.com X-Forwarded-For: patch@linaro.org linaro-patchwork@canonical.com Delivered-To: patches@linaro.org Received: by 10.52.183.130 with SMTP id em2cs26182vdc; Sat, 18 Jun 2011 08:10:30 -0700 (PDT) Received: by 10.42.138.7 with SMTP id a7mr3840812icu.299.1308409830156; Sat, 18 Jun 2011 08:10:30 -0700 (PDT) Received: from mail-iy0-f178.google.com (mail-iy0-f178.google.com [209.85.210.178]) by mx.google.com with ESMTPS id v5si4556843icj.154.2011.06.18.08.10.29 (version=TLSv1/SSLv3 cipher=OTHER); Sat, 18 Jun 2011 08:10:30 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.210.178 is neither permitted nor denied by best guess record for domain of shawn.guo@linaro.org) client-ip=209.85.210.178; Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.210.178 is neither permitted nor denied by best guess record for domain of shawn.guo@linaro.org) smtp.mail=shawn.guo@linaro.org Received: by mail-iy0-f178.google.com with SMTP id 26so2381474iyb.37 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 Cc: linux-kernel@vger.kernel.org, netdev@vger.kernel.org, devicetree-discuss@lists.ozlabs.org, patches@linaro.org, Shawn Guo , Jason Liu , "David S. Miller" 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> 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,