aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/rtc
diff options
context:
space:
mode:
authorAlessandro Zummo <alessandro.zummo@towertech.it>2007-07-19 04:49:21 -0400
committerLinus Torvalds <torvalds@woody.linux-foundation.org>2007-07-19 13:04:52 -0400
commit57deb52622f3700d154e32662f36cd5f4053f6ed (patch)
treed27cc97a2d87c8c55dfadc73442afbb746f9516a /drivers/rtc
parentc7d51402d2a64c5b96531f9900bb368020ebbbbb (diff)
RTC: add periodic irq support to rtc-cmos
Adds support for periodic irq enabling in rtc-cmos. This could be used by the ALSA driver and is already being tested with the zaptel ztdummy module. Signed-off-by: Alessandro Zummo <a.zummo@towertech.it> Cc: David Brownell <david-b@pacbell.net> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers/rtc')
-rw-r--r--drivers/rtc/rtc-cmos.c33
1 files changed, 31 insertions, 2 deletions
diff --git a/drivers/rtc/rtc-cmos.c b/drivers/rtc/rtc-cmos.c
index e24ea82dc35b..5d760bb6c2cd 100644
--- a/drivers/rtc/rtc-cmos.c
+++ b/drivers/rtc/rtc-cmos.c
@@ -235,7 +235,7 @@ static int cmos_set_alarm(struct device *dev, struct rtc_wkalrm *t)
235 return 0; 235 return 0;
236} 236}
237 237
238static int cmos_set_freq(struct device *dev, int freq) 238static int cmos_irq_set_freq(struct device *dev, int freq)
239{ 239{
240 struct cmos_rtc *cmos = dev_get_drvdata(dev); 240 struct cmos_rtc *cmos = dev_get_drvdata(dev);
241 int f; 241 int f;
@@ -259,6 +259,34 @@ static int cmos_set_freq(struct device *dev, int freq)
259 return 0; 259 return 0;
260} 260}
261 261
262static int cmos_irq_set_state(struct device *dev, int enabled)
263{
264 struct cmos_rtc *cmos = dev_get_drvdata(dev);
265 unsigned char rtc_control, rtc_intr;
266 unsigned long flags;
267
268 if (!is_valid_irq(cmos->irq))
269 return -ENXIO;
270
271 spin_lock_irqsave(&rtc_lock, flags);
272 rtc_control = CMOS_READ(RTC_CONTROL);
273
274 if (enabled)
275 rtc_control |= RTC_PIE;
276 else
277 rtc_control &= ~RTC_PIE;
278
279 CMOS_WRITE(rtc_control, RTC_CONTROL);
280
281 rtc_intr = CMOS_READ(RTC_INTR_FLAGS);
282 rtc_intr &= (rtc_control & RTC_IRQMASK) | RTC_IRQF;
283 if (is_intr(rtc_intr))
284 rtc_update_irq(cmos->rtc, 1, rtc_intr);
285
286 spin_unlock_irqrestore(&rtc_lock, flags);
287 return 0;
288}
289
262#if defined(CONFIG_RTC_INTF_DEV) || defined(CONFIG_RTC_INTF_DEV_MODULE) 290#if defined(CONFIG_RTC_INTF_DEV) || defined(CONFIG_RTC_INTF_DEV_MODULE)
263 291
264static int 292static int
@@ -360,7 +388,8 @@ static const struct rtc_class_ops cmos_rtc_ops = {
360 .read_alarm = cmos_read_alarm, 388 .read_alarm = cmos_read_alarm,
361 .set_alarm = cmos_set_alarm, 389 .set_alarm = cmos_set_alarm,
362 .proc = cmos_procfs, 390 .proc = cmos_procfs,
363 .irq_set_freq = cmos_set_freq, 391 .irq_set_freq = cmos_irq_set_freq,
392 .irq_set_state = cmos_irq_set_state,
364}; 393};
365 394
366/*----------------------------------------------------------------*/ 395/*----------------------------------------------------------------*/