Patchwork [U-Boot,07/12] env: Update serial baudrate in env_relocate()

login
register
mail settings
Submitter Joe Hershberger
Date Aug. 17, 2012, 8:49 p.m.
Message ID <1345236586-19076-8-git-send-email-joe.hershberger@ni.com>
Download mbox | patch
Permalink /patch/178371/
State Changes Requested
Delegated to: Tom Rini
Headers show

Comments

Joe Hershberger - Aug. 17, 2012, 8:49 p.m.
After the env is relocated, make sure that the serial baudrate is
applied in case it's different (such as the env_nand case).

Signed-off-by: Joe Hershberger <joe.hershberger@ni.com>
---
 common/env_common.c | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

Patch

diff --git a/common/env_common.c b/common/env_common.c
index 0c7e845..e58971d 100644
--- a/common/env_common.c
+++ b/common/env_common.c
@@ -232,6 +232,10 @@  int env_import(const char *buf, int check)
 
 void env_relocate(void)
 {
+#ifdef CONFIG_BAUDRATE_UPDATE_ON_RELOC
+	const char *baudrate_str;
+#endif
+
 #if defined(CONFIG_NEEDS_MANUAL_RELOC)
 	env_reloc();
 #endif
@@ -253,6 +257,21 @@  void env_relocate(void)
 	else
 		gd->flags &= ~GD_FLG_SILENT;
 #endif
+
+#ifdef CONFIG_BAUDRATE_UPDATE_ON_RELOC
+	baudrate_str = getenv("baudrate");
+	if (baudrate_str != NULL) {
+		int baudrate = simple_strtoul(baudrate_str, NULL, 10);
+
+		if (baudrate != gd->baudrate) {
+			gd->baudrate = baudrate;
+#if defined(CONFIG_PPC) || defined(CONFIG_MCF52x2)
+			gd->bd->bi_baudrate = baudrate;
+#endif
+			serial_setbrg();
+		}
+	}
+#endif
 }
 
 #ifdef CONFIG_AUTO_COMPLETE