mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Michael Tretter <m.tretter@pengutronix.de>
To: Sascha Hauer <s.hauer@pengutronix.de>,
	 BAREBOX <barebox@lists.infradead.org>
Cc: Michael Tretter <m.tretter@pengutronix.de>
Subject: [PATCH] ARM: rockchip: select bbu default target using bootsource
Date: Tue, 16 Sep 2025 10:04:18 +0200	[thread overview]
Message-ID: <20250916-rock5-bbu-default-target-v1-1-aba344fa5c50@pengutronix.de> (raw)

The ROCK 5 boards may be booted from SD card and eMMC. The BootROM
prefers the eMMC unless disabled explicitly.

As a user, I'd expect barebox_update to update the SD card if I booted a
board from SD card.

Use the bootsource to set the default target for the bbu default
handler. If booted from SD card, by default update barebox on the SD
card.

Signed-off-by: Michael Tretter <m.tretter@pengutronix.de>
---
 arch/arm/boards/radxa-rock5/board.c | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)

diff --git a/arch/arm/boards/radxa-rock5/board.c b/arch/arm/boards/radxa-rock5/board.c
index eab0c010400036f281beaa1c199cec8b8b841de2..1f145bb61f5f663e7a99e40b759e0a94768b4a8e 100644
--- a/arch/arm/boards/radxa-rock5/board.c
+++ b/arch/arm/boards/radxa-rock5/board.c
@@ -15,16 +15,21 @@ static int rock5_probe(struct device *dev)
 	enum bootsource bootsource = bootsource_get();
 	int instance = bootsource_get_instance();
 	const struct rock5_model *model;
+	int bbu_flags_emmc = 0;
+	int bbu_flags_sd = 0;
 
 	model = device_get_match_data(dev);
 
-	if (bootsource == BOOTSOURCE_MMC && instance == 1)
+	if (bootsource == BOOTSOURCE_MMC && instance == 1) {
 		of_device_enable_path("/chosen/environment-sd");
-	else
+		bbu_flags_sd |= BBU_HANDLER_FLAG_DEFAULT;
+	} else {
 		of_device_enable_path("/chosen/environment-emmc");
+		bbu_flags_emmc |= BBU_HANDLER_FLAG_DEFAULT;
+	}
 
-	rockchip_bbu_mmc_register("emmc", BBU_HANDLER_FLAG_DEFAULT, "/dev/mmc0");
-	rockchip_bbu_mmc_register("sd", 0, "/dev/mmc1");
+	rockchip_bbu_mmc_register("emmc", bbu_flags_emmc, "/dev/mmc0");
+	rockchip_bbu_mmc_register("sd", bbu_flags_sd, "/dev/mmc1");
 
 	return 0;
 }

---
base-commit: f3be3a8e9ae884bdfb116238e9049b1eb2759810
change-id: 20250916-rock5-bbu-default-target-454f31b85518

Best regards,
-- 
Michael Tretter <m.tretter@pengutronix.de>




             reply	other threads:[~2025-09-16  8:04 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-09-16  8:04 Michael Tretter [this message]
2025-09-18 14:20 ` 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=20250916-rock5-bbu-default-target-v1-1-aba344fa5c50@pengutronix.de \
    --to=m.tretter@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    --cc=s.hauer@pengutronix.de \
    /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