[PATCH] Enable the IceCube/lite5200 variants to pass a device tree to Linux.
[oweals/u-boot.git] / cpu / mpc5xxx / cpu.c
index 8d1e7c637792cad79e9a74ec3c92a0f8666608c5..20e6735de4f6eaf7b52ac0b03894df1b8305e068 100644 (file)
 #include <mpc5xxx.h>
 #include <asm/processor.h>
 
+#if defined(CONFIG_OF_FLAT_TREE)
+#include <ft_build.h>
+#endif
+
+DECLARE_GLOBAL_DATA_PTR;
+
 int checkcpu (void)
 {
-       DECLARE_GLOBAL_DATA_PTR;
-
        ulong clock = gd->cpu_clk;
        char buf[32];
 #ifndef CONFIG_MGT5100
@@ -58,7 +62,7 @@ int checkcpu (void)
                break;
        }
 
-       printf (" v%d.%d, Core v%d.%d", SVR_MJREV (svr), SVR_MNREV (svr), 
+       printf (" v%d.%d, Core v%d.%d", SVR_MJREV (svr), SVR_MNREV (svr),
                PVR_MAJ(pvr), PVR_MIN(pvr));
 #endif
        printf (" at %s MHz\n", strmhz (buf, clock));
@@ -94,8 +98,6 @@ do_reset (cmd_tbl_t * cmdtp, int flag, int argc, char *argv[])
  */
 unsigned long get_tbclk (void)
 {
-       DECLARE_GLOBAL_DATA_PTR;
-
        ulong tbclk;
 
        tbclk = (gd->bus_clk + 3L) / 4L;
@@ -104,3 +106,27 @@ unsigned long get_tbclk (void)
 }
 
 /* ------------------------------------------------------------------------- */
+
+#ifdef CONFIG_OF_FLAT_TREE
+void
+ft_cpu_setup(void *blob, bd_t *bd)
+{
+       u32 *p;
+       ulong clock;
+       int len;
+
+       clock = bd->bi_busfreq;
+       p = ft_get_prop(blob, "/cpus/" OF_CPU "/bus-frequency", &len);
+       if (p != NULL)
+               *p = cpu_to_be32(clock);
+
+       p = ft_get_prop(blob, "/" OF_SOC "/bus-frequency", &len);
+       if (p != NULL)
+               *p = cpu_to_be32(clock);
+
+       p = ft_get_prop(blob, "/" OF_SOC "/ethernet@3000/mac-address", &len);
+       if (p != NULL)
+               memcpy(p, bd->bi_enetaddr, 6);
+
+}
+#endif