* Patch by Bernhard Kuhn, 28 Oct 2003:
  Add low boot support for MPC5200

* Fix problem with dual PCMCIA support (NSCU)

* Fix MPC5200 I2C initialization function
diff --git a/CHANGELOG b/CHANGELOG
index 16d7671..69ddff9 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,4 +1,15 @@
 ======================================================================
+Changes since U-Boot 1.0.0:
+======================================================================
+
+* Patch by Bernhard Kuhn, 28 Oct 2003:
+  Add low boot support for MPC5200
+
+* Fix problem with dual PCMCIA support (NSCU)
+
+* Fix MPC5200 I2C initialization function
+
+======================================================================
 Changes for U-Boot 1.0.0:
 ======================================================================
 
diff --git a/Makefile b/Makefile
index df2dfad..ef7e4fc 100644
--- a/Makefile
+++ b/Makefile
@@ -203,11 +203,21 @@
 #########################################################################
 ## MPC5xxx Systems
 #########################################################################
-MPC5200LITE		\
-icecube_5200_config	\
-IceCube_5200_config	\
+MPC5200LITE_config		\
+MPC5200LITE_LOWBOOT_config	\
+MPC5200LITE_LOWBOOT08_config	\
+icecube_5200_config		\
+IceCube_5200_config		\
 IceCube_5100_config:		unconfig
 	@ >include/config.h
+	@[ -z "$(findstring LOWBOOT,$@)" ] || \
+		{ echo "TEXT_BASE = 0xFF000000" >board/icecube/config.tmp ; \
+		  echo "... with LOWBOOT configuration" ; \
+		}
+	@[ -z "$(findstring LOWBOOT08,$@)" ] || \
+		{ echo "TEXT_BASE = 0xFF800000" >board/icecube/config.tmp ; \
+		  echo "... with 8 MB flash only" ; \
+		}
 	@[ -z "$(findstring 5200,$@)" ] || \
 		{ echo "#define CONFIG_MPC5200"		>>include/config.h ; \
 		  echo "... with MPC5200 processor" ; \
@@ -999,7 +1009,7 @@
 	rm -f tools/gdb/astest tools/gdb/gdbcont tools/gdb/gdbsend
 	rm -f tools/env/fw_printenv tools/env/fw_setenv
 	rm -f board/cray/L1/bootscript.c board/cray/L1/bootscript.image
-	rm -f board/trab/trab_fkt board/trab/config.tmp
+	rm -f board/trab/trab_fkt board/*/config.tmp
 
 clobber:	clean
 	find . -type f \
diff --git a/board/icecube/config.mk b/board/icecube/config.mk
index 9913cfb..07b5de1 100644
--- a/board/icecube/config.mk
+++ b/board/icecube/config.mk
@@ -22,10 +22,23 @@
 #
 
 #
-# IceCube board
+# IceCube board:
+#
+#	Valid values for TEXT_BASE are:
+#
+#	0xFFF00000   boot high (standard configuration)
+#	0xFF000000   boot low for 16 MiB boards
+#	0xFF800000   boot low for  8 MiB boards
+#	0x00100000   boot from RAM (for testing only)
 #
 
-TEXT_BASE = 0xfff00000
+sinclude $(TOPDIR)/board/$(BOARDDIR)/config.tmp
+
+ifndef TEXT_BASE
+## Standard: boot high
+TEXT_BASE = 0xFFF00000
+## For testing: boot from RAM
 # TEXT_BASE = 0x00100000
+endif
 
 PLATFORM_CPPFLAGS += -DTEXT_BASE=$(TEXT_BASE) -I$(TOPDIR)/board
diff --git a/board/icecube/icecube.c b/board/icecube/icecube.c
index 26cce5d..1b69d13 100644
--- a/board/icecube/icecube.c
+++ b/board/icecube/icecube.c
@@ -134,7 +134,7 @@
 	*(vu_long *)MPC5XXX_SDRAM_STOP = ((dramsize - 1) >> 15);
 #endif
 
-#else
+#else	/* CFG_RAMBOOT */
 #ifdef CONFIG_MGT5100
 	*(vu_long *)MPC5XXX_ADDECR |= (1 << 22); /* Enable SDRAM */
 	dramsize = ((*(vu_long *)MPC5XXX_SDRAM_STOP + 1) << 15);
diff --git a/common/cmd_ide.c b/common/cmd_ide.c
index 21a6666..45f6368 100644
--- a/common/cmd_ide.c
+++ b/common/cmd_ide.c
@@ -631,6 +631,7 @@
 #ifdef CONFIG_IDE_LED
 		int led = (IDE_BUS(i) == 0) ? LED_IDE1 : LED_IDE2;
 #endif
+		ide_dev_desc[i].type=DEV_TYPE_UNKNOWN;
 		ide_dev_desc[i].if_type=IF_TYPE_IDE;
 		ide_dev_desc[i].dev=i;
 		ide_dev_desc[i].part_type=PART_TYPE_UNKNOWN;
@@ -991,11 +992,9 @@
 		if (retries == 0) {
 			do_retry = 1;
 		} else {
-			dev_desc->type=DEV_TYPE_UNKNOWN;
 			return;
 		}
 #else
-		dev_desc->type=DEV_TYPE_UNKNOWN;
 		return;
 #endif	/* CONFIG_AMIGAONEG3SE */
 	}
diff --git a/cpu/mpc5xxx/i2c.c b/cpu/mpc5xxx/i2c.c
index ea37fb0..75c7739 100644
--- a/cpu/mpc5xxx/i2c.c
+++ b/cpu/mpc5xxx/i2c.c
@@ -229,9 +229,10 @@
 {
 	DECLARE_GLOBAL_DATA_PTR;
 	static int fdr = -1;
-	static int best_speed = 0;
 
 	if (fdr == -1) {
+		ulong best_speed = 0;
+		ulong divider;
 		ulong ipb, scl;
 		ulong bestmatch = 0xffffffffUL;
 		int best_i = 0, best_j = 0, i, j;
@@ -262,8 +263,13 @@
 				}
 			}
 		}
-		fdr = (best_i & 3) | ((best_i & 4) << 3) | (best_j << 2);
-		printf("%d kHz, ", best_speed / 1000);
+		divider = (best_i & 3) | ((best_i & 4) << 3) | (best_j << 2);
+		if (gd->flags & GD_FLG_RELOC) {
+			fdr = divider;
+		} else {
+			printf("%ld kHz, ", best_speed / 1000);
+			return divider;
+		}
 	}
 
 	return fdr;
diff --git a/cpu/mpc5xxx/start.S b/cpu/mpc5xxx/start.S
index 0557909..e0873ed 100644
--- a/cpu/mpc5xxx/start.S
+++ b/cpu/mpc5xxx/start.S
@@ -103,6 +103,47 @@
 boot_warm:
 	mfmsr	r5			/* save msr contents		*/
 
+#if defined(CFG_LOWBOOT)
+	lis	r4, CFG_DEFAULT_MBAR@h
+	lis	r3,     0x0000FF00@h
+	ori	r3, r3, 0x0000FF00@l
+	stw	r3, 0x4(r4)
+	lis	r3,     0x0000FFFF@h
+	ori	r3, r3, 0x0000FFFF@l
+	stw	r3, 0x8(r4)
+	lis	r3,     0x00047800@h
+	ori	r3, r3, 0x00047800@l
+	stw	r3, 0x300(r4)
+	lis	r3,     0x02010000@h
+	ori	r3, r3, 0x02010000@l
+	stw	r3, 0x54(r4)
+
+#if defined(CFG_LOWBOOT08)
+	lis	r3,     0xff800160@h
+	ori	r3, r3, 0xff800160@l
+#endif
+#if defined(CFG_LOWBOOT16)
+	lis	r3,     0xff000160@h
+	ori	r3, r3, 0xff000160@l
+#endif
+	mtlr	r3
+	blr
+lowboot_reentry:	/* FLASH_BASE + 0x160 */
+	
+	lis	r3,     0x0000FF00@h
+	ori	r3, r3, 0x0000FF00@l
+	stw	r3, 0x4c(r4)
+	lis	r3,     0x0000FFFF@h
+	ori	r3, r3, 0x0000FFFF@l
+	stw	r3, 0x50(r4)
+	lis	r3,     0x00047800@h
+	ori	r3, r3, 0x00047800@l
+	stw	r3, 0x300(r4)
+	lis	r3,     0x02000001@h
+	ori	r3, r3, 0x02000001@l
+	stw	r3, 0x54(r4)
+#endif	/* CFG_LOWBOOT */
+	
 #if defined(CFG_DEFAULT_MBAR) && !defined(CFG_RAMBOOT)
 	lis	r3, CFG_MBAR@h
 	ori	r3, r3, CFG_MBAR@l
diff --git a/include/configs/IceCube.h b/include/configs/IceCube.h
index 821d3b9..59abaef 100644
--- a/include/configs/IceCube.h
+++ b/include/configs/IceCube.h
@@ -90,12 +90,44 @@
 /* this must be included AFTER the definition of CONFIG_COMMANDS (if any) */
 #include <cmd_confdefs.h>
 
+#if (TEXT_BASE == 0xFF000000)		/* Boot low with 16 MB Flash */
+#   define CFG_LOWBOOT	        1
+#   define CFG_LOWBOOT16	1
+#endif
+#if (TEXT_BASE == 0xFF800000)		/* Boot low with  8 MB Flash */
+#   define CFG_LOWBOOT	        1
+#   define CFG_LOWBOOT08	1
+#endif
+
 /*
  * Autobooting
  */
 #define CONFIG_BOOTDELAY	5	/* autoboot after 5 seconds */
-#define CONFIG_BOOTCOMMAND	"bootm 100000"	/* autoboot command */
-#define CONFIG_BOOTARGS		"root=/dev/ram rw"
+
+#define CONFIG_PREBOOT	"echo;"	\
+	"echo Type \"run flash_nfs\" to mount root filesystem over NFS;" \
+	"echo"
+
+#undef	CONFIG_BOOTARGS
+
+#define	CONFIG_EXTRA_ENV_SETTINGS					\
+	"netdev=eth0\0"							\
+	"nfsargs=setenv bootargs root=/dev/nfs rw "			\
+		"nfsroot=$(serverip):$(rootpath)\0"			\
+	"ramargs=setenv bootargs root=/dev/ram rw\0"			\
+	"addip=setenv bootargs $(bootargs) "				\
+		"ip=$(ipaddr):$(serverip):$(gatewayip):$(netmask)"	\
+		":$(hostname):$(netdev):off panic=1\0"			\
+	"flash_nfs=run nfsargs addip;"					\
+		"bootm $(kernel_addr)\0"				\
+	"flash_self=run ramargs addip;"					\
+		"bootm $(kernel_addr) $(ramdisk_addr)\0"		\
+	"net_nfs=tftp 200000 $(bootfile);run nfsargs addip;bootm\0"	\
+	"rootpath=/opt/eldk/ppc_82xx\0"					\
+	"bootfile=/tftpboot/MPC5200/uImage\0"				\
+	""
+
+#define CONFIG_BOOTCOMMAND	"run flash_self"
 
 #if defined(CONFIG_MPC5200)
 /*
@@ -123,19 +155,19 @@
 /*
  * Flash configuration
  */
-#define CFG_FLASH_16M		1
-
-#if !defined(CFG_FLASH_16M) /* 8Mb chips support only */
-#define CFG_FLASH_BASE		0xff800000
-#define CFG_FLASH_SIZE		0x00800000
-#define CFG_MAX_FLASH_BANKS	1	/* max num of memory banks      */
-#define CFG_ENV_ADDR		(CFG_FLASH_BASE + 0x740000)
-#else
 #define CFG_FLASH_BASE		0xff000000
 #define CFG_FLASH_SIZE		0x01000000
+#if !defined(CFG_LOWBOOT)
 #define CFG_ENV_ADDR		(CFG_FLASH_BASE + 0x740000 + 0x800000)
-#define CFG_MAX_FLASH_BANKS	2	/* max num of memory banks      */
+#else	/* CFG_LOWBOOT */
+#if defined(CFG_LOWBOOT08)
+#define CFG_ENV_ADDR		(CFG_FLASH_BASE + 0x30000 + 0x800000)
 #endif
+#if defined(CFG_LOWBOOT16)
+#define CFG_ENV_ADDR		(CFG_FLASH_BASE + 0x30000)
+#endif
+#endif	/* CFG_LOWBOOT */
+#define CFG_MAX_FLASH_BANKS	2	/* max num of memory banks      */
 
 #define CFG_MAX_FLASH_SECT	128	/* max num of sects on one chip */
 
diff --git a/include/version.h b/include/version.h
index b4ee13a..e61a03c 100644
--- a/include/version.h
+++ b/include/version.h
@@ -24,6 +24,6 @@
 #ifndef	__VERSION_H__
 #define	__VERSION_H__
 
-#define	U_BOOT_VERSION	"U-Boot 1.0.0"
+#define	U_BOOT_VERSION	"U-Boot 1.0.1"
 
 #endif	/* __VERSION_H__ */