xref: /openbmc/u-boot/cmd/scsi.c (revision 5541543f)
1 /*
2  * (C) Copyright 2001
3  * Denis Peter, MPL AG Switzerland
4  *
5  * SPDX-License-Identifier:	GPL-2.0+
6  */
7 
8 /*
9  * SCSI support.
10  */
11 #include <common.h>
12 #include <command.h>
13 #include <scsi.h>
14 
15 static int scsi_curr_dev; /* current device */
16 
17 /*
18  * scsi boot command intepreter. Derived from diskboot
19  */
20 static int do_scsiboot(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[])
21 {
22 	return common_diskboot(cmdtp, "scsi", argc, argv);
23 }
24 
25 /*
26  * scsi command intepreter
27  */
28 static int do_scsi(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[])
29 {
30 	int ret;
31 
32 	if (argc == 2) {
33 		if (strncmp(argv[1], "res", 3) == 0) {
34 			printf("\nReset SCSI\n");
35 #ifndef CONFIG_DM_SCSI
36 			scsi_bus_reset(NULL);
37 #endif
38 			ret = scsi_scan(true);
39 			if (ret)
40 				return CMD_RET_FAILURE;
41 			return ret;
42 		}
43 		if (strncmp(argv[1], "scan", 4) == 0) {
44 			ret = scsi_scan(true);
45 			if (ret)
46 				return CMD_RET_FAILURE;
47 			return ret;
48 		}
49 	}
50 
51 	return blk_common_cmd(argc, argv, IF_TYPE_SCSI, &scsi_curr_dev);
52 }
53 
54 U_BOOT_CMD(
55 	scsi, 5, 1, do_scsi,
56 	"SCSI sub-system",
57 	"reset - reset SCSI controller\n"
58 	"scsi info  - show available SCSI devices\n"
59 	"scsi scan  - (re-)scan SCSI bus\n"
60 	"scsi device [dev] - show or set current device\n"
61 	"scsi part [dev] - print partition table of one or all SCSI devices\n"
62 	"scsi read addr blk# cnt - read `cnt' blocks starting at block `blk#'\n"
63 	"     to memory address `addr'\n"
64 	"scsi write addr blk# cnt - write `cnt' blocks starting at block\n"
65 	"     `blk#' from memory address `addr'"
66 );
67 
68 U_BOOT_CMD(
69 	scsiboot, 3, 1, do_scsiboot,
70 	"boot from SCSI device",
71 	"loadAddr dev:part"
72 );
73