From patchwork Thu Oct 7 08:20:07 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kukjin Kim X-Patchwork-Id: 67009 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from mail-fx0-f56.google.com (mail-fx0-f56.google.com [209.85.161.56]) by ozlabs.org (Postfix) with ESMTP id E3518B70D3 for ; Thu, 7 Oct 2010 19:29:51 +1100 (EST) Received: by fxm1 with SMTP id 1sf101857fxm.11 for ; Thu, 07 Oct 2010 01:29:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=beta; h=domainkey-signature:received:mime-version:x-beenthere:received :received:received:received:received-spf:received:received: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:list-post:list-help:list-archive :sender:list-subscribe:list-unsubscribe:content-type; bh=kGXlynCTYPbAgh0g7Sbjis7rKkUlX0fmnSbixUFnGbQ=; b=MaQ8pPA8gwpIt+trZqeW4nc520JLJPnynqV7jLOt1YRCQMXtdUl68zuWF7PjDv0aZr 7f0SqmsBdzt7f6Zj5g6kQ3h1NoQ4F4vgJTLeZNY+9P1YydOmE85N1WaT1l8EF/ErzI8b GKFWPcjeidDqmpHg5NdqwrtsVTdaJp0O0Nwh0= DomainKey-Signature: a=rsa-sha1; c=nofws; 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:list-post:list-help:list-archive:sender:list-subscribe :list-unsubscribe:content-type; b=G7gBdZMO3GbyMJrOvDc6O7FMXF3wYUa4A3bIyYHeuLVBhh5NZhollAKisWCE+szqUC TsM1ToBuqg6yGJef8f24qB37rU+p8TnL0/vLufGS+z4enUWeaxnH7XN/u9taY2icLvrf HqrVAVxp21ezyxH326DXe7G70J5MTDi+GOLjs= Received: by 10.223.91.65 with SMTP id l1mr5255fam.43.1286440188150; Thu, 07 Oct 2010 01:29:48 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: rtc-linux@googlegroups.com Received: by 10.223.59.212 with SMTP id m20ls2475693fah.3.p; Thu, 07 Oct 2010 01:29:47 -0700 (PDT) Received: by 10.223.105.131 with SMTP id t3mr13899fao.14.1286440187446; Thu, 07 Oct 2010 01:29:47 -0700 (PDT) Received: by 10.223.105.131 with SMTP id t3mr13898fao.14.1286440187422; Thu, 07 Oct 2010 01:29:47 -0700 (PDT) Received: from ganesha.gnumonks.org (ganesha.gnumonks.org [213.95.27.120]) by gmr-mx.google.com with ESMTP id 28si501638fas.11.2010.10.07.01.29.47; Thu, 07 Oct 2010 01:29:47 -0700 (PDT) Received-SPF: neutral (google.com: 213.95.27.120 is neither permitted nor denied by best guess record for domain of kgene.kim@samsung.com) client-ip=213.95.27.120; Received: from uucp by ganesha.gnumonks.org with local-bsmtp (Exim 4.69) (envelope-from ) id 1P3lrD-0005P2-H9; Thu, 07 Oct 2010 10:29:43 +0200 Received: from [12.23.102.184] (helo=localhost.localdomain) by jackpot.kr.gnumonks.org with esmtp (Exim 4.69) (envelope-from ) id 1P3l6j-0001Vo-VL; Thu, 07 Oct 2010 16:41:41 +0900 From: Kukjin Kim To: linux-arm-kernel@lists.infradead.org, linux-samsung-soc@vger.kernel.org, rtc-linux@googlegroups.com Cc: ben-linux@fluff.org, p_gortmaker@yahoo.com, a.zummo@towertech.it, Changhwan Youn , Kukjin Kim Subject: [rtc-linux] [PATCH v2 2/3] rtc: rtc-s3c: Fix on RTC initialization method Date: Thu, 7 Oct 2010 17:20:07 +0900 Message-Id: <1286439608-22722-2-git-send-email-kgene.kim@samsung.com> X-Mailer: git-send-email 1.6.2.5 In-Reply-To: <1286439608-22722-1-git-send-email-kgene.kim@samsung.com> References: <1286439608-22722-1-git-send-email-kgene.kim@samsung.com> X-Original-Sender: kgene.kim@samsung.com X-Original-Authentication-Results: gmr-mx.google.com; spf=neutral (google.com: 213.95.27.120 is neither permitted nor denied by best guess record for domain of kgene.kim@samsung.com) smtp.mail=kgene.kim@samsung.com Reply-To: rtc-linux@googlegroups.com Precedence: list Mailing-list: list rtc-linux@googlegroups.com; contact rtc-linux+owners@googlegroups.com List-ID: List-Post: , List-Help: , List-Archive: Sender: rtc-linux@googlegroups.com List-Subscribe: , List-Unsubscribe: , From: Changhwan Youn This patch changes RTC initialization method on probe(). The 'rtc_valid_tm(tm)' can check whether RTC BCD is valid or not. And should be changed the method of check because previous method cannot validate RTC BCD registers properly. Signed-off-by: Changhwan Youn Signed-off-by: Kukjin Kim Cc: Ben Dooks --- Changes since v1: - Added 'dev_warn' when initialized RTC as per Ben's suggestion drivers/rtc/rtc-s3c.c | 18 +++++++++++++----- 1 files changed, 13 insertions(+), 5 deletions(-) diff --git a/drivers/rtc/rtc-s3c.c b/drivers/rtc/rtc-s3c.c index 276b7c1..125c50a 100644 --- a/drivers/rtc/rtc-s3c.c +++ b/drivers/rtc/rtc-s3c.c @@ -453,8 +453,8 @@ static int __devexit s3c_rtc_remove(struct platform_device *dev) static int __devinit s3c_rtc_probe(struct platform_device *pdev) { struct rtc_device *rtc; + struct rtc_time rtc_tm; struct resource *res; - unsigned int tmp, i; int ret; pr_debug("%s: probe=%p\n", __func__, pdev); @@ -535,11 +535,19 @@ static int __devinit s3c_rtc_probe(struct platform_device *pdev) /* Check RTC Time */ - for (i = S3C2410_RTCSEC; i <= S3C2410_RTCYEAR; i += 0x4) { - tmp = readb(s3c_rtc_base + i); + s3c_rtc_gettime(NULL, &rtc_tm); - if ((tmp & 0xf) > 0x9 || ((tmp >> 4) & 0xf) > 0x9) - writeb(0, s3c_rtc_base + i); + if (rtc_valid_tm(&rtc_tm)) { + rtc_tm.tm_year = 100; + rtc_tm.tm_mon = 0; + rtc_tm.tm_mday = 1; + rtc_tm.tm_hour = 0; + rtc_tm.tm_min = 0; + rtc_tm.tm_sec = 0; + + s3c_rtc_settime(NULL, &rtc_tm); + + dev_warn(&pdev->dev, "warning: invalid RTC value so initializing it\n"); } if (s3c_rtc_cpu_type == TYPE_S3C64XX)