Consolidate bootcount code into drivers/bootcount
Subsystems (4)
PATCH v5 1/1 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.
---
v5:
- Removed bootcount target from arch/blackfin/cpu/Makefile as pointer out by Mike (thanks)
v4:
- Rebased against TOT
- Addressed Mike's comments
v3:
- Moved le-/be-accessors into header so that they now can be used by all bootcount drivers.
- Changed CONFIG_BOOTCOUNT_LE to CONFIG_SYS_BOOTCOUNT_LE
- Enabled CONFIG_SYS_BOOTCOUNT_LE in highbank
- Enabled CONFIG_SYS_BOOTCOUNT_SINGLEWORD in highbank
v2:
- Added CONFIG_BOOTCOUNT_LE to bootcount_davinci.c and enabled it in calimain.h to select little-endian accessors.
Makefile | 1 +
arch/arm/cpu/arm926ejs/at91/cpu.c | 26 --------
arch/arm/cpu/armv7/highbank/Makefile | 2 +-
arch/arm/cpu/armv7/highbank/bootcount.c | 36 -----------
arch/arm/cpu/ixp/cpu.c | 22 -------
arch/blackfin/cpu/Makefile | 1 -
arch/powerpc/lib/Makefile | 1 -
board/enbw/enbw_cmc/enbw_cmc.c | 29 ---------
board/keymile/km_arm/km_arm.c | 51 ---------------
board/omicron/calimain/calimain.c | 29 ---------
drivers/bootcount/Makefile | 45 ++++++++++++++
.../powerpc/lib => drivers/bootcount}/bootcount.c | 25 ++++----
drivers/bootcount/bootcount_at91.c | 43 +++++++++++++
.../bootcount/bootcount_blackfin.c | 0
drivers/bootcount/bootcount_davinci.c | 49 +++++++++++++++
drivers/bootcount/bootcount_ram.c | 72 ++++++++++++++++++++++
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 +
21 files changed, 282 insertions(+), 207 deletions(-)
delete mode 100644 arch/arm/cpu/armv7/highbank/bootcount.c
create mode 100644 drivers/bootcount/Makefile
rename {arch/powerpc/lib => drivers/bootcount}/bootcount.c (82%)
create mode 100644 drivers/bootcount/bootcount_at91.c
rename arch/blackfin/cpu/bootcount.c => drivers/bootcount/bootcount_blackfin.c (100%)
create mode 100644 drivers/bootcount/bootcount_davinci.c
create mode 100644 drivers/bootcount/bootcount_ram.c
create mode 100644 include/bootcount.hMakefile +1 -0
@@ -249,6 +249,7 @@ LIBS-y += net/libnet.o LIBS-y += disk/libdisk.o LIBS-y += drivers/bios_emulator/libatibiosemu.o LIBS-y += drivers/block/libblock.o +LIBS-$(CONFIG_BOOTCOUNT_LIMIT) += drivers/bootcount/libbootcount.o LIBS-y += drivers/dma/libdma.o LIBS-y += drivers/fpga/libfpga.o LIBS-y += drivers/gpio/libgpio.o
arch/arm/cpu/arm926ejs/at91/cpu.c +0 -26
@@ -71,29 +71,3 @@ int print_cpuinfo(void) return 0; }#endif - -#ifdef CONFIG_BOOTCOUNT_LIMIT -/* -* We combine the BOOTCOUNT_MAGIC and bootcount in one 32-bit register. -* This is done so we need to use only one of the four GPBR registers. -*/ -void bootcount_store (ulong a) -{ -at91_gpbr_t *gpbr = (at91_gpbr_t *)ATMEL_BASE_GPBR ; - -writel ((BOOTCOUNT_MAGIC &0xffff0000 ) | (a &0x0000ffff ), - &gpbr->reg[AT91_GPBR_INDEX_BOOTCOUNT ]); -} - -ulong bootcount_load (void ) -{ -at91_gpbr_t *gpbr = (at91_gpbr_t *)ATMEL_BASE_GPBR ; - -ulong val =readl (&gpbr->reg[AT91_GPBR_INDEX_BOOTCOUNT ]); -if ((val &0xffff0000 ) != (BOOTCOUNT_MAGIC &0xffff0000 )) -return 0 ; -else -return val &0x0000ffff ; -} - -#endif /* CONFIG_BOOTCOUNT_LIMIT */
arch/arm/cpu/armv7/highbank/Makefile +1 -1
@@ -25,7 +25,7 @@ include $(TOPDIR)/config.mk LIB = $(obj)lib$(SOC).o -COBJS := timer.o bootcount.o +COBJS := timer.o SOBJS := SRCS := $(SOBJS:.o=.S) $(COBJS:.o=.c)
arch/arm/cpu/armv7/highbank/bootcount.c deleted +0 -36
@@ -1,36 +0,0 @@ -/* -* Copyright 2011 Calxeda, Inc. -* -* 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 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. -* -* You should have received a copy of the GNU General Public License along with -* this program. If not, see <http://www.gnu.org/licenses/>. -*/ - -#include <common.h> -#include <asm/io.h> - -#ifdef CONFIG_BOOTCOUNT_LIMIT -void bootcount_store (ulong a) -{ -writel ((BOOTCOUNT_MAGIC &0xffff0000 ) | a,CONFIG_SYS_BOOTCOUNT_ADDR ); -} - -ulong bootcount_load (void ) -{ -u32 tmp =readl (CONFIG_SYS_BOOTCOUNT_ADDR ); - -if ((tmp &0xffff0000 ) != (BOOTCOUNT_MAGIC &0xffff0000 )) -return 0 ; -else -return tmp &0x0000ffff ; -} -#endif
arch/arm/cpu/ixp/cpu.c +0 -22
@@ -107,28 +107,6 @@ void pci_init(void)} */ -#ifdef CONFIG_BOOTCOUNT_LIMIT - -void bootcount_store (ulong a) -{ -volatile ulong *save_addr = (volatile ulong *)(CONFIG_SYS_BOOTCOUNT_ADDR ); - - save_addr[0 ] = a; - save_addr[1 ] =BOOTCOUNT_MAGIC ; -} - -ulong bootcount_load (void ) -{ -volatile ulong *save_addr = (volatile ulong *)(CONFIG_SYS_BOOTCOUNT_ADDR ); - -if (save_addr[1 ] !=BOOTCOUNT_MAGIC ) -return 0 ; -else -return save_addr[0 ]; -} - -#endif /* CONFIG_BOOTCOUNT_LIMIT */ -int cpu_eth_init (bd_t *bis) {#ifdef CONFIG_IXP4XX_NPE
arch/blackfin/cpu/Makefile +0 -1
@@ -17,7 +17,6 @@ EXTRA := init.elf CEXTRA := initcode.o SEXTRA := start.o SOBJS := interrupt.o cache.o -COBJS-$(CONFIG_BOOTCOUNT_LIMIT) += bootcount.o COBJS-y += cpu.o COBJS-y += gpio.o COBJS-y += interrupts.o
arch/powerpc/lib/Makefile +0 -1
@@ -46,7 +46,6 @@ SOBJS-y += reloc.o COBJS-$(CONFIG_BAT_RW) += bat_rw.o COBJS-y += board.o COBJS-y += bootm.o -COBJS-$(CONFIG_BOOTCOUNT_LIMIT) += bootcount.o COBJS-y += cache.o COBJS-y += extable.o COBJS-y += interrupts.o
board/enbw/enbw_cmc/enbw_cmc.c +0 -29
@@ -778,35 +778,6 @@ void arch_memory_failure_handle(void) }#endif -#if defined(CONFIG_BOOTCOUNT_LIMIT ) -void bootcount_store (ulong a) -{ -struct davinci_rtc *reg = - (struct davinci_rtc *)CONFIG_SYS_BOOTCOUNT_ADDR ; - -/* -* write RTC kick register to enable write -* for RTC Scratch registers. Scratch0 and 1 are -* used for bootcount values. -*/ -writel (RTC_KICK0R_WE , ®->kick0r); -writel (RTC_KICK1R_WE , ®->kick1r); -out_be32 (®->scratch0, a); -out_be32 (®->scratch1,BOOTCOUNT_MAGIC ); -} - -ulong bootcount_load (void ) -{ -struct davinci_rtc *reg = - (struct davinci_rtc *)CONFIG_SYS_BOOTCOUNT_ADDR ; - -if (in_be32 (®->scratch1) !=BOOTCOUNT_MAGIC ) -return 0 ; -else -return in_be32 (®->scratch0); -} -#endif -ulong post_word_load (void ) { struct davinci_rtc *reg =
board/keymile/km_arm/km_arm.c +0 -51
57 lines not on this page · raw message
board/omicron/calimain/calimain.c +0 -29
@@ -157,32 +157,3 @@ void hw_watchdog_reset(void) davinci_hw_watchdog_reset(); }#endif - -#if defined(CONFIG_BOOTCOUNT_LIMIT ) -void bootcount_store (ulong a) -{ -struct davinci_rtc *reg = - (struct davinci_rtc *)CONFIG_SYS_BOOTCOUNT_ADDR ; - -/* -* write RTC kick register to enable write -* for RTC Scratch registers. Scratch0 and 1 are -* used for bootcount values. -*/ -writel (RTC_KICK0R_WE , ®->kick0r); -writel (RTC_KICK1R_WE , ®->kick1r); -writel (a, ®->scratch0); -writel (BOOTCOUNT_MAGIC , ®->scratch1); -} - -ulong bootcount_load (void ) -{ -struct davinci_rtc *reg = - (struct davinci_rtc *)CONFIG_SYS_BOOTCOUNT_ADDR ; - -if (readl (®->scratch1) !=BOOTCOUNT_MAGIC ) -return 0 ; -else -return readl (®->scratch0); -} -#endif
drivers/bootcount/Makefile new file +45 -0
45 lines not on this page · raw message
drivers/bootcount/bootcount.c renamed from arch/powerpc/lib/bootcount.c +14 -11
@@ -1,5 +1,5 @@/* -* (C) Copyright 2010 +* (C) Copyright 2010-2012 * Stefan Roese, DENX Software Engineering, sr at denx.de. * * See file CREDITS for list of people who contributed to this
@@ -21,8 +21,8 @@* MA 02111-1307 USA */ -#include <common.h> -#include <asm/io.h> +#include <bootcount.h> +#include <linux/compiler.h> /* * Only override CONFIG_SYS_BOOTCOUNT_ADDR if not already defined. This
@@ -65,33 +65,36 @@#endif /* !defined(CONFIG_SYS_BOOTCOUNT_ADDR) */ -void bootcount_store (ulong a) +/* Now implement the generic default functions */ +#if defined(CONFIG_SYS_BOOTCOUNT_ADDR ) +__weak void bootcount_store (ulong a) {void *reg = (void *)CONFIG_SYS_BOOTCOUNT_ADDR ;#if defined(CONFIG_SYS_BOOTCOUNT_SINGLEWORD ) -out_be32 (reg, (BOOTCOUNT_MAGIC &0xffff0000 ) | a); +raw_bootcount_store (reg, (BOOTCOUNT_MAGIC &0xffff0000 ) | a);#else -out_be32 (reg, a); -out_be32 (reg +4 ,BOOTCOUNT_MAGIC ); +raw_bootcount_store (reg, a); +raw_bootcount_store (reg +4 ,BOOTCOUNT_MAGIC );#endif } -ulong bootcount_load (void ) +__weak ulong bootcount_load (void ) {void *reg = (void *)CONFIG_SYS_BOOTCOUNT_ADDR ;#if defined(CONFIG_SYS_BOOTCOUNT_SINGLEWORD ) -u32 tmp =in_be32 (reg); +u32 tmp =raw_bootcount_load (reg);if ((tmp &0xffff0000 ) != (BOOTCOUNT_MAGIC &0xffff0000 ))return 0 ;else return (tmp &0x0000ffff );#else -if (in_be32 (reg +4 ) !=BOOTCOUNT_MAGIC ) +if (raw_bootcount_load (reg +4 ) !=BOOTCOUNT_MAGIC )return 0 ;else -return in_be32 (reg); +return raw_bootcount_load (reg);#endif } +#endif
drivers/bootcount/bootcount_at91.c new file +43 -0
43 lines not on this page · raw message
drivers/bootcount/bootcount_blackfin.c renamed from arch/blackfin/cpu/bootcount.c +0 -0
drivers/bootcount/bootcount_davinci.c new file +49 -0
49 lines not on this page · raw message
drivers/bootcount/bootcount_ram.c new file +72 -0
72 lines not on this page · raw message
include/bootcount.h new file +51 -0
51 lines not on this page · raw message
include/configs/calimain.h +1 -0
@@ -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__
include/configs/enbw_cmc.h +1 -0
@@ -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
include/configs/highbank.h +2 -0
@@ -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
include/configs/km/km_arm.h +2 -0
@@ -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)
Signature · 1 line
1.7.11.3
PATCH v5 1/1 Consolidate bootcount code into drivers/bootcount
Quoted 3 lines · On Thursday 16 August 2012 23:55:41 Stefan Roese wrote:
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.
-mike
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: This is a digitally signed message part.
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20120817/90d767e2/attachment.pgp>
PATCH v5 1/1 Consolidate bootcount code into drivers/bootcount
In reply to Stefan RoeseHi Stefan,
Quoted 4 lines · Stefan Roese
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.
Quoted 10 lines
Signed-off-by Stefan Roese <[email protected]>Cc Heiko Schocher <[email protected]>Cc Valentin Longchamp <[email protected]>Cc Christian Riesch <[email protected]>Cc Manfred Rudigier <[email protected]>Cc Mike Frysinger <[email protected]>Cc Rob Herring <[email protected]>Cc Reinhard Meyer <[email protected]>Tested-by Valentin Longchamp <[email protected]>Tested-by Christian Riesch <[email protected]>
I tested it again on the calimain board and confirmed that it still works fine :-)
Thank you!
Regards, Christian
Quoted 1 line
Acked-by Rob Herring <[email protected]>
Wolfgang Denk
AppliedPATCH v5 1/1 Consolidate bootcount code into drivers/bootcount
In reply to Stefan RoeseDear Stefan Roese,
Quoted 57 lines · In message <[email protected]> you wrote:
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 <[email protected]>Cc Heiko Schocher <[email protected]>Cc Valentin Longchamp <[email protected]>Cc Christian Riesch <[email protected]>Cc Manfred Rudigier <[email protected]>Cc Mike Frysinger <[email protected]>Cc Rob Herring <[email protected]>Cc Reinhard Meyer <[email protected]>Tested-by Valentin Longchamp <[email protected]>Tested-by Christian Riesch <[email protected]>Acked-by Rob Herring <[email protected]>---
v5:
- Removed bootcount target fromarch/blackfin/cpu/Makefileas pointer out by Mike (thanks)v4:
- Rebased against TOT
- Addressed Mike's commentsv3:
- Moved le-/be-accessors into header so that they now can be used by all bootcount drivers.
- ChangedCONFIG_BOOTCOUNT_LEtoCONFIG_SYS_BOOTCOUNT_LE
- EnabledCONFIG_SYS_BOOTCOUNT_LEin highbank
- EnabledCONFIG_SYS_BOOTCOUNT_SINGLEWORDin highbankv2:
- AddedCONFIG_BOOTCOUNT_LEtobootcount_davinci.cand enabled it incalimain.hto select little-endian accessors.Makefile | 1 + arch/arm/cpu/arm926ejs/at91/cpu.c | 26 -------- arch/arm/cpu/armv7/highbank/Makefile | 2 +- arch/arm/cpu/armv7/highbank/bootcount.c | 36 ----------- arch/arm/cpu/ixp/cpu.c | 22 ------- arch/blackfin/cpu/Makefile | 1 - arch/powerpc/lib/Makefile | 1 - board/enbw/enbw_cmc/enbw_cmc.c | 29 --------- board/keymile/km_arm/km_arm.c | 51 --------------- board/omicron/calimain/calimain.c | 29 --------- drivers/bootcount/Makefile | 45 ++++++++++++++ .../powerpc/lib => drivers/bootcount}/bootcount.c | 25 ++++---- drivers/bootcount/bootcount_at91.c | 43 +++++++++++++ .../bootcount/bootcount_blackfin.c | 0 drivers/bootcount/bootcount_davinci.c | 49 +++++++++++++++ drivers/bootcount/bootcount_ram.c | 72 ++++++++++++++++++++++ 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 + 21 files changed, 282 insertions(+), 207 deletions(-)
Quoted 8 lines
delete mode 100644 arch/arm/cpu/armv7/highbank/bootcount.c
create mode 100644 drivers/bootcount/Makefile
rename {arch/powerpc/lib => drivers/bootcount}/bootcount.c (82%)
create mode 100644 drivers/bootcount/bootcount_at91.c
rename arch/blackfin/cpu/bootcount.c => drivers/bootcount/bootcount_blackfin.c (100%)
create mode 100644 drivers/bootcount/bootcount_davinci.c
create mode 100644 drivers/bootcount/bootcount_ram.c
create mode 100644 include/bootcount.hApplied, thanks.
Best regards,
Wolfgang Denk
Signature · 5 lines
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de Microsoft Multimedia: You have nice graphics, sound and animations when the system crashes.