xref: /openbmc/u-boot/arch/arm/mach-imx/mmc_env.c (revision cf0bcd7d)
1 /*
2  * Copyright (C) 2017 NXP
3  *
4  * SPDX-License-Identifier:	GPL-2.0+
5  */
6 
7 #include <common.h>
8 #include <asm/arch/imx-regs.h>
9 #include <asm/arch/sys_proto.h>
10 #include <asm/io.h>
11 #include <asm/mach-imx/boot_mode.h>
12 
13 __weak int board_mmc_get_env_dev(int devno)
14 {
15 	return CONFIG_SYS_MMC_ENV_DEV;
16 }
17 
18 int mmc_get_env_dev(void)
19 {
20 	struct bootrom_sw_info **p =
21 		(struct bootrom_sw_info **)(ulong)ROM_SW_INFO_ADDR;
22 	int devno = (*p)->boot_dev_instance;
23 	u8 boot_type = (*p)->boot_dev_type;
24 
25 	/* If not boot from sd/mmc, use default value */
26 	if ((boot_type != BOOT_TYPE_SD) && (boot_type != BOOT_TYPE_MMC))
27 		return CONFIG_SYS_MMC_ENV_DEV;
28 
29 	return board_mmc_get_env_dev(devno);
30 }
31