35 #include <linux/module.h>
37 #include <linux/rtc.h>
38 #include <linux/sched.h>
48 #define DCAMR_UNSET 0xFFFFFFFF
51 #define DCR_TCE (1 << 3)
54 #define DSR_WBF (1 << 10)
55 #define DSR_WNF (1 << 9)
56 #define DSR_WCF (1 << 8)
57 #define DSR_WEF (1 << 7)
58 #define DSR_CAF (1 << 4)
59 #define DSR_NVF (1 << 1)
60 #define DSR_SVF (1 << 0)
63 #define DIER_WNIE (1 << 9)
64 #define DIER_WCIE (1 << 8)
65 #define DIER_WEIE (1 << 7)
66 #define DIER_CAIE (1 << 4)
104 spin_unlock_irqrestore(&imxdi->
irq_lock, flags);
110 static void di_int_disable(
struct imxdi_dev *imxdi,
u32 intr)
117 spin_unlock_irqrestore(&imxdi->
irq_lock, flags);
127 static void clear_write_error(
struct imxdi_dev *imxdi)
131 dev_warn(&imxdi->
pdev->dev,
"WARNING: Register write error!\n");
137 for (cnt = 0; cnt < 1000; cnt++) {
143 "ERROR: Cannot clear write-error flag!\n");
174 }
else if (ret == 0) {
176 "Write-wait timeout "
177 "val = 0x%08x reg = 0x%08x\n", val, reg);
182 clear_write_error(imxdi);
210 static int dryice_rtc_set_mmss(
struct device *
dev,
unsigned long secs)
216 rc = di_write_wait(imxdi, 0,
DTCLR);
218 rc = di_write_wait(imxdi, secs,
DTCMR);
223 static int dryice_rtc_alarm_irq_enable(
struct device *dev,
269 unsigned long alarm_time;
278 if (alarm_time < now)
282 rc = di_write_wait(imxdi, (
u32)alarm_time,
DCAMR);
295 .read_time = dryice_rtc_read_time,
296 .set_mmss = dryice_rtc_set_mmss,
297 .alarm_irq_enable = dryice_rtc_alarm_irq_enable,
298 .read_alarm = dryice_rtc_read_alarm,
299 .set_alarm = dryice_rtc_set_alarm,
325 di_int_disable(imxdi, DIER_WCIE);
341 di_int_disable(imxdi, DIER_CAIE);
408 if (IS_ERR(imxdi->
clk))
409 return PTR_ERR(imxdi->
clk);
410 clk_prepare_enable(imxdi->
clk);
419 rc = devm_request_irq(&pdev->
dev, imxdi->
irq, dryice_norm_irq,
422 dev_warn(&pdev->
dev,
"interrupt not available.\n");
428 rc = di_write_wait(imxdi, DSR_NVF |
DSR_SVF,
DSR);
437 rc = di_write_wait(imxdi, 0,
DCALR);
443 rc = di_write_wait(imxdi, DSR_CAF,
DSR);
450 rc = di_write_wait(imxdi, 0,
DTCMR);
457 rc = di_write_wait(imxdi,
464 platform_set_drvdata(pdev, imxdi);
467 if (IS_ERR(imxdi->
rtc)) {
468 rc = PTR_ERR(imxdi->
rtc);
475 clk_disable_unprepare(imxdi->
clk);
483 struct imxdi_dev *imxdi = platform_get_drvdata(pdev);
492 clk_disable_unprepare(imxdi->
clk);
506 static int __init dryice_rtc_init(
void)
511 static void __exit dryice_rtc_exit(
void)