3 * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
6 * Mark Jonas, Freescale Semiconductor, mark.jonas@motorola.com.
8 * (C) Copyright 2005-2009
9 * Modified for InterControl digsyMTC MPC5200 board by
10 * Frank Bodammer, GCD Hard- & Software GmbH,
11 * frank.bodammer@gcd-solutions.de
14 * Grzegorz Bernacki, Semihalf, gjb@semihalf.com
16 * See file CREDITS for list of people who contributed to this
19 * This program is free software; you can redistribute it and/or
20 * modify it under the terms of the GNU General Public License as
21 * published by the Free Software Foundation; either version 2 of
22 * the License, or (at your option) any later version.
24 * This program is distributed in the hope that it will be useful,
25 * but WITHOUT ANY WARRANTY; without even the implied warranty of
26 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
27 * GNU General Public License for more details.
29 * You should have received a copy of the GNU General Public License
30 * along with this program; if not, write to the Free Software
31 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
39 #include <asm/processor.h>
42 #include "is42s16800a-7t.h"
44 DECLARE_GLOBAL_DATA_PTR;
46 extern int usb_cpu_init(void);
48 #ifndef CONFIG_SYS_RAMBOOT
49 static void sdram_start(int hi_addr)
51 long hi_addr_bit = hi_addr ? 0x01000000 : 0;
52 long control = SDRAM_CONTROL | hi_addr_bit;
54 /* unlock mode register */
55 out_be32((void *)MPC5XXX_SDRAM_CTRL, control | 0x80000000);
57 /* precharge all banks */
58 out_be32((void *)MPC5XXX_SDRAM_CTRL, control | 0x80000002);
61 out_be32((void *)MPC5XXX_SDRAM_CTRL, control | 0x80000004);
63 /* set mode register */
64 out_be32((void *)MPC5XXX_SDRAM_MODE, SDRAM_MODE);
66 /* normal operation */
67 out_be32((void *)MPC5XXX_SDRAM_CTRL, control);
72 * ATTENTION: Although partially referenced initdram does NOT make real use
73 * use of CONFIG_SYS_SDRAM_BASE. The code does not work if
74 * CONFIG_SYS_SDRAM_BASE is something else than 0x00000000.
77 phys_size_t initdram(int board_type)
82 #ifndef CONFIG_SYS_RAMBOOT
85 /* setup SDRAM chip selects */
86 out_be32((void *)MPC5XXX_SDRAM_CS0CFG, 0x0000001C); /* 512MB at 0x0 */
87 out_be32((void *)MPC5XXX_SDRAM_CS1CFG, 0x80000000); /* disabled */
89 /* setup config registers */
90 out_be32((void *)MPC5XXX_SDRAM_CONFIG1, SDRAM_CONFIG1);
91 out_be32((void *)MPC5XXX_SDRAM_CONFIG2, SDRAM_CONFIG2);
93 /* find RAM size using SDRAM CS0 only */
95 test1 = get_ram_size((long *)CONFIG_SYS_SDRAM_BASE, 0x08000000);
97 test2 = get_ram_size((long *)CONFIG_SYS_SDRAM_BASE, 0x08000000);
105 /* memory smaller than 1MB is impossible */
106 if (dramsize < (1 << 20))
109 /* set SDRAM CS0 size according to the amount of RAM found */
111 out_be32((void *)MPC5XXX_SDRAM_CS0CFG,
112 (0x13 + __builtin_ffs(dramsize >> 20) - 1));
114 out_be32((void *)MPC5XXX_SDRAM_CS0CFG, 0); /* disabled */
117 /* let SDRAM CS1 start right after CS0 */
118 out_be32((void *)MPC5XXX_SDRAM_CS1CFG, dramsize + 0x0000001C);
120 /* find RAM size using SDRAM CS1 only */
121 test1 = get_ram_size((long *)(CONFIG_SYS_SDRAM_BASE + dramsize),
125 /* memory smaller than 1MB is impossible */
126 if (dramsize2 < (1 << 20))
129 /* set SDRAM CS1 size according to the amount of RAM found */
131 out_be32((void *)MPC5XXX_SDRAM_CS1CFG, (dramsize |
132 (0x13 + __builtin_ffs(dramsize2 >> 20) - 1)));
134 out_be32((void *)MPC5XXX_SDRAM_CS1CFG, dramsize); /* disabled */
137 #else /* CONFIG_SYS_RAMBOOT */
139 /* retrieve size of memory connected to SDRAM CS0 */
140 dramsize = in_be32((void *)MPC5XXX_SDRAM_CS0CFG) & 0xFF;
141 if (dramsize >= 0x13)
142 dramsize = (1 << (dramsize - 0x13)) << 20;
146 /* retrieve size of memory connected to SDRAM CS1 */
147 dramsize2 = in_be32((void *)MPC5XXX_SDRAM_CS1CFG) & 0xFF;
148 if (dramsize2 >= 0x13)
149 dramsize2 = (1 << (dramsize2 - 0x13)) << 20;
153 #endif /* CONFIG_SYS_RAMBOOT */
156 * On MPC5200B we need to set the special configuration delay in the
157 * DDR controller. Please refer to Freescale's AN3221 "MPC5200B SDRAM
158 * Initialization and Configuration", 3.3.1 SDelay--MBAR + 0x0190:
160 * "The SDelay should be written to a value of 0x00000004. It is
161 * required to account for changes caused by normal wafer processing
166 if ((SVR_MJREV(svr) >= 2) &&
167 (PVR_MAJ(pvr) == 1) && (PVR_MIN(pvr) == 4))
168 out_be32((void *)MPC5XXX_SDRAM_SDELAY, 0x04);
170 return dramsize + dramsize2;
175 char *s = getenv("serial#");
177 puts ("Board: InterControl digsyMTC");
187 int board_early_init_r(void)
190 * Now, when we are in RAM, enable flash write access for detection
191 * process. Note that CS_BOOT cannot be cleared when executing in
194 /* disable CS_BOOT */
195 clrbits_be32((void *)MPC5XXX_ADDECR, (1 << 25));
197 setbits_be32((void *)MPC5XXX_ADDECR, (1 << 17));
199 setbits_be32((void *)MPC5XXX_ADDECR, (1 << 16));
201 #if defined(CONFIG_USB_OHCI_NEW) && defined(CONFIG_SYS_USB_OHCI_CPU_INIT)
202 /* Low level USB init, required for proper kernel operation */
208 void board_get_enetaddr (uchar * enet)
211 ushort addr_of_eth_addr = 0;
213 ushort len_sys_cfg = 0;
215 /* check identification word */
216 eeprom_read(EEPROM_ADDR, EEPROM_ADDR_IDENT, (uchar *)&read, 2);
217 if (read != EEPROM_IDENT)
220 /* calculate offset of config area */
221 eeprom_read(EEPROM_ADDR, EEPROM_ADDR_LEN_SYS, (uchar *)&len_sys, 2);
222 eeprom_read(EEPROM_ADDR, EEPROM_ADDR_LEN_SYSCFG,
223 (uchar *)&len_sys_cfg, 2);
224 addr_of_eth_addr = (len_sys + len_sys_cfg + EEPROM_ADDR_ETHADDR) << 1;
225 if (addr_of_eth_addr >= EEPROM_LEN)
228 eeprom_read(EEPROM_ADDR, addr_of_eth_addr, enet, 6);
231 int misc_init_r(void)
235 if (!eth_getenv_enetaddr("ethaddr", enetaddr)) {
236 board_get_enetaddr(enetaddr);
237 eth_setenv_enetaddr("ethaddr", enetaddr);
244 static struct pci_controller hose;
246 extern void pci_mpc5xxx_init(struct pci_controller *);
248 void pci_init_board(void)
250 pci_mpc5xxx_init(&hose);
254 #ifdef CONFIG_CMD_IDE
256 #ifdef CONFIG_IDE_RESET
258 void init_ide_reset(void)
260 debug ("init_ide_reset\n");
262 /* set gpio output value to 1 */
263 setbits_be32((void *)MPC5XXX_WU_GPIO_DATA_O, (1 << 25));
264 /* open drain output */
265 setbits_be32((void *)MPC5XXX_WU_GPIO_ODE, (1 << 25));
266 /* direction output */
267 setbits_be32((void *)MPC5XXX_WU_GPIO_DIR, (1 << 25));
269 setbits_be32((void *)MPC5XXX_WU_GPIO_ENABLE, (1 << 25));
273 void ide_set_reset(int idereset)
275 debug ("ide_reset(%d)\n", idereset);
277 /* set gpio output value to 0 */
278 clrbits_be32((void *)MPC5XXX_WU_GPIO_DATA_O, (1 << 25));
279 /* open drain output */
280 setbits_be32((void *)MPC5XXX_WU_GPIO_ODE, (1 << 25));
281 /* direction output */
282 setbits_be32((void *)MPC5XXX_WU_GPIO_DIR, (1 << 25));
284 setbits_be32((void *)MPC5XXX_WU_GPIO_ENABLE, (1 << 25));
288 /* set gpio output value to 1 */
289 setbits_be32((void *)MPC5XXX_WU_GPIO_DATA_O, (1 << 25));
290 /* open drain output */
291 setbits_be32((void *)MPC5XXX_WU_GPIO_ODE, (1 << 25));
292 /* direction output */
293 setbits_be32((void *)MPC5XXX_WU_GPIO_DIR, (1 << 25));
295 setbits_be32((void *)MPC5XXX_WU_GPIO_ENABLE, (1 << 25));
297 #endif /* CONFIG_IDE_RESET */
299 #if defined(CONFIG_OF_LIBFDT) && defined(CONFIG_OF_BOARD_SETUP)
300 void ft_board_setup(void *blob, bd_t *bd)
302 ft_cpu_setup(blob, bd);
304 #endif /* defined(CONFIG_OF_LIBFDT) && defined(CONFIG_OF_BOARD_SETUP) */
306 #endif /* CONFIG_CMD_IDE */