From: chao.xie@marvell.com (Chao Xie)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 2/4] rtc: pxa: fix rtc caculation issue
Date: Wed, 28 Nov 2012 21:21:08 -0500 [thread overview]
Message-ID: <1354155670-6267-2-git-send-email-chao.xie@marvell.com> (raw)
In-Reply-To: <1354155670-6267-1-git-send-email-chao.xie@marvell.com>
The original calculation does not take care of week-of-month and
day-of-week. It will make rdar/rdcr not matched when set the
alarm.
Signed-off-by: Chao Xie <chao.xie@marvell.com>
---
drivers/rtc/rtc-pxa.c | 10 +++++++++-
1 files changed, 9 insertions(+), 1 deletions(-)
diff --git a/drivers/rtc/rtc-pxa.c b/drivers/rtc/rtc-pxa.c
index f771b2e..22ea4f5 100644
--- a/drivers/rtc/rtc-pxa.c
+++ b/drivers/rtc/rtc-pxa.c
@@ -62,6 +62,10 @@
#define RYxR_MONTH_S 5
#define RYxR_MONTH_MASK (0xf << RYxR_MONTH_S)
#define RYxR_DAY_MASK 0x1f
+#define RDxR_WOM_S 20
+#define RDxR_WOM_MASK (0x7 << RDxR_WOM_S)
+#define RDxR_DOW_S 17
+#define RDxR_DOW_MASK (0x7 << RDxR_DOW_S)
#define RDxR_HOUR_S 12
#define RDxR_HOUR_MASK (0x1f << RDxR_HOUR_S)
#define RDxR_MIN_S 6
@@ -100,7 +104,10 @@ static u32 ryxr_calc(struct rtc_time *tm)
static u32 rdxr_calc(struct rtc_time *tm)
{
- return (tm->tm_hour << RDxR_HOUR_S) | (tm->tm_min << RDxR_MIN_S)
+ return ((((tm->tm_mday + 6) / 7) << RDxR_WOM_S) & RDxR_WOM_MASK)
+ | (((tm->tm_wday + 1) << RDxR_DOW_S) & RDxR_DOW_MASK)
+ | (tm->tm_hour << RDxR_HOUR_S)
+ | (tm->tm_min << RDxR_MIN_S)
| tm->tm_sec;
}
@@ -109,6 +116,7 @@ static void tm_calc(u32 rycr, u32 rdcr, struct rtc_time *tm)
tm->tm_year = ((rycr & RYxR_YEAR_MASK) >> RYxR_YEAR_S) - 1900;
tm->tm_mon = (((rycr & RYxR_MONTH_MASK) >> RYxR_MONTH_S)) - 1;
tm->tm_mday = (rycr & RYxR_DAY_MASK);
+ tm->tm_wday = ((rdcr & RDxR_DOW_MASK) >> RDxR_DOW_S) - 1;
tm->tm_hour = (rdcr & RDxR_HOUR_MASK) >> RDxR_HOUR_S;
tm->tm_min = (rdcr & RDxR_MIN_MASK) >> RDxR_MIN_S;
tm->tm_sec = rdcr & RDxR_SEC_MASK;
--
1.7.4.1
next prev parent reply other threads:[~2012-11-29 2:21 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-11-29 2:21 [PATCH 1/4] rtc: sa1100: enable/disable rtc when probe/remove the device Chao Xie
2012-11-29 2:21 ` Chao Xie [this message]
2012-11-29 20:04 ` [PATCH 2/4] rtc: pxa: fix rtc caculation issue Robert Jarzmik
2012-12-03 2:40 ` Chao Xie
2012-12-04 2:53 ` Chao Xie
2012-11-29 2:21 ` [PATCH 3/4] rtc: pxa: add pxa95x rtc support Chao Xie
2012-12-04 7:03 ` Haojian Zhuang
2012-11-29 2:21 ` [PATCH 4/4] rtc: pxa: request rtc irqs when probe/remove the device Chao Xie
2012-11-29 10:26 ` Russell King - ARM Linux
2012-11-29 20:10 ` Robert Jarzmik
2012-11-29 10:25 ` [PATCH 1/4] rtc: sa1100: enable/disable rtc " Russell King - ARM Linux
2012-11-30 7:04 ` Haojian Zhuang
2012-12-03 1:39 ` Chao Xie
2012-12-03 2:53 ` Chao Xie
2012-12-03 5:35 ` Haojian Zhuang
2012-12-03 5:42 ` Chao Xie
2012-12-03 9:48 ` Russell King - ARM Linux
2012-12-04 2:51 ` Chao Xie
2012-12-04 7:01 ` Haojian Zhuang
2012-12-03 5:33 ` Haojian Zhuang
2012-12-03 5:02 ` devendra.aaru
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1354155670-6267-2-git-send-email-chao.xie@marvell.com \
--to=chao.xie@marvell.com \
--cc=linux-arm-kernel@lists.infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).