Merge branch 'master' of git://git.denx.de/u-boot-ppc4xx
[oweals/u-boot.git] / arch / powerpc / cpu / mpc85xx / cpu_init.c
index d491e2ad5a521d80055bd3e5aaf123a39492efeb..27236a0bad5082c943cb16df870dc54d94348520 100644 (file)
@@ -32,6 +32,7 @@
 #include <ioports.h>
 #include <sata.h>
 #include <asm/io.h>
+#include <asm/cache.h>
 #include <asm/mmu.h>
 #include <asm/fsl_law.h>
 #include <asm/fsl_serdes.h>
 
 DECLARE_GLOBAL_DATA_PTR;
 
-#ifdef CONFIG_MPC8536
-extern void fsl_serdes_init(void);
-#endif
-
 #ifdef CONFIG_QE
 extern qe_iop_conf_t qe_iop_conf_tab[];
 extern void qe_config_iopin(u8 port, u8 pin, int dir,
@@ -131,6 +128,44 @@ void config_8560_ioports (volatile ccsr_cpm_t * cpm)
 }
 #endif
 
+#ifdef CONFIG_SYS_FSL_CPC
+static void enable_cpc(void)
+{
+       int i;
+       u32 size = 0;
+
+       cpc_corenet_t *cpc = (cpc_corenet_t *)CONFIG_SYS_FSL_CPC_ADDR;
+
+       for (i = 0; i < CONFIG_SYS_NUM_CPC; i++, cpc++) {
+               u32 cpccfg0 = in_be32(&cpc->cpccfg0);
+               size += CPC_CFG0_SZ_K(cpccfg0);
+
+               out_be32(&cpc->cpccsr0, CPC_CSR0_CE | CPC_CSR0_PE);
+               /* Read back to sync write */
+               in_be32(&cpc->cpccsr0);
+
+       }
+
+       printf("Corenet Platform Cache: %d KB enabled\n", size);
+}
+
+void invalidate_cpc(void)
+{
+       int i;
+       cpc_corenet_t *cpc = (cpc_corenet_t *)CONFIG_SYS_FSL_CPC_ADDR;
+
+       for (i = 0; i < CONFIG_SYS_NUM_CPC; i++, cpc++) {
+               /* Flash invalidate the CPC and clear all the locks */
+               out_be32(&cpc->cpccsr0, CPC_CSR0_FI | CPC_CSR0_LFC);
+               while (in_be32(&cpc->cpccsr0) & (CPC_CSR0_FI | CPC_CSR0_LFC))
+                       ;
+       }
+}
+#else
+#define enable_cpc()
+#define invalidate_cpc()
+#endif /* CONFIG_SYS_FSL_CPC */
+
 /*
  * Breathe some life into the CPU...
  *
@@ -144,7 +179,7 @@ static void corenet_tb_init(void)
        volatile ccsr_rcpm_t *rcpm =
                (void *)(CONFIG_SYS_FSL_CORENET_RCPM_ADDR);
        volatile ccsr_pic_t *pic =
-               (void *)(CONFIG_SYS_MPC85xx_PIC_ADDR);
+               (void *)(CONFIG_SYS_MPC8xxx_PIC_ADDR);
        u32 whoami = in_be32(&pic->whoami);
 
        /* Enable the timebase register for this core */
@@ -185,9 +220,6 @@ void cpu_init_f (void)
        /* Config QE ioports */
        config_qe_ioports();
 #endif
-#if defined(CONFIG_MPC8536)
-       fsl_serdes_init();
-#endif
 #if defined(CONFIG_FSL_DMA)
        dma_init();
 #endif
@@ -195,6 +227,9 @@ void cpu_init_f (void)
        corenet_tb_init();
 #endif
        init_used_tlb_cams();
+
+       /* Invalidate the CPC before DDR gets enabled */
+       invalidate_cpc();
 }
 
 
@@ -205,13 +240,18 @@ void cpu_init_f (void)
  * use the same bit-encoding as the older 8555, etc, parts.
  *
  */
-
 int cpu_init_r(void)
 {
 #ifdef CONFIG_SYS_LBC_LCRR
        volatile fsl_lbc_t *lbc = LBC_BASE_ADDR;
 #endif
 
+#if defined(CONFIG_SYS_P4080_ERRATUM_CPU22)
+       flush_dcache();
+       mtspr(L1CSR2, (mfspr(L1CSR2) | L1CSR2_DCWS));
+       sync();
+#endif
+
        puts ("L2:    ");
 
 #if defined(CONFIG_L2_CACHE)
@@ -326,12 +366,20 @@ int cpu_init_r(void)
 #else
        puts("disabled\n");
 #endif
+
+       enable_cpc();
+
 #ifdef CONFIG_QE
        uint qe_base = CONFIG_SYS_IMMR + 0x00080000; /* QE immr base */
        qe_init(qe_base);
        qe_reset();
 #endif
 
+#if defined(CONFIG_SYS_HAS_SERDES)
+       /* needs to be in ram since code uses global static vars */
+       fsl_serdes_init();
+#endif
+
 #if defined(CONFIG_MP)
        setup_mp();
 #endif