2 * (C) Copyright 2003-2004
3 * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
6 * Mark Jonas, Freescale Semiconductor, mark.jonas@motorola.com.
12 * Wolfgang Grandegger, DENX Software Engineering, wg@denx.de.
14 * See file CREDITS for list of people who contributed to this
17 * This program is free software; you can redistribute it and/or
18 * modify it under the terms of the GNU General Public License as
19 * published by the Free Software Foundation; either version 2 of
20 * the License, or (at your option) any later version.
22 * This program is distributed in the hope that it will be useful,
23 * but WITHOUT ANY WARRANTY; without even the implied warranty of
24 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25 * GNU General Public License for more details.
27 * You should have received a copy of the GNU General Public License
28 * along with this program; if not, write to the Free Software
29 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
41 #include <asm/processor.h>
44 #ifdef CONFIG_OF_LIBFDT
45 #include <fdt_support.h>
46 #endif /* CONFIG_OF_LIBFDT */
49 #ifdef CONFIG_MPC5200_DDR
50 /* Settings for XLB = 132 MHz */
51 #define SDRAM_MODE 0x018D0000
52 #define SDRAM_EMODE 0x40090000
53 #define SDRAM_CONTROL 0x714f0f00
54 #define SDRAM_CONFIG1 0x73722930
55 #define SDRAM_CONFIG2 0x47770000
56 #define SDRAM_TAPDELAY 0x10000000
58 #error SDRAM is not supported on this board
61 DECLARE_GLOBAL_DATA_PTR;
63 static void sdram_start (int hi_addr)
65 struct mpc5xxx_sdram *sdram = (struct mpc5xxx_sdram *)MPC5XXX_SDRAM;
66 long hi_addr_bit = hi_addr ? 0x01000000 : 0;
68 /* unlock mode register */
69 out_be32 (&sdram->ctrl, SDRAM_CONTROL | 0x80000000 | hi_addr_bit);
71 /* precharge all banks */
72 out_be32 (&sdram->ctrl, SDRAM_CONTROL | 0x80000002 | hi_addr_bit);
74 /* set mode register: extended mode */
75 out_be32 (&sdram->mode, SDRAM_EMODE);
77 /* set mode register: reset DLL */
78 out_be32 (&sdram->mode, SDRAM_MODE | 0x04000000);
80 /* precharge all banks */
81 out_be32 (&sdram->ctrl, SDRAM_CONTROL | 0x80000002 | hi_addr_bit);
84 out_be32 (&sdram->ctrl, SDRAM_CONTROL | 0x80000004 | hi_addr_bit);
86 /* set mode register */
87 out_be32 (&sdram->mode, SDRAM_MODE);
89 /* normal operation */
90 out_be32 (&sdram->ctrl, SDRAM_CONTROL | hi_addr_bit);
94 * ATTENTION: Although partially referenced initdram does NOT make real
95 * use of CONFIG_SYS_SDRAM_BASE. The code does not work if
96 * CONFIG_SYS_SDRAM_BASE is something else than 0x00000000.
99 phys_size_t initdram (int board_type)
101 struct mpc5xxx_mmap_ctl *mmap_ctl =
102 (struct mpc5xxx_mmap_ctl *)CONFIG_SYS_MBAR;
103 struct mpc5xxx_sdram *sdram = (struct mpc5xxx_sdram *)MPC5XXX_SDRAM;
104 struct mpc5xxx_cdm *cdm = (struct mpc5xxx_cdm *)MPC5XXX_CDM;
109 /* setup SDRAM chip selects */
110 out_be32 (&mmap_ctl->sdram0, 0x0000001e); /* 2G at 0x0 */
111 out_be32 (&mmap_ctl->sdram1, 0x00000000); /* disabled */
113 /* setup config registers */
114 out_be32 (&sdram->config1, SDRAM_CONFIG1);
115 out_be32 (&sdram->config2, SDRAM_CONFIG2);
118 out_be32 (&cdm->porcfg, SDRAM_TAPDELAY);
120 /* find RAM size using SDRAM CS0 only */
122 test1 = get_ram_size ((long *)CONFIG_SYS_SDRAM_BASE, 0x80000000);
124 test2 = get_ram_size ((long *)CONFIG_SYS_SDRAM_BASE, 0x80000000);
132 /* memory smaller than 1MB is impossible */
133 if (dramsize < (1 << 20))
136 /* set SDRAM CS0 size according to the amount of RAM found */
138 out_be32 (&mmap_ctl->sdram0,
139 0x13 + __builtin_ffs (dramsize >> 20) - 1);
141 out_be32 (&mmap_ctl->sdram1, 0); /* disabled */
144 * On MPC5200B we need to set the special configuration delay in the
145 * DDR controller. Please refer to Freescale's AN3221 "MPC5200B SDRAM
146 * Initialization and Configuration", 3.3.1 SDelay--MBAR + 0x0190:
148 * "The SDelay should be written to a value of 0x00000004. It is
149 * required to account for changes caused by normal wafer processing
152 out_be32 (&sdram->sdelay, 0x04);
154 return dramsize + dramsize2;
157 int checkboard (void)
159 puts ("Board: IPEK01 \n");
163 void flash_preinit (void)
165 struct mpc5xxx_lpb *lpb = (struct mpc5xxx_lpb *)MPC5XXX_LPB;
168 * Now, when we are in RAM, enable flash write
169 * access for detection process.
170 * Note that CS_BOOT cannot be cleared when
171 * executing in flash.
173 clrbits_be32 (&lpb->cs0_cfg, 0x1); /* clear RO */
176 void flash_afterinit (ulong start, ulong size)
178 struct mpc5xxx_mmap_ctl *mmap_ctl =
179 (struct mpc5xxx_mmap_ctl *)CONFIG_SYS_MBAR;
181 #if defined(CONFIG_BOOT_ROM)
183 out_be32 (&mmap_ctl->cs1_start, START_REG (start));
184 out_be32 (&mmap_ctl->cs1_stop, STOP_REG (start, size));
187 out_be32 (&mmap_ctl->boot_start, START_REG (start));
188 out_be32 (&mmap_ctl->cs0_start, START_REG (start));
189 out_be32 (&mmap_ctl->boot_stop, STOP_REG (start, size));
190 out_be32 (&mmap_ctl->cs0_stop, STOP_REG (start, size));
194 extern flash_info_t flash_info[]; /* info for FLASH chips */
196 int misc_init_r (void)
198 /* adjust flash start */
199 gd->bd->bi_flashstart = flash_info[0].start[0];
204 static struct pci_controller hose;
206 extern void pci_mpc5xxx_init (struct pci_controller *);
208 void pci_init_board (void)
210 pci_mpc5xxx_init (&hose);
214 #if defined(CONFIG_OF_LIBFDT) && defined(CONFIG_OF_BOARD_SETUP)
215 void ft_board_setup (void *blob, bd_t * bd)
217 ft_cpu_setup (blob, bd);
218 fdt_fixup_memory (blob, (u64) bd->bi_memstart, (u64) bd->bi_memsize);
220 #endif /* defined(CONFIG_OF_LIBFDT) && defined(CONFIG_OF_BOARD_SETUP) */
222 int board_eth_init(bd_t *bis)
224 cpu_eth_init(bis); /* Built in FEC comes first */
225 return pci_eth_init(bis);
229 extern GraphicDevice mb862xx;
231 static const gdc_regs init_regs[] = {
232 {0x0100, 0x00000900},
233 {0x0020, 0x80190257},
234 {0x0024, 0x00000000},
235 {0x0028, 0x00000000},
236 {0x002c, 0x00000000},
237 {0x0110, 0x00000000},
238 {0x0114, 0x00000000},
239 {0x0118, 0x02570320},
240 {0x0004, 0x041f0000},
241 {0x0008, 0x031f031f},
242 {0x000c, 0x067f0347},
243 {0x0010, 0x02780000},
244 {0x0014, 0x0257025c},
245 {0x0018, 0x00000000},
246 {0x001c, 0x02570320},
247 {0x0100, 0x80010900},
251 const gdc_regs *board_get_regs (void)
256 /* Returns Lime base address */
257 unsigned int board_video_init (void)
259 if (mb862xx_probe (CONFIG_SYS_LIME_BASE) != MB862XX_TYPE_LIME)
262 mb862xx.winSizeX = 800;
263 mb862xx.winSizeY = 600;
264 mb862xx.gdfIndex = GDF_15BIT_555RGB;
265 mb862xx.gdfBytesPP = 2;
267 return CONFIG_SYS_LIME_BASE;
270 #if defined(CONFIG_CONSOLE_EXTRA_INFO)
272 * Return text to be printed besides the logo.
274 void video_get_info_str (int line_number, char *info)
276 if (line_number == 1)
277 strcpy (info, " Board: IPEK01");
282 #endif /* CONFIG_VIDEO */