From patchwork Thu Nov 26 18:41:01 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sughosh Ganu X-Patchwork-Id: 333042 Delivered-To: patch@linaro.org Received: by 2002:a92:5e16:0:0:0:0:0 with SMTP id s22csp1542888ilb; Thu, 26 Nov 2020 10:43:02 -0800 (PST) X-Google-Smtp-Source: ABdhPJwXrcaQ+rvu0CLXIe5VQrHpUdkTb+5qhY1D4YxjbC0kwnnQAUZVvWro/FJ6sWHqFbjvHC+p X-Received: by 2002:a17:906:7e43:: with SMTP id z3mr3889864ejr.67.1606416182027; Thu, 26 Nov 2020 10:43:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1606416182; cv=none; d=google.com; s=arc-20160816; b=0cCFdGRo4NOMu/yFv5w0o/KmmyGNKjN1L+xnp7HRe2/x+JbXVfsfVe5DV+lg7p1pwZ UcUQbiESbBIHRzVDpiOGm4KyQxCoVqgQgdSc17DYtOAdxYw/RLYWyj0y0DzcKzSqL+Pp +nSh/eHnlnqCmo763VQklti9FVdGSjnFUNi4OSbbG5d/eyBrDxdlzjhxvEtnztXUp5Yl 9ijN85xEF3LyTxCEdiiLxF5awetwYgGLfaHdQl6etmU2F1ffuO9UslNiFrNMXYzKT0hl 88R9jRHnF52MMlalN4uNGq0Qvl2sDqoCrVom+OtHZpggn/r58R8lvK1A4HkZeDnHjcfz lN+g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:references:in-reply-to :message-id:date:subject:cc:to:from; bh=OqtLYtxkD3mM3ej3YXXdo7qfrHOGp8l/zJCgOom7Elg=; b=UmbKXh6Fe2QTbWBIAHszXxoqXGL3FfuIZH3tOFQbqSKGT6f8GBQAa5dsZxAC7TcA1o u4VORCW3ukZAjuAoZdp2PFAAagD0ApMjU47tCBCLb/astVtm9TF0hnTUfqTquBr2BUEC txQbNg2Oq7hleOXaWtmJtLny8E6DbRddoAkHX+4Jkp7evzRVKXonEx6XOpZCiP9aTWcL HnWZv5PBhdJyvbGtjl1PDdbZXkYvElohlq97z6p/I7Fv9l4qDwDKX+lkhaG4emE0SjGy s2hJnhT2LGMN2WUBnlsz3PJTb11KdVzSwm+JoIM2h+Mep6sSP51yOA2/iqEnmrvsSKEG Nr5Q== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from phobos.denx.de (phobos.denx.de. [85.214.62.61]) by mx.google.com with ESMTPS id u13si1508439edd.500.2020.11.26.10.43.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 26 Nov 2020 10:43:02 -0800 (PST) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) client-ip=85.214.62.61; Authentication-Results: mx.google.com; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 69AAF826F3; Thu, 26 Nov 2020 19:42:26 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Received: by phobos.denx.de (Postfix, from userid 109) id C4D8A826EA; Thu, 26 Nov 2020 19:42:10 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_NONE, URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by phobos.denx.de (Postfix) with ESMTP id 0FC8F826E2 for ; Thu, 26 Nov 2020 19:42:05 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=fail smtp.mailfrom=sughosh.ganu@linaro.org Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 9C6CB161B; Thu, 26 Nov 2020 10:42:03 -0800 (PST) Received: from a076522.blr.arm.com (a076522.blr.arm.com [10.162.16.44]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 349943F23F; Thu, 26 Nov 2020 10:42:00 -0800 (PST) From: Sughosh Ganu To: u-boot@lists.denx.de Cc: Takahiro Akashi , Heinrich Schuchardt , Alexander Graf , Lukasz Majewski , Tuomas Tynkkynen , Tom Rini , Sughosh Ganu Subject: [PATCH 05/14] qemu: arm64: Add support for dynamic mtdparts for the platform Date: Fri, 27 Nov 2020 00:11:01 +0530 Message-Id: <20201126184110.30521-6-sughosh.ganu@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20201126184110.30521-1-sughosh.ganu@linaro.org> References: <20201126184110.30521-1-sughosh.ganu@linaro.org> X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 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.102.3 at phobos.denx.de X-Virus-Status: Clean Add support for setting the default values for mtd partitions on the platform for the nor flash. This would be used for updating the firmware image using uefi capsule update with the dfu mtd backend driver. Signed-off-by: Sughosh Ganu --- board/emulation/qemu-arm/qemu-arm.c | 70 +++++++++++++++++++++++++++++ include/configs/qemu-arm.h | 7 +++ 2 files changed, 77 insertions(+) -- 2.17.1 diff --git a/board/emulation/qemu-arm/qemu-arm.c b/board/emulation/qemu-arm/qemu-arm.c index b3d5b3d5c2..d5ed3eebaf 100644 --- a/board/emulation/qemu-arm/qemu-arm.c +++ b/board/emulation/qemu-arm/qemu-arm.c @@ -197,3 +197,73 @@ void flash_write32(u32 value, void *addr) { asm("str %" __W "1, %0" : "=m"(*(u32 *)addr) : "r"(value)); } + +#if defined(CONFIG_EFI_CAPSULE_FIRMWARE_MANAGEMENT) + +#include + +static void board_get_mtdparts(const char *dev, const char *partition, + char *mtdids, char *mtdparts) +{ + /* mtdids: "=, ...." */ + if (mtdids[0] != '\0') + strcat(mtdids, ","); + strcat(mtdids, dev); + strcat(mtdids, "="); + strcat(mtdids, dev); + + /* mtdparts: "mtdparts=:>;..." */ + if (mtdparts[0] != '\0') + strncat(mtdparts, ";", MTDPARTS_LEN); + else + strcat(mtdparts, "mtdparts="); + + strncat(mtdparts, dev, MTDPARTS_LEN); + strncat(mtdparts, ":", MTDPARTS_LEN); + strncat(mtdparts, partition, MTDPARTS_LEN); +} + +void board_mtdparts_default(const char **mtdids, const char **mtdparts) +{ + struct mtd_info *mtd; + struct udevice *dev; + const char *mtd_partition; + static char parts[3 * MTDPARTS_LEN + 1]; + static char ids[MTDIDS_LEN + 1]; + static bool mtd_initialized; + + if (mtd_initialized) { + *mtdids = ids; + *mtdparts = parts; + return; + } + + memset(parts, 0, sizeof(parts)); + memset(ids, 0, sizeof(ids)); + + /* probe all MTD devices */ + for (uclass_first_device(UCLASS_MTD, &dev); dev; + uclass_next_device(&dev)) { + debug("mtd device = %s\n", dev->name); + } + + mtd = get_mtd_device_nm("nor0"); + if (!IS_ERR_OR_NULL(mtd)) { + mtd_partition = MTDPARTS_NOR0; + board_get_mtdparts("nor0", mtd_partition, ids, parts); + put_mtd_device(mtd); + } + + mtd = get_mtd_device_nm("nor1"); + if (!IS_ERR_OR_NULL(mtd)) { + mtd_partition = MTDPARTS_NOR1; + board_get_mtdparts("nor1", mtd_partition, ids, parts); + put_mtd_device(mtd); + } + + mtd_initialized = true; + *mtdids = ids; + *mtdparts = parts; + debug("%s:mtdids=%s & mtdparts=%s\n", __func__, ids, parts); +} +#endif /* CONFIG_EFI_CAPSULE_FIRMWARE_MANAGEMENT */ diff --git a/include/configs/qemu-arm.h b/include/configs/qemu-arm.h index 273fa1a7d7..69ff329434 100644 --- a/include/configs/qemu-arm.h +++ b/include/configs/qemu-arm.h @@ -32,6 +32,13 @@ #include +#if defined(CONFIG_EFI_CAPSULE_FIRMWARE_MANAGEMENT) +#define CONFIG_SYS_MTDPARTS_RUNTIME +#endif + +#define MTDPARTS_NOR0 "64m(u-boot)\0" +#define MTDPARTS_NOR1 "64m(u-boot-env)\0" + #define CONFIG_EXTRA_ENV_SETTINGS \ "fdt_high=0xffffffff\0" \ "initrd_high=0xffffffff\0" \