From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 8FF1BC7EE24 for ; Sat, 3 Jun 2023 14:05:19 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 600B48561F; Sat, 3 Jun 2023 16:05:12 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=ventanamicro.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=ventanamicro.com header.i=@ventanamicro.com header.b="BAWpXZPe"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 61463857D5; Sat, 3 Jun 2023 16:05:10 +0200 (CEST) Received: from mail-oi1-x231.google.com (mail-oi1-x231.google.com [IPv6:2607:f8b0:4864:20::231]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 3C420847D5 for ; Sat, 3 Jun 2023 16:05:06 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=ventanamicro.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=mchitale@ventanamicro.com Received: by mail-oi1-x231.google.com with SMTP id 5614622812f47-39aa825c299so25475b6e.0 for ; Sat, 03 Jun 2023 07:05:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1685801105; x=1688393105; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=ALTsjnS0mp13gyTLnoMsyJYnQI13FNiRxUBipjZDc6s=; b=BAWpXZPe1h6YpJzXnWeIJxo7R2CDB8/EhQ5Gu9m07dbeZZpq6gfyBD1N1yJAh2mu5j h5wmMX5EOAuTYaG/6rj2W/Hofgdol5sod6WczRNNABrJ1XqQMWNywTFDSl9g2EIgZDDj Ztm19kszVDiaEkDM0vzOMqQ+D+6jgr3dWc4IjwCrkrB/uueu8liE477eI61KjxNNbgJC xgmCvD2vz6ln8Tl4G+ze+zEeQ+x6sPWSvV0wSnFLEqAoRE3gfGjiEhewpNYVHnPILw7h pXMIb1Lvy4f35XVDeL6xwvxhWhx5354exXkMzUf2LriaDyXkG8U1gxWyio/2NdnAHabd uDmg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1685801105; x=1688393105; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ALTsjnS0mp13gyTLnoMsyJYnQI13FNiRxUBipjZDc6s=; b=UGIBVbu7TNhn94xBhWbZuN3KnccgiPtQjFO5yWCBKKIbbxsdKF8no5TNV70dgYHFsa HPCgMTeaE5D5ChWMvrMVVk8o5BsiPKioftSFrcu5pnCNse7b+qw2BdffgLD1wrlOkW98 786co9q1OAgp1eTa2F8qv/VQrFMV62/3xYcGhtQJZtZo22qt1+l+eZzqKavhezAtGKBd Lw2kwLVwgg4kgtx1U3bL2/0d6D4MZZNsaGzWLZQYMy1yFaceKnKDFkCMZ/DdTXcEdYgC skfuL7FcTGOXO9/jUo0XDXlg8LvR32gfugWOVJNyfzYjhF4sFRMBz0792DR7jCEOKUju YcQA== X-Gm-Message-State: AC+VfDzcekidN/HdgdpqZcb9xCg1TRTWy6tLFV8D16OEIub4gBN18C7R y0IwlvyeimQNP7F91v5tkiawUQ== X-Google-Smtp-Source: ACHHUZ4dJrt6hzsCzJlghgRIXCYPWYLKOqrFHCboUGdTiqc3buLZ6LzcBhe9XSik5tdF/YfRgC5bcA== X-Received: by 2002:aca:a957:0:b0:39a:a78f:2b79 with SMTP id s84-20020acaa957000000b0039aa78f2b79mr114675oie.16.1685801104518; Sat, 03 Jun 2023 07:05:04 -0700 (PDT) Received: from mchitale-vm.. ([103.97.165.210]) by smtp.googlemail.com with ESMTPSA id cz8-20020a056808404800b0039819ef73e7sm113150oib.2.2023.06.03.07.04.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 03 Jun 2023 07:05:03 -0700 (PDT) From: Mayuresh Chitale To: Bin Meng , Simon Glass Cc: Mayuresh Chitale , u-boot@lists.denx.de, Heinrich Schuchardt , Rick Chen , Leo Subject: [PATCH v4 4/4] common: spl: Add spl NVMe boot support Date: Sat, 3 Jun 2023 19:32:56 +0530 Message-Id: <20230603140256.2443518-5-mchitale@ventanamicro.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230603140256.2443518-1-mchitale@ventanamicro.com> References: <20230603140256.2443518-1-mchitale@ventanamicro.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean 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 --- arch/riscv/include/asm/spl.h | 1 + common/spl/Makefile | 1 + common/spl/spl_nvme.c | 32 ++++++++++++++++++++++++++++++++ disk/part.c | 10 ++++++---- 4 files changed, 40 insertions(+), 4 deletions(-) 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/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..2af63f1dc8 --- /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 +#include +#include +#include + +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 35300df590..d330c57ab4 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) { -- 2.34.1