]> git.sur5r.net Git - u-boot/blobdiff - board/keymile/common/common.c
env: Rename setenv() to env_set()
[u-boot] / board / keymile / common / common.c
index 136b2dee12a2f07caa85fd6ea781b8699691d3a9..56d304424108f4897a3da0705537ebd99f486021 100644 (file)
@@ -12,7 +12,7 @@
 #include <ioports.h>
 #include <command.h>
 #include <malloc.h>
-#include <hush.h>
+#include <cli_hush.h>
 #include <net.h>
 #include <netdev.h>
 #include <asm/io.h>
 #include "common.h"
 #include <i2c.h>
 
-#if !defined(CONFIG_MPC83xx)
-static void i2c_write_start_seq(void);
-#endif
-
 DECLARE_GLOBAL_DATA_PTR;
 
 /*
@@ -55,30 +51,29 @@ int set_km_env(void)
        pnvramaddr = gd->ram_size - CONFIG_KM_RESERVED_PRAM - CONFIG_KM_PHRAM
                        - CONFIG_KM_PNVRAM;
        sprintf((char *)buf, "0x%x", pnvramaddr);
-       setenv("pnvramaddr", (char *)buf);
+       env_set("pnvramaddr", (char *)buf);
 
-       /* try to read rootfssize (ram image) from envrionment */
+       /* try to read rootfssize (ram image) from environment */
        p = getenv("rootfssize");
        if (p != NULL)
                strict_strtoul(p, 16, &rootfssize);
        pram = (rootfssize + CONFIG_KM_RESERVED_PRAM + CONFIG_KM_PHRAM +
                CONFIG_KM_PNVRAM) / 0x400;
        sprintf((char *)buf, "0x%x", pram);
-       setenv("pram", (char *)buf);
+       env_set("pram", (char *)buf);
 
        varaddr = gd->ram_size - CONFIG_KM_RESERVED_PRAM - CONFIG_KM_PHRAM;
        sprintf((char *)buf, "0x%x", varaddr);
-       setenv("varaddr", (char *)buf);
+       env_set("varaddr", (char *)buf);
 
        kernelmem = gd->ram_size - 0x400 * pram;
        sprintf((char *)buf, "0x%x", kernelmem);
-       setenv("kernelmem", (char *)buf);
+       env_set("kernelmem", (char *)buf);
 
        return 0;
 }
 
 #if defined(CONFIG_SYS_I2C_INIT_BOARD)
-#if !defined(CONFIG_MPC83xx)
 static void i2c_write_start_seq(void)
 {
        set_sda(1);
@@ -101,21 +96,6 @@ static void i2c_write_start_seq(void)
  */
 int i2c_make_abort(void)
 {
-
-#if defined(CONFIG_HARD_I2C) && !defined(MACH_TYPE_KM_KIRKWOOD)
-       immap_t *immap = (immap_t *)CONFIG_SYS_IMMR;
-       i2c8260_t *i2c  = (i2c8260_t *)&immap->im_i2c;
-
-       /*
-        * disable I2C controller first, otherwhise it thinks we want to
-        * talk to the slave port...
-        */
-       clrbits_8(&i2c->i2c_i2mod, 0x01);
-
-       /* Set the PortPins to GPIO */
-       setports(1);
-#endif
-
        int     scl_state = 0;
        int     sda_state = 0;
        int     i = 0;
@@ -148,13 +128,8 @@ int i2c_make_abort(void)
        set_sda(1);
        get_sda();
 
-#if defined(CONFIG_HARD_I2C)
-       /* Set the PortPins back to use for I2C */
-       setports(0);
-#endif
        return ret;
 }
-#endif
 
 /**
  * i2c_init_board - reset i2c bus. When the board is powercycled during a
@@ -167,6 +142,7 @@ void i2c_init_board(void)
 }
 #endif
 
+#if defined(CONFIG_KM_COMMON_ETH_INIT)
 int board_eth_init(bd_t *bis)
 {
        if (ethernet_present())
@@ -174,6 +150,7 @@ int board_eth_init(bd_t *bis)
 
        return -1;
 }
+#endif
 
 /*
  * do_setboardid command
@@ -191,8 +168,8 @@ static int do_setboardid(cmd_tbl_t *cmdtp, int flag, int argc,
                printf("can't get the IVM_Boardid\n");
                return 1;
        }
-       sprintf((char *)buf, "%s", p);
-       setenv("boardid", (char *)buf);
+       strcpy((char *)buf, p);
+       env_set("boardid", (char *)buf);
        printf("set boardid=%s\n", buf);
 
        p = get_local_var("IVM_HWKey");
@@ -200,8 +177,8 @@ static int do_setboardid(cmd_tbl_t *cmdtp, int flag, int argc,
                printf("can't get the IVM_HWKey\n");
                return 1;
        }
-       sprintf((char *)buf, "%s", p);
-       setenv("hwkey", (char *)buf);
+       strcpy((char *)buf, p);
+       env_set("hwkey", (char *)buf);
        printf("set hwkey=%s\n", buf);
        printf("Execute manually saveenv for persistent storage.\n");
 
@@ -334,9 +311,9 @@ static int do_checkboardidhwk(cmd_tbl_t *cmdtp, int flag, int argc,
                                        envbid   = bid;
                                        envhwkey = hwkey;
                                        sprintf(buf, "%lx", bid);
-                                       setenv("boardid", buf);
+                                       env_set("boardid", buf);
                                        sprintf(buf, "%lx", hwkey);
-                                       setenv("hwkey", buf);
+                                       env_set("hwkey", buf);
                                }
                        } /* end while( ! found ) */
                }
@@ -377,12 +354,13 @@ static int do_checktestboot(cmd_tbl_t *cmdtp, int flag, int argc,
 
 #if defined(CONFIG_POST)
        testpin = post_hotkeys_pressed();
-       s = getenv("test_bank");
 #endif
+       s = getenv("test_bank");
        /* when test_bank is not set, act as if testpin is not asserted */
        testboot = (testpin != 0) && (s);
        if (verbose) {
                printf("testpin   = %d\n", testpin);
+               /* cppcheck-suppress nullPointer */
                printf("test_bank = %s\n", s ? s : "not set");
                printf("boot test app : %s\n", (testboot) ? "yes" : "no");
        }