diff options
author | jino.cho <jino.cho@samsung.com> | 2016-04-14 16:10:23 +0900 |
---|---|---|
committer | jino.cho <jino.cho@samsung.com> | 2016-04-14 16:27:23 +0900 |
commit | e13c186820e1bcdf7134f1d1f3b99b24bfb9d9e9 (patch) | |
tree | 976fd5a77b141e38c9d3880d7ea36599e2b0c0b3 | |
parent | df35515c7bf2cd9c527e62337b39ef9bbf07cd33 (diff) | |
download | u-boot-artik-e13c186820e1bcdf7134f1d1f3b99b24bfb9d9e9.tar.gz u-boot-artik-e13c186820e1bcdf7134f1d1f3b99b24bfb9d9e9.tar.bz2 u-boot-artik-e13c186820e1bcdf7134f1d1f3b99b24bfb9d9e9.zip |
artik: dfu: add DFU functions
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>
-rw-r--r-- | board/samsung/espresso3250/espresso3250.c | 69 | ||||
-rw-r--r-- | board/samsung/smdk5422/smdk5422.c | 39 | ||||
-rw-r--r-- | include/configs/artik_common.h | 40 |
3 files changed, 147 insertions, 1 deletions
diff --git a/board/samsung/espresso3250/espresso3250.c b/board/samsung/espresso3250/espresso3250.c index fc9547985..10e1d6467 100644 --- a/board/samsung/espresso3250/espresso3250.c +++ b/board/samsung/espresso3250/espresso3250.c @@ -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 diff --git a/board/samsung/smdk5422/smdk5422.c b/board/samsung/smdk5422/smdk5422.c index 49be1e5cb..320976807 100644 --- a/board/samsung/smdk5422/smdk5422.c +++ b/board/samsung/smdk5422/smdk5422.c @@ -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 diff --git a/include/configs/artik_common.h b/include/configs/artik_common.h index a7000939c..47f03a372 100644 --- a/include/configs/artik_common.h +++ b/include/configs/artik_common.h @@ -277,6 +277,9 @@ #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;" \ @@ -291,6 +294,38 @@ "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) \ @@ -338,7 +373,10 @@ "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" \ |