[U-Boot] [PATCH v2 18/21] keymile, common: add setting of some environment variables
Heiko Schocher
hs at denx.de
Tue Mar 15 10:04:01 CET 2011
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 at keymile.com>
Signed-off-by: Heiko Schocher <hs at denx.de>
cc: Valentin Longchamp <valentin.longchamp at keymile.com>
cc: Wolfgang Denk <wd at denx.de>
cc: Kim Phillips <kim.phillips at freescale.com>
---
Changes for v2:
- fix checkpatch.pl errors and warnings
board/keymile/common/common.c | 36 ++++++++++++++++++++++++++++++++++--
board/keymile/common/common.h | 2 ++
board/keymile/km83xx/km83xx.c | 13 +++++++++++++
board/keymile/km_arm/km_arm.c | 11 +++++++++++
board/keymile/mgcoge/mgcoge.c | 13 +++++++++++++
include/configs/keymile-common.h | 3 +++
include/configs/km_arm.h | 5 +++++
7 files changed, 81 insertions(+), 2 deletions(-)
diff --git a/board/keymile/common/common.c b/board/keymile/common/common.c
index ecb9664..8f3910e 100644
--- a/board/keymile/common/common.c
+++ b/board/keymile/common/common.c
@@ -40,8 +40,6 @@
#if defined(CONFIG_HARD_I2C) || defined(CONFIG_SOFT_I2C)
#include <i2c.h>
-extern int i2c_soft_read_pin (void);
-
int ivm_calc_crc (unsigned char *buf, int len)
{
const unsigned short crc_tab[16] = {
@@ -72,6 +70,40 @@ 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 = arch_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 = arch_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];
diff --git a/board/keymile/common/common.h b/board/keymile/common/common.h
index a2adf1d..b5f603a 100644
--- a/board/keymile/common/common.h
+++ b/board/keymile/common/common.h
@@ -18,11 +18,13 @@ int ethernet_present(void);
int ivm_read_eeprom(void);
void writeStartSeq(void);
int i2c_make_abort(void);
+unsigned int arch_ram_size(void);
#ifdef CONFIG_KEYMILE_HDLC_ENET
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,
diff --git a/board/keymile/km83xx/km83xx.c b/board/keymile/km83xx/km83xx.c
index a085d7e..02be714 100644
--- a/board/keymile/km83xx/km83xx.c
+++ b/board/keymile/km83xx/km83xx.c
@@ -30,6 +30,8 @@
#include "../common/common.h"
+DECLARE_GLOBAL_DATA_PTR;
+
extern void disable_addr_trans(void);
extern void enable_addr_trans(void);
const qe_iop_conf_t qe_iop_conf_tab[] = {
@@ -178,6 +180,17 @@ int misc_init_r(void)
return 0;
}
+unsigned int arch_ram_size(void)
+{
+ return gd->bd->bi_memsize;
+}
+
+int last_stage_init(void)
+{
+ set_km_env();
+ return 0;
+}
+
int fixed_sdram(void)
{
volatile immap_t *im = (immap_t *)CONFIG_SYS_IMMR;
diff --git a/board/keymile/km_arm/km_arm.c b/board/keymile/km_arm/km_arm.c
index ba8f833..bf52867 100644
--- a/board/keymile/km_arm/km_arm.c
+++ b/board/keymile/km_arm/km_arm.c
@@ -210,6 +210,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[])
{
@@ -273,6 +279,11 @@ void dram_init_banksize(void)
}
}
+unsigned int arch_ram_size(void)
+{
+ return gd->ram_size;
+}
+
/* Configure and enable MV88E1118 PHY */
void reset_phy(void)
{
diff --git a/board/keymile/mgcoge/mgcoge.c b/board/keymile/mgcoge/mgcoge.c
index f973b8d..38f25d4 100644
--- a/board/keymile/mgcoge/mgcoge.c
+++ b/board/keymile/mgcoge/mgcoge.c
@@ -37,6 +37,8 @@
#include "../common/common.h"
+DECLARE_GLOBAL_DATA_PTR;
+
/*
* I/O Port configuration table
*
@@ -310,6 +312,17 @@ int board_early_init_r (void)
return 0;
}
+unsigned int arch_ram_size(void)
+{
+ return gd->bd->bi_memsize;
+}
+
+int last_stage_init(void)
+{
+ set_km_env();
+ return 0;
+}
+
int hush_init_var (void)
{
ivm_read_eeprom ();
diff --git a/include/configs/keymile-common.h b/include/configs/keymile-common.h
index 0927ce3..e4699e2 100644
--- a/include/configs/keymile-common.h
+++ b/include/configs/keymile-common.h
@@ -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
diff --git a/include/configs/km_arm.h b/include/configs/km_arm.h
index 762f0cf..f009059 100644
--- a/include/configs/km_arm.h
+++ b/include/configs/km_arm.h
@@ -252,4 +252,9 @@ 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 */
--
1.7.4
More information about the U-Boot
mailing list