aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/rtc
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2012-03-27 19:03:32 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2012-03-27 19:03:32 -0400
commitd61b7a572b292e2be409e13b4b3adf475f18fb29 (patch)
treee9d30390860147136c05e66abf1edda1bc5b0562 /drivers/rtc
parent18d9946bc7e2252fe3c0f2f609ac383c627edefd (diff)
parentf4e2467bad53023589cbff18dd1ab6e0aa3f004c (diff)
Merge tag 'cleanup' of git://git.kernel.org/pub/scm/linux/kernel/git/arm/arm-soc
Pull "ARM: global cleanups" from Arnd Bergmann: "Quite a bit of code gets removed, and some stuff moved around, mostly the old samsung s3c24xx stuff. There should be no functional changes in this series otherwise. Some cleanups have dependencies on other arm-soc branches and will be sent in the second round. Signed-off-by: Arnd Bergmann <arnd@arndb.de>" Fixed up trivial conflicts mainly due to #include's being changes on both sides. * tag 'cleanup' of git://git.kernel.org/pub/scm/linux/kernel/git/arm/arm-soc: (121 commits) ep93xx: Remove unnecessary includes of ep93xx-regs.h ep93xx: Move EP93XX_SYSCON defines to SoC private header ep93xx: Move crunch code to mach-ep93xx directory ep93xx: Make syscon access functions private to SoC ep93xx: Configure GPIO ports in core code ep93xx: Move peripheral defines to local SoC header ep93xx: Convert the watchdog driver into a platform device. ep93xx: Use ioremap for backlight driver ep93xx: Move GPIO defines to gpio-ep93xx.h ep93xx: Don't use system controller defines in audio drivers ep93xx: Move PHYS_BASE defines to local SoC header file ARM: EXYNOS: Add clock register addresses for EXYNOS4X12 bus devfreq driver ARM: EXYNOS: add clock registers for exynos4x12-cpufreq PM / devfreq: update the name of EXYNOS clock registers that were omitted PM / devfreq: update the name of EXYNOS clock register ARM: EXYNOS: change the prefix S5P_ to EXYNOS4_ for clock ARM: EXYNOS: use static declaration on regarding clock ARM: EXYNOS: replace clock.c for other new EXYNOS SoCs ARM: OMAP2+: Fix build error after merge ARM: S3C24XX: remove call to s3c24xx_setup_clocks ...
Diffstat (limited to 'drivers/rtc')
-rw-r--r--drivers/rtc/Kconfig2
-rw-r--r--drivers/rtc/rtc-sa1100.c81
2 files changed, 12 insertions, 71 deletions
diff --git a/drivers/rtc/Kconfig b/drivers/rtc/Kconfig
index 4f9fb25f945b..4768a9d28375 100644
--- a/drivers/rtc/Kconfig
+++ b/drivers/rtc/Kconfig
@@ -755,7 +755,7 @@ config HAVE_S3C_RTC
755 755
756config RTC_DRV_S3C 756config RTC_DRV_S3C
757 tristate "Samsung S3C series SoC RTC" 757 tristate "Samsung S3C series SoC RTC"
758 depends on ARCH_S3C2410 || ARCH_S3C64XX || HAVE_S3C_RTC 758 depends on ARCH_S3C64XX || HAVE_S3C_RTC
759 help 759 help
760 RTC (Realtime Clock) driver for the clock inbuilt into the 760 RTC (Realtime Clock) driver for the clock inbuilt into the
761 Samsung S3C24XX series of SoCs. This can provide periodic 761 Samsung S3C24XX series of SoCs. This can provide periodic
diff --git a/drivers/rtc/rtc-sa1100.c b/drivers/rtc/rtc-sa1100.c
index fb758db9d0f4..44cd81c72ea1 100644
--- a/drivers/rtc/rtc-sa1100.c
+++ b/drivers/rtc/rtc-sa1100.c
@@ -42,67 +42,8 @@
42#define RTC_DEF_TRIM 0 42#define RTC_DEF_TRIM 0
43 43
44static const unsigned long RTC_FREQ = 1024; 44static const unsigned long RTC_FREQ = 1024;
45static struct rtc_time rtc_alarm;
46static DEFINE_SPINLOCK(sa1100_rtc_lock); 45static DEFINE_SPINLOCK(sa1100_rtc_lock);
47 46
48static inline int rtc_periodic_alarm(struct rtc_time *tm)
49{
50 return (tm->tm_year == -1) ||
51 ((unsigned)tm->tm_mon >= 12) ||
52 ((unsigned)(tm->tm_mday - 1) >= 31) ||
53 ((unsigned)tm->tm_hour > 23) ||
54 ((unsigned)tm->tm_min > 59) ||
55 ((unsigned)tm->tm_sec > 59);
56}
57
58/*
59 * Calculate the next alarm time given the requested alarm time mask
60 * and the current time.
61 */
62static void rtc_next_alarm_time(struct rtc_time *next, struct rtc_time *now,
63 struct rtc_time *alrm)
64{
65 unsigned long next_time;
66 unsigned long now_time;
67
68 next->tm_year = now->tm_year;
69 next->tm_mon = now->tm_mon;
70 next->tm_mday = now->tm_mday;
71 next->tm_hour = alrm->tm_hour;
72 next->tm_min = alrm->tm_min;
73 next->tm_sec = alrm->tm_sec;
74
75 rtc_tm_to_time(now, &now_time);
76 rtc_tm_to_time(next, &next_time);
77
78 if (next_time < now_time) {
79 /* Advance one day */
80 next_time += 60 * 60 * 24;
81 rtc_time_to_tm(next_time, next);
82 }
83}
84
85static int rtc_update_alarm(struct rtc_time *alrm)
86{
87 struct rtc_time alarm_tm, now_tm;
88 unsigned long now, time;
89 int ret;
90
91 do {
92 now = RCNR;
93 rtc_time_to_tm(now, &now_tm);
94 rtc_next_alarm_time(&alarm_tm, &now_tm, alrm);
95 ret = rtc_tm_to_time(&alarm_tm, &time);
96 if (ret != 0)
97 break;
98
99 RTSR = RTSR & (RTSR_HZE|RTSR_ALE|RTSR_AL);
100 RTAR = time;
101 } while (now != RCNR);
102
103 return ret;
104}
105
106static irqreturn_t sa1100_rtc_interrupt(int irq, void *dev_id) 47static irqreturn_t sa1100_rtc_interrupt(int irq, void *dev_id)
107{ 48{
108 struct platform_device *pdev = to_platform_device(dev_id); 49 struct platform_device *pdev = to_platform_device(dev_id);
@@ -146,9 +87,6 @@ static irqreturn_t sa1100_rtc_interrupt(int irq, void *dev_id)
146 87
147 rtc_update_irq(rtc, 1, events); 88 rtc_update_irq(rtc, 1, events);
148 89
149 if (rtsr & RTSR_AL && rtc_periodic_alarm(&rtc_alarm))
150 rtc_update_alarm(&rtc_alarm);
151
152 spin_unlock(&sa1100_rtc_lock); 90 spin_unlock(&sa1100_rtc_lock);
153 91
154 return IRQ_HANDLED; 92 return IRQ_HANDLED;
@@ -224,7 +162,6 @@ static int sa1100_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alrm)
224{ 162{
225 u32 rtsr; 163 u32 rtsr;
226 164
227 memcpy(&alrm->time, &rtc_alarm, sizeof(struct rtc_time));
228 rtsr = RTSR; 165 rtsr = RTSR;
229 alrm->enabled = (rtsr & RTSR_ALE) ? 1 : 0; 166 alrm->enabled = (rtsr & RTSR_ALE) ? 1 : 0;
230 alrm->pending = (rtsr & RTSR_AL) ? 1 : 0; 167 alrm->pending = (rtsr & RTSR_AL) ? 1 : 0;
@@ -233,16 +170,20 @@ static int sa1100_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alrm)
233 170
234static int sa1100_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alrm) 171static int sa1100_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alrm)
235{ 172{
173 unsigned long time;
236 int ret; 174 int ret;
237 175
238 spin_lock_irq(&sa1100_rtc_lock); 176 spin_lock_irq(&sa1100_rtc_lock);
239 ret = rtc_update_alarm(&alrm->time); 177 ret = rtc_tm_to_time(&alrm->time, &time);
240 if (ret == 0) { 178 if (ret != 0)
241 if (alrm->enabled) 179 goto out;
242 RTSR |= RTSR_ALE; 180 RTSR = RTSR & (RTSR_HZE|RTSR_ALE|RTSR_AL);
243 else 181 RTAR = time;
244 RTSR &= ~RTSR_ALE; 182 if (alrm->enabled)
245 } 183 RTSR |= RTSR_ALE;
184 else
185 RTSR &= ~RTSR_ALE;
186out:
246 spin_unlock_irq(&sa1100_rtc_lock); 187 spin_unlock_irq(&sa1100_rtc_lock);
247 188
248 return ret; 189 return ret;