2008-03-26 22:49:44 +08:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2000-2005, DENX Software Engineering
|
|
|
|
* Wolfgang Denk <wd@denx.de>
|
|
|
|
* Copyright (C) Procsys. All rights reserved.
|
|
|
|
* Mushtaq Khan <mushtaq_k@procsys.com>
|
|
|
|
* <mushtaqk_921@yahoo.co.in>
|
|
|
|
* Copyright (C) 2008 Freescale Semiconductor, Inc.
|
|
|
|
* Dave Liu <daveliu@freescale.com>
|
|
|
|
*
|
2013-07-08 09:37:19 +02:00
|
|
|
* SPDX-License-Identifier: GPL-2.0+
|
2008-03-26 22:49:44 +08:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <common.h>
|
|
|
|
#include <command.h>
|
|
|
|
#include <part.h>
|
|
|
|
#include <sata.h>
|
|
|
|
|
2012-10-29 13:34:31 +00:00
|
|
|
static int sata_curr_device = -1;
|
2008-03-26 22:49:44 +08:00
|
|
|
|
2012-10-29 13:34:31 +00:00
|
|
|
static int do_sata(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
|
2008-03-26 22:49:44 +08:00
|
|
|
{
|
|
|
|
int rc = 0;
|
|
|
|
|
2014-11-21 12:47:24 +02:00
|
|
|
if (argc == 2 && strcmp(argv[1], "stop") == 0)
|
|
|
|
return sata_stop();
|
|
|
|
|
|
|
|
if (argc == 2 && strcmp(argv[1], "init") == 0) {
|
|
|
|
if (sata_curr_device != -1)
|
|
|
|
sata_stop();
|
|
|
|
|
2017-01-11 16:51:53 +01:00
|
|
|
return (sata_initialize() < 0) ?
|
|
|
|
CMD_RET_FAILURE : CMD_RET_SUCCESS;
|
2014-11-21 12:47:24 +02:00
|
|
|
}
|
2009-01-27 16:12:21 -05:00
|
|
|
|
|
|
|
/* If the user has not yet run `sata init`, do it now */
|
2016-11-21 10:24:20 +08:00
|
|
|
if (sata_curr_device == -1) {
|
|
|
|
rc = sata_initialize();
|
|
|
|
if (rc == -1)
|
2017-01-11 16:51:53 +01:00
|
|
|
return CMD_RET_FAILURE;
|
2016-11-21 10:24:20 +08:00
|
|
|
sata_curr_device = rc;
|
|
|
|
}
|
2009-01-27 16:12:21 -05:00
|
|
|
|
2017-07-29 11:34:55 -06:00
|
|
|
return blk_common_cmd(argc, argv, IF_TYPE_SATA, &sata_curr_device);
|
2008-03-26 22:49:44 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
U_BOOT_CMD(
|
|
|
|
sata, 5, 1, do_sata,
|
2009-01-27 18:03:12 -06:00
|
|
|
"SATA sub system",
|
2013-02-20 14:35:35 +00:00
|
|
|
"init - init SATA sub system\n"
|
2014-11-21 12:47:24 +02:00
|
|
|
"sata stop - disable SATA sub system\n"
|
2008-03-26 22:49:44 +08:00
|
|
|
"sata info - show available SATA devices\n"
|
|
|
|
"sata device [dev] - show or set current device\n"
|
|
|
|
"sata part [dev] - print partition table\n"
|
|
|
|
"sata read addr blk# cnt\n"
|
2009-05-24 17:06:54 +02:00
|
|
|
"sata write addr blk# cnt"
|
|
|
|
);
|