Commit f1737152c01734749c3694d30e1aa86ab28f374e

Authored by Tom Rini

Merge git://git.denx.de/u-boot-fdt

Showing 4 changed files Side-by-side Diff

common/fdt_support.c
... ... @@ -194,6 +194,31 @@
194 194 return fdt_setprop_u32(fdt, nodeoffset, name, (uint32_t)val);
195 195 }
196 196  
  197 +int fdt_root(void *fdt)
  198 +{
  199 + char *serial;
  200 + int err;
  201 +
  202 + err = fdt_check_header(fdt);
  203 + if (err < 0) {
  204 + printf("fdt_root: %s\n", fdt_strerror(err));
  205 + return err;
  206 + }
  207 +
  208 + serial = getenv("serial#");
  209 + if (serial) {
  210 + err = fdt_setprop(fdt, 0, "serial-number", serial,
  211 + strlen(serial) + 1);
  212 +
  213 + if (err < 0) {
  214 + printf("WARNING: could not set serial-number %s.\n",
  215 + fdt_strerror(err));
  216 + return err;
  217 + }
  218 + }
  219 +
  220 + return 0;
  221 +}
197 222  
198 223 int fdt_initrd(void *fdt, ulong initrd_start, ulong initrd_end)
199 224 {
... ... @@ -471,6 +471,10 @@
471 471 int ret = -EPERM;
472 472 int fdt_ret;
473 473  
  474 + if (fdt_root(blob) < 0) {
  475 + printf("ERROR: root node setup failed\n");
  476 + goto err;
  477 + }
474 478 if (fdt_chosen(blob) < 0) {
475 479 printf("ERROR: /chosen node create failed\n");
476 480 goto err;
doc/device-tree-bindings/root.txt
  1 +The root node
  2 +
  3 +Optional properties:
  4 + - serial-number : a string representing the device's serial number
include/fdt_support.h
... ... @@ -16,8 +16,35 @@
16 16 const char *prop, const u32 dflt);
17 17 u32 fdt_getprop_u32_default(const void *fdt, const char *path,
18 18 const char *prop, const u32 dflt);
  19 +
  20 +/**
  21 + * Add data to the root of the FDT before booting the OS.
  22 + *
  23 + * See doc/device-tree-bindings/root.txt
  24 + *
  25 + * @param fdt FDT address in memory
  26 + * @return 0 if ok, or -FDT_ERR_... on error
  27 + */
  28 +int fdt_root(void *fdt);
  29 +
  30 +/**
  31 + * Add chosen data the FDT before booting the OS.
  32 + *
  33 + * In particular, this adds the kernel command line (bootargs) to the FDT.
  34 + *
  35 + * @param fdt FDT address in memory
  36 + * @return 0 if ok, or -FDT_ERR_... on error
  37 + */
19 38 int fdt_chosen(void *fdt);
  39 +
  40 +/**
  41 + * Add initrd information to the FDT before booting the OS.
  42 + *
  43 + * @param fdt FDT address in memory
  44 + * @return 0 if ok, or -FDT_ERR_... on error
  45 + */
20 46 int fdt_initrd(void *fdt, ulong initrd_start, ulong initrd_end);
  47 +
21 48 void do_fixup_by_path(void *fdt, const char *path, const char *prop,
22 49 const void *val, int len, int create);
23 50 void do_fixup_by_path_u32(void *fdt, const char *path, const char *prop,