]> git.kernelconcepts.de Git - karo-tx-uboot.git/blob - arch/blackfin/cpu/bootcount.c
Blackfin: use on-chip reset func with newer parts
[karo-tx-uboot.git] / arch / blackfin / cpu / bootcount.c
1 /*
2  * functions for handling bootcount support
3  *
4  * Copyright (c) 2010 Analog Devices Inc.
5  *
6  * Licensed under the 2-clause BSD.
7  */
8
9 /* This version uses one 32bit storage and combines the magic/count */
10
11 #include <common.h>
12
13 /* We abuse the EVT0 MMR for bootcount storage by default */
14 #ifndef CONFIG_SYS_BOOTCOUNT_ADDR
15 # define CONFIG_SYS_BOOTCOUNT_ADDR EVT0
16 #endif
17
18 #define MAGIC_MASK 0xffff0000
19 #define COUNT_MASK 0x0000ffff
20
21 void bootcount_store(ulong cnt)
22 {
23         ulong magic = (BOOTCOUNT_MAGIC & MAGIC_MASK) | (cnt & COUNT_MASK);
24         bfin_write32(CONFIG_SYS_BOOTCOUNT_ADDR, magic);
25 }
26
27 ulong bootcount_load(void)
28 {
29         ulong magic = bfin_read32(CONFIG_SYS_BOOTCOUNT_ADDR);
30         if ((magic & MAGIC_MASK) == (BOOTCOUNT_MAGIC & MAGIC_MASK))
31                 return magic & COUNT_MASK;
32         else
33                 return 0;
34 }