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