From patchwork Mon Jan 31 16:28:14 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: thomas.abraham@linaro.org X-Patchwork-Id: 43 Return-Path: Delivered-To: unknown Received: from imap.gmail.com (74.125.159.109) by localhost6.localdomain6 with IMAP4-SSL; 08 Jun 2011 14:39:26 -0000 Delivered-To: patches@linaro.org Received: by 10.147.124.5 with SMTP id b5cs87873yan; Mon, 31 Jan 2011 08:29:09 -0800 (PST) Received: by 10.213.14.136 with SMTP id g8mr8652313eba.97.1296491348519; Mon, 31 Jan 2011 08:29:08 -0800 (PST) Received: from mailout3.samsung.com (mailout3.samsung.com [203.254.224.33]) by mx.google.com with ESMTP id p50si48406999eei.17.2011.01.31.08.29.07; Mon, 31 Jan 2011 08:29:08 -0800 (PST) Received-SPF: neutral (google.com: 203.254.224.33 is neither permitted nor denied by best guess record for domain of thomas.abraham@linaro.org) client-ip=203.254.224.33; Authentication-Results: mx.google.com; spf=neutral (google.com: 203.254.224.33 is neither permitted nor denied by best guess record for domain of thomas.abraham@linaro.org) smtp.mail=thomas.abraham@linaro.org Received: from epmmp2 (mailout3.samsung.com [203.254.224.33]) by mailout3.samsung.com (Oracle Communications Messaging Exchange Server 7u4-19.01 64bit (built Sep 7 2010)) with ESMTP id <0LFW0091IB4IOK00@mailout3.samsung.com> for patches@linaro.org; Tue, 01 Feb 2011 01:29:06 +0900 (KST) Received: from localhost.localdomain ([107.108.73.37]) by mmp2.samsung.com (iPlanet Messaging Server 5.2 Patch 2 (built Jul 14 2004)) with ESMTPA id <0LFW00C5UB49VJ@mmp2.samsung.com> for patches@linaro.org; Tue, 01 Feb 2011 01:29:06 +0900 (KST) Date: Mon, 31 Jan 2011 21:58:14 +0530 From: thomas.abraham@linaro.org Subject: [RFC PATCH] SDHCI: S3C: Add support for retrieving memory and irq resource information from device tree. To: devicetree-discuss@lists.ozlabs.org Cc: kgene.kim@samsung.net, linaro-dev@lists.linaro.org, patches@linaro.org, Thomas Abraham Message-id: <1296491294-11030-1-git-send-email-thomas.abraham@linaro.org> X-Mailer: git-send-email 1.6.6.rc2 Content-transfer-encoding: 7BIT From: Thomas Abraham Add support for retrieving memory and irq resource information from device tree for Samsung's SDHCI controller driver. Signed-off-by: Thomas Abraham --- The modification will be made more generic to support both DT and non-DT versions of the driver without the #ifdef's. For now, this patch is for review and to understand if the approach adopted to obtain resource information from the device tree is appropriate. drivers/mmc/host/sdhci-s3c.c | 32 ++++++++++++++++++++++++++++++++ 1 files changed, 32 insertions(+), 0 deletions(-) diff --git a/drivers/mmc/host/sdhci-s3c.c b/drivers/mmc/host/sdhci-s3c.c index 1720358..f536061 100644 --- a/drivers/mmc/host/sdhci-s3c.c +++ b/drivers/mmc/host/sdhci-s3c.c @@ -19,6 +19,9 @@ #include #include #include +#include +#include +#include #include @@ -348,23 +351,52 @@ static int __devinit sdhci_s3c_probe(struct platform_device *pdev) struct sdhci_s3c *sc; struct resource *res; int ret, irq, ptr, clks; + struct device_node *np = NULL; +#ifdef CONFIG_OF + struct resource iores; +#endif if (!pdata) { dev_err(dev, "no device data specified\n"); return -ENOENT; } +#ifdef CONFIG_OF + for_each_compatible_node(np, NULL, "samsung,sdhci-s3c") { + const u32 *id = of_get_property(np, "cell-index", NULL); + if (be32_to_cpu(*id) == pdev->id) + break; + } + + if (!np) { + dev_err(dev, "no matching device node specified in device tree\n"); + return -ENOENT; + } +#endif + +#ifndef CONFIG_OF irq = platform_get_irq(pdev, 0); +#else + irq = of_irq_to_resource(np, 0, NULL); +#endif if (irq < 0) { dev_err(dev, "no irq specified\n"); return irq; } +#ifndef CONFIG_OF res = platform_get_resource(pdev, IORESOURCE_MEM, 0); if (!res) { dev_err(dev, "no memory specified\n"); return -ENOENT; } +#else + if (of_address_to_resource(np, 0, &iores)) { + dev_err(dev, "no memory specified in device tree\n"); + return -ENOENT; + } + res = &iores; +#endif host = sdhci_alloc_host(dev, sizeof(struct sdhci_s3c)); if (IS_ERR(host)) {