20 #include <linux/kernel.h>
21 #include <linux/module.h>
26 #include <linux/rtc.h>
27 #include <linux/slab.h>
30 #include <mach/common.h>
32 #define STMP3XXX_RTC_CTRL 0x0
33 #define STMP3XXX_RTC_CTRL_SET 0x4
34 #define STMP3XXX_RTC_CTRL_CLR 0x8
35 #define STMP3XXX_RTC_CTRL_ALARM_IRQ_EN 0x00000001
36 #define STMP3XXX_RTC_CTRL_ONEMSEC_IRQ_EN 0x00000002
37 #define STMP3XXX_RTC_CTRL_ALARM_IRQ 0x00000004
39 #define STMP3XXX_RTC_STAT 0x10
40 #define STMP3XXX_RTC_STAT_STALE_SHIFT 16
41 #define STMP3XXX_RTC_STAT_RTC_PRESENT 0x80000000
43 #define STMP3XXX_RTC_SECONDS 0x30
45 #define STMP3XXX_RTC_ALARM 0x40
47 #define STMP3XXX_RTC_PERSISTENT0 0x60
48 #define STMP3XXX_RTC_PERSISTENT0_SET 0x64
49 #define STMP3XXX_RTC_PERSISTENT0_CLR 0x68
50 #define STMP3XXX_RTC_PERSISTENT0_ALARM_WAKE_EN 0x00000002
51 #define STMP3XXX_RTC_PERSISTENT0_ALARM_EN 0x00000004
52 #define STMP3XXX_RTC_PERSISTENT0_ALARM_WAKE 0x00000080
77 stmp3xxx_wait_time(rtc_data);
82 static int stmp3xxx_rtc_set_mmss(
struct device *dev,
unsigned long t)
87 stmp3xxx_wait_time(rtc_data);
98 writel(STMP3XXX_RTC_CTRL_ALARM_IRQ,
107 static int stmp3xxx_alarm_irq_enable(
struct device *dev,
unsigned int enabled)
127 static int stmp3xxx_rtc_read_alarm(
struct device *dev,
struct rtc_wkalrm *alm)
135 static int stmp3xxx_rtc_set_alarm(
struct device *dev,
struct rtc_wkalrm *alm)
143 stmp3xxx_alarm_irq_enable(dev, alm->
enabled);
150 stmp3xxx_alarm_irq_enable,
151 .read_time = stmp3xxx_rtc_gettime,
152 .set_mmss = stmp3xxx_rtc_set_mmss,
153 .read_alarm = stmp3xxx_rtc_read_alarm,
154 .set_alarm = stmp3xxx_rtc_set_alarm,
168 platform_set_drvdata(pdev,
NULL);
181 rtc_data = kzalloc(
sizeof *rtc_data,
GFP_KERNEL);
187 dev_err(&pdev->
dev,
"failed to get resource\n");
208 platform_set_drvdata(pdev, rtc_data);
222 if (IS_ERR(rtc_data->
rtc)) {
223 err = PTR_ERR(rtc_data->
rtc);
228 "RTC alarm", &pdev->
dev);
240 platform_set_drvdata(pdev,
NULL);
265 #define stmp3xxx_rtc_suspend NULL
266 #define stmp3xxx_rtc_resume NULL
270 { .compatible =
"fsl,stmp3xxx-rtc", },
276 .probe = stmp3xxx_rtc_probe,
277 .remove = stmp3xxx_rtc_remove,
281 .name =
"stmp3xxx-rtc",
283 .of_match_table = rtc_dt_ids,