nvme.c 1.3 KB

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