board: samsung: exynos5-dt: modify the get_dfu_alt_system information
authorJaehoon Chung <jh80.chung@samsung.com>
Mon, 1 Oct 2018 04:00:43 +0000 (13:00 +0900)
committerJaehoon Chung <jh80.chung@samsung.com>
Tue, 20 Oct 2020 06:13:47 +0000 (15:13 +0900)
If there is a partition7, set to dfu_alt_system_2.
Otherwise, just use the dfu_alt_system.
(It's relevant to thor download.)

- change from getenv() to env_get().

Change-Id: I1ff7b5a6c97ad7eed2b6cd489260cfdc902c2a73
Signed-off-by: Jaehoon Chung <jh80.chung@samsung.com>
board/samsung/common/exynos5-dt.c

index 2727211e3c37bd813b17109ec938c22ba5fe7016..213640b7eb1d8f3f6fa89aec5728101ae894da65 100644 (file)
@@ -12,6 +12,7 @@
 #include <asm/io.h>
 #include <errno.h>
 #include <i2c.h>
+#include <part.h>
 #include <mmc.h>
 #include <netdev.h>
 #include <samsung-usb-phy-uboot.h>
@@ -163,11 +164,44 @@ int board_usb_init(int index, enum usb_init_type init)
 char *get_dfu_alt_system(char *interface, char *devstr)
 {
        char *info = "Not supported!";
+       struct mmc *mmc;
+       char *alt_system;
+       int dev_num;
+       int ret;
+       struct disk_partition partinfo;
 
        if (board_is_odroidxu4() || board_is_odroidhc1() || board_is_odroidhc2())
                return info;
 
-       return env_get("dfu_alt_system");
+       dev_num = simple_strtoul(devstr, NULL, 10);
+
+       mmc = find_mmc_device(dev_num);
+       if (!mmc)
+               return NULL;
+
+       if (mmc_init(mmc))
+               return NULL;
+
+       ret = blk_select_hwpart_devnum(IF_TYPE_MMC, 0, 0);
+       if (ret)
+               return NULL;
+
+       if (env_get("ramdiskpart")) {
+               int part_num = (int)simple_strtoul(env_get("ramdiskpart"), NULL, 10);
+#ifndef CONFIG_BLK
+               ret = part_get_info(&mmc->block_dev, part_num, &partinfo);
+#else
+               ret = part_get_info(mmc_get_blk_desc(mmc), part_num, &partinfo);
+#endif
+               if (ret)
+                       alt_system = CONFIG_DFU_ALT_SYSTEM;
+               else
+                       alt_system = CONFIG_DFU_ALT_SYSTEM_2;
+       } else {
+               alt_system = CONFIG_DFU_ALT_SYSTEM;
+       }
+
+       return alt_system;
 }
 
 char *get_dfu_alt_boot(char *interface, char *devstr)