Xi Chen has uploaded this change for review. ( https://review.coreboot.org/c/coreboot/+/48071 )
Change subject: TEST-ONLY: soc/mediatek/mt8192: add dram full scan ......................................................................
TEST-ONLY: soc/mediatek/mt8192: add dram full scan
Used to check all dram address read/write is ok or not.
Signed-off-by: Xi Chen xixi.chen@mediatek.com Change-Id: I4d1c7adfd49910287ceccf08d667acdc41b209d5 --- M src/soc/mediatek/common/memory_test.c M src/soc/mediatek/mt8192/include/soc/emi.h M src/soc/mediatek/mt8192/memory.c 3 files changed, 64 insertions(+), 22 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/71/48071/1
diff --git a/src/soc/mediatek/common/memory_test.c b/src/soc/mediatek/common/memory_test.c index 51f3b23..b917341 100644 --- a/src/soc/mediatek/common/memory_test.c +++ b/src/soc/mediatek/common/memory_test.c @@ -1,6 +1,9 @@ /* SPDX-License-Identifier: GPL-2.0-only */
#include <soc/emi.h> +#include <console/console.h> + +#define LOGH printk(BIOS_ERR, "%s@%d\n", __func__, __LINE__);
enum { /* test patterns */ @@ -22,6 +25,37 @@ PATTERNF = 0xFFFFFFFF };
+int mem_test_fullscan(u8 *start, unsigned long long len) +{ + unsigned int *mem32_base = (unsigned int *)start; + unsigned long long i, size; + + printk(BIOS_INFO, "Test length: 0x%llx\n", len); + LOGH; + size = len >> 2; + + /* verify the tied bits (tied high) */ + for (i = 0; i < size; i++) { + mem32_base[i] = (unsigned int)i; + if (i % 100000 == 0) + printk(BIOS_INFO, "mem write: pos: %llx\n", i); + } + + LOGH; + for (i = 0; i < size; i++) { + if (mem32_base[i] != (unsigned int)i) { + printk(BIOS_ERR, "%s failed at %llx, value: 0x%x, expected: 0x%x\n", + __func__, i, (unsigned int)i, mem32_base[i]); + return -1; + } + if (i % 100000 == 0) + printk(BIOS_INFO, "mem compare: pos: %llx\n", i); + } + + return 0; +} + + int complex_mem_test(u8 *start, unsigned int len) { unsigned char *mem8_base = (unsigned char *)start; @@ -34,12 +68,14 @@ unsigned int value; uintptr_t p;
+ LOGH; size = len >> 2;
/* verify the tied bits (tied high) */ for (i = 0; i < size; i++) mem32_base[i] = PATTERN0;
+ LOGH; for (i = 0; i < size; i++) { if (mem32_base[i] != PATTERN0) return -1; @@ -47,6 +83,7 @@ mem32_base[i] = PATTERNF; }
+ LOGH; /* verify the tied bits (tied low) */ for (i = 0; i < size; i++) { if (mem32_base[i] != PATTERNF) @@ -58,11 +95,14 @@ pattern8 = PATTERN0; for (i = 0; i < len; i++) mem8_base[i] = pattern8++; + + LOGH; pattern8 = PATTERN0; for (i = 0; i < len; i++) { if (mem8_base[i] != pattern8++) return -3; } + LOGH;
/* verify pattern 2 (0x00~0xff) */ pattern8 = PATTERN0; @@ -74,7 +114,8 @@
pattern8 += 2; } - + LOGH; + /* verify pattern 3 (0x00~0xffff) */ pattern16 = PATTERN0; for (i = 0; i < (len >> 1); i++) @@ -84,7 +125,7 @@ if (mem16_base[i] != pattern16++) return -5; } - + LOGH; /* verify pattern 4 (0x00~0xffffffff) */ pattern32 = PATTERN0; for (i = 0; i < (len >> 2); i++) @@ -94,7 +135,7 @@ if (mem32_base[i] != pattern32++) return -6; } - + LOGH; /* pattern 5: filling memory range with 0x12345678 */ for (i = 0; i < size; i++) mem32_base[i] = PATTERNE; @@ -106,7 +147,7 @@
mem32_base[i] = PATTERN2; } - + LOGH; /* read check then fill memory with 00 byte pattern at offset 0h */ for (i = 0; i < size; i++) { if (mem32_base[i] != PATTERN2) @@ -114,7 +155,7 @@
mem8_base[i * 4] = PATTERN0; } - + LOGH; /* read check then fill memory with 00 byte pattern at offset 2h */ for (i = 0; i < size; i++) { if (mem32_base[i] != PATTERN3) @@ -122,7 +163,7 @@
mem8_base[i * 4 + 2] = PATTERN0; } - + LOGH; /* read check then fill memory with 00 byte pattern at offset 1h */ for (i = 0; i < size; i++) { if (mem32_base[i] != PATTERN4) @@ -130,7 +171,7 @@
mem8_base[i * 4 + 1] = PATTERN0; } - + LOGH; /* read check then fill memory with 00 byte pattern at offset 3h */ for (i = 0; i < size; i++) { if (mem32_base[i] != PATTERN5) @@ -138,7 +179,7 @@
mem8_base[i * 4 + 3] = PATTERN0; } - + LOGH; /* read check then fill memory with ffff word pattern at offset 1h */ for (i = 0; i < size; i++) { if (mem32_base[i] != PATTERN0) @@ -146,7 +187,7 @@
mem16_base[i * 2 + 1] = PATTERN7; } - + LOGH; /* read check then fill memory with ffff word pattern at offset 0h */ for (i = 0; i < size; i++) { if (mem32_base[i] != PATTERN6) @@ -154,13 +195,13 @@
mem16_base[i * 2] = PATTERN7; } - + LOGH; /* read check */ for (i = 0; i < size; i++) { if (mem32_base[i] != PATTERNF) return -14; } - + LOGH; /* stage 1 => write 0 */ for (i = 0; i < size; i++) mem_base[i] = PATTERN1; @@ -174,7 +215,7 @@
mem_base[i] = PATTERN2; } - + LOGH; /* stage 3 => read 0xf, write 0 */ for (i = 0; i < size; i++) { value = mem_base[i]; @@ -183,7 +224,7 @@
mem_base[i] = PATTERN1; } - + LOGH; /* stage 4 => read 0, write 0xf */ for (i = 0; i < size; i++) { value = mem_base[i]; @@ -192,7 +233,7 @@
mem_base[i] = PATTERN2; } - + LOGH; /* stage 5 => read 0xf, write 0 */ for (i = 0; i < size; i++) { value = mem_base[i]; @@ -201,14 +242,14 @@
mem_base[i] = PATTERN1; } - + LOGH; /* stage 6 => read 0 */ for (i = 0; i < size; i++) { value = mem_base[i]; if (value != PATTERN1) return -19; } - + LOGH; /* 1/2/4-byte combination test */ p = (uintptr_t)mem_base;
@@ -246,13 +287,13 @@ *((unsigned int *)p) = PATTERNE; p += 4; } - + LOGH; for (i = 0; i < size; i++) { value = mem_base[i]; if (value != PATTERNE) return -20; } - + LOGH; /* verify pattern 1 (0x00~0xff) */ pattern8 = PATTERN0; mem8_base[0] = pattern8; @@ -268,7 +309,7 @@
pattern8++; } - + LOGH; /* verify pattern 2 (0x00~0xffff) */ pattern16 = PATTERN0; mem16_base[0] = pattern16; @@ -280,7 +321,7 @@
pattern16++; } - + LOGH; /* verify pattern 3 (0x00~0xffffffff) */ pattern32 = PATTERN0; mem32_base[0] = pattern32; @@ -292,6 +333,6 @@
pattern32++; } - + LOGH; return 0; } diff --git a/src/soc/mediatek/mt8192/include/soc/emi.h b/src/soc/mediatek/mt8192/include/soc/emi.h old mode 100644 new mode 100755 index 02a90be..fee49ed --- a/src/soc/mediatek/mt8192/include/soc/emi.h +++ b/src/soc/mediatek/mt8192/include/soc/emi.h @@ -9,5 +9,6 @@ void mt_set_emi(const struct dramc_data *dparam); void mt_mem_init(struct dramc_param_ops *dparam_ops); int complex_mem_test(u8 *start, unsigned int len); +int mem_test_fullscan(u8 *start, unsigned long long len);
#endif /* SOC_MEDIATEK_MT8192_EMI_H */ diff --git a/src/soc/mediatek/mt8192/memory.c b/src/soc/mediatek/mt8192/memory.c old mode 100644 new mode 100755 index 549dede..3f90d30 --- a/src/soc/mediatek/mt8192/memory.c +++ b/src/soc/mediatek/mt8192/memory.c @@ -16,7 +16,7 @@ const struct ddr_base_info *ddr_info = &dparam->ddr_info;
for (u8 rank = RANK_0; rank < ddr_info->support_ranks; rank++) { - int result = complex_mem_test(addr, 0x2000); + int result = mem_test_fullscan(addr, (unsigned long long)sdram_size());
if (result != 0) { printk(BIOS_ERR,