From: Andre Heider <a.heider@gmail.com>
To: u-boot@lists.denx.de
Subject: [PATCH v2] arm: mvebu: Espressobin: Set environment variable fdtfile
Date: Fri, 11 Sep 2020 06:35:10 +0200 [thread overview]
Message-ID: <20200911043510.488790-1-a.heider@gmail.com> (raw)
In-Reply-To: <20200905120744.634300-1-a.heider@gmail.com>
Required for the generic distro mechanism.
Linux ships with 4 variants:
marvell/armada-3720-espressobin-v7-emmc.dtb
marvell/armada-3720-espressobin-v7.dtb
marvell/armada-3720-espressobin-emmc.dtb
marvell/armada-3720-espressobin.dtb
Use available information to determine the appropriate filename.
Fixes booting GRUB EFI arm64 on Fedora.
Reported-by: Dennis Gilmore <dennis@ausil.us>
Signed-off-by: Andre Heider <a.heider@gmail.com>
---
v2:
- enable BOARD_LATE_INIT only for espressobin, via defconfig
- don't overwrite a set/saved $fdtfile
This still has the issue that $fdtfile doesn't show up after `env
default -a`. Pali may look into that, but the infrastructure for it
needs to be created first.
Until then, this can be considered as v2010.10 material as it fixes
booting distros relying on $fdtfile.
Tested myself on a v5 board without eMMC.
Tested by G?rald on v7 emmc, v7/ddr4 detection confirmed working.
board/Marvell/mvebu_armada-37xx/board.c | 47 +++++++++++++++++++++
configs/mvebu_espressobin-88f3720_defconfig | 1 +
2 files changed, 48 insertions(+)
diff --git a/board/Marvell/mvebu_armada-37xx/board.c b/board/Marvell/mvebu_armada-37xx/board.c
index 90bfc139aa..73d69e0388 100644
--- a/board/Marvell/mvebu_armada-37xx/board.c
+++ b/board/Marvell/mvebu_armada-37xx/board.c
@@ -5,6 +5,7 @@
#include <common.h>
#include <dm.h>
+#include <env.h>
#include <i2c.h>
#include <init.h>
#include <phy.h>
@@ -50,6 +51,22 @@ DECLARE_GLOBAL_DATA_PTR;
#define MVEBU_G2_SMI_PHY_CMD_REG (24)
#define MVEBU_G2_SMI_PHY_DATA_REG (25)
+/*
+ * Memory Controller Registers
+ *
+ * Assembled based on public information:
+ * https://gitlab.nic.cz/turris/mox-boot-builder/-/blob/master/wtmi/main.c#L332-336
+ * https://github.com/MarvellEmbeddedProcessors/mv-ddr-marvell/blob/mv_ddr-armada-18.12/drivers/mv_ddr_mc6.h#L309-L332
+ *
+ * And checked against the written register values for the various topologies:
+ * https://github.com/MarvellEmbeddedProcessors/mv-ddr-marvell/blob/mv_ddr-armada-atf-mainline/a3700/mv_ddr_tim.h
+ */
+#define A3700_CH0_MC_CTRL2_REG MVEBU_REGISTER(0x002c4)
+#define A3700_MC_CTRL2_SDRAM_TYPE_MASK 0xf
+#define A3700_MC_CTRL2_SDRAM_TYPE_OFFS 4
+#define A3700_MC_CTRL2_SDRAM_TYPE_DDR3 2
+#define A3700_MC_CTRL2_SDRAM_TYPE_DDR4 3
+
int board_early_init_f(void)
{
return 0;
@@ -63,6 +80,36 @@ int board_init(void)
return 0;
}
+#ifdef CONFIG_BOARD_LATE_INIT
+int board_late_init(void)
+{
+ bool ddr4, emmc;
+
+ if (env_get("fdtfile"))
+ return 0;
+
+ if (!of_machine_is_compatible("globalscale,espressobin"))
+ return 0;
+
+ /* 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;
+
+ emmc = of_machine_is_compatible("globalscale,espressobin-emmc");
+
+ if (ddr4 && emmc)
+ env_set("fdtfile", "marvell/armada-3720-espressobin-v7-emmc.dtb");
+ else if (ddr4)
+ env_set("fdtfile", "marvell/armada-3720-espressobin-v7.dtb");
+ else if (emmc)
+ env_set("fdtfile", "marvell/armada-3720-espressobin-emmc.dtb");
+ else
+ env_set("fdtfile", "marvell/armada-3720-espressobin.dtb");
+
+ return 0;
+}
+#endif
+
/* Board specific AHCI / SATA enable code */
int board_ahci_enable(void)
{
diff --git a/configs/mvebu_espressobin-88f3720_defconfig b/configs/mvebu_espressobin-88f3720_defconfig
index 5e9fcd1f26..559aeb076f 100644
--- a/configs/mvebu_espressobin-88f3720_defconfig
+++ b/configs/mvebu_espressobin-88f3720_defconfig
@@ -85,3 +85,4 @@ CONFIG_USB_ETHER_SMSC95XX=y
CONFIG_SHA1=y
CONFIG_SHA256=y
CONFIG_NET_RANDOM_ETHADDR=y
+CONFIG_BOARD_LATE_INIT=y
--
2.28.0
next prev parent reply other threads:[~2020-09-11 4:35 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-09-05 12:07 [PATCH] arm: mvebu: Espressobin: Set environment variable fdtfile Andre Heider
2020-09-06 9:32 ` Pali Rohár
2020-09-06 16:12 ` Marek Behun
2020-09-06 18:48 ` Andre Heider
2020-09-06 18:56 ` Marek Behun
2020-09-07 5:20 ` Andre Heider
2020-09-06 18:44 ` Andre Heider
2020-09-07 7:58 ` Pali Rohár
2020-09-07 8:46 ` Andre Heider
2020-09-07 8:52 ` Pali Rohár
2020-09-07 16:51 ` Andre Heider
2020-09-11 4:35 ` Andre Heider [this message]
2020-09-11 13:02 ` [PATCH v2] " Gérald Kerma
2020-09-24 10:38 ` Stefan Roese
2020-09-25 7:46 ` Pali Rohár
2020-09-26 9:09 ` Andre Heider
2020-10-02 10:49 ` Pali Rohár
2020-10-03 7:17 ` Andre Heider
2020-10-03 8:50 ` Pali Rohár
2020-10-05 16:20 ` Andre Heider
2020-10-06 11:02 ` Pali Rohár
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=20200911043510.488790-1-a.heider@gmail.com \
--to=a.heider@gmail.com \
--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