10 #include <linux/kernel.h>
11 #include <linux/rtc.h>
18 #include <linux/module.h>
21 #define RTC_TIME_REG_OFFS 0
22 #define RTC_SECONDS_OFFS 0
23 #define RTC_MINUTES_OFFS 8
24 #define RTC_HOURS_OFFS 16
25 #define RTC_WDAY_OFFS 24
26 #define RTC_HOURS_12H_MODE (1 << 22)
28 #define RTC_DATE_REG_OFFS 4
29 #define RTC_MDAY_OFFS 0
30 #define RTC_MONTH_OFFS 8
31 #define RTC_YEAR_OFFS 16
33 #define RTC_ALARM_TIME_REG_OFFS 8
34 #define RTC_ALARM_DATE_REG_OFFS 0xc
35 #define RTC_ALARM_VALID (1 << 7)
37 #define RTC_ALARM_INTERRUPT_MASK_REG_OFFS 0x10
38 #define RTC_ALARM_INTERRUPT_CASUE_REG_OFFS 0x14
66 static int mv_rtc_read_time(
struct device *dev,
struct rtc_time *tm)
76 second = rtc_time & 0x7f;
81 day = rtc_date & 0x3f;
107 second = rtc_time & 0x7f;
112 day = rtc_date & 0x3f;
126 dev_err(dev,
"retrieved alarm date/time is not valid.\n");
140 if (alm->
time.tm_sec >= 0)
143 if (alm->
time.tm_min >= 0)
146 if (alm->
time.tm_hour >= 0)
152 if (alm->
time.tm_mday >= 0)
158 if (alm->
time.tm_mon >= 0)
162 if (alm->
time.tm_year >= 0)
174 static int mv_rtc_alarm_irq_enable(
struct device *dev,
unsigned int enabled)
206 .read_time = mv_rtc_read_time,
207 .set_time = mv_rtc_set_time,
211 .read_time = mv_rtc_read_time,
212 .set_time = mv_rtc_set_time,
213 .read_alarm = mv_rtc_read_alarm,
214 .set_alarm = mv_rtc_set_alarm,
215 .alarm_irq_enable = mv_rtc_alarm_irq_enable,
233 size = resource_size(res);
245 dev_err(&pdev->
dev,
"24 Hours mode not supported.\n");
250 if (rtc_time == 0x01000000) {
253 if (rtc_time == 0x01000000) {
254 dev_err(&pdev->
dev,
"internal RTC not ticking\n");
261 platform_set_drvdata(pdev, pdata);
263 if (pdata->
irq >= 0) {
271 if (IS_ERR(pdata->
rtc))
272 return PTR_ERR(pdata->
rtc);
274 if (pdata->
irq >= 0) {
276 if (devm_request_irq(&pdev->
dev, pdata->
irq, mv_rtc_interrupt,
278 pdev->
name, pdata) < 0) {
279 dev_warn(&pdev->
dev,
"interrupt not available.\n");
314 static __init int mv_init(
void)
319 static __exit void mv_exit(
void)