2018-05-06 21:58:06 +00:00
|
|
|
// SPDX-License-Identifier: GPL-2.0+
|
2017-08-03 09:30:59 +00:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2017 NXP Semiconductors
|
|
|
|
* Copyright (C) 2017 Bin Meng <bmeng.cn@gmail.com>
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <common.h>
|
2020-05-10 17:39:58 +00:00
|
|
|
#include <blk.h>
|
2017-08-03 09:30:59 +00:00
|
|
|
#include <command.h>
|
|
|
|
#include <dm.h>
|
|
|
|
#include <nvme.h>
|
|
|
|
|
2017-08-22 15:15:17 +00:00
|
|
|
static int nvme_curr_dev;
|
2017-08-03 09:30:59 +00:00
|
|
|
|
2020-05-10 17:40:03 +00:00
|
|
|
static int do_nvme(struct cmd_tbl *cmdtp, int flag, int argc,
|
|
|
|
char *const argv[])
|
2017-08-03 09:30:59 +00:00
|
|
|
{
|
|
|
|
int ret;
|
|
|
|
|
2017-08-22 15:15:17 +00:00
|
|
|
if (argc == 2) {
|
|
|
|
if (strncmp(argv[1], "scan", 4) == 0) {
|
|
|
|
ret = nvme_scan_namespace();
|
|
|
|
if (ret)
|
|
|
|
return CMD_RET_FAILURE;
|
2017-08-03 09:30:59 +00:00
|
|
|
|
2017-08-22 15:15:17 +00:00
|
|
|
return ret;
|
2017-08-03 09:30:59 +00:00
|
|
|
}
|
2017-08-22 15:15:17 +00:00
|
|
|
if (strncmp(argv[1], "deta", 4) == 0) {
|
|
|
|
struct udevice *udev;
|
2017-08-03 09:30:59 +00:00
|
|
|
|
2022-08-12 01:34:59 +00:00
|
|
|
ret = blk_get_device(UCLASS_NVME, nvme_curr_dev,
|
2017-08-22 15:15:17 +00:00
|
|
|
&udev);
|
|
|
|
if (ret < 0)
|
|
|
|
return CMD_RET_FAILURE;
|
2017-08-03 09:30:59 +00:00
|
|
|
|
2017-08-22 15:15:17 +00:00
|
|
|
nvme_print_info(udev);
|
2017-08-03 09:30:59 +00:00
|
|
|
|
2017-08-22 15:15:17 +00:00
|
|
|
return ret;
|
2017-08-03 09:30:59 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-08-12 01:34:59 +00:00
|
|
|
return blk_common_cmd(argc, argv, UCLASS_NVME, &nvme_curr_dev);
|
2017-08-03 09:30:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
U_BOOT_CMD(
|
2017-08-22 15:15:17 +00:00
|
|
|
nvme, 8, 1, do_nvme,
|
2017-08-03 09:30:59 +00:00
|
|
|
"NVM Express sub-system",
|
2017-08-22 15:15:17 +00:00
|
|
|
"scan - scan NVMe devices\n"
|
|
|
|
"nvme detail - show details of current NVMe device\n"
|
|
|
|
"nvme info - show all available NVMe devices\n"
|
|
|
|
"nvme device [dev] - show or set current NVMe device\n"
|
|
|
|
"nvme part [dev] - print partition table of one or all NVMe devices\n"
|
|
|
|
"nvme read addr blk# cnt - read `cnt' blocks starting at block\n"
|
|
|
|
" `blk#' to memory address `addr'\n"
|
|
|
|
"nvme write addr blk# cnt - write `cnt' blocks starting at block\n"
|
|
|
|
" `blk#' from memory address `addr'"
|
2017-08-03 09:30:59 +00:00
|
|
|
);
|