5xxx: write MAC address to mac-address and local-mac-address
[oweals/u-boot.git] / cpu / mpc5xxx / cpu.c
index c481d187df9449594b02accc52f943e5a97e4fba..1eac2bbfbe10a2f1e64c4d5f0bb959630c366258 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
+       uint svr, pvr;
+#endif
 
        puts ("CPU:   ");
 
-       printf (CPU_ID_STR);
-
+#ifdef CONFIG_MGT5100
+       puts   (CPU_ID_STR);
        printf (" (JTAG ID %08lx)", *(vu_long *)MPC5XXX_CDM_JTAGID);
-
+#else
+       svr = get_svr();
+       pvr = get_pvr();
+
+       switch (pvr) {
+       case PVR_5200:
+               printf("MPC5200");
+               break;
+       case PVR_5200B:
+               printf("MPC5200B");
+               break;
+       default:
+               printf("Unknown MPC5xxx");
+               break;
+       }
+
+       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));
-
        return 0;
 }
 
@@ -62,8 +86,9 @@ do_reset (cmd_tbl_t * cmdtp, int flag, int argc, char *argv[])
        __asm__ __volatile__ ("mtmsr    %0"::"r" (msr));
 
        /* Charge the watchdog timer */
-       *(vu_long *)(MPC5XXX_GPT0_COUNTER) = 0xf;
+       *(vu_long *)(MPC5XXX_GPT0_COUNTER) = 0x0001000f;
        *(vu_long *)(MPC5XXX_GPT0_ENABLE) = 0x9004; /* wden|ce|timer_ms */
+       while(1);
 
        return 1;
 
@@ -77,8 +102,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;
@@ -87,3 +110,30 @@ unsigned long get_tbclk (void)
 }
 
 /* ------------------------------------------------------------------------- */
+
+#ifdef CONFIG_OF_FLAT_TREE
+void
+ft_cpu_setup(void *blob, bd_t *bd)
+{
+       u32 *p;
+       int len;
+
+       /* Core XLB bus frequency */
+       p = ft_get_prop(blob, "/cpus/" OF_CPU "/bus-frequency", &len);
+       if (p != NULL)
+               *p = cpu_to_be32(bd->bi_busfreq);
+
+       /* SOC peripherals use the IPB bus frequency */
+       p = ft_get_prop(blob, "/" OF_SOC "/bus-frequency", &len);
+       if (p != NULL)
+               *p = cpu_to_be32(bd->bi_ipbfreq);
+
+       p = ft_get_prop(blob, "/" OF_SOC "/ethernet@3000/mac-address", &len);
+       if (p != NULL)
+               memcpy(p, bd->bi_enetaddr, 6);
+
+       p = ft_get_prop(blob, "/" OF_SOC "/ethernet@3000/local-mac-address", &len);
+       if (p != NULL)
+               memcpy(p, bd->bi_enetaddr, 6);
+}
+#endif