summaryrefslogtreecommitdiff
path: root/board/keymile
diff options
context:
space:
mode:
authorHeiko Schocher <hs@denx.de>2010-04-26 13:07:28 +0200
committerWolfgang Denk <wd@denx.de>2011-04-30 00:45:22 +0200
commitf1fef1d8a141e0b4e4520d66e162c06ff047bd16 (patch)
tree41b7f4a2fd983b3472816ad6e613c72c97a482dd /board/keymile
parent0d01520200f3bb0686567134bc2e7bb940009559 (diff)
keymile, common: add setting of some environment variables
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>
Diffstat (limited to 'board/keymile')
-rw-r--r--board/keymile/common/common.c36
-rw-r--r--board/keymile/common/common.h1
-rw-r--r--board/keymile/km83xx/km83xx.c6
-rw-r--r--board/keymile/km_arm/km_arm.c6
-rw-r--r--board/keymile/mgcoge/mgcoge.c1
5 files changed, 50 insertions, 0 deletions
diff --git a/board/keymile/common/common.c b/board/keymile/common/common.c
index 8392a6413ea..4883fe588b8 100644
--- a/board/keymile/common/common.c
+++ b/board/keymile/common/common.c
@@ -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];
diff --git a/board/keymile/common/common.h b/board/keymile/common/common.h
index e32de8d9fa4..099de98c6d9 100644
--- a/board/keymile/common/common.h
+++ b/board/keymile/common/common.h
@@ -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,
diff --git a/board/keymile/km83xx/km83xx.c b/board/keymile/km83xx/km83xx.c
index f9186e813b9..17560c8dbae 100644
--- a/board/keymile/km83xx/km83xx.c
+++ b/board/keymile/km83xx/km83xx.c
@@ -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;
diff --git a/board/keymile/km_arm/km_arm.c b/board/keymile/km_arm/km_arm.c
index cb999b23fae..c772ee2a558 100644
--- a/board/keymile/km_arm/km_arm.c
+++ b/board/keymile/km_arm/km_arm.c
@@ -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[])
{
diff --git a/board/keymile/mgcoge/mgcoge.c b/board/keymile/mgcoge/mgcoge.c
index 7f487f109e9..7b346849bae 100644
--- a/board/keymile/mgcoge/mgcoge.c
+++ b/board/keymile/mgcoge/mgcoge.c
@@ -310,6 +310,7 @@ int last_stage_init(void)
puts("DIP: Enabled\n");
setenv("actual_bank", "0");
}
+ set_km_env();
return 0;
}