From patchwork Fri Sep 7 06:07:57 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: wzch X-Patchwork-Id: 182324 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from mail-pb0-f56.google.com (mail-pb0-f56.google.com [209.85.160.56]) (using TLSv1 with cipher ECDHE-RSA-RC4-SHA (128/128 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id E385F2C0083 for ; Fri, 7 Sep 2012 16:08:35 +1000 (EST) Received: by pbbjt11 with SMTP id jt11sf1994247pbb.11 for ; Thu, 06 Sep 2012 23:08:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=20120806; h=mime-version:x-beenthere:received-spf:from:to:cc:subject:date :message-id:x-mailer:x-originalarrivaltime: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=sGzlMQ2GEu2zfTXpxHps4ZB+GzvUwOrXsqMWiGVP9TE=; b=oSd20efuFF1ul0nNGn/zPDM40IDQdUgetozYt8kRlsV892QFJ96GfInRmdTpI9mWLX IojjmVXODlNd9kTKduNRw4xx9fOIrUo3b9ke4FpoLfjx5SigUQ+NMdmP6IoA3jJLkza3 mxml9gMNNUM6vRlrx6uDbxMYoUuM1mqwkXzl6lvLU9Vmt40ZQ/Ux7oL0hn4Exn1HLKvR VHTlUQwX+Cov6eTVpR02gu3F4dEkTc9pvKbcxYamm5H8Ftou6FGdGQlcCMeVG1elLfa0 UpKIcu+Dw21iGoFEgj+KQxR6uLRfShbyOOpGZP8mEPldk40SLy9WHgpPzeeThHLnZcRV 6TOg== Received: by 10.68.232.230 with SMTP id tr6mr1108560pbc.16.1346998113136; Thu, 06 Sep 2012 23:08:33 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: rtc-linux@googlegroups.com Received: by 10.68.194.202 with SMTP id hy10ls835871pbc.0.gmail; Thu, 06 Sep 2012 23:08:32 -0700 (PDT) Received: by 10.68.141.225 with SMTP id rr1mr1076204pbb.2.1346998112210; Thu, 06 Sep 2012 23:08:32 -0700 (PDT) Received: by 10.68.141.225 with SMTP id rr1mr1076203pbb.2.1346998112199; Thu, 06 Sep 2012 23:08:32 -0700 (PDT) Received: from na3sys009aog124.obsmtp.com (na3sys009aog124.obsmtp.com [74.125.149.151]) by gmr-mx.google.com with SMTP id qq4si1913157pbb.1.2012.09.06.23.08.22 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 06 Sep 2012 23:08:32 -0700 (PDT) Received-SPF: neutral (google.com: 74.125.149.151 is neither permitted nor denied by best guess record for domain of wenzeng.chen@marvell.com) client-ip=74.125.149.151; Received: from MSI-MTA.marvell.com ([65.219.4.132]) (using TLSv1) by na3sys009aob124.postini.com ([74.125.148.12]) with SMTP ID DSNKUEmPUU8ACOSqX3r5r6YdmKo7lpQQTq+C@postini.com; Thu, 06 Sep 2012 23:08:32 PDT Received: from maili.marvell.com ([10.68.76.210]) by MSI-MTA.marvell.com with Microsoft SMTPSVC(6.0.3790.3959); Thu, 6 Sep 2012 23:08:11 -0700 Received: from localhost (unknown [10.38.37.60]) by maili.marvell.com (Postfix) with ESMTP id 6F3F04E510; Thu, 6 Sep 2012 23:08:11 -0700 (PDT) From: wzch To: a.zummo@towertech.it, rtc-linux@googlegroups.com, linux-kernel@vger.kernel.org Cc: Wenzeng Chen , Wenzeng Chen Subject: [rtc-linux] [PATCH] rtc/pxa: fix set wrong data to RTC register issue Date: Fri, 7 Sep 2012 14:07:57 +0800 Message-Id: <1346998077-29090-1-git-send-email-wzch@marvell.com> X-Mailer: git-send-email 1.7.1 X-OriginalArrivalTime: 07 Sep 2012 06:08:11.0125 (UTC) FILETIME=[28972A50:01CD8CBF] X-Original-Sender: wzch@marvell.com X-Original-Authentication-Results: gmr-mx.google.com; spf=neutral (google.com: 74.125.149.151 is neither permitted nor denied by best guess record for domain of wenzeng.chen@marvell.com) smtp.mail=wenzeng.chen@marvell.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: , From: Wenzeng Chen Pxa rtc Day Count Register(RDCR) have 5 fields: Senconds, Minutes, Hour, Day-of-week(DOW) and Week-of-month(WOM). If someone wants to set the register, they can call rtc_writel(pxa_rtc, RDCR, rdxr_calc(tm)). But currently in function rdxr_calc(), we only get the value of minutes and hour, so we may set a wrong seconds/DOW/WOM value to RDCR register. Adding this patch to fix the issue. Change-Id: Iaf8cfc68c445d742637410e1bfb19e0fd7bc4a02 Signed-off-by: Wenzeng Chen --- drivers/rtc/rtc-pxa.c | 11 ++++++++++- 1 files changed, 10 insertions(+), 1 deletions(-) diff --git a/drivers/rtc/rtc-pxa.c b/drivers/rtc/rtc-pxa.c index 0075c8f..5397bb5 100644 --- a/drivers/rtc/rtc-pxa.c +++ b/drivers/rtc/rtc-pxa.c @@ -60,6 +60,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 @@ -89,6 +93,7 @@ struct pxa_rtc { spinlock_t lock; /* Protects this structure */ }; + static u32 ryxr_calc(struct rtc_time *tm) { return ((tm->tm_year + 1900) << RYxR_YEAR_S) @@ -98,7 +103,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; } @@ -107,6 +115,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;