blob: 8d21c7dde8092f713aec34dadcc3826a394eeeaf [file] [log] [blame]
Tom Rini83d290c2018-05-06 17:58:06 -04001// SPDX-License-Identifier: GPL-2.0+
wdenka46d8212002-09-12 22:01:13 +00002/*
3 * (C) Copyright 2002
4 * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
wdenka46d8212002-09-12 22:01:13 +00005 */
6
7/*
8 * Diagnostics support
9 */
10#include <common.h>
11#include <command.h>
wdenka46d8212002-09-12 22:01:13 +000012#include <post.h>
13
Wolfgang Denk54841ab2010-06-28 22:00:46 +020014int do_diag (cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[])
wdenka46d8212002-09-12 22:01:13 +000015{
16 unsigned int i;
17
18 if (argc == 1 || strcmp (argv[1], "run") != 0) {
19 /* List test info */
20 if (argc == 1) {
wdenk4b9206e2004-03-23 22:14:11 +000021 puts ("Available hardware tests:\n");
wdenka46d8212002-09-12 22:01:13 +000022 post_info (NULL);
wdenk4b9206e2004-03-23 22:14:11 +000023 puts ("Use 'diag [<test1> [<test2> ...]]'"
wdenka46d8212002-09-12 22:01:13 +000024 " to get more info.\n");
wdenk4b9206e2004-03-23 22:14:11 +000025 puts ("Use 'diag run [<test1> [<test2> ...]]'"
wdenka46d8212002-09-12 22:01:13 +000026 " to run tests.\n");
27 } else {
28 for (i = 1; i < argc; i++) {
29 if (post_info (argv[i]) != 0)
30 printf ("%s - no such test\n", argv[i]);
31 }
32 }
33 } else {
34 /* Run tests */
35 if (argc == 2) {
36 post_run (NULL, POST_RAM | POST_MANUAL);
37 } else {
38 for (i = 2; i < argc; i++) {
39 if (post_run (argv[i], POST_RAM | POST_MANUAL) != 0)
40 printf ("%s - unable to execute the test\n",
41 argv[i]);
42 }
43 }
44 }
45
46 return 0;
47}
wdenk8bde7f72003-06-27 21:31:46 +000048/***************************************************/
49
wdenk0d498392003-07-01 21:06:45 +000050U_BOOT_CMD(
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +020051 diag, CONFIG_SYS_MAXARGS, 0, do_diag,
Peter Tyser2fb26042009-01-27 18:03:12 -060052 "perform board diagnostics",
wdenk8bde7f72003-06-27 21:31:46 +000053 " - print list of available tests\n"
54 "diag [test1 [test2]]\n"
55 " - print information about specified tests\n"
56 "diag run - run all available tests\n"
57 "diag run [test1 [test2]]\n"
Wolfgang Denka89c33d2009-05-24 17:06:54 +020058 " - run specified tests"
wdenk8bde7f72003-06-27 21:31:46 +000059);