]> git.sur5r.net Git - u-boot/blobdiff - board/keymile/common/common.c
km/common: implement setboardid command
[u-boot] / board / keymile / common / common.c
index 4883fe588b80c23a23ed1c01199e00b5a0c8adc8..9adfefaf6aac9c89cfec7e86429da150aabace33 100644 (file)
  */
 
 #include <common.h>
-#if defined(CONFIG_MGCOGE) || defined(CONFIG_MGCOGE2NE)
+#if defined(CONFIG_KM82XX)
 #include <mpc8260.h>
 #endif
 #include <ioports.h>
+#include <command.h>
 #include <malloc.h>
 #include <hush.h>
 #include <net.h>
@@ -398,10 +399,10 @@ int ivm_read_eeprom(void)
 #define DELAY_ABORT_SEQ                62  /* @200kHz 9 clocks = 44us, 62us is ok */
 #define DELAY_HALF_PERIOD      (500 / (CONFIG_SYS_I2C_SPEED / 1000))
 
-#if defined(CONFIG_MGCOGE) || defined(CONFIG_MGCOGE2NE)
+#if defined(CONFIG_KM_82XX)
 #define SDA_MASK       0x00010000
 #define SCL_MASK       0x00020000
-static void set_pin(int state, unsigned long mask)
+void set_pin(int state, unsigned long mask)
 {
        ioport_t *iop = ioport_addr((immap_t *)CONFIG_SYS_IMMR, 3);
 
@@ -677,11 +678,41 @@ int ethernet_present(void)
 
 int board_eth_init(bd_t *bis)
 {
-#ifdef CONFIG_KEYMILE_HDLC_ENET
-       (void)keymile_hdlc_enet_initialize(bis);
-#endif
        if (ethernet_present())
                return cpu_eth_init(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");