xref: /rk3399_rockchip-uboot/post/lib_powerpc/fpu/fpu.c (revision a47a12becf66f02a56da91c161e2edb625e9f20c)
1*a47a12beSStefan Roese /*
2*a47a12beSStefan Roese  * Copyright (C) 2007
3*a47a12beSStefan Roese  * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
4*a47a12beSStefan Roese  *
5*a47a12beSStefan Roese  * Author: Sergei Poselenov <sposelenov@emcraft.com>
6*a47a12beSStefan Roese  *
7*a47a12beSStefan Roese  * See file CREDITS for list of people who contributed to this
8*a47a12beSStefan Roese  * project.
9*a47a12beSStefan Roese  *
10*a47a12beSStefan Roese  * This program is free software; you can redistribute it and/or
11*a47a12beSStefan Roese  * modify it under the terms of the GNU General Public License as
12*a47a12beSStefan Roese  * published by the Free Software Foundation; either version 2 of
13*a47a12beSStefan Roese  * the License, or (at your option) any later version.
14*a47a12beSStefan Roese  *
15*a47a12beSStefan Roese  * This program is distributed in the hope that it will be useful,
16*a47a12beSStefan Roese  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17*a47a12beSStefan Roese  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18*a47a12beSStefan Roese  * GNU General Public License for more details.
19*a47a12beSStefan Roese  *
20*a47a12beSStefan Roese  * You should have received a copy of the GNU General Public License
21*a47a12beSStefan Roese  * along with this program; if not, write to the Free Software
22*a47a12beSStefan Roese  * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
23*a47a12beSStefan Roese  * MA 02111-1307 USA
24*a47a12beSStefan Roese  */
25*a47a12beSStefan Roese 
26*a47a12beSStefan Roese #include <common.h>
27*a47a12beSStefan Roese 
28*a47a12beSStefan Roese /*
29*a47a12beSStefan Roese  * FPU test
30*a47a12beSStefan Roese  *
31*a47a12beSStefan Roese  * This test checks the arithmetic logic unit (ALU) of CPU.
32*a47a12beSStefan Roese  * It tests independently various groups of instructions using
33*a47a12beSStefan Roese  * run-time modification of the code to reduce the memory footprint.
34*a47a12beSStefan Roese  * For more details refer to post/cpu/ *.c files.
35*a47a12beSStefan Roese  */
36*a47a12beSStefan Roese 
37*a47a12beSStefan Roese #include <post.h>
38*a47a12beSStefan Roese 
39*a47a12beSStefan Roese #if CONFIG_POST & CONFIG_SYS_POST_FPU
40*a47a12beSStefan Roese 
41*a47a12beSStefan Roese #include <watchdog.h>
42*a47a12beSStefan Roese 
43*a47a12beSStefan Roese GNU_FPOST_ATTR
44*a47a12beSStefan Roese 
45*a47a12beSStefan Roese extern int fpu_status (void);
46*a47a12beSStefan Roese extern void fpu_enable (void);
47*a47a12beSStefan Roese extern void fpu_disable (void);
48*a47a12beSStefan Roese 
49*a47a12beSStefan Roese extern int fpu_post_test_math1 (void);
50*a47a12beSStefan Roese extern int fpu_post_test_math2 (void);
51*a47a12beSStefan Roese extern int fpu_post_test_math3 (void);
52*a47a12beSStefan Roese extern int fpu_post_test_math4 (void);
53*a47a12beSStefan Roese extern int fpu_post_test_math5 (void);
54*a47a12beSStefan Roese extern int fpu_post_test_math6 (void);
55*a47a12beSStefan Roese extern int fpu_post_test_math7 (void);
56*a47a12beSStefan Roese 
57*a47a12beSStefan Roese int fpu_post_test (int flags)
58*a47a12beSStefan Roese {
59*a47a12beSStefan Roese 	int fpu = fpu_status ();
60*a47a12beSStefan Roese 
61*a47a12beSStefan Roese 	int ret = 0;
62*a47a12beSStefan Roese 
63*a47a12beSStefan Roese 	WATCHDOG_RESET ();
64*a47a12beSStefan Roese 
65*a47a12beSStefan Roese 	if (!fpu)
66*a47a12beSStefan Roese 		fpu_enable ();
67*a47a12beSStefan Roese 
68*a47a12beSStefan Roese 	if (ret == 0)
69*a47a12beSStefan Roese 		ret = fpu_post_test_math1 ();
70*a47a12beSStefan Roese 	if (ret == 0)
71*a47a12beSStefan Roese 		ret = fpu_post_test_math2 ();
72*a47a12beSStefan Roese 	if (ret == 0)
73*a47a12beSStefan Roese 		ret = fpu_post_test_math3 ();
74*a47a12beSStefan Roese 	if (ret == 0)
75*a47a12beSStefan Roese 		ret = fpu_post_test_math4 ();
76*a47a12beSStefan Roese 	if (ret == 0)
77*a47a12beSStefan Roese 		ret = fpu_post_test_math5 ();
78*a47a12beSStefan Roese 	if (ret == 0)
79*a47a12beSStefan Roese 		ret = fpu_post_test_math6 ();
80*a47a12beSStefan Roese 	if (ret == 0)
81*a47a12beSStefan Roese 		ret = fpu_post_test_math7 ();
82*a47a12beSStefan Roese 
83*a47a12beSStefan Roese 	if (!fpu)
84*a47a12beSStefan Roese 		fpu_disable ();
85*a47a12beSStefan Roese 
86*a47a12beSStefan Roese 	WATCHDOG_RESET ();
87*a47a12beSStefan Roese 
88*a47a12beSStefan Roese 	return ret;
89*a47a12beSStefan Roese }
90*a47a12beSStefan Roese 
91*a47a12beSStefan Roese #endif /* CONFIG_POST & CONFIG_SYS_POST_FPU */
92