mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH 1/2] ARM: dts: add common bootstate.dtsi
@ 2024-04-04 10:26 Ahmad Fatoum
  2024-04-04 10:26 ` [PATCH 2/2] ARM: stm32mp: lxa-mc1: add state description Ahmad Fatoum
  2024-04-05 10:40 ` [PATCH 1/2] ARM: dts: add common bootstate.dtsi Sascha Hauer
  0 siblings, 2 replies; 3+ messages in thread
From: Ahmad Fatoum @ 2024-04-04 10:26 UTC (permalink / raw)
  To: barebox; +Cc: Ahmad Fatoum

For use by at least the LXA MC-1, add a bootstate definition with the
minimal set of variables needed for bootchooser.

We add this to a generic location, so it may be used by other boards as
well.

Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
 arch/arm/dts/bootstate.dtsi | 45 +++++++++++++++++++++++++++++++++++++
 1 file changed, 45 insertions(+)
 create mode 100644 arch/arm/dts/bootstate.dtsi

diff --git a/arch/arm/dts/bootstate.dtsi b/arch/arm/dts/bootstate.dtsi
new file mode 100644
index 000000000000..aa767d4e3b96
--- /dev/null
+++ b/arch/arm/dts/bootstate.dtsi
@@ -0,0 +1,45 @@
+// SPDX-License-Identifier: (GPL-2.0+ OR BSD-3-Clause)
+
+bootstate {
+	#address-cells = <1>;
+	#size-cells = <1>;
+
+	system0 {
+		#address-cells = <1>;
+		#size-cells = <1>;
+
+		remaining_attempts@0 {
+			reg = <0x0 0x4>;
+			type = "uint32";
+			default = <3>;
+		};
+
+		priority@4 {
+			reg = <0x4 0x4>;
+			type = "uint32";
+			default = <20>;
+		};
+	};
+
+	system1 {
+		#address-cells = <1>;
+		#size-cells = <1>;
+
+		remaining_attempts@8 {
+			reg = <0x8 0x4>;
+			type = "uint32";
+			default = <3>;
+		};
+
+		priority@c {
+			reg = <0xc 0x4>;
+			type = "uint32";
+			default = <10>;
+		};
+	};
+
+	last_chosen@10 {
+		reg = <0x10 0x4>;
+		type = "uint32";
+	};
+};
-- 
2.39.2




^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH 2/2] ARM: stm32mp: lxa-mc1: add state description
  2024-04-04 10:26 [PATCH 1/2] ARM: dts: add common bootstate.dtsi Ahmad Fatoum
@ 2024-04-04 10:26 ` Ahmad Fatoum
  2024-04-05 10:40 ` [PATCH 1/2] ARM: dts: add common bootstate.dtsi Sascha Hauer
  1 sibling, 0 replies; 3+ messages in thread
From: Ahmad Fatoum @ 2024-04-04 10:26 UTC (permalink / raw)
  To: barebox; +Cc: Ahmad Fatoum

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




^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH 1/2] ARM: dts: add common bootstate.dtsi
  2024-04-04 10:26 [PATCH 1/2] ARM: dts: add common bootstate.dtsi Ahmad Fatoum
  2024-04-04 10:26 ` [PATCH 2/2] ARM: stm32mp: lxa-mc1: add state description Ahmad Fatoum
@ 2024-04-05 10:40 ` Sascha Hauer
  1 sibling, 0 replies; 3+ messages in thread
From: Sascha Hauer @ 2024-04-05 10:40 UTC (permalink / raw)
  To: barebox, Ahmad Fatoum


On Thu, 04 Apr 2024 12:26:22 +0200, Ahmad Fatoum wrote:
> For use by at least the LXA MC-1, add a bootstate definition with the
> minimal set of variables needed for bootchooser.
> 
> We add this to a generic location, so it may be used by other boards as
> well.
> 
> 
> [...]

Applied, thanks!

[1/2] ARM: dts: add common bootstate.dtsi
      https://git.pengutronix.de/cgit/barebox/commit/?id=1e778c610dd4 (link may not be stable)
[2/2] ARM: stm32mp: lxa-mc1: add state description
      https://git.pengutronix.de/cgit/barebox/commit/?id=9dd40f0d077d (link may not be stable)

Best regards,
-- 
Sascha Hauer <s.hauer@pengutronix.de>




^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2024-04-05 10:41 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-04-04 10:26 [PATCH 1/2] ARM: dts: add common bootstate.dtsi Ahmad Fatoum
2024-04-04 10:26 ` [PATCH 2/2] ARM: stm32mp: lxa-mc1: add state description Ahmad Fatoum
2024-04-05 10:40 ` [PATCH 1/2] ARM: dts: add common bootstate.dtsi Sascha Hauer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox