2 * functions for handling bootcount support
4 * Copyright (c) 2010 Analog Devices Inc.
6 * Licensed under the 2-clause BSD.
9 /* This version uses one 32bit storage and combines the magic/count */
13 /* We abuse the EVT0 MMR for bootcount storage by default */
14 #ifndef CONFIG_SYS_BOOTCOUNT_ADDR
15 # define CONFIG_SYS_BOOTCOUNT_ADDR EVT0
18 #define MAGIC_MASK 0xffff0000
19 #define COUNT_MASK 0x0000ffff
21 void bootcount_store(ulong cnt
)
23 ulong magic
= (BOOTCOUNT_MAGIC
& MAGIC_MASK
) | (cnt
& COUNT_MASK
);
24 bfin_write32(CONFIG_SYS_BOOTCOUNT_ADDR
, magic
);
27 ulong
bootcount_load(void)
29 ulong magic
= bfin_read32(CONFIG_SYS_BOOTCOUNT_ADDR
);
30 if ((magic
& MAGIC_MASK
) == (BOOTCOUNT_MAGIC
& MAGIC_MASK
))
31 return magic
& COUNT_MASK
;