Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

rtc: rtc-s3c: Add device tree support

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>

authored by

Thomas Abraham and committed by
Kukjin Kim
39ce4084 b3d6ac3e

+40 -1
+20
Documentation/devicetree/bindings/rtc/s3c-rtc.txt
··· 1 + * Samsung's S3C Real Time Clock controller 2 + 3 + Required properties: 4 + - compatible: should be one of the following. 5 + * "samsung,s3c2410-rtc" - for controllers compatible with s3c2410 rtc. 6 + * "samsung,s3c6410-rtc" - for controllers compatible with s3c6410 rtc. 7 + - reg: physical base address of the controller and length of memory mapped 8 + region. 9 + - interrupts: Two interrupt numbers to the cpu should be specified. First 10 + interrupt number is the rtc alarm interupt and second interrupt number 11 + is the rtc tick interrupt. The number of cells representing a interrupt 12 + depends on the parent interrupt controller. 13 + 14 + Example: 15 + 16 + rtc@10070000 { 17 + compatible = "samsung,s3c6410-rtc"; 18 + reg = <0x10070000 0x100>; 19 + interrupts = <44 0 45 0>; 20 + };
+20 -1
drivers/rtc/rtc-s3c.c
··· 25 25 #include <linux/clk.h> 26 26 #include <linux/log2.h> 27 27 #include <linux/slab.h> 28 + #include <linux/of.h> 28 29 29 30 #include <mach/hardware.h> 30 31 #include <asm/uaccess.h> ··· 508 507 goto err_nortc; 509 508 } 510 509 511 - s3c_rtc_cpu_type = platform_get_device_id(pdev)->driver_data; 510 + #ifdef CONFIG_OF 511 + if (pdev->dev.of_node) 512 + s3c_rtc_cpu_type = of_device_is_compatible(pdev->dev.of_node, 513 + "samsung,s3c6410-rtc") ? TYPE_S3C64XX : TYPE_S3C2410; 514 + else 515 + #endif 516 + s3c_rtc_cpu_type = platform_get_device_id(pdev)->driver_data; 512 517 513 518 /* Check RTC Time */ 514 519 ··· 636 629 #define s3c_rtc_resume NULL 637 630 #endif 638 631 632 + #ifdef CONFIG_OF 633 + static const struct of_device_id s3c_rtc_dt_match[] = { 634 + { .compatible = "samsung,s3c2410-rtc" }, 635 + { .compatible = "samsung,s3c6410-rtc" }, 636 + {}, 637 + }; 638 + MODULE_DEVICE_TABLE(of, s3c_rtc_dt_match); 639 + #else 640 + #define s3c_rtc_dt_match NULL 641 + #endif 642 + 639 643 static struct platform_device_id s3c_rtc_driver_ids[] = { 640 644 { 641 645 .name = "s3c2410-rtc", ··· 669 651 .driver = { 670 652 .name = "s3c-rtc", 671 653 .owner = THIS_MODULE, 654 + .of_match_table = s3c_rtc_dt_match, 672 655 }, 673 656 }; 674 657