summaryrefslogtreecommitdiff
path: root/board
diff options
context:
space:
mode:
authorPeng Fan <peng.fan@nxp.com>2016-02-23 12:43:10 +0800
committerYe Li <ye.li@nxp.com>2017-04-05 14:04:28 +0800
commit6f6a828fbe7478efd5932c302e6368877107bbca (patch)
tree62db1aeff7df25eca9b47c65bedd2317ca9ccb8f /board
parent71dbb9dadd51c35dd558c900ca18ef70117a424f (diff)
downloadu-boot-imx-6f6a828fbe7478efd5932c302e6368877107bbca.zip
u-boot-imx-6f6a828fbe7478efd5932c302e6368877107bbca.tar.gz
u-boot-imx-6f6a828fbe7478efd5932c302e6368877107bbca.tar.bz2
MLK-12434-1: imx: dynamic setting mmcdev and mmcroot
Align to imx_v2015.04, dynamic setting mmcdev and mmcroot. Then when boot linux, we can have correct "root=/dev/mmcblk[x]p2" Signed-off-by: Peng Fan <peng.fan@nxp.com> (cherry picked from commit b46b99a901eb194e81fc4836ee2259ad8857f4d3)
Diffstat (limited to 'board')
-rw-r--r--board/freescale/common/Makefile1
-rw-r--r--board/freescale/common/mmc.c48
2 files changed, 49 insertions, 0 deletions
diff --git a/board/freescale/common/Makefile b/board/freescale/common/Makefile
index 7df6af2..d844831 100644
--- a/board/freescale/common/Makefile
+++ b/board/freescale/common/Makefile
@@ -64,6 +64,7 @@ obj-$(CONFIG_POWER_PFUZE100) += pfuze.o
obj-$(CONFIG_POWER_MC34VR500) += mc34vr500.o
obj-$(CONFIG_DM_PMIC_PFUZE100) += pfuze_dm.o
obj-$(CONFIG_MXC_EPDC) += epdc_setup.o
+obj-y += mmc.o
obj-$(CONFIG_LS102XA_STREAM_ID) += ls102xa_stream_id.o
diff --git a/board/freescale/common/mmc.c b/board/freescale/common/mmc.c
new file mode 100644
index 0000000..20eaab6
--- /dev/null
+++ b/board/freescale/common/mmc.c
@@ -0,0 +1,48 @@
+/*
+ * Copyright (C) 2016 Freescale Semiconductor, Inc.
+ *
+ * SPDX-License-Identifier: GPL-2.0+
+ */
+#include <common.h>
+#include <asm/arch/sys_proto.h>
+#include <linux/errno.h>
+#include <asm/io.h>
+#include <stdbool.h>
+
+static int check_mmc_autodetect(void)
+{
+ char *autodetect_str = getenv("mmcautodetect");
+
+ if ((autodetect_str != NULL) &&
+ (strcmp(autodetect_str, "yes") == 0)) {
+ return 1;
+ }
+
+ return 0;
+}
+
+/* This should be defined for each board */
+__weak int mmc_map_to_kernel_blk(int dev_no)
+{
+ return dev_no;
+}
+
+void board_late_mmc_env_init(void)
+{
+ char cmd[32];
+ char mmcblk[32];
+ u32 dev_no = mmc_get_env_dev();
+
+ if (!check_mmc_autodetect())
+ return;
+
+ setenv_ulong("mmcdev", dev_no);
+
+ /* Set mmcblk env */
+ sprintf(mmcblk, "/dev/mmcblk%dp2 rootwait rw",
+ mmc_map_to_kernel_blk(dev_no));
+ setenv("mmcroot", mmcblk);
+
+ sprintf(cmd, "mmc dev %d", dev_no);
+ run_command(cmd, 0);
+}