From patchwork Sun Nov 6 16:46:45 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yauhen Kharuzhy X-Patchwork-Id: 123938 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from mail-bw0-f56.google.com (mail-bw0-f56.google.com [209.85.214.56]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority" (verified OK)) by ozlabs.org (Postfix) with ESMTPS id 61026B6F82 for ; Mon, 7 Nov 2011 03:47:05 +1100 (EST) Received: by bkbzu17 with SMTP id zu17sf3529099bkb.11 for ; Sun, 06 Nov 2011 08:47:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=beta; h=mime-version:x-beenthere:received-spf:from:to:cc:subject:date :message-id:x-mailer:in-reply-to:references:x-original-sender :x-original-authentication-results:reply-to:precedence:mailing-list :list-id:x-google-group-id:list-post:list-help:list-archive:sender :list-subscribe:list-unsubscribe:content-type; bh=PoCqUe7hU6gmPteWpcffD3m5KaaTwFsftcLQ6OZN5Rw=; b=pKcCpj0FuJr5DY+Zn/apHkSwEgv/pBraRsLr0lnbrv95ta/3TqzXpbb9Fp18QXqtmI nXQbPE/CIcE/7hoz4lyi/4ESHWbffFXg9GIsbPSIBID/NwMqhLQT4gnl8bhdH5Y0yBGb tsatgEHeMJXiwt7ncb4zCFkaywUPvyakqvGcI= Received: by 10.205.128.144 with SMTP id he16mr229640bkc.4.1320598018594; Sun, 06 Nov 2011 08:46:58 -0800 (PST) MIME-Version: 1.0 X-BeenThere: rtc-linux@googlegroups.com Received: by 10.204.29.7 with SMTP id o7ls1971691bkc.2.gmail; Sun, 06 Nov 2011 08:46:57 -0800 (PST) Received: by 10.204.151.81 with SMTP id b17mr2649417bkw.3.1320598017490; Sun, 06 Nov 2011 08:46:57 -0800 (PST) Received: by 10.204.151.81 with SMTP id b17mr2649416bkw.3.1320598017474; Sun, 06 Nov 2011 08:46:57 -0800 (PST) Received: from mail-fx0-f45.google.com (mail-fx0-f45.google.com [209.85.161.45]) by gmr-mx.google.com with ESMTPS id i17si8507676fai.0.2011.11.06.08.46.57 (version=TLSv1/SSLv3 cipher=OTHER); Sun, 06 Nov 2011 08:46:57 -0800 (PST) Received-SPF: pass (google.com: domain of jekhor@gmail.com designates 209.85.161.45 as permitted sender) client-ip=209.85.161.45; Received: by mail-fx0-f45.google.com with SMTP id p15so5882579faa.18 for ; Sun, 06 Nov 2011 08:46:57 -0800 (PST) Received: by 10.223.14.197 with SMTP id h5mr2107520faa.2.1320598017354; Sun, 06 Nov 2011 08:46:57 -0800 (PST) Received: from localhost.localdomain (vulture-nat-38.telecom.by. [213.184.224.38]) by mx.google.com with ESMTPS id n25sm27360192fah.15.2011.11.06.08.46.55 (version=TLSv1/SSLv3 cipher=OTHER); Sun, 06 Nov 2011 08:46:56 -0800 (PST) Received: from jek by localhost.localdomain with local (Exim 4.77) (envelope-from ) id 1RN5rx-0004bm-DU; Sun, 06 Nov 2011 19:46:53 +0300 From: Yauhen Kharuzhy To: Alessandro Zummo Cc: rtc-linux@googlegroups.com, linux-kernel@vger.kernel.org, Daniel Mack , Yauhen Kharuzhy Subject: [rtc-linux] [PATCH 1/2] RTC MXC: Fix setting time for MX1 SoC Date: Sun, 6 Nov 2011 19:46:45 +0300 Message-Id: <1320598006-17678-2-git-send-email-jekhor@gmail.com> X-Mailer: git-send-email 1.7.7.1 In-Reply-To: <1320598006-17678-1-git-send-email-jekhor@gmail.com> References: <1320598006-17678-1-git-send-email-jekhor@gmail.com> X-Original-Sender: jekhor@gmail.com X-Original-Authentication-Results: gmr-mx.google.com; spf=pass (google.com: domain of jekhor@gmail.com designates 209.85.161.45 as permitted sender) smtp.mail=jekhor@gmail.com; dkim=pass (test mode) header.i=@gmail.com Reply-To: rtc-linux@googlegroups.com Precedence: list Mailing-list: list rtc-linux@googlegroups.com; contact rtc-linux+owners@googlegroups.com List-ID: X-Google-Group-Id: 712029733259 List-Post: , List-Help: , List-Archive: Sender: rtc-linux@googlegroups.com List-Subscribe: , List-Unsubscribe: , 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 --- 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);