diff mbox

[U-Boot,v2,3/8] km/common: implement setboardid command

Message ID 600f7afcb8e770eaaa417db1b119823070b62c48.1304508448.git.holger.brunck@keymile.com
State Accepted
Commit a9417ce74a8b79b1a3ab879d05f4f54138422c6e
Headers show

Commit Message

Holger Brunck May 4, 2011, 11:47 a.m. UTC
Read out board id and HW key from the IVM eeprom and set
these values as an environment variable.

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>
---
Changes for v2:
   - split up first large patch serie to three independent smaller
     patch series
   - rework the patch with inputs from W.Denk:
      - adapt commit msg
      - add error handling

 board/keymile/common/common.c |   34 ++++++++++++++++++++++++++++++++++
 1 files changed, 34 insertions(+), 0 deletions(-)

Comments

Wolfgang Denk May 10, 2011, 9:20 p.m. UTC | #1
Dear Holger Brunck,

In message <600f7afcb8e770eaaa417db1b119823070b62c48.1304508448.git.holger.brunck@keymile.com> you wrote:
> Read out board id and HW key from the IVM eeprom and set
> these values as an environment variable.
> 
> 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>
> ---
> Changes for v2:
>    - split up first large patch serie to three independent smaller
>      patch series
>    - rework the patch with inputs from W.Denk:
>       - adapt commit msg
>       - add error handling
> 
>  board/keymile/common/common.c |   34 ++++++++++++++++++++++++++++++++++
>  1 files changed, 34 insertions(+), 0 deletions(-)

Applied, thanks.

Best regards,

Wolfgang Denk
diff mbox

Patch

diff --git a/board/keymile/common/common.c b/board/keymile/common/common.c
index 4883fe5..68e6b9f 100644
--- a/board/keymile/common/common.c
+++ b/board/keymile/common/common.c
@@ -26,6 +26,7 @@ 
 #include <mpc8260.h>
 #endif
 #include <ioports.h>
+#include <command.h>
 #include <malloc.h>
 #include <hush.h>
 #include <net.h>
@@ -685,3 +686,36 @@  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");
+	if (p == NULL) {
+		printf("can't get the IVM_Boardid\n");
+		return 1;
+	}
+	sprintf((char *)buf, "%s", p);
+	setenv("boardid", (char *)buf);
+
+	p = get_local_var("IVM_HWKey");
+	if (p == NULL) {
+		printf("can't get the IVM_HWKey\n");
+		return 1;
+	}
+	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");