From: "Pali Rohár" <pali@kernel.org>
To: u-boot@lists.denx.de
Subject: [PATCH 2/3] arm: mvebu: Espressobin: Set default value for $fdtfile env variable
Date: Wed, 23 Dec 2020 12:21:29 +0100 [thread overview]
Message-ID: <20201223112130.31389-3-pali@kernel.org> (raw)
In-Reply-To: <20201223112130.31389-1-pali@kernel.org>
On Espressobin board value for $fdtfile cannot be determined at compile
time and is calculated at board runtime code. This change uses a new option
DEFAULT_ENV_IS_RW to allow modifying default_environment[] array at runtime
and set into it correct value.
This change also ensure that 'env default -a' set correct value to $fdtfile.
Signed-off-by: Pali Roh?r <pali@kernel.org>
---
board/Marvell/mvebu_armada-37xx/board.c | 22 +++++++++++++++-------
include/configs/mvebu_armada-37xx.h | 13 ++++++++++++-
2 files changed, 27 insertions(+), 8 deletions(-)
diff --git a/board/Marvell/mvebu_armada-37xx/board.c b/board/Marvell/mvebu_armada-37xx/board.c
index f67b04b78c..9297ea0f90 100644
--- a/board/Marvell/mvebu_armada-37xx/board.c
+++ b/board/Marvell/mvebu_armada-37xx/board.c
@@ -6,6 +6,7 @@
#include <common.h>
#include <dm.h>
#include <env.h>
+#include <env_internal.h>
#include <i2c.h>
#include <init.h>
#include <mmc.h>
@@ -84,15 +85,17 @@ int board_init(void)
#ifdef CONFIG_BOARD_LATE_INIT
int board_late_init(void)
{
+ char *ptr = (char *)&default_environment[0];
struct mmc *mmc_dev;
bool ddr4, emmc;
- if (env_get("fdtfile"))
- return 0;
-
if (!of_machine_is_compatible("globalscale,espressobin"))
return 0;
+ /* Find free buffer in default_environment[] for new variables */
+ while (*ptr != '\0' && *(ptr+1) != '\0') ptr++;
+ ptr += 2;
+
/* If the memory controller has been configured for DDR4, we're running on v7 */
ddr4 = ((readl(A3700_CH0_MC_CTRL2_REG) >> A3700_MC_CTRL2_SDRAM_TYPE_OFFS)
& A3700_MC_CTRL2_SDRAM_TYPE_MASK) == A3700_MC_CTRL2_SDRAM_TYPE_DDR4;
@@ -101,14 +104,19 @@ int board_late_init(void)
mmc_dev = find_mmc_device(1);
emmc = (mmc_dev && mmc_init(mmc_dev) == 0);
+ /* Ensure that 'env default -a' set correct value to $fdtfile */
if (ddr4 && emmc)
- env_set("fdtfile", "marvell/armada-3720-espressobin-v7-emmc.dtb");
+ strcpy(ptr, "fdtfile=marvell/armada-3720-espressobin-v7-emmc.dtb");
else if (ddr4)
- env_set("fdtfile", "marvell/armada-3720-espressobin-v7.dtb");
+ strcpy(ptr, "fdtfile=marvell/armada-3720-espressobin-v7.dtb");
else if (emmc)
- env_set("fdtfile", "marvell/armada-3720-espressobin-emmc.dtb");
+ strcpy(ptr, "fdtfile=marvell/armada-3720-espressobin-emmc.dtb");
else
- env_set("fdtfile", "marvell/armada-3720-espressobin.dtb");
+ strcpy(ptr, "fdtfile=marvell/armada-3720-espressobin.dtb");
+
+ /* If $fdtfile was not set explicitly by user then set default value */
+ if (!env_get("fdtfile"))
+ env_set("fdtfile", ptr + sizeof("fdtfile="));
return 0;
}
diff --git a/include/configs/mvebu_armada-37xx.h b/include/configs/mvebu_armada-37xx.h
index 0d585606a7..6df702367c 100644
--- a/include/configs/mvebu_armada-37xx.h
+++ b/include/configs/mvebu_armada-37xx.h
@@ -57,6 +57,11 @@
*/
#define CONFIG_MTD_PARTITIONS /* required for UBI partition support */
+/*
+ * Environment
+ */
+#define DEFAULT_ENV_IS_RW /* required for configuring default fdtfile= */
+
/*
* Ethernet Driver configuration
*/
@@ -87,6 +92,11 @@
#include <config_distro_bootcmd.h>
+/* filler for default values filled by board_early_init_f() */
+#define ENV_RW_FILLER \
+ "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" /* for fdtfile= */ \
+ ""
+
/* fdt_addr and kernel_addr are needed for existing distribution boot scripts */
#define CONFIG_EXTRA_ENV_SETTINGS \
"scriptaddr=0x6d00000\0" \
@@ -96,6 +106,7 @@
"kernel_addr=0x7000000\0" \
"kernel_addr_r=0x7000000\0" \
"ramdisk_addr_r=0xa000000\0" \
- BOOTENV
+ BOOTENV \
+ ENV_RW_FILLER
#endif /* _CONFIG_MVEBU_ARMADA_37XX_H */
--
2.20.1
next prev parent reply other threads:[~2020-12-23 11:21 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-12-23 11:21 [PATCH 0/3] arm: mvebu: Espressobin: Set default env values at runtime Pali Rohár
2020-12-23 11:21 ` [PATCH 1/3] env: Allow to set default_environment[] from board code via compile option DEFAULT_ENV_IS_RW Pali Rohár
2020-12-23 11:21 ` Pali Rohár [this message]
2020-12-23 11:21 ` [PATCH 3/3] arm: mvebu: Espressobin: Set default value for $ethNaddr env variable Pali Rohár
2021-01-11 10:51 ` [PATCH 0/3] arm: mvebu: Espressobin: Set default env values at runtime Pali Rohár
2021-01-12 8:18 ` Andre Heider
2021-01-12 8:42 ` Andre Heider
2021-01-12 9:24 ` Pali Rohár
2021-02-02 15:09 ` Stefan Roese
2021-02-02 15:19 ` Pali Rohár
2021-02-02 16:13 ` Andre Heider
2021-02-02 16:32 ` Stefan Roese
2021-02-02 17:24 ` Andre Heider
2021-02-01 15:24 ` Pali Rohár
2021-02-08 11:33 ` Stefan Roese
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=20201223112130.31389-3-pali@kernel.org \
--to=pali@kernel.org \
--cc=u-boot@lists.denx.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