aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMayuresh Chitale <mchitale@ventanamicro.com>2023-06-03 19:32:56 +0530
committerTom Rini <trini@konsulko.com>2023-06-19 17:19:44 -0400
commit124be6eeeef5ddab9dd60b2f60fa4c609842c2ef (patch)
treec4d30b2d6f2ad1bbe04472c4dfec5a2c7aba4dd6
parent32f5e9e5c1a787b351ab087ebe284182cfd83188 (diff)
downloadu-boot-WIP/2023-06-19-spl-nvme-support.zip
u-boot-WIP/2023-06-19-spl-nvme-support.tar.gz
u-boot-WIP/2023-06-19-spl-nvme-support.tar.bz2
common: spl: Add spl NVMe boot supportWIP/2023-06-19-spl-nvme-support
Add support to load the next stage image from an NVMe disk which may be formatted as an EXT or FAT filesystem. Also protect the call to env_get in blk_get_device_part_str with CONFIG_SPL_ENV_SUPPORT macro to avoid link error when SPL_ENV_SUPPORT is not enabled. Signed-off-by: Mayuresh Chitale <mchitale@ventanamicro.com>
-rw-r--r--arch/riscv/include/asm/spl.h1
-rw-r--r--common/spl/Makefile1
-rw-r--r--common/spl/spl_nvme.c32
-rw-r--r--disk/part.c10
4 files changed, 40 insertions, 4 deletions
diff --git a/arch/riscv/include/asm/spl.h b/arch/riscv/include/asm/spl.h
index 2898a77..9c0bf975 100644
--- a/arch/riscv/include/asm/spl.h
+++ b/arch/riscv/include/asm/spl.h
@@ -20,6 +20,7 @@ enum {
BOOT_DEVICE_SPI,
BOOT_DEVICE_USB,
BOOT_DEVICE_SATA,
+ BOOT_DEVICE_NVME,
BOOT_DEVICE_I2C,
BOOT_DEVICE_BOARD,
BOOT_DEVICE_DFU,
diff --git a/common/spl/Makefile b/common/spl/Makefile
index 5210ad0..bad2bbf 100644
--- a/common/spl/Makefile
+++ b/common/spl/Makefile
@@ -29,6 +29,7 @@ obj-$(CONFIG_$(SPL_TPL_)USB_STORAGE) += spl_usb.o
obj-$(CONFIG_$(SPL_TPL_)FS_FAT) += spl_fat.o
obj-$(CONFIG_$(SPL_TPL_)FS_EXT4) += spl_ext.o
obj-$(CONFIG_$(SPL_TPL_)SATA) += spl_sata.o
+obj-$(CONFIG_$(SPL_TPL_)NVME) += spl_nvme.o
obj-$(CONFIG_$(SPL_TPL_)SEMIHOSTING) += spl_semihosting.o
obj-$(CONFIG_$(SPL_TPL_)DFU) += spl_dfu.o
obj-$(CONFIG_$(SPL_TPL_)SPI_LOAD) += spl_spi.o
diff --git a/common/spl/spl_nvme.c b/common/spl/spl_nvme.c
new file mode 100644
index 0000000..2af63f1
--- /dev/null
+++ b/common/spl/spl_nvme.c
@@ -0,0 +1,32 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright (C) 2023
+ * Ventana Micro Systems Inc.
+ *
+ */
+
+#include <common.h>
+#include <spl.h>
+#include <init.h>
+#include <nvme.h>
+
+static int spl_nvme_load_image(struct spl_image_info *spl_image,
+ struct spl_boot_device *bootdev)
+{
+ int ret;
+
+ ret = pci_init();
+ if (ret < 0)
+ return ret;
+
+ ret = nvme_scan_namespace();
+ if (ret < 0)
+ return ret;
+
+ ret = spl_blk_load_image(spl_image, bootdev, UCLASS_NVME,
+ CONFIG_SPL_NVME_BOOT_DEVICE,
+ CONFIG_SYS_NVME_BOOT_PARTITION);
+ return ret;
+}
+
+SPL_LOAD_IMAGE_METHOD("NVME", 0, BOOT_DEVICE_NVME, spl_nvme_load_image);
diff --git a/disk/part.c b/disk/part.c
index 35300df5..d330c57 100644
--- a/disk/part.c
+++ b/disk/part.c
@@ -467,10 +467,12 @@ int blk_get_device_part_str(const char *ifname, const char *dev_part_str,
}
#endif
- /* If no dev_part_str, use bootdevice environment variable */
- if (!dev_part_str || !strlen(dev_part_str) ||
- !strcmp(dev_part_str, "-"))
- dev_part_str = env_get("bootdevice");
+ if (IS_ENABLED(CONFIG_SPL_ENV_SUPPORT)) {
+ /* If no dev_part_str, use bootdevice environment variable */
+ if (!dev_part_str || !strlen(dev_part_str) ||
+ !strcmp(dev_part_str, "-"))
+ dev_part_str = env_get("bootdevice");
+ }
/* If still no dev_part_str, it's an error */
if (!dev_part_str) {