xref: /openbmc/u-boot/post/tests.c (revision 8d3fcb5e60b6c8e1d530dbc2e2e33ec6a44670da)
1324f6cfdSwdenk /*
2324f6cfdSwdenk  * (C) Copyright 2002
3324f6cfdSwdenk  * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
4324f6cfdSwdenk  *
5324f6cfdSwdenk  * See file CREDITS for list of people who contributed to this
6324f6cfdSwdenk  * project.
7324f6cfdSwdenk  *
8324f6cfdSwdenk  * This program is free software; you can redistribute it and/or
9324f6cfdSwdenk  * modify it under the terms of the GNU General Public License as
10324f6cfdSwdenk  * published by the Free Software Foundation; either version 2 of
11324f6cfdSwdenk  * the License, or (at your option) any later version.
12324f6cfdSwdenk  *
13324f6cfdSwdenk  * This program is distributed in the hope that it will be useful,
14324f6cfdSwdenk  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15324f6cfdSwdenk  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16324f6cfdSwdenk  * GNU General Public License for more details.
17324f6cfdSwdenk  *
18324f6cfdSwdenk  * You should have received a copy of the GNU General Public License
19324f6cfdSwdenk  * along with this program; if not, write to the Free Software
20324f6cfdSwdenk  * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
21324f6cfdSwdenk  * MA 02111-1307 USA
22228f29acSwdenk  *
23228f29acSwdenk  * Be sure to mark tests to be run before relocation as such with the
246d0f6bcfSJean-Christophe PLAGNIOL-VILLARD  * CONFIG_SYS_POST_PREREL flag so that logging is done correctly if the
25228f29acSwdenk  * logbuffer support is enabled.
26324f6cfdSwdenk  */
27324f6cfdSwdenk 
28324f6cfdSwdenk #include <common.h>
29324f6cfdSwdenk 
30324f6cfdSwdenk #include <post.h>
31324f6cfdSwdenk 
326e8ec682SYuri Tikhonov extern int ocm_post_test (int flags);
33324f6cfdSwdenk extern int cache_post_test (int flags);
34324f6cfdSwdenk extern int watchdog_post_test (int flags);
35324f6cfdSwdenk extern int i2c_post_test (int flags);
36324f6cfdSwdenk extern int rtc_post_test (int flags);
37324f6cfdSwdenk extern int memory_post_test (int flags);
38324f6cfdSwdenk extern int cpu_post_test (int flags);
39a11e0696SIgor Lisitsin extern int fpu_post_test (int flags);
40324f6cfdSwdenk extern int uart_post_test (int flags);
41324f6cfdSwdenk extern int ether_post_test (int flags);
42324f6cfdSwdenk extern int spi_post_test (int flags);
43324f6cfdSwdenk extern int usb_post_test (int flags);
44324f6cfdSwdenk extern int spr_post_test (int flags);
454532cb69Swdenk extern int sysmon_post_test (int flags);
465a8c51cdSwdenk extern int dsp_post_test (int flags);
4779fa88f3Swdenk extern int codec_post_test (int flags);
48531e3e8bSPavel Kolesnikov extern int ecc_post_test (int flags);
49f6f7395eSMike Frysinger extern int flash_post_test(int flags);
504532cb69Swdenk 
5165b20dceSYuri Tikhonov extern int dspic_init_post_test (int flags);
5265b20dceSYuri Tikhonov extern int dspic_post_test (int flags);
5365b20dceSYuri Tikhonov extern int gdc_post_test (int flags);
5465b20dceSYuri Tikhonov extern int fpga_post_test (int flags);
5565b20dceSYuri Tikhonov extern int lwmon5_watchdog_post_test(int flags);
5665b20dceSYuri Tikhonov extern int sysmon1_post_test(int flags);
5729fd7cebSAnatolij Gustschin extern int coprocessor_post_test(int flags);
582151374fSMike Frysinger extern int led_post_test(int flags);
592151374fSMike Frysinger extern int button_post_test(int flags);
60*8d3fcb5eSValentin Longchamp extern int memory_regions_post_test(int flags);
6165b20dceSYuri Tikhonov 
624532cb69Swdenk extern int sysmon_init_f (void);
634532cb69Swdenk 
644532cb69Swdenk extern void sysmon_reloc (void);
654532cb69Swdenk 
66324f6cfdSwdenk 
67324f6cfdSwdenk struct post_test post_list[] =
68324f6cfdSwdenk {
696d0f6bcfSJean-Christophe PLAGNIOL-VILLARD #if CONFIG_POST & CONFIG_SYS_POST_OCM
706e8ec682SYuri Tikhonov     {
716e8ec682SYuri Tikhonov 	"OCM test",
726e8ec682SYuri Tikhonov 	"ocm",
736e8ec682SYuri Tikhonov 	"This test checks on chip memory (OCM).",
747845d490SYuri Tikhonov 	POST_ROM | POST_ALWAYS | POST_PREREL | POST_CRITICAL | POST_STOP,
756e8ec682SYuri Tikhonov 	&ocm_post_test,
766e8ec682SYuri Tikhonov 	NULL,
776e8ec682SYuri Tikhonov 	NULL,
786d0f6bcfSJean-Christophe PLAGNIOL-VILLARD 	CONFIG_SYS_POST_OCM
796e8ec682SYuri Tikhonov     },
806e8ec682SYuri Tikhonov #endif
816d0f6bcfSJean-Christophe PLAGNIOL-VILLARD #if CONFIG_POST & CONFIG_SYS_POST_CACHE
82324f6cfdSwdenk     {
83324f6cfdSwdenk 	"Cache test",
84324f6cfdSwdenk 	"cache",
85324f6cfdSwdenk 	"This test verifies the CPU cache operation.",
86324f6cfdSwdenk 	POST_RAM | POST_ALWAYS,
87228f29acSwdenk 	&cache_post_test,
884532cb69Swdenk 	NULL,
894532cb69Swdenk 	NULL,
906d0f6bcfSJean-Christophe PLAGNIOL-VILLARD 	CONFIG_SYS_POST_CACHE
91324f6cfdSwdenk     },
92324f6cfdSwdenk #endif
936d0f6bcfSJean-Christophe PLAGNIOL-VILLARD #if CONFIG_POST & CONFIG_SYS_POST_WATCHDOG
9465b20dceSYuri Tikhonov #if defined(CONFIG_POST_WATCHDOG)
9565b20dceSYuri Tikhonov 	CONFIG_POST_WATCHDOG,
9665b20dceSYuri Tikhonov #else
97324f6cfdSwdenk     {
98324f6cfdSwdenk 	"Watchdog timer test",
99324f6cfdSwdenk 	"watchdog",
100324f6cfdSwdenk 	"This test checks the watchdog timer.",
1018564acf9Swdenk 	POST_RAM | POST_POWERON | POST_SLOWTEST | POST_MANUAL | POST_REBOOT,
102228f29acSwdenk 	&watchdog_post_test,
1034532cb69Swdenk 	NULL,
1044532cb69Swdenk 	NULL,
1056d0f6bcfSJean-Christophe PLAGNIOL-VILLARD 	CONFIG_SYS_POST_WATCHDOG
106324f6cfdSwdenk     },
107324f6cfdSwdenk #endif
10865b20dceSYuri Tikhonov #endif
1096d0f6bcfSJean-Christophe PLAGNIOL-VILLARD #if CONFIG_POST & CONFIG_SYS_POST_I2C
110324f6cfdSwdenk     {
111324f6cfdSwdenk 	"I2C test",
112324f6cfdSwdenk 	"i2c",
113324f6cfdSwdenk 	"This test verifies the I2C operation.",
114324f6cfdSwdenk 	POST_RAM | POST_ALWAYS,
115228f29acSwdenk 	&i2c_post_test,
1164532cb69Swdenk 	NULL,
1174532cb69Swdenk 	NULL,
1186d0f6bcfSJean-Christophe PLAGNIOL-VILLARD 	CONFIG_SYS_POST_I2C
119324f6cfdSwdenk     },
120324f6cfdSwdenk #endif
1216d0f6bcfSJean-Christophe PLAGNIOL-VILLARD #if CONFIG_POST & CONFIG_SYS_POST_RTC
122324f6cfdSwdenk     {
123324f6cfdSwdenk 	"RTC test",
124324f6cfdSwdenk 	"rtc",
125324f6cfdSwdenk 	"This test verifies the RTC operation.",
1268564acf9Swdenk 	POST_RAM | POST_SLOWTEST | POST_MANUAL,
127228f29acSwdenk 	&rtc_post_test,
1284532cb69Swdenk 	NULL,
1294532cb69Swdenk 	NULL,
1306d0f6bcfSJean-Christophe PLAGNIOL-VILLARD 	CONFIG_SYS_POST_RTC
131324f6cfdSwdenk     },
132324f6cfdSwdenk #endif
1336d0f6bcfSJean-Christophe PLAGNIOL-VILLARD #if CONFIG_POST & CONFIG_SYS_POST_MEMORY
134324f6cfdSwdenk     {
135324f6cfdSwdenk 	"Memory test",
136324f6cfdSwdenk 	"memory",
137324f6cfdSwdenk 	"This test checks RAM.",
1388564acf9Swdenk 	POST_ROM | POST_POWERON | POST_SLOWTEST | POST_PREREL,
139228f29acSwdenk 	&memory_post_test,
1404532cb69Swdenk 	NULL,
1414532cb69Swdenk 	NULL,
1426d0f6bcfSJean-Christophe PLAGNIOL-VILLARD 	CONFIG_SYS_POST_MEMORY
143324f6cfdSwdenk     },
144324f6cfdSwdenk #endif
1456d0f6bcfSJean-Christophe PLAGNIOL-VILLARD #if CONFIG_POST & CONFIG_SYS_POST_CPU
146324f6cfdSwdenk     {
147324f6cfdSwdenk 	"CPU test",
148324f6cfdSwdenk 	"cpu",
149324f6cfdSwdenk 	"This test verifies the arithmetic logic unit of"
150324f6cfdSwdenk 	" CPU.",
151324f6cfdSwdenk 	POST_RAM | POST_ALWAYS,
152228f29acSwdenk 	&cpu_post_test,
1534532cb69Swdenk 	NULL,
1544532cb69Swdenk 	NULL,
1556d0f6bcfSJean-Christophe PLAGNIOL-VILLARD 	CONFIG_SYS_POST_CPU
156324f6cfdSwdenk     },
157324f6cfdSwdenk #endif
1586d0f6bcfSJean-Christophe PLAGNIOL-VILLARD #if CONFIG_POST & CONFIG_SYS_POST_FPU
159a11e0696SIgor Lisitsin     {
160a11e0696SIgor Lisitsin 	"FPU test",
161a11e0696SIgor Lisitsin 	"fpu",
162a11e0696SIgor Lisitsin 	"This test verifies the arithmetic logic unit of"
163a11e0696SIgor Lisitsin 	" FPU.",
164a11e0696SIgor Lisitsin 	POST_RAM | POST_ALWAYS,
165a11e0696SIgor Lisitsin 	&fpu_post_test,
166a11e0696SIgor Lisitsin 	NULL,
167a11e0696SIgor Lisitsin 	NULL,
1686d0f6bcfSJean-Christophe PLAGNIOL-VILLARD 	CONFIG_SYS_POST_FPU
169a11e0696SIgor Lisitsin     },
170a11e0696SIgor Lisitsin #endif
1716d0f6bcfSJean-Christophe PLAGNIOL-VILLARD #if CONFIG_POST & CONFIG_SYS_POST_UART
172834a45d7SStefan Roese #if defined(CONFIG_POST_UART)
173834a45d7SStefan Roese 	CONFIG_POST_UART,
174834a45d7SStefan Roese #else
175324f6cfdSwdenk     {
176324f6cfdSwdenk 	"UART test",
177324f6cfdSwdenk 	"uart",
178324f6cfdSwdenk 	"This test verifies the UART operation.",
1798564acf9Swdenk 	POST_RAM | POST_SLOWTEST | POST_MANUAL,
180228f29acSwdenk 	&uart_post_test,
1814532cb69Swdenk 	NULL,
1824532cb69Swdenk 	NULL,
1836d0f6bcfSJean-Christophe PLAGNIOL-VILLARD 	CONFIG_SYS_POST_UART
184324f6cfdSwdenk     },
185834a45d7SStefan Roese #endif /* CONFIG_POST_UART */
186324f6cfdSwdenk #endif
1876d0f6bcfSJean-Christophe PLAGNIOL-VILLARD #if CONFIG_POST & CONFIG_SYS_POST_ETHER
188324f6cfdSwdenk     {
189324f6cfdSwdenk 	"ETHERNET test",
190324f6cfdSwdenk 	"ethernet",
191324f6cfdSwdenk 	"This test verifies the ETHERNET operation.",
192324f6cfdSwdenk 	POST_RAM | POST_ALWAYS | POST_MANUAL,
193228f29acSwdenk 	&ether_post_test,
1944532cb69Swdenk 	NULL,
1954532cb69Swdenk 	NULL,
1966d0f6bcfSJean-Christophe PLAGNIOL-VILLARD 	CONFIG_SYS_POST_ETHER
197324f6cfdSwdenk     },
198324f6cfdSwdenk #endif
1996d0f6bcfSJean-Christophe PLAGNIOL-VILLARD #if CONFIG_POST & CONFIG_SYS_POST_SPI
200324f6cfdSwdenk     {
201324f6cfdSwdenk 	"SPI test",
202324f6cfdSwdenk 	"spi",
203324f6cfdSwdenk 	"This test verifies the SPI operation.",
204324f6cfdSwdenk 	POST_RAM | POST_ALWAYS | POST_MANUAL,
205228f29acSwdenk 	&spi_post_test,
2064532cb69Swdenk 	NULL,
2074532cb69Swdenk 	NULL,
2086d0f6bcfSJean-Christophe PLAGNIOL-VILLARD 	CONFIG_SYS_POST_SPI
209324f6cfdSwdenk     },
210324f6cfdSwdenk #endif
2116d0f6bcfSJean-Christophe PLAGNIOL-VILLARD #if CONFIG_POST & CONFIG_SYS_POST_USB
212324f6cfdSwdenk     {
213324f6cfdSwdenk 	"USB test",
214324f6cfdSwdenk 	"usb",
215324f6cfdSwdenk 	"This test verifies the USB operation.",
216324f6cfdSwdenk 	POST_RAM | POST_ALWAYS | POST_MANUAL,
217228f29acSwdenk 	&usb_post_test,
2184532cb69Swdenk 	NULL,
2194532cb69Swdenk 	NULL,
2206d0f6bcfSJean-Christophe PLAGNIOL-VILLARD 	CONFIG_SYS_POST_USB
221324f6cfdSwdenk     },
222324f6cfdSwdenk #endif
2236d0f6bcfSJean-Christophe PLAGNIOL-VILLARD #if CONFIG_POST & CONFIG_SYS_POST_SPR
224324f6cfdSwdenk     {
225324f6cfdSwdenk 	"SPR test",
226324f6cfdSwdenk 	"spr",
227324f6cfdSwdenk 	"This test checks SPR contents.",
228b2e2142cSStefan Roese 	POST_RAM | POST_ALWAYS,
229228f29acSwdenk 	&spr_post_test,
2304532cb69Swdenk 	NULL,
2314532cb69Swdenk 	NULL,
2326d0f6bcfSJean-Christophe PLAGNIOL-VILLARD 	CONFIG_SYS_POST_SPR
233324f6cfdSwdenk     },
234324f6cfdSwdenk #endif
2356d0f6bcfSJean-Christophe PLAGNIOL-VILLARD #if CONFIG_POST & CONFIG_SYS_POST_SYSMON
2364532cb69Swdenk     {
2374532cb69Swdenk 	"SYSMON test",
2384532cb69Swdenk 	"sysmon",
2394532cb69Swdenk 	"This test monitors system hardware.",
2404532cb69Swdenk 	POST_RAM | POST_ALWAYS,
2414532cb69Swdenk 	&sysmon_post_test,
2424532cb69Swdenk 	&sysmon_init_f,
2434532cb69Swdenk 	&sysmon_reloc,
2446d0f6bcfSJean-Christophe PLAGNIOL-VILLARD 	CONFIG_SYS_POST_SYSMON
2454532cb69Swdenk     },
2464532cb69Swdenk #endif
2476d0f6bcfSJean-Christophe PLAGNIOL-VILLARD #if CONFIG_POST & CONFIG_SYS_POST_DSP
2485a8c51cdSwdenk     {
2495a8c51cdSwdenk 	"DSP test",
2505a8c51cdSwdenk 	"dsp",
2515a8c51cdSwdenk 	"This test checks any connected DSP(s).",
2525744ddc6SSascha Laue 	POST_RAM | POST_ALWAYS | POST_MANUAL,
2535a8c51cdSwdenk 	&dsp_post_test,
2545a8c51cdSwdenk 	NULL,
2555a8c51cdSwdenk 	NULL,
2566d0f6bcfSJean-Christophe PLAGNIOL-VILLARD 	CONFIG_SYS_POST_DSP
2575a8c51cdSwdenk     },
2585a8c51cdSwdenk #endif
2596d0f6bcfSJean-Christophe PLAGNIOL-VILLARD #if CONFIG_POST & CONFIG_SYS_POST_CODEC
26079fa88f3Swdenk     {
26179fa88f3Swdenk 	"CODEC test",
26279fa88f3Swdenk 	"codec",
26379fa88f3Swdenk 	"This test checks any connected codec(s).",
26479fa88f3Swdenk 	POST_RAM | POST_MANUAL,
26579fa88f3Swdenk 	&codec_post_test,
26679fa88f3Swdenk 	NULL,
26779fa88f3Swdenk 	NULL,
2686d0f6bcfSJean-Christophe PLAGNIOL-VILLARD 	CONFIG_SYS_POST_CODEC
26979fa88f3Swdenk     },
27079fa88f3Swdenk #endif
2716d0f6bcfSJean-Christophe PLAGNIOL-VILLARD #if CONFIG_POST & CONFIG_SYS_POST_ECC
272531e3e8bSPavel Kolesnikov     {
273531e3e8bSPavel Kolesnikov 	"ECC test",
274531e3e8bSPavel Kolesnikov 	"ecc",
2758dafa874SLarry Johnson 	"This test checks the ECC facility of memory.",
2768dafa874SLarry Johnson 	POST_ROM | POST_ALWAYS | POST_PREREL,
277531e3e8bSPavel Kolesnikov 	&ecc_post_test,
278531e3e8bSPavel Kolesnikov 	NULL,
279531e3e8bSPavel Kolesnikov 	NULL,
2806d0f6bcfSJean-Christophe PLAGNIOL-VILLARD 	CONFIG_SYS_POST_ECC
281531e3e8bSPavel Kolesnikov     },
282531e3e8bSPavel Kolesnikov #endif
2836d0f6bcfSJean-Christophe PLAGNIOL-VILLARD #if CONFIG_POST & CONFIG_SYS_POST_BSPEC1
28465b20dceSYuri Tikhonov 	CONFIG_POST_BSPEC1,
28565b20dceSYuri Tikhonov #endif
2866d0f6bcfSJean-Christophe PLAGNIOL-VILLARD #if CONFIG_POST & CONFIG_SYS_POST_BSPEC2
28765b20dceSYuri Tikhonov 	CONFIG_POST_BSPEC2,
28865b20dceSYuri Tikhonov #endif
2896d0f6bcfSJean-Christophe PLAGNIOL-VILLARD #if CONFIG_POST & CONFIG_SYS_POST_BSPEC3
29065b20dceSYuri Tikhonov 	CONFIG_POST_BSPEC3,
29165b20dceSYuri Tikhonov #endif
2926d0f6bcfSJean-Christophe PLAGNIOL-VILLARD #if CONFIG_POST & CONFIG_SYS_POST_BSPEC4
29365b20dceSYuri Tikhonov 	CONFIG_POST_BSPEC4,
29465b20dceSYuri Tikhonov #endif
2956d0f6bcfSJean-Christophe PLAGNIOL-VILLARD #if CONFIG_POST & CONFIG_SYS_POST_BSPEC5
29665b20dceSYuri Tikhonov 	CONFIG_POST_BSPEC5,
29765b20dceSYuri Tikhonov #endif
29829fd7cebSAnatolij Gustschin #if CONFIG_POST & CONFIG_SYS_POST_COPROC
29929fd7cebSAnatolij Gustschin     {
30029fd7cebSAnatolij Gustschin 	"Coprocessors communication test",
30129fd7cebSAnatolij Gustschin 	"coproc_com",
30229fd7cebSAnatolij Gustschin 	"This test checks communication with coprocessors.",
30329fd7cebSAnatolij Gustschin 	POST_RAM | POST_ALWAYS | POST_CRITICAL,
30429fd7cebSAnatolij Gustschin 	&coprocessor_post_test,
30529fd7cebSAnatolij Gustschin 	NULL,
30629fd7cebSAnatolij Gustschin 	NULL,
30729fd7cebSAnatolij Gustschin 	CONFIG_SYS_POST_COPROC
308f6f7395eSMike Frysinger     },
309f6f7395eSMike Frysinger #endif
310f6f7395eSMike Frysinger #if CONFIG_POST & CONFIG_SYS_POST_FLASH
311f6f7395eSMike Frysinger     {
312f6f7395eSMike Frysinger 	"Parallel NOR flash test",
313f6f7395eSMike Frysinger 	"flash",
314f6f7395eSMike Frysinger 	"This test verifies parallel flash operations.",
315f6f7395eSMike Frysinger 	POST_RAM | POST_SLOWTEST | POST_MANUAL,
316f6f7395eSMike Frysinger 	&flash_post_test,
317f6f7395eSMike Frysinger 	NULL,
318f6f7395eSMike Frysinger 	NULL,
319f6f7395eSMike Frysinger 	CONFIG_SYS_POST_FLASH
320f6f7395eSMike Frysinger     },
32129fd7cebSAnatolij Gustschin #endif
322*8d3fcb5eSValentin Longchamp #if CONFIG_POST & CONFIG_SYS_POST_MEM_REGIONS
323*8d3fcb5eSValentin Longchamp     {
324*8d3fcb5eSValentin Longchamp 	"Memory regions test",
325*8d3fcb5eSValentin Longchamp 	"mem_regions",
326*8d3fcb5eSValentin Longchamp 	"This test checks regularly placed regions of the RAM.",
327*8d3fcb5eSValentin Longchamp 	POST_ROM | POST_SLOWTEST | POST_PREREL,
328*8d3fcb5eSValentin Longchamp 	&memory_regions_post_test,
329*8d3fcb5eSValentin Longchamp 	NULL,
330*8d3fcb5eSValentin Longchamp 	NULL,
331*8d3fcb5eSValentin Longchamp 	CONFIG_SYS_POST_MEM_REGIONS
332*8d3fcb5eSValentin Longchamp     },
333*8d3fcb5eSValentin Longchamp #endif
334324f6cfdSwdenk };
335324f6cfdSwdenk 
336d2397817SMike Frysinger unsigned int post_list_size = ARRAY_SIZE(post_list);
337