Skip to contentSkip to conversation

rtc: twl: update TWL RTC driver

PATCH New Venu Byravarasu 1 participant 4 messages Jan 19, 2012 Real time clock (RTC)

lore
Share & tools
lore
#0 lore raw

cover rtc: twl: update TWL RTC driver

From: Venu Byravarasu <[email protected]>

Observed minor issues with TWL RTC driver.
Hence tried fixing them with below 3 patches.

Venu Byravarasu (3):
rtc: twl: Enable RTC irrespective of its prior state
rtc: twl: Simplify RTC interrupt clearing
rtc: twl: Return correct RTC event from ISR

 drivers/rtc/rtc-twl.c |   20 ++++++--------------
 1 files changed, 6 insertions(+), 14 deletions(-)
#2 lore raw

PATCH 2/3 rtc: twl: Simplify RTC interrupt clearing

From: Venu Byravarasu <[email protected]>

For clearing RTC interrupt, programming ALARM bit only is sufficient, as all other bits are any way not affected by writing 0 to them.

Hence removed unwanted OR operation.

---
 drivers/rtc/rtc-twl.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
drivers/rtc/rtc-twl.c +1 -1
index 61ae1b7..1c85443 100644
@@ -376,7 +376,7 @@ static irqreturn_t twl_rtc_interrupt(int irq, void *rtc)
 	else
 		events |= RTC_IRQF | RTC_UF;
 
-	res = twl_rtc_write_u8(rd_reg | BIT_RTC_STATUS_REG_ALARM_M,
+	res = twl_rtc_write_u8(BIT_RTC_STATUS_REG_ALARM_M,
 				   REG_RTC_STATUS_REG);
 	if (res)
 		goto out;
Signature · 1 line
1.7.1.1
#1 lore raw

PATCH 1/3 rtc: twl: Enable RTC irrespective of its prior state

In reply to Venu Byravarasu

From: Venu Byravarasu <[email protected]>

As part of probe, before enabling RTC, RTC_CTRL register is read to check if it is already running. If RTC is used by kernel alone, then this read is not required. Even if RTC was enabled already by boot loader, setting STOP_RTC bit again should not harm. Hence removed unwanted read operation.

---
 drivers/rtc/rtc-twl.c |   12 ++----------
 1 files changed, 2 insertions(+), 10 deletions(-)
drivers/rtc/rtc-twl.c +2 -10
index 20687d5..61ae1b7 100644
@@ -449,19 +449,11 @@ static int __devinit twl_rtc_probe(struct platform_device *pdev)
 			REG_INT_MSK_STS_A);
 	}
 
-	/* Check RTC module status, Enable if it is off */
-	ret = twl_rtc_read_u8(&rd_reg, REG_RTC_CTRL_REG);
+	dev_info(&pdev->dev, "Enabling TWL-RTC\n");
+	ret = twl_rtc_write_u8(BIT_RTC_CTRL_REG_STOP_RTC_M, REG_RTC_CTRL_REG);
 	if (ret < 0)
 		goto out1;
 
-	if (!(rd_reg & BIT_RTC_CTRL_REG_STOP_RTC_M)) {
-		dev_info(&pdev->dev, "Enabling TWL-RTC.\n");
-		rd_reg = BIT_RTC_CTRL_REG_STOP_RTC_M;
-		ret = twl_rtc_write_u8(rd_reg, REG_RTC_CTRL_REG);
-		if (ret < 0)
-			goto out1;
-	}
-
 	/* init cached IRQ enable bits */
 	ret = twl_rtc_read_u8(&rtc_irq_bits, REG_RTC_INTERRUPTS_REG);
 	if (ret < 0)
Signature · 1 line
1.7.1.1
#3 lore raw

PATCH 3/3 rtc: twl: Return correct RTC event from ISR

In reply to Venu Byravarasu

From: Venu Byravarasu <[email protected]>

Following changes are made as part of this change:
1. As TWL RTC supports periodic interrupt, the correct event should be RTC_PF instead of RTC_UF.
2. No need to initialize variable "events" to 0 & then OR it with the event values. Hence fixing it.

---
 drivers/rtc/rtc-twl.c |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)
drivers/rtc/rtc-twl.c +3 -3
index 1c85443..a0236a0 100644
@@ -357,7 +357,7 @@ out:
 
 static irqreturn_t twl_rtc_interrupt(int irq, void *rtc)
 {
-	unsigned long events = 0;
+	unsigned long events;
 	int ret = IRQ_NONE;
 	int res;
 	u8 rd_reg;
@@ -372,9 +372,9 @@ static irqreturn_t twl_rtc_interrupt(int irq, void *rtc)
 	 * by reading RTS_INTERRUPTS_REGISTER[IT_TIMER,IT_ALARM]
 	 */
 	if (rd_reg & BIT_RTC_STATUS_REG_ALARM_M)
-		events |= RTC_IRQF | RTC_AF;
+		events = RTC_IRQF | RTC_AF;
 	else
-		events |= RTC_IRQF | RTC_UF;
+		events = RTC_IRQF | RTC_PF;
 
 	res = twl_rtc_write_u8(BIT_RTC_STATUS_REG_ALARM_M,
 				   REG_RTC_STATUS_REG);
Signature · 1 line
1.7.1.1