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