2 * See file CREDITS for list of people who contributed to this
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License as
7 * published by the Free Software Foundation; either version 2 of
8 * the License, or (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
19 #include <asm/arch/hardware.h>
20 #include <asm/arch/at91_gpbr.h>
23 * We combine the BOOTCOUNT_MAGIC and bootcount in one 32-bit register.
24 * This is done so we need to use only one of the four GPBR registers.
26 void bootcount_store(ulong a)
28 at91_gpbr_t *gpbr = (at91_gpbr_t *) ATMEL_BASE_GPBR;
30 writel((BOOTCOUNT_MAGIC & 0xffff0000) | (a & 0x0000ffff),
31 &gpbr->reg[AT91_GPBR_INDEX_BOOTCOUNT]);
34 ulong bootcount_load(void)
36 at91_gpbr_t *gpbr = (at91_gpbr_t *) ATMEL_BASE_GPBR;
38 ulong val = readl(&gpbr->reg[AT91_GPBR_INDEX_BOOTCOUNT]);
39 if ((val & 0xffff0000) != (BOOTCOUNT_MAGIC & 0xffff0000))
42 return val & 0x0000ffff;