mirror of
https://github.com/u-boot/u-boot.git
synced 2025-04-24 06:24:17 +00:00
bootcount: Make bootcount magic configurable
Add new Kconfig option, SYS_BOOTCOUNT_MAGIC, to select the boot counter magic word. This can be useful ie. in case the entire boot counter register is not usable. Signed-off-by: Marek Vasut <marex@denx.de> Cc: Tom Rini <trini@konsulko.com>
This commit is contained in:
parent
0533fb8b3f
commit
758694ff07
6 changed files with 19 additions and 13 deletions
|
@ -127,4 +127,10 @@ config SYS_BOOTCOUNT_ADDR
|
||||||
help
|
help
|
||||||
Set the address used for reading and writing the boot counter.
|
Set the address used for reading and writing the boot counter.
|
||||||
|
|
||||||
|
config SYS_BOOTCOUNT_MAGIC
|
||||||
|
hex "Magic value for the boot counter"
|
||||||
|
default 0xB001C041
|
||||||
|
help
|
||||||
|
Set the magic value used for the boot counter.
|
||||||
|
|
||||||
endif
|
endif
|
||||||
|
|
|
@ -16,13 +16,13 @@ __weak void bootcount_store(ulong a)
|
||||||
uintptr_t flush_end;
|
uintptr_t flush_end;
|
||||||
|
|
||||||
#if defined(CONFIG_SYS_BOOTCOUNT_SINGLEWORD)
|
#if defined(CONFIG_SYS_BOOTCOUNT_SINGLEWORD)
|
||||||
raw_bootcount_store(reg, (BOOTCOUNT_MAGIC & 0xffff0000) | a);
|
raw_bootcount_store(reg, (CONFIG_SYS_BOOTCOUNT_MAGIC & 0xffff0000) | a);
|
||||||
|
|
||||||
flush_end = roundup(CONFIG_SYS_BOOTCOUNT_ADDR + 4,
|
flush_end = roundup(CONFIG_SYS_BOOTCOUNT_ADDR + 4,
|
||||||
CONFIG_SYS_CACHELINE_SIZE);
|
CONFIG_SYS_CACHELINE_SIZE);
|
||||||
#else
|
#else
|
||||||
raw_bootcount_store(reg, a);
|
raw_bootcount_store(reg, a);
|
||||||
raw_bootcount_store(reg + 4, BOOTCOUNT_MAGIC);
|
raw_bootcount_store(reg + 4, CONFIG_SYS_BOOTCOUNT_MAGIC);
|
||||||
|
|
||||||
flush_end = roundup(CONFIG_SYS_BOOTCOUNT_ADDR + 8,
|
flush_end = roundup(CONFIG_SYS_BOOTCOUNT_ADDR + 8,
|
||||||
CONFIG_SYS_CACHELINE_SIZE);
|
CONFIG_SYS_CACHELINE_SIZE);
|
||||||
|
@ -37,12 +37,12 @@ __weak ulong bootcount_load(void)
|
||||||
#if defined(CONFIG_SYS_BOOTCOUNT_SINGLEWORD)
|
#if defined(CONFIG_SYS_BOOTCOUNT_SINGLEWORD)
|
||||||
u32 tmp = raw_bootcount_load(reg);
|
u32 tmp = raw_bootcount_load(reg);
|
||||||
|
|
||||||
if ((tmp & 0xffff0000) != (BOOTCOUNT_MAGIC & 0xffff0000))
|
if ((tmp & 0xffff0000) != (CONFIG_SYS_BOOTCOUNT_MAGIC & 0xffff0000))
|
||||||
return 0;
|
return 0;
|
||||||
else
|
else
|
||||||
return (tmp & 0x0000ffff);
|
return (tmp & 0x0000ffff);
|
||||||
#else
|
#else
|
||||||
if (raw_bootcount_load(reg + 4) != BOOTCOUNT_MAGIC)
|
if (raw_bootcount_load(reg + 4) != CONFIG_SYS_BOOTCOUNT_MAGIC)
|
||||||
return 0;
|
return 0;
|
||||||
else
|
else
|
||||||
return raw_bootcount_load(reg);
|
return raw_bootcount_load(reg);
|
||||||
|
|
|
@ -6,14 +6,15 @@
|
||||||
#include <asm/arch/at91_gpbr.h>
|
#include <asm/arch/at91_gpbr.h>
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* We combine the BOOTCOUNT_MAGIC and bootcount in one 32-bit register.
|
* We combine the CONFIG_SYS_BOOTCOUNT_MAGIC and bootcount in one 32-bit
|
||||||
* This is done so we need to use only one of the four GPBR registers.
|
* register. This is done so we need to use only one of the four GPBR
|
||||||
|
* registers.
|
||||||
*/
|
*/
|
||||||
void bootcount_store(ulong a)
|
void bootcount_store(ulong a)
|
||||||
{
|
{
|
||||||
at91_gpbr_t *gpbr = (at91_gpbr_t *) ATMEL_BASE_GPBR;
|
at91_gpbr_t *gpbr = (at91_gpbr_t *) ATMEL_BASE_GPBR;
|
||||||
|
|
||||||
writel((BOOTCOUNT_MAGIC & 0xffff0000) | (a & 0x0000ffff),
|
writel((CONFIG_SYS_BOOTCOUNT_MAGIC & 0xffff0000) | (a & 0x0000ffff),
|
||||||
&gpbr->reg[AT91_GPBR_INDEX_BOOTCOUNT]);
|
&gpbr->reg[AT91_GPBR_INDEX_BOOTCOUNT]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -22,7 +23,7 @@ ulong bootcount_load(void)
|
||||||
at91_gpbr_t *gpbr = (at91_gpbr_t *) ATMEL_BASE_GPBR;
|
at91_gpbr_t *gpbr = (at91_gpbr_t *) ATMEL_BASE_GPBR;
|
||||||
|
|
||||||
ulong val = readl(&gpbr->reg[AT91_GPBR_INDEX_BOOTCOUNT]);
|
ulong val = readl(&gpbr->reg[AT91_GPBR_INDEX_BOOTCOUNT]);
|
||||||
if ((val & 0xffff0000) != (BOOTCOUNT_MAGIC & 0xffff0000))
|
if ((val & 0xffff0000) != (CONFIG_SYS_BOOTCOUNT_MAGIC & 0xffff0000))
|
||||||
return 0;
|
return 0;
|
||||||
else
|
else
|
||||||
return val & 0x0000ffff;
|
return val & 0x0000ffff;
|
||||||
|
|
|
@ -24,7 +24,7 @@ void bootcount_store(ulong a)
|
||||||
writel(RTC_KICK0R_WE, ®->kick0r);
|
writel(RTC_KICK0R_WE, ®->kick0r);
|
||||||
writel(RTC_KICK1R_WE, ®->kick1r);
|
writel(RTC_KICK1R_WE, ®->kick1r);
|
||||||
raw_bootcount_store(®->scratch2,
|
raw_bootcount_store(®->scratch2,
|
||||||
(BOOTCOUNT_MAGIC & 0xffff0000) | (a & 0x0000ffff));
|
(CONFIG_SYS_BOOTCOUNT_MAGIC & 0xffff0000) | (a & 0x0000ffff));
|
||||||
}
|
}
|
||||||
|
|
||||||
ulong bootcount_load(void)
|
ulong bootcount_load(void)
|
||||||
|
@ -34,7 +34,7 @@ ulong bootcount_load(void)
|
||||||
(struct davinci_rtc *)CONFIG_SYS_BOOTCOUNT_ADDR;
|
(struct davinci_rtc *)CONFIG_SYS_BOOTCOUNT_ADDR;
|
||||||
|
|
||||||
val = raw_bootcount_load(®->scratch2);
|
val = raw_bootcount_load(®->scratch2);
|
||||||
if ((val & 0xffff0000) != (BOOTCOUNT_MAGIC & 0xffff0000))
|
if ((val & 0xffff0000) != (CONFIG_SYS_BOOTCOUNT_MAGIC & 0xffff0000))
|
||||||
return 0;
|
return 0;
|
||||||
else
|
else
|
||||||
return val & 0x0000ffff;
|
return val & 0x0000ffff;
|
||||||
|
|
|
@ -28,7 +28,7 @@ void bootcount_store(ulong a)
|
||||||
size += gd->bd->bi_dram[i].size;
|
size += gd->bd->bi_dram[i].size;
|
||||||
save_addr = (ulong *)(size - BOOTCOUNT_ADDR);
|
save_addr = (ulong *)(size - BOOTCOUNT_ADDR);
|
||||||
writel(a, save_addr);
|
writel(a, save_addr);
|
||||||
writel(BOOTCOUNT_MAGIC, &save_addr[1]);
|
writel(CONFIG_SYS_BOOTCOUNT_MAGIC, &save_addr[1]);
|
||||||
|
|
||||||
for (i = 0; i < REPEAT_PATTERN; i++)
|
for (i = 0; i < REPEAT_PATTERN; i++)
|
||||||
writel(patterns[i % NBR_OF_PATTERNS],
|
writel(patterns[i % NBR_OF_PATTERNS],
|
||||||
|
|
|
@ -385,7 +385,6 @@ uint dpram_alloc(uint size);
|
||||||
uint dpram_alloc_align(uint size,uint align);
|
uint dpram_alloc_align(uint size,uint align);
|
||||||
void bootcount_store (ulong);
|
void bootcount_store (ulong);
|
||||||
ulong bootcount_load (void);
|
ulong bootcount_load (void);
|
||||||
#define BOOTCOUNT_MAGIC 0xB001C041
|
|
||||||
|
|
||||||
/* $(CPU)/.../<eth> */
|
/* $(CPU)/.../<eth> */
|
||||||
void mii_init (void);
|
void mii_init (void);
|
||||||
|
|
Loading…
Add table
Reference in a new issue