1 // SPDX-License-Identifier: GPL-2.0+
5 #include <asm/arch/hardware.h>
6 #include <asm/arch/at91_gpbr.h>
9 * We combine the BOOTCOUNT_MAGIC and bootcount in one 32-bit register.
10 * This is done so we need to use only one of the four GPBR registers.
12 void bootcount_store(ulong a)
14 at91_gpbr_t *gpbr = (at91_gpbr_t *) ATMEL_BASE_GPBR;
16 writel((BOOTCOUNT_MAGIC & 0xffff0000) | (a & 0x0000ffff),
17 &gpbr->reg[AT91_GPBR_INDEX_BOOTCOUNT]);
20 ulong bootcount_load(void)
22 at91_gpbr_t *gpbr = (at91_gpbr_t *) ATMEL_BASE_GPBR;
24 ulong val = readl(&gpbr->reg[AT91_GPBR_INDEX_BOOTCOUNT]);
25 if ((val & 0xffff0000) != (BOOTCOUNT_MAGIC & 0xffff0000))
28 return val & 0x0000ffff;