rtc: rtc-s3c: Add device tree support
authorThomas Abraham <thomas.abraham@linaro.org>
Mon, 24 Oct 2011 12:49:04 +0000 (14:49 +0200)
committerKukjin Kim <kgene.kim@samsung.com>
Fri, 23 Dec 2011 01:07:10 +0000 (10:07 +0900)
Add device tree based discovery support for Samsung's rtc controller.

Cc: Ben Dooks <ben-linux@fluff.org>
Signed-off-by: Thomas Abraham <thomas.abraham@linaro.org>
Acked-by: Grant Likely <grant.likely@secretlab.ca>
Signed-off-by: Kukjin Kim <kgene.kim@samsung.com>
Documentation/devicetree/bindings/rtc/s3c-rtc.txt [new file with mode: 0644]
drivers/rtc/rtc-s3c.c

diff --git a/Documentation/devicetree/bindings/rtc/s3c-rtc.txt b/Documentation/devicetree/bindings/rtc/s3c-rtc.txt
new file mode 100644 (file)
index 0000000..90ec45f
--- /dev/null
@@ -0,0 +1,20 @@
+* Samsung's S3C Real Time Clock controller
+
+Required properties:
+- compatible: should be one of the following.
+    * "samsung,s3c2410-rtc" - for controllers compatible with s3c2410 rtc.
+    * "samsung,s3c6410-rtc" - for controllers compatible with s3c6410 rtc.
+- reg: physical base address of the controller and length of memory mapped
+  region.
+- interrupts: Two interrupt numbers to the cpu should be specified. First
+  interrupt number is the rtc alarm interupt and second interrupt number
+  is the rtc tick interrupt. The number of cells representing a interrupt
+  depends on the parent interrupt controller.
+
+Example:
+
+       rtc@10070000 {
+               compatible = "samsung,s3c6410-rtc";
+               reg = <0x10070000 0x100>;
+               interrupts = <44 0 45 0>;
+       };
index 5b979d9..175067a 100644 (file)
@@ -25,6 +25,7 @@
 #include <linux/clk.h>
 #include <linux/log2.h>
 #include <linux/slab.h>
+#include <linux/of.h>
 
 #include <mach/hardware.h>
 #include <asm/uaccess.h>
@@ -507,7 +508,13 @@ static int __devinit s3c_rtc_probe(struct platform_device *pdev)
                goto err_nortc;
        }
 
-       s3c_rtc_cpu_type = platform_get_device_id(pdev)->driver_data;
+#ifdef CONFIG_OF
+       if (pdev->dev.of_node)
+               s3c_rtc_cpu_type = of_device_is_compatible(pdev->dev.of_node,
+                       "samsung,s3c6410-rtc") ? TYPE_S3C64XX : TYPE_S3C2410;
+       else
+#endif
+               s3c_rtc_cpu_type = platform_get_device_id(pdev)->driver_data;
 
        /* Check RTC Time */
 
@@ -629,6 +636,17 @@ static int s3c_rtc_resume(struct platform_device *pdev)
 #define s3c_rtc_resume  NULL
 #endif
 
+#ifdef CONFIG_OF
+static const struct of_device_id s3c_rtc_dt_match[] = {
+       { .compatible = "samsung,s3c2410-rtc" },
+       { .compatible = "samsung,s3c6410-rtc" },
+       {},
+};
+MODULE_DEVICE_TABLE(of, s3c_rtc_dt_match);
+#else
+#define s3c_rtc_dt_match NULL
+#endif
+
 static struct platform_device_id s3c_rtc_driver_ids[] = {
        {
                .name           = "s3c2410-rtc",
@@ -651,6 +669,7 @@ static struct platform_driver s3c_rtc_driver = {
        .driver         = {
                .name   = "s3c-rtc",
                .owner  = THIS_MODULE,
+               .of_match_table = s3c_rtc_dt_match,
        },
 };