3 * Heiko Schocher, DENX Software Engineering, hs@denx.de.
5 * SPDX-License-Identifier: GPL-2.0+
9 #include <asm/davinci_rtc.h>
11 void bootcount_store(ulong a)
13 struct davinci_rtc *reg =
14 (struct davinci_rtc *)CONFIG_SYS_BOOTCOUNT_ADDR;
17 * write RTC kick register to enable write
18 * for RTC Scratch registers. Scratch0 and 1 are
19 * used for bootcount values.
21 writel(RTC_KICK0R_WE, ®->kick0r);
22 writel(RTC_KICK1R_WE, ®->kick1r);
23 raw_bootcount_store(®->scratch2,
24 (BOOTCOUNT_MAGIC & 0xffff0000) | (a & 0x0000ffff));
27 ulong bootcount_load(void)
30 struct davinci_rtc *reg =
31 (struct davinci_rtc *)CONFIG_SYS_BOOTCOUNT_ADDR;
33 val = raw_bootcount_load(®->scratch2);
34 if ((val & 0xffff0000) != (BOOTCOUNT_MAGIC & 0xffff0000))
37 return val & 0x0000ffff;