]> git.ipfire.org Git - thirdparty/u-boot.git/blame - cmd/sata.c
dm: sata: dw_sata: Set up common versions of operations
[thirdparty/u-boot.git] / cmd / sata.c
CommitLineData
c7057b52
DL
1/*
2 * Copyright (C) 2000-2005, DENX Software Engineering
3 * Wolfgang Denk <wd@denx.de>
4 * Copyright (C) Procsys. All rights reserved.
5 * Mushtaq Khan <mushtaq_k@procsys.com>
6 * <mushtaqk_921@yahoo.co.in>
7 * Copyright (C) 2008 Freescale Semiconductor, Inc.
8 * Dave Liu <daveliu@freescale.com>
9 *
1a459660 10 * SPDX-License-Identifier: GPL-2.0+
c7057b52
DL
11 */
12
13#include <common.h>
14#include <command.h>
15#include <part.h>
16#include <sata.h>
17
088f1b19 18static int sata_curr_device = -1;
c7057b52 19
088f1b19 20static int do_sata(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
c7057b52
DL
21{
22 int rc = 0;
23
d957c28a
NK
24 if (argc == 2 && strcmp(argv[1], "stop") == 0)
25 return sata_stop();
26
27 if (argc == 2 && strcmp(argv[1], "init") == 0) {
28 if (sata_curr_device != -1)
29 sata_stop();
30
8547f45b
GB
31 return (sata_initialize() < 0) ?
32 CMD_RET_FAILURE : CMD_RET_SUCCESS;
d957c28a 33 }
cf7e399f
MF
34
35 /* If the user has not yet run `sata init`, do it now */
aa6ab905
TY
36 if (sata_curr_device == -1) {
37 rc = sata_initialize();
38 if (rc == -1)
8547f45b 39 return CMD_RET_FAILURE;
aa6ab905
TY
40 sata_curr_device = rc;
41 }
cf7e399f 42
e29e71e9 43 return blk_common_cmd(argc, argv, IF_TYPE_SATA, &sata_curr_device);
c7057b52
DL
44}
45
46U_BOOT_CMD(
47 sata, 5, 1, do_sata,
2fb2604d 48 "SATA sub system",
85dafbb8 49 "init - init SATA sub system\n"
d957c28a 50 "sata stop - disable SATA sub system\n"
c7057b52
DL
51 "sata info - show available SATA devices\n"
52 "sata device [dev] - show or set current device\n"
53 "sata part [dev] - print partition table\n"
54 "sata read addr blk# cnt\n"
a89c33db
WD
55 "sata write addr blk# cnt"
56);