Merge branch 'master' of git://www.denx.de/git/u-boot-fdt
diff --git a/README b/README
index 8a8915d..5d059e7 100644
--- a/README
+++ b/README
@@ -372,19 +372,6 @@
 
 		boards with QUICC Engines require OF_QE to set UCC mac addresses
 
-		CONFIG_OF_HAS_BD_T
-
-		 * CONFIG_OF_LIBFDT - enables the "fdt bd_t" command
-		 * CONFIG_OF_FLAT_TREE - The resulting flat device tree
-		     will have a copy of the bd_t.  Space should be
-		     pre-allocated in the dts for the bd_t.
-
-		CONFIG_OF_HAS_UBOOT_ENV
-
-		 * CONFIG_OF_LIBFDT - enables the "fdt env" command
-		 * CONFIG_OF_FLAT_TREE - The resulting flat device tree
-		     will have a copy of u-boot's environment variables
-
 		CONFIG_OF_BOARD_SETUP
 
 		Board code has addition modification that it wants to make
diff --git a/common/cmd_fdt.c b/common/cmd_fdt.c
index a52284e..7436a95 100644
--- a/common/cmd_fdt.c
+++ b/common/cmd_fdt.c
@@ -42,8 +42,7 @@
 DECLARE_GLOBAL_DATA_PTR;
 
 static int fdt_valid(void);
-static int fdt_parse_prop(char *pathp, char *prop, char *newval,
-	char *data, int *len);
+static int fdt_parse_prop(char **newval, int count, char *data, int *len);
 static int fdt_print(const char *pathp, char *prop, int depth);
 
 /*
@@ -202,7 +201,7 @@
 		if (argc == 4) {
 			len = 0;
 		} else {
-			ret = fdt_parse_prop(pathp, prop, argv[4], data, &len);
+			ret = fdt_parse_prop(&argv[4], argc - 4, data, &len);
 			if (ret != 0)
 				return ret;
 		}
@@ -464,69 +463,77 @@
 
 /*
  * Parse the user's input, partially heuristic.  Valid formats:
- * <00>		- hex byte
- * <0011>	- hex half word (16 bits)
- * <00112233>	- hex word (32 bits)
- *		- hex double words (64 bits) are not supported, must use
- *			a byte stream instead.
+ * <0x00112233 4 05>	- an array of cells.  Numbers follow standard
+ * 			C conventions.
  * [00 11 22 .. nn] - byte stream
  * "string"	- If the the value doesn't start with "<" or "[", it is
  *			treated as a string.  Note that the quotes are
  *			stripped by the parser before we get the string.
+ * newval: An array of strings containing the new property as specified
+ * 	on the command line
+ * count: The number of strings in the array
+ * data: A bytestream to be placed in the property
+ * len: The length of the resulting bytestream
  */
-static int fdt_parse_prop(char *pathp, char *prop, char *newval,
-	char *data, int *len)
+static int fdt_parse_prop(char **newval, int count, char *data, int *len)
 {
 	char *cp;		/* temporary char pointer */
+	char *newp;		/* temporary newval char pointer */
 	unsigned long tmp;	/* holds converted values */
+	int stridx = 0;
 
-	if (*newval == '<') {
-		/*
-		 * Bigger values than bytes.
-		 */
-		*len = 0;
-		newval++;
-		while ((*newval != '>') && (*newval != '\0')) {
-			cp = newval;
-			tmp = simple_strtoul(cp, &newval, 16);
-			if ((newval - cp) <= 2) {
-				*data = tmp & 0xFF;
-				data  += 1;
-				*len += 1;
-			} else if ((newval - cp) <= 4) {
-				*(uint16_t *)data = __cpu_to_be16(tmp);
-				data  += 2;
-				*len += 2;
-			} else if ((newval - cp) <= 8) {
-				*(uint32_t *)data = __cpu_to_be32(tmp);
-				data  += 4;
-				*len += 4;
-			} else {
+	*len = 0;
+	newp = newval[0];
+
+	/* An array of cells */
+	if (*newp == '<') {
+		newp++;
+		while ((*newp != '>') && (stridx < count)) {
+			/*
+			 * Keep searching until we find that last ">"
+			 * That way users don't have to escape the spaces
+			 */
+			if (*newp == '\0') {
+				newp = newval[++stridx];
+				continue;
+			}
+
+			cp = newp;
+			tmp = simple_strtoul(cp, &newp, 0);
+			*(uint32_t *)data = __cpu_to_be32(tmp);
+			data  += 4;
+			*len += 4;
+
+			/* If the ptr didn't advance, something went wrong */
+			if ((newp - cp) <= 0) {
 				printf("Sorry, I could not convert \"%s\"\n",
 					cp);
 				return 1;
 			}
-			while (*newval == ' ')
-				newval++;
+
+			while (*newp == ' ')
+				newp++;
 		}
-		if (*newval != '>') {
-			printf("Unexpected character '%c'\n", *newval);
+
+		if (*newp != '>') {
+			printf("Unexpected character '%c'\n", *newp);
 			return 1;
 		}
-	} else if (*newval == '[') {
+	} else if (*newp == '[') {
 		/*
 		 * Byte stream.  Convert the values.
 		 */
-		*len = 0;
-		newval++;
-		while ((*newval != ']') && (*newval != '\0')) {
-			tmp = simple_strtoul(newval, &newval, 16);
+		newp++;
+		while ((*newp != ']') && (stridx < count)) {
+			tmp = simple_strtoul(newp, &newp, 16);
 			*data++ = tmp & 0xFF;
 			*len    = *len + 1;
-			while (*newval == ' ')
-				newval++;
+			while (*newp == ' ')
+				newp++;
+			if (*newp != '\0')
+				newp = newval[++stridx];
 		}
-		if (*newval != ']') {
+		if (*newp != ']') {
 			printf("Unexpected character '%c'\n", *newval);
 			return 1;
 		}
@@ -535,8 +542,11 @@
 		 * Assume it is a string.  Copy it into our data area for
 		 * convenience (including the terminating '\0').
 		 */
-		*len = strlen(newval) + 1;
-		strcpy(data, newval);
+		while (stridx < count) {
+			*len = strlen(newp) + 1;
+			strcpy(data, newp);
+			newp = newval[++stridx];
+		}
 	}
 	return 0;
 }
@@ -593,7 +603,6 @@
 static void print_data(const void *data, int len)
 {
 	int j;
-	const u8 *s;
 
 	/* no data, don't print */
 	if (len == 0)
@@ -616,32 +625,20 @@
 		return;
 	}
 
-	switch (len) {
-	case 1:	 /* byte */
-		printf("<0x%02x>", (*(u8 *) data) & 0xff);
-		break;
-	case 2:	 /* half-word */
-		printf("<0x%04x>", be16_to_cpu(*(u16 *) data) & 0xffff);
-		break;
-	case 4:	 /* word */
-		printf("<0x%08x>", be32_to_cpu(*(u32 *) data) & 0xffffffffU);
-		break;
-	case 8:	 /* double-word */
-#if __WORDSIZE == 64
-		printf("<0x%016llx>", be64_to_cpu(*(uint64_t *) data));
-#else
-		printf("<0x%08x ", be32_to_cpu(*(u32 *) data) & 0xffffffffU);
-		data += 4;
-		printf("0x%08x>", be32_to_cpu(*(u32 *) data) & 0xffffffffU);
-#endif
-		break;
-	default:		/* anything else... hexdump */
+	if ((len %4) == 0) {
+		const u32 *p;
+
+		printf("<");
+		for (j = 0, p = data; j < len/4; j ++)
+			printf("0x%x%s", p[j], j < (len/4 - 1) ? " " : "");
+		printf(">");
+	} else { /* anything else... hexdump */
+		const u8 *s;
+
 		printf("[");
 		for (j = 0, s = data; j < len; j++)
 			printf("%02x%s", s[j], j < len - 1 ? " " : "");
 		printf("]");
-
-		break;
 	}
 }
 
@@ -771,7 +768,7 @@
 /********************************************************************/
 
 U_BOOT_CMD(
-	fdt,	5,	0,	do_fdt,
+	fdt,	255,	0,	do_fdt,
 	"fdt     - flattened device tree utility commands\n",
 	    "addr   <addr> [<length>]        - Set the fdt location to <addr>\n"
 #ifdef CONFIG_OF_BOARD_SETUP
diff --git a/common/ft_build.c b/common/ft_build.c
index 5a0575e..0e5699a 100644
--- a/common/ft_build.c
+++ b/common/ft_build.c
@@ -399,72 +399,12 @@
 /* Function that returns a character from the environment */
 extern uchar(*env_get_char) (int);
 
-#define BDM(x)	{	.name = #x, .offset = offsetof(bd_t, bi_ ##x ) }
-
-#ifdef CONFIG_OF_HAS_BD_T
-static const struct {
-	const char *name;
-	int offset;
-} bd_map[] = {
-	BDM(memstart),
-	BDM(memsize),
-	BDM(flashstart),
-	BDM(flashsize),
-	BDM(flashoffset),
-	BDM(sramstart),
-	BDM(sramsize),
-#if defined(CONFIG_5xx) || defined(CONFIG_8xx) || defined(CONFIG_8260) \
-	|| defined(CONFIG_E500)
-	BDM(immr_base),
-#endif
-#if defined(CONFIG_MPC5xxx)
-	BDM(mbar_base),
-#endif
-#if defined(CONFIG_MPC83XX)
-	BDM(immrbar),
-#endif
-#if defined(CONFIG_MPC8220)
-	BDM(mbar_base),
-	BDM(inpfreq),
-	BDM(pcifreq),
-	BDM(pevfreq),
-	BDM(flbfreq),
-	BDM(vcofreq),
-#endif
-	BDM(bootflags),
-	BDM(ip_addr),
-	BDM(intfreq),
-	BDM(busfreq),
-#ifdef CONFIG_CPM2
-	BDM(cpmfreq),
-	BDM(brgfreq),
-	BDM(sccfreq),
-	BDM(vco),
-#endif
-#if defined(CONFIG_MPC5xxx)
-	BDM(ipbfreq),
-	BDM(pcifreq),
-#endif
-	BDM(baudrate),
-};
-#endif
-
 void ft_setup(void *blob, bd_t * bd, ulong initrd_start, ulong initrd_end)
 {
 	u32 *p;
 	int len;
 	struct ft_cxt cxt;
 	ulong clock;
-#if defined(CONFIG_OF_HAS_UBOOT_ENV)
-	int k, nxt;
-#endif
-#if defined(CONFIG_OF_HAS_BD_T)
-	u8 *end;
-#endif
-#if defined(CONFIG_OF_HAS_UBOOT_ENV) || defined(CONFIG_OF_HAS_BD_T)
-	int i;
-	static char tmpenv[256];
-#endif
 
 	/* disable OF tree; booting old kernel */
 	if (getenv("disable_of") != NULL) {
@@ -485,30 +425,6 @@
 	/* back into root */
 	ft_backtrack_node(&cxt);
 
-#ifdef CONFIG_OF_HAS_UBOOT_ENV
-	ft_begin_node(&cxt, "u-boot-env");
-
-	for (i = 0; env_get_char(i) != '\0'; i = nxt + 1) {
-		char *s, *lval, *rval;
-
-		for (nxt = i; env_get_char(nxt) != '\0'; ++nxt) ;
-		s = tmpenv;
-		for (k = i; k < nxt && s < &tmpenv[sizeof(tmpenv) - 1]; ++k)
-			*s++ = env_get_char(k);
-		*s++ = '\0';
-		lval = tmpenv;
-		s = strchr(tmpenv, '=');
-		if (s != NULL) {
-			*s++ = '\0';
-			rval = s;
-		} else
-			continue;
-		ft_prop_str(&cxt, lval, rval);
-	}
-
-	ft_end_node(&cxt);
-#endif
-
 	ft_begin_node(&cxt, "chosen");
 	ft_prop_str(&cxt, "name", "chosen");
 
@@ -529,36 +445,7 @@
 	ft_end_tree(&cxt);
 	ft_finalize_tree(&cxt);
 
-#ifdef CONFIG_OF_HAS_BD_T
-	/* paste the bd_t at the end of the flat tree */
-	end = (char *)blob +
-	    be32_to_cpu(((struct boot_param_header *)blob)->totalsize);
-	memcpy(end, bd, sizeof(*bd));
-#endif
-
 #ifdef CONFIG_PPC
-
-#ifdef CONFIG_OF_HAS_BD_T
-	for (i = 0; i < sizeof(bd_map)/sizeof(bd_map[0]); i++) {
-		uint32_t v;
-
-		sprintf(tmpenv, "/bd_t/%s", bd_map[i].name);
-		v = *(uint32_t *)((char *)bd + bd_map[i].offset);
-
-		p = ft_get_prop(blob, tmpenv, &len);
-		if (p != NULL)
-			*p = cpu_to_be32(v);
-	}
-
-	p = ft_get_prop(blob, "/bd_t/enetaddr", &len);
-	if (p != NULL)
-		memcpy(p, bd->bi_enetaddr, 6);
-
-	p = ft_get_prop(blob, "/bd_t/ethspeed", &len);
-	if (p != NULL)
-		*p = cpu_to_be32((uint32_t) bd->bi_ethspeed);
-#endif
-
 	clock = bd->bi_intfreq;
 	p = ft_get_prop(blob, "/cpus/" OF_CPU "/clock-frequency", &len);
 	if (p != NULL)
diff --git a/cpu/mpc8xx/Makefile b/cpu/mpc8xx/Makefile
index dbdc2e0..5f70459 100644
--- a/cpu/mpc8xx/Makefile
+++ b/cpu/mpc8xx/Makefile
@@ -27,16 +27,29 @@
 
 LIB	= $(obj)lib$(CPU).a
 
-START	= start.o kgdb.o
-COBJS	= bedbug_860.o commproc.o cpu.o cpu_init.o	\
-	  fec.o fdt.o i2c.o interrupts.o lcd.o scc.o	\
-	  serial.o speed.o spi.o \
-	  traps.o upatch.o video.o
-SOBJS	= plprcr_write.o
+START-y	+= start.o
+START-y	+= kgdb.o
+COBJS-y	+= bedbug_860.o
+COBJS-y	+= commproc.o
+COBJS-y	+= cpu.o
+COBJS-y	+= cpu_init.o
+COBJS-y	+= fec.o
+COBJS-$(CONFIG_OF_LIBFDT) += fdt.o
+COBJS-y	+= i2c.o
+COBJS-y	+= interrupts.o
+COBJS-y	+= lcd.o
+COBJS-y	+= scc.o
+COBJS-y	+= serial.o
+COBJS-y	+= speed.o
+COBJS-y	+= spi.o
+COBJS-y	+= traps.o
+COBJS-y	+= upatch.o
+COBJS-y	+= video.o
+SOBJS-y	+= plprcr_write.o
 
-SRCS	:= $(START:.o=.S) $(SOBJS:.o=.S) $(COBJS:.o=.c)
-OBJS	:= $(addprefix $(obj),$(SOBJS) $(COBJS))
-START	:= $(addprefix $(obj),$(START))
+SRCS	:= $(START-y:.o=.S) $(SOBJS-y:.o=.S) $(COBJS-y:.o=.c)
+OBJS	:= $(addprefix $(obj),$(SOBJS-y) $(COBJS-y))
+START	:= $(addprefix $(obj),$(START-y))
 
 all:	$(obj).depend $(START) $(LIB)
 
diff --git a/lib_ppc/bootm.c b/lib_ppc/bootm.c
index b893146..2901607 100644
--- a/lib_ppc/bootm.c
+++ b/lib_ppc/bootm.c
@@ -184,18 +184,6 @@
 			fdt_error ("/chosen node create failed");
 			goto error;
 		}
-#ifdef CONFIG_OF_HAS_UBOOT_ENV
-		if (fdt_env(of_flat_tree) < 0) {
-			fdt_error ("/u-boot-env node create failed");
-			goto error;
-		}
-#endif
-#ifdef CONFIG_OF_HAS_BD_T
-		if (fdt_bd_t(of_flat_tree) < 0) {
-			fdt_error ("/bd_t node create failed");
-			goto error;
-		}
-#endif
 #ifdef CONFIG_OF_BOARD_SETUP
 		/* Call the board-specific fixup routine */
 		ft_board_setup(of_flat_tree, gd->bd);