Added bootcount_load() and bootcount_store(). The bootcounter is stored in the internal RAM at the address defined in the configuration file (CONFIG_BOOTCOUNT_ADDRESS).
Signed-off-by: Stefano Babic <sba...@denx.de> --- arch/arm/cpu/arm1136/mx35/generic.c | 33 +++++++++++++++++++++++++++++ arch/arm/include/asm/arch-mx35/imx-regs.h | 8 +++++++ include/configs/mx35pdk.h | 11 ++++++++- 3 files changed, 50 insertions(+), 2 deletions(-) diff --git a/arch/arm/cpu/arm1136/mx35/generic.c b/arch/arm/cpu/arm1136/mx35/generic.c index 1b4ab75..bb47328 100644 --- a/arch/arm/cpu/arm1136/mx35/generic.c +++ b/arch/arm/cpu/arm1136/mx35/generic.c @@ -461,3 +461,36 @@ void reset_cpu(ulong addr) struct wdog_regs *wdog = (struct wdog_regs *)WDOG_BASE_ADDR; writew(4, &wdog->wcr); } + +#ifdef CONFIG_BOOTCOUNT_LIMIT +/* + * We write the bootcounter as single 32bit + * in the IRAM at the address set in configuration + * file + */ +void bootcount_store(ulong a) +{ + int i; + u32 *bootcnt = (u32 *) CONFIG_BOOTCOUNT_ADDRESS; + + /* + * Experience shows that the bootcounter + * must be written at least twice + */ + for (i = 0; i < 3; i++) + writel((BOOTCOUNT_MAGIC & 0xffff0000) | (a & 0x0000ffff), + bootcnt); +} + +ulong bootcount_load(void) +{ + u32 *bootcnt = (u32 *) CONFIG_BOOTCOUNT_ADDRESS; + + ulong val = readl(bootcnt); + if ((val & 0xffff0000) != (BOOTCOUNT_MAGIC & 0xffff0000)) + return 0; + else + return val & 0x0000ffff; +} + +#endif /* CONFIG_BOOTCOUNT_LIMIT */ diff --git a/arch/arm/include/asm/arch-mx35/imx-regs.h b/arch/arm/include/asm/arch-mx35/imx-regs.h index e741fb0..8fd8888 100644 --- a/arch/arm/include/asm/arch-mx35/imx-regs.h +++ b/arch/arm/include/asm/arch-mx35/imx-regs.h @@ -32,6 +32,14 @@ #define IRAM_SIZE 0x00020000 /* 128 KB */ /* + * Part of IRAM is used by ROM Bootloader + * define IRAM not changed by RBL + * (ofssets 0x01B00 : 0x1E000) + */ +#define IRAM_USER_BASE_ADDR (IRAM_BASE_ADDR + 0x1B00) +#define IRAM_USER_SIZE 0x1C500 + +/* * AIPS 1 */ #define AIPS1_BASE_ADDR 0x43F00000 diff --git a/include/configs/mx35pdk.h b/include/configs/mx35pdk.h index 086355b..02601b3 100644 --- a/include/configs/mx35pdk.h +++ b/include/configs/mx35pdk.h @@ -178,10 +178,11 @@ #define PHYS_SDRAM_1_SIZE (128 * 1024 * 1024) #define iomem_valid_addr(addr, size) \ (addr >= PHYS_SDRAM_1 && addr <= (PHYS_SDRAM_1 + PHYS_SDRAM_1_SIZE)) +#define IRAM_PERS_SIZE 256 #define CONFIG_SYS_SDRAM_BASE CSD0_BASE_ADDR -#define CONFIG_SYS_INIT_RAM_ADDR (IRAM_BASE_ADDR + 0x10000) -#define CONFIG_SYS_INIT_RAM_SIZE (IRAM_SIZE / 2) +#define CONFIG_SYS_INIT_RAM_ADDR IRAM_USER_BASE_ADDR +#define CONFIG_SYS_INIT_RAM_SIZE (IRAM_USER_SIZE - IRAM_PERS_SIZE) #define CONFIG_SYS_GBL_DATA_OFFSET (CONFIG_SYS_INIT_RAM_SIZE - \ GENERATED_GBL_DATA_SIZE) #define CONFIG_SYS_INIT_SP_ADDR (CONFIG_SYS_INIT_RAM_ADDR + \ @@ -249,6 +250,12 @@ #define CONFIG_SYS_NAND_LARGEPAGE /* + * Bootcounter + */ +#define CONFIG_BOOTCOUNT_LIMIT +#define CONFIG_BOOTCOUNT_ADDRESS (CONFIG_SYS_INIT_RAM_ADDR + \ + CONFIG_SYS_INIT_RAM_SIZE) +/* * Default environment and default scripts * to update uboot and load kernel */ -- 1.7.1 _______________________________________________ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot