3 * Sergei Poselenov, Emcraft Systems, sposelenov@emcraft.com.
5 * See file CREDITS for list of people who contributed to this
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License as
10 * published by the Free Software Foundation; either version 2 of
11 * the License, or (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
26 #include <asm/processor.h>
27 #include <asm/immap_85xx.h>
28 #include <asm/fsl_ddr_sdram.h>
29 #include <asm/processor.h>
31 #include <spd_sdram.h>
34 #if !defined(CONFIG_SPD_EEPROM)
36 * Autodetect onboard DDR SDRAM on 85xx platforms
38 * NOTE: Some of the hardcoded values are hardware dependant,
39 * so this should be extended for other future boards
42 phys_size_t
fixed_sdram(void)
44 volatile ccsr_ddr_t
*ddr
= (void *)(CONFIG_SYS_MPC8xxx_DDR_ADDR
);
47 * Disable memory controller.
52 ddr
->cs0_bnds
= CONFIG_SYS_DDR_CS0_BNDS
;
53 ddr
->cs0_config
= CONFIG_SYS_DDR_CS0_CONFIG
;
54 ddr
->timing_cfg_0
= CONFIG_SYS_DDR_TIMING_0
;
55 ddr
->timing_cfg_1
= CONFIG_SYS_DDR_TIMING_1
;
56 ddr
->timing_cfg_2
= CONFIG_SYS_DDR_TIMING_2
;
57 ddr
->sdram_mode
= CONFIG_SYS_DDR_MODE
;
58 ddr
->sdram_interval
= CONFIG_SYS_DDR_INTERVAL
;
59 ddr
->sdram_cfg_2
= CONFIG_SYS_DDR_CONFIG_2
;
60 ddr
->sdram_clk_cntl
= CONFIG_SYS_DDR_CLK_CONTROL
;
62 asm ("sync;isync;msync");
65 ddr
->sdram_cfg
= CONFIG_SYS_DDR_CONFIG
;
66 asm ("sync; isync; msync");
69 if (get_ram_size(0, CONFIG_SYS_SDRAM_SIZE
<<20) == CONFIG_SYS_SDRAM_SIZE
<<20) {
71 * OK, size detected -> all done
73 return CONFIG_SYS_SDRAM_SIZE
<<20;
76 return 0; /* nothing found ! */
80 #if defined(CONFIG_SYS_DRAM_TEST)
83 uint
*pstart
= (uint
*) CONFIG_SYS_MEMTEST_START
;
84 uint
*pend
= (uint
*) CONFIG_SYS_MEMTEST_END
;
87 printf ("SDRAM test phase 1:\n");
88 for (p
= pstart
; p
< pend
; p
++)
91 for (p
= pstart
; p
< pend
; p
++) {
92 if (*p
!= 0xaaaaaaaa) {
93 printf ("SDRAM test fails at: %08x\n", (uint
) p
);
98 printf ("SDRAM test phase 2:\n");
99 for (p
= pstart
; p
< pend
; p
++)
102 for (p
= pstart
; p
< pend
; p
++) {
103 if (*p
!= 0x55555555) {
104 printf ("SDRAM test fails at: %08x\n", (uint
) p
);
109 printf ("SDRAM test passed.\n");