1 // SPDX-License-Identifier: GPL-2.0+
2 /*
3  * (C) Copyright 2000
4  * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
5  */
6 
7 /*
8  * Boot support
9  */
10 #include <common.h>
11 #include <command.h>
12 #include <iomux.h>
13 #include <stdio_dev.h>
14 
15 extern void _do_coninfo (void);
do_coninfo(struct cmd_tbl * cmd,int flag,int argc,char * const argv[])16 static int do_coninfo(struct cmd_tbl *cmd, int flag, int argc,
17 		      char *const argv[])
18 {
19 	int l;
20 	struct list_head *list = stdio_get_list();
21 	struct list_head *pos;
22 	struct stdio_dev *dev;
23 
24 	/* Scan for valid output and input devices */
25 
26 	puts("List of available devices\n");
27 
28 	list_for_each(pos, list) {
29 		dev = list_entry(pos, struct stdio_dev, list);
30 
31 		printf("|-- %s (%s%s)\n",
32 		       dev->name,
33 		       (dev->flags & DEV_FLAGS_INPUT) ? "I" : "",
34 		       (dev->flags & DEV_FLAGS_OUTPUT) ? "O" : "");
35 
36 		for (l = 0; l < MAX_FILES; l++) {
37 			if (CONFIG_IS_ENABLED(CONSOLE_MUX)) {
38 				if (iomux_match_device(console_devices[l],
39 						       cd_count[l], dev) >= 0)
40 					printf("|   |-- %s\n", stdio_names[l]);
41 			} else {
42 				if (stdio_devices[l] == dev)
43 					printf("|   |-- %s\n", stdio_names[l]);
44 			}
45 
46 		}
47 	}
48 	return 0;
49 }
50 
51 
52 /***************************************************/
53 
54 U_BOOT_CMD(
55 	coninfo,	3,	1,	do_coninfo,
56 	"print console devices and information",
57 	""
58 );
59