blob: addb50f5382aa31b968ba3285eed1d385de61a99 [file] [log] [blame]
Tom Rini10e47792018-05-06 17:58:06 -04001// SPDX-License-Identifier: GPL-2.0+
Peng Fanc131a382018-01-10 13:20:36 +08002/*
3 * Copyright (C) 2017 NXP
Peng Fanc131a382018-01-10 13:20:36 +08004 */
5
6#include <common.h>
7#include <asm/arch/imx-regs.h>
8#include <asm/arch/sys_proto.h>
9#include <asm/io.h>
10#include <asm/mach-imx/boot_mode.h>
11
12__weak int board_mmc_get_env_dev(int devno)
13{
Peng Fan50f69802019-08-27 06:25:54 +000014 if (CONFIG_IS_ENABLED(DM_MMC))
15 return devno;
16
Peng Fanc131a382018-01-10 13:20:36 +080017 return CONFIG_SYS_MMC_ENV_DEV;
18}
19
20int mmc_get_env_dev(void)
21{
22 struct bootrom_sw_info **p =
23 (struct bootrom_sw_info **)(ulong)ROM_SW_INFO_ADDR;
24 int devno = (*p)->boot_dev_instance;
25 u8 boot_type = (*p)->boot_dev_type;
26
27 /* If not boot from sd/mmc, use default value */
28 if ((boot_type != BOOT_TYPE_SD) && (boot_type != BOOT_TYPE_MMC))
29 return CONFIG_SYS_MMC_ENV_DEV;
30
31 return board_mmc_get_env_dev(devno);
32}