2 * (C) Copyright 2010-2012
3 * Stefan Roese, DENX Software Engineering, sr@denx.de.
5 * SPDX-License-Identifier: GPL-2.0+
9 #include <linux/compiler.h>
11 /* Now implement the generic default functions */
12 __weak
void bootcount_store(ulong a
)
14 void *reg
= (void *)CONFIG_SYS_BOOTCOUNT_ADDR
;
16 #if defined(CONFIG_SYS_BOOTCOUNT_SINGLEWORD)
17 raw_bootcount_store(reg
, (BOOTCOUNT_MAGIC
& 0xffff0000) | a
);
19 raw_bootcount_store(reg
, a
);
20 raw_bootcount_store(reg
+ 4, BOOTCOUNT_MAGIC
);
21 #endif /* defined(CONFIG_SYS_BOOTCOUNT_SINGLEWORD */
24 __weak ulong
bootcount_load(void)
26 void *reg
= (void *)CONFIG_SYS_BOOTCOUNT_ADDR
;
28 #if defined(CONFIG_SYS_BOOTCOUNT_SINGLEWORD)
29 u32 tmp
= raw_bootcount_load(reg
);
31 if ((tmp
& 0xffff0000) != (BOOTCOUNT_MAGIC
& 0xffff0000))
34 return (tmp
& 0x0000ffff);
36 if (raw_bootcount_load(reg
+ 4) != BOOTCOUNT_MAGIC
)
39 return raw_bootcount_load(reg
);
40 #endif /* defined(CONFIG_SYS_BOOTCOUNT_SINGLEWORD) */