]> git.kernelconcepts.de Git - karo-tx-uboot.git/commitdiff
Moved fdt command support code to fdt_support.c
authorGerald Van Baren <vanbaren@cideas.com>
Fri, 6 Apr 2007 18:19:43 +0000 (14:19 -0400)
committerGerald Van Baren <vanbaren@cideas.com>
Fri, 6 Apr 2007 18:19:43 +0000 (14:19 -0400)
...in preparation for improving the bootm command's handling of fdt blobs.
Also cleaned up some coding sloppiness.

board/mpc8360emds/mpc8360emds.c
common/Makefile
common/cmd_bootm.c
common/cmd_fdt.c
common/fdt_support.c [new file with mode: 0644]
cpu/mpc83xx/cpu.c
include/fdt_support.h [new file with mode: 0644]

index deadb5ffbe2456ee4f9b0f9cb973ffb772d43eaa..5cabe47084d3be5dd57525b6b7e30b6aa0e10e3f 100644 (file)
@@ -664,19 +664,28 @@ U_BOOT_CMD(ecc, 4, 0, do_ecc,
 
 #if (defined(CONFIG_OF_FLAT_TREE) || defined(CONFIG_OF_LIBFDT)) \
      && defined(CONFIG_OF_BOARD_SETUP)
+
+/*
+ * Prototypes of functions that we use.
+ */
+void ft_cpu_setup(void *blob, bd_t *bd);
+
+#ifdef CONFIG_PCI
+void ft_pci_setup(void *blob, bd_t *bd);
+#endif
+
 void
 ft_board_setup(void *blob, bd_t *bd)
 {
 #if defined(CONFIG_OF_LIBFDT)
        int nodeoffset;
-       int err;
        int tmp[2];
 
        nodeoffset = fdt_path_offset (fdt, "/memory");
        if (nodeoffset >= 0) {
                tmp[0] = cpu_to_be32(bd->bi_memstart);
                tmp[1] = cpu_to_be32(bd->bi_memsize);
-               err = fdt_setprop(fdt, nodeoffset, "reg", tmp, sizeof(tmp));
+               fdt_setprop(fdt, nodeoffset, "reg", tmp, sizeof(tmp));
        }
 #else
        u32 *p;
@@ -694,4 +703,5 @@ ft_board_setup(void *blob, bd_t *bd)
 #endif
        ft_cpu_setup(blob, bd);
 }
-#endif
+#endif /* CONFIG_OF_x */
+
index 74a6af204e535de7580eeee46227b641f6d1f05e..5dfd3a84a2492339fc810d1714edf4b9a452d052 100644 (file)
@@ -45,7 +45,7 @@ COBJS = main.o ACEX1K.o altera.o bedbug.o circbuf.o cmd_autoscript.o \
          env_nand.o env_dataflash.o env_flash.o env_eeprom.o \
          env_nvram.o env_nowhere.o \
          exports.o \
-         flash.o fpga.o ft_build.o \
+         fdt_support.o flash.o fpga.o ft_build.o \
          hush.o kgdb.o lcd.o lists.o lynxkdi.o \
          memsize.o miiphybb.o miiphyutil.o \
          s_record.o serial.o soft_i2c.o soft_spi.o spartan2.o spartan3.o \
index 2721216bf35eba2418efa60874703c7214eb3e05..3eeb03c3b205bc43a96b0ece40ad3a2a2d567532 100644 (file)
@@ -950,7 +950,7 @@ do_bootm_linux (cmd_tbl_t *cmdtp, int flag,
 
                printf ("   Loading Device Tree to %08lx, end %08lx ... ",
                        of_start, of_start + of_len - 1);
-               err = fdt_open_into(of_start, of_data, of_len);
+               err = fdt_open_into((void *)of_start, (void *)of_data, of_len);
                if (err != 0) {
                        printf ("libfdt: %s\n", fdt_strerror(err));
                }
index 968bade626d6be43640e84460fe68acdf4f157b5..08fe3512d4fe6ff8f3a95c328413c4f352d8f4ae 100644 (file)
 #include <linux/types.h>
 
 #ifdef CONFIG_OF_LIBFDT
+
 #include <asm/global_data.h>
 #include <fdt.h>
 #include <libfdt.h>
+#include <fdt_support.h>
 
 #define MAX_LEVEL      32              /* how deeply nested we will go */
 #define SCRATCHPAD     1024    /* bytes of scratchpad memory */
@@ -53,9 +55,6 @@ static char data[SCRATCHPAD];
  */
 static int fdt_valid(void);
 static void print_data(const void *data, int len);
-static int fdt_chosen(void *fdt, ulong initrd_start, ulong initrd_end);
-static int fdt_env(void *fdt);
-static int fdt_bd_t(void *fdt);
 
 
 /*
@@ -437,7 +436,7 @@ int do_fdt (cmd_tbl_t * cmdtp, int flag, int argc, char *argv[])
         * Create a chosen node
         ********************************************************************/
        } else if (op == 'c') {
-               fdt_chosen(fdt, 0, 0);
+               fdt_chosen(fdt, 0, 0, 1);
 
        /********************************************************************
         * Create a u-boot-env node
@@ -466,25 +465,36 @@ int do_fdt (cmd_tbl_t * cmdtp, int flag, int argc, char *argv[])
 
 static int fdt_valid(void)
 {
+       int  err;
+
        if (fdt == NULL) {
-               printf ("The address of the fdt is invalid.\n");
-               return 0;
-       }
-       if (!fdt || (fdt_magic(fdt) != FDT_MAGIC)) {
-               fdt = NULL;
-               printf ("Unrecognized fdt: bad magic\n");
-               return 0;
-       }
-       if (fdt_version(fdt) < FDT_FIRST_SUPPORTED_VERSION) {
-               printf ("Unsupported fdt version: $d < %d\n",
-                       FDT_FIRST_SUPPORTED_VERSION, fdt_version(fdt));
-               fdt = NULL;
+               printf ("The address of the fdt is invalid (NULL).\n");
                return 0;
        }
-       if (fdt_last_comp_version(fdt) > FDT_LAST_SUPPORTED_VERSION) {
-               printf ("Unsupported fdt version: $d > %d\n",
-                       fdt_version(fdt), FDT_LAST_SUPPORTED_VERSION);
-               fdt = NULL;
+
+       err = fdt_check_header(fdt);
+       if (err == 0)
+               return 1;       /* valid */
+
+       if (err < 0) {
+               printf("libfdt: %s", fdt_strerror(err));
+               /*
+                * Be more informative on bad version.
+                */
+               if (err == -FDT_ERR_BADVERSION) {
+                       if (fdt_version(fdt) < FDT_FIRST_SUPPORTED_VERSION) {
+                               printf (" - too old, fdt $d < %d",
+                                       fdt_version(fdt), FDT_FIRST_SUPPORTED_VERSION);
+                               fdt = NULL;
+                       }
+                       if (fdt_last_comp_version(fdt) > FDT_LAST_SUPPORTED_VERSION) {
+                               printf (" - too new, fdt $d > %d",
+                                       fdt_version(fdt), FDT_LAST_SUPPORTED_VERSION);
+                               fdt = NULL;
+                       }
+                       return 0;
+               }
+               printf("\n");
                return 0;
        }
        return 1;
@@ -593,255 +603,6 @@ static void print_data(const void *data, int len)
 
 /********************************************************************/
 
-static int fdt_chosen(void *fdt, ulong initrd_start, ulong initrd_end)
-{
-       bd_t *bd = gd->bd;
-       int   nodeoffset;
-       int   err;
-       u32   tmp;                      /* used to set 32 bit integer properties */
-       char  *str;                     /* used to set string properties */
-       ulong clock;
-
-       if (initrd_start && initrd_end) {
-               err = fdt_add_reservemap_entry(fdt,
-                       initrd_start, initrd_end - initrd_start + 1);
-               if (err < 0) {
-                       printf("libfdt: %s\n", fdt_strerror(err));
-                       return err;
-               }
-       }
-
-       /*
-        * See if we already have a "chosen" node, create it if not.
-        */
-       nodeoffset = fdt_path_offset (fdt, "/chosen");
-       if (nodeoffset < 0) {
-               /*
-                * Create a new node "/chosen" (offset 0 is root level)
-                */
-               nodeoffset = fdt_add_subnode(fdt, 0, "chosen");
-               if (nodeoffset < 0) {
-                       printf("libfdt: %s\n", fdt_strerror(nodeoffset));
-                       return nodeoffset;
-               }
-       }
-
-       str = getenv("bootargs");
-       if (str != NULL) {
-               err = fdt_setprop(fdt, nodeoffset, "bootargs", str, strlen(str)+1);
-               if (err < 0)
-                       printf("libfdt: %s\n", fdt_strerror(err));
-       }
-       if (initrd_start && initrd_end) {
-               tmp = __cpu_to_be32(initrd_start);
-               err = fdt_setprop(fdt, nodeoffset, "linux,initrd-start", &tmp, sizeof(tmp));
-               if (err < 0)
-                       printf("libfdt: %s\n", fdt_strerror(err));
-               tmp = __cpu_to_be32(initrd_end);
-               err = fdt_setprop(fdt, nodeoffset, "linux,initrd-end", &tmp, sizeof(tmp));
-               if (err < 0)
-                       printf("libfdt: %s\n", fdt_strerror(err));
-       }
-#ifdef OF_STDOUT_PATH
-       err = fdt_setprop(fdt, nodeoffset, "linux,stdout-path", OF_STDOUT_PATH, strlen(OF_STDOUT_PATH)+1);
-       if (err < 0)
-               printf("libfdt: %s\n", fdt_strerror(err));
-#endif
-
-       nodeoffset = fdt_path_offset (fdt, "/cpus");
-       if (nodeoffset >= 0) {
-               clock = cpu_to_be32(bd->bi_intfreq);
-               err = fdt_setprop(fdt, nodeoffset, "clock-frequency", &clock, 4);
-               if (err < 0)
-                       printf("libfdt: %s\n", fdt_strerror(err));
-       }
-#ifdef OF_TBCLK
-       nodeoffset = fdt_path_offset (fdt, "/cpus/" OF_CPU "/timebase-frequency");
-       if (nodeoffset >= 0) {
-               clock = cpu_to_be32(OF_TBCLK);
-               err = fdt_setprop(fdt, nodeoffset, "clock-frequency", &clock, 4);
-               if (err < 0)
-                       printf("libfdt: %s\n", fdt_strerror(err));
-       }
-#endif
-}
-
-/********************************************************************/
-
-#ifdef CONFIG_OF_HAS_BD_T
-
-/* 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 ) }
-
-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),
-};
-
-static int fdt_env(void *fdt)
-{
-       int   nodeoffset;
-       int   err;
-       int   k, nxt;
-       int i;
-       static char tmpenv[256];
-
-       /*
-        * See if we already have a "u-boot-env" node, delete it if so.
-        * Then create a new empty node.
-        */
-       nodeoffset = fdt_path_offset (fdt, "/u-boot-env");
-       if (nodeoffset >= 0) {
-               err = fdt_del_node(fdt, nodeoffset);
-               if (err < 0) {
-                       printf("libfdt: %s\n", fdt_strerror(err));
-                       return err;
-               }
-       }
-       /*
-        * Create a new node "/u-boot-env" (offset 0 is root level)
-        */
-       nodeoffset = fdt_add_subnode(fdt, 0, "u-boot-env");
-       if (nodeoffset < 0) {
-               printf("libfdt: %s\n", fdt_strerror(nodeoffset));
-               return nodeoffset;
-       }
-
-       for (i = 0; env_get_char(i) != '\0'; i = nxt + 1) {
-               char *s, *lval, *rval;
-
-               /*
-                * Find the end of the name=definition
-                */
-               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;
-               /*
-                * Find the first '=': it separates the name from the value
-                */
-               s = strchr(tmpenv, '=');
-               if (s != NULL) {
-                       *s++ = '\0';
-                       rval = s;
-               } else
-                       continue;
-               err = fdt_setprop(fdt, nodeoffset, lval, rval, strlen(rval)+1);
-               if (err < 0) {
-                       printf("\"%s\" - libfdt: %s\n", lval, fdt_strerror(err));
-                       return err;
-               }
-       }
-       return 0;
-}
-#endif /* CONFIG_OF_HAS_UBOOT_ENV */
-
-/********************************************************************/
-
-#ifdef CONFIG_OF_HAS_BD_T
-static int fdt_bd_t(void *fdt)
-{
-       bd_t *bd = gd->bd;
-       int   nodeoffset;
-       int   err;
-       u32   tmp;                      /* used to set 32 bit integer properties */
-       int i;
-
-       /*
-        * See if we already have a "bd_t" node, delete it if so.
-        * Then create a new empty node.
-        */
-       nodeoffset = fdt_path_offset (fdt, "/bd_t");
-       if (nodeoffset >= 0) {
-               err = fdt_del_node(fdt, nodeoffset);
-               if (err < 0) {
-                       printf("libfdt: %s\n", fdt_strerror(err));
-                       return err;
-               }
-       }
-       /*
-        * Create a new node "/bd_t" (offset 0 is root level)
-        */
-       nodeoffset = fdt_add_subnode(fdt, 0, "bd_t");
-       if (nodeoffset < 0) {
-               printf("libfdt: %s\n", fdt_strerror(nodeoffset));
-               return nodeoffset;
-       }
-       /*
-        * Use the string/pointer structure to create the entries...
-        */
-       for (i = 0; i < sizeof(bd_map)/sizeof(bd_map[0]); i++) {
-               tmp = cpu_to_be32(getenv("bootargs"));
-               err = fdt_setprop(fdt, nodeoffset, bd_map[i].name, &tmp, sizeof(tmp));
-               if (err < 0)
-                       printf("libfdt: %s\n", fdt_strerror(err));
-       }
-       /*
-        * Add a couple of oddball entries...
-        */
-       err = fdt_setprop(fdt, nodeoffset, "enetaddr", &bd->bi_enetaddr, 6);
-       if (err < 0)
-               printf("libfdt: %s\n", fdt_strerror(err));
-       err = fdt_setprop(fdt, nodeoffset, "ethspeed", &bd->bi_ethspeed, 4);
-       if (err < 0)
-               printf("libfdt: %s\n", fdt_strerror(err));
-
-#ifdef CONFIG_OF_BOARD_SETUP
-       ft_board_setup(fdt, bd);
-#endif
-
-       return 0;
-}
-#endif /* CONFIG_OF_HAS_BD_T */
-
-/********************************************************************/
-
 U_BOOT_CMD(
        fdt,    5,      0,      do_fdt,
        "fdt     - flattened device tree utility commands\n",
@@ -871,4 +632,4 @@ U_BOOT_CMD(
        "          fdt set   /cpus \"#address-cells\" \"[00 00 00 01]\"\n"
 );
 
-#endif /* CONFIG_OF_FLAT_TREE */
+#endif /* CONFIG_OF_LIBFDT */
diff --git a/common/fdt_support.c b/common/fdt_support.c
new file mode 100644 (file)
index 0000000..14a4df5
--- /dev/null
@@ -0,0 +1,323 @@
+/*
+ * (C) Copyright 2007
+ * Gerald Van Baren, Custom IDEAS, vanbaren@cideas.com
+ *
+ * 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>
+#include <linux/ctype.h>
+#include <linux/types.h>
+
+#ifdef CONFIG_OF_LIBFDT
+
+#include <asm/global_data.h>
+#include <fdt.h>
+#include <libfdt.h>
+#include <fdt_support.h>
+
+/*
+ * Global data (for the gd->bd)
+ */
+DECLARE_GLOBAL_DATA_PTR;
+
+
+/********************************************************************/
+
+int fdt_chosen(void *fdt, ulong initrd_start, ulong initrd_end, int force)
+{
+       bd_t *bd = gd->bd;
+       int   nodeoffset;
+       int   err;
+       u32   tmp;                      /* used to set 32 bit integer properties */
+       char  *str;                     /* used to set string properties */
+       ulong clock;
+
+       err = fdt_check_header(fdt);
+       if (err < 0) {
+               printf("libfdt: %s\n", fdt_strerror(err));
+               return err;
+       }
+
+#warning "Don't double-add the reserved map"
+       if (initrd_start && initrd_end) {
+               err = fdt_add_reservemap_entry(fdt,
+                       initrd_start, initrd_end - initrd_start + 1);
+               if (err < 0) {
+                       printf("libfdt: %s\n", fdt_strerror(err));
+                       return err;
+               }
+       }
+
+       /*
+        * Find the "chosen" node.
+        */
+       nodeoffset = fdt_path_offset (fdt, "/chosen");
+
+       /*
+        * If we have a "chosen" node already the "force the writing"
+        * is not set, our job is done.
+        */
+       if ((nodeoffset >= 0) && !force)
+               return 0;
+
+       /*
+        * No "chosen" node in the blob: create it.
+        */
+       if (nodeoffset < 0) {
+               /*
+                * Create a new node "/chosen" (offset 0 is root level)
+                */
+               nodeoffset = fdt_add_subnode(fdt, 0, "chosen");
+               if (nodeoffset < 0) {
+                       printf("libfdt: %s\n", fdt_strerror(nodeoffset));
+                       return nodeoffset;
+               }
+       }
+
+       /*
+        * Update pre-existing properties, create them if non-existant.
+        */
+       str = getenv("bootargs");
+       if (str != NULL) {
+               err = fdt_setprop(fdt, nodeoffset, "bootargs", str, strlen(str)+1);
+               if (err < 0)
+                       printf("libfdt: %s\n", fdt_strerror(err));
+       }
+       if (initrd_start && initrd_end) {
+               tmp = __cpu_to_be32(initrd_start);
+               err = fdt_setprop(fdt, nodeoffset, "linux,initrd-start", &tmp, sizeof(tmp));
+               if (err < 0)
+                       printf("libfdt: %s\n", fdt_strerror(err));
+               tmp = __cpu_to_be32(initrd_end);
+               err = fdt_setprop(fdt, nodeoffset, "linux,initrd-end", &tmp, sizeof(tmp));
+               if (err < 0)
+                       printf("libfdt: %s\n", fdt_strerror(err));
+       }
+#ifdef OF_STDOUT_PATH
+       err = fdt_setprop(fdt, nodeoffset, "linux,stdout-path", OF_STDOUT_PATH, strlen(OF_STDOUT_PATH)+1);
+       if (err < 0)
+               printf("libfdt: %s\n", fdt_strerror(err));
+#endif
+
+       nodeoffset = fdt_path_offset (fdt, "/cpus");
+       if (nodeoffset >= 0) {
+               clock = cpu_to_be32(bd->bi_intfreq);
+               err = fdt_setprop(fdt, nodeoffset, "clock-frequency", &clock, 4);
+               if (err < 0)
+                       printf("libfdt: %s\n", fdt_strerror(err));
+       }
+#ifdef OF_TBCLK
+       nodeoffset = fdt_path_offset (fdt, "/cpus/" OF_CPU "/timebase-frequency");
+       if (nodeoffset >= 0) {
+               clock = cpu_to_be32(OF_TBCLK);
+               err = fdt_setprop(fdt, nodeoffset, "clock-frequency", &clock, 4);
+               if (err < 0)
+                       printf("libfdt: %s\n", fdt_strerror(err));
+       }
+#endif
+       return err;
+}
+
+/********************************************************************/
+
+#ifdef CONFIG_OF_HAS_UBOOT_ENV
+
+/* Function that returns a character from the environment */
+extern uchar(*env_get_char) (int);
+
+
+int fdt_env(void *fdt)
+{
+       int   nodeoffset;
+       int   err;
+       int   k, nxt;
+       int i;
+       static char tmpenv[256];
+
+       err = fdt_check_header(fdt);
+       if (err < 0) {
+               printf("libfdt: %s\n", fdt_strerror(err));
+               return err;
+       }
+
+       /*
+        * See if we already have a "u-boot-env" node, delete it if so.
+        * Then create a new empty node.
+        */
+       nodeoffset = fdt_path_offset (fdt, "/u-boot-env");
+       if (nodeoffset >= 0) {
+               err = fdt_del_node(fdt, nodeoffset);
+               if (err < 0) {
+                       printf("libfdt: %s\n", fdt_strerror(err));
+                       return err;
+               }
+       }
+       /*
+        * Create a new node "/u-boot-env" (offset 0 is root level)
+        */
+       nodeoffset = fdt_add_subnode(fdt, 0, "u-boot-env");
+       if (nodeoffset < 0) {
+               printf("libfdt: %s\n", fdt_strerror(nodeoffset));
+               return nodeoffset;
+       }
+
+       for (i = 0; env_get_char(i) != '\0'; i = nxt + 1) {
+               char *s, *lval, *rval;
+
+               /*
+                * Find the end of the name=definition
+                */
+               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;
+               /*
+                * Find the first '=': it separates the name from the value
+                */
+               s = strchr(tmpenv, '=');
+               if (s != NULL) {
+                       *s++ = '\0';
+                       rval = s;
+               } else
+                       continue;
+               err = fdt_setprop(fdt, nodeoffset, lval, rval, strlen(rval)+1);
+               if (err < 0) {
+                       printf("libfdt: %s\n", lval, fdt_strerror(err));
+                       return err;
+               }
+       }
+       return 0;
+}
+#endif /* CONFIG_OF_HAS_UBOOT_ENV */
+
+/********************************************************************/
+
+#ifdef CONFIG_OF_HAS_BD_T
+
+#define BDM(x) {       .name = #x, .offset = offsetof(bd_t, bi_ ##x ) }
+
+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),
+};
+
+
+int fdt_bd_t(void *fdt)
+{
+       bd_t *bd = gd->bd;
+       int   nodeoffset;
+       int   err;
+       u32   tmp;                      /* used to set 32 bit integer properties */
+       int i;
+
+       err = fdt_check_header(fdt);
+       if (err < 0) {
+               printf("libfdt: %s\n", fdt_strerror(err));
+               return err;
+       }
+
+       /*
+        * See if we already have a "bd_t" node, delete it if so.
+        * Then create a new empty node.
+        */
+       nodeoffset = fdt_path_offset (fdt, "/bd_t");
+       if (nodeoffset >= 0) {
+               err = fdt_del_node(fdt, nodeoffset);
+               if (err < 0) {
+                       printf("libfdt: %s\n", fdt_strerror(err));
+                       return err;
+               }
+       }
+       /*
+        * Create a new node "/bd_t" (offset 0 is root level)
+        */
+       nodeoffset = fdt_add_subnode(fdt, 0, "bd_t");
+       if (nodeoffset < 0) {
+               printf("libfdt: %s\n", fdt_strerror(nodeoffset));
+               return nodeoffset;
+       }
+       /*
+        * Use the string/pointer structure to create the entries...
+        */
+       for (i = 0; i < sizeof(bd_map)/sizeof(bd_map[0]); i++) {
+               tmp = cpu_to_be32(getenv("bootargs"));
+               err = fdt_setprop(fdt, nodeoffset, bd_map[i].name, &tmp, sizeof(tmp));
+               if (err < 0)
+                       printf("libfdt: %s\n", fdt_strerror(err));
+       }
+       /*
+        * Add a couple of oddball entries...
+        */
+       err = fdt_setprop(fdt, nodeoffset, "enetaddr", &bd->bi_enetaddr, 6);
+       if (err < 0)
+               printf("libfdt: %s\n", fdt_strerror(err));
+       err = fdt_setprop(fdt, nodeoffset, "ethspeed", &bd->bi_ethspeed, 4);
+       if (err < 0)
+               printf("libfdt: %s\n", fdt_strerror(err));
+
+       return 0;
+}
+#endif /* CONFIG_OF_HAS_BD_T */
+
+#endif /* CONFIG_OF_LIBFDT */
index 21b16463cd7429574795b7893daa0332ef0ce63a..aa4d9b1f1b373ba8b6d33f939f1325906acc540c 100644 (file)
@@ -364,6 +364,7 @@ ft_cpu_setup(void *blob, bd_t *bd)
                        /*
                         * If unconditional create or the property already exists...
                         */
+                       err = 0;
                        if ((fixup_props[j].createflags & FT_CREATE) ||
                                (fdt_get_property(fdt, nodeoffset, fixup_props[j].prop, 0))) {
                                if (fixup_props[j].createflags & FT_BUSFREQ) {
diff --git a/include/fdt_support.h b/include/fdt_support.h
new file mode 100644 (file)
index 0000000..a276834
--- /dev/null
@@ -0,0 +1,42 @@
+/*
+ * (C) Copyright 2007
+ * Gerald Van Baren, Custom IDEAS, vanbaren@cideas.com
+ *
+ * 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
+ */
+
+#ifndef __FDT_SUPPORT_H
+#define __FDT_SUPPORT_H
+
+#ifdef CONFIG_OF_LIBFDT
+
+#include <fdt.h>
+
+int fdt_chosen(void *fdt, ulong initrd_start, ulong initrd_end, int force);
+
+#ifdef CONFIG_OF_HAS_UBOOT_ENV
+int fdt_env(void *fdt);
+#endif
+
+#ifdef CONFIG_OF_HAS_BD_T
+int fdt_bd_t(void *fdt);
+#endif
+
+#endif /* ifdef CONFIG_OF_LIBFDT */
+#endif /* ifndef __FDT_SUPPORT_H */