blob: 9a9f2f3591c6063422e7eb7877da2433f45a1dc2 [file] [log] [blame]
#include <bootcount.h>
#include <flintstone_lpgpr.h>
/* F1 also uses SNVS LPGPR for reset cause information */
void bootcount_store(ulong a)
{
void *reg = (void *)CONFIG_SYS_BOOTCOUNT_ADDR;
u32 snvs = readl(SNVS_BASE_ADDR + SNVS_LPGPR);
snvs &= ~LPGPR_BOOTCOUNT_MASK;
snvs |= a & LPGPR_BOOTCOUNT_MASK;
raw_bootcount_store(reg, (BOOTCOUNT_MAGIC & LPGPR_UBOOT_MAGIC_MASK) | (snvs & 0xffff));
}
ulong bootcount_load(void)
{
void *reg = (void *)CONFIG_SYS_BOOTCOUNT_ADDR;
u32 tmp = raw_bootcount_load(reg);
if ((tmp & LPGPR_UBOOT_MAGIC_MASK) != (BOOTCOUNT_MAGIC & LPGPR_UBOOT_MAGIC_MASK))
return 0;
else
return (tmp & LPGPR_BOOTCOUNT_MASK);
}