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