toradex: configblock: initialize MMC before switching partition
authorStefan Agner <stefan.agner@toradex.com>
Fri, 12 Jul 2019 10:35:05 +0000 (12:35 +0200)
committerStefano Babic <sbabic@denx.de>
Fri, 19 Jul 2019 18:32:24 +0000 (20:32 +0200)
If the module is in serial downloader mode, we do no longer read the
environment from eMMC. Therefor, the eMMC is unitialized when trying
to read the config block. Use mmc_init to initialize the selected
MMC device before using it.

Note: In case the MMC has already been initialized, the mmc_init
detects that and returns immediately.

Signed-off-by: Stefan Agner <stefan.agner@toradex.com>
Acked-by: Max Krummenacher <max.krummenacher@toradex.com>
Signed-off-by: Marcel Ziswiler <marcel.ziswiler@toradex.com>
Reviewed-by: Igor Opaniuk <igor.opaniuk@toradex.com>
Reviewed-by: Oleksandr Suvorov <oleksandr.suvorov@toradex.com>
board/toradex/common/tdx-cfg-block.c

index f69c4433b24376398724e155cf38e3677e278888..67e0557f678143d85422c467000f23fd5c3742ce 100644 (file)
@@ -129,6 +129,10 @@ static int tdx_cfg_block_mmc_storage(u8 *config_block, int write)
                ret = -ENODEV;
                goto out;
        }
+       if (mmc_init(mmc)) {
+               puts("MMC init failed\n");
+               return -EINVAL;
+       }
        if (part != mmc_get_blk_desc(mmc)->hwpart) {
                if (blk_select_hwpart_devnum(IF_TYPE_MMC, dev, part)) {
                        puts("MMC partition switch failed\n");