15 #include <linux/i2c.h>
17 #include <linux/module.h>
20 #include <linux/rtc.h>
21 #include <linux/slab.h>
35 #define ALARM_1SEC (1 << 7)
36 #define HOUR_12 (1 << 7)
37 #define HOUR_AM_PM (1 << 5)
38 #define ALARM0_IRQ (1 << 3)
39 #define ALARM1_IRQ (1 << 2)
40 #define ALARM0_STATUS (1 << 2)
41 #define ALARM1_STATUS (1 << 1)
81 static void tm_to_regs(
struct rtc_time *tm,
u8 *regs)
85 high = (tm->
tm_year + 1900) / 100;
108 regs_to_tm(regs, tm);
113 static int max8907_rtc_set_time(
struct device *dev,
struct rtc_time *tm)
118 tm_to_regs(tm, regs);
124 static int max8907_rtc_read_alarm(
struct device *dev,
struct rtc_wkalrm *alrm)
136 regs_to_tm(regs, &alrm->
time);
142 alrm->
enabled = !!(val & 0x7f);
147 static int max8907_rtc_set_alarm(
struct device *dev,
struct rtc_wkalrm *alrm)
153 tm_to_regs(&alrm->
time, regs);
173 .read_time = max8907_rtc_read_time,
174 .set_time = max8907_rtc_set_time,
175 .read_alarm = max8907_rtc_read_alarm,
176 .set_alarm = max8907_rtc_set_alarm,
188 platform_set_drvdata(pdev, rtc);
197 dev_err(&pdev->
dev,
"Failed to register RTC device: %d\n", ret);
211 dev_err(&pdev->
dev,
"Failed to request IRQ%d: %d\n",
225 struct max8907_rtc *rtc = platform_get_drvdata(pdev);
235 .name =
"max8907-rtc",
238 .probe = max8907_rtc_probe,