17 #include <linux/kernel.h>
18 #include <linux/module.h>
20 #include <linux/device.h>
21 #include <linux/slab.h>
23 #include <linux/rtc.h>
29 #define PCF50633_REG_RTCSC 0x59
30 #define PCF50633_REG_RTCMN 0x5a
31 #define PCF50633_REG_RTCHR 0x5b
32 #define PCF50633_REG_RTCWD 0x5c
33 #define PCF50633_REG_RTCDT 0x5d
34 #define PCF50633_REG_RTCMT 0x5e
35 #define PCF50633_REG_RTCYR 0x5f
36 #define PCF50633_REG_RTCSCA 0x60
37 #define PCF50633_REG_RTCMNA 0x61
38 #define PCF50633_REG_RTCHRA 0x62
39 #define PCF50633_REG_RTCWDA 0x63
40 #define PCF50633_REG_RTCDTA 0x64
41 #define PCF50633_REG_RTCMTA 0x65
42 #define PCF50633_REG_RTCYRA 0x66
120 dev_err(dev,
"Failed to read time\n");
124 dev_dbg(dev,
"PCF_TIME: %02x.%02x.%02x %02x:%02x:%02x\n",
132 pcf2rtc_time(tm, &pcf_tm);
134 dev_dbg(dev,
"RTC_TIME: %u.%u.%u %u:%u:%u\n",
141 static int pcf50633_rtc_set_time(
struct device *dev,
struct rtc_time *tm)
145 int alarm_masked, ret = 0;
149 dev_dbg(dev,
"RTC_TIME: %u.%u.%u %u:%u:%u\n",
153 rtc2pcf_time(&pcf_tm, tm);
155 dev_dbg(dev,
"PCF_TIME: %02x.%02x.%02x %02x:%02x:%02x\n",
180 static int pcf50633_rtc_read_alarm(
struct device *dev,
struct rtc_wkalrm *alrm)
194 dev_err(dev,
"Failed to read time\n");
198 pcf2rtc_time(&alrm->
time, &pcf_tm);
203 static int pcf50633_rtc_set_alarm(
struct device *dev,
struct rtc_wkalrm *alrm)
207 int alarm_masked, ret = 0;
211 rtc2pcf_time(&pcf_tm, &alrm->
time);
228 if (!alarm_masked || alrm->
enabled)
236 .read_time = pcf50633_rtc_read_time,
237 .set_time = pcf50633_rtc_set_time,
238 .read_alarm = pcf50633_rtc_read_alarm,
239 .set_alarm = pcf50633_rtc_set_alarm,
240 .alarm_irq_enable = pcf50633_rtc_alarm_irq_enable,
243 static void pcf50633_rtc_irq(
int irq,
void *
data)
259 rtc->
pcf = dev_to_pcf50633(pdev->
dev.parent);
260 platform_set_drvdata(pdev, rtc);
265 int ret = PTR_ERR(rtc->
rtc_dev);
271 pcf50633_rtc_irq, rtc);
279 rtc = platform_get_drvdata(pdev);
291 .name =
"pcf50633-rtc",
293 .probe = pcf50633_rtc_probe,