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 2/2] ARM: stm32mp: lxa-mc1: add state description
Date: Thu,  4 Apr 2024 12:26:23 +0200	[thread overview]
Message-ID: <20240404102623.1008974-2-a.fatoum@pengutronix.de> (raw)
In-Reply-To: <20240404102623.1008974-1-a.fatoum@pengutronix.de>

The MC-1 can boot from either SD or eMMC. Detect this at runtime and
select the state that's stored on the boot medium.

Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
 arch/arm/boards/lxa-mc1/board.c      | 13 +++++++++++--
 arch/arm/dts/stm32mp157c-lxa-mc1.dts | 14 ++++++++++++++
 2 files changed, 25 insertions(+), 2 deletions(-)

diff --git a/arch/arm/boards/lxa-mc1/board.c b/arch/arm/boards/lxa-mc1/board.c
index b377d4323ecc..8be265b0fca0 100644
--- a/arch/arm/boards/lxa-mc1/board.c
+++ b/arch/arm/boards/lxa-mc1/board.c
@@ -31,6 +31,7 @@ static int of_fixup_regulator_supply_disable(struct device_node *root, void *pat
 
 static int mc1_probe(struct device *dev)
 {
+	struct device_node *state_node, *state_backend;
 	int flags;
 
 	flags = bootsource_get_instance() == 0 ? BBU_HANDLER_FLAG_DEFAULT : 0;
@@ -40,10 +41,18 @@ static int mc1_probe(struct device *dev)
 	stm32mp_bbu_mmc_register_handler("emmc", "/dev/mmc1.ssbl", flags);
 
 
-	if (bootsource_get_instance() == 0)
+	if (bootsource_get_instance() == 0) {
 		of_device_enable_path("/chosen/environment-sd");
-	else
+		state_backend = of_find_node_by_alias(NULL, "mmc0");
+	} else {
 		of_device_enable_path("/chosen/environment-emmc");
+		state_backend = of_find_node_by_alias(NULL, "mmc1");
+	}
+
+	state_node = of_find_node_by_alias(NULL, "state");
+	if (state_node)
+		of_property_write_u32(state_node, "backend",
+				      of_node_create_phandle(state_backend));
 
 	barebox_set_hostname("lxa-mc1");
 
diff --git a/arch/arm/dts/stm32mp157c-lxa-mc1.dts b/arch/arm/dts/stm32mp157c-lxa-mc1.dts
index 1220a77c1bb0..29852ee9aae0 100644
--- a/arch/arm/dts/stm32mp157c-lxa-mc1.dts
+++ b/arch/arm/dts/stm32mp157c-lxa-mc1.dts
@@ -7,6 +7,10 @@
 #include "stm32mp151.dtsi"
 
 / {
+	aliases {
+		state = &state;
+	};
+
 	chosen {
 		environment-sd {
 			compatible = "barebox,environment";
@@ -21,6 +25,16 @@ environment-emmc {
 		};
 	};
 
+	state: state {
+		compatible = "barebox,state";
+		magic = <0x778ec0f4>;
+		/* backend is fixed up by board code */
+		backend-type = "raw";
+		backend-storage-type = "direct";
+		backend-stridesize = <0x40>;
+
+		#include "bootstate.dtsi"
+	};
 };
 
 &panel {
-- 
2.39.2




  reply	other threads:[~2024-04-04 10:27 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-04 10:26 [PATCH 1/2] ARM: dts: add common bootstate.dtsi Ahmad Fatoum
2024-04-04 10:26 ` Ahmad Fatoum [this message]
2024-04-05 10:40 ` 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=20240404102623.1008974-2-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