All of lore.kernel.org
 help / color / mirror / Atom feed
From: peng.fan at nxp.com <peng.fan@nxp.com>
To: u-boot@lists.denx.de
Subject: [PATCH 08/11] imx8mn/imx8mp: override env_get_offset and env_get_location
Date: Thu,  9 Jul 2020 16:40:39 +0800	[thread overview]
Message-ID: <20200709084042.8234-9-peng.fan@nxp.com> (raw)
In-Reply-To: <20200709084042.8234-1-peng.fan@nxp.com>

From: Ye Li <ye.li@nxp.com>

To use one defconfig for all boot device, we have to runtime set
env offset and return env medium according to the boot device.
This patch overrides the env_get_offset and env_get_location to
implement the feature.

Signed-off-by: Ye Li <ye.li@nxp.com>
Signed-off-by: Peng Fan <peng.fan@nxp.com>
---
 arch/arm/mach-imx/imx8m/soc.c | 59 +++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 59 insertions(+)

diff --git a/arch/arm/mach-imx/imx8m/soc.c b/arch/arm/mach-imx/imx8m/soc.c
index f74a343ed8..9517a7cfcf 100644
--- a/arch/arm/mach-imx/imx8m/soc.c
+++ b/arch/arm/mach-imx/imx8m/soc.c
@@ -20,6 +20,8 @@
 #include <asm/armv8/mmu.h>
 #include <dm/uclass.h>
 #include <efi_loader.h>
+#include <env.h>
+#include <env_internal.h>
 #include <errno.h>
 #include <fdt_support.h>
 #include <fsl_wdog.h>
@@ -616,3 +618,60 @@ void do_error(struct pt_regs *pt_regs, unsigned int esr)
 }
 #endif
 #endif
+
+#if defined(CONFIG_IMX8MN) || defined(CONFIG_IMX8MP)
+enum env_location env_get_location(enum env_operation op, int prio)
+{
+	enum boot_device dev = get_boot_device();
+	enum env_location env_loc = ENVL_UNKNOWN;
+
+	if (prio)
+		return env_loc;
+
+	switch (dev) {
+#ifdef CONFIG_ENV_IS_IN_SPI_FLASH
+	case QSPI_BOOT:
+		env_loc = ENVL_SPI_FLASH;
+		break;
+#endif
+#ifdef CONFIG_ENV_IS_IN_NAND
+	case NAND_BOOT:
+		env_loc = ENVL_NAND;
+		break;
+#endif
+#ifdef CONFIG_ENV_IS_IN_MMC
+	case SD1_BOOT:
+	case SD2_BOOT:
+	case SD3_BOOT:
+	case MMC1_BOOT:
+	case MMC2_BOOT:
+	case MMC3_BOOT:
+		env_loc =  ENVL_MMC;
+		break;
+#endif
+	default:
+#if defined(CONFIG_ENV_IS_NOWHERE)
+		env_loc = ENVL_NOWHERE;
+#endif
+		break;
+	}
+
+	return env_loc;
+}
+
+#ifndef ENV_IS_EMBEDDED
+long long env_get_offset(long long defautl_offset)
+{
+	enum boot_device dev = get_boot_device();
+
+	switch (dev) {
+	case NAND_BOOT:
+		return (60 << 20);  /* 60MB offset for NAND */
+	default:
+		break;
+	}
+
+	return defautl_offset;
+}
+#endif
+#endif
-- 
2.16.4

  parent reply	other threads:[~2020-07-09  8:40 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-09  8:40 [PATCH 00/11] imx8m: soc/clk update peng.fan at nxp.com
2020-07-09  8:40 ` [PATCH 01/11] imx8m: configure arm clk sources from PLL peng.fan at nxp.com
2020-07-09  8:40 ` [PATCH 02/11] imx8m: configure NoC clk peng.fan at nxp.com
2020-07-09  8:40 ` [PATCH 03/11] imx8m: add sdhc/nand/ecspi clk api peng.fan at nxp.com
2020-07-09  8:40 ` [PATCH 04/11] imx8m: add eqos clk peng.fan at nxp.com
2020-07-09  8:40 ` [PATCH 05/11] imx8m: workaround ROM serror peng.fan at nxp.com
2020-07-09  8:40 ` [PATCH 06/11] imx8mp: Add fused parts support peng.fan at nxp.com
2020-07-09  8:40 ` [PATCH 07/11] imx8m: power down fused cores peng.fan at nxp.com
2020-07-09  8:40 ` peng.fan at nxp.com [this message]
2020-07-09  8:40 ` [PATCH 09/11] imx8m: disable nodes before kernel/mfgtool boot for fused part peng.fan at nxp.com
2020-07-09  8:40 ` [PATCH 10/11] clk: imx8m: drop clk settings peng.fan at nxp.com
2020-07-09  8:40 ` [PATCH 11/11] imx8m: Refactor the OPTEE memory removal peng.fan at nxp.com

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=20200709084042.8234-9-peng.fan@nxp.com \
    --to=peng.fan@nxp.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.