artik: dfu: add DFU functions 51/65951/2
authorjino.cho <jino.cho@samsung.com>
Thu, 14 Apr 2016 07:10:23 +0000 (16:10 +0900)
committerjino.cho <jino.cho@samsung.com>
Thu, 14 Apr 2016 07:27:23 +0000 (16:27 +0900)
This patch adds DFU functions and DFU informations for the ARTIK devices.

 set_dfu_alt_info
  - setting dfu information for the ARTIK devices.
 get_dfu_alt_system
  - getting system partition information.
 get_dfu_alt_boot
  - getting predefined boot partition information.

Change-Id: I4361f75ba6889b86d6c6bb4501c38545c742442a
Signed-off-by: jino.cho <jino.cho@samsung.com>
board/samsung/espresso3250/espresso3250.c
board/samsung/smdk5422/smdk5422.c
include/configs/artik_common.h

index fc9547985f3308224086a8922644f2743553d88b..10e1d6467ad2c9b17c1b9e5e1e5e0ccb45d94e87 100644 (file)
@@ -32,6 +32,7 @@
 #include <asm/arch/pinmux.h>
 #include <asm/arch/sromc.h>
 #include <asm/arch/sysreg.h>
+#include <mmc.h>
 #include "pmic.h"
 
 #define DEBOUNCE_DELAY 10000
@@ -602,3 +603,71 @@ int board_late_init(void)
 #endif
        return 0;
 }
+
+#ifdef CONFIG_SET_DFU_ALT_INFO
+char *get_dfu_alt_system(char *interface, char *devstr)
+{
+       return getenv("dfu_alt_system");
+}
+
+char *get_dfu_alt_boot(char *interface, char *devstr)
+{
+       struct mmc *mmc;
+       char *alt_boot;
+       int dev_num;
+
+       dev_num = simple_strtoul(devstr, NULL, 10);
+
+       mmc = find_mmc_device(dev_num);
+       if (!mmc)
+               return NULL;
+
+       if (mmc_init(mmc))
+               return NULL;
+
+       if (IS_SD(mmc))
+               alt_boot = CONFIG_DFU_ALT_BOOT_SD;
+       else
+               alt_boot = CONFIG_DFU_ALT_BOOT_EMMC;
+
+       return alt_boot;
+}
+
+void set_dfu_alt_info(char *interface, char *devstr)
+{
+       size_t buf_size = CONFIG_SET_DFU_ALT_BUF_LEN;
+       ALLOC_CACHE_ALIGN_BUFFER(char, buf, buf_size);
+       char *alt_info = "Settings not found!";
+       char *status = "error!\n";
+       char *alt_setting;
+       char *alt_sep;
+       int offset = 0;
+
+       puts("DFU alt info setting: ");
+
+       alt_setting = get_dfu_alt_boot(interface, devstr);
+       if (alt_setting) {
+               setenv("dfu_alt_boot", alt_setting);
+               offset = snprintf(buf, buf_size, "%s", alt_setting);
+       }
+
+       alt_setting = get_dfu_alt_system(interface, devstr);
+       if (alt_setting) {
+               if (offset)
+                       alt_sep = ";";
+               else
+                       alt_sep = "";
+
+               offset += snprintf(buf + offset, buf_size - offset,
+                                   "%s%s", alt_sep, alt_setting);
+       }
+
+       if (offset) {
+               alt_info = buf;
+               status = "done\n";
+       }
+
+       setenv("dfu_alt_info", alt_info);
+       puts(status);
+}
+#endif
index 49be1e5cb497587e49782179f58918626813f3a8..320976807372272d41a16df2af8af2f665a02b5b 100644 (file)
@@ -33,6 +33,7 @@
 #include <asm/arch/pinmux.h>
 #include <asm/arch/sromc.h>
 #include <asm/arch/sysreg.h>
+#include <mmc.h>
 #include "pmic.h"
 #ifdef CONFIG_CPU_EXYNOS5422_EVT0
 #ifdef CONFIG_MACH_UNIVERSAL5422
@@ -558,4 +559,42 @@ char *get_dfu_alt_boot(char *interface, char *devstr)
 
        return alt_boot;
 }
+
+void set_dfu_alt_info(char *interface, char *devstr)
+{
+       size_t buf_size = CONFIG_SET_DFU_ALT_BUF_LEN;
+       ALLOC_CACHE_ALIGN_BUFFER(char, buf, buf_size);
+       char *alt_info = "Settings not found!";
+       char *status = "error!\n";
+       char *alt_setting;
+       char *alt_sep;
+       int offset = 0;
+
+       puts("DFU alt info setting: ");
+
+       alt_setting = get_dfu_alt_boot(interface, devstr);
+       if (alt_setting) {
+               setenv("dfu_alt_boot", alt_setting);
+               offset = snprintf(buf, buf_size, "%s", alt_setting);
+       }
+
+       alt_setting = get_dfu_alt_system(interface, devstr);
+       if (alt_setting) {
+               if (offset)
+                       alt_sep = ";";
+               else
+                       alt_sep = "";
+
+               offset += snprintf(buf + offset, buf_size - offset,
+                                   "%s%s", alt_sep, alt_setting);
+       }
+
+       if (offset) {
+               alt_info = buf;
+               status = "done\n";
+       }
+
+       setenv("dfu_alt_info", alt_info);
+       puts(status);
+}
 #endif
index a7000939c567f94260d7743837351c362bdc8232..47f03a372a690bfb25be637333634319941ba0bf 100644 (file)
 #define CONFIG_MODULE_PART     2
 #define CONFIG_ROOT_PART       3
 
+#define CONFIG_SET_DFU_ALT_INFO
+#define CONFIG_SET_DFU_ALT_BUF_LEN     (1 << 10)       /* 1 KB */
+
 #define CONFIG_DFU_ALT_SYSTEM               \
        "uImage fat 0 1;"                   \
        "zImage fat 0 1;"                   \
        "system-data part 0 4;" \
        "user part 0 5\0"
 
+#ifdef CONFIG_MACH_ARTIK5
+#define CONFIG_DFU_ALT_BOOT_EMMC               \
+       "u-boot raw 0x3e 0x290 mmcpart 1;"      \
+       "bl1 raw 0x0 0x1e mmcpart 1;"           \
+       "bl2 raw 0x1e 0x20 mmcpart 1;"          \
+       "tzsw raw 0x2ce 0x138 mmcpart 1;"       \
+       "params raw 0x406 0x20 \0"
+
+#define CONFIG_DFU_ALT_BOOT_SD                 \
+       "u-boot raw 0x3e 0x290;"                \
+       "bl1 raw 0x0 0x1e;"                     \
+       "bl2 raw 0x1e 0x20;"                    \
+       "tzsw raw 0x2ce 0x138;"                 \
+       "params raw 0x406 0x20\0"
+#endif
+
+#ifdef CONFIG_MACH_ARTIK10
+#define CONFIG_DFU_ALT_BOOT_EMMC               \
+       "u-boot raw 0x3e 0x290 mmcpart 1;"      \
+       "bl1 raw 0x0 0x1e mmcpart 1;"           \
+       "bl2 raw 0x1e 0x20 mmcpart 1;"          \
+       "tzsw raw 0x2ce 0x200 mmcpart 1;"       \
+       "params raw 0x4ce 0x20 \0"
+
+#define CONFIG_DFU_ALT_BOOT_SD                 \
+       "u-boot raw 0x3e 0x290;"                \
+       "bl1 raw 0x0 0x1e;"                     \
+       "bl2 raw 0x1e 0x20;"                    \
+       "tzsw raw 0x2ce 0x200;"                 \
+       "params raw 0x4ce 0x20\0"
+#endif
+
 #define PARTS_DEFAULT                                                  \
        "uuid_disk=${uuid_gpt_disk};"                                   \
        "name=boot,start=1MiB,size=" __stringify(CONFIG_BOOT_PART_SIZE) \
        "fdtaddr=40800000\0"                                            \
        "initrd_file=uInitrd\0"                                         \
        "initrd_addr=43000000\0"                                        \
-       "dfu_alt_info=" CONFIG_DFU_ALT_SYSTEM                           \
+       "dfu_alt_system=" CONFIG_DFU_ALT_SYSTEM                 \
+       "dfu_usb_con=0\0"                                               \
+       "dfu_interface=mmc\0"                                           \
+       "dfu_device=${emmc_dev}\0"                                      \
        "sdrecovery=sdfuse format; sdfuse flashall 3\0"                 \
        "factory_load=factory_info load mmc ${emmc_dev} 0x80 0x8\0"     \
        "factory_save=factory_info save mmc ${emmc_dev} 0x80 0x8\0"     \