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 6F50AC433FE for ; Thu, 29 Sep 2022 11:39:28 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 2E50784D6F; Thu, 29 Sep 2022 13:38:31 +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="cF3x7g1U"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 1479984B2B; Thu, 29 Sep 2022 11:57:25 +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 1769C84BB9 for ; Thu, 29 Sep 2022 11:57:22 +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 i15-20020a17090a4b8f00b0020073b4ac27so846943pjh.3 for ; Thu, 29 Sep 2022 02:57:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=k2AmtbOzehV/5xTu25nhJueTl+9r/eahnQwQrV/D24M=; b=cF3x7g1U0EZb6feBhZF7WOwE5Uhuu+VVksKx9dH3F6IgQ++4E0w86sdEWjSeYIpYqF lEyco2LpPuwMGLODApmq//qaMpljkQMHA2d2icA/uy9AjMKHM4Ykc6ANd9HByi8RD8sS gUPMWhGUiyYBAA0xyS74ruz5xbNNSNLWh86PyD4+4gj3kmeBT4AY4vOE/UkAVXF8N2Js Pp/WCFL27wRxGnCHLij38PQNstUHzx3qMkU5T/lS/3QXwQz4bQ+ZjO8TBOUXSVvNQXpE Bj2GRNNxLcp5rsX/vaJK6i7OOypFjatrYyiER2Q6YADTYX1WoICioXY3woL0oGjzfqmX azZg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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; bh=k2AmtbOzehV/5xTu25nhJueTl+9r/eahnQwQrV/D24M=; b=rbw3rIEN+Q5qJ3CZTKOtgMatj26h5WKXbxR0Ay9F6GexGcJxtes5+1vrPjQyTbjSRg clQTDhE6K2oCYdlYYOhgFwGXBufokLhjmDjbRIM0bJ3e6X/cibh1WW4TgV0cYyM9Bkic 8sD/T4DVnc6d0I21k6P3uRjQcpZNFdjN84gI9NpRCxwhKgut7517jm9izjYa1FaurTDs iiGcPw9gQKlzEN6mFCUA+Gs7TF9bBbAUrViDtO2cbnfVTyCbc2ELKzxAYOZk/PmJuiDf 0s/LhCQ1FKSAuZcNmSUUZ0uJOE2Upn7kgsyMaaJS0ooO9FyMUdFdOIzePY79tI9VWJ/+ hBAA== X-Gm-Message-State: ACrzQf0AwKdTENVRVcZ8B/1WO1gcMT2WwjG2zCYyoiYXkBU7SC10xkIl LkYByIgztlb+0RqtEsZErfY8jQ== X-Google-Smtp-Source: AMsMyM7BAEgKTWSc538pWWMlgyWEACoOXYTLCUMpcHJQ2wzQpftVfdm+3Udo030j2CP2YzQbydenlw== X-Received: by 2002:a17:902:f64d:b0:178:a963:d400 with SMTP id m13-20020a170902f64d00b00178a963d400mr2723181plg.6.1664445440433; Thu, 29 Sep 2022 02:57:20 -0700 (PDT) Received: from ThinkPad-T490.dc1.ventanamicro.com ([103.97.165.210]) by smtp.googlemail.com with ESMTPSA id a1-20020a170902710100b00176dee43e0dsm5418139pll.285.2022.09.29.02.57.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 29 Sep 2022 02:57:20 -0700 (PDT) From: Mayuresh Chitale To: Bin Meng , Simon Glass Cc: Mayuresh Chitale , u-boot@lists.denx.de, Heinrich Schuchardt , Rick Chen , Leo Subject: [RFC PATCH v1 3/3] common: spl: Add spl NVMe boot support Date: Thu, 29 Sep 2022 15:26:39 +0530 Message-Id: <20220929095639.355675-4-mchitale@ventanamicro.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220929095639.355675-1-mchitale@ventanamicro.com> References: <20220929095639.355675-1-mchitale@ventanamicro.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Mailman-Approved-At: Thu, 29 Sep 2022 13:38:11 +0200 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.6 at phobos.denx.de X-Virus-Status: Clean Add spl_nvme to read a fat partition from a bootable NVMe device. Signed-off-by: Mayuresh Chitale --- arch/riscv/include/asm/spl.h | 1 + common/spl/Makefile | 1 + common/spl/spl_nvme.c | 44 ++++++++++++++++++++++++++++++++++++ 3 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 e8a94fcb1f..5d0ba4b034 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 13db3df993..4bcc3d7e68 100644 --- a/common/spl/Makefile +++ b/common/spl/Makefile @@ -28,6 +28,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..d8a9dba845 --- /dev/null +++ b/common/spl/spl_nvme.c @@ -0,0 +1,44 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Copyright (C) 2022 + * 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; + struct blk_desc *blk_desc; + + ret = pci_init(); + if (ret < 0) + goto out; + + ret = nvme_scan_namespace(); + if (ret < 0) + goto out; + + blk_show_device(IF_TYPE_NVME, CONFIG_SPL_NVME_BOOT_DEVICE); + blk_desc = blk_get_devnum_by_type(IF_TYPE_NVME, + CONFIG_SPL_NVME_BOOT_DEVICE); + if (IS_ENABLED(CONFIG_SPL_FS_FAT)) + ret = spl_load_image_fat(spl_image, bootdev, blk_desc, + CONFIG_SYS_NVME_FAT_BOOT_PARTITION, + CONFIG_SPL_PAYLOAD); + else + ret = -ENOSYS; + +out: + return ret; +} + +SPL_LOAD_IMAGE_METHOD("NVME", 0, BOOT_DEVICE_NVME, spl_nvme_load_image); -- 2.25.1