Patchwork [U-Boot] km/common: implement setboardid as a command

login
register
mail settings
Submitter Valentin Longchamp
Date April 8, 2011, 12:47 p.m.
Message ID <30d7413306aba80ca4540c3353d884bdffe9a643.1302266367.git.valentin.longchamp@keymile.com>
Download mbox | patch
Permalink /patch/90330/
State Superseded
Headers show

Comments

Valentin Longchamp - April 8, 2011, 12:47 p.m.
From: Holger Brunck <holger.brunck@keymile.com>

Read out board id and HW key from the IVM eeprom and set
these values as an environment variable was now done inside the
code as a command.

Signed-off-by: Holger Brunck <holger.brunck@keymile.com>
Acked-by: Heiko Schocher <hs@denx.de>
cc: Wolfgang Denk <wd@denx.de>
cc: Detlev Zundel <dzu@denx.de>
cc: Valentin Longchamp <valentin.longchamp@keymile.com>
Signed-off-by: Valentin Longchamp <valentin.longchamp@keymile.com>
---
 board/keymile/common/common.c |   25 +++++++++++++++++++++++++
 1 files changed, 25 insertions(+), 0 deletions(-)

Patch

diff --git a/board/keymile/common/common.c b/board/keymile/common/common.c
index 9ec0022..5704b7f 100644
--- a/board/keymile/common/common.c
+++ b/board/keymile/common/common.c
@@ -25,6 +25,7 @@ 
 #if defined(CONFIG_KM82XX)
 #include <mpc8260.h>
 #endif
+#include <command.h>
 #include <ioports.h>
 #include <malloc.h>
 #include <hush.h>
@@ -689,3 +690,27 @@  int board_eth_init(bd_t *bis)
 
 	return -1;
 }
+
+/*
+ * do_setboardid command
+ * read out the board id and the hw key from the intventory EEPROM and set
+ * this values as environment variables.
+ */
+static int do_setboardid(cmd_tbl_t *cmdtp, int flag, int argc,
+				char *const argv[])
+{
+	unsigned char buf[32];
+	char *p;
+
+	p = get_local_var("IVM_BoardId");
+	sprintf((char *)buf, "%s", p);
+	setenv("boardid", (char *)buf);
+	p = get_local_var("IVM_HWKey");
+	sprintf((char *)buf, "%s", p);
+	setenv("hwkey", (char *)buf);
+	return 0;
+}
+
+U_BOOT_CMD(km_setboardid, 1, 0, do_setboardid, "setboardid", "read out bid and "
+				 "hwkey from IVM and set in environment");
+