3 * Stefan Roese, DENX Software Engineering, sr@denx.de.
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>
29 static void wait_init_complete(void)
34 mfsdram(mem_mcsts, val);
35 } while (!(val & 0x80000000));
39 * long int initdram(int board_type)
41 * As the name already indicates, this function is called very early
42 * from start.S and configures the SDRAM with fixed values. This is needed,
43 * since the 440EP has no internal SRAM and the 4kB NAND_SPL loader has
44 * not enough free space to implement the complete I2C SPD DDR autodetection
45 * routines. Therefore the Bamboo only supports the onboard 64MBytes of SDRAM
46 * when booting from NAND flash.
49 * As found out by Eugene O'Brien <eugene.obrien@advantechamt.com>, the fixed
50 * DDR setup has problems (U-Boot crashes randomly upon TFTP), when the DIMM
51 * modules are still plugged in. So it is recommended to remove the DIMM
52 * modules while using the NAND booting code with the fixed SDRAM setup!
54 long int initdram(int board_type)
57 * Soft-reset SDRAM controller.
59 mtsdr(sdr_srst, SDR0_SRST_DMC);
60 mtsdr(sdr_srst, 0x00000000);
63 * Disable memory controller.
65 mtsdram(mem_cfg0, 0x00000000);
70 mtsdram(mem_uabba, 0x00000000); /* ubba=0 (default) */
71 mtsdram(mem_slio, 0x00000000); /* rdre=0 wrre=0 rarw=0 */
72 mtsdram(mem_devopt, 0x00000000); /* dll=0 ds=0 (normal) */
73 mtsdram(mem_wddctr, 0x00000000); /* wrcp=0 dcd=0 */
74 mtsdram(mem_clktr, 0x40000000); /* clkp=1 (90 deg wr) dcdt=0 */
77 * Following for CAS Latency = 2.5 @ 133 MHz PLB
79 mtsdram(mem_b0cr, 0x00082001);
80 mtsdram(mem_tr0, 0x41094012);
81 mtsdram(mem_tr1, 0x8080083d); /* SS=T2 SL=STAGE 3 CD=1 CT=0x00*/
82 mtsdram(mem_rtr, 0x04100000); /* Interval 7.8µs @ 133MHz PLB */
83 mtsdram(mem_cfg1, 0x00000000); /* Self-refresh exit, disable PM*/
86 * Enable the controller, then wait for DCEN to complete
88 mtsdram(mem_cfg0, 0x80000000); /* DCEN=1, PMUD=0*/
91 return CFG_MBYTES_SDRAM << 20;