From patchwork Thu Nov 25 07:01:41 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sughosh Ganu X-Patchwork-Id: 519361 Delivered-To: patch@linaro.org Received: by 2002:ac0:c605:0:0:0:0:0 with SMTP id p5csp357719imj; Wed, 24 Nov 2021 23:04:01 -0800 (PST) X-Google-Smtp-Source: ABdhPJzg8Z1f+yy+Ld3eEjArfmEtCSKMsbz/lj9cwjksVLtBqr+9CoqMk6tq3+i3SGTnXvSBykJ4 X-Received: by 2002:a17:906:d54e:: with SMTP id cr14mr28577697ejc.458.1637823841523; Wed, 24 Nov 2021 23:04:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1637823841; cv=none; d=google.com; s=arc-20160816; b=Gr/cMvvhC8K+SkIwmzvUVfTUIGBi22lEP2mbR87T5ibjslB31QO0BLcjt7BIx/bxyf 5LYH5b20BBu4w8jbdg6DMxvO/DTJfya0w7zuHMzJdo6vqD2W9yTXQmbqPBzJH7c4uh+M +VPKJ6FdXPwN5oFh8iN4B85P5ebM1LuUoOxRqpA7p+vNJknE+USHLnIeD/qLvIm5iaUT QfH0UnqfX61U1/aNgwm2n3tc2mseo0aCeJhPmtLmAgvPSDzEbTUOLpZExsGWGGQYkCmP 233g8OVLUCtq1cQsgVmstgc/4KI4bIXXBeTytFJeQpA+wL2Oy3zibVT+Mt0sbqt+x7LK nQCw== 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=CpYdJ/o66UcWZlpqK2guk60h9LAoE+a95Rei7NIKwKQ=; b=IQh8JzMCPbbl9olZOWittAAfJq9sWQ3bjCXtWhPqYBoGy7u+t0Kw/HYlev1Ls6baS0 LrsmiqbDOnd6qzahH62YiZNr8EIKJ05LwrfRIPT6mJP59Grwzqdemg4Hgi47qMn1pHUn jrFRDy7sEZfmCdR9xGhg5eb6TZiDwXIvJ2HSsmjSUIdEcIn3vWlxvvA5hEjZPhU9TWL7 bUVxpTUPPJaaNi3PQL81i4YYT0cihiuT++MFpLcEOEGXHad3S0tQejMx0NyJURTEn9bQ 6k45xMO4E6HTWhKbpq+9nt3shcANukqRMyK/r8UJIuzRimzpZpvbO7l2/rg4orpQhak9 3DXw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 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. [2a01:238:438b:c500:173d:9f52:ddab:ee01]) by mx.google.com with ESMTPS id y8si7070024edd.474.2021.11.24.23.03.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 24 Nov 2021 23:04:01 -0800 (PST) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; Authentication-Results: mx.google.com; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 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 F41338371B; Thu, 25 Nov 2021 08:03:29 +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 C291883691; Thu, 25 Nov 2021 08:03:20 +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.2 required=5.0 tests=BAYES_00,SPF_HELO_NONE, SPF_SOFTFAIL autolearn=no 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 6273D83434 for ; Thu, 25 Nov 2021 08:03:16 +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 BA0FB152B; Wed, 24 Nov 2021 23:03:15 -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 F2DA83F5A1; Wed, 24 Nov 2021 23:03:11 -0800 (PST) From: Sughosh Ganu To: u-boot@lists.denx.de Cc: Patrick Delaunay , Patrice Chotard , Heinrich Schuchardt , Alexander Graf , Simon Glass , Bin Meng , Peng Fan , AKASHI Takahiro , Ilias Apalodimas , Jose Marinho , Grant Likely , Jason Liu , Sughosh Ganu Subject: [RFC PATCH 05/10] FWU: stm32mp1: Add helper functions for accessing metadata Date: Thu, 25 Nov 2021 12:31:41 +0530 Message-Id: <20211125070146.2389-6-sughosh.ganu@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20211125070146.2389-1-sughosh.ganu@linaro.org> References: <20211125070146.2389-1-sughosh.ganu@linaro.org> X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.37 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.2 at phobos.denx.de X-Virus-Status: Clean Add helper functions needed for accessing the metadata which contains information on the updatable images. These functions have been added for the STM32MP157C-DK2 board which has the updatable images on the uSD card, formatted as GPT partitions. Signed-off-by: Sughosh Ganu --- board/st/stm32mp1/stm32mp1.c | 63 ++++++++++++++++++++++++++++++++++++ include/fwu_metadata.h | 3 ++ 2 files changed, 66 insertions(+) diff --git a/board/st/stm32mp1/stm32mp1.c b/board/st/stm32mp1/stm32mp1.c index 84592677e4..a6884d2772 100644 --- a/board/st/stm32mp1/stm32mp1.c +++ b/board/st/stm32mp1/stm32mp1.c @@ -7,6 +7,7 @@ #include #include +#include #include #include #include @@ -14,6 +15,7 @@ #include #include #include +#include #include #include #include @@ -23,6 +25,7 @@ #include #include #include +#include #include #include #include @@ -938,3 +941,63 @@ static void board_copro_image_process(ulong fw_image, size_t fw_size) } U_BOOT_FIT_LOADABLE_HANDLER(IH_TYPE_COPRO, board_copro_image_process); + +#ifdef CONFIG_FWU_MULTI_BANK_UPDATE + +int fwu_plat_get_update_index(u32 *update_idx) +{ + int ret; + u32 active_idx; + + ret = fwu_get_active_index(&active_idx); + + if (ret < 0) + return -1; + + *update_idx = active_idx ^= 0x1; + + return ret; +} + +int fwu_plat_get_blk_desc(struct blk_desc **desc) +{ + int ret; + struct mmc *mmc; + struct udevice *dev; + + /* + * Initial support is being added for the DK2 + * platform + */ + if (CONFIG_IS_ENABLED(TARGET_ST_STM32MP15x) && + (of_machine_is_compatible("st,stm32mp157c-dk2"))) { + ret = uclass_get_device(UCLASS_MMC, 0, &dev); + if (ret) + return -1; + + mmc = mmc_get_mmc_dev(dev); + if (!mmc) + return -1; + + if (mmc_init(mmc)) + return -1; + + *desc = mmc_get_blk_desc(mmc); + if (!*desc) + return -1; + } + + return 0; +} + +struct fwu_metadata_ops *get_plat_fwu_metadata_ops(void) +{ + if (CONFIG_IS_ENABLED(TARGET_ST_STM32MP15x) && + (of_machine_is_compatible("st,stm32mp157c-dk2"))) { + return &fwu_gpt_blk_ops; + } + + return NULL; +} + +#endif /* CONFIG_FWU_MULTI_BANK_UPDATE */ diff --git a/include/fwu_metadata.h b/include/fwu_metadata.h index e692ef7506..6a5e814ab6 100644 --- a/include/fwu_metadata.h +++ b/include/fwu_metadata.h @@ -122,4 +122,7 @@ int fwu_accept_image(efi_guid_t *img_type_id); int fwu_clear_accept_image(efi_guid_t *img_type_id, u32 bank); int fwu_get_metadata(struct fwu_metadata **metadata); +int fwu_plat_get_update_index(u32 *update_idx); +int fwu_plat_get_blk_desc(struct blk_desc **desc); + #endif /* _FWU_METADATA_H_ */