From 84c6ec9b622d30872f08105c2da35099ec626a72 Mon Sep 17 00:00:00 2001 From: Przemyslaw Marczak Date: Thu, 13 Nov 2014 11:40:02 +0100 Subject: [PATCH] samsung: misc_init_r: insert call to platform_setup() This change adds call of platform_setup() to check or set active platform configuration. Another change is setup environment variable: ${platname}, from board name in set_board_info(). Change-Id: I355736bf40f8fa3697ce0b4546f7702d2e54a0f9 Signed-off-by: Przemyslaw Marczak --- board/samsung/common/board.c | 3 +++ board/samsung/common/misc.c | 3 +++ cmd/dfu.c | 57 ++++++++++++++++++++++++++++++++++++-------- 3 files changed, 53 insertions(+), 10 deletions(-) diff --git a/board/samsung/common/board.c b/board/samsung/common/board.c index 755757f..599d50e 100644 --- a/board/samsung/common/board.c +++ b/board/samsung/common/board.c @@ -340,6 +340,9 @@ int misc_init_r(void) #ifdef CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG set_board_info(); #endif +#ifdef CONFIG_PLATFORM_SETUP + platform_setup(); +#endif #ifdef CONFIG_OF_MULTI if (!board_is_trats2()) return 0; diff --git a/board/samsung/common/misc.c b/board/samsung/common/misc.c index ccd5fd2..9e65280 100644 --- a/board/samsung/common/misc.c +++ b/board/samsung/common/misc.c @@ -292,6 +292,9 @@ void set_board_info(void) #ifdef CONFIG_OF_MULTI bdname = get_board_name(); +#ifdef CONFIG_PLATFORM_SETUP + setenv("platname", bdname); +#endif #endif sprintf(info, "%s%s", bdname, bdtype); env_set("board_name", info); diff --git a/cmd/dfu.c b/cmd/dfu.c index 91a750a..02c28b7 100644 --- a/cmd/dfu.c +++ b/cmd/dfu.c @@ -20,19 +20,46 @@ static int do_dfu(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) { - - if (argc < 4) - return CMD_RET_USAGE; - -#ifdef CONFIG_DFU_OVER_USB - char *usb_controller = argv[1]; -#endif #if defined(CONFIG_DFU_OVER_USB) || defined(CONFIG_DFU_OVER_TFTP) + char *interface; + char *devstring; +#else + char *usb_controller = argv[1]; + if (argv < 4) + return CMD_RET_USAGE; char *interface = argv[2]; char *devstring = argv[3]; #endif - int ret = 0; + +#ifdef CONFIG_DFU_OVER_USB + char *usb_controller; + int argv_list = 0; + bool dfu_reset = false; + switch (argc) { + case 2: + argv_list = 1; + case 1: + usb_controller = strdup(env_get("dfu_usb_con")); + interface = strdup(env_get("dfu_interface")); + devstring = strdup(env_get("dfu_device")); + if (!usb_controller || !interface || !devstring) { + puts("DFU: default device environment is not set.\n"); + ret = CMD_RET_USAGE; + goto bad_args; + } + break; + case 5: + argv_list = 4; + case 4: + usb_controller = argv[1]; + interface = argv[2]; + devstring = argv[3]; + break; + default: + return CMD_RET_USAGE; + } +#endif #ifdef CONFIG_DFU_OVER_TFTP unsigned long addr = 0; if (!strcmp(argv[1], "tftp")) { @@ -47,8 +74,7 @@ static int do_dfu(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) if (ret) goto done; - ret = CMD_RET_SUCCESS; - if (argc > 4 && strcmp(argv[4], "list") == 0) { + if (argv_list && !strcmp(argv[argv_list], "list")) { dfu_show_entities(); goto done; } @@ -59,6 +85,17 @@ static int do_dfu(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) done: dfu_free_entities(); + + if (dfu_reset) + run_command("reset", 0); + + g_dnl_clear_detach(); +bad_args: + if (argc == 1) { + free(usb_controller); + free(interface); + free(devstring); + } #endif return ret; } -- 2.7.4