X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=post%2Fdrivers%2Fmemory.c;h=c2b711e2f4100aeb43cd30eb5dadc2ff024f87e5;hb=310ae55efe14aa7923b16c718cbdb22ec364b18b;hp=a2c088bad8d5f3cf274b4e62085e9b664f96cedd;hpb=f6d3faae792be848567688df7ea3f803c25af5b2;p=u-boot diff --git a/post/drivers/memory.c b/post/drivers/memory.c index a2c088bad8..c2b711e2f4 100644 --- a/post/drivers/memory.c +++ b/post/drivers/memory.c @@ -150,12 +150,10 @@ * the whole RAM. */ -#ifdef CONFIG_POST - #include #include -#if CONFIG_POST & CFG_POST_MEMORY +#if CONFIG_POST & CONFIG_SYS_POST_MEMORY DECLARE_GLOBAL_DATA_PTR; @@ -186,7 +184,7 @@ DECLARE_GLOBAL_DATA_PTR; * * For other processors, let the compiler generate the best code it can. */ -static void move64(unsigned long long *src, unsigned long long *dest) +static void move64(const unsigned long long *src, unsigned long long *dest) { #if defined(CONFIG_MPC8260) || defined(CONFIG_MPC824X) asm ("lfd 0, 0(3)\n\t" /* fpr0 = *scr */ @@ -227,18 +225,18 @@ const unsigned long long otherpattern = 0x0123456789abcdefULL; static int memory_post_dataline(unsigned long long * pmem) { unsigned long long temp64 = 0; - int num_patterns = sizeof(pattern)/ sizeof(pattern[0]); + int num_patterns = ARRAY_SIZE(pattern); int i; unsigned int hi, lo, pathi, patlo; int ret = 0; for ( i = 0; i < num_patterns; i++) { - move64((unsigned long long *)&(pattern[i]), pmem++); + move64(&(pattern[i]), pmem++); /* * Put a different pattern on the data lines: otherwise they * may float long enough to read back what we wrote. */ - move64((unsigned long long *)&otherpattern, pmem--); + move64(&otherpattern, pmem--); move64(pmem, &temp64); #ifdef INJECT_DATA_ERRORS @@ -284,7 +282,7 @@ static int memory_post_addrline(ulong *testaddr, ulong *base, ulong size) #endif if(readback == *testaddr) { post_log ("Memory (address line) error at %08x<->%08x, " - "XOR value %08x !\n", + "XOR value %08x !\n", testaddr, target, xor); ret = -1; } @@ -454,30 +452,73 @@ static int memory_post_tests (unsigned long start, unsigned long size) return ret; } -int memory_post_test (int flags) +/* + * !! this is only valid, if you have contiguous memory banks !! + */ +__attribute__((weak)) +int arch_memory_test_prepare(u32 *vstart, u32 *size, phys_addr_t *phys_offset) { - int ret = 0; bd_t *bd = gd->bd; - unsigned long memsize = (bd->bi_memsize >= 256 << 20 ? - 256 << 20 : bd->bi_memsize) - (1 << 20); + *vstart = CONFIG_SYS_SDRAM_BASE; + *size = (gd->ram_size >= 256 << 20 ? + 256 << 20 : gd->ram_size) - (1 << 20); + + /* Limit area to be tested with the board info struct */ + if ((*vstart) + (*size) > (ulong)bd) + *size = (ulong)bd - *vstart; - if (flags & POST_SLOWTEST) { - ret = memory_post_tests (CFG_SDRAM_BASE, memsize); - } else { /* POST_NORMAL */ + return 0; +} - unsigned long i; +__attribute__((weak)) +int arch_memory_test_advance(u32 *vstart, u32 *size, phys_addr_t *phys_offset) +{ + return 1; +} - for (i = 0; i < (memsize >> 20) && ret == 0; i++) { - if (ret == 0) - ret = memory_post_tests (i << 20, 0x800); - if (ret == 0) - ret = memory_post_tests ((i << 20) + 0xff800, 0x800); +__attribute__((weak)) +int arch_memory_test_cleanup(u32 *vstart, u32 *size, phys_addr_t *phys_offset) +{ + return 0; +} + +__attribute__((weak)) +void arch_memory_failure_handle(void) +{ + return; +} + +int memory_post_test(int flags) +{ + int ret = 0; + phys_addr_t phys_offset = 0; + u32 memsize, vstart; + + arch_memory_test_prepare(&vstart, &memsize, &phys_offset); + + do { + if (flags & POST_SLOWTEST) { + ret = memory_post_tests(vstart, memsize); + } else { /* POST_NORMAL */ + unsigned long i; + for (i = 0; i < (memsize >> 20) && ret == 0; i++) { + if (ret == 0) + ret = memory_post_tests(vstart + + (i << 20), 0x800); + if (ret == 0) + ret = memory_post_tests(vstart + + (i << 20) + 0xff800, 0x800); + } } - } + } while (!ret && + !arch_memory_test_advance(&vstart, &memsize, &phys_offset)); + + arch_memory_test_cleanup(&vstart, &memsize, &phys_offset); + if (ret) + arch_memory_failure_handle(); return ret; } -#endif /* CONFIG_POST & CFG_POST_MEMORY */ -#endif /* CONFIG_POST */ +#endif /* CONFIG_POST & CONFIG_SYS_POST_MEMORY */