mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Ahmad Fatoum <a.fatoum@pengutronix.de>
To: barebox@lists.infradead.org
Cc: Ahmad Fatoum <a.fatoum@pengutronix.de>
Subject: [PATCH 3/7] bbu: add flag for enabling eMMC boot ack
Date: Thu,  2 Jun 2022 11:01:29 +0200	[thread overview]
Message-ID: <20220602090133.3190450-4-a.fatoum@pengutronix.de> (raw)
In-Reply-To: <20220602090133.3190450-1-a.fatoum@pengutronix.de>

bbu_mmcboot_handler() already takes care to switch $mmc.boot to the
freshly read inactive partition. On some SoCs like the STM32MP1, this is
not enough, but the boot ack bit must be set as well, so the BootROM can
communicate with the eMMC.

Have this happen as part of the eMMC boot switch after a successful
update if bbu_data::flags has BBU_FLAG_MMC_BOOT_ACK set.

Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
 common/bbu.c  | 17 ++++++++++++++++-
 include/bbu.h |  1 +
 2 files changed, 17 insertions(+), 1 deletion(-)

diff --git a/common/bbu.c b/common/bbu.c
index 4d92d70ff9e3..26b997c02ed1 100644
--- a/common/bbu.c
+++ b/common/bbu.c
@@ -310,7 +310,7 @@ int bbu_mmcboot_handler(struct bbu_handler *handler, struct bbu_data *data,
 {
 	struct bbu_data _data = *data;
 	int ret;
-	char *devicefile = NULL, *bootpartvar = NULL;
+	char *devicefile = NULL, *bootpartvar = NULL, *bootackvar = NULL;
 	const char *bootpart;
 	const char *devname = devpath_to_name(data->devicefile);
 
@@ -346,10 +346,25 @@ int bbu_mmcboot_handler(struct bbu_handler *handler, struct bbu_data *data,
 	if (ret < 0)
 		goto out;
 
+	/*
+	 * This flag can be set in the chained handler or by
+	 * bbu_mmcboot_handler's caller
+	 */
+	if ((_data.flags | data->flags) & BBU_FLAG_MMC_BOOT_ACK) {
+		ret = asprintf(&bootackvar, "%s.boot_ack", devname);
+		if (ret < 0)
+			goto out;
+
+		ret = setenv(bootackvar, "1");
+		if (ret)
+			goto out;
+	}
+
 	/* on success switch boot source */
 	ret = setenv(bootpartvar, bootpart);
 
 out:
+	free(bootackvar);
 	free(devicefile);
 	free(bootpartvar);
 
diff --git a/include/bbu.h b/include/bbu.h
index bf5f2158df72..bd19fa187faf 100644
--- a/include/bbu.h
+++ b/include/bbu.h
@@ -10,6 +10,7 @@
 struct bbu_data {
 #define BBU_FLAG_FORCE	(1 << 0)
 #define BBU_FLAG_YES	(1 << 1)
+#define BBU_FLAG_MMC_BOOT_ACK	(1 << 2)
 	unsigned long flags;
 	int force;
 	const void *image;
-- 
2.30.2


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


  parent reply	other threads:[~2022-06-02  9:03 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-06-02  9:01 [PATCH 0/7] ARM: stm32mp: bbu: add FIP update handler Ahmad Fatoum
2022-06-02  9:01 ` [PATCH 1/7] bbu: move barebox_update eMMC boot handling into common code Ahmad Fatoum
2022-06-02  9:01 ` [PATCH 2/7] bbu: use free(NULL) to simplify function cleanup Ahmad Fatoum
2022-06-02  9:01 ` Ahmad Fatoum [this message]
2022-06-02  9:01 ` [PATCH 4/7] bbu: export bbu_std_file_handler for use in custom handlers Ahmad Fatoum
2022-06-02  9:01 ` [PATCH 5/7] filetype: differentiate between STM32MP FSBL and SSBL images Ahmad Fatoum
2022-06-02  9:01 ` [PATCH 6/7] ARM: stm32mp: bbu: add FIP update handler Ahmad Fatoum
2022-06-02  9:01 ` [PATCH 7/7] fastboot: support TF-A FSBL and FIP images for barebox update Ahmad Fatoum
2022-06-03  7:17 ` [PATCH 0/7] ARM: stm32mp: bbu: add FIP update handler Sascha Hauer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220602090133.3190450-4-a.fatoum@pengutronix.de \
    --to=a.fatoum@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox