static int mpc5121_rtc_read_time(struct device *dev, struct rtc_time *tm) { struct mpc5121_rtc_data *rtc = dev_get_drvdata(dev); struct mpc5121_rtc_regs __iomem *regs = rtc->regs; unsigned long now; /* * linux time is actual_time plus the offset saved in target_time */ now = in_be32(®s->actual_time) + in_be32(®s->target_time); rtc_time_to_tm(now, tm); /* * update second minute hour registers * so alarms will work */ mpc5121_rtc_update_smh(regs, tm); return rtc_valid_tm(tm); }
static int mpc5121_rtc_read_time(struct device *dev, struct rtc_time *tm) { struct mpc5121_rtc_data *rtc = dev_get_drvdata(dev); struct mpc5121_rtc_regs __iomem *regs = rtc->regs; unsigned long now; /* */ now = in_be32(®s->actual_time) + in_be32(®s->target_time); rtc_time_to_tm(now, tm); /* */ mpc5121_rtc_update_smh(regs, tm); return rtc_valid_tm(tm); }
static int mpc5121_rtc_set_time(struct device *dev, struct rtc_time *tm) { struct mpc5121_rtc_data *rtc = dev_get_drvdata(dev); struct mpc5121_rtc_regs __iomem *regs = rtc->regs; int ret; unsigned long now; /* * The actual_time register is read only so we write the offset * between it and linux time to the target_time register. */ ret = rtc_tm_to_time(tm, &now); if (ret == 0) out_be32(®s->target_time, now - in_be32(®s->actual_time)); /* * update second minute hour registers * so alarms will work */ mpc5121_rtc_update_smh(regs, tm); return 0; }
static int mpc5121_rtc_set_time(struct device *dev, struct rtc_time *tm) { struct mpc5121_rtc_data *rtc = dev_get_drvdata(dev); struct mpc5121_rtc_regs __iomem *regs = rtc->regs; int ret; unsigned long now; /* */ ret = rtc_tm_to_time(tm, &now); if (ret == 0) out_be32(®s->target_time, now - in_be32(®s->actual_time)); /* */ mpc5121_rtc_update_smh(regs, tm); return 0; }