11 #include <linux/module.h>
12 #include <linux/kernel.h>
14 #include <linux/slab.h>
15 #include <linux/rtc.h>
30 #define RTC_CTRL_PCLR 1
31 #define RTC_CTRL_TOPEN 2
32 #define RTC_CTRL_PSEL 8
39 #define RTC_IER_TOPI 0
42 #define RTC_IDR_TOPI 0
45 #define RTC_IMR_TOPI 0
48 #define RTC_ISR_TOPI 0
51 #define RTC_ICR_TOPI 0
53 #define RTC_BIT(name) (1 << RTC_##name)
54 #define RTC_BF(name, value) ((value) << RTC_##name)
56 #define rtc_readl(dev, reg) \
57 __raw_readl((dev)->regs + RTC_##reg)
58 #define rtc_writel(dev, reg, value) \
59 __raw_writel((value), (dev)->regs + RTC_##reg)
98 spin_lock_irq(&rtc->
lock);
102 spin_unlock_irq(&rtc->
lock);
110 unsigned long rtc_unix_time;
111 unsigned long alarm_unix_time;
120 if (alarm_unix_time < rtc_unix_time)
123 spin_lock_irq(&rtc->
lock);
132 spin_unlock_irq(&rtc->
lock);
137 static int at32_rtc_alarm_irq_enable(
struct device *dev,
unsigned int enabled)
142 spin_lock_irq(&rtc->
lock);
160 spin_unlock_irq(&rtc->
lock);
172 spin_lock(&rtc->
lock);
185 spin_unlock(&rtc->
lock);
191 .read_time = at32_rtc_readtime,
192 .set_time = at32_rtc_settime,
193 .read_alarm = at32_rtc_readalarm,
194 .set_alarm = at32_rtc_setalarm,
195 .alarm_irq_enable = at32_rtc_alarm_irq_enable,
213 dev_dbg(&pdev->
dev,
"no mmio resource defined\n");
229 dev_dbg(&pdev->
dev,
"could not map I/O memory\n");
249 dev_dbg(&pdev->
dev,
"could not request irq %d\n", irq);
253 platform_set_drvdata(pdev, rtc);
257 if (IS_ERR(rtc->
rtc)) {
258 dev_dbg(&pdev->
dev,
"could not register rtc device\n");
259 ret = PTR_ERR(rtc->
rtc);
265 dev_info(&pdev->
dev,
"Atmel RTC for AT32AP700x at %08lx irq %ld\n",
266 (
unsigned long)rtc->
regs, rtc->
irq);
271 platform_set_drvdata(pdev,
NULL);
290 platform_set_drvdata(pdev,
NULL);
298 .remove =
__exit_p(at32_rtc_remove),
300 .name =
"at32ap700x_rtc",
305 static int __init at32_rtc_init(
void)
311 static void __exit at32_rtc_exit(
void)