3 * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
6 * Mark Jonas, Freescale Semiconductor, mark.jonas@motorola.com.
8 * See file CREDITS for list of people who contributed to this
11 * This program is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU General Public License as
13 * published by the Free Software Foundation; either version 2 of
14 * the License, or (at your option) any later version.
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
32 #define SDRAM_MODE 0x00CD0000
33 #define SDRAM_CONTROL 0x504F0000
34 #define SDRAM_CONFIG1 0xD2322800
35 #define SDRAM_CONFIG2 0x8AD70000
37 static void sdram_start (int hi_addr)
39 long hi_addr_bit = hi_addr ? 0x01000000 : 0;
41 /* unlock mode register */
42 *(vu_long *)MPC5XXX_SDRAM_CTRL = SDRAM_CONTROL | 0x80000000 | hi_addr_bit;
43 __asm__ volatile ("sync");
45 /* precharge all banks */
46 *(vu_long *)MPC5XXX_SDRAM_CTRL = SDRAM_CONTROL | 0x80000002 | hi_addr_bit;
47 __asm__ volatile ("sync");
49 /* precharge all banks */
50 *(vu_long *)MPC5XXX_SDRAM_CTRL = SDRAM_CONTROL | 0x80000002 | hi_addr_bit;
51 __asm__ volatile ("sync");
54 *(vu_long *)MPC5XXX_SDRAM_CTRL = SDRAM_CONTROL | 0x80000004 | hi_addr_bit;
55 __asm__ volatile ("sync");
57 /* set mode register */
58 *(vu_long *)MPC5XXX_SDRAM_MODE = SDRAM_MODE;
59 __asm__ volatile ("sync");
61 /* normal operation */
62 *(vu_long *)MPC5XXX_SDRAM_CTRL = SDRAM_CONTROL | hi_addr_bit;
63 __asm__ volatile ("sync");
67 * ATTENTION: Although partially referenced initdram does NOT make real use
68 * use of CONFIG_SYS_SDRAM_BASE. The code does not work if CONFIG_SYS_SDRAM_BASE
69 * is something else than 0x00000000.
71 phys_size_t initdram (int board_type)
77 /* setup SDRAM chip selects */
78 *(vu_long *)MPC5XXX_SDRAM_CS0CFG = 0x0000001e;/* 2G at 0x0 */
79 *(vu_long *)MPC5XXX_SDRAM_CS1CFG = 0x80000000;/* disabled */
80 __asm__ volatile ("sync");
82 /* setup config registers */
83 *(vu_long *)MPC5XXX_SDRAM_CONFIG1 = SDRAM_CONFIG1;
84 *(vu_long *)MPC5XXX_SDRAM_CONFIG2 = SDRAM_CONFIG2;
85 __asm__ volatile ("sync");
87 /* find RAM size using SDRAM CS0 only */
89 test1 = get_ram_size((long *)CONFIG_SYS_SDRAM_BASE, 0x80000000);
91 test2 = get_ram_size((long *)CONFIG_SYS_SDRAM_BASE, 0x80000000);
99 /* memory smaller than 1MB is impossible */
100 if (dramsize < (1 << 20)) {
104 /* set SDRAM CS0 size according to the amount of RAM found */
106 *(vu_long *)MPC5XXX_SDRAM_CS0CFG = 0x13 + __builtin_ffs(dramsize >> 20) - 1;
108 *(vu_long *)MPC5XXX_SDRAM_CS0CFG = 0; /* disabled */
110 /* let SDRAM CS1 start right after CS0 */
111 *(vu_long *)MPC5XXX_SDRAM_CS1CFG = dramsize + 0x0000001e;/* 2G */
113 /* find RAM size using SDRAM CS1 only */
117 test2 = test1 = get_ram_size((long *)(CONFIG_SYS_SDRAM_BASE + dramsize), 0x80000000);
121 test2 = get_ram_size((long *)(CONFIG_SYS_SDRAM_BASE + dramsize), 0x80000000);
131 /* memory smaller than 1MB is impossible */
132 if (dramsize2 < (1 << 20))
135 /* set SDRAM CS1 size according to the amount of RAM found */
137 *(vu_long *)MPC5XXX_SDRAM_CS1CFG = dramsize
138 | (0x13 + __builtin_ffs(dramsize2 >> 20) - 1);
140 *(vu_long *)MPC5XXX_SDRAM_CS1CFG = dramsize; /* disabled */
143 return dramsize + dramsize2;
146 int checkboard (void)
148 puts ("Board: O2DNT\n");
152 void flash_preinit(void)
155 * Now, when we are in RAM, enable flash write
156 * access for detection process.
157 * Note that CS_BOOT cannot be cleared when
158 * executing in flash.
160 *(vu_long *)MPC5XXX_BOOTCS_CFG &= ~0x1; /* clear RO */
163 void flash_afterinit(ulong size)
165 if (size == 0x800000) { /* adjust mapping */
166 *(vu_long *)MPC5XXX_BOOTCS_START = *(vu_long *)MPC5XXX_CS0_START =
167 START_REG(CONFIG_SYS_BOOTCS_START | size);
169 *(vu_long *)MPC5XXX_BOOTCS_STOP = *(vu_long *)MPC5XXX_CS0_STOP =
170 STOP_REG(CONFIG_SYS_BOOTCS_START | size, size);
175 static struct pci_controller hose;
177 extern void pci_mpc5xxx_init(struct pci_controller *);
179 void pci_init_board(void)
181 pci_mpc5xxx_init(&hose);
185 int board_eth_init(bd_t *bis)
187 cpu_eth_init(bis); /* Built in FEC comes first */
188 return pci_eth_init(bis);