Wolfgang Denk | b38e0df | 2007-03-06 18:08:43 +0100 | [diff] [blame] | 1 | /* |
| 2 | * (C) Copyright 2002 |
| 3 | * Wolfgang Denk, DENX Software Engineering, wd@denx.de. |
| 4 | * |
Wolfgang Denk | d79de1d | 2013-07-08 09:37:19 +0200 | [diff] [blame] | 5 | * SPDX-License-Identifier: GPL-2.0+ |
Wolfgang Denk | b38e0df | 2007-03-06 18:08:43 +0100 | [diff] [blame] | 6 | */ |
| 7 | |
| 8 | #include <common.h> |
| 9 | |
| 10 | /* Cache test |
| 11 | * |
| 12 | * This test verifies the CPU data and instruction cache using |
| 13 | * several test scenarios. |
| 14 | */ |
| 15 | |
Wolfgang Denk | b38e0df | 2007-03-06 18:08:43 +0100 | [diff] [blame] | 16 | #include <post.h> |
| 17 | #include <watchdog.h> |
| 18 | |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 19 | #if CONFIG_POST & CONFIG_SYS_POST_CACHE |
Wolfgang Denk | b38e0df | 2007-03-06 18:08:43 +0100 | [diff] [blame] | 20 | |
| 21 | #define CACHE_POST_SIZE 1024 |
| 22 | |
| 23 | extern int cache_post_test1 (char *, unsigned int); |
| 24 | extern int cache_post_test2 (char *, unsigned int); |
| 25 | extern int cache_post_test3 (char *, unsigned int); |
| 26 | extern int cache_post_test4 (char *, unsigned int); |
| 27 | extern int cache_post_test5 (void); |
| 28 | extern int cache_post_test6 (void); |
| 29 | |
| 30 | int cache_post_test (int flags) |
| 31 | { |
| 32 | int ints = disable_interrupts (); |
| 33 | int res = 0; |
| 34 | static char ta[CACHE_POST_SIZE + 0xf]; |
| 35 | char *testarea = (char *) (((unsigned long) ta + 0xf) & ~0xf); |
| 36 | |
| 37 | WATCHDOG_RESET (); |
| 38 | if (res == 0) |
| 39 | res = cache_post_test1 (testarea, CACHE_POST_SIZE); |
| 40 | WATCHDOG_RESET (); |
| 41 | if (res == 0) |
| 42 | res = cache_post_test2 (testarea, CACHE_POST_SIZE); |
| 43 | WATCHDOG_RESET (); |
| 44 | if (res == 0) |
| 45 | res = cache_post_test3 (testarea, CACHE_POST_SIZE); |
| 46 | WATCHDOG_RESET (); |
| 47 | if (res == 0) |
| 48 | res = cache_post_test4 (testarea, CACHE_POST_SIZE); |
| 49 | WATCHDOG_RESET (); |
| 50 | if (res == 0) |
| 51 | res = cache_post_test5 (); |
| 52 | WATCHDOG_RESET (); |
| 53 | if (res == 0) |
| 54 | res = cache_post_test6 (); |
| 55 | |
| 56 | WATCHDOG_RESET (); |
| 57 | if (ints) |
| 58 | enable_interrupts (); |
| 59 | return res; |
| 60 | } |
| 61 | |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 62 | #endif /* CONFIG_POST & CONFIG_SYS_POST_CACHE */ |