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., 51 Franklin St, Fifth Floor, Boston,
24 #include <ppc_asm.tmpl>
31 #define CONFIG_SDRAM_BANK0
32 #ifdef CONFIG_SDRAM_BANK0
35 * According to the PPC405GPr Users Manual, only non-reserved
36 * bits of SDRAM registers can be set. This means reading the
37 * contents and masking off bits to be set.
39 #define CMD_BITS 0x80C00000
40 #define CMD_MASK 0xFFE00000
41 #define TR_BITS 0x010E8016
42 #define TR_MASK 0x018FC01F
43 #define B0CR_BITS 0x00084001
44 #define B0CR_MASK 0xFFCEE001
45 #define RTR_BITS 0x08080000
46 #define RTR_MASK 0xFFFF0000
47 #define ECCCF_BITS 0x00000000
48 #define ECCCF_MASK 0x00F00000
49 #define PMIT_BITS 0x0F000000
50 #define PMIT_MASK 0xFFC00000
52 #define mfsdram0(reg, data) mtdcr(memcfga,reg);data = mfdcr(memcfgd)
53 #define mtsdram0(reg, data) mtdcr(memcfga,reg);mtdcr(memcfgd,data)
55 #define set_sdram0(reg, val) \
56 mfsdram0(reg, reg32); \
57 reg32 &= ~(val##_MASK); \
58 reg32 |= (val##_BITS); \
61 /*-----------------------------------------------------------------------
63 void memory_init(void)
73 * Determine SDRAM speed
75 speed = get_pci_bus_freq(); /* parameter not used on ppc4xx */
78 * Support for 100MHz and 133MHz SDRAM
80 if (speed > 100000000) {
88 * default: 100 MHz SDRAM
96 * Disable memory controller.
98 /* TODO: work out why this trashes cache ram */
99 //mtsdram0(mem_mcopt1, 0x00000000);
101 #if EMBEDDED_RAM_SIZE==128*1024*1024
103 #elif EMBEDDED_RAM_SIZE==64*1024*1024
104 set_sdram0(mem_sdtr1, TR);
105 set_sdram0(mem_mb0cf, B0CR);
106 set_sdram0(mem_rtr, RTR);
107 set_sdram0(mem_ecccf, ECCCF);
108 set_sdram0(mem_pmit, PMIT);
109 #elif EMBEDDED_RAM_SIZE==32*1024*1024
111 #elif EMBEDDED_RAM_SIZE==16*1024*1024
121 * Set memory controller options reg, MCOPT1.
122 * Set DC_EN to '1' and BRD_PRF to '01' for 16 byte PLB Burst
125 set_sdram0(mem_mcopt1, CMD);
133 #endif /* CONFIG_SDRAM_BANK0 */