]> git.sur5r.net Git - u-boot/commitdiff
keymile, common: add setting of some environment variables
authorHeiko Schocher <hs@denx.de>
Mon, 26 Apr 2010 11:07:28 +0000 (13:07 +0200)
committerWolfgang Denk <wd@denx.de>
Fri, 29 Apr 2011 22:45:22 +0000 (00:45 +0200)
This patch adds last_stage_init to all keymile boards. And
in the last stage init some environment variables for u-boot
were set. Currently these are pnvramaddr, pram and var address.

Signed-off-by: Holger Brunck <holger.brunck@keymile.com>
Signed-off-by: Heiko Schocher <hs@denx.de>
Acked-by: Kim Phillips <kim.phillips@freescale.com>
cc: Valentin Longchamp <valentin.longchamp@keymile.com>
cc: Wolfgang Denk <wd@denx.de>
cc: Kim Phillips <kim.phillips@freescale.com>

board/keymile/common/common.c
board/keymile/common/common.h
board/keymile/km83xx/km83xx.c
board/keymile/km_arm/km_arm.c
board/keymile/mgcoge/mgcoge.c
include/configs/keymile-common.h
include/configs/km_arm.h
include/configs/mgcoge.h

index 8392a6413ea30aba8691313f2bb588dd47739e0e..4883fe588b80c23a23ed1c01199e00b5a0c8adc8 100644 (file)
@@ -42,6 +42,7 @@
 
 static void i2c_write_start_seq(void);
 static int i2c_make_abort(void);
+DECLARE_GLOBAL_DATA_PTR;
 
 int ivm_calc_crc(unsigned char *buf, int len)
 {
@@ -73,6 +74,41 @@ int ivm_calc_crc(unsigned char *buf, int len)
        return crc;
 }
 
+/*
+ * Set Keymile specific environment variables
+ * Currently only some memory layout variables are calculated here
+ * ... ------------------------------------------------
+ * ... |@rootfsaddr |@pnvramaddr |@varaddr |@reserved |@END_OF_RAM
+ * ... |<------------------- pram ------------------->|
+ * ... ------------------------------------------------
+ * @END_OF_RAM: denotes the RAM size
+ * @pnvramaddr: Startadress of pseudo non volatile RAM in hex
+ * @pram      : preserved ram size in k
+ * @varaddr   : startadress for /var mounted into RAM
+ */
+int set_km_env(void)
+{
+       uchar buf[32];
+       unsigned int pnvramaddr;
+       unsigned int pram;
+       unsigned int varaddr;
+
+       pnvramaddr = gd->ram_size - CONFIG_KM_RESERVED_PRAM - CONFIG_KM_PHRAM
+                       - CONFIG_KM_PNVRAM;
+       sprintf((char *)buf, "0x%x", pnvramaddr);
+       setenv("pnvramaddr", (char *)buf);
+
+       pram = (CONFIG_KM_RESERVED_PRAM + CONFIG_KM_PHRAM + CONFIG_KM_PNVRAM) /
+               0x400;
+       sprintf((char *)buf, "0x%x", pram);
+       setenv("pram", (char *)buf);
+
+       varaddr = gd->ram_size - CONFIG_KM_RESERVED_PRAM - CONFIG_KM_PHRAM;
+       sprintf((char *)buf, "0x%x", varaddr);
+       setenv("varaddr", (char *)buf);
+       return 0;
+}
+
 static int ivm_set_value(char *name, char *value)
 {
        char tempbuf[256];
index e32de8d9fa484afdca851e986229b5cf1f5f5a36..099de98c6d9e02e818daf55131433a33871dc82f 100644 (file)
@@ -50,6 +50,7 @@ int ivm_read_eeprom(void);
 int keymile_hdlc_enet_initialize(bd_t *bis);
 #endif
 
+int set_km_env(void);
 int fdt_set_node_and_value(void *blob,
                        char *nodename,
                        char *regname,
index f9186e813b92292d70a4e75dbc35ce3788db5856..17560c8dbae52ba8c028d7b76aa378d7736280e9 100644 (file)
@@ -190,6 +190,12 @@ int misc_init_r(void)
        return 0;
 }
 
+int last_stage_init(void)
+{
+       set_km_env();
+       return 0;
+}
+
 int fixed_sdram(void)
 {
        immap_t *im = (immap_t *)CONFIG_SYS_IMMR;
index cb999b23faef6bd79c0011cbe6f6a63a17cb8342..c772ee2a55881864332dfccf80299f917a4b1ee6 100644 (file)
@@ -212,6 +212,12 @@ int board_init(void)
        return 0;
 }
 
+int last_stage_init(void)
+{
+       set_km_env();
+       return 0;
+}
+
 #if defined(CONFIG_CMD_SF)
 int do_spi_toggle(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 {
index 7f487f109e9ddabd590163886bbc3701f4ded35d..7b346849bae4878327939a1982d618fdd154f93b 100644 (file)
@@ -310,6 +310,7 @@ int last_stage_init(void)
                puts("DIP:   Enabled\n");
                setenv("actual_bank", "0");
        }
+       set_km_env();
        return 0;
 }
 
index 77e20909ce82e83b4384e6ec86f9f8d4903ba0fa..da5a4475b051323a44f3ea9bb3eaddbf28f7a1f0 100644 (file)
@@ -26,6 +26,9 @@
 
 /* Do boardspecific init for all boards */
 #define CONFIG_BOARD_EARLY_INIT_R
+#define CONFIG_LAST_STAGE_INIT
+
+#define CONFIG_BOOTCOUNT_LIMIT
 
 /*
  * By default kwbimage.cfg from board specific folder is used
index 8cb0fe834db41d238b9a49475e4ba5b056d543b9..9c8d0e7af740a37a4728933e7bb8f65aaea38970 100644 (file)
@@ -254,4 +254,11 @@ int get_scl (void);
 #define CONFIG_SYS_INIT_SP_ADDR                0xC8012000
 /* Do early setups now in board_init_f() */
 #define CONFIG_BOARD_EARLY_INIT_F
+
+/*
+ * resereved pram area at the end of memroy [hex]
+ * 8Mbytes for switch + 4Kbytes for bootcount
+ */
+#define CONFIG_KM_RESERVED_PRAM 0x801000
+
 #endif /* _CONFIG_KM_ARM_H */
index a0d1765adf433e199d6d6a121562af73e65d7150..dcde76c86f201ffb2cbc679f749acc5baa23bcb9 100644 (file)
@@ -61,8 +61,6 @@
 /* include further common stuff for all keymile 82xx boards */
 #include "km82xx-common.h"
 
-/* enable last_stage_init */
-#define CONFIG_LAST_STAGE_INIT          1
 /* bfticu address */
 #define CONFIG_SYS_BFTICU_BASE          0x40000000