Creative ZEN: fix RTC regression

Creative ZEN lost it's time when shutting down.
The bug was introduced with commit 7f282b9280 (g#2601),
followed by e3f6e9d9f6 (g#2616).

I guarded all persistent register writes with wait loops,
as described in the datasheet.

TODO:
test SONY_NWZE360 and SONY_NWZE370 targets

Change-Id: Ib38ab8691fd1c6e8d0771c1e2eca20dfeb6fc87f
This commit is contained in:
Sebastian Leonhardt 2025-05-10 17:00:38 +02:00 committed by Solomon Peachy
parent 69bc230e7d
commit 297af3a483
2 changed files with 13 additions and 2 deletions

View file

@ -28,8 +28,8 @@
#define YEAR1980 315532800 /* 1980/1/1 00:00:00 in UTC */
#if defined(SANSA_FUZEPLUS) || defined(CREATIVE_ZENXFI3) || defined(SONY_NWZE360) || \
defined(SONY_NWZE370)
#if defined(SANSA_FUZEPLUS) || defined(SONY_NWZE360) || defined(SONY_NWZE370) || \
defined(CREATIVE_ZENXFI2) || defined(CREATIVE_ZENXFI3)
#define USE_PERSISTENT
#endif

View file

@ -86,10 +86,21 @@ static inline void imx233_rtc_init(void)
BF_CLR(RTC_CTRL, SFTRST);
udelay(5); /* only need 3 GPMI clocks (1us) */
BF_CLR(RTC_CTRL, CLKGATE);
#if defined(SANSA_FUZEPLUS)
#ifdef BM_RTC_PERSISTENT0_DISABLE_XTALOK
while (BF_RD(RTC_STAT, NEW_REGS)!=0) {};
BF_SET(RTC_PERSISTENT0, XTAL24MHZ_PWRUP, DISABLE_XTALOK);
#endif
while (BF_RD(RTC_STAT, NEW_REGS)!=0) {};
BF_CLR(RTC_PERSISTENT0, CLOCKSOURCE);
#else
/* confirmed for CREATIVE_ZEN and CREATIVE_ZENXFI2 */
/* FIXME: test SONY_NWZE360 and SONY_NWZE370 targets */
while (BF_RD(RTC_STAT, NEW_REGS)!=0) {};
BF_SET(RTC_PERSISTENT0, XTAL32KHZ_PWRUP, CLOCKSOURCE);
while (BF_RD(RTC_STAT, NEW_REGS)!=0) {};
BF_CLR(RTC_PERSISTENT0, XTAL24MHZ_PWRUP, DISABLE_XTALOK);
#endif
imx233_rtc_enable_watchdog(false);
}