board: lsxl: make last resort recovery more reliable

If something is wrong with the environment, we cannot rely on a proper
u-boot operation anymore. In fact, it is possible, that we never reach
misc_init_r() with a broken environment.

Also don't enable the netconsole by environment settings. This way the
user don't have to reconfigure the environment. Instead the network
console is only enabled when the push button is pressed during boot.

Signed-off-by: Michael Walle <michael@walle.cc>
Reviewed-by: Stefan Roese <sr@denx.de>
diff --git a/arch/arm/mach-kirkwood/Kconfig b/arch/arm/mach-kirkwood/Kconfig
index f5460f3..c8a193d 100644
--- a/arch/arm/mach-kirkwood/Kconfig
+++ b/arch/arm/mach-kirkwood/Kconfig
@@ -45,6 +45,7 @@
 	bool "lsxl Board"
 	select FEROCEON_88FR131
 	select KW88F6281
+	select BOARD_EARLY_INIT_R
 	select MISC_INIT_R
 
 config TARGET_POGO_E02
diff --git a/board/buffalo/lsxl/lsxl.c b/board/buffalo/lsxl/lsxl.c
index eca7da2..7fab5fb 100644
--- a/board/buffalo/lsxl/lsxl.c
+++ b/board/buffalo/lsxl/lsxl.c
@@ -42,6 +42,8 @@
 
 DECLARE_GLOBAL_DATA_PTR;
 
+static bool force_rescue_mode;
+
 int board_early_init_f(void)
 {
 	/*
@@ -247,14 +249,22 @@
 	if (i >= 100)
 		erase_environment();
 	else if (i >= 10)
-		rescue_mode();
+		force_rescue_mode = true;
+}
+
+int board_early_init_r(void)
+{
+	check_push_button();
+
+	return 0;
 }
 
 int misc_init_r(void)
 {
 	check_power_switch();
 	check_enetaddr();
-	check_push_button();
+	if (force_rescue_mode)
+		rescue_mode();
 
 	return 0;
 }
diff --git a/configs/lschlv2_defconfig b/configs/lschlv2_defconfig
index f4ffb9c..b3ad20c 100644
--- a/configs/lschlv2_defconfig
+++ b/configs/lschlv2_defconfig
@@ -29,7 +29,6 @@
 CONFIG_BOOTARGS="console=ttyS0,115200 root=/dev/sda2"
 CONFIG_BOOTCOMMAND="run bootcmd_${bootsource}"
 CONFIG_DEFAULT_FDT_FILE="kirkwood-lschlv2.dtb"
-CONFIG_SYS_CONSOLE_IS_IN_ENV=y
 CONFIG_SYS_CONSOLE_INFO_QUIET=y
 # CONFIG_DISPLAY_BOARDINFO is not set
 CONFIG_SYS_MAXARGS=32
diff --git a/configs/lsxhl_defconfig b/configs/lsxhl_defconfig
index e8fb87d..747a224 100644
--- a/configs/lsxhl_defconfig
+++ b/configs/lsxhl_defconfig
@@ -30,7 +30,6 @@
 CONFIG_BOOTARGS="console=ttyS0,115200 root=/dev/sda2"
 CONFIG_BOOTCOMMAND="run bootcmd_${bootsource}"
 CONFIG_DEFAULT_FDT_FILE="kirkwood-lsxhl.dtb"
-CONFIG_SYS_CONSOLE_IS_IN_ENV=y
 CONFIG_SYS_CONSOLE_INFO_QUIET=y
 # CONFIG_DISPLAY_BOARDINFO is not set
 CONFIG_SYS_MAXARGS=32
diff --git a/include/configs/lsxl.h b/include/configs/lsxl.h
index 162f077..4d5908d 100644
--- a/include/configs/lsxl.h
+++ b/include/configs/lsxl.h
@@ -57,17 +57,7 @@
 		"&& setenv ncip "					\
 		"&& setenv autoload ${autoload_old}; "			\
 		"setenv autoload_old\0"					\
-	"standard_env=setenv ipaddr; setenv netmask; setenv serverip; "	\
-		"setenv ncip; setenv gatewayip; setenv ethact; "	\
-		"setenv bootfile; setenv dnsip; "			\
-		"setenv bootsource legacy; run ser\0"			\
-	"restore_env=run standard_env; saveenv; reset\0"		\
-	"ser=setenv stdin serial; setenv stdout serial; "		\
-		"setenv stderr serial\0"				\
 	"nc=setenv stdin nc; setenv stdout nc; setenv stderr nc\0"	\
-	"stdin=serial\0"						\
-	"stdout=serial\0"						\
-	"stderr=serial\0"
 
 /*
  * Ethernet Driver configuration