diff options
Diffstat (limited to 'drivers/rtc/rtc-s3c.c')
-rw-r--r-- | drivers/rtc/rtc-s3c.c | 79 |
1 files changed, 31 insertions, 48 deletions
diff --git a/drivers/rtc/rtc-s3c.c b/drivers/rtc/rtc-s3c.c index 9329dbb9ebab..4e7c04e773e0 100644 --- a/drivers/rtc/rtc-s3c.c +++ b/drivers/rtc/rtc-s3c.c | |||
@@ -152,10 +152,6 @@ static int s3c_rtc_gettime(struct device *dev, struct rtc_time *rtc_tm) | |||
152 | goto retry_get_time; | 152 | goto retry_get_time; |
153 | } | 153 | } |
154 | 154 | ||
155 | pr_debug("read time %04d.%02d.%02d %02d:%02d:%02d\n", | ||
156 | 1900 + rtc_tm->tm_year, rtc_tm->tm_mon, rtc_tm->tm_mday, | ||
157 | rtc_tm->tm_hour, rtc_tm->tm_min, rtc_tm->tm_sec); | ||
158 | |||
159 | rtc_tm->tm_sec = bcd2bin(rtc_tm->tm_sec); | 155 | rtc_tm->tm_sec = bcd2bin(rtc_tm->tm_sec); |
160 | rtc_tm->tm_min = bcd2bin(rtc_tm->tm_min); | 156 | rtc_tm->tm_min = bcd2bin(rtc_tm->tm_min); |
161 | rtc_tm->tm_hour = bcd2bin(rtc_tm->tm_hour); | 157 | rtc_tm->tm_hour = bcd2bin(rtc_tm->tm_hour); |
@@ -164,6 +160,11 @@ static int s3c_rtc_gettime(struct device *dev, struct rtc_time *rtc_tm) | |||
164 | rtc_tm->tm_year = bcd2bin(rtc_tm->tm_year); | 160 | rtc_tm->tm_year = bcd2bin(rtc_tm->tm_year); |
165 | 161 | ||
166 | rtc_tm->tm_year += 100; | 162 | rtc_tm->tm_year += 100; |
163 | |||
164 | pr_debug("read time %04d.%02d.%02d %02d:%02d:%02d\n", | ||
165 | 1900 + rtc_tm->tm_year, rtc_tm->tm_mon, rtc_tm->tm_mday, | ||
166 | rtc_tm->tm_hour, rtc_tm->tm_min, rtc_tm->tm_sec); | ||
167 | |||
167 | rtc_tm->tm_mon -= 1; | 168 | rtc_tm->tm_mon -= 1; |
168 | 169 | ||
169 | clk_disable(rtc_clk); | 170 | clk_disable(rtc_clk); |
@@ -269,10 +270,9 @@ static int s3c_rtc_setalarm(struct device *dev, struct rtc_wkalrm *alrm) | |||
269 | clk_enable(rtc_clk); | 270 | clk_enable(rtc_clk); |
270 | pr_debug("s3c_rtc_setalarm: %d, %04d.%02d.%02d %02d:%02d:%02d\n", | 271 | pr_debug("s3c_rtc_setalarm: %d, %04d.%02d.%02d %02d:%02d:%02d\n", |
271 | alrm->enabled, | 272 | alrm->enabled, |
272 | 1900 + tm->tm_year, tm->tm_mon, tm->tm_mday, | 273 | 1900 + tm->tm_year, tm->tm_mon + 1, tm->tm_mday, |
273 | tm->tm_hour, tm->tm_min, tm->tm_sec); | 274 | tm->tm_hour, tm->tm_min, tm->tm_sec); |
274 | 275 | ||
275 | |||
276 | alrm_en = readb(base + S3C2410_RTCALM) & S3C2410_RTCALM_ALMEN; | 276 | alrm_en = readb(base + S3C2410_RTCALM) & S3C2410_RTCALM_ALMEN; |
277 | writeb(0x00, base + S3C2410_RTCALM); | 277 | writeb(0x00, base + S3C2410_RTCALM); |
278 | 278 | ||
@@ -319,49 +319,7 @@ static int s3c_rtc_proc(struct device *dev, struct seq_file *seq) | |||
319 | return 0; | 319 | return 0; |
320 | } | 320 | } |
321 | 321 | ||
322 | static int s3c_rtc_open(struct device *dev) | ||
323 | { | ||
324 | struct platform_device *pdev = to_platform_device(dev); | ||
325 | struct rtc_device *rtc_dev = platform_get_drvdata(pdev); | ||
326 | int ret; | ||
327 | |||
328 | ret = request_irq(s3c_rtc_alarmno, s3c_rtc_alarmirq, | ||
329 | IRQF_DISABLED, "s3c2410-rtc alarm", rtc_dev); | ||
330 | |||
331 | if (ret) { | ||
332 | dev_err(dev, "IRQ%d error %d\n", s3c_rtc_alarmno, ret); | ||
333 | return ret; | ||
334 | } | ||
335 | |||
336 | ret = request_irq(s3c_rtc_tickno, s3c_rtc_tickirq, | ||
337 | IRQF_DISABLED, "s3c2410-rtc tick", rtc_dev); | ||
338 | |||
339 | if (ret) { | ||
340 | dev_err(dev, "IRQ%d error %d\n", s3c_rtc_tickno, ret); | ||
341 | goto tick_err; | ||
342 | } | ||
343 | |||
344 | return ret; | ||
345 | |||
346 | tick_err: | ||
347 | free_irq(s3c_rtc_alarmno, rtc_dev); | ||
348 | return ret; | ||
349 | } | ||
350 | |||
351 | static void s3c_rtc_release(struct device *dev) | ||
352 | { | ||
353 | struct platform_device *pdev = to_platform_device(dev); | ||
354 | struct rtc_device *rtc_dev = platform_get_drvdata(pdev); | ||
355 | |||
356 | /* do not clear AIE here, it may be needed for wake */ | ||
357 | |||
358 | free_irq(s3c_rtc_alarmno, rtc_dev); | ||
359 | free_irq(s3c_rtc_tickno, rtc_dev); | ||
360 | } | ||
361 | |||
362 | static const struct rtc_class_ops s3c_rtcops = { | 322 | static const struct rtc_class_ops s3c_rtcops = { |
363 | .open = s3c_rtc_open, | ||
364 | .release = s3c_rtc_release, | ||
365 | .read_time = s3c_rtc_gettime, | 323 | .read_time = s3c_rtc_gettime, |
366 | .set_time = s3c_rtc_settime, | 324 | .set_time = s3c_rtc_settime, |
367 | .read_alarm = s3c_rtc_getalarm, | 325 | .read_alarm = s3c_rtc_getalarm, |
@@ -425,6 +383,9 @@ static int __devexit s3c_rtc_remove(struct platform_device *dev) | |||
425 | { | 383 | { |
426 | struct rtc_device *rtc = platform_get_drvdata(dev); | 384 | struct rtc_device *rtc = platform_get_drvdata(dev); |
427 | 385 | ||
386 | free_irq(s3c_rtc_alarmno, rtc); | ||
387 | free_irq(s3c_rtc_tickno, rtc); | ||
388 | |||
428 | platform_set_drvdata(dev, NULL); | 389 | platform_set_drvdata(dev, NULL); |
429 | rtc_device_unregister(rtc); | 390 | rtc_device_unregister(rtc); |
430 | 391 | ||
@@ -548,10 +509,32 @@ static int __devinit s3c_rtc_probe(struct platform_device *pdev) | |||
548 | 509 | ||
549 | s3c_rtc_setfreq(&pdev->dev, 1); | 510 | s3c_rtc_setfreq(&pdev->dev, 1); |
550 | 511 | ||
512 | ret = request_irq(s3c_rtc_alarmno, s3c_rtc_alarmirq, | ||
513 | IRQF_DISABLED, "s3c2410-rtc alarm", rtc); | ||
514 | if (ret) { | ||
515 | dev_err(&pdev->dev, "IRQ%d error %d\n", s3c_rtc_alarmno, ret); | ||
516 | goto err_alarm_irq; | ||
517 | } | ||
518 | |||
519 | ret = request_irq(s3c_rtc_tickno, s3c_rtc_tickirq, | ||
520 | IRQF_DISABLED, "s3c2410-rtc tick", rtc); | ||
521 | if (ret) { | ||
522 | dev_err(&pdev->dev, "IRQ%d error %d\n", s3c_rtc_tickno, ret); | ||
523 | free_irq(s3c_rtc_alarmno, rtc); | ||
524 | goto err_tick_irq; | ||
525 | } | ||
526 | |||
551 | clk_disable(rtc_clk); | 527 | clk_disable(rtc_clk); |
552 | 528 | ||
553 | return 0; | 529 | return 0; |
554 | 530 | ||
531 | err_tick_irq: | ||
532 | free_irq(s3c_rtc_alarmno, rtc); | ||
533 | |||
534 | err_alarm_irq: | ||
535 | platform_set_drvdata(pdev, NULL); | ||
536 | rtc_device_unregister(rtc); | ||
537 | |||
555 | err_nortc: | 538 | err_nortc: |
556 | s3c_rtc_enable(pdev, 0); | 539 | s3c_rtc_enable(pdev, 0); |
557 | clk_disable(rtc_clk); | 540 | clk_disable(rtc_clk); |