From patchwork Sat Aug 21 12:30:29 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vaibhav Hiremath X-Patchwork-Id: 121751 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter.kernel.org (8.14.4/8.14.3) with ESMTP id o7LCVQVE029791 for ; Sat, 21 Aug 2010 12:31:36 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752025Ab0HUMav (ORCPT ); Sat, 21 Aug 2010 08:30:51 -0400 Received: from comal.ext.ti.com ([198.47.26.152]:47020 "EHLO comal.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752009Ab0HUMat (ORCPT ); Sat, 21 Aug 2010 08:30:49 -0400 Received: from dbdp31.itg.ti.com ([172.24.170.98]) by comal.ext.ti.com (8.13.7/8.13.7) with ESMTP id o7LCUZh2018335 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Sat, 21 Aug 2010 07:30:37 -0500 Received: from localhost.localdomain (localhost [127.0.0.1]) by dbdp31.itg.ti.com (8.13.8/8.13.8) with ESMTP id o7LCUTDv024070; Sat, 21 Aug 2010 18:00:34 +0530 (IST) From: hvaibhav@ti.com To: linux-kernel@vger.kernel.org Cc: akpm@linux-foundation.org, byron.bbradley@gmail.com, linux-omap@vger.kernel.org, felipe.balbi@nokia.com, Vaibhav Hiremath Subject: [PATCH-V2 3/3] RTC:s35390a: Add update_irq (per Min interrupt) support Date: Sat, 21 Aug 2010 18:00:29 +0530 Message-Id: <1282393829-7326-4-git-send-email-hvaibhav@ti.com> X-Mailer: git-send-email 1.6.2.4 In-Reply-To: References: Sender: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter.kernel.org [140.211.167.41]); Sat, 21 Aug 2010 12:31:37 +0000 (UTC) diff --git a/drivers/rtc/rtc-s35390a.c b/drivers/rtc/rtc-s35390a.c index d8d59d7..34c9c47 100644 --- a/drivers/rtc/rtc-s35390a.c +++ b/drivers/rtc/rtc-s35390a.c @@ -390,6 +390,35 @@ static int s35390a_rtc_set_irq_freq(struct device *dev, int freq) return s35390a_set_irq_freq(to_i2c_client(dev), freq); } +static int s35390a_update_irq_enable(struct i2c_client *client, + unsigned enabled) +{ + struct s35390a *s35390a = i2c_get_clientdata(client); + char buf[1]; + + if (s35390a_get_reg(s35390a, S35390A_CMD_STATUS2, buf, sizeof(buf)) < 0) + return -EIO; + + /* This chip returns the bits of each byte in reverse order */ + buf[0] = bitrev8(buf[0]); + + buf[0] &= ~S35390A_INT1_MODE_MASK; + if (enabled) + buf[0] |= S35390A_INT1_MODE_PMIN_STDY; + else + buf[0] |= S35390A_INT1_MODE_NOINTR; + + /* This chip expects the bits of each byte in reverse order */ + buf[0] = bitrev8(buf[0]); + + return s35390a_set_reg(s35390a, S35390A_CMD_STATUS2, buf, sizeof(buf)); +} + +static int s35390a_rtc_update_irq_enable(struct device *dev, unsigned enabled) +{ + return s35390a_update_irq_enable(to_i2c_client(dev), enabled); +} + static irqreturn_t s35390a_irq_thread(int irq, void *handle) { char buf[1]; @@ -406,6 +435,8 @@ static irqreturn_t s35390a_irq_thread(int irq, void *handle) if (buf[0] & BIT(2)) { rtc_update_irq(s35390a->rtc, 1, RTC_IRQF | RTC_AF); s35390a_alarm_irq_enable(client, 0); + } else if (buf[0] & BIT(1)) { + rtc_update_irq(s35390a->rtc, 1, RTC_IRQF | RTC_UF); } else if (buf[0] & BIT(0)) { rtc_update_irq(s35390a->rtc, 1, RTC_IRQF | RTC_PF); } @@ -422,6 +453,7 @@ static const struct rtc_class_ops s35390a_rtc_ops = { .read_alarm = s35390a_rtc_read_alarm, .irq_set_freq = s35390a_rtc_set_irq_freq, .irq_set_state = s35390a_rtc_freq_irq_enable, + .update_irq_enable = s35390a_rtc_update_irq_enable, }; static struct i2c_driver s35390a_driver;