Tom Rini | 83d290c | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
Wolfgang Denk | ad5bb45 | 2007-03-06 18:08:43 +0100 | [diff] [blame] | 2 | /* |
| 3 | * (C) Copyright 2002 |
| 4 | * Wolfgang Denk, DENX Software Engineering, wd@denx.de. |
Wolfgang Denk | ad5bb45 | 2007-03-06 18:08:43 +0100 | [diff] [blame] | 5 | */ |
| 6 | |
| 7 | #include <common.h> |
Simon Glass | 9edefc2 | 2019-11-14 12:57:37 -0700 | [diff] [blame] | 8 | #include <cpu_func.h> |
Wolfgang Denk | ad5bb45 | 2007-03-06 18:08:43 +0100 | [diff] [blame] | 9 | |
| 10 | /* |
| 11 | * CPU test |
| 12 | * |
| 13 | * This test checks the arithmetic logic unit (ALU) of CPU. |
| 14 | * It tests independently various groups of instructions using |
| 15 | * run-time modification of the code to reduce the memory footprint. |
| 16 | * For more details refer to post/cpu/ *.c files. |
| 17 | */ |
| 18 | |
Wolfgang Denk | ad5bb45 | 2007-03-06 18:08:43 +0100 | [diff] [blame] | 19 | #include <watchdog.h> |
| 20 | #include <post.h> |
Stefan Roese | 3db93b8 | 2007-10-31 20:51:10 +0100 | [diff] [blame] | 21 | #include <asm/mmu.h> |
Wolfgang Denk | ad5bb45 | 2007-03-06 18:08:43 +0100 | [diff] [blame] | 22 | |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 23 | #if CONFIG_POST & CONFIG_SYS_POST_CPU |
Wolfgang Denk | ad5bb45 | 2007-03-06 18:08:43 +0100 | [diff] [blame] | 24 | |
| 25 | extern int cpu_post_test_cmp (void); |
| 26 | extern int cpu_post_test_cmpi (void); |
| 27 | extern int cpu_post_test_two (void); |
| 28 | extern int cpu_post_test_twox (void); |
| 29 | extern int cpu_post_test_three (void); |
| 30 | extern int cpu_post_test_threex (void); |
| 31 | extern int cpu_post_test_threei (void); |
| 32 | extern int cpu_post_test_andi (void); |
| 33 | extern int cpu_post_test_srawi (void); |
| 34 | extern int cpu_post_test_rlwnm (void); |
| 35 | extern int cpu_post_test_rlwinm (void); |
| 36 | extern int cpu_post_test_rlwimi (void); |
| 37 | extern int cpu_post_test_store (void); |
| 38 | extern int cpu_post_test_load (void); |
| 39 | extern int cpu_post_test_cr (void); |
| 40 | extern int cpu_post_test_b (void); |
| 41 | extern int cpu_post_test_multi (void); |
| 42 | extern int cpu_post_test_string (void); |
| 43 | extern int cpu_post_test_complex (void); |
| 44 | |
| 45 | ulong cpu_post_makecr (long v) |
| 46 | { |
| 47 | ulong cr = 0; |
| 48 | |
| 49 | if (v < 0) |
| 50 | cr |= 0x80000000; |
| 51 | if (v > 0) |
| 52 | cr |= 0x40000000; |
| 53 | if (v == 0) |
| 54 | cr |= 0x20000000; |
| 55 | |
| 56 | return cr; |
| 57 | } |
| 58 | |
| 59 | int cpu_post_test (int flags) |
| 60 | { |
Simon Glass | 6cc915b | 2019-11-14 12:57:36 -0700 | [diff] [blame] | 61 | int ic = icache_status(); |
Wolfgang Denk | ad5bb45 | 2007-03-06 18:08:43 +0100 | [diff] [blame] | 62 | int ret = 0; |
| 63 | |
Stefan Roese | 29caf93 | 2022-09-02 14:10:46 +0200 | [diff] [blame^] | 64 | schedule(); |
Wolfgang Denk | ad5bb45 | 2007-03-06 18:08:43 +0100 | [diff] [blame] | 65 | if (ic) |
Simon Glass | 6cc915b | 2019-11-14 12:57:36 -0700 | [diff] [blame] | 66 | icache_disable(); |
Wolfgang Denk | ad5bb45 | 2007-03-06 18:08:43 +0100 | [diff] [blame] | 67 | |
| 68 | if (ret == 0) |
| 69 | ret = cpu_post_test_cmp (); |
| 70 | if (ret == 0) |
| 71 | ret = cpu_post_test_cmpi (); |
| 72 | if (ret == 0) |
| 73 | ret = cpu_post_test_two (); |
| 74 | if (ret == 0) |
| 75 | ret = cpu_post_test_twox (); |
Stefan Roese | 29caf93 | 2022-09-02 14:10:46 +0200 | [diff] [blame^] | 76 | schedule(); |
Wolfgang Denk | ad5bb45 | 2007-03-06 18:08:43 +0100 | [diff] [blame] | 77 | if (ret == 0) |
| 78 | ret = cpu_post_test_three (); |
| 79 | if (ret == 0) |
| 80 | ret = cpu_post_test_threex (); |
| 81 | if (ret == 0) |
| 82 | ret = cpu_post_test_threei (); |
| 83 | if (ret == 0) |
| 84 | ret = cpu_post_test_andi (); |
Stefan Roese | 29caf93 | 2022-09-02 14:10:46 +0200 | [diff] [blame^] | 85 | schedule(); |
Wolfgang Denk | ad5bb45 | 2007-03-06 18:08:43 +0100 | [diff] [blame] | 86 | if (ret == 0) |
| 87 | ret = cpu_post_test_srawi (); |
| 88 | if (ret == 0) |
| 89 | ret = cpu_post_test_rlwnm (); |
| 90 | if (ret == 0) |
| 91 | ret = cpu_post_test_rlwinm (); |
| 92 | if (ret == 0) |
| 93 | ret = cpu_post_test_rlwimi (); |
Stefan Roese | 29caf93 | 2022-09-02 14:10:46 +0200 | [diff] [blame^] | 94 | schedule(); |
Wolfgang Denk | ad5bb45 | 2007-03-06 18:08:43 +0100 | [diff] [blame] | 95 | if (ret == 0) |
| 96 | ret = cpu_post_test_store (); |
| 97 | if (ret == 0) |
| 98 | ret = cpu_post_test_load (); |
| 99 | if (ret == 0) |
| 100 | ret = cpu_post_test_cr (); |
| 101 | if (ret == 0) |
| 102 | ret = cpu_post_test_b (); |
Stefan Roese | 29caf93 | 2022-09-02 14:10:46 +0200 | [diff] [blame^] | 103 | schedule(); |
Wolfgang Denk | ad5bb45 | 2007-03-06 18:08:43 +0100 | [diff] [blame] | 104 | if (ret == 0) |
| 105 | ret = cpu_post_test_multi (); |
Stefan Roese | 29caf93 | 2022-09-02 14:10:46 +0200 | [diff] [blame^] | 106 | schedule(); |
Wolfgang Denk | ad5bb45 | 2007-03-06 18:08:43 +0100 | [diff] [blame] | 107 | if (ret == 0) |
| 108 | ret = cpu_post_test_string (); |
| 109 | if (ret == 0) |
| 110 | ret = cpu_post_test_complex (); |
Stefan Roese | 29caf93 | 2022-09-02 14:10:46 +0200 | [diff] [blame^] | 111 | schedule(); |
Wolfgang Denk | ad5bb45 | 2007-03-06 18:08:43 +0100 | [diff] [blame] | 112 | |
| 113 | if (ic) |
Simon Glass | 6cc915b | 2019-11-14 12:57:36 -0700 | [diff] [blame] | 114 | icache_enable(); |
Wolfgang Denk | ad5bb45 | 2007-03-06 18:08:43 +0100 | [diff] [blame] | 115 | |
Stefan Roese | 29caf93 | 2022-09-02 14:10:46 +0200 | [diff] [blame^] | 116 | schedule(); |
Wolfgang Denk | ad5bb45 | 2007-03-06 18:08:43 +0100 | [diff] [blame] | 117 | |
| 118 | return ret; |
| 119 | } |
| 120 | |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 121 | #endif /* CONFIG_POST & CONFIG_SYS_POST_CPU */ |