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: 8580 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id A2A3023E61 for ; Mon, 14 May 2012 09:17:13 +0000 (UTC) Received: from mail-gg0-f180.google.com (mail-gg0-f180.google.com [209.85.161.180]) by fiordland.canonical.com (Postfix) with ESMTP id 6D541A184F0 for ; Mon, 14 May 2012 09:17:13 +0000 (UTC) Received: by ggnf1 with SMTP id f1so3107136ggn.11 for ; Mon, 14 May 2012 02:17:12 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-forwarded-to:x-forwarded-for:delivered-to:received-spf:from:to:cc :subject:date:message-id:x-mailer:mime-version:content-type :x-gm-message-state; bh=5cQw7RFI+FuO+L/EKzQqxcBdKQNs87OYqw1eEmm04WE=; b=BhiCnqMpazkLRt3JyAqqSlMJGAqIUk6PhSbJ7BfoAR1GFkFznIy3jYjYuFPGucbIxT mOKaTboPsVtHwHXGL0mTEPUdtVumi1bbWj2gvSpUdH5KzrhJW7tymWqnFaxGCbDaKmRk efKJcvks+7pmPGizJFFWpq/tJR50M5TSvKB7viZ18h9X5pVMSyX98gMI/L18vaZGoAbC iDtT8UOFHMvxPhvaOsniiAq1P1WkpqFt3DkY9f7ERzXe2F6J31Dn8qYxdxRUnEYItP4g XzwyFXP4y2XQtr3OssE/XOmSVeghBj5Wal6PM40mwof1ndVDol0siQsF9b/sGJZATOTl 6DHA== Received: by 10.50.185.233 with SMTP id ff9mr3748628igc.57.1336987032746; Mon, 14 May 2012 02:17:12 -0700 (PDT) X-Forwarded-To: linaro-patchwork@canonical.com X-Forwarded-For: patch@linaro.org linaro-patchwork@canonical.com Delivered-To: patches@linaro.org Received: by 10.231.35.72 with SMTP id o8csp329058ibd; Mon, 14 May 2012 02:17:11 -0700 (PDT) Received: by 10.213.145.67 with SMTP id c3mr1217234ebv.144.1336987031006; Mon, 14 May 2012 02:17:11 -0700 (PDT) Received: from eu1sys200aog103.obsmtp.com (eu1sys200aog103.obsmtp.com. [207.126.144.115]) by mx.google.com with SMTP id g15si5261942eea.122.2012.05.14.02.17.01 (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; Authentication-Results: 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 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: [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-Gm-Message-State: ALoCoQld+6F8mt6d8FJjdd72nhLimsn4JIIQkGL4JWSruGG44SmtEErsP/CtOeWzlZ0boyPhbo/8 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)) {