From patchwork Tue May 7 01:17:26 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chao Xie X-Patchwork-Id: 241868 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from mail-yh0-x23d.google.com (mail-yh0-x23d.google.com [IPv6:2607:f8b0:4002:c01::23d]) (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 0B2E42C011B for ; Tue, 7 May 2013 11:20:37 +1000 (EST) Received: by mail-yh0-f61.google.com with SMTP id b20sf7492yha.26 for ; Mon, 06 May 2013 18:20:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=20120806; h=x-received:x-beenthere:x-received:received-spf:from:to:cc:subject :date:message-id:x-mailer:in-reply-to:references: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=XN9kYqZ0ZrMZkMP3f9oaBae8gNZqBE+1zlF2F5mMW3g=; b=wHlDST7KKNhw6wZnPc7fZM57J6U9zM1v245E5LYU1Z9EQzpzfTWe23QmCKqY5WLj1G BUH3mUmhv0wtGvS3wFK7WxW89CfVeDQCWeV2LCgxBp9lKPZ4qmkQyFyEnzcWuHdkQl09 mIoQ4n7EpLtp2QALBuaGAYdeCYTeJg3zPeqCJR/eJuCQYQLk8i4vdGp0/ykQSu8ThbRB tPrJpvd9E8gtFQvR+eK4zguAwk9dC1ZKdGQgwrQ8WowQW2zFoiZYYuqEtCKaTkB9Fgev GSE1/YiWpeJJghPQUoT7CbsDWlZTwXmU7FC8mEmXHrkuqm2lLqjARrpzJCniPQFXHGaS a5wA== X-Received: by 10.50.28.81 with SMTP id z17mr1003401igg.13.1367889634811; Mon, 06 May 2013 18:20:34 -0700 (PDT) X-BeenThere: rtc-linux@googlegroups.com Received: by 10.50.50.129 with SMTP id c1ls2181086igo.25.canary; Mon, 06 May 2013 18:20:33 -0700 (PDT) X-Received: by 10.66.150.129 with SMTP id ui1mr99452pab.25.1367889633947; Mon, 06 May 2013 18:20:33 -0700 (PDT) Received: from na3sys009aog111.obsmtp.com ([74.125.149.205]) by gmr-mx.google.com with SMTP id qo12si4173322pbb.1.2013.05.06.18.20.24 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Mon, 06 May 2013 18:20:33 -0700 (PDT) Received-SPF: temperror (google.com: error in processing during lookup of cxie4@marvell.com: DNS timeout) client-ip=74.125.149.205; Received: from SC-OWA01.marvell.com ([199.233.58.136]) (using TLSv1) by na3sys009aob111.postini.com ([74.125.148.12]) with SMTP ID DSNKUYhWz8MEHIqi+nB70vK1oFd9VckyjHAP@postini.com; Mon, 06 May 2013 18:20:33 PDT Received: from maili.marvell.com (10.93.76.43) by sc-owa01.marvell.com (10.93.76.21) with Microsoft SMTP Server id 8.3.213.0; Mon, 6 May 2013 18:17:28 -0700 Received: from localhost (unknown [10.38.36.239]) by maili.marvell.com (Postfix) with ESMTP id D994A4E513; Mon, 6 May 2013 18:17:28 -0700 (PDT) From: Chao Xie To: , , , , , , , , , CC: Chao Xie Subject: [rtc-linux] [PATCH 1/2] Revert "drivers/rtc/rtc-pxa.c: fix set time sync time issue" Date: Mon, 6 May 2013 21:17:26 -0400 Message-ID: <1367889447-15619-2-git-send-email-chao.xie@marvell.com> X-Mailer: git-send-email 1.7.4.1 In-Reply-To: <1367889447-15619-1-git-send-email-chao.xie@marvell.com> References: <1367889447-15619-1-git-send-email-chao.xie@marvell.com> MIME-Version: 1.0 X-Original-Sender: cxie4@marvell.com X-Original-Authentication-Results: gmr-mx.google.com; spf=temperror (google.com: error in processing during lookup of cxie4@marvell.com: DNS timeout) smtp.mail=cxie4@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: , This patch have something wrong. 1.The pxa_sync_time API is not needed. The RTC sync can be done by user space applications, so in kernel this API is not needed. 2.The pxa_rtc_open can not be deleted. This change has been declined during review at the mail list 3.Based on specification and talked with owner of driver, it does not matter to set WOM and DOW. Only need to keep PSBR control for pxa95x This reverts commit 57489fabb7f3fc02483df2125fdbfb8b1bb1fcd8. --- drivers/rtc/rtc-pxa.c | 63 +++++----------------------------------------- include/linux/rtc-pxa.h | 18 ------------- 2 files changed, 7 insertions(+), 74 deletions(-) delete mode 100644 include/linux/rtc-pxa.h diff --git a/drivers/rtc/rtc-pxa.c b/drivers/rtc/rtc-pxa.c index a2c75c1..e261e2f 100644 --- a/drivers/rtc/rtc-pxa.c +++ b/drivers/rtc/rtc-pxa.c @@ -81,29 +81,22 @@ #define RYAR1 0x1c #define RTCPICR 0x34 #define PIAR 0x38 -#define PSBR_RTC 0x00 #define rtc_readl(pxa_rtc, reg) \ __raw_readl((pxa_rtc)->base + (reg)) #define rtc_writel(pxa_rtc, reg, value) \ __raw_writel((value), (pxa_rtc)->base + (reg)) -#define rtc_readl_psbr(pxa_rtc, reg) \ - __raw_readl((pxa_rtc)->base_psbr + (reg)) -#define rtc_writel_psbr(pxa_rtc, reg, value) \ - __raw_writel((value), (pxa_rtc)->base_psbr + (reg)) struct pxa_rtc { struct resource *ress; - struct resource *ress_psbr; void __iomem *base; - void __iomem *base_psbr; int irq_1Hz; int irq_Alrm; struct rtc_device *rtc; spinlock_t lock; /* Protects this structure */ }; -static struct pxa_rtc *rtc_info; + static u32 ryxr_calc(struct rtc_time *tm) { return ((tm->tm_year + 1900) << RYxR_YEAR_S) @@ -125,7 +118,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_wday = ((rycr & 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; @@ -183,6 +176,7 @@ static irqreturn_t pxa_rtc_irq(int irq, void *dev_id) /* enable back rtc interrupts */ rtc_writel(pxa_rtc, RTSR, rtsr & ~RTSR_TRIG_MASK); + spin_unlock(&pxa_rtc->lock); return IRQ_HANDLED; } @@ -257,45 +251,12 @@ static int pxa_rtc_read_time(struct device *dev, struct rtc_time *tm) static int pxa_rtc_set_time(struct device *dev, struct rtc_time *tm) { struct pxa_rtc *pxa_rtc = dev_get_drvdata(dev); - /* sequence to wirte pxa rtc register RCNR RDCR RYCR is - *1. set PSBR[RWE] bit, take 2x32-khz to complete - *2. write to RTC register,take 2x32-khz to complete - *3. clear PSBR[RWE] bit,take 2x32-khz to complete - */ - if ((tm->tm_year < 70) || (tm->tm_year > 138)) - return -EINVAL; - rtc_writel_psbr(rtc_info, PSBR_RTC, 0x01); - udelay(100); + rtc_writel(pxa_rtc, RYCR, ryxr_calc(tm)); rtc_writel(pxa_rtc, RDCR, rdxr_calc(tm)); - udelay(100); - rtc_writel_psbr(rtc_info, PSBR_RTC, 0x00); - udelay(100); - pxa_rtc_read_time(dev, tm); - dev_info(dev, "tm.year = %d, tm.month = %d, tm.day = %d\n", - tm->tm_year + 1900, tm->tm_mon, tm->tm_mday); - return 0; -} -int pxa_rtc_sync_time(unsigned int ticks) -{ - /* sequence to wirte pxa rtc register RCNR RDCR RYCR is - *1. set PSBR[RWE] bit, take 2x32-khz to complete - *2. write to RTC register,take 2x32-khz to complete - *3. clear PSBR[RWE] bit,take 2x32-khz to complete - */ - struct rtc_time tm; - rtc_time_to_tm(ticks, &tm); - rtc_writel_psbr(rtc_info, PSBR_RTC, 0x01); - udelay(100); - rtc_writel(rtc_info, RYCR, ryxr_calc(&tm)); - rtc_writel(rtc_info, RDCR, rdxr_calc(&tm)); - udelay(100); - rtc_writel_psbr(rtc_info, PSBR_RTC, 0x00); - udelay(100); return 0; } -EXPORT_SYMBOL(pxa_rtc_sync_time); static int pxa_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alrm) { @@ -367,7 +328,7 @@ static int __init pxa_rtc_probe(struct platform_device *pdev) pxa_rtc = kzalloc(sizeof(struct pxa_rtc), GFP_KERNEL); if (!pxa_rtc) return -ENOMEM; - rtc_info = pxa_rtc; + spin_lock_init(&pxa_rtc->lock); platform_set_drvdata(pdev, pxa_rtc); @@ -377,11 +338,6 @@ static int __init pxa_rtc_probe(struct platform_device *pdev) dev_err(dev, "No I/O memory resource defined\n"); goto err_ress; } - pxa_rtc->ress_psbr = platform_get_resource(pdev, IORESOURCE_MEM, 1); - if (!pxa_rtc->ress_psbr) { - dev_err(dev, "No I/O memory resource defined\n"); - goto err_ress; - } pxa_rtc->irq_1Hz = platform_get_irq(pdev, 0); if (pxa_rtc->irq_1Hz < 0) { @@ -393,6 +349,7 @@ static int __init pxa_rtc_probe(struct platform_device *pdev) dev_err(dev, "No alarm IRQ resource defined\n"); goto err_ress; } + pxa_rtc_open(dev); ret = -ENOMEM; pxa_rtc->base = ioremap(pxa_rtc->ress->start, resource_size(pxa_rtc->ress)); @@ -401,12 +358,6 @@ static int __init pxa_rtc_probe(struct platform_device *pdev) goto err_map; } - pxa_rtc->base_psbr = ioremap(pxa_rtc->ress_psbr->start, - resource_size(pxa_rtc->ress_psbr)); - if (!pxa_rtc->base_psbr) { - dev_err(&pdev->dev, "Unable to map pxa RTC PSBR I/O memory\n"); - goto err_map; - } /* * If the clock divider is uninitialized then reset it to the * default value to get the 1Hz clock. @@ -429,7 +380,7 @@ static int __init pxa_rtc_probe(struct platform_device *pdev) } device_init_wakeup(dev, 1); - pxa_rtc_open(dev); + return 0; err_rtc_reg: diff --git a/include/linux/rtc-pxa.h b/include/linux/rtc-pxa.h deleted file mode 100644 index 71bc45f..0000000 --- a/include/linux/rtc-pxa.h +++ /dev/null @@ -1,18 +0,0 @@ -/* - * include/linux/rtc-pxa.h - * - * RTC PXA Header file - * - * Copyright (C) 2010 Marvell International Ltd. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 as - * published by the Free Software Foundation. - */ - -#ifndef __LINUX_RTC_PXA_H -#define __LINUX_RTC_PXA_H - -extern int pxa_rtc_sync_time(unsigned int ticks); - -#endif /* __LINUX_RTC_PXA_H */