* (C) Copyright 2002
* Wolfgang Denk, DENX Software Engineering, wd@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.
- *
- * 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
+ * SPDX-License-Identifier: GPL-2.0+
*/
#include <common.h>
#include <post.h>
#include <watchdog.h>
-#if CONFIG_POST & CONFIG_SYS_POST_MEMORY
+#if CONFIG_POST & (CONFIG_SYS_POST_MEMORY | CONFIG_SYS_POST_MEM_REGIONS)
DECLARE_GLOBAL_DATA_PTR;
return ret;
}
-static int memory_post_tests(unsigned long start, unsigned long size)
+static int memory_post_test_lines(unsigned long start, unsigned long size)
{
int ret = 0;
- if (!ret)
- ret = memory_post_dataline((unsigned long long *)start);
+ ret = memory_post_dataline((unsigned long long *)start);
WATCHDOG_RESET();
if (!ret)
ret = memory_post_addrline((ulong *)start, (ulong *)start,
- size);
+ size);
WATCHDOG_RESET();
if (!ret)
- ret = memory_post_addrline((ulong *)(start + size - 8),
- (ulong *)start, size);
+ ret = memory_post_addrline((ulong *)(start+size-8),
+ (ulong *)start, size);
WATCHDOG_RESET();
- if (!ret)
- ret = memory_post_test1(start, size, 0x00000000);
+
+ return ret;
+}
+
+static int memory_post_test_patterns(unsigned long start, unsigned long size)
+{
+ int ret = 0;
+
+ ret = memory_post_test1(start, size, 0x00000000);
WATCHDOG_RESET();
if (!ret)
ret = memory_post_test1(start, size, 0xffffffff);
return ret;
}
+static int memory_post_test_regions(unsigned long start, unsigned long size)
+{
+ unsigned long i;
+ int ret = 0;
+
+ for (i = 0; i < (size >> 20) && (!ret); i++) {
+ if (!ret)
+ ret = memory_post_test_patterns(start + (i << 20),
+ 0x800);
+ if (!ret)
+ ret = memory_post_test_patterns(start + (i << 20) +
+ 0xff800, 0x800);
+ }
+
+ return ret;
+}
+
+static int memory_post_tests(unsigned long start, unsigned long size)
+{
+ int ret = 0;
+
+ ret = memory_post_test_lines(start, size);
+ if (!ret)
+ ret = memory_post_test_patterns(start, size);
+
+ return ret;
+}
+
/*
* !! this is only valid, if you have contiguous memory banks !!
*/
return;
}
+int memory_regions_post_test(int flags)
+{
+ int ret = 0;
+ phys_addr_t phys_offset = 0;
+ u32 memsize, vstart;
+
+ arch_memory_test_prepare(&vstart, &memsize, &phys_offset);
+
+ ret = memory_post_test_lines(vstart, memsize);
+ if (!ret)
+ ret = memory_post_test_regions(vstart, memsize);
+
+ return ret;
+}
+
int memory_post_test(int flags)
{
int ret = 0;
if (flags & POST_SLOWTEST) {
ret = memory_post_tests(vstart, memsize);
} else { /* POST_NORMAL */
- unsigned long i;
- for (i = 0; i < (memsize >> 20) && !ret; i++) {
- if (!ret)
- ret = memory_post_tests(vstart +
- (i << 20), 0x800);
- if (!ret)
- ret = memory_post_tests(vstart +
- (i << 20) + 0xff800, 0x800);
- }
+ ret = memory_post_test_regions(vstart, memsize);
}
} while (!ret &&
!arch_memory_test_advance(&vstart, &memsize, &phys_offset));
return ret;
}
-#endif /* CONFIG_POST & CONFIG_SYS_POST_MEMORY */
+#endif /* CONFIG_POST&(CONFIG_SYS_POST_MEMORY|CONFIG_SYS_POST_MEM_REGIONS) */