Lines Matching refs:info

53 	void (*irq_handler) (struct s3c_rtc *info, int mask);
54 void (*enable) (struct s3c_rtc *info);
55 void (*disable) (struct s3c_rtc *info);
58 static int s3c_rtc_enable_clk(struct s3c_rtc *info) in s3c_rtc_enable_clk() argument
62 ret = clk_enable(info->rtc_clk); in s3c_rtc_enable_clk()
66 if (info->data->needs_src_clk) { in s3c_rtc_enable_clk()
67 ret = clk_enable(info->rtc_src_clk); in s3c_rtc_enable_clk()
69 clk_disable(info->rtc_clk); in s3c_rtc_enable_clk()
76 static void s3c_rtc_disable_clk(struct s3c_rtc *info) in s3c_rtc_disable_clk() argument
78 if (info->data->needs_src_clk) in s3c_rtc_disable_clk()
79 clk_disable(info->rtc_src_clk); in s3c_rtc_disable_clk()
80 clk_disable(info->rtc_clk); in s3c_rtc_disable_clk()
86 struct s3c_rtc *info = (struct s3c_rtc *)id; in s3c_rtc_alarmirq() local
88 if (info->data->irq_handler) in s3c_rtc_alarmirq()
89 info->data->irq_handler(info, S3C2410_INTP_ALM); in s3c_rtc_alarmirq()
97 struct s3c_rtc *info = dev_get_drvdata(dev); in s3c_rtc_setaie() local
102 dev_dbg(info->dev, "%s: aie=%d\n", __func__, enabled); in s3c_rtc_setaie()
104 ret = s3c_rtc_enable_clk(info); in s3c_rtc_setaie()
108 tmp = readb(info->base + S3C2410_RTCALM) & ~S3C2410_RTCALM_ALMEN; in s3c_rtc_setaie()
113 writeb(tmp, info->base + S3C2410_RTCALM); in s3c_rtc_setaie()
115 spin_lock_irqsave(&info->alarm_lock, flags); in s3c_rtc_setaie()
117 if (info->alarm_enabled && !enabled) in s3c_rtc_setaie()
118 s3c_rtc_disable_clk(info); in s3c_rtc_setaie()
119 else if (!info->alarm_enabled && enabled) in s3c_rtc_setaie()
120 ret = s3c_rtc_enable_clk(info); in s3c_rtc_setaie()
122 info->alarm_enabled = enabled; in s3c_rtc_setaie()
123 spin_unlock_irqrestore(&info->alarm_lock, flags); in s3c_rtc_setaie()
125 s3c_rtc_disable_clk(info); in s3c_rtc_setaie()
131 static int s3c_rtc_read_time(struct s3c_rtc *info, struct rtc_time *tm) in s3c_rtc_read_time() argument
136 ret = s3c_rtc_enable_clk(info); in s3c_rtc_read_time()
141 tm->tm_min = readb(info->base + S3C2410_RTCMIN); in s3c_rtc_read_time()
142 tm->tm_hour = readb(info->base + S3C2410_RTCHOUR); in s3c_rtc_read_time()
143 tm->tm_mday = readb(info->base + S3C2410_RTCDATE); in s3c_rtc_read_time()
144 tm->tm_mon = readb(info->base + S3C2410_RTCMON); in s3c_rtc_read_time()
145 tm->tm_year = readb(info->base + S3C2410_RTCYEAR); in s3c_rtc_read_time()
146 tm->tm_sec = readb(info->base + S3C2410_RTCSEC); in s3c_rtc_read_time()
158 s3c_rtc_disable_clk(info); in s3c_rtc_read_time()
171 static int s3c_rtc_write_time(struct s3c_rtc *info, const struct rtc_time *tm) in s3c_rtc_write_time() argument
175 ret = s3c_rtc_enable_clk(info); in s3c_rtc_write_time()
179 writeb(bin2bcd(tm->tm_sec), info->base + S3C2410_RTCSEC); in s3c_rtc_write_time()
180 writeb(bin2bcd(tm->tm_min), info->base + S3C2410_RTCMIN); in s3c_rtc_write_time()
181 writeb(bin2bcd(tm->tm_hour), info->base + S3C2410_RTCHOUR); in s3c_rtc_write_time()
182 writeb(bin2bcd(tm->tm_mday), info->base + S3C2410_RTCDATE); in s3c_rtc_write_time()
183 writeb(bin2bcd(tm->tm_mon), info->base + S3C2410_RTCMON); in s3c_rtc_write_time()
184 writeb(bin2bcd(tm->tm_year), info->base + S3C2410_RTCYEAR); in s3c_rtc_write_time()
186 s3c_rtc_disable_clk(info); in s3c_rtc_write_time()
193 struct s3c_rtc *info = dev_get_drvdata(dev); in s3c_rtc_gettime() local
196 ret = s3c_rtc_read_time(info, tm); in s3c_rtc_gettime()
210 struct s3c_rtc *info = dev_get_drvdata(dev); in s3c_rtc_settime() local
222 return s3c_rtc_write_time(info, &rtc_tm); in s3c_rtc_settime()
227 struct s3c_rtc *info = dev_get_drvdata(dev); in s3c_rtc_getalarm() local
232 ret = s3c_rtc_enable_clk(info); in s3c_rtc_getalarm()
236 alm_tm->tm_sec = readb(info->base + S3C2410_ALMSEC); in s3c_rtc_getalarm()
237 alm_tm->tm_min = readb(info->base + S3C2410_ALMMIN); in s3c_rtc_getalarm()
238 alm_tm->tm_hour = readb(info->base + S3C2410_ALMHOUR); in s3c_rtc_getalarm()
239 alm_tm->tm_mon = readb(info->base + S3C2410_ALMMON); in s3c_rtc_getalarm()
240 alm_tm->tm_mday = readb(info->base + S3C2410_ALMDATE); in s3c_rtc_getalarm()
241 alm_tm->tm_year = readb(info->base + S3C2410_ALMYEAR); in s3c_rtc_getalarm()
243 alm_en = readb(info->base + S3C2410_RTCALM); in s3c_rtc_getalarm()
245 s3c_rtc_disable_clk(info); in s3c_rtc_getalarm()
277 struct s3c_rtc *info = dev_get_drvdata(dev); in s3c_rtc_setalarm() local
284 ret = s3c_rtc_enable_clk(info); in s3c_rtc_setalarm()
288 alrm_en = readb(info->base + S3C2410_RTCALM) & S3C2410_RTCALM_ALMEN; in s3c_rtc_setalarm()
289 writeb(0x00, info->base + S3C2410_RTCALM); in s3c_rtc_setalarm()
293 writeb(bin2bcd(tm->tm_sec), info->base + S3C2410_ALMSEC); in s3c_rtc_setalarm()
298 writeb(bin2bcd(tm->tm_min), info->base + S3C2410_ALMMIN); in s3c_rtc_setalarm()
303 writeb(bin2bcd(tm->tm_hour), info->base + S3C2410_ALMHOUR); in s3c_rtc_setalarm()
308 writeb(bin2bcd(tm->tm_mon + 1), info->base + S3C2410_ALMMON); in s3c_rtc_setalarm()
313 writeb(bin2bcd(tm->tm_mday), info->base + S3C2410_ALMDATE); in s3c_rtc_setalarm()
318 writeb(alrm_en, info->base + S3C2410_RTCALM); in s3c_rtc_setalarm()
322 s3c_rtc_disable_clk(info); in s3c_rtc_setalarm()
335 static void s3c24xx_rtc_enable(struct s3c_rtc *info) in s3c24xx_rtc_enable() argument
339 con = readw(info->base + S3C2410_RTCCON); in s3c24xx_rtc_enable()
342 dev_info(info->dev, "rtc disabled, re-enabling\n"); in s3c24xx_rtc_enable()
344 tmp = readw(info->base + S3C2410_RTCCON); in s3c24xx_rtc_enable()
345 writew(tmp | S3C2410_RTCCON_RTCEN, info->base + S3C2410_RTCCON); in s3c24xx_rtc_enable()
349 dev_info(info->dev, "removing RTCCON_CNTSEL\n"); in s3c24xx_rtc_enable()
351 tmp = readw(info->base + S3C2410_RTCCON); in s3c24xx_rtc_enable()
353 info->base + S3C2410_RTCCON); in s3c24xx_rtc_enable()
357 dev_info(info->dev, "removing RTCCON_CLKRST\n"); in s3c24xx_rtc_enable()
359 tmp = readw(info->base + S3C2410_RTCCON); in s3c24xx_rtc_enable()
361 info->base + S3C2410_RTCCON); in s3c24xx_rtc_enable()
365 static void s3c24xx_rtc_disable(struct s3c_rtc *info) in s3c24xx_rtc_disable() argument
369 con = readw(info->base + S3C2410_RTCCON); in s3c24xx_rtc_disable()
371 writew(con, info->base + S3C2410_RTCCON); in s3c24xx_rtc_disable()
373 con = readb(info->base + S3C2410_TICNT); in s3c24xx_rtc_disable()
375 writeb(con, info->base + S3C2410_TICNT); in s3c24xx_rtc_disable()
378 static void s3c6410_rtc_disable(struct s3c_rtc *info) in s3c6410_rtc_disable() argument
382 con = readw(info->base + S3C2410_RTCCON); in s3c6410_rtc_disable()
385 writew(con, info->base + S3C2410_RTCCON); in s3c6410_rtc_disable()
390 struct s3c_rtc *info = platform_get_drvdata(pdev); in s3c_rtc_remove() local
392 s3c_rtc_setaie(info->dev, 0); in s3c_rtc_remove()
394 if (info->data->needs_src_clk) in s3c_rtc_remove()
395 clk_unprepare(info->rtc_src_clk); in s3c_rtc_remove()
396 clk_unprepare(info->rtc_clk); in s3c_rtc_remove()
403 struct s3c_rtc *info = NULL; in s3c_rtc_probe() local
406 info = devm_kzalloc(&pdev->dev, sizeof(*info), GFP_KERNEL); in s3c_rtc_probe()
407 if (!info) in s3c_rtc_probe()
410 info->dev = &pdev->dev; in s3c_rtc_probe()
411 info->data = of_device_get_match_data(&pdev->dev); in s3c_rtc_probe()
412 if (!info->data) { in s3c_rtc_probe()
416 spin_lock_init(&info->alarm_lock); in s3c_rtc_probe()
418 platform_set_drvdata(pdev, info); in s3c_rtc_probe()
420 info->irq_alarm = platform_get_irq(pdev, 0); in s3c_rtc_probe()
421 if (info->irq_alarm < 0) in s3c_rtc_probe()
422 return info->irq_alarm; in s3c_rtc_probe()
424 dev_dbg(&pdev->dev, "s3c2410_rtc: alarm irq %d\n", info->irq_alarm); in s3c_rtc_probe()
427 info->base = devm_platform_ioremap_resource(pdev, 0); in s3c_rtc_probe()
428 if (IS_ERR(info->base)) in s3c_rtc_probe()
429 return PTR_ERR(info->base); in s3c_rtc_probe()
431 info->rtc_clk = devm_clk_get(&pdev->dev, "rtc"); in s3c_rtc_probe()
432 if (IS_ERR(info->rtc_clk)) { in s3c_rtc_probe()
433 ret = PTR_ERR(info->rtc_clk); in s3c_rtc_probe()
440 ret = clk_prepare_enable(info->rtc_clk); in s3c_rtc_probe()
444 if (info->data->needs_src_clk) { in s3c_rtc_probe()
445 info->rtc_src_clk = devm_clk_get(&pdev->dev, "rtc_src"); in s3c_rtc_probe()
446 if (IS_ERR(info->rtc_src_clk)) { in s3c_rtc_probe()
447 ret = dev_err_probe(&pdev->dev, PTR_ERR(info->rtc_src_clk), in s3c_rtc_probe()
451 ret = clk_prepare_enable(info->rtc_src_clk); in s3c_rtc_probe()
457 if (info->data->disable) in s3c_rtc_probe()
458 info->data->disable(info); in s3c_rtc_probe()
461 if (info->data->enable) in s3c_rtc_probe()
462 info->data->enable(info); in s3c_rtc_probe()
465 readw(info->base + S3C2410_RTCCON)); in s3c_rtc_probe()
469 info->rtc = devm_rtc_allocate_device(&pdev->dev); in s3c_rtc_probe()
470 if (IS_ERR(info->rtc)) { in s3c_rtc_probe()
471 ret = PTR_ERR(info->rtc); in s3c_rtc_probe()
475 info->rtc->ops = &s3c_rtcops; in s3c_rtc_probe()
476 info->rtc->range_min = RTC_TIMESTAMP_BEGIN_2000; in s3c_rtc_probe()
477 info->rtc->range_max = RTC_TIMESTAMP_END_2099; in s3c_rtc_probe()
479 ret = devm_rtc_register_device(info->rtc); in s3c_rtc_probe()
483 ret = devm_request_irq(&pdev->dev, info->irq_alarm, s3c_rtc_alarmirq, in s3c_rtc_probe()
484 0, "s3c2410-rtc alarm", info); in s3c_rtc_probe()
486 dev_err(&pdev->dev, "IRQ%d error %d\n", info->irq_alarm, ret); in s3c_rtc_probe()
490 s3c_rtc_disable_clk(info); in s3c_rtc_probe()
495 if (info->data->disable) in s3c_rtc_probe()
496 info->data->disable(info); in s3c_rtc_probe()
498 if (info->data->needs_src_clk) in s3c_rtc_probe()
499 clk_disable_unprepare(info->rtc_src_clk); in s3c_rtc_probe()
501 clk_disable_unprepare(info->rtc_clk); in s3c_rtc_probe()
510 struct s3c_rtc *info = dev_get_drvdata(dev); in s3c_rtc_suspend() local
513 ret = s3c_rtc_enable_clk(info); in s3c_rtc_suspend()
517 if (info->data->disable) in s3c_rtc_suspend()
518 info->data->disable(info); in s3c_rtc_suspend()
520 if (device_may_wakeup(dev) && !info->wake_en) { in s3c_rtc_suspend()
521 if (enable_irq_wake(info->irq_alarm) == 0) in s3c_rtc_suspend()
522 info->wake_en = true; in s3c_rtc_suspend()
532 struct s3c_rtc *info = dev_get_drvdata(dev); in s3c_rtc_resume() local
534 if (info->data->enable) in s3c_rtc_resume()
535 info->data->enable(info); in s3c_rtc_resume()
537 s3c_rtc_disable_clk(info); in s3c_rtc_resume()
539 if (device_may_wakeup(dev) && info->wake_en) { in s3c_rtc_resume()
540 disable_irq_wake(info->irq_alarm); in s3c_rtc_resume()
541 info->wake_en = false; in s3c_rtc_resume()
549 static void s3c24xx_rtc_irq(struct s3c_rtc *info, int mask) in s3c24xx_rtc_irq() argument
551 rtc_update_irq(info->rtc, 1, RTC_AF | RTC_IRQF); in s3c24xx_rtc_irq()
554 static void s3c6410_rtc_irq(struct s3c_rtc *info, int mask) in s3c6410_rtc_irq() argument
556 rtc_update_irq(info->rtc, 1, RTC_AF | RTC_IRQF); in s3c6410_rtc_irq()
557 writeb(mask, info->base + S3C2410_INTP); in s3c6410_rtc_irq()