xref: /openbmc/u-boot/post/lib_powerpc/fpu/fpu.c (revision 29b103c7)
1 /*
2  * Copyright (C) 2007
3  * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
4  *
5  * Author: Sergei Poselenov <sposelenov@emcraft.com>
6  *
7  * SPDX-License-Identifier:	GPL-2.0+
8  */
9 
10 #include <common.h>
11 
12 /*
13  * FPU test
14  *
15  * This test checks the arithmetic logic unit (ALU) of CPU.
16  * It tests independently various groups of instructions using
17  * run-time modification of the code to reduce the memory footprint.
18  * For more details refer to post/cpu/ *.c files.
19  */
20 
21 #include <post.h>
22 
23 GNU_FPOST_ATTR
24 
25 #if CONFIG_POST & CONFIG_SYS_POST_FPU
26 
27 #include <watchdog.h>
28 
29 extern int fpu_status (void);
30 extern void fpu_enable (void);
31 extern void fpu_disable (void);
32 
33 extern int fpu_post_test_math1 (void);
34 extern int fpu_post_test_math2 (void);
35 extern int fpu_post_test_math3 (void);
36 extern int fpu_post_test_math4 (void);
37 extern int fpu_post_test_math5 (void);
38 extern int fpu_post_test_math6 (void);
39 extern int fpu_post_test_math7 (void);
40 
41 int fpu_post_test (int flags)
42 {
43 	int fpu = fpu_status ();
44 
45 	int ret = 0;
46 
47 	WATCHDOG_RESET ();
48 
49 	if (!fpu)
50 		fpu_enable ();
51 
52 	if (ret == 0)
53 		ret = fpu_post_test_math1 ();
54 	if (ret == 0)
55 		ret = fpu_post_test_math2 ();
56 	if (ret == 0)
57 		ret = fpu_post_test_math3 ();
58 	if (ret == 0)
59 		ret = fpu_post_test_math4 ();
60 	if (ret == 0)
61 		ret = fpu_post_test_math5 ();
62 	if (ret == 0)
63 		ret = fpu_post_test_math6 ();
64 	if (ret == 0)
65 		ret = fpu_post_test_math7 ();
66 
67 	if (!fpu)
68 		fpu_disable ();
69 
70 	WATCHDOG_RESET ();
71 
72 	return ret;
73 }
74 
75 #endif /* CONFIG_POST & CONFIG_SYS_POST_FPU */
76