
Add support to load the next stage image from an NVMe disk which may be formatted as an EXT or FAT filesystem.
Signed-off-by: Mayuresh Chitale mchitale@ventanamicro.com --- arch/riscv/include/asm/spl.h | 1 + common/spl/Kconfig | 10 ++++++++++ common/spl/Makefile | 1 + common/spl/spl_nvme.c | 34 ++++++++++++++++++++++++++++++++++ 4 files changed, 46 insertions(+) create mode 100644 common/spl/spl_nvme.c
diff --git a/arch/riscv/include/asm/spl.h b/arch/riscv/include/asm/spl.h index 2898a770ee..9c0bf9755c 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/Kconfig b/common/spl/Kconfig index 515e8f2c66..6e41ac4e56 100644 --- a/common/spl/Kconfig +++ b/common/spl/Kconfig @@ -1284,6 +1284,16 @@ config SPL_NVME_BOOT_DEVICE depends on SPL_NVME default 0x0
+config SYS_NVME_EXT_BOOT_PARTITION + hex "NVMe ext boot partition number" + depends on SPL_NVME + default 0x2 + +config SYS_NVME_FAT_BOOT_PARTITION + hex "NVMe boot partition number" + depends on SPL_NVME + default 0x1 + config SPL_SERIAL bool "Support serial" select SPL_PRINTF diff --git a/common/spl/Makefile b/common/spl/Makefile index 5210ad0248..bad2bbf6cf 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 0000000000..82b2bf3493 --- /dev/null +++ b/common/spl/spl_nvme.c @@ -0,0 +1,34 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Copyright (C) 2023 + * Ventana Micro Systems Inc. + * + * Derived work from spl_sata.c + */ + +#include <common.h> +#include <spl.h> +#include <errno.h> +#include <fat.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); + return ret; +} + +SPL_LOAD_IMAGE_METHOD("NVME", 0, BOOT_DEVICE_NVME, spl_nvme_load_image);