stm32mp1: display board information
[oweals/u-boot.git] / cmd / mvebu / bubt.c
index 1e1f0af35cc0b86c7f55836bcb3368c15d1a46e2..b4d371f3056ffe9b4cf8b628df41b6d5a1e98852 100644 (file)
@@ -1,7 +1,6 @@
+// SPDX-License-Identifier: GPL-2.0
 /*
  * Copyright (C) 2016 Marvell International Ltd.
- *
- * SPDX-License-Identifier:    GPL-2.0
  * https://spdx.org/licenses
  */
 
@@ -98,7 +97,7 @@ static ulong get_load_addr(void)
        const char *addr_str;
        unsigned long addr;
 
-       addr_str = getenv("loadaddr");
+       addr_str = env_get("loadaddr");
        if (addr_str)
                addr = simple_strtoul(addr_str, NULL, 16);
        else
@@ -110,7 +109,7 @@ static ulong get_load_addr(void)
 /********************************************************************
  *     eMMC services
  ********************************************************************/
-#ifdef CONFIG_DM_MMC
+#if CONFIG_IS_ENABLED(DM_MMC) && CONFIG_IS_ENABLED(MMC_WRITE)
 static int mmc_burn_image(size_t image_size)
 {
        struct mmc      *mmc;
@@ -311,23 +310,21 @@ static int nand_burn_image(size_t image_size)
 {
        int ret;
        uint32_t block_size;
-       struct mtd_info *nand;
-       int dev = nand_curr_device;
+       struct mtd_info *mtd;
 
-       if ((dev < 0) || (dev >= CONFIG_SYS_MAX_NAND_DEVICE) ||
-           (!nand_info[dev]->name)) {
+       mtd = get_nand_dev_by_index(nand_curr_device);
+       if (!mtd) {
                puts("\nno devices available\n");
                return -ENOMEDIUM;
        }
-       nand = nand_info[dev];
-       block_size = nand->erasesize;
+       block_size = mtd->erasesize;
 
        /* Align U-Boot size to currently used blocksize */
        image_size = ((image_size + (block_size - 1)) & (~(block_size - 1)));
 
        /* Erase the U-BOOT image space */
        printf("Erasing 0x%x - 0x%x:...", 0, (int)image_size);
-       ret = nand_erase(nand, 0, image_size);
+       ret = nand_erase(mtd, 0, image_size);
        if (ret) {
                printf("Error!\n");
                goto error;
@@ -337,7 +334,7 @@ static int nand_burn_image(size_t image_size)
        /* Write the image to flash */
        printf("Writing %d bytes from 0x%lx to offset 0 ... ",
               (int)image_size, get_load_addr());
-       ret = nand_write(nand, 0, &image_size, (void *)get_load_addr());
+       ret = nand_write(mtd, 0, &image_size, (void *)get_load_addr());
        if (ret)
                printf("Error!\n");
        else