diff options
Diffstat (limited to 'drivers/rtc/rtc-s3c.c')
-rw-r--r-- | drivers/rtc/rtc-s3c.c | 78 |
1 files changed, 21 insertions, 57 deletions
diff --git a/drivers/rtc/rtc-s3c.c b/drivers/rtc/rtc-s3c.c index a7a2a998fa91..fb994e9ddc15 100644 --- a/drivers/rtc/rtc-s3c.c +++ b/drivers/rtc/rtc-s3c.c | |||
@@ -47,8 +47,6 @@ struct s3c_rtc_drv_data { | |||
47 | /* I have yet to find an S3C implementation with more than one | 47 | /* I have yet to find an S3C implementation with more than one |
48 | * of these rtc blocks in */ | 48 | * of these rtc blocks in */ |
49 | 49 | ||
50 | static struct resource *s3c_rtc_mem; | ||
51 | |||
52 | static struct clk *rtc_clk; | 50 | static struct clk *rtc_clk; |
53 | static void __iomem *s3c_rtc_base; | 51 | static void __iomem *s3c_rtc_base; |
54 | static int s3c_rtc_alarmno = NO_IRQ; | 52 | static int s3c_rtc_alarmno = NO_IRQ; |
@@ -117,7 +115,7 @@ static int s3c_rtc_setaie(struct device *dev, unsigned int enabled) | |||
117 | { | 115 | { |
118 | unsigned int tmp; | 116 | unsigned int tmp; |
119 | 117 | ||
120 | pr_debug("%s: aie=%d\n", __func__, enabled); | 118 | dev_dbg(dev, "%s: aie=%d\n", __func__, enabled); |
121 | 119 | ||
122 | clk_enable(rtc_clk); | 120 | clk_enable(rtc_clk); |
123 | tmp = readb(s3c_rtc_base + S3C2410_RTCALM) & ~S3C2410_RTCALM_ALMEN; | 121 | tmp = readb(s3c_rtc_base + S3C2410_RTCALM) & ~S3C2410_RTCALM_ALMEN; |
@@ -205,7 +203,7 @@ static int s3c_rtc_gettime(struct device *dev, struct rtc_time *rtc_tm) | |||
205 | 203 | ||
206 | rtc_tm->tm_year += 100; | 204 | rtc_tm->tm_year += 100; |
207 | 205 | ||
208 | pr_debug("read time %04d.%02d.%02d %02d:%02d:%02d\n", | 206 | dev_dbg(dev, "read time %04d.%02d.%02d %02d:%02d:%02d\n", |
209 | 1900 + rtc_tm->tm_year, rtc_tm->tm_mon, rtc_tm->tm_mday, | 207 | 1900 + rtc_tm->tm_year, rtc_tm->tm_mon, rtc_tm->tm_mday, |
210 | rtc_tm->tm_hour, rtc_tm->tm_min, rtc_tm->tm_sec); | 208 | rtc_tm->tm_hour, rtc_tm->tm_min, rtc_tm->tm_sec); |
211 | 209 | ||
@@ -220,7 +218,7 @@ static int s3c_rtc_settime(struct device *dev, struct rtc_time *tm) | |||
220 | void __iomem *base = s3c_rtc_base; | 218 | void __iomem *base = s3c_rtc_base; |
221 | int year = tm->tm_year - 100; | 219 | int year = tm->tm_year - 100; |
222 | 220 | ||
223 | pr_debug("set time %04d.%02d.%02d %02d:%02d:%02d\n", | 221 | dev_dbg(dev, "set time %04d.%02d.%02d %02d:%02d:%02d\n", |
224 | 1900 + tm->tm_year, tm->tm_mon, tm->tm_mday, | 222 | 1900 + tm->tm_year, tm->tm_mon, tm->tm_mday, |
225 | tm->tm_hour, tm->tm_min, tm->tm_sec); | 223 | tm->tm_hour, tm->tm_min, tm->tm_sec); |
226 | 224 | ||
@@ -261,7 +259,7 @@ static int s3c_rtc_getalarm(struct device *dev, struct rtc_wkalrm *alrm) | |||
261 | 259 | ||
262 | alrm->enabled = (alm_en & S3C2410_RTCALM_ALMEN) ? 1 : 0; | 260 | alrm->enabled = (alm_en & S3C2410_RTCALM_ALMEN) ? 1 : 0; |
263 | 261 | ||
264 | pr_debug("read alarm %d, %04d.%02d.%02d %02d:%02d:%02d\n", | 262 | dev_dbg(dev, "read alarm %d, %04d.%02d.%02d %02d:%02d:%02d\n", |
265 | alm_en, | 263 | alm_en, |
266 | 1900 + alm_tm->tm_year, alm_tm->tm_mon, alm_tm->tm_mday, | 264 | 1900 + alm_tm->tm_year, alm_tm->tm_mon, alm_tm->tm_mday, |
267 | alm_tm->tm_hour, alm_tm->tm_min, alm_tm->tm_sec); | 265 | alm_tm->tm_hour, alm_tm->tm_min, alm_tm->tm_sec); |
@@ -312,7 +310,7 @@ static int s3c_rtc_setalarm(struct device *dev, struct rtc_wkalrm *alrm) | |||
312 | unsigned int alrm_en; | 310 | unsigned int alrm_en; |
313 | 311 | ||
314 | clk_enable(rtc_clk); | 312 | clk_enable(rtc_clk); |
315 | pr_debug("s3c_rtc_setalarm: %d, %04d.%02d.%02d %02d:%02d:%02d\n", | 313 | dev_dbg(dev, "s3c_rtc_setalarm: %d, %04d.%02d.%02d %02d:%02d:%02d\n", |
316 | alrm->enabled, | 314 | alrm->enabled, |
317 | 1900 + tm->tm_year, tm->tm_mon + 1, tm->tm_mday, | 315 | 1900 + tm->tm_year, tm->tm_mon + 1, tm->tm_mday, |
318 | tm->tm_hour, tm->tm_min, tm->tm_sec); | 316 | tm->tm_hour, tm->tm_min, tm->tm_sec); |
@@ -335,7 +333,7 @@ static int s3c_rtc_setalarm(struct device *dev, struct rtc_wkalrm *alrm) | |||
335 | writeb(bin2bcd(tm->tm_hour), base + S3C2410_ALMHOUR); | 333 | writeb(bin2bcd(tm->tm_hour), base + S3C2410_ALMHOUR); |
336 | } | 334 | } |
337 | 335 | ||
338 | pr_debug("setting S3C2410_RTCALM to %08x\n", alrm_en); | 336 | dev_dbg(dev, "setting S3C2410_RTCALM to %08x\n", alrm_en); |
339 | 337 | ||
340 | writeb(alrm_en, base + S3C2410_RTCALM); | 338 | writeb(alrm_en, base + S3C2410_RTCALM); |
341 | 339 | ||
@@ -423,25 +421,17 @@ static void s3c_rtc_enable(struct platform_device *pdev, int en) | |||
423 | clk_disable(rtc_clk); | 421 | clk_disable(rtc_clk); |
424 | } | 422 | } |
425 | 423 | ||
426 | static int __devexit s3c_rtc_remove(struct platform_device *dev) | 424 | static int s3c_rtc_remove(struct platform_device *dev) |
427 | { | 425 | { |
428 | struct rtc_device *rtc = platform_get_drvdata(dev); | 426 | struct rtc_device *rtc = platform_get_drvdata(dev); |
429 | 427 | ||
430 | free_irq(s3c_rtc_alarmno, rtc); | ||
431 | free_irq(s3c_rtc_tickno, rtc); | ||
432 | |||
433 | platform_set_drvdata(dev, NULL); | 428 | platform_set_drvdata(dev, NULL); |
434 | rtc_device_unregister(rtc); | 429 | rtc_device_unregister(rtc); |
435 | 430 | ||
436 | s3c_rtc_setaie(&dev->dev, 0); | 431 | s3c_rtc_setaie(&dev->dev, 0); |
437 | 432 | ||
438 | clk_put(rtc_clk); | ||
439 | rtc_clk = NULL; | 433 | rtc_clk = NULL; |
440 | 434 | ||
441 | iounmap(s3c_rtc_base); | ||
442 | release_resource(s3c_rtc_mem); | ||
443 | kfree(s3c_rtc_mem); | ||
444 | |||
445 | return 0; | 435 | return 0; |
446 | } | 436 | } |
447 | 437 | ||
@@ -461,7 +451,7 @@ static inline int s3c_rtc_get_driver_data(struct platform_device *pdev) | |||
461 | return platform_get_device_id(pdev)->driver_data; | 451 | return platform_get_device_id(pdev)->driver_data; |
462 | } | 452 | } |
463 | 453 | ||
464 | static int __devinit s3c_rtc_probe(struct platform_device *pdev) | 454 | static int s3c_rtc_probe(struct platform_device *pdev) |
465 | { | 455 | { |
466 | struct rtc_device *rtc; | 456 | struct rtc_device *rtc; |
467 | struct rtc_time rtc_tm; | 457 | struct rtc_time rtc_tm; |
@@ -469,7 +459,7 @@ static int __devinit s3c_rtc_probe(struct platform_device *pdev) | |||
469 | int ret; | 459 | int ret; |
470 | int tmp; | 460 | int tmp; |
471 | 461 | ||
472 | pr_debug("%s: probe=%p\n", __func__, pdev); | 462 | dev_dbg(&pdev->dev, "%s: probe=%p\n", __func__, pdev); |
473 | 463 | ||
474 | /* find the IRQs */ | 464 | /* find the IRQs */ |
475 | 465 | ||
@@ -485,7 +475,7 @@ static int __devinit s3c_rtc_probe(struct platform_device *pdev) | |||
485 | return s3c_rtc_alarmno; | 475 | return s3c_rtc_alarmno; |
486 | } | 476 | } |
487 | 477 | ||
488 | pr_debug("s3c2410_rtc: tick irq %d, alarm irq %d\n", | 478 | dev_dbg(&pdev->dev, "s3c2410_rtc: tick irq %d, alarm irq %d\n", |
489 | s3c_rtc_tickno, s3c_rtc_alarmno); | 479 | s3c_rtc_tickno, s3c_rtc_alarmno); |
490 | 480 | ||
491 | /* get the memory region */ | 481 | /* get the memory region */ |
@@ -496,28 +486,16 @@ static int __devinit s3c_rtc_probe(struct platform_device *pdev) | |||
496 | return -ENOENT; | 486 | return -ENOENT; |
497 | } | 487 | } |
498 | 488 | ||
499 | s3c_rtc_mem = request_mem_region(res->start, resource_size(res), | 489 | s3c_rtc_base = devm_ioremap_resource(&pdev->dev, res); |
500 | pdev->name); | 490 | if (IS_ERR(s3c_rtc_base)) |
501 | 491 | return PTR_ERR(s3c_rtc_base); | |
502 | if (s3c_rtc_mem == NULL) { | ||
503 | dev_err(&pdev->dev, "failed to reserve memory region\n"); | ||
504 | ret = -ENOENT; | ||
505 | goto err_nores; | ||
506 | } | ||
507 | |||
508 | s3c_rtc_base = ioremap(res->start, resource_size(res)); | ||
509 | if (s3c_rtc_base == NULL) { | ||
510 | dev_err(&pdev->dev, "failed ioremap()\n"); | ||
511 | ret = -EINVAL; | ||
512 | goto err_nomap; | ||
513 | } | ||
514 | 492 | ||
515 | rtc_clk = clk_get(&pdev->dev, "rtc"); | 493 | rtc_clk = devm_clk_get(&pdev->dev, "rtc"); |
516 | if (IS_ERR(rtc_clk)) { | 494 | if (IS_ERR(rtc_clk)) { |
517 | dev_err(&pdev->dev, "failed to find rtc clock source\n"); | 495 | dev_err(&pdev->dev, "failed to find rtc clock source\n"); |
518 | ret = PTR_ERR(rtc_clk); | 496 | ret = PTR_ERR(rtc_clk); |
519 | rtc_clk = NULL; | 497 | rtc_clk = NULL; |
520 | goto err_clk; | 498 | return ret; |
521 | } | 499 | } |
522 | 500 | ||
523 | clk_enable(rtc_clk); | 501 | clk_enable(rtc_clk); |
@@ -526,7 +504,7 @@ static int __devinit s3c_rtc_probe(struct platform_device *pdev) | |||
526 | 504 | ||
527 | s3c_rtc_enable(pdev, 1); | 505 | s3c_rtc_enable(pdev, 1); |
528 | 506 | ||
529 | pr_debug("s3c2410_rtc: RTCCON=%02x\n", | 507 | dev_dbg(&pdev->dev, "s3c2410_rtc: RTCCON=%02x\n", |
530 | readw(s3c_rtc_base + S3C2410_RTCCON)); | 508 | readw(s3c_rtc_base + S3C2410_RTCCON)); |
531 | 509 | ||
532 | device_init_wakeup(&pdev->dev, 1); | 510 | device_init_wakeup(&pdev->dev, 1); |
@@ -576,28 +554,24 @@ static int __devinit s3c_rtc_probe(struct platform_device *pdev) | |||
576 | 554 | ||
577 | s3c_rtc_setfreq(&pdev->dev, 1); | 555 | s3c_rtc_setfreq(&pdev->dev, 1); |
578 | 556 | ||
579 | ret = request_irq(s3c_rtc_alarmno, s3c_rtc_alarmirq, | 557 | ret = devm_request_irq(&pdev->dev, s3c_rtc_alarmno, s3c_rtc_alarmirq, |
580 | 0, "s3c2410-rtc alarm", rtc); | 558 | 0, "s3c2410-rtc alarm", rtc); |
581 | if (ret) { | 559 | if (ret) { |
582 | dev_err(&pdev->dev, "IRQ%d error %d\n", s3c_rtc_alarmno, ret); | 560 | dev_err(&pdev->dev, "IRQ%d error %d\n", s3c_rtc_alarmno, ret); |
583 | goto err_alarm_irq; | 561 | goto err_alarm_irq; |
584 | } | 562 | } |
585 | 563 | ||
586 | ret = request_irq(s3c_rtc_tickno, s3c_rtc_tickirq, | 564 | ret = devm_request_irq(&pdev->dev, s3c_rtc_tickno, s3c_rtc_tickirq, |
587 | 0, "s3c2410-rtc tick", rtc); | 565 | 0, "s3c2410-rtc tick", rtc); |
588 | if (ret) { | 566 | if (ret) { |
589 | dev_err(&pdev->dev, "IRQ%d error %d\n", s3c_rtc_tickno, ret); | 567 | dev_err(&pdev->dev, "IRQ%d error %d\n", s3c_rtc_tickno, ret); |
590 | free_irq(s3c_rtc_alarmno, rtc); | 568 | goto err_alarm_irq; |
591 | goto err_tick_irq; | ||
592 | } | 569 | } |
593 | 570 | ||
594 | clk_disable(rtc_clk); | 571 | clk_disable(rtc_clk); |
595 | 572 | ||
596 | return 0; | 573 | return 0; |
597 | 574 | ||
598 | err_tick_irq: | ||
599 | free_irq(s3c_rtc_alarmno, rtc); | ||
600 | |||
601 | err_alarm_irq: | 575 | err_alarm_irq: |
602 | platform_set_drvdata(pdev, NULL); | 576 | platform_set_drvdata(pdev, NULL); |
603 | rtc_device_unregister(rtc); | 577 | rtc_device_unregister(rtc); |
@@ -605,15 +579,7 @@ static int __devinit s3c_rtc_probe(struct platform_device *pdev) | |||
605 | err_nortc: | 579 | err_nortc: |
606 | s3c_rtc_enable(pdev, 0); | 580 | s3c_rtc_enable(pdev, 0); |
607 | clk_disable(rtc_clk); | 581 | clk_disable(rtc_clk); |
608 | clk_put(rtc_clk); | ||
609 | 582 | ||
610 | err_clk: | ||
611 | iounmap(s3c_rtc_base); | ||
612 | |||
613 | err_nomap: | ||
614 | release_resource(s3c_rtc_mem); | ||
615 | |||
616 | err_nores: | ||
617 | return ret; | 583 | return ret; |
618 | } | 584 | } |
619 | 585 | ||
@@ -695,8 +661,6 @@ static const struct of_device_id s3c_rtc_dt_match[] = { | |||
695 | {}, | 661 | {}, |
696 | }; | 662 | }; |
697 | MODULE_DEVICE_TABLE(of, s3c_rtc_dt_match); | 663 | MODULE_DEVICE_TABLE(of, s3c_rtc_dt_match); |
698 | #else | ||
699 | #define s3c_rtc_dt_match NULL | ||
700 | #endif | 664 | #endif |
701 | 665 | ||
702 | static struct platform_device_id s3c_rtc_driver_ids[] = { | 666 | static struct platform_device_id s3c_rtc_driver_ids[] = { |
@@ -720,14 +684,14 @@ MODULE_DEVICE_TABLE(platform, s3c_rtc_driver_ids); | |||
720 | 684 | ||
721 | static struct platform_driver s3c_rtc_driver = { | 685 | static struct platform_driver s3c_rtc_driver = { |
722 | .probe = s3c_rtc_probe, | 686 | .probe = s3c_rtc_probe, |
723 | .remove = __devexit_p(s3c_rtc_remove), | 687 | .remove = s3c_rtc_remove, |
724 | .suspend = s3c_rtc_suspend, | 688 | .suspend = s3c_rtc_suspend, |
725 | .resume = s3c_rtc_resume, | 689 | .resume = s3c_rtc_resume, |
726 | .id_table = s3c_rtc_driver_ids, | 690 | .id_table = s3c_rtc_driver_ids, |
727 | .driver = { | 691 | .driver = { |
728 | .name = "s3c-rtc", | 692 | .name = "s3c-rtc", |
729 | .owner = THIS_MODULE, | 693 | .owner = THIS_MODULE, |
730 | .of_match_table = s3c_rtc_dt_match, | 694 | .of_match_table = of_match_ptr(s3c_rtc_dt_match), |
731 | }, | 695 | }, |
732 | }; | 696 | }; |
733 | 697 | ||