21 #include <linux/module.h>
22 #include <linux/kernel.h>
24 #include <linux/time.h>
25 #include <linux/rtc.h>
32 #include <asm/uaccess.h>
36 #define at91_rtc_read(field) \
37 __raw_readl(at91_rtc_regs + field)
38 #define at91_rtc_write(field, val) \
39 __raw_writel((val), at91_rtc_regs + field)
41 #define AT91_RTC_EPOCH 1900UL
45 static void __iomem *at91_rtc_regs;
51 static void at91_rtc_decodetime(
unsigned int timereg,
unsigned int calreg,
89 pr_debug(
"%s(): %4d-%02d-%02d %02d:%02d:%02d\n", __func__,
103 pr_debug(
"%s(): %4d-%02d-%02d %02d:%02d:%02d\n", __func__,
143 tm->
tm_year = at91_alarm_year - 1900;
148 pr_debug(
"%s(): %4d-%02d-%02d %02d:%02d:%02d\n", __func__,
186 pr_debug(
"%s(): %4d-%02d-%02d %02d:%02d:%02d\n", __func__,
193 static int at91_rtc_alarm_irq_enable(
struct device *dev,
unsigned int enabled)
195 pr_debug(
"%s(): cmd=%08x\n", __func__, enabled);
208 static int at91_rtc_proc(
struct device *dev,
struct seq_file *seq)
243 pr_debug(
"%s(): num=%ld, events=0x%02lx\n", __func__,
244 events >> 8, events & 0x000000FF);
252 .read_time = at91_rtc_readtime,
253 .set_time = at91_rtc_settime,
254 .read_alarm = at91_rtc_readalarm,
255 .set_alarm = at91_rtc_setalarm,
256 .proc = at91_rtc_proc,
257 .alarm_irq_enable = at91_rtc_alarm_irq_enable,
271 dev_err(&pdev->
dev,
"no mmio resource defined\n");
277 dev_err(&pdev->
dev,
"no irq resource defined\n");
281 at91_rtc_regs =
ioremap(regs->
start, resource_size(regs));
282 if (!at91_rtc_regs) {
283 dev_err(&pdev->
dev,
"failed to map registers, aborting.\n");
307 if (!device_can_wakeup(&pdev->
dev))
316 platform_set_drvdata(pdev, rtc);
327 struct rtc_device *rtc = platform_get_drvdata(pdev);
336 platform_set_drvdata(pdev,
NULL);
345 static u32 at91_rtc_imr;
355 if (device_may_wakeup(dev))
356 enable_irq_wake(irq);
366 if (device_may_wakeup(dev))
367 disable_irq_wake(irq);
374 static const struct dev_pm_ops at91_rtc_pm = {
379 #define at91_rtc_pm_ptr &at91_rtc_pm
382 #define at91_rtc_pm_ptr NULL
386 .remove =
__exit_p(at91_rtc_remove),
394 static int __init at91_rtc_init(
void)
399 static void __exit at91_rtc_exit(
void)