mirror of
https://github.com/Fishwaldo/u-boot.git
synced 2025-03-18 21:21:37 +00:00
Merge branch 'master' of git://www.denx.de/git/u-boot-fdt
This commit is contained in:
commit
aeff6d503b
5 changed files with 89 additions and 217 deletions
13
README
13
README
|
@ -372,19 +372,6 @@ The following options need to be configured:
|
||||||
|
|
||||||
boards with QUICC Engines require OF_QE to set UCC mac addresses
|
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
|
CONFIG_OF_BOARD_SETUP
|
||||||
|
|
||||||
Board code has addition modification that it wants to make
|
Board code has addition modification that it wants to make
|
||||||
|
|
137
common/cmd_fdt.c
137
common/cmd_fdt.c
|
@ -42,8 +42,7 @@
|
||||||
DECLARE_GLOBAL_DATA_PTR;
|
DECLARE_GLOBAL_DATA_PTR;
|
||||||
|
|
||||||
static int fdt_valid(void);
|
static int fdt_valid(void);
|
||||||
static int fdt_parse_prop(char *pathp, char *prop, char *newval,
|
static int fdt_parse_prop(char **newval, int count, char *data, int *len);
|
||||||
char *data, int *len);
|
|
||||||
static int fdt_print(const char *pathp, char *prop, int depth);
|
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) {
|
if (argc == 4) {
|
||||||
len = 0;
|
len = 0;
|
||||||
} else {
|
} else {
|
||||||
ret = fdt_parse_prop(pathp, prop, argv[4], data, &len);
|
ret = fdt_parse_prop(&argv[4], argc - 4, data, &len);
|
||||||
if (ret != 0)
|
if (ret != 0)
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -464,69 +463,77 @@ static int fdt_valid(void)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Parse the user's input, partially heuristic. Valid formats:
|
* Parse the user's input, partially heuristic. Valid formats:
|
||||||
* <00> - hex byte
|
* <0x00112233 4 05> - an array of cells. Numbers follow standard
|
||||||
* <0011> - hex half word (16 bits)
|
* C conventions.
|
||||||
* <00112233> - hex word (32 bits)
|
|
||||||
* - hex double words (64 bits) are not supported, must use
|
|
||||||
* a byte stream instead.
|
|
||||||
* [00 11 22 .. nn] - byte stream
|
* [00 11 22 .. nn] - byte stream
|
||||||
* "string" - If the the value doesn't start with "<" or "[", it is
|
* "string" - If the the value doesn't start with "<" or "[", it is
|
||||||
* treated as a string. Note that the quotes are
|
* treated as a string. Note that the quotes are
|
||||||
* stripped by the parser before we get the string.
|
* 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,
|
static int fdt_parse_prop(char **newval, int count, char *data, int *len)
|
||||||
char *data, int *len)
|
|
||||||
{
|
{
|
||||||
char *cp; /* temporary char pointer */
|
char *cp; /* temporary char pointer */
|
||||||
|
char *newp; /* temporary newval char pointer */
|
||||||
unsigned long tmp; /* holds converted values */
|
unsigned long tmp; /* holds converted values */
|
||||||
|
int stridx = 0;
|
||||||
|
|
||||||
if (*newval == '<') {
|
*len = 0;
|
||||||
/*
|
newp = newval[0];
|
||||||
* Bigger values than bytes.
|
|
||||||
*/
|
/* An array of cells */
|
||||||
*len = 0;
|
if (*newp == '<') {
|
||||||
newval++;
|
newp++;
|
||||||
while ((*newval != '>') && (*newval != '\0')) {
|
while ((*newp != '>') && (stridx < count)) {
|
||||||
cp = newval;
|
/*
|
||||||
tmp = simple_strtoul(cp, &newval, 16);
|
* Keep searching until we find that last ">"
|
||||||
if ((newval - cp) <= 2) {
|
* That way users don't have to escape the spaces
|
||||||
*data = tmp & 0xFF;
|
*/
|
||||||
data += 1;
|
if (*newp == '\0') {
|
||||||
*len += 1;
|
newp = newval[++stridx];
|
||||||
} else if ((newval - cp) <= 4) {
|
continue;
|
||||||
*(uint16_t *)data = __cpu_to_be16(tmp);
|
}
|
||||||
data += 2;
|
|
||||||
*len += 2;
|
cp = newp;
|
||||||
} else if ((newval - cp) <= 8) {
|
tmp = simple_strtoul(cp, &newp, 0);
|
||||||
*(uint32_t *)data = __cpu_to_be32(tmp);
|
*(uint32_t *)data = __cpu_to_be32(tmp);
|
||||||
data += 4;
|
data += 4;
|
||||||
*len += 4;
|
*len += 4;
|
||||||
} else {
|
|
||||||
|
/* If the ptr didn't advance, something went wrong */
|
||||||
|
if ((newp - cp) <= 0) {
|
||||||
printf("Sorry, I could not convert \"%s\"\n",
|
printf("Sorry, I could not convert \"%s\"\n",
|
||||||
cp);
|
cp);
|
||||||
return 1;
|
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;
|
return 1;
|
||||||
}
|
}
|
||||||
} else if (*newval == '[') {
|
} else if (*newp == '[') {
|
||||||
/*
|
/*
|
||||||
* Byte stream. Convert the values.
|
* Byte stream. Convert the values.
|
||||||
*/
|
*/
|
||||||
*len = 0;
|
newp++;
|
||||||
newval++;
|
while ((*newp != ']') && (stridx < count)) {
|
||||||
while ((*newval != ']') && (*newval != '\0')) {
|
tmp = simple_strtoul(newp, &newp, 16);
|
||||||
tmp = simple_strtoul(newval, &newval, 16);
|
|
||||||
*data++ = tmp & 0xFF;
|
*data++ = tmp & 0xFF;
|
||||||
*len = *len + 1;
|
*len = *len + 1;
|
||||||
while (*newval == ' ')
|
while (*newp == ' ')
|
||||||
newval++;
|
newp++;
|
||||||
|
if (*newp != '\0')
|
||||||
|
newp = newval[++stridx];
|
||||||
}
|
}
|
||||||
if (*newval != ']') {
|
if (*newp != ']') {
|
||||||
printf("Unexpected character '%c'\n", *newval);
|
printf("Unexpected character '%c'\n", *newval);
|
||||||
return 1;
|
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
|
* Assume it is a string. Copy it into our data area for
|
||||||
* convenience (including the terminating '\0').
|
* convenience (including the terminating '\0').
|
||||||
*/
|
*/
|
||||||
*len = strlen(newval) + 1;
|
while (stridx < count) {
|
||||||
strcpy(data, newval);
|
*len = strlen(newp) + 1;
|
||||||
|
strcpy(data, newp);
|
||||||
|
newp = newval[++stridx];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return 0;
|
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)
|
static void print_data(const void *data, int len)
|
||||||
{
|
{
|
||||||
int j;
|
int j;
|
||||||
const u8 *s;
|
|
||||||
|
|
||||||
/* no data, don't print */
|
/* no data, don't print */
|
||||||
if (len == 0)
|
if (len == 0)
|
||||||
|
@ -616,32 +625,20 @@ static void print_data(const void *data, int len)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (len) {
|
if ((len %4) == 0) {
|
||||||
case 1: /* byte */
|
const u32 *p;
|
||||||
printf("<0x%02x>", (*(u8 *) data) & 0xff);
|
|
||||||
break;
|
printf("<");
|
||||||
case 2: /* half-word */
|
for (j = 0, p = data; j < len/4; j ++)
|
||||||
printf("<0x%04x>", be16_to_cpu(*(u16 *) data) & 0xffff);
|
printf("0x%x%s", p[j], j < (len/4 - 1) ? " " : "");
|
||||||
break;
|
printf(">");
|
||||||
case 4: /* word */
|
} else { /* anything else... hexdump */
|
||||||
printf("<0x%08x>", be32_to_cpu(*(u32 *) data) & 0xffffffffU);
|
const u8 *s;
|
||||||
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 */
|
|
||||||
printf("[");
|
printf("[");
|
||||||
for (j = 0, s = data; j < len; j++)
|
for (j = 0, s = data; j < len; j++)
|
||||||
printf("%02x%s", s[j], j < len - 1 ? " " : "");
|
printf("%02x%s", s[j], j < len - 1 ? " " : "");
|
||||||
printf("]");
|
printf("]");
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -771,7 +768,7 @@ static int fdt_print(const char *pathp, char *prop, int depth)
|
||||||
/********************************************************************/
|
/********************************************************************/
|
||||||
|
|
||||||
U_BOOT_CMD(
|
U_BOOT_CMD(
|
||||||
fdt, 5, 0, do_fdt,
|
fdt, 255, 0, do_fdt,
|
||||||
"fdt - flattened device tree utility commands\n",
|
"fdt - flattened device tree utility commands\n",
|
||||||
"addr <addr> [<length>] - Set the fdt location to <addr>\n"
|
"addr <addr> [<length>] - Set the fdt location to <addr>\n"
|
||||||
#ifdef CONFIG_OF_BOARD_SETUP
|
#ifdef CONFIG_OF_BOARD_SETUP
|
||||||
|
|
|
@ -399,72 +399,12 @@ void *ft_get_prop(void *bphp, const char *propname, int *szp)
|
||||||
/* Function that returns a character from the environment */
|
/* Function that returns a character from the environment */
|
||||||
extern uchar(*env_get_char) (int);
|
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)
|
void ft_setup(void *blob, bd_t * bd, ulong initrd_start, ulong initrd_end)
|
||||||
{
|
{
|
||||||
u32 *p;
|
u32 *p;
|
||||||
int len;
|
int len;
|
||||||
struct ft_cxt cxt;
|
struct ft_cxt cxt;
|
||||||
ulong clock;
|
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 */
|
/* disable OF tree; booting old kernel */
|
||||||
if (getenv("disable_of") != NULL) {
|
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 */
|
/* back into root */
|
||||||
ft_backtrack_node(&cxt);
|
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_begin_node(&cxt, "chosen");
|
||||||
ft_prop_str(&cxt, "name", "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_end_tree(&cxt);
|
||||||
ft_finalize_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_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;
|
clock = bd->bi_intfreq;
|
||||||
p = ft_get_prop(blob, "/cpus/" OF_CPU "/clock-frequency", &len);
|
p = ft_get_prop(blob, "/cpus/" OF_CPU "/clock-frequency", &len);
|
||||||
if (p != NULL)
|
if (p != NULL)
|
||||||
|
|
|
@ -27,16 +27,29 @@ include $(TOPDIR)/config.mk
|
||||||
|
|
||||||
LIB = $(obj)lib$(CPU).a
|
LIB = $(obj)lib$(CPU).a
|
||||||
|
|
||||||
START = start.o kgdb.o
|
START-y += start.o
|
||||||
COBJS = bedbug_860.o commproc.o cpu.o cpu_init.o \
|
START-y += kgdb.o
|
||||||
fec.o fdt.o i2c.o interrupts.o lcd.o scc.o \
|
COBJS-y += bedbug_860.o
|
||||||
serial.o speed.o spi.o \
|
COBJS-y += commproc.o
|
||||||
traps.o upatch.o video.o
|
COBJS-y += cpu.o
|
||||||
SOBJS = plprcr_write.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)
|
SRCS := $(START-y:.o=.S) $(SOBJS-y:.o=.S) $(COBJS-y:.o=.c)
|
||||||
OBJS := $(addprefix $(obj),$(SOBJS) $(COBJS))
|
OBJS := $(addprefix $(obj),$(SOBJS-y) $(COBJS-y))
|
||||||
START := $(addprefix $(obj),$(START))
|
START := $(addprefix $(obj),$(START-y))
|
||||||
|
|
||||||
all: $(obj).depend $(START) $(LIB)
|
all: $(obj).depend $(START) $(LIB)
|
||||||
|
|
||||||
|
|
|
@ -184,18 +184,6 @@ do_bootm_linux(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[],
|
||||||
fdt_error ("/chosen node create failed");
|
fdt_error ("/chosen node create failed");
|
||||||
goto error;
|
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
|
#ifdef CONFIG_OF_BOARD_SETUP
|
||||||
/* Call the board-specific fixup routine */
|
/* Call the board-specific fixup routine */
|
||||||
ft_board_setup(of_flat_tree, gd->bd);
|
ft_board_setup(of_flat_tree, gd->bd);
|
||||||
|
|
Loading…
Add table
Reference in a new issue