mpc83xx: spd_sdram: fix ddr sdram base address assignment bug
authorAnton Vorontsov <avorontsov@ru.mvista.com>
Thu, 11 Sep 2008 17:35:36 +0000 (21:35 +0400)
committerKim Phillips <kim.phillips@freescale.com>
Wed, 24 Sep 2008 14:58:33 +0000 (09:58 -0500)
The spd_dram code shifts the base address, then masks 20 bits, but
forgets to shift the base address back. Fix this by just masking the
base address correctly.

Found this bug while trying to relocate a DDR memory at the base != 0.

Signed-off-by: Anton Vorontsov <avorontsov@ru.mvista.com>
Signed-off-by: Kim Phillips <kim.phillips@freescale.com>
board/freescale/mpc8313erdb/sdram.c
board/freescale/mpc8315erdb/sdram.c
board/freescale/mpc8349emds/mpc8349emds.c
board/freescale/mpc8349itx/mpc8349itx.c
board/freescale/mpc837xemds/mpc837xemds.c
board/freescale/mpc837xerdb/mpc837xerdb.c
board/matrix_vision/mvblm7/mvblm7.c
board/sbc8349/sbc8349.c
cpu/mpc83xx/spd_sdram.c

index 3a6347f..128cd40 100644 (file)
@@ -64,7 +64,7 @@ static long fixed_sdram(void)
        volatile immap_t *im = (volatile immap_t *)CFG_IMMR;
        u32 msize_log2 = __ilog2(msize);
 
-       im->sysconf.ddrlaw[0].bar = CFG_DDR_SDRAM_BASE >> 12;
+       im->sysconf.ddrlaw[0].bar = CFG_DDR_SDRAM_BASE & 0xfffff000;
        im->sysconf.ddrlaw[0].ar = LBLAWAR_EN | (msize_log2 - 1);
        im->sysconf.ddrcdr = CFG_DDRCDR_VALUE;
 
index 07e6486..3714c2c 100644 (file)
@@ -60,7 +60,7 @@ static long fixed_sdram(void)
        u32 msize = CFG_DDR_SIZE * 1024 * 1024;
        u32 msize_log2 = __ilog2(msize);
 
-       im->sysconf.ddrlaw[0].bar = CFG_DDR_SDRAM_BASE >> 12;
+       im->sysconf.ddrlaw[0].bar = CFG_DDR_SDRAM_BASE  & 0xfffff000;
        im->sysconf.ddrlaw[0].ar = LBLAWAR_EN | (msize_log2 - 1);
        im->sysconf.ddrcdr = CFG_DDRCDR_VALUE;
 
index 4c04f2c..ef947fe 100644 (file)
@@ -109,7 +109,7 @@ int fixed_sdram(void)
                        return -1;
                }
        }
-       im->sysconf.ddrlaw[0].bar = ((CFG_DDR_SDRAM_BASE>>12) & 0xfffff);
+       im->sysconf.ddrlaw[0].bar = CFG_DDR_SDRAM_BASE & 0xfffff000;
        im->sysconf.ddrlaw[0].ar = LAWAR_EN | ((ddr_size_log2 - 1) & LAWAR_SIZE);
 
 #if (CFG_DDR_SIZE != 256)
index d3fc560..0a20e2b 100644 (file)
@@ -55,7 +55,7 @@ int fixed_sdram(void)
 
        im->sysconf.ddrlaw[0].ar =
            LAWAR_EN | ((ddr_size_log2 - 1) & LAWAR_SIZE);
-       im->sysconf.ddrlaw[0].bar = (CFG_DDR_SDRAM_BASE >> 12) & 0xfffff;
+       im->sysconf.ddrlaw[0].bar = CFG_DDR_SDRAM_BASE & 0xfffff000;
 
        /* Only one CS0 for DDR */
        im->ddr.csbnds[0].csbnds = 0x0000000f;
index 40f1e63..8003ec1 100644 (file)
@@ -108,7 +108,7 @@ int fixed_sdram(void)
        u32 msize = CFG_DDR_SIZE * 1024 * 1024;
        u32 msize_log2 = __ilog2(msize);
 
-       im->sysconf.ddrlaw[0].bar = CFG_DDR_SDRAM_BASE >> 12;
+       im->sysconf.ddrlaw[0].bar = CFG_DDR_SDRAM_BASE & 0xfffff000;
        im->sysconf.ddrlaw[0].ar = LBLAWAR_EN | (msize_log2 - 1);
 
 #if (CFG_DDR_SIZE != 512)
index aaefc18..e547b51 100644 (file)
@@ -96,7 +96,7 @@ int fixed_sdram(void)
        u32 msize = CFG_DDR_SIZE * 1024 * 1024;
        u32 msize_log2 = __ilog2(msize);
 
-       im->sysconf.ddrlaw[0].bar = CFG_DDR_SDRAM_BASE >> 12;
+       im->sysconf.ddrlaw[0].bar = CFG_DDR_SDRAM_BASE & 0xfffff000;
        im->sysconf.ddrlaw[0].ar = LBLAWAR_EN | (msize_log2 - 1);
 
        im->sysconf.ddrcdr = CFG_DDRCDR_VALUE;
index b07f913..3dcff67 100644 (file)
@@ -50,7 +50,7 @@ int fixed_sdram(void)
                if (ddr_size & 1)
                        return -1;
        }
-       im->sysconf.ddrlaw[0].bar = ((CFG_DDR_SDRAM_BASE>>12) & 0xfffff);
+       im->sysconf.ddrlaw[0].bar = CFG_DDR_SDRAM_BASE & 0xfffff000;
        im->sysconf.ddrlaw[0].ar = LAWAR_EN | ((ddr_size_log2 - 1) &
                LAWAR_SIZE);
 
index 4a44fda..93ada0b 100644 (file)
@@ -101,7 +101,7 @@ int fixed_sdram(void)
                        return -1;
                }
        }
-       im->sysconf.ddrlaw[0].bar = ((CFG_DDR_SDRAM_BASE>>12) & 0xfffff);
+       im->sysconf.ddrlaw[0].bar = CFG_DDR_SDRAM_BASE & 0xfffff000;
        im->sysconf.ddrlaw[0].ar = LAWAR_EN | ((ddr_size_log2 - 1) & LAWAR_SIZE);
 
 #if (CFG_DDR_SIZE != 256)
index 76f2474..f4a0e90 100644 (file)
@@ -274,7 +274,7 @@ long int spd_sdram()
        /*
         * Set up LAWBAR for all of DDR.
         */
-       ecm->bar = ((CFG_DDR_SDRAM_BASE>>12) & 0xfffff);
+       ecm->bar = CFG_DDR_SDRAM_BASE & 0xfffff000;
        ecm->ar  = (LAWAR_EN | LAWAR_TRGT_IF_DDR | (LAWAR_SIZE & law_size));
        debug("DDR:bar=0x%08x\n", ecm->bar);
        debug("DDR:ar=0x%08x\n", ecm->ar);