From patchwork Thu Mar 19 10:05:58 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Magnus Damm X-Patchwork-Id: 13033 Received: from vger.kernel.org (vger.kernel.org [209.132.176.167]) by demeter.kernel.org (8.14.2/8.14.2) with ESMTP id n2JA8WfW003611 for ; Thu, 19 Mar 2009 10:08:32 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751706AbZCSKIc (ORCPT ); Thu, 19 Mar 2009 06:08:32 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1752233AbZCSKIc (ORCPT ); Thu, 19 Mar 2009 06:08:32 -0400 Received: from rv-out-0506.google.com ([209.85.198.225]:9193 "EHLO rv-out-0506.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751530AbZCSKIb (ORCPT ); Thu, 19 Mar 2009 06:08:31 -0400 Received: by rv-out-0506.google.com with SMTP id f9so492730rvb.1 for ; Thu, 19 Mar 2009 03:08:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:from:to:cc:date:message-id :subject; bh=/6uLc/CSKzAWCXOY0ia9Tq2AzFBr3zutO+uI9i9TVQk=; b=IfLIhVoOuFvrfWI0hE2RKwzuYX/qgrs1R5kZrZ26VbkoBr2m6fcGeXo9PBBuKT08Cj /m9hmDt7rWPoQePEitpSFhHtjPb+PKUTgHCQ6Y2BJsKpn7D25yhWepcXC/hHqXX+J4g2 hm3DcH9fv/qolzyQD+ThTov5xQi3eUPRCaN38= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=from:to:cc:date:message-id:subject; b=AyNy6EG+bwCoX6evgoG4mPxczHBg2qxK1EyhUZFqSJm88jn22xtwGj9WfQ9TbOT64b X/v7Br4799HDucZP3p0KeT5R1AxScfgkxGenDD4OoBgHwDXSrUZAn+T3wKprNbI+EdPi DFHEK2rZsj4aMmAxOwDlHx5iFePtp8D19dE5c= Received: by 10.114.197.10 with SMTP id u10mr1522863waf.96.1237457309349; Thu, 19 Mar 2009 03:08:29 -0700 (PDT) Received: from rx1.opensource.se (210.5.32.202.bf.2iij.net [202.32.5.210]) by mx.google.com with ESMTPS id m25sm970380waf.44.2009.03.19.03.08.27 (version=TLSv1/SSLv3 cipher=RC4-MD5); Thu, 19 Mar 2009 03:08:28 -0700 (PDT) From: Magnus Damm To: linux-sh@vger.kernel.org Cc: Magnus Damm , lethal@linux-sh.org Date: Thu, 19 Mar 2009 19:05:58 +0900 Message-Id: <20090319100558.9820.49100.sendpatchset@rx1.opensource.se> Subject: [PATCH] sh: sh-rtc carry interrupt rework Sender: linux-sh-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-sh@vger.kernel.org From: Magnus Damm This patch modifies the SuperH RTC driver to only enable carry interrupts when needed. So by default no interrupts are enabled with this patch. Without this patch a suspending system will most likely wake up by the carry interrupt regardless if the alarm interrupt has been enabled or not. Signed-off-by: Magnus Damm --- Tested on sh7723/ap320 hardware. drivers/rtc/rtc-sh.c | 40 ++++++++++++++++++++++++++++++++-------- 1 file changed, 32 insertions(+), 8 deletions(-) -- To unsubscribe from this list: send the line "unsubscribe linux-sh" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html --- 0001/drivers/rtc/rtc-sh.c +++ work/drivers/rtc/rtc-sh.c 2009-03-19 18:29:29.000000000 +0900 @@ -319,6 +319,25 @@ static int sh_rtc_proc(struct device *de return 0; } +static inline void sh_rtc_setcie(struct device *dev, unsigned int enable) +{ + struct sh_rtc *rtc = dev_get_drvdata(dev); + unsigned int tmp; + + spin_lock_irq(&rtc->lock); + + tmp = readb(rtc->regbase + RCR1); + + if (!enable) + tmp &= ~RCR1_CIE; + else + tmp |= RCR1_CIE; + + writeb(tmp, rtc->regbase + RCR1); + + spin_unlock_irq(&rtc->lock); +} + static int sh_rtc_ioctl(struct device *dev, unsigned int cmd, unsigned long arg) { struct sh_rtc *rtc = dev_get_drvdata(dev); @@ -335,9 +354,11 @@ static int sh_rtc_ioctl(struct device *d break; case RTC_UIE_OFF: rtc->periodic_freq &= ~PF_OXS; + sh_rtc_setcie(dev, 0); break; case RTC_UIE_ON: rtc->periodic_freq |= PF_OXS; + sh_rtc_setcie(dev, 1); break; case RTC_IRQP_READ: ret = put_user(rtc->rtc_dev->irq_freq, @@ -400,6 +421,10 @@ static int sh_rtc_read_time(struct devic tm->tm_sec--; #endif + /* only keep the carry interrupt enabled if UIE is on */ + if (!(rtc->periodic_freq & PF_OXS)) + sh_rtc_setcie(dev, 0); + dev_dbg(dev, "%s: tm is secs=%d, mins=%d, hours=%d, " "mday=%d, mon=%d, year=%d, wday=%d\n", __func__, @@ -616,7 +641,6 @@ static int __devinit sh_rtc_probe(struct { struct sh_rtc *rtc; struct resource *res; - unsigned int tmp; int ret; rtc = kzalloc(sizeof(struct sh_rtc), GFP_KERNEL); @@ -676,8 +700,6 @@ static int __devinit sh_rtc_probe(struct } rtc->rtc_dev->max_user_freq = 256; - rtc->rtc_dev->irq_freq = 1; - rtc->periodic_freq = 0x60; platform_set_drvdata(pdev, rtc); @@ -724,11 +746,12 @@ static int __devinit sh_rtc_probe(struct } } - tmp = readb(rtc->regbase + RCR1); - tmp &= ~RCR1_CF; - tmp |= RCR1_CIE; - writeb(tmp, rtc->regbase + RCR1); - + /* everything disabled by default */ + rtc->periodic_freq = 0; + rtc->rtc_dev->irq_freq = 0; + sh_rtc_setpie(&pdev->dev, 0); + sh_rtc_setaie(&pdev->dev, 0); + sh_rtc_setcie(&pdev->dev, 0); return 0; err_unmap: @@ -750,6 +773,7 @@ static int __devexit sh_rtc_remove(struc sh_rtc_setpie(&pdev->dev, 0); sh_rtc_setaie(&pdev->dev, 0); + sh_rtc_setcie(&pdev->dev, 0); free_irq(rtc->periodic_irq, rtc); if (rtc->carry_irq > 0) {