15 #include <linux/module.h>
16 #include <linux/i2c.h>
17 #include <linux/slab.h>
19 #include <linux/rtc.h>
25 #define MAX8998_RTC_SEC 0x00
26 #define MAX8998_RTC_MIN 0x01
27 #define MAX8998_RTC_HOUR 0x02
28 #define MAX8998_RTC_WEEKDAY 0x03
29 #define MAX8998_RTC_DATE 0x04
30 #define MAX8998_RTC_MONTH 0x05
31 #define MAX8998_RTC_YEAR1 0x06
32 #define MAX8998_RTC_YEAR2 0x07
33 #define MAX8998_ALARM0_SEC 0x08
34 #define MAX8998_ALARM0_MIN 0x09
35 #define MAX8998_ALARM0_HOUR 0x0a
36 #define MAX8998_ALARM0_WEEKDAY 0x0b
37 #define MAX8998_ALARM0_DATE 0x0c
38 #define MAX8998_ALARM0_MONTH 0x0d
39 #define MAX8998_ALARM0_YEAR1 0x0e
40 #define MAX8998_ALARM0_YEAR2 0x0f
41 #define MAX8998_ALARM1_SEC 0x10
42 #define MAX8998_ALARM1_MIN 0x11
43 #define MAX8998_ALARM1_HOUR 0x12
44 #define MAX8998_ALARM1_WEEKDAY 0x13
45 #define MAX8998_ALARM1_DATE 0x14
46 #define MAX8998_ALARM1_MONTH 0x15
47 #define MAX8998_ALARM1_YEAR1 0x16
48 #define MAX8998_ALARM1_YEAR2 0x17
49 #define MAX8998_ALARM0_CONF 0x18
50 #define MAX8998_ALARM1_CONF 0x19
51 #define MAX8998_RTC_STATUS 0x1a
52 #define MAX8998_WTSR_SMPL_CNTL 0x1b
53 #define MAX8998_TEST 0x1f
55 #define HOUR_12 (1 << 7)
56 #define HOUR_PM (1 << 5)
57 #define ALARM0_STATUS (1 << 1)
58 #define ALARM1_STATUS (1 << 2)
120 max8998_data_to_tm(data, tm);
125 static int max8998_rtc_set_time(
struct device *dev,
struct rtc_time *tm)
131 max8998_tm_to_data(tm, data);
141 static int max8998_rtc_read_alarm(
struct device *dev,
struct rtc_wkalrm *alrm)
152 max8998_data_to_tm(data, &alrm->
time);
185 u8 alarm0_conf = 0x77;
199 static int max8998_rtc_set_alarm(
struct device *dev,
struct rtc_wkalrm *alrm)
205 max8998_tm_to_data(&alrm->
time, data);
207 ret = max8998_rtc_stop_alarm(info);
219 ret = max8998_rtc_start_alarm(info);
224 static int max8998_rtc_alarm_irq_enable(
struct device *dev,
230 return max8998_rtc_start_alarm(info);
232 return max8998_rtc_stop_alarm(info);
245 .read_time = max8998_rtc_read_time,
246 .set_time = max8998_rtc_set_time,
247 .read_alarm = max8998_rtc_read_alarm,
248 .set_alarm = max8998_rtc_set_alarm,
249 .alarm_irq_enable = max8998_rtc_alarm_irq_enable,
268 platform_set_drvdata(pdev, info);
275 dev_err(&pdev->
dev,
"Failed to register RTC device: %d\n", ret);
283 dev_err(&pdev->
dev,
"Failed to request alarm IRQ: %d: %d\n",
289 dev_warn(&pdev->
dev,
"LP3974 with RTC REGERR option."
290 " RTC updates will be extremely slow.\n");
296 platform_set_drvdata(pdev,
NULL);
322 .name =
"max8998-rtc",
325 .probe = max8998_rtc_probe,
327 .id_table = max8998_rtc_id,