Merge commit 'wd/master'
[oweals/u-boot.git] / cpu / mpc5xxx / cpu.c
index 6b6f8282cf36e8515b0ab13cdd94ee7544f9b12e..e4d6168224825ae9ba9c09d864e1348ad05397bc 100644 (file)
 #include <watchdog.h>
 #include <command.h>
 #include <mpc5xxx.h>
+#include <asm/io.h>
 #include <asm/processor.h>
 
+#if defined(CONFIG_OF_LIBFDT)
+#include <libfdt.h>
+#include <libfdt_env.h>
+#include <fdt_support.h>
+#endif
+
 DECLARE_GLOBAL_DATA_PTR;
 
 int checkcpu (void)
@@ -49,12 +56,16 @@ int checkcpu (void)
 #else
        svr = get_svr();
        pvr = get_pvr();
-       switch (SVR_VER (svr)) {
-       case SVR_MPC5200:
-               printf ("MPC5200");
+
+       switch (pvr) {
+       case PVR_5200:
+               printf("MPC5200");
+               break;
+       case PVR_5200B:
+               printf("MPC5200B");
                break;
        default:
-               printf ("MPC52??  (SVR %08x)", svr);
+               printf("Unknown MPC5xxx");
                break;
        }
 
@@ -102,3 +113,21 @@ unsigned long get_tbclk (void)
 }
 
 /* ------------------------------------------------------------------------- */
+
+#ifdef CONFIG_OF_LIBFDT
+void ft_cpu_setup(void *blob, bd_t *bd)
+{
+       int div = in_8((void*)CFG_MBAR + 0x204) & 0x0020 ? 8 : 4;
+       char * cpu_path = "/cpus/" OF_CPU;
+       char * eth_path = "/" OF_SOC "/ethernet@3000";
+
+       do_fixup_by_path_u32(blob, cpu_path, "timebase-frequency", OF_TBCLK, 1);
+       do_fixup_by_path_u32(blob, cpu_path, "bus-frequency", bd->bi_busfreq, 1);
+       do_fixup_by_path_u32(blob, cpu_path, "clock-frequency", bd->bi_intfreq, 1);
+       do_fixup_by_path_u32(blob, "/" OF_SOC, "bus-frequency", bd->bi_ipbfreq, 1);
+       do_fixup_by_path_u32(blob, "/" OF_SOC, "system-frequency",
+                               bd->bi_busfreq*div, 1);
+       do_fixup_by_path(blob, eth_path, "mac-address", bd->bi_enetaddr, 6, 0);
+       do_fixup_by_path(blob, eth_path, "local-mac-address", bd->bi_enetaddr, 6, 0);
+}
+#endif