3 * Heiko Schocher, DENX Software Engineering, hs@denx.de.
5 * SPDX-License-Identifier: GPL-2.0+
9 #include <asm/arch/da850_lowlevel.h>
10 #include <asm/arch/davinci_misc.h>
12 void bootcount_store(ulong a)
14 struct davinci_rtc *reg =
15 (struct davinci_rtc *)CONFIG_SYS_BOOTCOUNT_ADDR;
18 * write RTC kick register to enable write
19 * for RTC Scratch registers. Scratch0 and 1 are
20 * used for bootcount values.
22 writel(RTC_KICK0R_WE, ®->kick0r);
23 writel(RTC_KICK1R_WE, ®->kick1r);
24 raw_bootcount_store(®->scratch0, a);
25 raw_bootcount_store(®->scratch1, BOOTCOUNT_MAGIC);
28 ulong bootcount_load(void)
30 struct davinci_rtc *reg =
31 (struct davinci_rtc *)CONFIG_SYS_BOOTCOUNT_ADDR;
33 if (raw_bootcount_load(®->scratch1) != BOOTCOUNT_MAGIC)
36 return raw_bootcount_load(®->scratch0);