From: thomas.abraham-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org
To: devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ@public.gmane.org
Cc: kgene.kim-Sze3O3UU22LR7s880joybQ@public.gmane.org,
Thomas Abraham
<thomas.abraham-68IGFXMjmZ7QT0dZR+AlfA@public.gmane.org>,
linaro-dev-cunTk1MwBs8s++Sfvej+rw@public.gmane.org,
patches-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org
Subject: [RFC PATCH] SDHCI: S3C: Add support for retrieving memory and irq resource information from device tree.
Date: Mon, 31 Jan 2011 21:58:14 +0530 [thread overview]
Message-ID: <1296491294-11030-1-git-send-email-thomas.abraham@linaro.org> (raw)
From: Thomas Abraham <thomas.abraham-68IGFXMjmZ7QT0dZR+AlfA@public.gmane.org>
Add support for retrieving memory and irq resource information
from device tree for Samsung's SDHCI controller driver.
Signed-off-by: Thomas Abraham <thomas.abraham-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
---
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 <linux/clk.h>
#include <linux/io.h>
#include <linux/gpio.h>
+#include <linux/of.h>
+#include <linux/of_irq.h>
+#include <linux/of_address.h>
#include <linux/mmc/host.h>
@@ -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)) {
--
1.6.6.rc2
next reply other threads:[~2011-01-31 16:28 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-01-31 16:28 thomas.abraham-QSEj5FYQhm4dnm+yROfE0A [this message]
[not found] ` <1296491294-11030-1-git-send-email-thomas.abraham-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
2011-01-31 16:41 ` [RFC PATCH] SDHCI: S3C: Add support for retrieving memory and irq resource information from device tree Grant Likely
2011-01-31 17:00 ` Rob Herring
[not found] ` <4D46EABD.8010903-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2011-01-31 18:00 ` Grant Likely
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1296491294-11030-1-git-send-email-thomas.abraham@linaro.org \
--to=thomas.abraham-qsej5fyqhm4dnm+yrofe0a@public.gmane.org \
--cc=devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ@public.gmane.org \
--cc=kgene.kim-Sze3O3UU22LR7s880joybQ@public.gmane.org \
--cc=linaro-dev-cunTk1MwBs8s++Sfvej+rw@public.gmane.org \
--cc=patches-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org \
--cc=thomas.abraham-68IGFXMjmZ7QT0dZR+AlfA@public.gmane.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox