]> git.ipfire.org Git - people/ms/u-boot.git/blame - cmd/scsi.c
Merge git://git.denx.de/u-boot-ubi
[people/ms/u-boot.git] / cmd / scsi.c
CommitLineData
e887afc9
WD
1/*
2 * (C) Copyright 2001
3 * Denis Peter, MPL AG Switzerland
4 *
1a459660 5 * SPDX-License-Identifier: GPL-2.0+
e887afc9
WD
6 */
7
8/*
9 * SCSI support.
10 */
e887afc9
WD
11#include <common.h>
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 */
861fe650 20static int do_scsiboot(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[])
e887afc9 21{
7405a133 22 return common_diskboot(cmdtp, "scsi", argc, argv);
e887afc9
WD
23}
24
11f610ed 25/*
e887afc9
WD
26 * scsi command intepreter
27 */
861fe650 28static int do_scsi(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[])
e887afc9 29{
c002e39a
MS
30 int ret;
31
1eaadd34 32 if (argc == 2) {
f1d4d937
SG
33 if (strncmp(argv[1], "res", 3) == 0) {
34 printf("\nReset SCSI\n");
db13a768 35#ifndef CONFIG_DM_SCSI
4682c8a1 36 scsi_bus_reset(NULL);
db13a768 37#endif
8eab1a58 38 ret = scsi_scan(true);
c002e39a
MS
39 if (ret)
40 return CMD_RET_FAILURE;
41 return ret;
f1d4d937 42 }
f1d4d937 43 if (strncmp(argv[1], "scan", 4) == 0) {
8eab1a58 44 ret = scsi_scan(true);
c002e39a
MS
45 if (ret)
46 return CMD_RET_FAILURE;
47 return ret;
f1d4d937 48 }
1eaadd34 49 }
11f610ed 50
1eaadd34 51 return blk_common_cmd(argc, argv, IF_TYPE_SCSI, &scsi_curr_dev);
758c9e69
HTL
52}
53
73a9cfde
SG
54U_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
68U_BOOT_CMD(
69 scsiboot, 3, 1, do_scsiboot,
70 "boot from SCSI device",
71 "loadAddr dev:part"
72);