mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Yauhen Kharuzhy <jekhor@gmail.com>
To: Alessandro Zummo <a.zummo@towertech.it>
Cc: rtc-linux@googlegroups.com, linux-kernel@vger.kernel.org,
	Daniel Mack <daniel@caiaq.de>, Yauhen Kharuzhy <jekhor@gmail.com>
Subject: [PATCH 1/2] RTC MXC: Fix setting time for MX1 SoC
Date: Sun,  6 Nov 2011 19:46:45 +0300	[thread overview]
Message-ID: <1320598006-17678-2-git-send-email-jekhor@gmail.com> (raw)
In-Reply-To: <1320598006-17678-1-git-send-email-jekhor@gmail.com>

There is no way to track year in the i.MX1 RTC: Days Counter register is
9-bit wide only. Attempt to save date after 1970-01-01 plus 512 days
causes endless loop in mxc_rtc_set_mmss(). Fix this by resetting year to
1970.

Signed-off-by: Yauhen Kharuzhy <jekhor@gmail.com>
---
 drivers/rtc/rtc-mxc.c |   11 +++++++++++
 1 files changed, 11 insertions(+), 0 deletions(-)

diff --git a/drivers/rtc/rtc-mxc.c b/drivers/rtc/rtc-mxc.c
index 39e41fb..1cf6a0b 100644
--- a/drivers/rtc/rtc-mxc.c
+++ b/drivers/rtc/rtc-mxc.c
@@ -290,6 +290,17 @@ static int mxc_rtc_read_time(struct device *dev, struct rtc_time *tm)
  */
 static int mxc_rtc_set_mmss(struct device *dev, unsigned long time)
 {
+	/* RTC_DAYR register is 9-bit in MX1 SoC,
+	 * save time and day of year only
+	 */
+	if (cpu_is_mx1()) {
+		struct rtc_time tm;
+
+		rtc_time_to_tm(time, &tm);
+		tm.tm_year = 70;
+		rtc_tm_to_time(&tm, &time);
+	}
+
 	/* Avoid roll-over from reading the different registers */
 	do {
 		set_alarm_or_time(dev, MXC_RTC_TIME, time);
-- 
1.7.7.1


  reply	other threads:[~2011-11-06 16:47 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-11-06 16:46 [PATCH 0/2] i.MX1 RTC fixes Yauhen Kharuzhy
2011-11-06 16:46 ` Yauhen Kharuzhy [this message]
2011-11-06 16:46 ` [PATCH 2/2] RTC MXC: Make alarm working Yauhen Kharuzhy
2011-11-28 22:56   ` Andrew Morton

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=1320598006-17678-2-git-send-email-jekhor@gmail.com \
    --to=jekhor@gmail.com \
    --cc=a.zummo@towertech.it \
    --cc=daniel@caiaq.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=rtc-linux@googlegroups.com \
    /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

all inboxes | Powered by JetHome®