sbc8548: Fix LBC SDRAM initialization settings
authorPaul Gortmaker <paul.gortmaker@windriver.com>
Sat, 31 Dec 2011 04:53:09 +0000 (23:53 -0500)
committerKumar Gala <galak@kernel.crashing.org>
Wed, 11 Jan 2012 19:59:03 +0000 (13:59 -0600)
These were cloned from the mpc8548cds platform which has
a different memory layout (1/2 the size).  Set the values
by comparing to the register file for the board used during
JTAG init sequence:

LSDMR1 0x2863B727 /* PCHALL */
LSDMR2 0x0863B727 /* NORMAL */
LSDMR3 0x1863B727 /* MRW    */
LSDMR4 0x4063B727 /* RFEN   */

This differs from what was there already in that the RFEN is
not bundled in all four steps implicitly, but issued once
as the final step.

The other difference seen when comparing vs. the register file init,
is that since the memory is split across /CS3 and /CS4, the dummy
writes need to go to 0xf000_0000 _and_ to 0xf400_0000.

We also rewrite the final LBC SDRAM inits as macros, as there is
no real need for them to be a local variable that is modified
on the fly at runtime.

Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com>
Signed-off-by: Kumar Gala <galak@kernel.crashing.org>
board/sbc8548/sbc8548.c
include/configs/sbc8548.h

index 63d504d61da5b7290727f0e1e5bdaaf1f1a53c8d..96554b2cdcc490442c63b9dcf0f708e946289c60 100644 (file)
@@ -107,13 +107,14 @@ void lbc_sdram_init(void)
 #if defined(CONFIG_SYS_LBC_SDRAM_SIZE)
 
        uint idx;
+       const unsigned long size = CONFIG_SYS_LBC_SDRAM_SIZE * 1024 * 1024;
        volatile fsl_lbc_t *lbc = LBC_BASE_ADDR;
        uint *sdram_addr = (uint *)CONFIG_SYS_LBC_SDRAM_BASE;
-       uint lsdmr_common;
+       uint *sdram_addr2 = (uint *)(CONFIG_SYS_LBC_SDRAM_BASE + size/2);
 
        puts("    SDRAM: ");
 
-       print_size(CONFIG_SYS_LBC_SDRAM_SIZE * 1024 * 1024, "\n");
+       print_size(size, "\n");
 
        /*
         * Setup SDRAM Base and Option Registers
@@ -130,48 +131,50 @@ void lbc_sdram_init(void)
        out_be32(&lbc->mrtpr, CONFIG_SYS_LBC_MRTPR);
        asm("msync");
 
-       /*
-        * MPC8548 uses "new" 15-16 style addressing.
-        */
-       lsdmr_common = CONFIG_SYS_LBC_LSDMR_COMMON;
-       lsdmr_common |= LSDMR_BSMA1516;
-
        /*
         * Issue PRECHARGE ALL command.
         */
-       out_be32(&lbc->lsdmr, lsdmr_common | LSDMR_OP_PCHALL);
+       out_be32(&lbc->lsdmr, CONFIG_SYS_LBC_LSDMR_PCHALL);
        asm("sync;msync");
        *sdram_addr = 0xff;
        ppcDcbf((unsigned long) sdram_addr);
+       *sdram_addr2 = 0xff;
+       ppcDcbf((unsigned long) sdram_addr2);
        udelay(100);
 
        /*
         * Issue 8 AUTO REFRESH commands.
         */
        for (idx = 0; idx < 8; idx++) {
-               out_be32(&lbc->lsdmr, lsdmr_common | LSDMR_OP_ARFRSH);
+               out_be32(&lbc->lsdmr, CONFIG_SYS_LBC_LSDMR_ARFRSH);
                asm("sync;msync");
                *sdram_addr = 0xff;
                ppcDcbf((unsigned long) sdram_addr);
+               *sdram_addr2 = 0xff;
+               ppcDcbf((unsigned long) sdram_addr2);
                udelay(100);
        }
 
        /*
         * Issue 8 MODE-set command.
         */
-       out_be32(&lbc->lsdmr, lsdmr_common | LSDMR_OP_MRW);
+       out_be32(&lbc->lsdmr, CONFIG_SYS_LBC_LSDMR_MRW);
        asm("sync;msync");
        *sdram_addr = 0xff;
        ppcDcbf((unsigned long) sdram_addr);
+       *sdram_addr2 = 0xff;
+       ppcDcbf((unsigned long) sdram_addr2);
        udelay(100);
 
        /*
-        * Issue NORMAL OP command.
+        * Issue RFEN command.
         */
-       out_be32(&lbc->lsdmr, lsdmr_common | LSDMR_OP_NORMAL);
+       out_be32(&lbc->lsdmr, CONFIG_SYS_LBC_LSDMR_RFEN);
        asm("sync;msync");
        *sdram_addr = 0xff;
        ppcDcbf((unsigned long) sdram_addr);
+       *sdram_addr2 = 0xff;
+       ppcDcbf((unsigned long) sdram_addr2);
        udelay(200);    /* Overkill. Must wait > 200 bus cycles */
 
 #endif /* enable SDRAM init */
index fb07d09f3f40f26d015d7d2b66b97cd7b347ac9c..1df2225a77887e2c50508b2e84b4b637ffaca4cc 100644 (file)
 
 /*
  * Common settings for all Local Bus SDRAM commands.
- * At run time, either BSMA1516 (for CPU 1.1)
- *                  or BSMA1617 (for CPU 1.0) (old)
- * is OR'ed in too.
  */
 #define CONFIG_SYS_LBC_LSDMR_COMMON    ( LSDMR_RFCR16          \
-                               | LSDMR_PRETOACT7       \
-                               | LSDMR_ACTTORW7        \
+                               | LSDMR_BSMA1516        \
+                               | LSDMR_PRETOACT3       \
+                               | LSDMR_ACTTORW3        \
+                               | LSDMR_BUFCMD          \
                                | LSDMR_BL8             \
-                               | LSDMR_WRC4            \
+                               | LSDMR_WRC2            \
                                | LSDMR_CL3             \
-                               | LSDMR_RFEN            \
                                )
 
+#define CONFIG_SYS_LBC_LSDMR_PCHALL    \
+        (CONFIG_SYS_LBC_LSDMR_COMMON | LSDMR_OP_PCHALL)
+#define CONFIG_SYS_LBC_LSDMR_ARFRSH    \
+        (CONFIG_SYS_LBC_LSDMR_COMMON | LSDMR_OP_ARFRSH)
+#define CONFIG_SYS_LBC_LSDMR_MRW       \
+        (CONFIG_SYS_LBC_LSDMR_COMMON | LSDMR_OP_MRW)
+#define CONFIG_SYS_LBC_LSDMR_RFEN      \
+        (CONFIG_SYS_LBC_LSDMR_COMMON | LSDMR_RFEN)
+
 #define CONFIG_SYS_INIT_RAM_LOCK       1
 #define CONFIG_SYS_INIT_RAM_ADDR       0xe4010000      /* Initial RAM address */
 #define CONFIG_SYS_INIT_RAM_SIZE       0x4000          /* Size of used area in RAM */