Patchwork [U-Boot,v3,04/11] samsung: misc: add function for setting $dfu_alt_info

login
register
mail settings
Submitter Przemyslaw Marczak
Date June 26, 2014, 2:15 p.m.
Message ID <1403792137-3113-5-git-send-email-p.marczak@samsung.com>
Download mbox | patch
Permalink /patch/364552/
State Changes Requested
Delegated to: Minkyu Kang
Headers show

Comments

Przemyslaw Marczak - June 26, 2014, 2:15 p.m.
This change introduces new common function:
- set_dfu_alt_info() - put dfu system and bootloader setting
                       into $dfu_alt_info.
functions declaration:
- char *get_dfu_alt_system(void)
- char *get_dfu_alt_boot(void)
- void set_dfu_alt_info(void)
and new config:
- CONFIG_SET_DFU_ALT_INFO

This function can be used for auto setting dfu configuration on boot.
Such feature is useful for multi board support by one u-boot binary.
Each board should define two functions:
- get_dfu_alt_system()
- get_dfu_alt_boot()

Signed-off-by: Przemyslaw Marczak <p.marczak@samsung.com>
Cc: Piotr Wilczek <p.wilczek@samsung.com>
Cc: Minkyu Kang <mk7.kang@samsung.com>

---
Changes v2:
- change config names:
  CONFIG_SET_DFU_BOOT_ALT to CONFIG_DFU_ALT_BOOTLOADER and
  CONFIG_DFU_BOOT_ALT_* to CONFIG_DFU_ALT_BOOT_*
- change function name: set_dfu_boot_alt() to set_dfu_alt_boot()
- remove superfluous ifdefs

Changes v3:
- set $dfu_alt_info at every boot
- new config: CONFIG_SET_DFU_ALT_INFO
- update commit msg
---
 board/samsung/common/misc.c | 36 ++++++++++++++++++++++++++++++++++++
 include/samsung/misc.h      |  6 ++++++
 2 files changed, 42 insertions(+)

Patch

diff --git a/board/samsung/common/misc.c b/board/samsung/common/misc.c
index a453a82..166ea83 100644
--- a/board/samsung/common/misc.c
+++ b/board/samsung/common/misc.c
@@ -11,6 +11,7 @@ 
 #include <samsung/misc.h>
 #include <errno.h>
 #include <version.h>
+#include <malloc.h>
 #include <linux/sizes.h>
 #include <asm/arch/cpu.h>
 #include <asm/arch/gpio.h>
@@ -21,6 +22,41 @@ 
 
 DECLARE_GLOBAL_DATA_PTR;
 
+#ifdef CONFIG_SET_DFU_ALT_INFO
+void set_dfu_alt_info(void)
+{
+	char *alt_boot = NULL;
+	char *alt_system = NULL;
+	char *buf = NULL;
+	int buf_len;
+
+	puts("DFU alt info setting: ");
+
+	alt_boot = get_dfu_alt_boot();
+	if (!alt_boot)
+		goto error;
+
+	alt_system = get_dfu_alt_system();
+	if (!alt_system)
+		goto error;
+
+	buf_len = strlen(alt_boot) + strlen(alt_system) + 2;
+	buf = malloc(buf_len);
+
+	sprintf(buf, "%s;%s", alt_boot, alt_system);
+	setenv("dfu_alt_info", buf);
+
+	free(buf);
+
+	puts("done\n");
+
+	return;
+error:
+	puts("error\n");
+	setenv("dfu_alt_info", "Settings not found!");
+}
+#endif
+
 #ifdef CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG
 void set_board_info(void)
 {
diff --git a/include/samsung/misc.h b/include/samsung/misc.h
index 57bac7d..c3fcc29 100644
--- a/include/samsung/misc.h
+++ b/include/samsung/misc.h
@@ -35,4 +35,10 @@  void draw_logo(void);
 
 unsigned int boot_device(void);
 
+#ifdef CONFIG_SET_DFU_ALT_INFO
+char *get_dfu_alt_system(void);
+char *get_dfu_alt_boot(void);
+void set_dfu_alt_info(void);
+#endif
+
 #endif /* __SAMSUNG_MISC_COMMON_H__ */