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.fat...@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