82xx serial, smc: Coding-Style cleanup serial SMC driver
[oweals/u-boot.git] / cpu / mpc8260 / cpu.c
index c2b753d6bd2e8ac4c73124aeea53566f416d8ff6..f4beca55be0d673392aacc4e68e679d5b411d0bf 100644 (file)
 #include <watchdog.h>
 #include <command.h>
 #include <mpc8260.h>
+#include <netdev.h>
 #include <asm/processor.h>
 #include <asm/cpm_8260.h>
 
 #if defined(CONFIG_OF_LIBFDT)
 #include <libfdt.h>
 #include <libfdt_env.h>
+#include <fdt_support.h>
 #endif
 
 DECLARE_GLOBAL_DATA_PTR;
@@ -60,7 +62,7 @@ extern int get_cpu_str_f (char *buf);
 
 int checkcpu (void)
 {
-       volatile immap_t *immap = (immap_t *) CFG_IMMR;
+       volatile immap_t *immap = (immap_t *) CONFIG_SYS_IMMR;
        ulong clock = gd->cpu_clk;
        uint pvr = get_pvr ();
        uint immr, rev, m, k;
@@ -87,7 +89,7 @@ int checkcpu (void)
        rev = pvr & 0xff;
 
        immr = immap->im_memctl.memc_immr;
-       if ((immr & IMMR_ISB_MSK) != CFG_IMMR)
+       if ((immr & IMMR_ISB_MSK) != CONFIG_SYS_IMMR)
                return -1;      /* whoops! someone moved the IMMR */
 
 #if defined(CONFIG_GET_CPU_STR_F)
@@ -177,7 +179,7 @@ int checkcpu (void)
 
 void upmconfig (uint upm, uint * table, uint size)
 {
-       volatile immap_t *immap = (immap_t *) CFG_IMMR;
+       volatile immap_t *immap = (immap_t *) CONFIG_SYS_IMMR;
        volatile memctl8260_t *memctl = &immap->im_memctl;
        volatile uchar *dummy = (uchar *) BRx_BA_MSK;   /* set all BA bits */
        uint i;
@@ -240,7 +242,7 @@ do_reset (cmd_tbl_t * cmdtp, int flag, int argc, char *argv[])
 {
        ulong msr, addr;
 
-       volatile immap_t *immap = (immap_t *) CFG_IMMR;
+       volatile immap_t *immap = (immap_t *) CONFIG_SYS_IMMR;
 
        immap->im_clkrst.car_rmr = RMR_CSRE;    /* Checkstop Reset enable */
 
@@ -254,15 +256,15 @@ do_reset (cmd_tbl_t * cmdtp, int flag, int argc, char *argv[])
         * Trying to execute the next instruction at a non-existing address
         * should cause a machine check, resulting in reset
         */
-#ifdef CFG_RESET_ADDRESS
-       addr = CFG_RESET_ADDRESS;
+#ifdef CONFIG_SYS_RESET_ADDRESS
+       addr = CONFIG_SYS_RESET_ADDRESS;
 #else
        /*
-        * note: when CFG_MONITOR_BASE points to a RAM address, CFG_MONITOR_BASE
+        * note: when CONFIG_SYS_MONITOR_BASE points to a RAM address, CONFIG_SYS_MONITOR_BASE
         * - sizeof (ulong) is usually a valid address. Better pick an address
-        * known to be invalid on your system and assign it to CFG_RESET_ADDRESS.
+        * known to be invalid on your system and assign it to CONFIG_SYS_RESET_ADDRESS.
         */
-       addr = CFG_MONITOR_BASE - sizeof (ulong);
+       addr = CONFIG_SYS_MONITOR_BASE - sizeof (ulong);
 #endif
        ((void (*)(void)) addr) ();
        return 1;
@@ -292,43 +294,40 @@ void watchdog_reset (void)
 {
        int re_enable = disable_interrupts ();
 
-       reset_8260_watchdog ((immap_t *) CFG_IMMR);
+       reset_8260_watchdog ((immap_t *) CONFIG_SYS_IMMR);
        if (re_enable)
                enable_interrupts ();
 }
 #endif /* CONFIG_WATCHDOG */
 
 /* ------------------------------------------------------------------------- */
-#if defined(CONFIG_OF_LIBFDT)
-static void do_fixup(void *fdt, const char *node, const char *prop,
-                       const void *val, int len, int create)
+#if defined(CONFIG_OF_LIBFDT) && defined (CONFIG_OF_BOARD_SETUP)
+void ft_cpu_setup (void *blob, bd_t *bd)
 {
-#if defined(DEBUG)
-       int i;
-       debug("Updating property '%s/%s' = ", node, prop);
-       for (i = 0; i < len; i++)
-               debug(" %.2x", *(u8*)(val+i));
-       debug("\n");
+       char * cpu_path = "/cpus/" OF_CPU;
+
+#if defined(CONFIG_HAS_ETH0) || defined(CONFIG_HAS_ETH1) ||\
+    defined(CONFIG_HAS_ETH2) || defined(CONFIG_HAS_ETH3)
+       fdt_fixup_ethernet(blob);
 #endif
-       int rc = fdt_find_and_setprop(fdt, node, prop, val, len, create);
-       if (rc)
-               printf("Unable to update property %s:%s, err=%s\n",
-                       node, prop, fdt_strerror(rc));
-}
 
-static void do_fixup_u32(void *fdt, const char *node, const char *prop,
-                        u32 val, int create)
-{
-       val = cpu_to_fdt32(val);
-       do_fixup(fdt, node, prop, &val, sizeof(val), create);
+       do_fixup_by_path_u32(blob, cpu_path, "bus-frequency", bd->bi_busfreq, 1);
+       do_fixup_by_path_u32(blob, cpu_path, "timebase-frequency", OF_TBCLK, 1);
+       do_fixup_by_path_u32(blob, cpu_path, "clock-frequency", bd->bi_intfreq, 1);
 }
+#endif /* CONFIG_OF_LIBFDT */
 
-void ft_cpu_setup (void *blob, bd_t *bd)
+/*
+ * Initializes on-chip ethernet controllers.
+ * to override, implement board_eth_init()
+ */
+int cpu_eth_init(bd_t *bis)
 {
-       char * cpu_path = "/cpus/" OF_CPU;
-
-       do_fixup_u32(blob, cpu_path, "bus-frequency", bd->bi_busfreq, 1);
-       do_fixup_u32(blob, cpu_path, "timebase-frequency", OF_TBCLK, 1);
-       do_fixup_u32(blob, cpu_path, "clock-frequency", bd->bi_intfreq, 1);
+#if defined(CONFIG_ETHER_ON_FCC)
+       fec_initialize(bis);
+#endif
+#if defined(CONFIG_ETHER_ON_SCC)
+       mpc82xx_scc_enet_initialize(bd);
+#endif
+       return 0;
 }
-#endif /* CONFIG_OF_LIBFDT */