board: samsung: exynos5-dt: modify the get_dfu_alt_system information 23/190323/4
authorJaehoon Chung <jh80.chung@samsung.com>
Mon, 1 Oct 2018 04:00:43 +0000 (13:00 +0900)
committerJaehoon Chung <jh80.chung@samsung.com>
Mon, 1 Oct 2018 08:25:53 +0000 (17:25 +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-Id: I1ff7b5a6c97ad7eed2b6cd489260cfdc902c2a73
Signed-off-by: Jaehoon Chung <jh80.chung@samsung.com>
board/samsung/common/exynos5-dt.c

index 8d982896233d183f46b84843c71bebda0b79f274..8a01d5779f5cd6c5daf2d545dcbce952f2ed78e6 100644 (file)
@@ -11,6 +11,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>
@@ -187,11 +188,40 @@ 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;
+       disk_partition_t partinfo;
 
        if (board_is_odroidxu4() || board_is_odroidhc1())
                return info;
 
-       return getenv("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 (getenv("ramdiskpart")) {
+               int part_num = (int)simple_strtoul(getenv("ramdiskpart"), NULL, 10);
+               ret = part_get_info(&mmc->block_dev, part_num, &partinfo);
+               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)