From patchwork Sun Jun 17 13:45:07 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 9365 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 533E723EE2 for ; Sun, 17 Jun 2012 13:45:33 +0000 (UTC) Received: from mail-yx0-f180.google.com (mail-yx0-f180.google.com [209.85.213.180]) by fiordland.canonical.com (Postfix) with ESMTP id 0D782A1826B for ; Sun, 17 Jun 2012 13:45:32 +0000 (UTC) Received: by yenq6 with SMTP id q6so3563013yen.11 for ; Sun, 17 Jun 2012 06:45:32 -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=+ncLdjcT2mNthU0/Z+oyTWMX6Y6I5bt0pLzUGe+xStM=; b=Mu9m/kiVoB7AMQJgv9OtkvM4UNxkgRMf2+fnSsNg6kjKwKd1tcA7SIcXTwYYLiMLz3 yTBQLKB98EN3jHq9gE4ul1CAGykYJ0sl58iTqm0Cs//QZhcEkQJy19iJwtFojVBOt783 3xDR+ZjlGwyfvUKsdHmF+nLR28P5LMCzx6eKvWGMkFHelZsRNqNMEJo5RKrTuQSSuWin eR9CMaHzQ1hduOf5jC1XTDVVIG08tx3Rn7NUOsnzZmPOGijdPBX52ggWfhiPDJpNAryO jk6rFN1+Jj+8tH+MjWBa7PyAsMAi/mEWCr9HuJLb4UUrWsgZaCPW1mXRxCK+KhMC9OCe OMPg== Received: by 10.50.195.234 with SMTP id ih10mr6252874igc.0.1339940732341; Sun, 17 Jun 2012 06:45:32 -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.24.148 with SMTP id v20csp22757ibb; Sun, 17 Jun 2012 06:45:31 -0700 (PDT) Received: by 10.14.127.77 with SMTP id c53mr2781871eei.113.1339940730845; Sun, 17 Jun 2012 06:45:30 -0700 (PDT) Received: from eu1sys200aog111.obsmtp.com (eu1sys200aog111.obsmtp.com. [207.126.144.131]) by mx.google.com with SMTP id z13si7087768eef.40.2012.06.17.06.45.21 (version=TLSv1/SSLv3 cipher=OTHER); Sun, 17 Jun 2012 06:45:30 -0700 (PDT) Received-SPF: neutral (google.com: 207.126.144.131 is neither permitted nor denied by best guess record for domain of linus.walleij@stericsson.com) client-ip=207.126.144.131; Authentication-Results: mx.google.com; spf=neutral (google.com: 207.126.144.131 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 eu1sys200aob111.postini.com ([207.126.147.11]) with SMTP ID DSNKT93fcFWYEbjGSCoXrbtreX43jGkR41q7@postini.com; Sun, 17 Jun 2012 13:45:30 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 D3AFE9D; Sun, 17 Jun 2012 13:36:56 +0000 (GMT) Received: from relay2.stm.gmessaging.net (unknown [10.230.100.18]) by zeta.dmz-ap.st.com (STMicroelectronics) with ESMTP id C253D12A5; Sun, 17 Jun 2012 13:45:15 +0000 (GMT) Received: from exdcvycastm003.EQ1STM.local (alteon-source-exch [10.230.100.61]) (using TLSv1 with cipher RC4-MD5 (128/128 bits)) (Client CN "exdcvycastm003", Issuer "exdcvycastm003" (not verified)) by relay2.stm.gmessaging.net (Postfix) with ESMTPS id 3D9A5A8065; Sun, 17 Jun 2012 15:45:09 +0200 (CEST) Received: from steludxu4075.lud.stericsson.com (10.230.100.153) by smtp.stericsson.com (10.230.100.1) with Microsoft SMTP Server (TLS) id 8.3.83.0; Sun, 17 Jun 2012 15:45:14 +0200 From: Linus Walleij To: Andrew Morton Cc: Alessandro Zummo , , Ramesh Chandrasekaran , Linus Walleij Subject: [PATCH 1/2] rtc/ab8500: use UIE emulation Date: Sun, 17 Jun 2012 15:45:07 +0200 Message-ID: <1339940707-6927-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: ALoCoQmbiaGajesmxHJT2oIHD0PRlDd3+ycAIafon25MPZNewrSeSPDV+ab2LDZ5NIzEWdyYoXJD From: Ramesh Chandrasekaran RTC: Fix to correct improper implementation of clock update irq (RTC_UIE) and enable UIE Emulation. Signed-off-by: Ramesh Chandrasekaran Signed-off-by: Linus Walleij --- drivers/rtc/Kconfig | 1 + drivers/rtc/rtc-ab8500.c | 15 ++++++++++++++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/drivers/rtc/Kconfig b/drivers/rtc/Kconfig index 08cbdb9..668da59 100644 --- a/drivers/rtc/Kconfig +++ b/drivers/rtc/Kconfig @@ -694,6 +694,7 @@ config RTC_DRV_AB3100 config RTC_DRV_AB8500 tristate "ST-Ericsson AB8500 RTC" depends on AB8500_CORE + select RTC_INTF_DEV_UIE_EMUL help Select this to enable the ST-Ericsson AB8500 power management IC RTC support. This chip contains a battery- and capacitor-backed RTC. diff --git a/drivers/rtc/rtc-ab8500.c b/drivers/rtc/rtc-ab8500.c index 4bcf9ca..60e43ab 100644 --- a/drivers/rtc/rtc-ab8500.c +++ b/drivers/rtc/rtc-ab8500.c @@ -224,7 +224,8 @@ static int ab8500_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alarm) { int retval, i; unsigned char buf[ARRAY_SIZE(ab8500_rtc_alarm_regs)]; - unsigned long mins, secs = 0; + unsigned long mins, secs = 0, cursec=0; + struct rtc_time curtm; if (alarm->time.tm_year < (AB8500_RTC_EPOCH - 1900)) { dev_dbg(dev, "year should be equal to or greater than %d\n", @@ -236,6 +237,18 @@ static int ab8500_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alarm) rtc_tm_to_time(&alarm->time, &secs); /* + * Check whether alarm is set less than 1min. + * Since our RTC doesn't support alarm resolution less than 1min, + * return -EINVAL, so UIE EMUL can take it up, incase of UIE_ON + */ + ab8500_rtc_read_time(dev, &curtm); /* Read current time */ + rtc_tm_to_time(&curtm, &cursec); + if ((secs - cursec) < 59 ){ + dev_dbg(dev, "Alarm less than 1 minute not supported\r\n"); + return -EINVAL; + } + + /* * Convert it to the number of seconds since 01-01-2000 00:00:00, since * we only have a small counter in the RTC. */