Lines Matching refs:info

61 	void (*irq_handler) (struct s3c_rtc *info, int mask);
62 void (*set_freq) (struct s3c_rtc *info, int freq);
63 void (*enable_tick) (struct s3c_rtc *info, struct seq_file *seq);
64 void (*select_tick_clk) (struct s3c_rtc *info);
65 void (*save_tick_cnt) (struct s3c_rtc *info);
66 void (*restore_tick_cnt) (struct s3c_rtc *info);
67 void (*enable) (struct s3c_rtc *info);
68 void (*disable) (struct s3c_rtc *info);
71 static int s3c_rtc_enable_clk(struct s3c_rtc *info) in s3c_rtc_enable_clk() argument
76 spin_lock_irqsave(&info->alarm_clk_lock, irq_flags); in s3c_rtc_enable_clk()
78 if (info->clk_disabled) { in s3c_rtc_enable_clk()
79 ret = clk_enable(info->rtc_clk); in s3c_rtc_enable_clk()
83 if (info->data->needs_src_clk) { in s3c_rtc_enable_clk()
84 ret = clk_enable(info->rtc_src_clk); in s3c_rtc_enable_clk()
86 clk_disable(info->rtc_clk); in s3c_rtc_enable_clk()
90 info->clk_disabled = false; in s3c_rtc_enable_clk()
94 spin_unlock_irqrestore(&info->alarm_clk_lock, irq_flags); in s3c_rtc_enable_clk()
99 static void s3c_rtc_disable_clk(struct s3c_rtc *info) in s3c_rtc_disable_clk() argument
103 spin_lock_irqsave(&info->alarm_clk_lock, irq_flags); in s3c_rtc_disable_clk()
104 if (!info->clk_disabled) { in s3c_rtc_disable_clk()
105 if (info->data->needs_src_clk) in s3c_rtc_disable_clk()
106 clk_disable(info->rtc_src_clk); in s3c_rtc_disable_clk()
107 clk_disable(info->rtc_clk); in s3c_rtc_disable_clk()
108 info->clk_disabled = true; in s3c_rtc_disable_clk()
110 spin_unlock_irqrestore(&info->alarm_clk_lock, irq_flags); in s3c_rtc_disable_clk()
116 struct s3c_rtc *info = (struct s3c_rtc *)id; in s3c_rtc_tickirq() local
118 if (info->data->irq_handler) in s3c_rtc_tickirq()
119 info->data->irq_handler(info, S3C2410_INTP_TIC); in s3c_rtc_tickirq()
126 struct s3c_rtc *info = (struct s3c_rtc *)id; in s3c_rtc_alarmirq() local
128 if (info->data->irq_handler) in s3c_rtc_alarmirq()
129 info->data->irq_handler(info, S3C2410_INTP_ALM); in s3c_rtc_alarmirq()
137 struct s3c_rtc *info = dev_get_drvdata(dev); in s3c_rtc_setaie() local
141 dev_dbg(info->dev, "%s: aie=%d\n", __func__, enabled); in s3c_rtc_setaie()
143 ret = s3c_rtc_enable_clk(info); in s3c_rtc_setaie()
147 tmp = readb(info->base + S3C2410_RTCALM) & ~S3C2410_RTCALM_ALMEN; in s3c_rtc_setaie()
152 writeb(tmp, info->base + S3C2410_RTCALM); in s3c_rtc_setaie()
154 s3c_rtc_disable_clk(info); in s3c_rtc_setaie()
157 ret = s3c_rtc_enable_clk(info); in s3c_rtc_setaie()
161 s3c_rtc_disable_clk(info); in s3c_rtc_setaie()
168 static int s3c_rtc_setfreq(struct s3c_rtc *info, int freq) in s3c_rtc_setfreq() argument
175 ret = s3c_rtc_enable_clk(info); in s3c_rtc_setfreq()
178 spin_lock_irq(&info->pie_lock); in s3c_rtc_setfreq()
180 if (info->data->set_freq) in s3c_rtc_setfreq()
181 info->data->set_freq(info, freq); in s3c_rtc_setfreq()
183 spin_unlock_irq(&info->pie_lock); in s3c_rtc_setfreq()
184 s3c_rtc_disable_clk(info); in s3c_rtc_setfreq()
192 struct s3c_rtc *info = dev_get_drvdata(dev); in s3c_rtc_gettime() local
196 ret = s3c_rtc_enable_clk(info); in s3c_rtc_gettime()
201 rtc_tm->tm_min = readb(info->base + S3C2410_RTCMIN); in s3c_rtc_gettime()
202 rtc_tm->tm_hour = readb(info->base + S3C2410_RTCHOUR); in s3c_rtc_gettime()
203 rtc_tm->tm_mday = readb(info->base + S3C2410_RTCDATE); in s3c_rtc_gettime()
204 rtc_tm->tm_mon = readb(info->base + S3C2410_RTCMON); in s3c_rtc_gettime()
205 rtc_tm->tm_year = readb(info->base + S3C2410_RTCYEAR); in s3c_rtc_gettime()
206 rtc_tm->tm_sec = readb(info->base + S3C2410_RTCSEC); in s3c_rtc_gettime()
225 s3c_rtc_disable_clk(info); in s3c_rtc_gettime()
240 struct s3c_rtc *info = dev_get_drvdata(dev); in s3c_rtc_settime() local
255 ret = s3c_rtc_enable_clk(info); in s3c_rtc_settime()
259 writeb(bin2bcd(tm->tm_sec), info->base + S3C2410_RTCSEC); in s3c_rtc_settime()
260 writeb(bin2bcd(tm->tm_min), info->base + S3C2410_RTCMIN); in s3c_rtc_settime()
261 writeb(bin2bcd(tm->tm_hour), info->base + S3C2410_RTCHOUR); in s3c_rtc_settime()
262 writeb(bin2bcd(tm->tm_mday), info->base + S3C2410_RTCDATE); in s3c_rtc_settime()
263 writeb(bin2bcd(tm->tm_mon + 1), info->base + S3C2410_RTCMON); in s3c_rtc_settime()
264 writeb(bin2bcd(year), info->base + S3C2410_RTCYEAR); in s3c_rtc_settime()
266 s3c_rtc_disable_clk(info); in s3c_rtc_settime()
273 struct s3c_rtc *info = dev_get_drvdata(dev); in s3c_rtc_getalarm() local
278 ret = s3c_rtc_enable_clk(info); in s3c_rtc_getalarm()
282 alm_tm->tm_sec = readb(info->base + S3C2410_ALMSEC); in s3c_rtc_getalarm()
283 alm_tm->tm_min = readb(info->base + S3C2410_ALMMIN); in s3c_rtc_getalarm()
284 alm_tm->tm_hour = readb(info->base + S3C2410_ALMHOUR); in s3c_rtc_getalarm()
285 alm_tm->tm_mon = readb(info->base + S3C2410_ALMMON); in s3c_rtc_getalarm()
286 alm_tm->tm_mday = readb(info->base + S3C2410_ALMDATE); in s3c_rtc_getalarm()
287 alm_tm->tm_year = readb(info->base + S3C2410_ALMYEAR); in s3c_rtc_getalarm()
289 alm_en = readb(info->base + S3C2410_RTCALM); in s3c_rtc_getalarm()
291 s3c_rtc_disable_clk(info); in s3c_rtc_getalarm()
326 struct s3c_rtc *info = dev_get_drvdata(dev); in s3c_rtc_setalarm() local
336 ret = s3c_rtc_enable_clk(info); in s3c_rtc_setalarm()
340 alrm_en = readb(info->base + S3C2410_RTCALM) & S3C2410_RTCALM_ALMEN; in s3c_rtc_setalarm()
341 writeb(0x00, info->base + S3C2410_RTCALM); in s3c_rtc_setalarm()
345 writeb(bin2bcd(tm->tm_sec), info->base + S3C2410_ALMSEC); in s3c_rtc_setalarm()
350 writeb(bin2bcd(tm->tm_min), info->base + S3C2410_ALMMIN); in s3c_rtc_setalarm()
355 writeb(bin2bcd(tm->tm_hour), info->base + S3C2410_ALMHOUR); in s3c_rtc_setalarm()
360 writeb(bin2bcd(tm->tm_mon + 1), info->base + S3C2410_ALMMON); in s3c_rtc_setalarm()
365 writeb(bin2bcd(tm->tm_mday), info->base + S3C2410_ALMDATE); in s3c_rtc_setalarm()
370 writeb(alrm_en, info->base + S3C2410_RTCALM); in s3c_rtc_setalarm()
372 s3c_rtc_disable_clk(info); in s3c_rtc_setalarm()
381 struct s3c_rtc *info = dev_get_drvdata(dev); in s3c_rtc_proc() local
384 ret = s3c_rtc_enable_clk(info); in s3c_rtc_proc()
388 if (info->data->enable_tick) in s3c_rtc_proc()
389 info->data->enable_tick(info, seq); in s3c_rtc_proc()
391 s3c_rtc_disable_clk(info); in s3c_rtc_proc()
405 static void s3c24xx_rtc_enable(struct s3c_rtc *info) in s3c24xx_rtc_enable() argument
409 con = readw(info->base + S3C2410_RTCCON); in s3c24xx_rtc_enable()
412 dev_info(info->dev, "rtc disabled, re-enabling\n"); in s3c24xx_rtc_enable()
414 tmp = readw(info->base + S3C2410_RTCCON); in s3c24xx_rtc_enable()
415 writew(tmp | S3C2410_RTCCON_RTCEN, info->base + S3C2410_RTCCON); in s3c24xx_rtc_enable()
419 dev_info(info->dev, "removing RTCCON_CNTSEL\n"); in s3c24xx_rtc_enable()
421 tmp = readw(info->base + S3C2410_RTCCON); in s3c24xx_rtc_enable()
423 info->base + S3C2410_RTCCON); in s3c24xx_rtc_enable()
427 dev_info(info->dev, "removing RTCCON_CLKRST\n"); in s3c24xx_rtc_enable()
429 tmp = readw(info->base + S3C2410_RTCCON); in s3c24xx_rtc_enable()
431 info->base + S3C2410_RTCCON); in s3c24xx_rtc_enable()
435 static void s3c24xx_rtc_disable(struct s3c_rtc *info) in s3c24xx_rtc_disable() argument
439 con = readw(info->base + S3C2410_RTCCON); in s3c24xx_rtc_disable()
441 writew(con, info->base + S3C2410_RTCCON); in s3c24xx_rtc_disable()
443 con = readb(info->base + S3C2410_TICNT); in s3c24xx_rtc_disable()
445 writeb(con, info->base + S3C2410_TICNT); in s3c24xx_rtc_disable()
448 static void s3c6410_rtc_disable(struct s3c_rtc *info) in s3c6410_rtc_disable() argument
452 con = readw(info->base + S3C2410_RTCCON); in s3c6410_rtc_disable()
455 writew(con, info->base + S3C2410_RTCCON); in s3c6410_rtc_disable()
460 struct s3c_rtc *info = platform_get_drvdata(pdev); in s3c_rtc_remove() local
462 s3c_rtc_setaie(info->dev, 0); in s3c_rtc_remove()
464 if (info->data->needs_src_clk) in s3c_rtc_remove()
465 clk_unprepare(info->rtc_src_clk); in s3c_rtc_remove()
466 clk_unprepare(info->rtc_clk); in s3c_rtc_remove()
483 struct s3c_rtc *info = NULL; in s3c_rtc_probe() local
488 info = devm_kzalloc(&pdev->dev, sizeof(*info), GFP_KERNEL); in s3c_rtc_probe()
489 if (!info) in s3c_rtc_probe()
493 info->irq_tick = platform_get_irq(pdev, 1); in s3c_rtc_probe()
494 if (info->irq_tick < 0) { in s3c_rtc_probe()
496 return info->irq_tick; in s3c_rtc_probe()
499 info->dev = &pdev->dev; in s3c_rtc_probe()
500 info->data = s3c_rtc_get_data(pdev); in s3c_rtc_probe()
501 if (!info->data) { in s3c_rtc_probe()
505 spin_lock_init(&info->pie_lock); in s3c_rtc_probe()
506 spin_lock_init(&info->alarm_clk_lock); in s3c_rtc_probe()
508 platform_set_drvdata(pdev, info); in s3c_rtc_probe()
510 info->irq_alarm = platform_get_irq(pdev, 0); in s3c_rtc_probe()
511 if (info->irq_alarm < 0) { in s3c_rtc_probe()
513 return info->irq_alarm; in s3c_rtc_probe()
517 info->irq_tick, info->irq_alarm); in s3c_rtc_probe()
521 info->base = devm_ioremap_resource(&pdev->dev, res); in s3c_rtc_probe()
522 if (IS_ERR(info->base)) in s3c_rtc_probe()
523 return PTR_ERR(info->base); in s3c_rtc_probe()
525 info->rtc_clk = devm_clk_get(&pdev->dev, "rtc"); in s3c_rtc_probe()
526 if (IS_ERR(info->rtc_clk)) { in s3c_rtc_probe()
527 ret = PTR_ERR(info->rtc_clk); in s3c_rtc_probe()
534 ret = clk_prepare_enable(info->rtc_clk); in s3c_rtc_probe()
538 if (info->data->needs_src_clk) { in s3c_rtc_probe()
539 info->rtc_src_clk = devm_clk_get(&pdev->dev, "rtc_src"); in s3c_rtc_probe()
540 if (IS_ERR(info->rtc_src_clk)) { in s3c_rtc_probe()
541 ret = PTR_ERR(info->rtc_src_clk); in s3c_rtc_probe()
550 ret = clk_prepare_enable(info->rtc_src_clk); in s3c_rtc_probe()
556 if (info->data->enable) in s3c_rtc_probe()
557 info->data->enable(info); in s3c_rtc_probe()
560 readw(info->base + S3C2410_RTCCON)); in s3c_rtc_probe()
579 info->rtc = devm_rtc_device_register(&pdev->dev, "s3c", &s3c_rtcops, in s3c_rtc_probe()
581 if (IS_ERR(info->rtc)) { in s3c_rtc_probe()
583 ret = PTR_ERR(info->rtc); in s3c_rtc_probe()
587 ret = devm_request_irq(&pdev->dev, info->irq_alarm, s3c_rtc_alarmirq, in s3c_rtc_probe()
588 0, "s3c2410-rtc alarm", info); in s3c_rtc_probe()
590 dev_err(&pdev->dev, "IRQ%d error %d\n", info->irq_alarm, ret); in s3c_rtc_probe()
594 ret = devm_request_irq(&pdev->dev, info->irq_tick, s3c_rtc_tickirq, in s3c_rtc_probe()
595 0, "s3c2410-rtc tick", info); in s3c_rtc_probe()
597 dev_err(&pdev->dev, "IRQ%d error %d\n", info->irq_tick, ret); in s3c_rtc_probe()
601 if (info->data->select_tick_clk) in s3c_rtc_probe()
602 info->data->select_tick_clk(info); in s3c_rtc_probe()
604 s3c_rtc_setfreq(info, 1); in s3c_rtc_probe()
609 if (info->data->disable) in s3c_rtc_probe()
610 info->data->disable(info); in s3c_rtc_probe()
612 if (info->data->needs_src_clk) in s3c_rtc_probe()
613 clk_disable_unprepare(info->rtc_src_clk); in s3c_rtc_probe()
615 clk_disable_unprepare(info->rtc_clk); in s3c_rtc_probe()
624 struct s3c_rtc *info = dev_get_drvdata(dev); in s3c_rtc_suspend() local
627 ret = s3c_rtc_enable_clk(info); in s3c_rtc_suspend()
632 if (info->data->save_tick_cnt) in s3c_rtc_suspend()
633 info->data->save_tick_cnt(info); in s3c_rtc_suspend()
635 if (info->data->disable) in s3c_rtc_suspend()
636 info->data->disable(info); in s3c_rtc_suspend()
638 if (device_may_wakeup(dev) && !info->wake_en) { in s3c_rtc_suspend()
639 if (enable_irq_wake(info->irq_alarm) == 0) in s3c_rtc_suspend()
640 info->wake_en = true; in s3c_rtc_suspend()
650 struct s3c_rtc *info = dev_get_drvdata(dev); in s3c_rtc_resume() local
652 if (info->data->enable) in s3c_rtc_resume()
653 info->data->enable(info); in s3c_rtc_resume()
655 if (info->data->restore_tick_cnt) in s3c_rtc_resume()
656 info->data->restore_tick_cnt(info); in s3c_rtc_resume()
658 s3c_rtc_disable_clk(info); in s3c_rtc_resume()
660 if (device_may_wakeup(dev) && info->wake_en) { in s3c_rtc_resume()
661 disable_irq_wake(info->irq_alarm); in s3c_rtc_resume()
662 info->wake_en = false; in s3c_rtc_resume()
670 static void s3c24xx_rtc_irq(struct s3c_rtc *info, int mask) in s3c24xx_rtc_irq() argument
672 rtc_update_irq(info->rtc, 1, RTC_AF | RTC_IRQF); in s3c24xx_rtc_irq()
675 static void s3c6410_rtc_irq(struct s3c_rtc *info, int mask) in s3c6410_rtc_irq() argument
677 rtc_update_irq(info->rtc, 1, RTC_AF | RTC_IRQF); in s3c6410_rtc_irq()
678 writeb(mask, info->base + S3C2410_INTP); in s3c6410_rtc_irq()
681 static void s3c2410_rtc_setfreq(struct s3c_rtc *info, int freq) in s3c2410_rtc_setfreq() argument
686 tmp = readb(info->base + S3C2410_TICNT); in s3c2410_rtc_setfreq()
689 val = (info->rtc->max_user_freq / freq) - 1; in s3c2410_rtc_setfreq()
692 writel(tmp, info->base + S3C2410_TICNT); in s3c2410_rtc_setfreq()
695 static void s3c2416_rtc_setfreq(struct s3c_rtc *info, int freq) in s3c2416_rtc_setfreq() argument
700 tmp = readb(info->base + S3C2410_TICNT); in s3c2416_rtc_setfreq()
703 val = (info->rtc->max_user_freq / freq) - 1; in s3c2416_rtc_setfreq()
706 writel(S3C2443_TICNT1_PART(val), info->base + S3C2443_TICNT1); in s3c2416_rtc_setfreq()
708 writel(S3C2416_TICNT2_PART(val), info->base + S3C2416_TICNT2); in s3c2416_rtc_setfreq()
710 writel(tmp, info->base + S3C2410_TICNT); in s3c2416_rtc_setfreq()
713 static void s3c2443_rtc_setfreq(struct s3c_rtc *info, int freq) in s3c2443_rtc_setfreq() argument
718 tmp = readb(info->base + S3C2410_TICNT); in s3c2443_rtc_setfreq()
721 val = (info->rtc->max_user_freq / freq) - 1; in s3c2443_rtc_setfreq()
724 writel(S3C2443_TICNT1_PART(val), info->base + S3C2443_TICNT1); in s3c2443_rtc_setfreq()
726 writel(tmp, info->base + S3C2410_TICNT); in s3c2443_rtc_setfreq()
729 static void s3c6410_rtc_setfreq(struct s3c_rtc *info, int freq) in s3c6410_rtc_setfreq() argument
733 val = (info->rtc->max_user_freq / freq) - 1; in s3c6410_rtc_setfreq()
734 writel(val, info->base + S3C2410_TICNT); in s3c6410_rtc_setfreq()
737 static void s3c24xx_rtc_enable_tick(struct s3c_rtc *info, struct seq_file *seq) in s3c24xx_rtc_enable_tick() argument
741 ticnt = readb(info->base + S3C2410_TICNT); in s3c24xx_rtc_enable_tick()
747 static void s3c2416_rtc_select_tick_clk(struct s3c_rtc *info) in s3c2416_rtc_select_tick_clk() argument
751 con = readw(info->base + S3C2410_RTCCON); in s3c2416_rtc_select_tick_clk()
753 writew(con, info->base + S3C2410_RTCCON); in s3c2416_rtc_select_tick_clk()
756 static void s3c6410_rtc_enable_tick(struct s3c_rtc *info, struct seq_file *seq) in s3c6410_rtc_enable_tick() argument
760 ticnt = readw(info->base + S3C2410_RTCCON); in s3c6410_rtc_enable_tick()
766 static void s3c24xx_rtc_save_tick_cnt(struct s3c_rtc *info) in s3c24xx_rtc_save_tick_cnt() argument
768 info->ticnt_save = readb(info->base + S3C2410_TICNT); in s3c24xx_rtc_save_tick_cnt()
771 static void s3c24xx_rtc_restore_tick_cnt(struct s3c_rtc *info) in s3c24xx_rtc_restore_tick_cnt() argument
773 writeb(info->ticnt_save, info->base + S3C2410_TICNT); in s3c24xx_rtc_restore_tick_cnt()
776 static void s3c6410_rtc_save_tick_cnt(struct s3c_rtc *info) in s3c6410_rtc_save_tick_cnt() argument
778 info->ticnt_en_save = readw(info->base + S3C2410_RTCCON); in s3c6410_rtc_save_tick_cnt()
779 info->ticnt_en_save &= S3C64XX_RTCCON_TICEN; in s3c6410_rtc_save_tick_cnt()
780 info->ticnt_save = readl(info->base + S3C2410_TICNT); in s3c6410_rtc_save_tick_cnt()
783 static void s3c6410_rtc_restore_tick_cnt(struct s3c_rtc *info) in s3c6410_rtc_restore_tick_cnt() argument
787 writel(info->ticnt_save, info->base + S3C2410_TICNT); in s3c6410_rtc_restore_tick_cnt()
788 if (info->ticnt_en_save) { in s3c6410_rtc_restore_tick_cnt()
789 con = readw(info->base + S3C2410_RTCCON); in s3c6410_rtc_restore_tick_cnt()
790 writew(con | info->ticnt_en_save, info->base + S3C2410_RTCCON); in s3c6410_rtc_restore_tick_cnt()