public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Frieder Schrempf <frieder@fris.de>
To: Frieder Schrempf <frieder.schrempf@kontron.de>, u-boot@lists.denx.de
Cc: Fabio Estevam <festevam@denx.de>,
	Jaehoon Chung <jh80.chung@samsung.com>,
	Simon Glass <sjg@chromium.org>, Stefano Babic <sbabic@denx.de>,
	Sughosh Ganu <sughosh.ganu@linaro.org>
Subject: [PATCH 03/14] imx: kontron-sl-mx8mm: Enable environment in MMC
Date: Wed, 13 Jul 2022 11:52:14 +0200	[thread overview]
Message-ID: <20220713095229.43274-4-frieder@fris.de> (raw)
In-Reply-To: <20220713095229.43274-1-frieder@fris.de>

From: Frieder Schrempf <frieder.schrempf@kontron.de>

In case we boot from SD card or eMMC, we also want to load
the environment from the according boot device.

Signed-off-by: Frieder Schrempf <frieder.schrempf@kontron.de>
---
 board/kontron/sl-mx8mm/sl-mx8mm.c  | 31 ++++++++++++++++++++++++++++++
 configs/kontron-sl-mx8mm_defconfig |  1 +
 2 files changed, 32 insertions(+)

diff --git a/board/kontron/sl-mx8mm/sl-mx8mm.c b/board/kontron/sl-mx8mm/sl-mx8mm.c
index fea93278374..416c4cbb407 100644
--- a/board/kontron/sl-mx8mm/sl-mx8mm.c
+++ b/board/kontron/sl-mx8mm/sl-mx8mm.c
@@ -4,10 +4,13 @@
  */
 
 #include <asm/arch/imx-regs.h>
+#include <asm/arch/sys_proto.h>
 #include <asm/global_data.h>
 #include <asm/io.h>
+#include <asm/mach-imx/boot_mode.h>
 #include <efi.h>
 #include <efi_loader.h>
+#include <env_internal.h>
 #include <fdt_support.h>
 #include <linux/errno.h>
 #include <linux/kernel.h>
@@ -117,3 +120,31 @@ int board_init(void)
 {
 	return 0;
 }
+
+enum env_location env_get_location(enum env_operation op, int prio)
+{
+	enum boot_device boot_dev = get_boot_device();
+
+	if (prio)
+		return ENVL_UNKNOWN;
+
+	/*
+	 * Make sure that the environment is loaded from
+	 * the MMC if we are running from SD card or eMMC.
+	 */
+	if (CONFIG_IS_ENABLED(ENV_IS_IN_MMC) &&
+	    (boot_dev == SD1_BOOT || boot_dev == SD2_BOOT))
+		return ENVL_MMC;
+
+	if (CONFIG_IS_ENABLED(ENV_IS_IN_SPI_FLASH))
+		return ENVL_SPI_FLASH;
+
+	return ENVL_NOWHERE;
+}
+
+#if defined(CONFIG_ENV_IS_IN_MMC)
+int board_mmc_get_env_dev(int devno)
+{
+	return devno;
+}
+#endif
diff --git a/configs/kontron-sl-mx8mm_defconfig b/configs/kontron-sl-mx8mm_defconfig
index 064f7d0caf6..e6b5c8f800a 100644
--- a/configs/kontron-sl-mx8mm_defconfig
+++ b/configs/kontron-sl-mx8mm_defconfig
@@ -69,6 +69,7 @@ CONFIG_CMD_EXT4_WRITE=y
 CONFIG_MTDPARTS_DEFAULT="mtdparts=spi0.0:320k(spl),1024k(u-boot),64k(env),64k(env_redundant)"
 CONFIG_OF_CONTROL=y
 CONFIG_SPL_OF_CONTROL=y
+CONFIG_ENV_IS_IN_MMC=y
 CONFIG_ENV_IS_IN_SPI_FLASH=y
 CONFIG_SYS_REDUNDAND_ENVIRONMENT=y
 CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG=y
-- 
2.37.0


  parent reply	other threads:[~2022-07-13  9:53 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-07-13  9:52 [PATCH 00/14] imx: kontron-sl-mx8mm: Improvements and OSM board support Frieder Schrempf
2022-07-13  9:52 ` [PATCH 01/14] imx: kontron-sl-mx8mm: Remove LVDS board type and devicetrees Frieder Schrempf
2022-07-13  9:52 ` [PATCH 02/14] imx: kontron-sl-mx8mm: Add redundant environment Frieder Schrempf
2022-07-13  9:52 ` Frieder Schrempf [this message]
2022-07-13  9:52 ` [PATCH 04/14] imx: kontron-sl-mx8mm: Migrate to use CONFIG_EXTRA_ENV_TEXT Frieder Schrempf
2022-07-13  9:52 ` [PATCH 05/14] imx: kontron-sl-mx8mm: Enable bootaux command Frieder Schrempf
2022-07-13  9:52 ` [PATCH 06/14] imx: kontron-sl-mx8mm: lpddr4_timing.c: Add spaces for proper alignment Frieder Schrempf
2022-07-13  9:52 ` [PATCH 07/14] imx: kontron-sl-mx8mm: Remove 100mt DDR setpoint Frieder Schrempf
2022-07-13  9:52 ` [PATCH 08/14] imx: kontron-sl-mx8mm: Use new LPDDR4 config parameters Frieder Schrempf
2022-07-13  9:52 ` [PATCH 09/14] imx: kontron-sl-mx8mm: Prepare for other i.MX8MM SoM types Frieder Schrempf
2022-07-13  9:52 ` [PATCH 10/14] imx: kontron-sl-mx8mm: Adjust board and SoM model strings Frieder Schrempf
2022-07-13  9:52 ` [PATCH 11/14] imx: kontron-sl-mx8mm: Use the VSELECT signal to switch SD card IO voltage Frieder Schrempf
2022-07-14 15:23   ` Heiko Thiery
2022-07-13  9:52 ` [PATCH 12/14] imx: kontron-sl-mx8mm: Use voltage rail names from schematic for PMIC regulator-names Frieder Schrempf
2022-07-13  9:52 ` [PATCH 13/14] imx: kontron-sl-mx8mm: Simplify code in spl.c Frieder Schrempf
2022-07-13  9:52 ` [PATCH 14/14] imx: kontron-sl-mx8mm: Add support for Kontron Electronics SoM SL i.MX8MM OSM-S Frieder Schrempf
2022-07-25 13:03 ` [PATCH 00/14] imx: kontron-sl-mx8mm: Improvements and OSM board support Stefano Babic
2022-08-01 10:31   ` Frieder Schrempf
2022-08-01 11:23     ` Stefano Babic

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=20220713095229.43274-4-frieder@fris.de \
    --to=frieder@fris.de \
    --cc=festevam@denx.de \
    --cc=frieder.schrempf@kontron.de \
    --cc=jh80.chung@samsung.com \
    --cc=sbabic@denx.de \
    --cc=sjg@chromium.org \
    --cc=sughosh.ganu@linaro.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