diff options
author | Tom Rini <trini@konsulko.com> | 2022-04-13 08:00:11 -0400 |
---|---|---|
committer | Tom Rini <trini@konsulko.com> | 2022-04-13 08:00:11 -0400 |
commit | 2ddf84679df65ba156782ceb75b44696f2cbb3e6 (patch) | |
tree | 7a736235da332086c458da9c20bd88cb1ce45a8e /board/freescale/common/mmc.c | |
parent | b2a22b2c9f07e4c78108feb3bc16e18ebd88388a (diff) | |
parent | a1c711046b0d5478a702b27c6773ea6231eba057 (diff) |
Merge tag 'u-boot-imx-20220413' of https://gitlab.denx.de/u-boot/custodians/u-boot-imx
u-boot-imx-20220413
i.MX patches for 2022.07
CI: https://source.denx.de/u-boot/custodians/u-boot-imx/-/pipelines/11710
Diffstat (limited to 'board/freescale/common/mmc.c')
-rw-r--r-- | board/freescale/common/mmc.c | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/board/freescale/common/mmc.c b/board/freescale/common/mmc.c new file mode 100644 index 00000000000..8cd5079f962 --- /dev/null +++ b/board/freescale/common/mmc.c @@ -0,0 +1,49 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Copyright 2016 Freescale Semiconductor, Inc. + * Copyright 2018-2022 NXP + */ + +#include <common.h> +#include <command.h> +#include <asm/arch/sys_proto.h> +#include <linux/errno.h> +#include <asm/io.h> +#include <stdbool.h> +#include <mmc.h> +#include <env.h> + +static int check_mmc_autodetect(void) +{ + char *autodetect_str = env_get("mmcautodetect"); + + if (autodetect_str && !strcmp(autodetect_str, "yes")) + 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; + + env_set_ulong("mmcdev", dev_no); + + /* Set mmcblk env */ + sprintf(mmcblk, "/dev/mmcblk%dp2 rootwait rw", mmc_map_to_kernel_blk(dev_no)); + env_set("mmcroot", mmcblk); + + sprintf(cmd, "mmc dev %d", dev_no); + run_command(cmd, 0); +} |