From patchwork Mon May 14 09:16:47 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 158957 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from mail-ee0-f56.google.com (mail-ee0-f56.google.com [74.125.83.56]) (using TLSv1 with cipher ECDHE-RSA-RC4-SHA (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority" (not verified)) by ozlabs.org (Postfix) with ESMTPS id 5AB4FB7007 for ; Mon, 14 May 2012 19:17:15 +1000 (EST) Received: by eeke53 with SMTP id e53sf2591887eek.11 for ; Mon, 14 May 2012 02:17:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=beta; h=x-beenthere:received-spf:from:to:cc:subject:date:message-id :x-mailer:mime-version: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=3USN1Dn+aP3soXdl2bG1vnDVqaKwj1QSwsYDrM/4zrA=; b=57HDW4Ib4AUAKFIfWTqulgWqE04Oxdw4aisfQT/zL4u0WqsJhPJkB6g4SWTHIH4UvR 6s+9RUO2MIRzIZGEW/7gsL0dMpMsq65PxzCzag5VtmqoDIPRPxEHKllQX2eGkkGIEToz R4bT90Z/ZqRsED5WrUL6g0AJyzU/HfKi2wAwc= Received: by 10.180.101.230 with SMTP id fj6mr484298wib.1.1336987031887; Mon, 14 May 2012 02:17:11 -0700 (PDT) X-BeenThere: rtc-linux@googlegroups.com Received: by 10.213.109.153 with SMTP id j25ls785054ebp.5.gmail; Mon, 14 May 2012 02:17:11 -0700 (PDT) Received: by 10.14.127.4 with SMTP id c4mr1777324eei.3.1336987031259; Mon, 14 May 2012 02:17:11 -0700 (PDT) Received: by 10.14.127.4 with SMTP id c4mr1777323eei.3.1336987031242; Mon, 14 May 2012 02:17:11 -0700 (PDT) Received: from eu1sys200aog103.obsmtp.com (eu1sys200aog103.obsmtp.com. [207.126.144.115]) by gmr-mx.google.com with SMTP id t52si17956428eeb.0.2012.05.14.02.17.00 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 14 May 2012 02:17:10 -0700 (PDT) Received-SPF: neutral (google.com: 207.126.144.115 is neither permitted nor denied by best guess record for domain of linus.walleij@stericsson.com) client-ip=207.126.144.115; Received: from beta.dmz-ap.st.com ([138.198.100.35]) (using TLSv1) by eu1sys200aob103.postini.com ([207.126.147.11]) with SMTP ID DSNKT7DNjEsZFYqYwpUJZu4TyyvkucG7obCL@postini.com; Mon, 14 May 2012 09:17:10 UTC Received: from zeta.dmz-ap.st.com (ns6.st.com [138.198.234.13]) by beta.dmz-ap.st.com (STMicroelectronics) with ESMTP id 2E0BBDB; Mon, 14 May 2012 09:08:34 +0000 (GMT) Received: from relay1.stm.gmessaging.net (unknown [10.230.100.17]) by zeta.dmz-ap.st.com (STMicroelectronics) with ESMTP id 2C7562C1; Mon, 14 May 2012 09:16:55 +0000 (GMT) Received: from exdcvycastm022.EQ1STM.local (alteon-source-exch [10.230.100.61]) (using TLSv1 with cipher RC4-MD5 (128/128 bits)) (Client CN "exdcvycastm022", Issuer "exdcvycastm022" (not verified)) by relay1.stm.gmessaging.net (Postfix) with ESMTPS id 0B32824C9B2; Mon, 14 May 2012 11:16:49 +0200 (CEST) Received: from steludxu4075.lud.stericsson.com (10.230.100.153) by smtp.stericsson.com (10.230.100.30) with Microsoft SMTP Server (TLS) id 8.3.83.0; Mon, 14 May 2012 11:16:53 +0200 From: Linus Walleij To: Andrew Morton Cc: Alessandro Zummo , , Rajkumar Kasirajan , Mattias Wallin , Linus Walleij Subject: [rtc-linux] [PATCH 1/2] RTC: pl031: configured correct wday for 2000-01-01 Date: Mon, 14 May 2012 11:16:47 +0200 Message-ID: <1336987007-19027-1-git-send-email-linus.walleij@stericsson.com> X-Mailer: git-send-email 1.7.9.2 MIME-Version: 1.0 X-Original-Sender: linus.walleij@stericsson.com X-Original-Authentication-Results: gmr-mx.google.com; spf=neutral (google.com: 207.126.144.115 is neither permitted nor denied by best guess record for domain of linus.walleij@stericsson.com) smtp.mail=linus.walleij@stericsson.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: Rajkumar Kasirajan The reset date of the ST Micro version of PL031 is 2000-01-01. The correct weekday for 2000-01-01 is saturday, but pl031 is initialized to sunday. This may lead to alarm malfunction, so configure the correct wday if RTC_DR indicates reset. Cc: Mattias Wallin Signed-off-by: Rajkumar Kasirajan Signed-off-by: Linus Walleij --- drivers/rtc/rtc-pl031.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/drivers/rtc/rtc-pl031.c b/drivers/rtc/rtc-pl031.c index 684ef4b..f027c06 100644 --- a/drivers/rtc/rtc-pl031.c +++ b/drivers/rtc/rtc-pl031.c @@ -312,6 +312,7 @@ static int pl031_probe(struct amba_device *adev, const struct amba_id *id) int ret; struct pl031_local *ldata; struct rtc_class_ops *ops = id->data; + unsigned long time; ret = amba_request_regions(adev, NULL); if (ret) @@ -343,6 +344,23 @@ static int pl031_probe(struct amba_device *adev, const struct amba_id *id) writel(readl(ldata->base + RTC_CR) | RTC_CR_CWEN, ldata->base + RTC_CR); + /* + * On ST PL031 variants, the RTC reset value does not provide correct + * weekday for 2000-01-01. Correct the erroneous sunday to saturday. + */ + if (ldata->hw_designer == AMBA_VENDOR_ST) { + if (readl(ldata->base + RTC_YDR) == 0x2000) { + time = readl(ldata->base + RTC_DR); + if ((time & + (RTC_MON_MASK | RTC_MDAY_MASK | RTC_WDAY_MASK)) + == 0x02120000) { + time = time | (0x7 << RTC_WDAY_SHIFT); + writel(0x2000, ldata->base + RTC_YLR); + writel(time, ldata->base + RTC_LR); + } + } + } + ldata->rtc = rtc_device_register("pl031", &adev->dev, ops, THIS_MODULE); if (IS_ERR(ldata->rtc)) {