3 * Wolfgang Denk, DENX Software Engineering, wd@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,
28 static long int dram_size(long int *base, long int maxsize)
30 volatile long int *addr;
32 ulong save[32]; /* to make test non-destructive */
35 for (cnt = (maxsize / sizeof (long)) >> 1; cnt > 0; cnt >>= 1) {
36 addr = base + cnt; /* pointer arith! */
42 /* write 0 to base address */
47 /* check at base address */
48 if ((val = *addr) != 0) {
53 for (cnt = 1; cnt < maxsize / sizeof (long); cnt <<= 1) {
54 addr = base + cnt; /* pointer arith! */
60 return (cnt * sizeof (long));
66 static void sdram_start (int hi_addr)
68 long hi_addr_bit = hi_addr ? 0x01000000 : 0;
70 /* unlock mode register */
71 *(vu_long *)MPC5XXX_SDRAM_CTRL = 0xd04f0000 | hi_addr_bit;
72 /* precharge all banks */
73 *(vu_long *)MPC5XXX_SDRAM_CTRL = 0xd04f0002 | hi_addr_bit;
74 /* set mode register */
75 #if defined(CONFIG_MPC5200)
76 *(vu_long *)MPC5XXX_SDRAM_MODE = 0x408d0000;
77 #elif defined(CONFIG_MGT5100)
78 *(vu_long *)MPC5XXX_SDRAM_MODE = 0x008d0000;
80 /* precharge all banks */
81 *(vu_long *)MPC5XXX_SDRAM_CTRL = 0xd04f0002 | hi_addr_bit;
83 *(vu_long *)MPC5XXX_SDRAM_CTRL = 0xd04f0004 | hi_addr_bit;
84 /* set mode register */
85 *(vu_long *)MPC5XXX_SDRAM_MODE = 0x008d0000;
86 /* normal operation */
87 *(vu_long *)MPC5XXX_SDRAM_CTRL = 0x504f0000 | hi_addr_bit;
90 long int initdram (int board_type)
92 ulong test1, test2, dramsize = 0;
94 /* configure SDRAM start/end */
95 #if defined(CONFIG_MPC5200)
96 *(vu_long *)MPC5XXX_SDRAM_CS0CFG = 0x0000001e;/* 2G at 0x0 */
97 *(vu_long *)MPC5XXX_SDRAM_CS1CFG = 0x80000000;/* disabled */
99 /* setup config registers */
100 *(vu_long *)MPC5XXX_SDRAM_CONFIG1 = 0xc2233a00;
101 *(vu_long *)MPC5XXX_SDRAM_CONFIG2 = 0x88b70004;
103 #elif defined(CONFIG_MGT5100)
104 *(vu_long *)MPC5XXX_SDRAM_START = 0x00000000;
105 *(vu_long *)MPC5XXX_SDRAM_STOP = 0x0000ffff;/* 2G */
106 *(vu_long *)MPC5XXX_ADDECR |= (1 << 22); /* Enable SDRAM */
108 /* setup config registers */
109 *(vu_long *)MPC5XXX_SDRAM_CONFIG1 = 0xc2222600;
110 *(vu_long *)MPC5XXX_SDRAM_CONFIG2 = 0x88b70004;
112 /* address select register */
113 *(vu_long *)MPC5XXX_SDRAM_XLBSEL = 0x03000000;
116 test1 = dram_size((ulong *)CFG_SDRAM_BASE, 0x80000000);
118 test2 = dram_size((ulong *)CFG_SDRAM_BASE, 0x80000000);
125 #if defined(CONFIG_MPC5200)
126 *(vu_long *)MPC5XXX_SDRAM_CS0CFG =
127 (0x13 + __builtin_ffs(dramsize >> 20) - 1);
128 *(vu_long *)MPC5XXX_SDRAM_CS1CFG = dramsize; /* disabled */
129 #elif defined(CONFIG_MGT5100)
130 *(vu_long *)MPC5XXX_SDRAM_STOP = ((dramsize - 1) >> 15);
134 #ifdef CONFIG_MGT5100
135 *(vu_long *)MPC5XXX_ADDECR |= (1 << 22); /* Enable SDRAM */
138 /* return total ram size */
142 int checkboard (void)
144 #if defined(CONFIG_MPC5200)
145 puts ("Board: Motorola MPC5200 (IceCube)\n");
146 #elif defined(CONFIG_MGT5100)
147 puts ("Board: Motorola MGT5100 (IceCube)\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 #if defined(CONFIG_MGT5100)
161 *(vu_long *)MPC5XXX_ADDECR &= ~(1 << 25); /* disable CS_BOOT */
162 *(vu_long *)MPC5XXX_ADDECR |= (1 << 16); /* enable CS0 */
164 *(vu_long *)MPC5XXX_BOOTCS_CFG &= ~0x1; /* clear RO */
168 static struct pci_controller hose;
170 extern void pci_mpc5xxx_init(struct pci_controller *);
172 void pci_init_board(void)
174 pci_mpc5xxx_init(&hose);