18 #include <linux/module.h>
19 #include <linux/rtc.h>
26 #include <linux/slab.h>
47 #define RTC_CR_CWEN (1 << 26)
49 #define RTC_TCR_EN (1 << 1)
52 #define RTC_BIT_AI (1 << 0)
53 #define RTC_BIT_PI (1 << 1)
56 #define RTC_SEC_SHIFT 0
57 #define RTC_SEC_MASK (0x3F << RTC_SEC_SHIFT)
58 #define RTC_MIN_SHIFT 6
59 #define RTC_MIN_MASK (0x3F << RTC_MIN_SHIFT)
60 #define RTC_HOUR_SHIFT 12
61 #define RTC_HOUR_MASK (0x1F << RTC_HOUR_SHIFT)
62 #define RTC_WDAY_SHIFT 17
63 #define RTC_WDAY_MASK (0x7 << RTC_WDAY_SHIFT)
64 #define RTC_MDAY_SHIFT 20
65 #define RTC_MDAY_MASK (0x1F << RTC_MDAY_SHIFT)
66 #define RTC_MON_SHIFT 25
67 #define RTC_MON_MASK (0xF << RTC_MON_SHIFT)
69 #define RTC_TIMER_FREQ 32768
93 static int pl031_alarm_irq_enable(
struct device *
dev,
115 static int pl031_stv2_tm_to_time(
struct device *
dev,
117 unsigned long *bcd_year)
123 if (wday < -1 || wday > 6) {
126 }
else if (wday == -1) {
133 wday = calc_tm.tm_wday;
151 static int pl031_stv2_time_to_tm(
unsigned long st_time,
unsigned long bcd_year,
168 static int pl031_stv2_read_time(
struct device *dev,
struct rtc_time *tm)
178 static int pl031_stv2_set_time(
struct device *dev,
struct rtc_time *tm)
181 unsigned long bcd_year;
185 ret = pl031_stv2_tm_to_time(dev, tm, &time, &bcd_year);
208 static int pl031_stv2_set_alarm(
struct device *dev,
struct rtc_wkalrm *alarm)
212 unsigned long bcd_year;
218 ret = pl031_stv2_tm_to_time(dev, &alarm->
time,
224 pl031_alarm_irq_enable(dev, alarm->
enabled);
234 unsigned long rtcmis;
249 static int pl031_read_time(
struct device *dev,
struct rtc_time *tm)
258 static int pl031_set_time(
struct device *dev,
struct rtc_time *tm)
296 pl031_alarm_irq_enable(dev, alarm->
enabled);
372 if (IS_ERR(ldata->
rtc)) {
373 ret = PTR_ERR(ldata->
rtc);
378 vendor->
irqflags,
"rtc-pl031", ldata)) {
402 .read_time = pl031_read_time,
403 .set_time = pl031_set_time,
404 .read_alarm = pl031_read_alarm,
405 .set_alarm = pl031_set_alarm,
406 .alarm_irq_enable = pl031_alarm_irq_enable,
414 .read_time = pl031_read_time,
415 .set_time = pl031_set_time,
416 .read_alarm = pl031_read_alarm,
417 .set_alarm = pl031_set_alarm,
418 .alarm_irq_enable = pl031_alarm_irq_enable,
428 .read_time = pl031_stv2_read_time,
429 .set_time = pl031_stv2_set_time,
430 .read_alarm = pl031_stv2_read_alarm,
431 .set_alarm = pl031_stv2_set_alarm,
432 .alarm_irq_enable = pl031_alarm_irq_enable,
443 static struct amba_id pl031_ids[] = {
469 .id_table = pl031_ids,
470 .probe = pl031_probe,
471 .remove = pl031_remove,