Merge branch 'master' of git://www.denx.de/git/u-boot-freebsd
diff --git a/Makefile b/Makefile
index a731ee8..2790865 100644
--- a/Makefile
+++ b/Makefile
@@ -244,7 +244,7 @@
 LIBS += api/libapi.a
 
 LIBS := $(addprefix $(obj),$(LIBS))
-.PHONY : $(LIBS)
+.PHONY : $(LIBS) $(VERSION_FILE)
 
 # Add GCC lib
 PLATFORM_LIBS += -L $(shell dirname `$(CC) $(CFLAGS) -print-libgcc-file-name`) -lgcc
@@ -326,6 +326,9 @@
 $(SUBDIRS):	depend $(obj)include/autoconf.mk
 		$(MAKE) -C $@ all
 
+$(LDSCRIPT):	depend $(obj)include/autoconf.mk
+		$(MAKE) -C $(dir $@) $(notdir $@)
+
 $(NAND_SPL):	$(VERSION_FILE)	$(obj)include/autoconf.mk
 		$(MAKE) -C nand_spl/board/$(BOARDDIR) all
 
@@ -411,6 +414,7 @@
 # to regenerate the autoconf.mk file.
 $(obj)include/autoconf.mk: $(obj)include/config.h $(VERSION_FILE)
 	@$(XECHO) Generating include/autoconf.mk ; \
+	set -e ; \
 	: Generate the dependancies ; \
 	$(CC) -M $(HOST_CFLAGS) $(CPPFLAGS) -MQ $@ include/common.h > $@.dep ; \
 	: Extract the config macros ; \
@@ -1921,7 +1925,7 @@
 	M5485EFE_config)	BOOT=2;CODE=0;VID=1;USB=1;RAM=64;RAM1=0;; \
 	M5485FFE_config)	BOOT=2;CODE=32;VID=1;USB=1;RAM=64;RAM1=64;; \
 	M5485GFE_config)	BOOT=4;CODE=0;VID=0;USB=0;RAM=64;RAM1=0;; \
-	M5485HFE_config)	BOOT=2;CODE=;VID=1;USB=0;RAM=64;RAM1=0;; \
+	M5485HFE_config)	BOOT=2;CODE=16;VID=1;USB=0;RAM=64;RAM1=0;; \
 	esac; \
 	>include/config.h ; \
 	echo "#define CFG_BUSCLK	100000000" > $(obj)include/config.h ; \
diff --git a/board/apollon/mem.c b/board/apollon/mem.c
index c0edca5..0211c6a 100644
--- a/board/apollon/mem.c
+++ b/board/apollon/mem.c
@@ -198,6 +198,8 @@
 	sdelay(2000);
 
 	/* setup cs2 */
+	__raw_writel(0x0, GPMC_CONFIG7_2);	/* disable current map */
+	sdelay(1000);
 	__raw_writel(APOLLON_24XX_GPMC_CONFIG1_0 | mux | mtype | mwidth,
 		     GPMC_CONFIG1_2);
 	/* It's same as cs 0 */
diff --git a/board/qemu-mips/Makefile b/board/qemu-mips/Makefile
index 23be447..837b6b9 100644
--- a/board/qemu-mips/Makefile
+++ b/board/qemu-mips/Makefile
@@ -25,7 +25,7 @@
 
 LIB	= $(obj)lib$(BOARD).a
 
-COBJS	= $(BOARD).o flash.o
+COBJS	= $(BOARD).o
 SOBJS	= lowlevel_init.o
 
 SRCS	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
diff --git a/board/qemu-mips/flash.c b/board/qemu-mips/flash.c
deleted file mode 100644
index e988272..0000000
--- a/board/qemu-mips/flash.c
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * (C) Copyright 2003
- * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
- *
- * See file CREDITS for list of people who contributed to this
- * project.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of
- * the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
- * MA 02111-1307 USA
- */
-
-#include <common.h>
-/*-----------------------------------------------------------------------
- * flash_init()
- *
- * sets up flash_info and returns size of FLASH (bytes)
- */
-unsigned long flash_init(void)
-{
-	printf("Skipping flash_init\n");
-	return(0);
-}
-
-int write_buff(void *info, uchar *src, ulong addr, ulong cnt)
-{
-	printf("write_buff not implemented\n");
-	return(-1);
-}
diff --git a/config.mk b/config.mk
index ee057b5..22d3398 100644
--- a/config.mk
+++ b/config.mk
@@ -69,6 +69,9 @@
 endif
 endif
 
+# Load generated board configuration
+sinclude $(OBJTREE)/include/autoconf.mk
+
 ifdef	ARCH
 sinclude $(TOPDIR)/$(ARCH)_config.mk	# include architecture dependend rules
 endif
@@ -87,9 +90,6 @@
 sinclude $(TOPDIR)/board/$(BOARDDIR)/config.mk	# include board specific rules
 endif
 
-# Load generated board configuration
-sinclude $(OBJTREE)/include/autoconf.mk
-
 #########################################################################
 
 CONFIG_SHELL	:= $(shell if [ -x "$$BASH" ]; then echo $$BASH; \
diff --git a/cpu/mcf52x2/interrupts.c b/cpu/mcf52x2/interrupts.c
index 2ccbde5..9167cec 100644
--- a/cpu/mcf52x2/interrupts.c
+++ b/cpu/mcf52x2/interrupts.c
@@ -77,7 +77,7 @@
 	volatile int0_t *intp = (int0_t *) (CFG_INTR_BASE);
 
 	intp->icr0[CFG_TMRINTR_NO] = CFG_TMRINTR_PRI;
-	intp->imrl0 &= ~0xFFFFFFFE;
+	intp->imrl0 &= 0xFFFFFFFE;
 	intp->imrl0 &= ~CFG_TMRINTR_MASK;
 }
 #endif				/* CONFIG_MCFTMR */
diff --git a/drivers/net/uli526x.c b/drivers/net/uli526x.c
index 8460f69..d64845f 100644
--- a/drivers/net/uli526x.c
+++ b/drivers/net/uli526x.c
@@ -32,9 +32,9 @@
 #define ULI5261_DEVICE_ID	0x5261
 #define ULI5263_DEVICE_ID	0x5263
 /* ULi M5261 ID*/
-#define PCI_ULI5261_ID		ULI5261_DEVICE_ID << 16 | ULI_VENDOR_ID
+#define PCI_ULI5261_ID		(ULI5261_DEVICE_ID << 16 | ULI_VENDOR_ID)
 /* ULi M5263 ID*/
-#define PCI_ULI5263_ID		ULI5263_DEVICE_ID << 16 | ULI_VENDOR_ID
+#define PCI_ULI5263_ID		(ULI5263_DEVICE_ID << 16 | ULI_VENDOR_ID)
 
 #define ULI526X_IO_SIZE	0x100
 #define TX_DESC_CNT	0x10		/* Allocated Tx descriptors */
@@ -281,7 +281,7 @@
 	if (db->desc_pool_ptr == NULL)
 		return -1;
 
-	db->buf_pool_ptr = &buf_pool[0];
+	db->buf_pool_ptr = (uchar *)&buf_pool[0];
 	db->buf_pool_dma_ptr = (dma_addr_t)&buf_pool[0];
 	if (db->buf_pool_ptr == NULL)
 		return -1;
@@ -588,7 +588,7 @@
 					__FUNCTION__, i, rxptr->rx_buf_ptr[i]);
 #endif
 
-				NetReceive(rxptr->rx_buf_ptr, rxlen);
+				NetReceive((uchar *)rxptr->rx_buf_ptr, rxlen);
 				uli526x_reuse_buf(rxptr);
 
 			} else {
@@ -656,7 +656,7 @@
 	tmp_tx_dma = db->first_tx_desc_dma;
 	for (tmp_tx = db->first_tx_desc, i = 0;
 			i < TX_DESC_CNT; i++, tmp_tx++) {
-		tmp_tx->tx_buf_ptr = tmp_buf;
+		tmp_tx->tx_buf_ptr = (char *)tmp_buf;
 		tmp_tx->tdes0 = cpu_to_le32(0);
 		tmp_tx->tdes1 = cpu_to_le32(0x81000000);	/* IC, chain */
 		tmp_tx->tdes2 = cpu_to_le32(tmp_buf_dma);
diff --git a/include/asm-ppc/fsl_law.h b/include/asm-ppc/fsl_law.h
index 23bd505..e955c75 100644
--- a/include/asm-ppc/fsl_law.h
+++ b/include/asm-ppc/fsl_law.h
@@ -3,7 +3,6 @@
 
 #include <asm/io.h>
 
-#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
 #define SET_LAW_ENTRY(idx, a, sz, trgt) \
 	{ .index = idx, .addr = a, .size = sz, .trgt_id = trgt }
 
diff --git a/include/asm-ppc/mmu.h b/include/asm-ppc/mmu.h
index ec1ca53..5af22af 100644
--- a/include/asm-ppc/mmu.h
+++ b/include/asm-ppc/mmu.h
@@ -427,7 +427,6 @@
 extern void invalidate_tlb(u8 tlb);
 extern void init_tlbs(void);
 
-#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
 #define SET_TLB_ENTRY(_tlb, _epn, _rpn, _perms, _wimge, _ts, _esel, _sz, _iprot) \
 	{ .tlb = _tlb, .epn = _epn, .rpn = _rpn, .perms = _perms, \
 	  .wimge = _wimge, .ts = _ts, .esel = _esel, .tsize = _sz, .iprot = _iprot }
diff --git a/lib_mips/board.c b/lib_mips/board.c
index c1a0acf..1645f2c 100644
--- a/lib_mips/board.c
+++ b/lib_mips/board.c
@@ -121,12 +121,13 @@
 	return (0);
 }
 
+#ifndef CFG_NO_FLASH
 static void display_flash_config(ulong size)
 {
 	puts ("Flash: ");
 	print_size (size, "\n");
 }
-
+#endif
 
 static int init_baudrate (void)
 {
@@ -247,7 +248,7 @@
 	debug ("Reserving %d Bytes for Global Data at: %08lx\n",
 			sizeof (gd_t), addr_sp);
 
- 	/* Reserve memory for boot params.
+	/* Reserve memory for boot params.
 	 */
 	addr_sp -= CFG_BOOTPARAMS_LEN;
 	bd->bi_boot_params = addr_sp;
@@ -301,7 +302,9 @@
 void board_init_r (gd_t *id, ulong dest_addr)
 {
 	cmd_tbl_t *cmdtp;
+#ifndef CFG_NO_FLASH
 	ulong size;
+#endif
 	extern void malloc_bin_reloc (void);
 #ifndef CFG_ENV_IS_NOWHERE
 	extern char * env_name_spec;
@@ -322,7 +325,7 @@
 	/*
 	 * We have to relocate the command table manually
 	 */
- 	for (cmdtp = &__u_boot_cmd_start; cmdtp !=  &__u_boot_cmd_end; cmdtp++) {
+	for (cmdtp = &__u_boot_cmd_start; cmdtp !=  &__u_boot_cmd_end; cmdtp++) {
 		ulong addr;
 
 		addr = (ulong) (cmdtp->cmd) + gd->reloc_off;
@@ -352,13 +355,16 @@
 	env_name_spec += gd->reloc_off;
 #endif
 
+	bd = gd->bd;
+
+#ifndef CFG_NO_FLASH
 	/* configure available FLASH banks */
 	size = flash_init();
 	display_flash_config (size);
-
-	bd = gd->bd;
-	bd->bi_flashstart = CFG_FLASH_BASE;
 	bd->bi_flashsize = size;
+#endif
+
+	bd->bi_flashstart = CFG_FLASH_BASE;
 #if CFG_MONITOR_BASE == CFG_FLASH_BASE
 	bd->bi_flashoffset = monitor_flash_len;	/* reserved area for U-Boot */
 #else
diff --git a/lib_ppc/board.c b/lib_ppc/board.c
index 45d1328..fbf1c5d 100644
--- a/lib_ppc/board.c
+++ b/lib_ppc/board.c
@@ -361,6 +361,20 @@
 	NULL,			/* Terminate this list */
 };
 
+#ifndef CONFIG_MAX_MEM_MAPPED
+#define CONFIG_MAX_MEM_MAPPED (256 << 20)
+#endif
+ulong get_effective_memsize(void)
+{
+#ifndef	CONFIG_VERY_BIG_RAM
+	return gd->ram_size;
+#else
+	/* limit stack to what we can reasonable map */
+	return ((gd->ram_size > CONFIG_MAX_MEM_MAPPED) ?
+		 CONFIG_MAX_MEM_MAPPED : gd->ram_size);
+#endif
+}
+
 /************************************************************************
  *
  * This is the first part of the initialization sequence that is
@@ -419,13 +433,7 @@
 	 */
 	len = (ulong)&_end - CFG_MONITOR_BASE;
 
-#ifndef	CONFIG_VERY_BIG_RAM
-	addr = CFG_SDRAM_BASE + gd->ram_size;
-#else
-	/* only allow stack below 256M */
-	addr = CFG_SDRAM_BASE +
-	       (gd->ram_size > 256 << 20) ? 256 << 20 : gd->ram_size;
-#endif
+	addr = CFG_SDRAM_BASE + get_effective_memsize();
 
 #ifdef CONFIG_LOGBUFFER
 	/* reserve kernel log buffer */
diff --git a/post/lib_ppc/asm.S b/post/lib_ppc/asm.S
index 5e72b34..1279176 100644
--- a/post/lib_ppc/asm.S
+++ b/post/lib_ppc/asm.S
@@ -308,7 +308,10 @@
 	lwz	r3, 0(r4)
 	lwz	r4, 0(r5)
 	mr	r6, r7
+
+	mfcr	r7
 	blrl
+	mtcr	r7
 
 	lwz	r7, 8(r1)
 	stw	r3, 0(r7)
diff --git a/tools/easylogo/easylogo.c b/tools/easylogo/easylogo.c
index 080bea9..c20e6a7 100644
--- a/tools/easylogo/easylogo.c
+++ b/tools/easylogo/easylogo.c
@@ -7,6 +7,8 @@
 ** This is still under construction!
 */
 
+#include <getopt.h>
+#include <stdbool.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
@@ -216,15 +218,10 @@
 	return 0;
 }
 
-int image_free (image_t * image)
+void image_free (image_t * image)
 {
-	if (image->data != NULL)
-		free (image->data);
-
-	if (image->palette != NULL)
-		free (image->palette);
-
-	return 0;
+	free (image->data);
+	free (image->palette);
 }
 
 int image_rgb_to_yuyv (image_t * rgb_image, image_t * yuyv_image)
@@ -353,59 +350,76 @@
 
 #define DEF_FILELEN	256
 
+static void usage (int exit_status)
+{
+	puts (
+		"EasyLogo 1.0 (C) 2000 by Paolo Scaffardi\n"
+		"\n"
+		"Syntax:	easylogo [options] inputfile [outputvar [outputfile]]\n"
+		"\n"
+		"Options:\n"
+		"  -r     Output RGB instead of YUYV\n"
+		"  -h     Help output\n"
+		"\n"
+		"Where: 'inputfile'   is the TGA image to load\n"
+		"       'outputvar'   is the variable name to create\n"
+		"       'outputfile'  is the output header file (default is 'inputfile.h')"
+	);
+	exit (exit_status);
+}
+
 int main (int argc, char *argv[])
 {
+	int c;
+	bool use_rgb = false;
 	char inputfile[DEF_FILELEN],
 		outputfile[DEF_FILELEN], varname[DEF_FILELEN];
 
 	image_t rgb_logo, yuyv_logo;
 
-	switch (argc) {
-	case 2:
-	case 3:
-	case 4:
-		strcpy (inputfile, argv[1]);
-
-		if (argc > 2)
-			strcpy (varname, argv[2]);
-		else {
-			char *dot = strchr (inputfile, '.');
-			int pos = dot - inputfile;
-
-			if (dot) {
-				strncpy (varname, inputfile, pos);
-				varname[pos] = 0;
-			}
+	while ((c = getopt(argc, argv, "hr")) > 0) {
+		switch (c) {
+		case 'h':
+			usage (0);
+			break;
+		case 'r':
+			use_rgb = true;
+			puts ("Using 24-bit RGB Output Fromat");
+			break;
+		default:
+			usage (1);
+			break;
 		}
-
-		if (argc > 3)
-			strcpy (outputfile, argv[3]);
-		else {
-			char *dot = strchr (varname, '.');
-			int pos = dot - varname;
-
-			if (dot) {
-				char app[DEF_FILELEN];
-
-				strncpy (app, varname, pos);
-				app[pos] = 0;
-				sprintf (outputfile, "%s.h", app);
-			}
-		}
-		break;
-
-	default:
-		printf ("EasyLogo 1.0 (C) 2000 by Paolo Scaffardi\n\n");
-
-		printf("Syntax:	easylogo inputfile [outputvar {outputfile}] \n");
-		printf("\n");
-		printf("Where:	'inputfile' 	is the TGA image to load\n");
-		printf("      	'outputvar' 	is the variable name to create\n");
-		printf("       	'outputfile' 	is the output header file (default is 'inputfile.h')\n");
-
-		return -1;
 	}
 
+	c = argc - optind;
+	if (c > 4 || c < 1)
+		usage (1);
+
+	strcpy (inputfile, argv[optind]);
+
+	if (c > 1)
+		strcpy (varname, argv[optind + 1]);
+	else {
+		/* transform "input.tga" to just "input" */
+		char *dot;
+		strcpy (varname, inputfile);
+		dot = strchr (varname, '.');
+		if (dot)
+			*dot = '\0';
+	}
+
+	if (c > 2)
+		strcpy (outputfile, argv[optind + 2]);
+	else {
+		/* just append ".h" to input file name */
+		strcpy (outputfile, inputfile);
+		strcat (outputfile, ".h");
+	}
+
+	/* Make sure the output is sent as soon as we printf() */
+	setbuf(stdout, NULL);
+
 	printf ("Doing '%s' (%s) from '%s'...",
 		outputfile, varname, inputfile);
 
@@ -417,20 +431,23 @@
 		exit (1);
 	}
 
-	/* Convert it to YUYV format */
+	/* Convert it to YUYV format if wanted */
 
-	printf ("C");
-	image_rgb_to_yuyv (&rgb_logo, &yuyv_logo);
+	if (!use_rgb) {
+		printf ("C");
+		image_rgb_to_yuyv (&rgb_logo, &yuyv_logo);
+	}
 
 	/* Save it into a header format */
 
 	printf ("S");
-	image_save_header (&yuyv_logo, outputfile, varname);
+	image_save_header (use_rgb ? &rgb_logo : &yuyv_logo, outputfile, varname);
 
 	/* Free original image and copy */
 
 	image_free (&rgb_logo);
-	image_free (&yuyv_logo);
+	if (!use_rgb)
+		image_free (&yuyv_logo);
 
 	printf ("\n");