From patchwork Tue Mar 8 13:30:14 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Heiko Schocher X-Patchwork-Id: 86001 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from theia.denx.de (theia.denx.de [85.214.87.163]) by ozlabs.org (Postfix) with ESMTP id D0299B70CE for ; Wed, 9 Mar 2011 00:41:59 +1100 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id B966E28124; Tue, 8 Mar 2011 14:40:10 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at theia.denx.de Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id AwjHz6fxunu6; Tue, 8 Mar 2011 14:40:10 +0100 (CET) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 9400528140; Tue, 8 Mar 2011 14:38:38 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id E9345280E8 for ; Tue, 8 Mar 2011 14:38:16 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at theia.denx.de Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id js7pr8YIaRhm for ; Tue, 8 Mar 2011 14:38:16 +0100 (CET) X-policyd-weight: IN_SBL_XBL_SPAMHAUS=4.35 NOT_IN_SPAMCOP=-1.5 NOT_IN_BL_NJABL=-1.5 (only DNSBL check requested) Received: from pollux.denx.de (p4FF0750E.dip.t-dialin.net [79.240.117.14]) by theia.denx.de (Postfix) with ESMTP id 073DC280B5 for ; Tue, 8 Mar 2011 14:38:09 +0100 (CET) Received: by pollux.denx.de (Postfix, from userid 515) id B5E7C18015DF7; Tue, 8 Mar 2011 14:30:32 +0100 (CET) From: Heiko Schocher To: u-boot@lists.denx.de Date: Tue, 8 Mar 2011 14:30:14 +0100 Message-Id: <1299591018-8944-17-git-send-email-hs@denx.de> X-Mailer: git-send-email 1.7.4 In-Reply-To: <1299591018-8944-1-git-send-email-hs@denx.de> References: <1299591018-8944-1-git-send-email-hs@denx.de> Cc: Valentin Longchamp , Kim Phillips , Holger Brunck , Heiko Schocher Subject: [U-Boot] [PATCH 16/20] keymile, common: add setting of some environment variables X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.9 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: u-boot-bounces@lists.denx.de Errors-To: u-boot-bounces@lists.denx.de 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 Signed-off-by: Heiko Schocher cc: Valentin Longchamp cc: Wolfgang Denk cc: Kim Phillips --- board/keymile/common/common.c | 35 +++++++++++++++++++++++++++++++++++ board/keymile/common/common.h | 1 + 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(+), 0 deletions(-) diff --git a/board/keymile/common/common.c b/board/keymile/common/common.c index 6136884..25c4539 100644 --- a/board/keymile/common/common.c +++ b/board/keymile/common/common.c @@ -42,6 +42,7 @@ extern int i2c_soft_read_pin (void); extern int i2c_make_abort (void); +extern unsigned int arch_ram_size(void); int ivm_calc_crc (unsigned char *buf, int len) { @@ -73,6 +74,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 8fd3125..acf19af 100644 --- a/board/keymile/common/common.h +++ b/board/keymile/common/common.h @@ -22,6 +22,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 c625b5d..1ee5ee0 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[] = { @@ -177,6 +179,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 3dc63ea..1b5426a 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 44dc7a5..e932633 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 33f2af2..142a6a1 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 1 +#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 578438e..cb14ada 100644 --- a/include/configs/km_arm.h +++ b/include/configs/km_arm.h @@ -251,4 +251,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 */