3 * Stefan Roese, esd gmbh germany, stefan.roese@esd-electronics.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>
30 #ifdef CONFIG_SDRAM_BANK0
33 #define MAGIC0 0x00000000
34 #define MAGIC1 0x11111111
35 #define MAGIC2 0x22222222
36 #define MAGIC3 0x33333333
37 #define MAGIC4 0x44444444
39 #define ADDR_ZERO 0x00000000
40 #define ADDR_400 0x00000400
41 #define ADDR_08MB 0x00800000
42 #define ADDR_16MB 0x01000000
43 #define ADDR_32MB 0x02000000
44 #define ADDR_64MB 0x04000000
46 #define mtsdram0(reg, data) mtdcr(memcfga,reg);mtdcr(memcfgd,data)
49 /*-----------------------------------------------------------------------
58 * Determine SDRAM speed
60 speed = get_bus_freq(0); /* parameter not used on ppc4xx */
63 * Support for 100MHz and 133MHz SDRAM
65 if (speed > 100000000) {
73 * default: 100 MHz SDRAM
80 * Set MB0CF for bank 0. (0-64MB) Address Mode 3 since 13x9(4)
82 mtsdram0(mem_mb0cf, 0x00084001);
84 mtsdram0(mem_sdtr1, sdtr1);
85 mtsdram0(mem_rtr, rtr);
93 * Set memory controller options reg, MCOPT1.
94 * Set DC_EN to '1' and BRD_PRF to '01' for 16 byte PLB Burst
97 mtsdram0(mem_mcopt1, 0x80800000);
105 * Test if 64 MByte are equipped (mirror test)
107 *(volatile ulong *)ADDR_ZERO = MAGIC0;
108 *(volatile ulong *)ADDR_08MB = MAGIC1;
109 *(volatile ulong *)ADDR_16MB = MAGIC2;
110 *(volatile ulong *)ADDR_32MB = MAGIC3;
112 if ((*(volatile ulong *)ADDR_ZERO == MAGIC0) &&
113 (*(volatile ulong *)ADDR_08MB == MAGIC1) &&
114 (*(volatile ulong *)ADDR_16MB == MAGIC2)) {
116 * OK, 64MB detected -> all done
122 * Now test for 32 MByte...
126 * Disable memory controller.
128 mtsdram0(mem_mcopt1, 0x00000000);
131 * Set MB0CF for bank 0. (0-32MB) Address Mode 2 since 12x9(4)
133 mtsdram0(mem_mb0cf, 0x00062001);
136 * Set memory controller options reg, MCOPT1.
137 * Set DC_EN to '1' and BRD_PRF to '01' for 16 byte PLB Burst
140 mtsdram0(mem_mcopt1, 0x80800000);
148 * Test if 32 MByte are equipped (mirror test)
150 *(volatile ulong *)ADDR_ZERO = MAGIC0;
151 *(volatile ulong *)ADDR_400 = MAGIC1;
152 *(volatile ulong *)ADDR_08MB = MAGIC2;
153 *(volatile ulong *)ADDR_16MB = MAGIC3;
155 if ((*(volatile ulong *)ADDR_ZERO == MAGIC0) &&
156 (*(volatile ulong *)ADDR_400 == MAGIC1) &&
157 (*(volatile ulong *)ADDR_08MB == MAGIC2)) {
159 * OK, 32MB detected -> all done
165 * Setup for 16 MByte...
169 * Disable memory controller.
171 mtsdram0(mem_mcopt1, 0x00000000);
174 * Set MB0CF for bank 0. (0-16MB) Address Mode 4 since 12x8(4)
176 mtsdram0(mem_mb0cf, 0x00046001);
179 * Set memory controller options reg, MCOPT1.
180 * Set DC_EN to '1' and BRD_PRF to '01' for 16 byte PLB Burst
183 mtsdram0(mem_mcopt1, 0x80800000);
191 #endif /* CONFIG_SDRAM_BANK0 */