From eae2464e9a93dc3a8918abcc62348af6c8d9bc9b Mon Sep 17 00:00:00 2001 From: Rafaël Carré Date: Mon, 24 May 2010 10:06:46 +0000 Subject: as3543 rtc wakeup: fix power off If we disable the hearbeat source after enabling the watchdog there's no more lock-up when powering off the dap Comment out alarm enabling on startup since rockbox disables the alarm anyway git-svn-id: svn://svn.rockbox.org/rockbox/trunk@26247 a1c6a512-1295-4272-9138-f99709370657 --- firmware/drivers/rtc/rtc_as3514.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/firmware/drivers/rtc/rtc_as3514.c b/firmware/drivers/rtc/rtc_as3514.c index e5db839e77..837806d2ea 100644 --- a/firmware/drivers/rtc/rtc_as3514.c +++ b/firmware/drivers/rtc/rtc_as3514.c @@ -93,8 +93,6 @@ void rtc_alarm_poweroff(void) disable_irq(); - ascodec_write_pmu(0x1a, 4, 0x0); // In_Cntr : disable hearbeat source - ascodec_write(AS3543_WAKEUP, seconds); seconds >>= 8; ascodec_write(AS3543_WAKEUP, seconds); @@ -102,11 +100,15 @@ void rtc_alarm_poweroff(void) seconds |= 1<<7; /* enable bit */ ascodec_write(AS3543_WAKEUP, seconds); - /* write our watermark : desired time of wake up */ + /* write our desired time of wake up to detect power-up from RTC */ ascodec_write(AS3543_WAKEUP, wakeup_h); ascodec_write(AS3543_WAKEUP, wakeup_m); - ascodec_write(AS3514_SYSTEM, (1<<3) | (1<<0)); // enable hearbeat watchdog + /* enable hearbeat watchdog */ + ascodec_write(AS3514_SYSTEM, (1<<3) | (1<<0)); + + /* In_Cntr : disable hearbeat source */ + ascodec_write_pmu(0x1a, 4, ascodec_read_pmu(0x1a, 4) & ~(3<<2)); while(1); } @@ -128,7 +130,9 @@ bool rtc_check_alarm_started(bool release_alarm) ascodec_read(AS3543_WAKEUP); /* bits 15:8 */ if(ascodec_read(AS3543_WAKEUP) & (1<<7)) /* enable bit */ { +#if 0 /* we could have a persistent setting for wake-up time */ alarm_enabled = true; +#endif /* subsequent reads give the 16 bytes static SRAM */ wakeup_h = ascodec_read(AS3543_WAKEUP); -- cgit v1.2.3