aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/rtc/rtc-s3c.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2012-03-27 19:41:24 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2012-03-27 19:41:24 -0400
commit34800598b2eebe061445216473b1e4c2ff5cba99 (patch)
treea6d0eb6fe45d9480888d7ddb34840e172ed80e56 /drivers/rtc/rtc-s3c.c
parent46b407ca4a6149c8d27fcec1881d4f184bec7c77 (diff)
parent511f1cb6d426938fabf9c6d69ce4861b66ffd919 (diff)
Merge tag 'drivers' of git://git.kernel.org/pub/scm/linux/kernel/git/arm/arm-soc
Pull "ARM: driver specific updates" from Arnd Bergmann: "These are all specific to some driver. They are typically the platform side of a change in the drivers directory, such as adding a new driver or extending the interface to the platform. In cases where there is no maintainer for the driver, or the maintainer prefers to have the platform changes in the same branch as the driver changes, the patches to the drivers are included as well. A much smaller set of driver updates that depend on other branches getting merged first will be sent later. The new export of tegra_chip_uid conflicts with other changes in fuse.c. In rtc-sa1100.c, the global removal of IRQF_DISABLED conflicts with the cleanup of the interrupt handling of that driver. Signed-off-by: Arnd Bergmann <arnd@arndb.de>" Fixed up aforementioned trivial conflicts. * tag 'drivers' of git://git.kernel.org/pub/scm/linux/kernel/git/arm/arm-soc: (94 commits) ARM: SAMSUNG: change the name from s3c-sdhci to exynos4-sdhci mmc: sdhci-s3c: add platform data for the second capability ARM: SAMSUNG: support the second capability for samsung-soc ARM: EXYNOS: add support DMA for EXYNOS4X12 SoC ARM: EXYNOS: Add apb_pclk clkdev entry for mdma1 ARM: EXYNOS: Enable MDMA driver regulator: Remove bq24022 regulator driver rtc: sa1100: add OF support pxa: magician/hx4700: Convert to gpio-regulator from bq24022 ARM: OMAP3+: SmartReflex: fix error handling ARM: OMAP3+: SmartReflex: fix the use of debugfs_create_* API ARM: OMAP3+: SmartReflex: micro-optimization for sanity check ARM: OMAP3+: SmartReflex: misc cleanups ARM: OMAP3+: SmartReflex: move late_initcall() closer to its argument ARM: OMAP3+: SmartReflex: add missing platform_set_drvdata() ARM: OMAP3+: hwmod: add SmartReflex IRQs ARM: OMAP3+: SmartReflex: clear ERRCONFIG_VPBOUNDINTST only on a need ARM: OMAP3+: SmartReflex: Fix status masking in ERRCONFIG register ARM: OMAP3+: SmartReflex: Add a shutdown hook ARM: OMAP3+: SmartReflex Class3: disable errorgen before disable VP ... Conflicts: arch/arm/mach-tegra/Makefile arch/arm/mach-tegra/fuse.c drivers/rtc/rtc-sa1100.c
Diffstat (limited to 'drivers/rtc/rtc-s3c.c')
-rw-r--r--drivers/rtc/rtc-s3c.c71
1 files changed, 58 insertions, 13 deletions
diff --git a/drivers/rtc/rtc-s3c.c b/drivers/rtc/rtc-s3c.c
index c543f6f1eec2..9ccea134a996 100644
--- a/drivers/rtc/rtc-s3c.c
+++ b/drivers/rtc/rtc-s3c.c
@@ -35,6 +35,8 @@
35 35
36enum s3c_cpu_type { 36enum s3c_cpu_type {
37 TYPE_S3C2410, 37 TYPE_S3C2410,
38 TYPE_S3C2416,
39 TYPE_S3C2443,
38 TYPE_S3C64XX, 40 TYPE_S3C64XX,
39}; 41};
40 42
@@ -132,6 +134,7 @@ static int s3c_rtc_setfreq(struct device *dev, int freq)
132 struct platform_device *pdev = to_platform_device(dev); 134 struct platform_device *pdev = to_platform_device(dev);
133 struct rtc_device *rtc_dev = platform_get_drvdata(pdev); 135 struct rtc_device *rtc_dev = platform_get_drvdata(pdev);
134 unsigned int tmp = 0; 136 unsigned int tmp = 0;
137 int val;
135 138
136 if (!is_power_of_2(freq)) 139 if (!is_power_of_2(freq))
137 return -EINVAL; 140 return -EINVAL;
@@ -139,12 +142,22 @@ static int s3c_rtc_setfreq(struct device *dev, int freq)
139 clk_enable(rtc_clk); 142 clk_enable(rtc_clk);
140 spin_lock_irq(&s3c_rtc_pie_lock); 143 spin_lock_irq(&s3c_rtc_pie_lock);
141 144
142 if (s3c_rtc_cpu_type == TYPE_S3C2410) { 145 if (s3c_rtc_cpu_type != TYPE_S3C64XX) {
143 tmp = readb(s3c_rtc_base + S3C2410_TICNT); 146 tmp = readb(s3c_rtc_base + S3C2410_TICNT);
144 tmp &= S3C2410_TICNT_ENABLE; 147 tmp &= S3C2410_TICNT_ENABLE;
145 } 148 }
146 149
147 tmp |= (rtc_dev->max_user_freq / freq)-1; 150 val = (rtc_dev->max_user_freq / freq) - 1;
151
152 if (s3c_rtc_cpu_type == TYPE_S3C2416 || s3c_rtc_cpu_type == TYPE_S3C2443) {
153 tmp |= S3C2443_TICNT_PART(val);
154 writel(S3C2443_TICNT1_PART(val), s3c_rtc_base + S3C2443_TICNT1);
155
156 if (s3c_rtc_cpu_type == TYPE_S3C2416)
157 writel(S3C2416_TICNT2_PART(val), s3c_rtc_base + S3C2416_TICNT2);
158 } else {
159 tmp |= val;
160 }
148 161
149 writel(tmp, s3c_rtc_base + S3C2410_TICNT); 162 writel(tmp, s3c_rtc_base + S3C2410_TICNT);
150 spin_unlock_irq(&s3c_rtc_pie_lock); 163 spin_unlock_irq(&s3c_rtc_pie_lock);
@@ -371,7 +384,7 @@ static void s3c_rtc_enable(struct platform_device *pdev, int en)
371 tmp &= ~S3C2410_RTCCON_RTCEN; 384 tmp &= ~S3C2410_RTCCON_RTCEN;
372 writew(tmp, base + S3C2410_RTCCON); 385 writew(tmp, base + S3C2410_RTCCON);
373 386
374 if (s3c_rtc_cpu_type == TYPE_S3C2410) { 387 if (s3c_rtc_cpu_type != TYPE_S3C64XX) {
375 tmp = readb(base + S3C2410_TICNT); 388 tmp = readb(base + S3C2410_TICNT);
376 tmp &= ~S3C2410_TICNT_ENABLE; 389 tmp &= ~S3C2410_TICNT_ENABLE;
377 writeb(tmp, base + S3C2410_TICNT); 390 writeb(tmp, base + S3C2410_TICNT);
@@ -428,12 +441,27 @@ static int __devexit s3c_rtc_remove(struct platform_device *dev)
428 return 0; 441 return 0;
429} 442}
430 443
444static const struct of_device_id s3c_rtc_dt_match[];
445
446static inline int s3c_rtc_get_driver_data(struct platform_device *pdev)
447{
448#ifdef CONFIG_OF
449 if (pdev->dev.of_node) {
450 const struct of_device_id *match;
451 match = of_match_node(s3c_rtc_dt_match, pdev->dev.of_node);
452 return match->data;
453 }
454#endif
455 return platform_get_device_id(pdev)->driver_data;
456}
457
431static int __devinit s3c_rtc_probe(struct platform_device *pdev) 458static int __devinit s3c_rtc_probe(struct platform_device *pdev)
432{ 459{
433 struct rtc_device *rtc; 460 struct rtc_device *rtc;
434 struct rtc_time rtc_tm; 461 struct rtc_time rtc_tm;
435 struct resource *res; 462 struct resource *res;
436 int ret; 463 int ret;
464 int tmp;
437 465
438 pr_debug("%s: probe=%p\n", __func__, pdev); 466 pr_debug("%s: probe=%p\n", __func__, pdev);
439 467
@@ -508,13 +536,7 @@ static int __devinit s3c_rtc_probe(struct platform_device *pdev)
508 goto err_nortc; 536 goto err_nortc;
509 } 537 }
510 538
511#ifdef CONFIG_OF 539 s3c_rtc_cpu_type = s3c_rtc_get_driver_data(pdev);
512 if (pdev->dev.of_node)
513 s3c_rtc_cpu_type = of_device_is_compatible(pdev->dev.of_node,
514 "samsung,s3c6410-rtc") ? TYPE_S3C64XX : TYPE_S3C2410;
515 else
516#endif
517 s3c_rtc_cpu_type = platform_get_device_id(pdev)->driver_data;
518 540
519 /* Check RTC Time */ 541 /* Check RTC Time */
520 542
@@ -533,11 +555,17 @@ static int __devinit s3c_rtc_probe(struct platform_device *pdev)
533 dev_warn(&pdev->dev, "warning: invalid RTC value so initializing it\n"); 555 dev_warn(&pdev->dev, "warning: invalid RTC value so initializing it\n");
534 } 556 }
535 557
536 if (s3c_rtc_cpu_type == TYPE_S3C64XX) 558 if (s3c_rtc_cpu_type != TYPE_S3C2410)
537 rtc->max_user_freq = 32768; 559 rtc->max_user_freq = 32768;
538 else 560 else
539 rtc->max_user_freq = 128; 561 rtc->max_user_freq = 128;
540 562
563 if (s3c_rtc_cpu_type == TYPE_S3C2416 || s3c_rtc_cpu_type == TYPE_S3C2443) {
564 tmp = readw(s3c_rtc_base + S3C2410_RTCCON);
565 tmp |= S3C2443_RTCCON_TICSEL;
566 writew(tmp, s3c_rtc_base + S3C2410_RTCCON);
567 }
568
541 platform_set_drvdata(pdev, rtc); 569 platform_set_drvdata(pdev, rtc);
542 570
543 s3c_rtc_setfreq(&pdev->dev, 1); 571 s3c_rtc_setfreq(&pdev->dev, 1);
@@ -638,8 +666,19 @@ static int s3c_rtc_resume(struct platform_device *pdev)
638 666
639#ifdef CONFIG_OF 667#ifdef CONFIG_OF
640static const struct of_device_id s3c_rtc_dt_match[] = { 668static const struct of_device_id s3c_rtc_dt_match[] = {
641 { .compatible = "samsung,s3c2410-rtc" }, 669 {
642 { .compatible = "samsung,s3c6410-rtc" }, 670 .compatible = "samsung,s3c2410-rtc"
671 .data = TYPE_S3C2410,
672 }, {
673 .compatible = "samsung,s3c2416-rtc"
674 .data = TYPE_S3C2416,
675 }, {
676 .compatible = "samsung,s3c2443-rtc"
677 .data = TYPE_S3C2443,
678 }, {
679 .compatible = "samsung,s3c6410-rtc"
680 .data = TYPE_S3C64XX,
681 },
643 {}, 682 {},
644}; 683};
645MODULE_DEVICE_TABLE(of, s3c_rtc_dt_match); 684MODULE_DEVICE_TABLE(of, s3c_rtc_dt_match);
@@ -652,6 +691,12 @@ static struct platform_device_id s3c_rtc_driver_ids[] = {
652 .name = "s3c2410-rtc", 691 .name = "s3c2410-rtc",
653 .driver_data = TYPE_S3C2410, 692 .driver_data = TYPE_S3C2410,
654 }, { 693 }, {
694 .name = "s3c2416-rtc",
695 .driver_data = TYPE_S3C2416,
696 }, {
697 .name = "s3c2443-rtc",
698 .driver_data = TYPE_S3C2443,
699 }, {
655 .name = "s3c64xx-rtc", 700 .name = "s3c64xx-rtc",
656 .driver_data = TYPE_S3C64XX, 701 .driver_data = TYPE_S3C64XX,
657 }, 702 },