提交 9b5ef64a 编写于 作者: Y Yoichi Yuasa 提交者: Linus Torvalds

rtc: update vr41xx alarm handling

- vr41xx_rtc_read_alarm() reports alarm enabled.
- vr41xx_rtc_set_alarm() sets alarm disable/enable by rtc_wkalrm.enabled.
Signed-off-by: NYoichi Yuasa <yoichi_yuasa@tripeaks.co.jp>
Acked-by: NAlessandro Zummo <a.zummo@towertech.it>
Acked-by: NDavid Brownell <dbrownell@users.sourceforge.net>
Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
上级 09a21e56
...@@ -97,6 +97,7 @@ static DEFINE_SPINLOCK(rtc_lock); ...@@ -97,6 +97,7 @@ static DEFINE_SPINLOCK(rtc_lock);
static char rtc_name[] = "RTC"; static char rtc_name[] = "RTC";
static unsigned long periodic_frequency; static unsigned long periodic_frequency;
static unsigned long periodic_count; static unsigned long periodic_count;
static unsigned int alarm_enabled;
struct resource rtc_resource[2] = { struct resource rtc_resource[2] = {
{ .name = rtc_name, { .name = rtc_name,
...@@ -188,6 +189,7 @@ static int vr41xx_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *wkalrm) ...@@ -188,6 +189,7 @@ static int vr41xx_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *wkalrm)
low = rtc1_read(ECMPLREG); low = rtc1_read(ECMPLREG);
mid = rtc1_read(ECMPMREG); mid = rtc1_read(ECMPMREG);
high = rtc1_read(ECMPHREG); high = rtc1_read(ECMPHREG);
wkalrm->enabled = alarm_enabled;
spin_unlock_irq(&rtc_lock); spin_unlock_irq(&rtc_lock);
...@@ -206,10 +208,18 @@ static int vr41xx_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *wkalrm) ...@@ -206,10 +208,18 @@ static int vr41xx_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *wkalrm)
spin_lock_irq(&rtc_lock); spin_lock_irq(&rtc_lock);
if (alarm_enabled)
disable_irq(ELAPSEDTIME_IRQ);
rtc1_write(ECMPLREG, (uint16_t)(alarm_sec << 15)); rtc1_write(ECMPLREG, (uint16_t)(alarm_sec << 15));
rtc1_write(ECMPMREG, (uint16_t)(alarm_sec >> 1)); rtc1_write(ECMPMREG, (uint16_t)(alarm_sec >> 1));
rtc1_write(ECMPHREG, (uint16_t)(alarm_sec >> 17)); rtc1_write(ECMPHREG, (uint16_t)(alarm_sec >> 17));
if (wkalrm->enabled)
enable_irq(ELAPSEDTIME_IRQ);
alarm_enabled = wkalrm->enabled;
spin_unlock_irq(&rtc_lock); spin_unlock_irq(&rtc_lock);
return 0; return 0;
...@@ -221,10 +231,24 @@ static int vr41xx_rtc_ioctl(struct device *dev, unsigned int cmd, unsigned long ...@@ -221,10 +231,24 @@ static int vr41xx_rtc_ioctl(struct device *dev, unsigned int cmd, unsigned long
switch (cmd) { switch (cmd) {
case RTC_AIE_ON: case RTC_AIE_ON:
enable_irq(ELAPSEDTIME_IRQ); spin_lock_irq(&rtc_lock);
if (!alarm_enabled) {
enable_irq(ELAPSEDTIME_IRQ);
alarm_enabled = 1;
}
spin_unlock_irq(&rtc_lock);
break; break;
case RTC_AIE_OFF: case RTC_AIE_OFF:
disable_irq(ELAPSEDTIME_IRQ); spin_lock_irq(&rtc_lock);
if (alarm_enabled) {
disable_irq(ELAPSEDTIME_IRQ);
alarm_enabled = 0;
}
spin_unlock_irq(&rtc_lock);
break; break;
case RTC_PIE_ON: case RTC_PIE_ON:
enable_irq(RTCLONG1_IRQ); enable_irq(RTCLONG1_IRQ);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册