Lines Matching refs:info
52 void (*irq_handler) (struct s3c_rtc *info, int mask);
53 void (*enable) (struct s3c_rtc *info);
54 void (*disable) (struct s3c_rtc *info);
57 static int s3c_rtc_enable_clk(struct s3c_rtc *info) in s3c_rtc_enable_clk() argument
61 ret = clk_enable(info->rtc_clk); in s3c_rtc_enable_clk()
65 if (info->data->needs_src_clk) { in s3c_rtc_enable_clk()
66 ret = clk_enable(info->rtc_src_clk); in s3c_rtc_enable_clk()
68 clk_disable(info->rtc_clk); in s3c_rtc_enable_clk()
75 static void s3c_rtc_disable_clk(struct s3c_rtc *info) in s3c_rtc_disable_clk() argument
77 if (info->data->needs_src_clk) in s3c_rtc_disable_clk()
78 clk_disable(info->rtc_src_clk); in s3c_rtc_disable_clk()
79 clk_disable(info->rtc_clk); in s3c_rtc_disable_clk()
85 struct s3c_rtc *info = (struct s3c_rtc *)id; in s3c_rtc_alarmirq() local
87 if (info->data->irq_handler) in s3c_rtc_alarmirq()
88 info->data->irq_handler(info, S3C2410_INTP_ALM); in s3c_rtc_alarmirq()
96 struct s3c_rtc *info = dev_get_drvdata(dev); in s3c_rtc_setaie() local
101 dev_dbg(info->dev, "%s: aie=%d\n", __func__, enabled); in s3c_rtc_setaie()
103 ret = s3c_rtc_enable_clk(info); in s3c_rtc_setaie()
107 tmp = readb(info->base + S3C2410_RTCALM) & ~S3C2410_RTCALM_ALMEN; in s3c_rtc_setaie()
112 writeb(tmp, info->base + S3C2410_RTCALM); in s3c_rtc_setaie()
114 spin_lock_irqsave(&info->alarm_lock, flags); in s3c_rtc_setaie()
116 if (info->alarm_enabled && !enabled) in s3c_rtc_setaie()
117 s3c_rtc_disable_clk(info); in s3c_rtc_setaie()
118 else if (!info->alarm_enabled && enabled) in s3c_rtc_setaie()
119 ret = s3c_rtc_enable_clk(info); in s3c_rtc_setaie()
121 info->alarm_enabled = enabled; in s3c_rtc_setaie()
122 spin_unlock_irqrestore(&info->alarm_lock, flags); in s3c_rtc_setaie()
124 s3c_rtc_disable_clk(info); in s3c_rtc_setaie()
130 static int s3c_rtc_read_time(struct s3c_rtc *info, struct rtc_time *tm) in s3c_rtc_read_time() argument
135 ret = s3c_rtc_enable_clk(info); in s3c_rtc_read_time()
140 tm->tm_min = readb(info->base + S3C2410_RTCMIN); in s3c_rtc_read_time()
141 tm->tm_hour = readb(info->base + S3C2410_RTCHOUR); in s3c_rtc_read_time()
142 tm->tm_mday = readb(info->base + S3C2410_RTCDATE); in s3c_rtc_read_time()
143 tm->tm_mon = readb(info->base + S3C2410_RTCMON); in s3c_rtc_read_time()
144 tm->tm_year = readb(info->base + S3C2410_RTCYEAR); in s3c_rtc_read_time()
145 tm->tm_sec = readb(info->base + S3C2410_RTCSEC); in s3c_rtc_read_time()
157 s3c_rtc_disable_clk(info); in s3c_rtc_read_time()
170 static int s3c_rtc_write_time(struct s3c_rtc *info, const struct rtc_time *tm) in s3c_rtc_write_time() argument
174 ret = s3c_rtc_enable_clk(info); in s3c_rtc_write_time()
178 writeb(bin2bcd(tm->tm_sec), info->base + S3C2410_RTCSEC); in s3c_rtc_write_time()
179 writeb(bin2bcd(tm->tm_min), info->base + S3C2410_RTCMIN); in s3c_rtc_write_time()
180 writeb(bin2bcd(tm->tm_hour), info->base + S3C2410_RTCHOUR); in s3c_rtc_write_time()
181 writeb(bin2bcd(tm->tm_mday), info->base + S3C2410_RTCDATE); in s3c_rtc_write_time()
182 writeb(bin2bcd(tm->tm_mon), info->base + S3C2410_RTCMON); in s3c_rtc_write_time()
183 writeb(bin2bcd(tm->tm_year), info->base + S3C2410_RTCYEAR); in s3c_rtc_write_time()
185 s3c_rtc_disable_clk(info); in s3c_rtc_write_time()
192 struct s3c_rtc *info = dev_get_drvdata(dev); in s3c_rtc_gettime() local
195 ret = s3c_rtc_read_time(info, tm); in s3c_rtc_gettime()
209 struct s3c_rtc *info = dev_get_drvdata(dev); in s3c_rtc_settime() local
221 return s3c_rtc_write_time(info, &rtc_tm); in s3c_rtc_settime()
226 struct s3c_rtc *info = dev_get_drvdata(dev); in s3c_rtc_getalarm() local
231 ret = s3c_rtc_enable_clk(info); in s3c_rtc_getalarm()
235 alm_tm->tm_sec = readb(info->base + S3C2410_ALMSEC); in s3c_rtc_getalarm()
236 alm_tm->tm_min = readb(info->base + S3C2410_ALMMIN); in s3c_rtc_getalarm()
237 alm_tm->tm_hour = readb(info->base + S3C2410_ALMHOUR); in s3c_rtc_getalarm()
238 alm_tm->tm_mon = readb(info->base + S3C2410_ALMMON); in s3c_rtc_getalarm()
239 alm_tm->tm_mday = readb(info->base + S3C2410_ALMDATE); in s3c_rtc_getalarm()
240 alm_tm->tm_year = readb(info->base + S3C2410_ALMYEAR); in s3c_rtc_getalarm()
242 alm_en = readb(info->base + S3C2410_RTCALM); in s3c_rtc_getalarm()
244 s3c_rtc_disable_clk(info); in s3c_rtc_getalarm()
276 struct s3c_rtc *info = dev_get_drvdata(dev); in s3c_rtc_setalarm() local
283 ret = s3c_rtc_enable_clk(info); in s3c_rtc_setalarm()
287 alrm_en = readb(info->base + S3C2410_RTCALM) & S3C2410_RTCALM_ALMEN; in s3c_rtc_setalarm()
288 writeb(0x00, info->base + S3C2410_RTCALM); in s3c_rtc_setalarm()
292 writeb(bin2bcd(tm->tm_sec), info->base + S3C2410_ALMSEC); in s3c_rtc_setalarm()
297 writeb(bin2bcd(tm->tm_min), info->base + S3C2410_ALMMIN); in s3c_rtc_setalarm()
302 writeb(bin2bcd(tm->tm_hour), info->base + S3C2410_ALMHOUR); in s3c_rtc_setalarm()
307 writeb(bin2bcd(tm->tm_mon + 1), info->base + S3C2410_ALMMON); in s3c_rtc_setalarm()
312 writeb(bin2bcd(tm->tm_mday), info->base + S3C2410_ALMDATE); in s3c_rtc_setalarm()
317 writeb(alrm_en, info->base + S3C2410_RTCALM); in s3c_rtc_setalarm()
321 s3c_rtc_disable_clk(info); in s3c_rtc_setalarm()
334 static void s3c24xx_rtc_enable(struct s3c_rtc *info) in s3c24xx_rtc_enable() argument
338 con = readw(info->base + S3C2410_RTCCON); in s3c24xx_rtc_enable()
341 dev_info(info->dev, "rtc disabled, re-enabling\n"); in s3c24xx_rtc_enable()
343 tmp = readw(info->base + S3C2410_RTCCON); in s3c24xx_rtc_enable()
344 writew(tmp | S3C2410_RTCCON_RTCEN, info->base + S3C2410_RTCCON); in s3c24xx_rtc_enable()
348 dev_info(info->dev, "removing RTCCON_CNTSEL\n"); in s3c24xx_rtc_enable()
350 tmp = readw(info->base + S3C2410_RTCCON); in s3c24xx_rtc_enable()
352 info->base + S3C2410_RTCCON); in s3c24xx_rtc_enable()
356 dev_info(info->dev, "removing RTCCON_CLKRST\n"); in s3c24xx_rtc_enable()
358 tmp = readw(info->base + S3C2410_RTCCON); in s3c24xx_rtc_enable()
360 info->base + S3C2410_RTCCON); in s3c24xx_rtc_enable()
364 static void s3c24xx_rtc_disable(struct s3c_rtc *info) in s3c24xx_rtc_disable() argument
368 con = readw(info->base + S3C2410_RTCCON); in s3c24xx_rtc_disable()
370 writew(con, info->base + S3C2410_RTCCON); in s3c24xx_rtc_disable()
372 con = readb(info->base + S3C2410_TICNT); in s3c24xx_rtc_disable()
374 writeb(con, info->base + S3C2410_TICNT); in s3c24xx_rtc_disable()
377 static void s3c6410_rtc_disable(struct s3c_rtc *info) in s3c6410_rtc_disable() argument
381 con = readw(info->base + S3C2410_RTCCON); in s3c6410_rtc_disable()
384 writew(con, info->base + S3C2410_RTCCON); in s3c6410_rtc_disable()
389 struct s3c_rtc *info = platform_get_drvdata(pdev); in s3c_rtc_remove() local
391 s3c_rtc_setaie(info->dev, 0); in s3c_rtc_remove()
393 if (info->data->needs_src_clk) in s3c_rtc_remove()
394 clk_unprepare(info->rtc_src_clk); in s3c_rtc_remove()
395 clk_unprepare(info->rtc_clk); in s3c_rtc_remove()
400 struct s3c_rtc *info = NULL; in s3c_rtc_probe() local
403 info = devm_kzalloc(&pdev->dev, sizeof(*info), GFP_KERNEL); in s3c_rtc_probe()
404 if (!info) in s3c_rtc_probe()
407 info->dev = &pdev->dev; in s3c_rtc_probe()
408 info->data = of_device_get_match_data(&pdev->dev); in s3c_rtc_probe()
409 if (!info->data) { in s3c_rtc_probe()
413 spin_lock_init(&info->alarm_lock); in s3c_rtc_probe()
415 platform_set_drvdata(pdev, info); in s3c_rtc_probe()
417 info->irq_alarm = platform_get_irq(pdev, 0); in s3c_rtc_probe()
418 if (info->irq_alarm < 0) in s3c_rtc_probe()
419 return info->irq_alarm; in s3c_rtc_probe()
421 dev_dbg(&pdev->dev, "s3c2410_rtc: alarm irq %d\n", info->irq_alarm); in s3c_rtc_probe()
424 info->base = devm_platform_ioremap_resource(pdev, 0); in s3c_rtc_probe()
425 if (IS_ERR(info->base)) in s3c_rtc_probe()
426 return PTR_ERR(info->base); in s3c_rtc_probe()
428 info->rtc_clk = devm_clk_get(&pdev->dev, "rtc"); in s3c_rtc_probe()
429 if (IS_ERR(info->rtc_clk)) in s3c_rtc_probe()
430 return dev_err_probe(&pdev->dev, PTR_ERR(info->rtc_clk), in s3c_rtc_probe()
432 ret = clk_prepare_enable(info->rtc_clk); in s3c_rtc_probe()
436 if (info->data->needs_src_clk) { in s3c_rtc_probe()
437 info->rtc_src_clk = devm_clk_get(&pdev->dev, "rtc_src"); in s3c_rtc_probe()
438 if (IS_ERR(info->rtc_src_clk)) { in s3c_rtc_probe()
439 ret = dev_err_probe(&pdev->dev, PTR_ERR(info->rtc_src_clk), in s3c_rtc_probe()
443 ret = clk_prepare_enable(info->rtc_src_clk); in s3c_rtc_probe()
449 if (info->data->disable) in s3c_rtc_probe()
450 info->data->disable(info); in s3c_rtc_probe()
453 if (info->data->enable) in s3c_rtc_probe()
454 info->data->enable(info); in s3c_rtc_probe()
457 readw(info->base + S3C2410_RTCCON)); in s3c_rtc_probe()
461 info->rtc = devm_rtc_allocate_device(&pdev->dev); in s3c_rtc_probe()
462 if (IS_ERR(info->rtc)) { in s3c_rtc_probe()
463 ret = PTR_ERR(info->rtc); in s3c_rtc_probe()
467 info->rtc->ops = &s3c_rtcops; in s3c_rtc_probe()
468 info->rtc->range_min = RTC_TIMESTAMP_BEGIN_2000; in s3c_rtc_probe()
469 info->rtc->range_max = RTC_TIMESTAMP_END_2099; in s3c_rtc_probe()
471 ret = devm_rtc_register_device(info->rtc); in s3c_rtc_probe()
475 ret = devm_request_irq(&pdev->dev, info->irq_alarm, s3c_rtc_alarmirq, in s3c_rtc_probe()
476 0, "s3c2410-rtc alarm", info); in s3c_rtc_probe()
478 dev_err(&pdev->dev, "IRQ%d error %d\n", info->irq_alarm, ret); in s3c_rtc_probe()
482 s3c_rtc_disable_clk(info); in s3c_rtc_probe()
487 if (info->data->disable) in s3c_rtc_probe()
488 info->data->disable(info); in s3c_rtc_probe()
490 if (info->data->needs_src_clk) in s3c_rtc_probe()
491 clk_disable_unprepare(info->rtc_src_clk); in s3c_rtc_probe()
493 clk_disable_unprepare(info->rtc_clk); in s3c_rtc_probe()
502 struct s3c_rtc *info = dev_get_drvdata(dev); in s3c_rtc_suspend() local
505 ret = s3c_rtc_enable_clk(info); in s3c_rtc_suspend()
509 if (info->data->disable) in s3c_rtc_suspend()
510 info->data->disable(info); in s3c_rtc_suspend()
512 if (device_may_wakeup(dev) && !info->wake_en) { in s3c_rtc_suspend()
513 if (enable_irq_wake(info->irq_alarm) == 0) in s3c_rtc_suspend()
514 info->wake_en = true; in s3c_rtc_suspend()
524 struct s3c_rtc *info = dev_get_drvdata(dev); in s3c_rtc_resume() local
526 if (info->data->enable) in s3c_rtc_resume()
527 info->data->enable(info); in s3c_rtc_resume()
529 s3c_rtc_disable_clk(info); in s3c_rtc_resume()
531 if (device_may_wakeup(dev) && info->wake_en) { in s3c_rtc_resume()
532 disable_irq_wake(info->irq_alarm); in s3c_rtc_resume()
533 info->wake_en = false; in s3c_rtc_resume()
541 static void s3c24xx_rtc_irq(struct s3c_rtc *info, int mask) in s3c24xx_rtc_irq() argument
543 rtc_update_irq(info->rtc, 1, RTC_AF | RTC_IRQF); in s3c24xx_rtc_irq()
546 static void s3c6410_rtc_irq(struct s3c_rtc *info, int mask) in s3c6410_rtc_irq() argument
548 rtc_update_irq(info->rtc, 1, RTC_AF | RTC_IRQF); in s3c6410_rtc_irq()
549 writeb(mask, info->base + S3C2410_INTP); in s3c6410_rtc_irq()