提交 fb4ac3c1 编写于 作者: K Krzysztof Kozlowski 提交者: Alexandre Belloni

rtc: s3c: Set year, month, day value for setting alarm

This patch sets year, month, day value for set_alarm function.
The current driver omits to set the values.

This fixes setting wake alarm for dates different than current day.
Without the patch the alarm scheduled for tomorrow would fire today on
chosen time.
Signed-off-by: NDonggeun Kim <dg77.kim@samsung.com>
Signed-off-by: NMyungJoo Ham <myungjoo.kim@samsung.com>
Signed-off-by: NKyungMin Park <kyungmin.park@samsung.com>
[k.kozlowski: Rebase and test the patch, update commit message]
Signed-off-by: NKrzysztof Kozlowski <k.kozlowski.k@gmail.com>
Signed-off-by: NAlexandre Belloni <alexandre.belloni@free-electrons.com>
上级 62c8c20a
...@@ -302,6 +302,7 @@ static int s3c_rtc_setalarm(struct device *dev, struct rtc_wkalrm *alrm) ...@@ -302,6 +302,7 @@ static int s3c_rtc_setalarm(struct device *dev, struct rtc_wkalrm *alrm)
struct s3c_rtc *info = dev_get_drvdata(dev); struct s3c_rtc *info = dev_get_drvdata(dev);
struct rtc_time *tm = &alrm->time; struct rtc_time *tm = &alrm->time;
unsigned int alrm_en; unsigned int alrm_en;
int year = tm->tm_year - 100;
dev_dbg(dev, "s3c_rtc_setalarm: %d, %04d.%02d.%02d %02d:%02d:%02d\n", dev_dbg(dev, "s3c_rtc_setalarm: %d, %04d.%02d.%02d %02d:%02d:%02d\n",
alrm->enabled, alrm->enabled,
...@@ -328,6 +329,21 @@ static int s3c_rtc_setalarm(struct device *dev, struct rtc_wkalrm *alrm) ...@@ -328,6 +329,21 @@ static int s3c_rtc_setalarm(struct device *dev, struct rtc_wkalrm *alrm)
writeb(bin2bcd(tm->tm_hour), info->base + S3C2410_ALMHOUR); writeb(bin2bcd(tm->tm_hour), info->base + S3C2410_ALMHOUR);
} }
if (year < 100 && year >= 0) {
alrm_en |= S3C2410_RTCALM_YEAREN;
writeb(bin2bcd(year), info->base + S3C2410_ALMYEAR);
}
if (tm->tm_mon < 12 && tm->tm_mon >= 0) {
alrm_en |= S3C2410_RTCALM_MONEN;
writeb(bin2bcd(tm->tm_mon + 1), info->base + S3C2410_ALMMON);
}
if (tm->tm_mday <= 31 && tm->tm_mday >= 1) {
alrm_en |= S3C2410_RTCALM_DAYEN;
writeb(bin2bcd(tm->tm_mday), info->base + S3C2410_ALMDATE);
}
dev_dbg(dev, "setting S3C2410_RTCALM to %08x\n", alrm_en); dev_dbg(dev, "setting S3C2410_RTCALM to %08x\n", alrm_en);
writeb(alrm_en, info->base + S3C2410_RTCALM); writeb(alrm_en, info->base + S3C2410_RTCALM);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册