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