From 0044c42e94ecc258728190919b4619508fb83089 Mon Sep 17 00:00:00 2001 From: Stefan Roese Date: Thu, 16 Aug 2012 17:55:41 +0000 Subject: Consolidate bootcount code into drivers/bootcount This patch moves all bootcount implementations into a common directory: drivers/bootcount. The generic bootcount driver is now usable not only by powerpc platforms, but others as well. Signed-off-by: Stefan Roese Cc: Heiko Schocher Cc: Valentin Longchamp Cc: Christian Riesch Cc: Manfred Rudigier Cc: Mike Frysinger Cc: Rob Herring Cc: Reinhard Meyer Tested-by: Valentin Longchamp Tested-by: Christian Riesch Acked-by: Rob Herring Acked-by: Mike Frysinger --- include/bootcount.h | 51 +++++++++++++++++++++++++++++++++++++++++++++ include/configs/calimain.h | 1 + include/configs/enbw_cmc.h | 1 + include/configs/highbank.h | 2 ++ include/configs/km/km_arm.h | 2 ++ 5 files changed, 57 insertions(+) create mode 100644 include/bootcount.h (limited to 'include') diff --git a/include/bootcount.h b/include/bootcount.h new file mode 100644 index 00000000000..3ec1aeccfd8 --- /dev/null +++ b/include/bootcount.h @@ -0,0 +1,51 @@ +/* + * (C) Copyright 2012 + * Stefan Roese, DENX Software Engineering, sr@denx.de. + * + * See file CREDITS for list of people who contributed to this + * project. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of + * the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + */ + +#include +#include +#include + +#if !defined(CONFIG_SYS_BOOTCOUNT_LE) && !defined(CONFIG_SYS_BOOTCOUNT_BE) +# if __BYTE_ORDER == __LITTLE_ENDIAN +# define CONFIG_SYS_BOOTCOUNT_LE +# else +# define CONFIG_SYS_BOOTCOUNT_BE +# endif +#endif + +#ifdef CONFIG_SYS_BOOTCOUNT_LE +static inline void raw_bootcount_store(volatile u32 *addr, u32 data) +{ + out_le32(addr, data); +} + +static inline u32 raw_bootcount_load(volatile u32 *addr) +{ + return in_le32(addr); +} +#else +static inline void raw_bootcount_store(volatile u32 *addr, u32 data) +{ + out_be32(addr, data); +} + +static inline u32 raw_bootcount_load(volatile u32 *addr) +{ + return in_be32(addr); +} +#endif diff --git a/include/configs/calimain.h b/include/configs/calimain.h index e31e40b9fe9..8141fd796ff 100644 --- a/include/configs/calimain.h +++ b/include/configs/calimain.h @@ -352,6 +352,7 @@ #define CONFIG_SYS_INIT_SP_ADDR (0x8001ff00) #define CONFIG_BOOTCOUNT_LIMIT +#define CONFIG_SYS_BOOTCOUNT_LE /* Use little-endian accessors */ #define CONFIG_SYS_BOOTCOUNT_ADDR DAVINCI_RTC_BASE #ifndef __ASSEMBLY__ diff --git a/include/configs/enbw_cmc.h b/include/configs/enbw_cmc.h index 3fc07e672aa..b99492c05bc 100644 --- a/include/configs/enbw_cmc.h +++ b/include/configs/enbw_cmc.h @@ -458,6 +458,7 @@ #define CONFIG_BOOTCOUNT_LIMIT #define CONFIG_SYS_BOOTCOUNT_ADDR DAVINCI_RTC_BASE +#define CONFIG_SYS_BOOTCOUNT_BE #define CONFIG_SYS_NAND_U_BOOT_DST 0xc0080000 #define CONFIG_SYS_NAND_U_BOOT_OFFS 0x60004000 diff --git a/include/configs/highbank.h b/include/configs/highbank.h index 791f3f5468f..897bc3937c3 100644 --- a/include/configs/highbank.h +++ b/include/configs/highbank.h @@ -41,6 +41,8 @@ #define CONFIG_BAUDRATE 38400 #define CONFIG_BOOTCOUNT_LIMIT +#define CONFIG_SYS_BOOTCOUNT_SINGLEWORD +#define CONFIG_SYS_BOOTCOUNT_LE /* Use little-endian accessors */ #define CONFIG_SYS_BOOTCOUNT_ADDR 0xfff3cf0c #define CONFIG_MISC_INIT_R diff --git a/include/configs/km/km_arm.h b/include/configs/km/km_arm.h index 3aa5ca152c8..0d5ecd55883 100644 --- a/include/configs/km/km_arm.h +++ b/include/configs/km/km_arm.h @@ -307,6 +307,8 @@ int get_scl(void); #define CONFIG_KM_RESERVED_PRAM 0x801000 /* address for the bootcount (taken from end of RAM) */ #define BOOTCOUNT_ADDR (CONFIG_KM_RESERVED_PRAM) +/* Use generic bootcount RAM driver */ +#define CONFIG_BOOTCOUNT_RAM /* enable POST tests */ #define CONFIG_POST (CONFIG_SYS_POST_MEM_REGIONS) -- cgit v1.2.3