env: Drop environment.h header file where not needed
[oweals/u-boot.git] / drivers / bootcount / bootcount_ram.c
index 8655af7eab07bd377308477c379ef04b9636c25b..edef36724b0587f4de9efbf7fa56ad22e9d8f6e3 100644 (file)
@@ -1,20 +1,7 @@
+// SPDX-License-Identifier: GPL-2.0+
 /*
  * (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>
@@ -41,12 +28,16 @@ void bootcount_store(ulong a)
                size += gd->bd->bi_dram[i].size;
        save_addr = (ulong *)(size - BOOTCOUNT_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++)
                writel(patterns[i % NBR_OF_PATTERNS],
                        &save_addr[i + OFFS_PATTERN]);
 
+       /* Make sure the data is written to RAM */
+       flush_dcache_range((ulong)&save_addr[0],
+                          (((ulong)&save_addr[REPEAT_PATTERN + OFFS_PATTERN] &
+                            ~(ARCH_DMA_MINALIGN - 1)) + ARCH_DMA_MINALIGN));
 }
 
 ulong bootcount_load(void)