From patchwork Thu Nov 25 07:12:57 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sughosh Ganu X-Patchwork-Id: 519375 Delivered-To: patch@linaro.org Received: by 2002:ac0:c605:0:0:0:0:0 with SMTP id p5csp368845imj; Wed, 24 Nov 2021 23:14:43 -0800 (PST) X-Google-Smtp-Source: ABdhPJyR+NW4i9qnXz9NxEmw5xB3XM831Rl0PZndTE6Pbqoo7XdZqs4n4cn+zXkgyHy7CzDHHvBs X-Received: by 2002:a05:6402:5193:: with SMTP id q19mr35543002edd.86.1637824483691; Wed, 24 Nov 2021 23:14:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1637824483; cv=none; d=google.com; s=arc-20160816; b=jfF9Vk0vowIH63sh/ok/xfGPSAuULKt8bJW8U1Mfj2slHOttgclQamxuGNm7KqafsX rceyeRlUnR/TW7ATBEjyWCYeqN6FFAR7FhgrI8iJxZ8a5vLO1FXS7XE5x8+hvf+ykalr mkvsXcRpawKcJOKcKOwa8kOc/A/x3DwkDEDklH3m6QP/figOdJFeQ1zLDZ0FYsvEwcvH dVtIcMOHgKw2sb41tjLYKSnjOUR/QoEcx6JIoxtCSsCQwNDlfU3DWzQEYZmEVbILjsBi jhcpwofXWo7p61Zdk1mxvpEQziaD0yYPD8K6AgQd/dgbg9r+hDKo3iGBZH0iDLl8ANDQ /PoQ== 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=VNB8qoL5DSGMfNq1tTXvDNaR5/RG+dmZlWIHURo8gskoRf0t6HxvbniyvVn/brQdrR 208y31PmYxYOO0uIib1x2uwDRHa4pTZUw3ndb88LK8ZqeAvd3ha2ZS/EcrcwNBKxbELT CUfFl5b558k5tIQ7GeXSzoqY6GLjI6rDp4Sh8+cZbTG25rrFtznr77v9uIMMtRn+e8Uy sNUFGmtcPKHaHESQb9DK5jz05vJEylsJT/qVVspf3kBzODgq12UZDqz7zFwMDxixsL4/ nFFz3Qi8KhCYc0XhOolM8QBYagbnLETP82uSizwRxErDvcLPueDtLCTZNEl2iRMU4/ip GVrA== 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 nd29si6714163ejc.75.2021.11.24.23.14.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 24 Nov 2021 23:14:43 -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 4764A83775; Thu, 25 Nov 2021 08:14:14 +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 9CCD48373E; Thu, 25 Nov 2021 08:13:57 +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 2506E8373F for ; Thu, 25 Nov 2021 08:13:50 +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 613A7152B; Wed, 24 Nov 2021 23:13:49 -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 968023F5A1; Wed, 24 Nov 2021 23:13:45 -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: [RESEND RFC PATCH 05/10] FWU: stm32mp1: Add helper functions for accessing metadata Date: Thu, 25 Nov 2021 12:42:57 +0530 Message-Id: <20211125071302.3644-6-sughosh.ganu@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20211125071302.3644-1-sughosh.ganu@linaro.org> References: <20211125071302.3644-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_ */