nvme.c 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. // SPDX-License-Identifier: GPL-2.0+
  2. /*
  3. * Copyright (C) 2017 NXP Semiconductors
  4. * Copyright (C) 2017 Bin Meng <bmeng.cn@gmail.com>
  5. */
  6. #include <common.h>
  7. #include <command.h>
  8. #include <dm.h>
  9. #include <nvme.h>
  10. static int nvme_curr_dev;
  11. static int do_nvme(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
  12. {
  13. int ret;
  14. if (argc == 2) {
  15. if (strncmp(argv[1], "scan", 4) == 0) {
  16. ret = nvme_scan_namespace();
  17. if (ret)
  18. return CMD_RET_FAILURE;
  19. return ret;
  20. }
  21. if (strncmp(argv[1], "deta", 4) == 0) {
  22. struct udevice *udev;
  23. ret = blk_get_device(IF_TYPE_NVME, nvme_curr_dev,
  24. &udev);
  25. if (ret < 0)
  26. return CMD_RET_FAILURE;
  27. nvme_print_info(udev);
  28. return ret;
  29. }
  30. }
  31. return blk_common_cmd(argc, argv, IF_TYPE_NVME, &nvme_curr_dev);
  32. }
  33. U_BOOT_CMD(
  34. nvme, 8, 1, do_nvme,
  35. "NVM Express sub-system",
  36. "scan - scan NVMe devices\n"
  37. "nvme detail - show details of current NVMe device\n"
  38. "nvme info - show all available NVMe devices\n"
  39. "nvme device [dev] - show or set current NVMe device\n"
  40. "nvme part [dev] - print partition table of one or all NVMe devices\n"
  41. "nvme read addr blk# cnt - read `cnt' blocks starting at block\n"
  42. " `blk#' to memory address `addr'\n"
  43. "nvme write addr blk# cnt - write `cnt' blocks starting at block\n"
  44. " `blk#' from memory address `addr'"
  45. );