14 #include <linux/module.h>
15 #include <linux/rtc.h>
19 #include <linux/slab.h>
97 out_8(®s->set_time, 0x1);
98 out_8(®s->set_time, 0x3);
99 out_8(®s->set_time, 0x1);
100 out_8(®s->set_time, 0x0);
120 mpc5121_rtc_update_smh(regs, tm);
144 mpc5121_rtc_update_smh(regs, tm);
149 static int mpc5200_rtc_read_time(
struct device *dev,
struct rtc_time *tm)
176 static int mpc5200_rtc_set_time(
struct device *dev,
struct rtc_time *tm)
181 mpc5121_rtc_update_smh(regs, tm);
218 if (alarm->
time.tm_sec) {
219 alarm->
time.tm_sec = 0;
220 alarm->
time.tm_min++;
221 if (alarm->
time.tm_min >= 60) {
222 alarm->
time.tm_min = 0;
223 alarm->
time.tm_hour++;
224 if (alarm->
time.tm_hour >= 24)
225 alarm->
time.tm_hour = 0;
229 alarm->
time.tm_mday = -1;
230 alarm->
time.tm_mon = -1;
231 alarm->
time.tm_year = -1;
242 static irqreturn_t mpc5121_rtc_handler(
int irq,
void *dev)
259 static irqreturn_t mpc5121_rtc_handler_upd(
int irq,
void *dev)
275 static int mpc5121_rtc_alarm_irq_enable(
struct device *dev,
294 .read_time = mpc5121_rtc_read_time,
295 .set_time = mpc5121_rtc_set_time,
296 .read_alarm = mpc5121_rtc_read_alarm,
297 .set_alarm = mpc5121_rtc_set_alarm,
298 .alarm_irq_enable = mpc5121_rtc_alarm_irq_enable,
302 .read_time = mpc5200_rtc_read_time,
303 .set_time = mpc5200_rtc_set_time,
304 .read_alarm = mpc5121_rtc_read_alarm,
305 .set_alarm = mpc5121_rtc_set_alarm,
306 .alarm_irq_enable = mpc5121_rtc_alarm_irq_enable,
320 dev_err(&op->
dev,
"%s: couldn't map io space\n", __func__);
331 "mpc5121-rtc", &op->
dev);
333 dev_err(&op->
dev,
"%s: could not request irq: %i\n",
340 0,
"mpc5121-rtc_upd", &op->
dev);
342 dev_err(&op->
dev,
"%s: could not request irq: %i\n",
352 "mpc5121-rtc: Battery or oscillator failure!\n");
363 if (IS_ERR(rtc->
rtc)) {
364 err = PTR_ERR(rtc->
rtc);
367 rtc->
rtc->uie_unsupported = 1;
407 { .compatible =
"fsl,mpc5121-rtc", },
408 { .compatible =
"fsl,mpc5200-rtc", },
414 .name =
"mpc5121-rtc",
416 .of_match_table = mpc5121_rtc_match,
418 .probe = mpc5121_rtc_probe,