2 * (C) Copyright 2005 Freescale Semiconductor, Inc.
4 * Roy Zang <tie-fei.zang@freescale.com>
6 * See file CREDITS for list of people who contributed to this
9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License as
11 * published by the Free Software Foundation; either version 2 of
12 * the License, or (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
24 * modifications for the Tsi108 Emul Board by avb@Tundra
28 * board support/init functions for the
29 * Freescale MPC7448 HPC2 (High-Performance Computing 2 Platform).
34 #if defined(CONFIG_OF_FLAT_TREE)
36 extern void ft_cpu_setup(void *blob, bd_t *bd);
41 extern void flush_data_cache(void);
42 extern void invalidate_l1_instruction_cache(void);
43 extern void tsi108_init_f(void);
45 int display_mem_map(void);
47 void after_reloc(ulong dest_addr)
49 DECLARE_GLOBAL_DATA_PTR;
52 * Jump to the main U-Boot board init code
54 board_init_r((gd_t *) gd, dest_addr);
59 * Check Board Identity:
68 printf("BOARD: %s\n", CFG_BOARD_NAME);
75 * report calling processor number
80 return 0; /* we are on single CPU platform for a while */
83 long int dram_size(int board_type)
85 return 0x20000000; /* 256M bytes */
88 long int initdram(int board_type)
90 return dram_size(board_type);
93 /* DRAM check routines copied from gw8260 */
95 #if defined (CFG_DRAM_TEST)
97 /*********************************************************************/
98 /* NAME: move64() - moves a double word (64-bit) */
101 /* this function performs a double word move from the data at */
102 /* the source pointer to the location at the destination pointer. */
105 /* unsigned long long *src - pointer to data to move */
108 /* unsigned long long *dest - pointer to locate to move data */
113 /* RESTRICTIONS/LIMITATIONS: */
114 /* May cloober fr0. */
116 /*********************************************************************/
117 static void move64(unsigned long long *src, unsigned long long *dest)
119 asm("lfd 0, 0(3)\n\t" /* fpr0 = *scr */
120 "stfd 0, 0(4)" /* *dest = fpr0 */
121 : : :"fr0"); /* Clobbers fr0 */
125 #if defined (CFG_DRAM_TEST_DATA)
127 unsigned long long pattern[] = {
128 0xaaaaaaaaaaaaaaaaULL,
129 0xccccccccccccccccULL,
130 0xf0f0f0f0f0f0f0f0ULL,
131 0xff00ff00ff00ff00ULL,
132 0xffff0000ffff0000ULL,
133 0xffffffff00000000ULL,
134 0x00000000ffffffffULL,
135 0x0000ffff0000ffffULL,
136 0x00ff00ff00ff00ffULL,
137 0x0f0f0f0f0f0f0f0fULL,
138 0x3333333333333333ULL,
139 0x5555555555555555ULL
142 /*********************************************************************/
143 /* NAME: mem_test_data() - test data lines for shorts and opens */
146 /* Tests data lines for shorts and opens by forcing adjacent data */
147 /* to opposite states. Because the data lines could be routed in */
148 /* an arbitrary manner the must ensure test patterns ensure that */
149 /* every case is tested. By using the following series of binary */
150 /* patterns every combination of adjacent bits is test regardless */
153 /* ...101010101010101010101010 */
154 /* ...110011001100110011001100 */
155 /* ...111100001111000011110000 */
156 /* ...111111110000000011111111 */
158 /* Carrying this out, gives us six hex patterns as follows: */
160 /* 0xaaaaaaaaaaaaaaaa */
161 /* 0xcccccccccccccccc */
162 /* 0xf0f0f0f0f0f0f0f0 */
163 /* 0xff00ff00ff00ff00 */
164 /* 0xffff0000ffff0000 */
165 /* 0xffffffff00000000 */
167 /* The number test patterns will always be given by: */
169 /* log(base 2)(number data bits) = log2 (64) = 6 */
171 /* To test for short and opens to other signals on our boards. we */
173 /* test with the 1's complemnt of the paterns as well. */
176 /* Displays failing test pattern */
179 /* 0 - Passed test */
180 /* 1 - Failed test */
182 /* RESTRICTIONS/LIMITATIONS: */
183 /* Assumes only one one SDRAM bank */
185 /*********************************************************************/
186 int mem_test_data(void)
188 unsigned long long *pmem = (unsigned long long *)CFG_MEMTEST_START;
189 unsigned long long temp64;
190 int num_patterns = sizeof(pattern) / sizeof(pattern[0]);
194 for (i = 0; i < num_patterns; i++) {
195 move64(&(pattern[i]), pmem);
196 move64(pmem, &temp64);
198 /* hi = (temp64>>32) & 0xffffffff; */
199 /* lo = temp64 & 0xffffffff; */
200 /* printf("\ntemp64 = 0x%08x%08x", hi, lo); */
202 hi = (pattern[i] >> 32) & 0xffffffff;
203 lo = pattern[i] & 0xffffffff;
204 /* printf("\npattern[%d] = 0x%08x%08x", i, hi, lo); */
206 if (temp64 != pattern[i]) {
207 printf("\n Data Test Failed, pattern 0x%08x%08x",
215 #endif /* CFG_DRAM_TEST_DATA */
217 #if defined (CFG_DRAM_TEST_ADDRESS)
218 /*********************************************************************/
219 /* NAME: mem_test_address() - test address lines */
222 /* This function performs a test to verify that each word im */
223 /* memory is uniquly addressable. The test sequence is as follows: */
225 /* 1) write the address of each word to each word. */
226 /* 2) verify that each location equals its address */
229 /* Displays failing test pattern and address */
232 /* 0 - Passed test */
233 /* 1 - Failed test */
235 /* RESTRICTIONS/LIMITATIONS: */
238 /*********************************************************************/
239 int mem_test_address(void)
241 volatile unsigned int *pmem =
242 (volatile unsigned int *)CFG_MEMTEST_START;
243 const unsigned int size = (CFG_MEMTEST_END - CFG_MEMTEST_START) / 4;
246 /* write address to each location */
247 for (i = 0; i < size; i++) {
251 /* verify each loaction */
252 for (i = 0; i < size; i++) {
254 printf("\n Address Test Failed at 0x%x", i);
260 #endif /* CFG_DRAM_TEST_ADDRESS */
262 #if defined (CFG_DRAM_TEST_WALK)
263 /*********************************************************************/
264 /* NAME: mem_march() - memory march */
267 /* Marches up through memory. At each location verifies rmask if */
268 /* read = 1. At each location write wmask if write = 1. Displays */
269 /* failing address and pattern. */
272 /* volatile unsigned long long * base - start address of test */
273 /* unsigned int size - number of dwords(64-bit) to test */
274 /* unsigned long long rmask - read verify mask */
275 /* unsigned long long wmask - wrtie verify mask */
276 /* short read - verifies rmask if read = 1 */
277 /* short write - writes wmask if write = 1 */
280 /* Displays failing test pattern and address */
283 /* 0 - Passed test */
284 /* 1 - Failed test */
286 /* RESTRICTIONS/LIMITATIONS: */
289 /*********************************************************************/
290 int mem_march(volatile unsigned long long *base,
292 unsigned long long rmask,
293 unsigned long long wmask, short read, short write)
296 unsigned long long temp;
297 unsigned int hitemp, lotemp, himask, lomask;
299 for (i = 0; i < size; i++) {
301 /* temp = base[i]; */
302 move64((unsigned long long *)&(base[i]), &temp);
304 hitemp = (temp >> 32) & 0xffffffff;
305 lotemp = temp & 0xffffffff;
306 himask = (rmask >> 32) & 0xffffffff;
307 lomask = rmask & 0xffffffff;
309 printf("\n Walking one's test failed: \
310 address = 0x%08x," "\n\texpected \
311 0x%08x%08x, found 0x%08x%08x", i << 3,\
312 himask, lomask, hitemp, lotemp);
317 /* base[i] = wmask; */
318 move64(&wmask, (unsigned long long *)&(base[i]));
323 #endif /* CFG_DRAM_TEST_WALK */
325 /*********************************************************************/
326 /* NAME: mem_test_walk() - a simple walking ones test */
329 /* Performs a walking ones through entire physical memory. The */
330 /* test uses as series of memory marches, mem_march(), to verify */
331 /* and write the test patterns to memory. The test sequence is as */
333 /* 1) march writing 0000...0001 */
334 /* 2) march verifying 0000...0001 , writing 0000...0010 */
335 /* 3) repeat step 2 shifting masks left 1 bit each time unitl */
336 /* the write mask equals 1000...0000 */
337 /* 4) march verifying 1000...0000 */
338 /* The test fails if any of the memory marches return a failure. */
341 /* Displays which pass on the memory test is executing */
344 /* 0 - Passed test */
345 /* 1 - Failed test */
347 /* RESTRICTIONS/LIMITATIONS: */
350 /*********************************************************************/
351 int mem_test_walk(void)
353 unsigned long long mask;
354 volatile unsigned long long *pmem =
355 (volatile unsigned long long *)CFG_MEMTEST_START;
356 const unsigned long size = (CFG_MEMTEST_END - CFG_MEMTEST_START) / 8;
362 printf("Initial Pass");
363 mem_march(pmem, size, 0x0, 0x1, 0, 1);
365 printf("\b\b\b\b\b\b\b\b\b\b\b\b");
368 printf("\b\b\b\b\b\b\b\b\b\b\b\b");
370 for (i = 0; i < 63; i++) {
371 printf("Pass %2d", i + 2);
372 if (mem_march(pmem, size, mask, mask << 1, 1, 1) != 0) {
373 /*printf("mask: 0x%x, pass: %d, ", mask, i); */
377 printf("\b\b\b\b\b\b\b");
381 if (mem_march(pmem, size, 0, mask, 0, 1) != 0) {
382 /* printf("mask: 0x%x", mask); */
385 printf("\b\b\b\b\b\b\b\b\b");
387 printf("\b\b\b\b\b\b\b\b\b");
392 /*********************************************************************/
393 /* NAME: testdram() - calls any enabled memory tests */
396 /* Runs memory tests if the environment test variables are set to */
400 /* testdramdata - If set to 'y', data test is run. */
401 /* testdramaddress - If set to 'y', address test is run. */
402 /* testdramwalk - If set to 'y', walking ones test is run */
408 /* 0 - Passed test */
409 /* 1 - Failed test */
411 /* RESTRICTIONS/LIMITATIONS: */
414 /*********************************************************************/
418 int rundata, runaddress, runwalk;
420 s = getenv("testdramdata");
421 rundata = (s && (*s == 'y')) ? 1 : 0;
422 s = getenv("testdramaddress");
423 runaddress = (s && (*s == 'y')) ? 1 : 0;
424 s = getenv("testdramwalk");
425 runwalk = (s && (*s == 'y')) ? 1 : 0;
428 /* runaddress = 0; */
431 if ((rundata == 1) || (runaddress == 1) || (runwalk == 1)) {
432 printf("Testing RAM from 0x%08x to 0x%08x ... \
433 (don't panic... that will take a moment !!!!)\n", \
434 CFG_MEMTEST_START, CFG_MEMTEST_END);
436 #ifdef CFG_DRAM_TEST_DATA
438 printf("Test DATA ... ");
439 if (mem_test_data () == 1) {
446 #ifdef CFG_DRAM_TEST_ADDRESS
447 if (runaddress == 1) {
448 printf("Test ADDRESS ... ");
449 if (mem_test_address () == 1) {
456 #ifdef CFG_DRAM_TEST_WALK
458 printf("Test WALKING ONEs ... ");
459 if (mem_test_walk() == 1) {
466 if ((rundata == 1) || (runaddress == 1) || (runwalk == 1)) {
472 #endif /* CFG_DRAM_TEST */
474 #if defined(CONFIG_OF_FLAT_TREE) && defined(CONFIG_OF_BOARD_SETUP)
476 ft_board_setup(void *blob, bd_t *bd)
481 ft_cpu_setup(blob, bd);
483 p = ft_get_prop(blob, "/memory/reg", &len);
485 *p++ = cpu_to_be32(bd->bi_memstart);
486 *p = cpu_to_be32(bd->bi_memsize);