Convert mpc7448hpc2 to CONFIG_OF_LIBFDT
authorGerald Van Baren <vanbaren@cideas.com>
Wed, 4 Jun 2008 00:24:58 +0000 (20:24 -0400)
committerGerald Van Baren <vanbaren@cideas.com>
Tue, 10 Jun 2008 01:13:24 +0000 (21:13 -0400)
This was configured to use the deprecated CONFIG_OF_FLAT_TREE, change
to CONFIG_OF_LIBFDT.

WARNING: This conversion is untested because I do not have a board to
test it on.

NOTE: The FDT blob (DTS) must have an /aliases/ethernet0 and (optionally)
/aliases/ethernet1 property for the ethernet to work.

Signed-off-by: Gerald Van Baren <vanbaren@cideas.com>
board/freescale/mpc7448hpc2/mpc7448hpc2.c
cpu/74xx_7xx/cpu.c
drivers/pci/tsi108_pci.c
include/configs/mpc7448hpc2.h

index 81846eba77d40d323cb33db6865b8cbcae0870da..fcbebc0e2d8c292b12131683029b9104a78ff86e 100644 (file)
@@ -105,3 +105,12 @@ ft_board_setup (void *blob, bd_t *bd)
        }
 }
 #endif
+
+#if defined(CONFIG_OF_BOARD_SETUP)
+void
+ft_board_setup(void *blob, bd_t *bd)
+{
+       ft_cpu_setup(blob, bd);
+       fdt_fixup_memory(blob, (u64)bd->bi_memstart, (u64)bd->bi_memsize);
+}
+#endif
index 9c8998b604e1404469574f420bc514ecffdf0555..a6e34260cf9c0d36de0aacf64c3da733a36f8a2a 100644 (file)
 #include <74xx_7xx.h>
 #include <asm/cache.h>
 
+#if defined(CONFIG_OF_LIBFDT)
+#include <libfdt.h>
+#include <fdt_support.h>
+#endif
+
 #if defined(CONFIG_OF_FLAT_TREE)
 #include <ft_build.h>
 #endif
@@ -301,29 +306,19 @@ watchdog_reset(void)
 
 /* ------------------------------------------------------------------------- */
 
-#ifdef CONFIG_OF_FLAT_TREE
-void
-ft_cpu_setup (void *blob, bd_t *bd)
+#ifdef CONFIG_OF_LIBFDT
+void ft_cpu_setup(void *blob, bd_t *bd)
 {
-       u32 *p;
-       ulong clock;
-       int len;
-
-       clock = bd->bi_busfreq;
+       do_fixup_by_prop_u32(blob, "device_type", "cpu", 4,
+                            "timebase-frequency", bd->bi_busfreq / 4, 1);
+       do_fixup_by_prop_u32(blob, "device_type", "cpu", 4,
+                            "bus-frequency", bd->bi_busfreq, 1);
+       do_fixup_by_prop_u32(blob, "device_type", "cpu", 4,
+                            "clock-frequency", bd->bi_intfreq, 1);
 
-       p = ft_get_prop (blob, "/cpus/" OF_CPU "/bus-frequency", &len);
-       if (p != NULL)
-               *p = cpu_to_be32 (clock);
+       fdt_fixup_memory(blob, (u64)bd->bi_memstart, (u64)bd->bi_memsize);
 
-#if defined(CONFIG_TSI108_ETH)
-       p = ft_get_prop (blob, "/" OF_TSI "/ethernet@6200/address", &len);
-               memcpy (p, bd->bi_enetaddr, 6);
-#endif
-
-#if defined(CONFIG_HAS_ETH1)
-       p = ft_get_prop (blob, "/" OF_TSI "/ethernet@6600/address", &len);
-               memcpy (p, bd->bi_enet1addr, 6);
-#endif
+       fdt_fixup_ethernet(blob, bd);
 }
 #endif
 /* ------------------------------------------------------------------------- */
index d5f11e42f08e387a676e273966e5e4b58505580b..4f02cb85e8c51d1c19269c7b726233ea68227e87 100644 (file)
@@ -33,8 +33,9 @@
 #include <pci.h>
 #include <asm/io.h>
 #include <tsi108.h>
-#ifdef CONFIG_OF_FLAT_TREE
-#include <ft_build.h>
+#if defined(CONFIG_OF_LIBFDT)
+#include <libfdt.h>
+#include <fdt_support.h>
 #endif
 
 struct pci_controller local_hose;
@@ -162,20 +163,24 @@ void pci_init_board (void)
        return;
 }
 
-#ifdef CONFIG_OF_FLAT_TREE
-void
-ft_pci_setup (void *blob, bd_t *bd)
+#if defined(CONFIG_OF_LIBFDT)
+void ft_pci_setup(void *blob, bd_t *bd)
 {
-       u32 *p;
-       int len;
-
-       p = (u32 *)ft_get_prop (blob, "/" OF_TSI "/pci@1000/bus-range", &len);
-       if (p != NULL) {
-               p[0] = local_hose.first_busno;
-               p[1] = local_hose.last_busno;
+       int nodeoffset;
+       int tmp[2];
+       const char *path;
+
+       nodeoffset = fdt_path_offset(blob, "/aliases");
+       if (nodeoffset >= 0) {
+               path = fdt_getprop(blob, nodeoffset, "pci", NULL);
+               if (path) {
+                       tmp[0] = cpu_to_be32(local_hose.first_busno);
+                       tmp[1] = cpu_to_be32(local_hose.last_busno);
+                       do_fixup_by_path(blob, path, "bus-range",
+                               &tmp, sizeof(tmp), 1);
+               }
        }
-
 }
-#endif
+#endif /* CONFIG_OF_LIBFDT */
 
 #endif /* CONFIG_TSI108_PCI */
index a218f7576c7254a3eedfdca926c7e93e745a8a70..3d71e229d959a5de62c60e3f0061a3e3ff5b8558 100644 (file)
@@ -75,7 +75,7 @@
 #define CFG_PROMPT_HUSH_PS2    "> "
 
 /* Pass open firmware flat tree */
-#define CONFIG_OF_FLAT_TREE    1
+#define CONFIG_OF_LIBFDT       1
 #define CONFIG_OF_BOARD_SETUP  1
 
 #define OF_CPU                 "PowerPC,7448@0"