]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
Consolidate bootcount code into drivers/bootcount
authorStefan Roese <sr@denx.de>
Thu, 16 Aug 2012 17:55:41 +0000 (17:55 +0000)
committerWolfgang Denk <wd@denx.de>
Sat, 1 Sep 2012 12:26:02 +0000 (14:26 +0200)
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 <sr@denx.de>
Cc: Heiko Schocher <hs@denx.de>
Cc: Valentin Longchamp <valentin.longchamp@keymile.com>
Cc: Christian Riesch <christian.riesch@omicron.at>
Cc: Manfred Rudigier <manfred.rudigier@omicron.at>
Cc: Mike Frysinger <vapier@gentoo.org>
Cc: Rob Herring <rob.herring@calxeda.com>
Cc: Reinhard Meyer <reinhard.meyer@emk-elektronik.de>
Tested-by: Valentin Longchamp <valentin.longchamp@keymile.com>
Tested-by: Christian Riesch <christian.riesch@omicron.at>
Acked-by: Rob Herring <rob.herring@calxeda.com>
Acked-by: Mike Frysinger <vapier@gentoo.org>
21 files changed:
Makefile
arch/arm/cpu/arm926ejs/at91/cpu.c
arch/arm/cpu/armv7/highbank/Makefile
arch/arm/cpu/armv7/highbank/bootcount.c [deleted file]
arch/arm/cpu/ixp/cpu.c
arch/blackfin/cpu/Makefile
arch/powerpc/lib/Makefile
board/enbw/enbw_cmc/enbw_cmc.c
board/keymile/km_arm/km_arm.c
board/omicron/calimain/calimain.c
drivers/bootcount/Makefile [new file with mode: 0644]
drivers/bootcount/bootcount.c [moved from arch/powerpc/lib/bootcount.c with 82% similarity]
drivers/bootcount/bootcount_at91.c [new file with mode: 0644]
drivers/bootcount/bootcount_blackfin.c [moved from arch/blackfin/cpu/bootcount.c with 100% similarity]
drivers/bootcount/bootcount_davinci.c [new file with mode: 0644]
drivers/bootcount/bootcount_ram.c [new file with mode: 0644]
include/bootcount.h [new file with mode: 0644]
include/configs/calimain.h
include/configs/enbw_cmc.h
include/configs/highbank.h
include/configs/km/km_arm.h

index 947f3ff06ae3af1658ba73ebd4381b12fd2aa0ab..a41b98705468627687d89787e4e7f9c58fcbd5df 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -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
index c47fb31e9996ab4dff6d46175fc9d2c5346c8223..5cf4fad0b092f27c560689dc474559817c6811cf 100644 (file)
@@ -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 */
index 917c3a36ba5faa7321975904c55026251028bec6..76faeb0fe1067ff27209fbe2ea9e845f216b8bae 100644 (file)
@@ -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)
diff --git a/arch/arm/cpu/armv7/highbank/bootcount.c b/arch/arm/cpu/armv7/highbank/bootcount.c
deleted file mode 100644 (file)
index 9ca0656..0000000
+++ /dev/null
@@ -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
index 942845d5441a16981ccde771b3e0d5ef1abd0cb8..f1864d6317f4a3b2fd56e2d224d3387cb4cdbd7a 100644 (file)
@@ -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
index 5deaa9e6a28fa0b9a4ac44e8557609d7e0bd2353..0a72ec5df3c0d6cb17edc8f43b75cd8e04dda761 100644 (file)
@@ -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
index cdd62a2061f848dcc2fea75ce373e37e00856e8d..965f9ea4a591aef9873efb047eef8422e0b24c7b 100644 (file)
@@ -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
index 0874e9c4e8c1bd14ca778ca99253a2f13eff4078..67d5d4d6e5f0e35b627f5c1b8a1b2fb1e2f9aa7f 100644 (file)
@@ -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, &reg->kick0r);
-       writel(RTC_KICK1R_WE, &reg->kick1r);
-       out_be32(&reg->scratch0, a);
-       out_be32(&reg->scratch1, BOOTCOUNT_MAGIC);
-}
-
-ulong bootcount_load(void)
-{
-       struct davinci_rtc *reg =
-               (struct davinci_rtc *)CONFIG_SYS_BOOTCOUNT_ADDR;
-
-       if (in_be32(&reg->scratch1) != BOOTCOUNT_MAGIC)
-               return 0;
-       else
-               return in_be32(&reg->scratch0);
-}
-#endif
-
 ulong post_word_load(void)
 {
        struct davinci_rtc *reg =
index 2b2ca393765818a2dc2898d159140834560d3ac8..930c80e7c2a60ac661ea6c940b03b0c5bc5fdeee 100644 (file)
@@ -408,57 +408,6 @@ int hush_init_var(void)
 }
 #endif
 
-#if defined(CONFIG_BOOTCOUNT_LIMIT)
-const ulong patterns[]      = {        0x00000000,
-                               0xFFFFFFFF,
-                               0xFF00FF00,
-                               0x0F0F0F0F,
-                               0xF0F0F0F0};
-const ulong NBR_OF_PATTERNS = ARRAY_SIZE(patterns);
-const ulong OFFS_PATTERN    = 3;
-const ulong REPEAT_PATTERN  = 1000;
-
-void bootcount_store(ulong a)
-{
-       ulong *save_addr;
-       ulong size = 0;
-       int i;
-
-       for (i = 0; i < CONFIG_NR_DRAM_BANKS; i++)
-               size += gd->bd->bi_dram[i].size;
-       save_addr = (ulong *)(size - BOOTCOUNT_ADDR);
-       writel(a, save_addr);
-       writel(BOOTCOUNT_MAGIC, &save_addr[1]);
-
-       for (i = 0; i < REPEAT_PATTERN; i++)
-               writel(patterns[i % NBR_OF_PATTERNS],
-                       &save_addr[i+OFFS_PATTERN]);
-
-}
-
-ulong bootcount_load(void)
-{
-       ulong *save_addr;
-       ulong size = 0;
-       ulong counter = 0;
-       int i, tmp;
-
-       for (i = 0; i < CONFIG_NR_DRAM_BANKS; i++)
-               size += gd->bd->bi_dram[i].size;
-       save_addr = (ulong *)(size - BOOTCOUNT_ADDR);
-
-       counter = readl(&save_addr[0]);
-
-       /* Is the counter reliable, check in the big pattern for bit errors */
-       for (i = 0; (i < REPEAT_PATTERN) && (counter != 0); i++) {
-               tmp = readl(&save_addr[i+OFFS_PATTERN]);
-               if (tmp != patterns[i % NBR_OF_PATTERNS])
-                       counter = 0;
-       }
-       return counter;
-}
-#endif
-
 #if defined(CONFIG_SOFT_I2C)
 void set_sda(int state)
 {
index 54415cedaf70f092a9915220b0ad96632cd85924..1060a1f6705cc2d1d53f329fc1ec973564582d6e 100644 (file)
@@ -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, &reg->kick0r);
-       writel(RTC_KICK1R_WE, &reg->kick1r);
-       writel(a, &reg->scratch0);
-       writel(BOOTCOUNT_MAGIC, &reg->scratch1);
-}
-
-ulong bootcount_load(void)
-{
-       struct davinci_rtc *reg =
-               (struct davinci_rtc *)CONFIG_SYS_BOOTCOUNT_ADDR;
-
-       if (readl(&reg->scratch1) != BOOTCOUNT_MAGIC)
-               return 0;
-       else
-               return readl(&reg->scratch0);
-}
-#endif
diff --git a/drivers/bootcount/Makefile b/drivers/bootcount/Makefile
new file mode 100644 (file)
index 0000000..a8d0ac7
--- /dev/null
@@ -0,0 +1,45 @@
+#
+# 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.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+# MA 02111-1307 USA
+#
+
+include $(TOPDIR)/config.mk
+
+LIB    := $(obj)libbootcount.o
+
+COBJS-y                                += bootcount.o
+COBJS-$(CONFIG_AT91SAM9XE)     += bootcount_at91.o
+COBJS-$(CONFIG_BLACKFIN)       += bootcount_blackfin.o
+COBJS-$(CONFIG_SOC_DA8XX)      += bootcount_davinci.o
+COBJS-$(CONFIG_BOOTCOUNT_RAM)  += bootcount_ram.o
+
+COBJS  := $(COBJS-y)
+SRCS   := $(COBJS:.o=.c)
+OBJS   := $(addprefix $(obj),$(COBJS))
+
+$(LIB):        $(obj).depend $(OBJS)
+       $(call cmd_link_o_target, $(OBJS))
+
+#########################################################################
+
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
+
+sinclude $(obj).depend
+
+########################################################################
similarity index 82%
rename from arch/powerpc/lib/bootcount.c
rename to drivers/bootcount/bootcount.c
index f9ce539ecb45f5734621a971784a7e553ac8e0f8..80eb71763f38f7b6ac8083033056978a83ea488d 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * (C) Copyright 2010
+ * (C) Copyright 2010-2012
  * Stefan Roese, DENX Software Engineering, sr@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
 
 #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
diff --git a/drivers/bootcount/bootcount_at91.c b/drivers/bootcount/bootcount_at91.c
new file mode 100644 (file)
index 0000000..7cfe14d
--- /dev/null
@@ -0,0 +1,43 @@
+/*
+ * 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 <common.h>
+#include <asm/io.h>
+#include <asm/arch/hardware.h>
+#include <asm/arch/at91_gpbr.h>
+
+/*
+ * 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;
+}
diff --git a/drivers/bootcount/bootcount_davinci.c b/drivers/bootcount/bootcount_davinci.c
new file mode 100644 (file)
index 0000000..1cd9436
--- /dev/null
@@ -0,0 +1,49 @@
+/*
+ * (C) Copyright 2011
+ * Heiko Schocher, DENX Software Engineering, hs@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 <bootcount.h>
+#include <asm/arch/da850_lowlevel.h>
+#include <asm/arch/davinci_misc.h>
+
+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, &reg->kick0r);
+       writel(RTC_KICK1R_WE, &reg->kick1r);
+       raw_bootcount_store(&reg->scratch0, a);
+       raw_bootcount_store(&reg->scratch1, BOOTCOUNT_MAGIC);
+}
+
+ulong bootcount_load(void)
+{
+       struct davinci_rtc *reg =
+               (struct davinci_rtc *)CONFIG_SYS_BOOTCOUNT_ADDR;
+
+       if (raw_bootcount_load(&reg->scratch1) != BOOTCOUNT_MAGIC)
+               return 0;
+       else
+               return raw_bootcount_load(&reg->scratch0);
+}
diff --git a/drivers/bootcount/bootcount_ram.c b/drivers/bootcount/bootcount_ram.c
new file mode 100644 (file)
index 0000000..8655af7
--- /dev/null
@@ -0,0 +1,72 @@
+/*
+ * (C) Copyright 2010
+ * Heiko Schocher, DENX Software Engineering, hs@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 <common.h>
+#include <asm/io.h>
+
+DECLARE_GLOBAL_DATA_PTR;
+
+const ulong patterns[]      = {        0x00000000,
+                               0xFFFFFFFF,
+                               0xFF00FF00,
+                               0x0F0F0F0F,
+                               0xF0F0F0F0};
+const ulong NBR_OF_PATTERNS = sizeof(patterns) / sizeof(*patterns);
+const ulong OFFS_PATTERN    = 3;
+const ulong REPEAT_PATTERN  = 1000;
+
+void bootcount_store(ulong a)
+{
+       ulong *save_addr;
+       ulong size = 0;
+       int i;
+
+       for (i = 0; i < CONFIG_NR_DRAM_BANKS; i++)
+               size += gd->bd->bi_dram[i].size;
+       save_addr = (ulong *)(size - BOOTCOUNT_ADDR);
+       writel(a, save_addr);
+       writel(BOOTCOUNT_MAGIC, &save_addr[1]);
+
+       for (i = 0; i < REPEAT_PATTERN; i++)
+               writel(patterns[i % NBR_OF_PATTERNS],
+                       &save_addr[i + OFFS_PATTERN]);
+
+}
+
+ulong bootcount_load(void)
+{
+       ulong *save_addr;
+       ulong size = 0;
+       ulong counter = 0;
+       int i, tmp;
+
+       for (i = 0; i < CONFIG_NR_DRAM_BANKS; i++)
+               size += gd->bd->bi_dram[i].size;
+       save_addr = (ulong *)(size - BOOTCOUNT_ADDR);
+
+       counter = readl(&save_addr[0]);
+
+       /* Is the counter reliable, check in the big pattern for bit errors */
+       for (i = 0; (i < REPEAT_PATTERN) && (counter != 0); i++) {
+               tmp = readl(&save_addr[i + OFFS_PATTERN]);
+               if (tmp != patterns[i % NBR_OF_PATTERNS])
+                       counter = 0;
+       }
+       return counter;
+}
diff --git a/include/bootcount.h b/include/bootcount.h
new file mode 100644 (file)
index 0000000..3ec1aec
--- /dev/null
@@ -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 <common.h>
+#include <asm/io.h>
+#include <asm/byteorder.h>
+
+#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
index e31e40b9fe9de3ff48d47bd447e235d9d6faee65..8141fd796ffcdf53f985c3ee266978d6d9c1b136 100644 (file)
 #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__
index 3fc07e672aa62236a385462437119b7ba11a6698..b99492c05bc2ff88cda7c3bd9ea345c0d966b796 100644 (file)
 
 #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
index 791f3f5468f02fb09324bdbb5226d881ec80f78d..897bc3937c31a56139ce9246c7727623e8fd8e31 100644 (file)
@@ -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
index 3aa5ca152c84f12195848cb949fc87b35e45be02..0d5ecd558839d0ce7ba0812a12d707a3281e5e45 100644 (file)
@@ -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)