13 #include <linux/kernel.h>
18 #include <linux/rtc.h>
21 #include <linux/module.h>
23 #define DRV_VERSION "0.3"
25 #define RTC_REG_SIZE 0x2000
26 #define RTC_OFFSET 0x1ff0
28 #define RTC_FLAGS (RTC_OFFSET + 0)
29 #define RTC_SECONDS_ALARM (RTC_OFFSET + 2)
30 #define RTC_MINUTES_ALARM (RTC_OFFSET + 3)
31 #define RTC_HOURS_ALARM (RTC_OFFSET + 4)
32 #define RTC_DATE_ALARM (RTC_OFFSET + 5)
33 #define RTC_INTERRUPTS (RTC_OFFSET + 6)
34 #define RTC_WATCHDOG (RTC_OFFSET + 7)
35 #define RTC_CONTROL (RTC_OFFSET + 8)
36 #define RTC_CENTURY (RTC_OFFSET + 8)
37 #define RTC_SECONDS (RTC_OFFSET + 9)
38 #define RTC_MINUTES (RTC_OFFSET + 10)
39 #define RTC_HOURS (RTC_OFFSET + 11)
40 #define RTC_DAY (RTC_OFFSET + 12)
41 #define RTC_DATE (RTC_OFFSET + 13)
42 #define RTC_MONTH (RTC_OFFSET + 14)
43 #define RTC_YEAR (RTC_OFFSET + 15)
45 #define RTC_CENTURY_MASK 0x3f
46 #define RTC_SECONDS_MASK 0x7f
47 #define RTC_DAY_MASK 0x07
50 #define RTC_WRITE 0x80
57 #define RTC_FLAGS_AF 0x40
58 #define RTC_FLAGS_BLF 0x10
61 #define RTC_INTS_AE 0x80
107 unsigned int century;
133 dev_err(dev,
"retrieved date/time is not valid.\n");
139 static void ds1553_rtc_update_alarm(
struct rtc_plat_data *pdata)
159 spin_unlock_irqrestore(&pdata->
lock, flags);
162 static int ds1553_rtc_set_alarm(
struct device *dev,
struct rtc_wkalrm *alrm)
175 ds1553_rtc_update_alarm(pdata);
179 static int ds1553_rtc_read_alarm(
struct device *dev,
struct rtc_wkalrm *alrm)
201 spin_lock(&pdata->
lock);
212 spin_unlock(&pdata->
lock);
216 static int ds1553_rtc_alarm_irq_enable(
struct device *dev,
unsigned int enabled)
227 ds1553_rtc_update_alarm(pdata);
232 .read_time = ds1553_rtc_read_time,
233 .set_time = ds1553_rtc_set_time,
234 .read_alarm = ds1553_rtc_read_alarm,
235 .set_alarm = ds1553_rtc_set_alarm,
236 .alarm_irq_enable = ds1553_rtc_alarm_irq_enable,
249 for (count = 0; size > 0 && pos <
RTC_OFFSET; count++, size--)
250 *buf++ =
readb(ioaddr + pos++);
256 char *buf, loff_t pos,
size_t size)
264 for (count = 0; size > 0 && pos <
RTC_OFFSET; count++, size--)
265 writeb(*buf++, ioaddr + pos++);
275 .read = ds1553_nvram_read,
276 .write = ds1553_nvram_write,
283 unsigned int cen,
sec;
318 platform_set_drvdata(pdev, pdata);
319 if (pdata->
irq > 0) {
321 if (devm_request_irq(&pdev->
dev, pdata->
irq,
322 ds1553_rtc_interrupt,
323 0, pdev->
name, pdev) < 0) {
324 dev_warn(&pdev->
dev,
"interrupt not available.\n");
356 .probe = ds1553_rtc_probe,
359 .name =
"rtc-ds1553",