Patchwork [U-Boot,v3,3/8] arm/km: introduce bootcount env variable and clean km_arm

login
register
mail settings
Submitter Valentin Longchamp
Date May 4, 2011, 3:53 p.m.
Message ID <43265308dc62301b763b0eab7308d3043f1b922c.1304523385.git.valentin.longchamp@keymile.com>
Download mbox | patch
Permalink /patch/94081/
State Changes Requested
Delegated to: Albert ARIBAUD
Headers show

Comments

Valentin Longchamp - May 4, 2011, 3:53 p.m.
This environment variable is used to set the bootcount address
for the kernel.

last_stage_init is not available for arm platforms. So the
calls to set_km_var and set_bootcount_addr are done in
misc_init_r.

Additionally some unneeded printouts were removed.

Signed-off-by: Valentin Longchamp <valentin.longchamp@keymile.com>
Signed-off-by: Holger Brunck <holger.brunck@keymile.com>
Acked-by: Heiko Schocher <hs@denx.de>
cc: Wolfgang Denk <wd@denx.de>
cc: Detlev Zundel <dzu@denx.de>
cc: Prafulla Wadaskar <prafulla@marvell.com>
---
Changes for v2:
   - split up first large patch series to three independent smaller
     patch series
   - taken Wolfgang Denk's comments into account
Changes for v3:
   - taken Prafulla's comments into account, merged with previous 02/08 patch

 board/keymile/km_arm/km_arm.c |   28 +++++++++++++++-------------
 include/configs/km_arm.h      |    3 +++
 2 files changed, 18 insertions(+), 13 deletions(-)
Prafulla Wadaskar - May 12, 2011, 10:46 a.m.
> -----Original Message-----
> From: Valentin Longchamp [mailto:valentin.longchamp@keymile.com]
> Sent: Wednesday, May 04, 2011 9:24 PM
> To: u-boot@lists.denx.de
> Cc: holger.brunck@keymile.com; Prafulla Wadaskar; Valentin Longchamp;
> Wolfgang Denk; Detlev Zundel
> Subject: [PATCH v3 3/8] arm/km: introduce bootcount env variable and
> clean km_arm
> 
> This environment variable is used to set the bootcount address
> for the kernel.
> 
> last_stage_init is not available for arm platforms. So the
> calls to set_km_var and set_bootcount_addr are done in
> misc_init_r.
> 
> Additionally some unneeded printouts were removed.
> 
> Signed-off-by: Valentin Longchamp <valentin.longchamp@keymile.com>
> Signed-off-by: Holger Brunck <holger.brunck@keymile.com>
> Acked-by: Heiko Schocher <hs@denx.de>
> cc: Wolfgang Denk <wd@denx.de>
> cc: Detlev Zundel <dzu@denx.de>
> cc: Prafulla Wadaskar <prafulla@marvell.com>
> ---
> Changes for v2:
>    - split up first large patch series to three independent smaller
>      patch series
>    - taken Wolfgang Denk's comments into account
> Changes for v3:
>    - taken Prafulla's comments into account, merged with previous 02/08
> patch
> 
>  board/keymile/km_arm/km_arm.c |   28 +++++++++++++++-------------
>  include/configs/km_arm.h      |    3 +++
>  2 files changed, 18 insertions(+), 13 deletions(-)
> 
> diff --git a/board/keymile/km_arm/km_arm.c
> b/board/keymile/km_arm/km_arm.c
> index c772ee2..4049a4e 100644
> --- a/board/keymile/km_arm/km_arm.c
> +++ b/board/keymile/km_arm/km_arm.c
> @@ -145,16 +145,22 @@ int initialize_unit_leds(void)
>  	return 0;
>  }
> 
> +#if defined(CONFIG_BOOTCOUNT_LIMIT)
> +void set_bootcount_addr(void)
> +{
> +	uchar buf[32];
> +	unsigned int bootcountaddr;
> +	bootcountaddr = gd->ram_size - BOOTCOUNT_ADDR;
> +	sprintf((char *)buf, "0x%x", bootcountaddr);
> +	setenv("bootcountaddr", (char *)buf);
> +}
> +#endif
> +
>  int misc_init_r(void)
>  {
>  	char *str;
>  	int mach_type;
> 
> -	puts("Piggy:");
> -	if (ethernet_present() == 0)
> -		puts (" not");
> -	puts(" present\n");
> -
>  	str = getenv("mach_type");
>  	if (str != NULL) {
>  		mach_type = simple_strtoul(str, NULL, 10);
> @@ -163,7 +169,10 @@ int misc_init_r(void)
>  	}
> 
>  	initialize_unit_leds();
> -
> +	set_km_env();
> +#if defined(CONFIG_BOOTCOUNT_LIMIT)
> +	set_bootcount_addr();
> +#endif
>  	return 0;
>  }
> 
> @@ -182,7 +191,6 @@ int board_early_init_f(void)
>  	writel(tmp | FLASH_GPIO_PIN , KW_GPIO0_BASE);
>  	tmp = readl(KW_GPIO0_BASE + 4);
>  	writel(tmp & (~FLASH_GPIO_PIN) , KW_GPIO0_BASE + 4);
> -	printf("KM: setting NAND mode\n");
> 
>  #if defined(CONFIG_SOFT_I2C)
>  	/* init the GPIO for I2C Bitbang driver */
> @@ -212,12 +220,6 @@ 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/include/configs/km_arm.h b/include/configs/km_arm.h
> index 313a7f8..16199ef 100644
> --- a/include/configs/km_arm.h
> +++ b/include/configs/km_arm.h
> @@ -64,6 +64,9 @@
>  #define CONFIG_KM_KERNEL_ADDR	0x2000000	/* 4096KBytes */
> 
>  #define CONFIG_KM_DEF_ENV_CPU						\
> +	"addbootcount="							\
> +		"setenv bootargs ${bootargs} "				\
> +		"bootcountaddr=${bootcountaddr}\0"			\
>  	"addmtdparts=setenv bootargs ${bootargs} ${mtdparts}\0"		\
>  	"boot=bootm ${actual_kernel_addr} - -\0"			\
>  	"cramfsloadfdt=echo \\\\c\0"					\
> --

Acked-by: Prafulla Wadaskar <Prafulla@marvell.com>

Regards..
Prafulla . .

> 1.7.0.5

Patch

diff --git a/board/keymile/km_arm/km_arm.c b/board/keymile/km_arm/km_arm.c
index c772ee2..4049a4e 100644
--- a/board/keymile/km_arm/km_arm.c
+++ b/board/keymile/km_arm/km_arm.c
@@ -145,16 +145,22 @@  int initialize_unit_leds(void)
 	return 0;
 }
 
+#if defined(CONFIG_BOOTCOUNT_LIMIT)
+void set_bootcount_addr(void)
+{
+	uchar buf[32];
+	unsigned int bootcountaddr;
+	bootcountaddr = gd->ram_size - BOOTCOUNT_ADDR;
+	sprintf((char *)buf, "0x%x", bootcountaddr);
+	setenv("bootcountaddr", (char *)buf);
+}
+#endif
+
 int misc_init_r(void)
 {
 	char *str;
 	int mach_type;
 
-	puts("Piggy:");
-	if (ethernet_present() == 0)
-		puts (" not");
-	puts(" present\n");
-
 	str = getenv("mach_type");
 	if (str != NULL) {
 		mach_type = simple_strtoul(str, NULL, 10);
@@ -163,7 +169,10 @@  int misc_init_r(void)
 	}
 
 	initialize_unit_leds();
-
+	set_km_env();
+#if defined(CONFIG_BOOTCOUNT_LIMIT)
+	set_bootcount_addr();
+#endif
 	return 0;
 }
 
@@ -182,7 +191,6 @@  int board_early_init_f(void)
 	writel(tmp | FLASH_GPIO_PIN , KW_GPIO0_BASE);
 	tmp = readl(KW_GPIO0_BASE + 4);
 	writel(tmp & (~FLASH_GPIO_PIN) , KW_GPIO0_BASE + 4);
-	printf("KM: setting NAND mode\n");
 
 #if defined(CONFIG_SOFT_I2C)
 	/* init the GPIO for I2C Bitbang driver */
@@ -212,12 +220,6 @@  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/include/configs/km_arm.h b/include/configs/km_arm.h
index 313a7f8..16199ef 100644
--- a/include/configs/km_arm.h
+++ b/include/configs/km_arm.h
@@ -64,6 +64,9 @@ 
 #define CONFIG_KM_KERNEL_ADDR	0x2000000	/* 4096KBytes */
 
 #define CONFIG_KM_DEF_ENV_CPU						\
+	"addbootcount="							\
+		"setenv bootargs ${bootargs} "				\
+		"bootcountaddr=${bootcountaddr}\0"			\
 	"addmtdparts=setenv bootargs ${bootargs} ${mtdparts}\0"		\
 	"boot=bootm ${actual_kernel_addr} - -\0"			\
 	"cramfsloadfdt=echo \\\\c\0"					\