From 6fe2946f198481254a6ee9600d7456b8316a4083 Mon Sep 17 00:00:00 2001 From: Kim Phillips Date: Fri, 28 Mar 2008 17:37:49 -0500 Subject: remove remaining CONFIG_OF_HAS_{UBOOT_ENV,BD_T} code finish off what commit 43ddd9c820fec44816188f53346b464e20b3142d, "Remove deprecated CONFIG_OF_HAS_UBOOT_ENV and CONFIG_OF_HAS_BD_T" started. Signed-off-by: Kim Phillips diff --git a/README b/README index 5cbe7c1..18b720c 100644 --- a/README +++ b/README @@ -372,19 +372,6 @@ The following options need to be configured: 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/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 @@ void *ft_get_prop(void *bphp, const char *propname, int *szp) /* 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 @@ void ft_setup(void *blob, bd_t * bd, ulong initrd_start, ulong initrd_end) /* 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 @@ void ft_setup(void *blob, bd_t * bd, ulong initrd_start, ulong initrd_end) 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/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 @@ do_bootm_linux(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[], 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); -- cgit v0.10.2 From 4abd844d8eb108736e1cf8fbf3dbf61f2d5fc11b Mon Sep 17 00:00:00 2001 From: Andy Fleming Date: Mon, 31 Mar 2008 20:45:56 -0500 Subject: Fix fdt set command to conform to dts spec The fdt set command was treating properties specified as <00> and <0011> as byte streams, rather than as an array of cells. As we already have syntax for expressing the desire for a stream of bytes ([ xx xx ...]), we should use the <> syntax to describe arrays of cells, which are always 32-bits per element. If we imagine this likely (IMHO) scenario: > fdt set /ethernet-phy@1 reg <1> With the old code, this would create a bad fdt, since the reg cell would be made to be one byte in length. But the cell must be 4 bytes, so this would break mysteriously. Also, the dts spec calls for constants inside the angle brackets (<>) to conform to C constant standards as they pertain to base. Take this scenario: > fdt set /ethernet@f00 reg <0xe250000\ 0x1000> The old fdt command would complain that it couldn't parse that. Or, if you wanted to specify that a certain clock ran at 33 MHz, you'd be required to do this: > fdt set /mydev clock <1f78a40> Whereas the new code will accept decimal numbers. While I was in there, I extended the fdt command parser to handle property strings which are split across multiple arguments: > fdt set /ethernet@f00 interrupts < 33 2 34 2 36 2 > > fdt p /ethernet@f00 ethernet@f00 { interrupts = <0x21 0x2 0x22 0x2 0x24 0x2>; }; Lastly, the fdt print code was rearranged slightly to print arrays of cells if the length of the property is a multiple of 4 bytes, and to not print leading zeros. Signed-off-by: Andy Fleming 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 @@ int do_fdt (cmd_tbl_t * cmdtp, int flag, int argc, char *argv[]) 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 @@ static int fdt_valid(void) /* * 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 @@ static int fdt_parse_prop(char *pathp, char *prop, char *newval, * 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 int is_printable_string(const void *data, int len) 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 @@ static void print_data(const void *data, int len) 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 @@ static int fdt_print(const char *pathp, char *prop, int depth) /********************************************************************/ U_BOOT_CMD( - fdt, 5, 0, do_fdt, + fdt, 255, 0, do_fdt, "fdt - flattened device tree utility commands\n", "addr [] - Set the fdt location to \n" #ifdef CONFIG_OF_BOARD_SETUP -- cgit v0.10.2 From c2a545ce33b26d80337f80b533828839249fb1c9 Mon Sep 17 00:00:00 2001 From: Jean-Christophe PLAGNIOL-VILLARD Date: Wed, 2 Apr 2008 08:03:56 +0200 Subject: MPC8xx: Fix libfdt support introduced in commit 77ff7b74 fdt.c: In function 'ft_cpu_setup': fdt.c:33: warning: implicit declaration of function 'do_fixup_by_prop_u32' fdt.c:39: warning: implicit declaration of function 'do_fixup_by_compat_u32' fdt.c:43: warning: implicit declaration of function 'fdt_fixup_ethernet' fdt.c:45: warning: implicit declaration of function 'fdt_fixup_memory' Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD 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 @@ include $(TOPDIR)/config.mk 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 - -SRCS := $(START:.o=.S) $(SOBJS:.o=.S) $(COBJS:.o=.c) -OBJS := $(addprefix $(obj),$(SOBJS) $(COBJS)) -START := $(addprefix $(obj),$(START)) +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-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) -- cgit v0.10.2