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 E8AE1C77B7C for ; Thu, 4 May 2023 09:54:51 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 6F5F884797; Thu, 4 May 2023 11:54:01 +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="eh6mnMNp"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 7C69485664; Thu, 4 May 2023 11:53:59 +0200 (CEST) Received: from mail-pj1-x1031.google.com (mail-pj1-x1031.google.com [IPv6:2607:f8b0:4864:20::1031]) (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 CE58F8579B for ; Thu, 4 May 2023 11:53:53 +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-pj1-x1031.google.com with SMTP id 98e67ed59e1d1-24e2bbec3d5so244121a91.3 for ; Thu, 04 May 2023 02:53:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1683194032; x=1685786032; 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=mbkD/iNF8zZpPjiruSQgwfGN/jiOAGxYNC01Fh22qcg=; b=eh6mnMNpls3dlJ5mqfqTiGM2jI1CmAHzSTDuQy+EvktoZBAsUusiXuvWMLlzY5dW0E GSdT1/0GHr9ul7rj88aaSF2HMyloL+95E7g2le6QlA2a+rWhAJENa8vsFhuC2dukoKhy kxfrTvFphPNBjz3603R3ub7ms6YCpIbzNr9gBtFfvdHTujZO0DsHp6D7IbS7dB49Owqu lDwcTHimjFkpDzB7aheV9oqyq1RtrWQ655PhDVD4RlZecAv648VYXh2jvyYIgBrYd1fu TsZ0u9crrnxZVuGduiv939HLV4Qmp7p85Oo/w05WNj1iuZx7DRVgBNmonrWB2ayTpIZ2 cZvg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1683194032; x=1685786032; 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=mbkD/iNF8zZpPjiruSQgwfGN/jiOAGxYNC01Fh22qcg=; b=Smx+u04sKPq2MprFs6TO3Z7qBDbzWE4K80BpggPivTSeq6YTSTzVNbyiF2ggkqUqp4 g9IxkRRYw3SqL0O/fK19g+jT4JEiwGpWWPF4ldC6m9F/AijloNCS07pWXOZtWr2dw5Cu 1rVwWuzqYHWNEhh1NNpHyYb6kwZCmTy9l+FrnISubiubpBK9wJfL+IpRfZVZXXlDvfBO mFNAOLl8yvEvvH13UJqXqaYTKdMGACDm/CRjyh7J8hjPd+nl7ATwBUGQj/MZ7k78dNMu uhPkwdOLcOWok93epaPzxzks1m914TICWQ+XLC2QjwZRLvmzgHm+Sz8GWVemzgTRTFJe 9ZGw== X-Gm-Message-State: AC+VfDxVnZ/6pSlUIQ7BlSTTJEN1zikcPuP17xVmKTcMjvTU7pESBUvO gcQ3SZZ02CVSlW+b0wH5THr2iQ== X-Google-Smtp-Source: ACHHUZ5C5TfUFICr9HAXUYjXPbnVtLiooIouJ3/foqwL3eX+1HibWdEK4D3HtUtVfpKLVk84ShSi7g== X-Received: by 2002:a17:90b:3148:b0:24e:5a0:d2c5 with SMTP id ip8-20020a17090b314800b0024e05a0d2c5mr1639638pjb.30.1683194032147; Thu, 04 May 2023 02:53:52 -0700 (PDT) Received: from mchitale-vm.. ([103.97.165.210]) by smtp.googlemail.com with ESMTPSA id w18-20020a63d752000000b0051b8172fa68sm21746267pgi.38.2023.05.04.02.53.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 May 2023 02:53:51 -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 v3 5/5] common: spl: Add spl NVMe boot support Date: Thu, 4 May 2023 15:23:27 +0530 Message-Id: <20230504095327.2791676-6-mchitale@ventanamicro.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230504095327.2791676-1-mchitale@ventanamicro.com> References: <20230504095327.2791676-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. Signed-off-by: Mayuresh Chitale --- 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 +#include +#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); + return ret; +} + +SPL_LOAD_IMAGE_METHOD("NVME", 0, BOOT_DEVICE_NVME, spl_nvme_load_image); -- 2.34.1