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:
67 printf ("BOARD: %s\n", CFG_BOARD_NAME);
74 * report calling processor number
79 return 0; /* we are on single CPU platform for a while */
82 long int dram_size (int board_type)
84 return 0x20000000; /* 256M bytes */
87 long int initdram (int board_type)
89 return dram_size (board_type);
92 /* DRAM check routines copied from gw8260 */
94 #if defined (CFG_DRAM_TEST)
96 /*********************************************************************/
97 /* NAME: move64() - moves a double word (64-bit) */
100 /* this function performs a double word move from the data at */
101 /* the source pointer to the location at the destination pointer. */
104 /* unsigned long long *src - pointer to data to move */
107 /* unsigned long long *dest - pointer to locate to move data */
112 /* RESTRICTIONS/LIMITATIONS: */
113 /* May cloober fr0. */
115 /*********************************************************************/
116 static void move64 (unsigned long long *src, unsigned long long *dest)
118 asm ("lfd 0, 0(3)\n\t" /* fpr0 = *scr */
119 "stfd 0, 0(4)" /* *dest = fpr0 */
120 : : :"fr0"); /* Clobbers fr0 */
124 #if defined (CFG_DRAM_TEST_DATA)
126 unsigned long long pattern[] = {
127 0xaaaaaaaaaaaaaaaaULL,
128 0xccccccccccccccccULL,
129 0xf0f0f0f0f0f0f0f0ULL,
130 0xff00ff00ff00ff00ULL,
131 0xffff0000ffff0000ULL,
132 0xffffffff00000000ULL,
133 0x00000000ffffffffULL,
134 0x0000ffff0000ffffULL,
135 0x00ff00ff00ff00ffULL,
136 0x0f0f0f0f0f0f0f0fULL,
137 0x3333333333333333ULL,
138 0x5555555555555555ULL
141 /*********************************************************************/
142 /* NAME: mem_test_data() - test data lines for shorts and opens */
145 /* Tests data lines for shorts and opens by forcing adjacent data */
146 /* to opposite states. Because the data lines could be routed in */
147 /* an arbitrary manner the must ensure test patterns ensure that */
148 /* every case is tested. By using the following series of binary */
149 /* patterns every combination of adjacent bits is test regardless */
152 /* ...101010101010101010101010 */
153 /* ...110011001100110011001100 */
154 /* ...111100001111000011110000 */
155 /* ...111111110000000011111111 */
157 /* Carrying this out, gives us six hex patterns as follows: */
159 /* 0xaaaaaaaaaaaaaaaa */
160 /* 0xcccccccccccccccc */
161 /* 0xf0f0f0f0f0f0f0f0 */
162 /* 0xff00ff00ff00ff00 */
163 /* 0xffff0000ffff0000 */
164 /* 0xffffffff00000000 */
166 /* The number test patterns will always be given by: */
168 /* log(base 2)(number data bits) = log2 (64) = 6 */
170 /* To test for short and opens to other signals on our boards. we */
172 /* test with the 1's complemnt of the paterns as well. */
175 /* Displays failing test pattern */
178 /* 0 - Passed test */
179 /* 1 - Failed test */
181 /* RESTRICTIONS/LIMITATIONS: */
182 /* Assumes only one one SDRAM bank */
184 /*********************************************************************/
185 int mem_test_data (void)
187 unsigned long long *pmem = (unsigned long long *)CFG_MEMTEST_START;
188 unsigned long long temp64;
189 int num_patterns = sizeof (pattern) / sizeof (pattern[0]);
193 for (i = 0; i < num_patterns; i++) {
194 move64 (&(pattern[i]), pmem);
195 move64 (pmem, &temp64);
197 /* hi = (temp64>>32) & 0xffffffff; */
198 /* lo = temp64 & 0xffffffff; */
199 /* printf ("\ntemp64 = 0x%08x%08x", hi, lo); */
201 hi = (pattern[i] >> 32) & 0xffffffff;
202 lo = pattern[i] & 0xffffffff;
203 /* printf ("\npattern[%d] = 0x%08x%08x", i, hi, lo); */
205 if (temp64 != pattern[i]) {
206 printf ("\n Data Test Failed, pattern 0x%08x%08x",
214 #endif /* CFG_DRAM_TEST_DATA */
216 #if defined (CFG_DRAM_TEST_ADDRESS)
217 /*********************************************************************/
218 /* NAME: mem_test_address() - test address lines */
221 /* This function performs a test to verify that each word im */
222 /* memory is uniquly addressable. The test sequence is as follows: */
224 /* 1) write the address of each word to each word. */
225 /* 2) verify that each location equals its address */
228 /* Displays failing test pattern and address */
231 /* 0 - Passed test */
232 /* 1 - Failed test */
234 /* RESTRICTIONS/LIMITATIONS: */
237 /*********************************************************************/
238 int mem_test_address (void)
240 volatile unsigned int *pmem =
241 (volatile unsigned int *)CFG_MEMTEST_START;
242 const unsigned int size = (CFG_MEMTEST_END - CFG_MEMTEST_START) / 4;
245 /* write address to each location */
246 for (i = 0; i < size; i++) {
250 /* verify each loaction */
251 for (i = 0; i < size; i++) {
253 printf ("\n Address Test Failed at 0x%x", i);
259 #endif /* CFG_DRAM_TEST_ADDRESS */
261 #if defined (CFG_DRAM_TEST_WALK)
262 /*********************************************************************/
263 /* NAME: mem_march() - memory march */
266 /* Marches up through memory. At each location verifies rmask if */
267 /* read = 1. At each location write wmask if write = 1. Displays */
268 /* failing address and pattern. */
271 /* volatile unsigned long long * base - start address of test */
272 /* unsigned int size - number of dwords(64-bit) to test */
273 /* unsigned long long rmask - read verify mask */
274 /* unsigned long long wmask - wrtie verify mask */
275 /* short read - verifies rmask if read = 1 */
276 /* short write - writes wmask if write = 1 */
279 /* Displays failing test pattern and address */
282 /* 0 - Passed test */
283 /* 1 - Failed test */
285 /* RESTRICTIONS/LIMITATIONS: */
288 /*********************************************************************/
289 int mem_march (volatile unsigned long long *base,
291 unsigned long long rmask,
292 unsigned long long wmask, short read, short write)
295 unsigned long long temp;
296 unsigned int hitemp, lotemp, himask, lomask;
298 for (i = 0; i < size; i++) {
300 /* temp = base[i]; */
301 move64 ((unsigned long long *)&(base[i]), &temp);
303 hitemp = (temp >> 32) & 0xffffffff;
304 lotemp = temp & 0xffffffff;
305 himask = (rmask >> 32) & 0xffffffff;
306 lomask = rmask & 0xffffffff;
308 printf ("\n Walking one's test failed: \
309 address = 0x%08x," "\n\texpected \
310 0x%08x%08x, found 0x%08x%08x", i << 3,\
311 himask, lomask, hitemp, lotemp);
316 /* base[i] = wmask; */
317 move64 (&wmask, (unsigned long long *)&(base[i]));
322 #endif /* CFG_DRAM_TEST_WALK */
324 /*********************************************************************/
325 /* NAME: mem_test_walk() - a simple walking ones test */
328 /* Performs a walking ones through entire physical memory. The */
329 /* test uses as series of memory marches, mem_march(), to verify */
330 /* and write the test patterns to memory. The test sequence is as */
332 /* 1) march writing 0000...0001 */
333 /* 2) march verifying 0000...0001 , writing 0000...0010 */
334 /* 3) repeat step 2 shifting masks left 1 bit each time unitl */
335 /* the write mask equals 1000...0000 */
336 /* 4) march verifying 1000...0000 */
337 /* The test fails if any of the memory marches return a failure. */
340 /* Displays which pass on the memory test is executing */
343 /* 0 - Passed test */
344 /* 1 - Failed test */
346 /* RESTRICTIONS/LIMITATIONS: */
349 /*********************************************************************/
350 int mem_test_walk (void)
352 unsigned long long mask;
353 volatile unsigned long long *pmem =
354 (volatile unsigned long long *)CFG_MEMTEST_START;
355 const unsigned long size = (CFG_MEMTEST_END - CFG_MEMTEST_START) / 8;
361 printf ("Initial Pass");
362 mem_march (pmem, size, 0x0, 0x1, 0, 1);
364 printf ("\b\b\b\b\b\b\b\b\b\b\b\b");
367 printf ("\b\b\b\b\b\b\b\b\b\b\b\b");
369 for (i = 0; i < 63; i++) {
370 printf ("Pass %2d", i + 2);
371 if (mem_march(pmem, size, mask, mask << 1, 1, 1) != 0)
372 /*printf ("mask: 0x%x, pass: %d, ", mask, i); */
375 printf ("\b\b\b\b\b\b\b");
378 printf ("Last Pass");
379 if (mem_march(pmem, size, 0, mask, 0, 1) != 0) {
380 /* printf ("mask: 0x%x", mask); */
383 printf ("\b\b\b\b\b\b\b\b\b");
385 printf ("\b\b\b\b\b\b\b\b\b");
390 /*********************************************************************/
391 /* NAME: testdram() - calls any enabled memory tests */
394 /* Runs memory tests if the environment test variables are set to */
398 /* testdramdata - If set to 'y', data test is run. */
399 /* testdramaddress - If set to 'y', address test is run. */
400 /* testdramwalk - If set to 'y', walking ones test is run */
406 /* 0 - Passed test */
407 /* 1 - Failed test */
409 /* RESTRICTIONS/LIMITATIONS: */
412 /*********************************************************************/
416 int rundata, runaddress, runwalk;
418 s = getenv ("testdramdata");
419 rundata = (s && (*s == 'y')) ? 1 : 0;
420 s = getenv ("testdramaddress");
421 runaddress = (s && (*s == 'y')) ? 1 : 0;
422 s = getenv ("testdramwalk");
423 runwalk = (s && (*s == 'y')) ? 1 : 0;
426 /* runaddress = 0; */
429 if ((rundata == 1) || (runaddress == 1) || (runwalk == 1))
430 printf ("Testing RAM from 0x%08x to 0x%08x ... \
431 (don't panic... that will take a moment !!!!)\n", \
432 CFG_MEMTEST_START, CFG_MEMTEST_END);
433 #ifdef CFG_DRAM_TEST_DATA
435 printf ("Test DATA ... ");
436 if (mem_test_data () == 1) {
437 printf ("failed \n");
443 #ifdef CFG_DRAM_TEST_ADDRESS
444 if (runaddress == 1) {
445 printf ("Test ADDRESS ... ");
446 if (mem_test_address () == 1) {
447 printf ("failed \n");
453 #ifdef CFG_DRAM_TEST_WALK
455 printf ("Test WALKING ONEs ... ");
456 if (mem_test_walk () == 1) {
457 printf ("failed \n");
463 if ((rundata == 1) || (runaddress == 1) || (runwalk == 1))
468 #endif /* CFG_DRAM_TEST */
470 #if defined(CONFIG_OF_FLAT_TREE) && defined(CONFIG_OF_BOARD_SETUP)
472 ft_board_setup (void *blob, bd_t *bd)
477 ft_cpu_setup (blob, bd);
479 p = ft_get_prop (blob, "/memory/reg", &len);
481 *p++ = cpu_to_be32 (bd->bi_memstart);
482 *p = cpu_to_be32 (bd->bi_memsize);