]> git.kernelconcepts.de Git - karo-tx-uboot.git/blobdiff - cpu/mpc8xx/cpu.c
ppc4xx/net: Fix MDIO clock setup
[karo-tx-uboot.git] / cpu / mpc8xx / cpu.c
index 4a32986a2e7c0cc33414acdb9d19f1031b7e96cb..2eb848bd0ef23f59902235f3d1993d4059a35b5c 100644 (file)
 #include <watchdog.h>
 #include <command.h>
 #include <mpc8xx.h>
+#include <commproc.h>
+#include <netdev.h>
 #include <asm/cache.h>
 
+#if defined(CONFIG_OF_LIBFDT)
+#include <libfdt.h>
+#include <libfdt_env.h>
+#include <fdt_support.h>
+#endif
+
+DECLARE_GLOBAL_DATA_PTR;
+
 static char *cpu_warning = "\n         " \
        "*** Warning: CPU Core has Silicon Bugs -- Check the Errata ***";
 
@@ -69,14 +79,15 @@ static int check_CPU (long clock, uint pvr, uint immr)
 
        k = (immr << 16) | *((ushort *) & immap->im_cpm.cp_dparam[0xB0]);
        m = 0;
+       suf = "";
 
        /*
         * Some boards use sockets so different CPUs can be used.
         * We have to check chip version in run time.
         */
        switch (k) {
-       case 0x00020001: pre = 'P'; suf = ""; break;
-       case 0x00030001: suf = ""; break;
+       case 0x00020001: pre = 'P'; break;
+       case 0x00030001: break;
        case 0x00120003: suf = "A"; break;
        case 0x00130003: suf = "A3"; break;
 
@@ -93,7 +104,11 @@ static int check_CPU (long clock, uint pvr, uint immr)
                /* this value is not documented anywhere */
        case 0x40000000: pre = 'P'; suf = "D"; m = 1; break;
                /* MPC866P/MPC866T/MPC859T/MPC859DSL/MPC852T */
-       case 0x08000003: pre = 'M'; suf = ""; m = 1;
+       case 0x08010004:                /* Rev. A.0 */
+               suf = "A";
+               /* fall through */
+       case 0x08000003:                /* Rev. 0.3 */
+               pre = 'M'; m = 1;
                if (id_str == NULL)
                        id_str =
 # if defined(CONFIG_MPC852T)
@@ -124,13 +139,13 @@ static int check_CPU (long clock, uint pvr, uint immr)
                printf ("unknown M%s (0x%08x)", id_str, k);
 
 
-#if defined(CFG_8xx_CPUCLK_MIN) && defined(CFG_8xx_CPUCLK_MAX)
+#if defined(CONFIG_SYS_8xx_CPUCLK_MIN) && defined(CONFIG_SYS_8xx_CPUCLK_MAX)
        printf (" at %s MHz [%d.%d...%d.%d MHz]\n       ",
                strmhz (buf, clock),
-               CFG_8xx_CPUCLK_MIN / 1000000,
-               ((CFG_8xx_CPUCLK_MIN % 1000000) + 50000) / 100000,
-               CFG_8xx_CPUCLK_MAX / 1000000,
-               ((CFG_8xx_CPUCLK_MAX % 1000000) + 50000) / 100000
+               CONFIG_SYS_8xx_CPUCLK_MIN / 1000000,
+               ((CONFIG_SYS_8xx_CPUCLK_MIN % 1000000) + 50000) / 100000,
+               CONFIG_SYS_8xx_CPUCLK_MAX / 1000000,
+               ((CONFIG_SYS_8xx_CPUCLK_MAX % 1000000) + 50000) / 100000
        );
 #else
        printf (" at %s MHz: ", strmhz (buf, clock));
@@ -344,8 +359,6 @@ static int check_CPU (long clock, uint pvr, uint immr)
 
 int checkcpu (void)
 {
-       DECLARE_GLOBAL_DATA_PTR;
-
        ulong clock = gd->cpu_clk;
        uint immr = get_immr (0);       /* Return full IMMR contents */
        uint pvr = get_pvr ();
@@ -364,7 +377,7 @@ int checkcpu (void)
 
 int checkicache (void)
 {
-       volatile immap_t *immap = (immap_t *) CFG_IMMR;
+       volatile immap_t *immap = (immap_t *) CONFIG_SYS_IMMR;
        volatile memctl8xx_t *memctl = &immap->im_memctl;
        u32 cacheon = rd_ic_cst () & IDC_ENABLED;
 
@@ -411,7 +424,7 @@ int checkicache (void)
 
 int checkdcache (void)
 {
-       volatile immap_t *immap = (immap_t *) CFG_IMMR;
+       volatile immap_t *immap = (immap_t *) CONFIG_SYS_IMMR;
        volatile memctl8xx_t *memctl = &immap->im_memctl;
        u32 cacheon = rd_dc_cst () & IDC_ENABLED;
 
@@ -451,7 +464,7 @@ void upmconfig (uint upm, uint * table, uint size)
 {
        uint i;
        uint addr = 0;
-       volatile immap_t *immap = (immap_t *) CFG_IMMR;
+       volatile immap_t *immap = (immap_t *) CONFIG_SYS_IMMR;
        volatile memctl8xx_t *memctl = &immap->im_memctl;
 
        for (i = 0; i < size; i++) {
@@ -469,7 +482,7 @@ int 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_plprcr |= PLPRCR_CSR;      /* Checkstop Reset enable */
 
@@ -484,16 +497,16 @@ int 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.
         * "(ulong)-1" used to be a good choice for many systems...
         */
-       addr = CFG_MONITOR_BASE - sizeof (ulong);
+       addr = CONFIG_SYS_MONITOR_BASE - sizeof (ulong);
 #endif
        ((void (*)(void)) addr) ();
        return 1;
@@ -514,7 +527,7 @@ int do_reset (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
        disable_interrupts ();
 
        /* make sure the watchdog is running */
-       reset_8xx_watchdog ((immap_t *) CFG_IMMR);
+       reset_8xx_watchdog ((immap_t *) CONFIG_SYS_IMMR);
 
        /* wait for watchdog reset */
        while (1) {};
@@ -534,8 +547,6 @@ int do_reset (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
  */
 unsigned long get_tbclk (void)
 {
-       DECLARE_GLOBAL_DATA_PTR;
-
        uint immr = get_immr (0);       /* Return full IMMR contents */
        volatile immap_t *immap = (volatile immap_t *)(immr & 0xFFFF0000);
        ulong oscclk, factor, pll;
@@ -582,7 +593,7 @@ void watchdog_reset (void)
 {
        int re_enable = disable_interrupts ();
 
-       reset_8xx_watchdog ((immap_t *) CFG_IMMR);
+       reset_8xx_watchdog ((immap_t *) CONFIG_SYS_IMMR);
        if (re_enable)
                enable_interrupts ();
 }
@@ -625,7 +636,19 @@ void reset_8xx_watchdog (volatile immap_t * immr)
        immr->im_siu_conf.sc_swsr = 0xaa39;     /* write magic2 */
 # endif /* CONFIG_LWMON */
 }
-
 #endif /* CONFIG_WATCHDOG */
 
-/* ------------------------------------------------------------------------- */
+/*
+ * Initializes on-chip ethernet controllers.
+ * to override, implement board_eth_init()
+ */
+int cpu_eth_init(bd_t *bis)
+{
+#if defined(SCC_ENET) && defined(CONFIG_CMD_NET)
+       scc_initialize(bis);
+#endif
+#if defined(FEC_ENET)
+       fec_initialize(bis);
+#endif
+       return 0;
+}