@@ -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)) {