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