Separate Alarm from IRQ for ds1307.

Submitted by Sachin Sanap on Dec. 21, 2010, 7:45 p.m.

Details

Message ID 1292960753.2445.5.camel@pe-lt522.marvell.com
State Superseded
Headers show

Commit Message

Sachin Sanap Dec. 21, 2010, 7:45 p.m.
Some RTC chips that support Alarm might not always be connected
to IRQ. The alarm interrupt of RTC might be connected to the
HOSTWAKEUP pin of the CPU, which gets CPU out of suspend to RAM
state.

Signed-off-by: Sachin Sanap <ssanap@marvell.com>
---
 drivers/rtc/rtc-ds1307.c |   13 +++++++++----
 1 files changed, 9 insertions(+), 4 deletions(-)

Patch hide | download patch | download mbox

diff --git a/drivers/rtc/rtc-ds1307.c b/drivers/rtc/rtc-ds1307.c
index d827ce5..4b79bdb 100644
--- a/drivers/rtc/rtc-ds1307.c
+++ b/drivers/rtc/rtc-ds1307.c
@@ -102,7 +102,8 @@  struct ds1307 {
 	enum ds_type		type;
 	unsigned long		flags;
 #define HAS_NVRAM	0		/* bit 0 == sysfs file active */
-#define HAS_ALARM	1		/* bit 1 == irq claimed */
+#define HAS_ALARM	1		/* bit 1 == has alarm */
+#define HAS_IRQ		2		/* bit 2 == irq claimed */
 	struct i2c_client	*client;
 	struct rtc_device	*rtc;
 	struct work_struct	work;
@@ -271,7 +272,7 @@  static void ds1307_work(struct work_struct *work)
 	}
 
 out:
-	if (test_bit(HAS_ALARM, &ds1307->flags))
+	if (test_bit(HAS_IRQ, &ds1307->flags))
 		enable_irq(client->irq);
 	mutex_unlock(lock);
 }
@@ -885,10 +886,14 @@  read_rtc:
 		}
 
 		device_set_wakeup_capable(&client->dev, 1);
-		set_bit(HAS_ALARM, &ds1307->flags);
+		set_bit(HAS_IRQ, &ds1307->flags);
 		dev_dbg(&client->dev, "got IRQ %d\n", client->irq);
 	}
 
+	/* has Alarm? */
+	if (chip->alarm)
+		set_bit(HAS_ALARM, &ds1307->flags);
+
 	if (chip->nvram56) {
 		err = sysfs_create_bin_file(&client->dev.kobj, &nvram);
 		if (err == 0) {
@@ -910,7 +915,7 @@  static int __devexit ds1307_remove(struct i2c_client *client)
 {
 	struct ds1307		*ds1307 = i2c_get_clientdata(client);
 
-	if (test_and_clear_bit(HAS_ALARM, &ds1307->flags)) {
+	if (test_and_clear_bit(HAS_IRQ, &ds1307->flags)) {
 		free_irq(client->irq, client);
 		cancel_work_sync(&ds1307->work);
 	}