3 * Heiko Schocher, DENX Software Engineering, hs@denx.de.
5 * See file CREDITS for list of people who contributed to this
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License as
10 * published by the Free Software Foundation; either version 2 of
11 * the License, or (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
20 #include <bootcount.h>
21 #include <asm/arch/da850_lowlevel.h>
22 #include <asm/arch/davinci_misc.h>
24 void bootcount_store(ulong a
)
26 struct davinci_rtc
*reg
=
27 (struct davinci_rtc
*)CONFIG_SYS_BOOTCOUNT_ADDR
;
30 * write RTC kick register to enable write
31 * for RTC Scratch registers. Scratch0 and 1 are
32 * used for bootcount values.
34 writel(RTC_KICK0R_WE
, ®
->kick0r
);
35 writel(RTC_KICK1R_WE
, ®
->kick1r
);
36 raw_bootcount_store(®
->scratch0
, a
);
37 raw_bootcount_store(®
->scratch1
, BOOTCOUNT_MAGIC
);
40 ulong
bootcount_load(void)
42 struct davinci_rtc
*reg
=
43 (struct davinci_rtc
*)CONFIG_SYS_BOOTCOUNT_ADDR
;
45 if (raw_bootcount_load(®
->scratch1
) != BOOTCOUNT_MAGIC
)
48 return raw_bootcount_load(®
->scratch0
);