blob: 6cebd1aeb6db265581144ccf5ecfd5e402dc6d26 [file] [log] [blame]
Stefan Roese1eac2a72006-11-29 15:42:37 +01001/*
2 * (C) Copyright 2006
3 * Stefan Roese, DENX Software Engineering, sr@denx.de.
4 *
5 * Based on original work by
6 * Roel Loeffen, (C) Copyright 2006 Prodrive B.V.
7 * Josh Huber, (C) Copyright 2001 Mission Critical Linux, Inc.
8 *
9 * See file CREDITS for list of people who contributed to this
10 * project.
11 *
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License as
14 * published by the Free Software Foundation; either version 2 of
15 * the License, or (at your option) any later version.
16 *
17 * This program is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
21 *
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, write to the Free Software
24 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
25 * MA 02111-1307 USA
26 *
27 * modifications for the DB64360 eval board based by Ingo.Assmus@keymile.com
28 * modifications for the cpci750 by reinhard.arlt@esd-electronics.com
29 * modifications for the P3M750 by roel.loeffen@prodrive.nl
30 */
31
32/*
33 * p3m750.c - main board support/init for the Prodrive p3m750/p3m7448.
34 */
35
36#include <common.h>
37#include <74xx_7xx.h>
38#include "../../Marvell/include/memory.h"
39#include "../../Marvell/include/pci.h"
40#include "../../Marvell/include/mv_gen_reg.h"
41#include <net.h>
42#include <i2c.h>
43
44#include "eth.h"
45#include "mpsc.h"
46#include "64460.h"
47#include "mv_regs.h"
48
49DECLARE_GLOBAL_DATA_PTR;
50
51#undef DEBUG
52/*#define DEBUG */
53
54#ifdef CONFIG_PCI
55#define MAP_PCI
56#endif /* of CONFIG_PCI */
57
58#ifdef DEBUG
59#define DP(x) x
60#else
61#define DP(x)
62#endif
63
64extern void flush_data_cache (void);
65extern void invalidate_l1_instruction_cache (void);
66extern flash_info_t flash_info[];
67
68/* ------------------------------------------------------------------------- */
69
70/* this is the current GT register space location */
71/* it starts at CFG_DFL_GT_REGS but moves later to CFG_GT_REGS */
72
73/* Unfortunately, we cant change it while we are in flash, so we initialize it
74 * to the "final" value. This means that any debug_led calls before
75 * board_early_init_f wont work right (like in cpu_init_f).
76 * See also my_remap_gt_regs below. (NTL)
77 */
78
79void board_prebootm_init (void);
80unsigned int INTERNAL_REG_BASE_ADDR = CFG_GT_REGS;
81int display_mem_map (void);
82
83/* ------------------------------------------------------------------------- */
84
85/*
86 * This is a version of the GT register space remapping function that
87 * doesn't touch globals (meaning, it's ok to run from flash.)
88 *
89 * Unfortunately, this has the side effect that a writable
90 * INTERNAL_REG_BASE_ADDR is impossible. Oh well.
91 */
92
93void my_remap_gt_regs (u32 cur_loc, u32 new_loc)
94{
95 u32 temp;
96
97 /* check and see if it's already moved */
98 temp = in_le32 ((u32 *) (new_loc + INTERNAL_SPACE_DECODE));
99 if ((temp & 0xffff) == new_loc >> 16)
100 return;
101
102 temp = (in_le32 ((u32 *) (cur_loc + INTERNAL_SPACE_DECODE)) &
103 0xffff0000) | (new_loc >> 16);
104
105 out_le32 ((u32 *) (cur_loc + INTERNAL_SPACE_DECODE), temp);
106
107 while (GTREGREAD (INTERNAL_SPACE_DECODE) != temp);
108}
109
110#ifdef CONFIG_PCI
111
112static void gt_pci_config (void)
113{
114 unsigned int stat;
115 unsigned int val = 0x00fff864; /* DINK32: BusNum 23:16, DevNum 15:11, */
116 /* FuncNum 10:8, RegNum 7:2 */
117
118 /*
119 * In PCIX mode devices provide their own bus and device numbers.
120 * We query the Discovery II's
121 * config registers by writing ones to the bus and device.
122 * We then update the Virtual register with the correct value for the
123 * bus and device.
124 */
125 if ((GTREGREAD (PCI_0_MODE) & (BIT4 | BIT5)) != 0) { /* if PCI-X */
126 GT_REG_WRITE (PCI_0_CONFIG_ADDR, BIT31 | val);
127
128 GT_REG_READ (PCI_0_CONFIG_DATA_VIRTUAL_REG, &stat);
129
130 GT_REG_WRITE (PCI_0_CONFIG_ADDR, BIT31 | val);
131 GT_REG_WRITE (PCI_0_CONFIG_DATA_VIRTUAL_REG,
132 (stat & 0xffff0000) | CFG_PCI_IDSEL);
133
134 }
135 if ((GTREGREAD (PCI_1_MODE) & (BIT4 | BIT5)) != 0) { /* if PCI-X */
136 GT_REG_WRITE (PCI_1_CONFIG_ADDR, BIT31 | val);
137 GT_REG_READ (PCI_1_CONFIG_DATA_VIRTUAL_REG, &stat);
138
139 GT_REG_WRITE (PCI_1_CONFIG_ADDR, BIT31 | val);
140 GT_REG_WRITE (PCI_1_CONFIG_DATA_VIRTUAL_REG,
141 (stat & 0xffff0000) | CFG_PCI_IDSEL);
142 }
143
144 /* Enable master */
145 PCI_MASTER_ENABLE (0, SELF);
146 PCI_MASTER_ENABLE (1, SELF);
147
148 /* Enable PCI0/1 Mem0 and IO 0 disable all others */
149 GT_REG_READ (BASE_ADDR_ENABLE, &stat);
150 stat |= (1 << 11) | (1 << 12) | (1 << 13) | (1 << 16) | (1 << 17) |
151 (1 << 18);
152 stat &= ~((1 << 9) | (1 << 10) | (1 << 14) | (1 << 15));
153 GT_REG_WRITE (BASE_ADDR_ENABLE, stat);
154
155 /* ronen:
156 * add write to pci remap registers for 64460.
157 * in 64360 when writing to pci base go and overide remap automaticaly,
158 * in 64460 it doesn't
159 */
160 GT_REG_WRITE (PCI_0_IO_BASE_ADDR, CFG_PCI0_IO_SPACE >> 16);
161 GT_REG_WRITE (PCI_0I_O_ADDRESS_REMAP, CFG_PCI0_IO_SPACE_PCI >> 16);
162 GT_REG_WRITE (PCI_0_IO_SIZE, (CFG_PCI0_IO_SIZE - 1) >> 16);
163
164 GT_REG_WRITE (PCI_0_MEMORY0_BASE_ADDR, CFG_PCI0_MEM_BASE >> 16);
165 GT_REG_WRITE (PCI_0MEMORY0_ADDRESS_REMAP, CFG_PCI0_MEM_BASE >> 16);
166 GT_REG_WRITE (PCI_0_MEMORY0_SIZE, (CFG_PCI0_MEM_SIZE - 1) >> 16);
167
168 GT_REG_WRITE (PCI_1_IO_BASE_ADDR, CFG_PCI1_IO_SPACE >> 16);
169 GT_REG_WRITE (PCI_1I_O_ADDRESS_REMAP, CFG_PCI1_IO_SPACE_PCI >> 16);
170 GT_REG_WRITE (PCI_1_IO_SIZE, (CFG_PCI1_IO_SIZE - 1) >> 16);
171
172 GT_REG_WRITE (PCI_1_MEMORY0_BASE_ADDR, CFG_PCI1_MEM_BASE >> 16);
173 GT_REG_WRITE (PCI_1MEMORY0_ADDRESS_REMAP, CFG_PCI1_MEM_BASE >> 16);
174 GT_REG_WRITE (PCI_1_MEMORY0_SIZE, (CFG_PCI1_MEM_SIZE - 1) >> 16);
175
176 /* PCI interface settings */
177 /* Timeout set to retry forever */
178 GT_REG_WRITE (PCI_0TIMEOUT_RETRY, 0x0);
179 GT_REG_WRITE (PCI_1TIMEOUT_RETRY, 0x0);
180
181 /* ronen - enable only CS0 and Internal reg!! */
182 GT_REG_WRITE (PCI_0BASE_ADDRESS_REGISTERS_ENABLE, 0xfffffdfe);
183 GT_REG_WRITE (PCI_1BASE_ADDRESS_REGISTERS_ENABLE, 0xfffffdfe);
184
185 /* ronen:
186 * update the pci internal registers base address.
187 */
188#ifdef MAP_PCI
189 for (stat = 0; stat <= PCI_HOST1; stat++)
190 pciWriteConfigReg (stat,
191 PCI_INTERNAL_REGISTERS_MEMORY_MAPPED_BASE_ADDRESS,
192 SELF, CFG_GT_REGS);
193#endif
194
195}
196#endif
197
198/* Setup CPU interface paramaters */
199static void gt_cpu_config (void)
200{
201 cpu_t cpu = get_cpu_type ();
202 ulong tmp;
203
204 /* cpu configuration register */
205 tmp = GTREGREAD (CPU_CONFIGURATION);
206 /* set the SINGLE_CPU bit see MV64460 */
207#ifndef CFG_GT_DUAL_CPU /* SINGLE_CPU seems to cause JTAG problems */
208 tmp |= CPU_CONF_SINGLE_CPU;
209#endif
210 tmp &= ~CPU_CONF_AACK_DELAY_2;
211 tmp |= CPU_CONF_DP_VALID;
212 tmp |= CPU_CONF_AP_VALID;
213 tmp |= CPU_CONF_PIPELINE;
214 GT_REG_WRITE (CPU_CONFIGURATION, tmp); /* Marvell (VXWorks) writes 0x20220FF */
215
216 /* CPU master control register */
217 tmp = GTREGREAD (CPU_MASTER_CONTROL);
218 tmp |= CPU_MAST_CTL_ARB_EN;
219
220 if ((cpu == CPU_7400) ||
221 (cpu == CPU_7410) || (cpu == CPU_7455) || (cpu == CPU_7450)) {
222
223 tmp |= CPU_MAST_CTL_CLEAN_BLK;
224 tmp |= CPU_MAST_CTL_FLUSH_BLK;
225
226 } else {
227 /* cleanblock must be cleared for CPUs
228 * that do not support this command (603e, 750)
229 * see Res#1 */
230 tmp &= ~CPU_MAST_CTL_CLEAN_BLK;
231 tmp &= ~CPU_MAST_CTL_FLUSH_BLK;
232 }
233 GT_REG_WRITE (CPU_MASTER_CONTROL, tmp);
234}
235
236/*
237 * board_early_init_f.
238 *
239 * set up gal. device mappings, etc.
240 */
241int board_early_init_f (void)
242{
243 /* set up the GT the way the kernel wants it
244 * the call to move the GT register space will obviously
245 * fail if it has already been done, but we're going to assume
246 * that if it's not at the power-on location, it's where we put
247 * it last time. (huber)
248 */
249
250 my_remap_gt_regs (CFG_DFL_GT_REGS, CFG_GT_REGS);
251
252#ifdef CONFIG_PCI
253 gt_pci_config ();
254#endif
255 /* mask all external interrupt sources */
256 GT_REG_WRITE (CPU_INTERRUPT_MASK_REGISTER_LOW, 0);
257 GT_REG_WRITE (CPU_INTERRUPT_MASK_REGISTER_HIGH, 0);
258 /* new in >MV6436x */
259 GT_REG_WRITE (CPU_INTERRUPT_1_MASK_REGISTER_LOW, 0);
260 GT_REG_WRITE (CPU_INTERRUPT_1_MASK_REGISTER_HIGH, 0);
261 /* --------------------- */
262 GT_REG_WRITE (PCI_0INTERRUPT_CAUSE_MASK_REGISTER_LOW, 0);
263 GT_REG_WRITE (PCI_0INTERRUPT_CAUSE_MASK_REGISTER_HIGH, 0);
264 GT_REG_WRITE (PCI_1INTERRUPT_CAUSE_MASK_REGISTER_LOW, 0);
265 GT_REG_WRITE (PCI_1INTERRUPT_CAUSE_MASK_REGISTER_HIGH, 0);
266
267 /* Device and Boot bus settings
268 */
269 memoryMapDeviceSpace(DEVICE0, 0, 0);
270 GT_REG_WRITE(DEVICE_BANK0PARAMETERS, 0);
271 memoryMapDeviceSpace(DEVICE1, 0, 0);
272 GT_REG_WRITE(DEVICE_BANK1PARAMETERS, 0);
273 memoryMapDeviceSpace(DEVICE2, 0, 0);
274 GT_REG_WRITE(DEVICE_BANK2PARAMETERS, 0);
275 memoryMapDeviceSpace(DEVICE3, 0, 0);
276 GT_REG_WRITE(DEVICE_BANK3PARAMETERS, 0);
277
278 GT_REG_WRITE(DEVICE_BOOT_BANK_PARAMETERS, CFG_BOOT_PAR);
279
280 gt_cpu_config();
281
282 /* MPP setup */
283 GT_REG_WRITE (MPP_CONTROL0, CFG_MPP_CONTROL_0);
284 GT_REG_WRITE (MPP_CONTROL1, CFG_MPP_CONTROL_1);
285 GT_REG_WRITE (MPP_CONTROL2, CFG_MPP_CONTROL_2);
286 GT_REG_WRITE (MPP_CONTROL3, CFG_MPP_CONTROL_3);
287
288 GT_REG_WRITE (GPP_LEVEL_CONTROL, CFG_GPP_LEVEL_CONTROL);
289
290 return 0;
291}
292
293/* various things to do after relocation */
294
295int misc_init_r ()
296{
297 u8 val;
298
299 icache_enable ();
300#ifdef CFG_L2
301 l2cache_enable ();
302#endif
303#ifdef CONFIG_MPSC
304 mpsc_sdma_init ();
305 mpsc_init2 ();
306#endif
307
308 /*
309 * Enable trickle changing in RTC upon powerup
310 * No diode, 250 ohm series resistor
311 */
312 val = 0xa5;
313 i2c_write(CFG_I2C_RTC_ADDR, 8, 1, &val, 1);
314
315 return 0;
316}
317
318int board_early_init_r(void)
319{
320 /* now relocate the debug serial driver */
321 mpsc_putchar += gd->reloc_off;
322 mpsc_getchar += gd->reloc_off;
323 mpsc_test_char += gd->reloc_off;
324
325 return 0;
326}
327
328void after_reloc (ulong dest_addr, gd_t * gd)
329{
330 memoryMapDeviceSpace (BOOT_DEVICE, CFG_BOOT_SPACE, CFG_BOOT_SIZE);
331
332/* display_mem_map(); */
333
334 /* now, jump to the main U-Boot board init code */
335 board_init_r (gd, dest_addr);
336 /* NOTREACHED */
337}
338
339/*
340 * Check Board Identity:
341 * right now, assume borad type. (there is just one...after all)
342 */
343
344int checkboard (void)
345{
346 char *s = getenv("serial#");
347
348 printf("Board: %s", CFG_BOARD_NAME);
349
350 if (s != NULL) {
351 puts(", serial# ");
352 puts(s);
353 }
354 putc('\n');
355
356 return (0);
357}
358
359/* utility functions */
360void debug_led (int led, int mode)
361{
362}
363
364int display_mem_map (void)
365{
366 int i, j;
367 unsigned int base, size, width;
368
369 /* SDRAM */
370 printf ("SD (DDR) RAM\n");
371 for (i = 0; i <= BANK3; i++) {
372 base = memoryGetBankBaseAddress (i);
373 size = memoryGetBankSize (i);
374 if (size != 0)
375 printf ("BANK%d: base - 0x%08x\tsize - %dM bytes\n",
376 i, base, size >> 20);
377 }
378#ifdef CONFIG_PCI
379 /* CPU's PCI windows */
380 for (i = 0; i <= PCI_HOST1; i++) {
381 printf ("\nCPU's PCI %d windows\n", i);
382 base = pciGetSpaceBase (i, PCI_IO);
383 size = pciGetSpaceSize (i, PCI_IO);
384 printf (" IO: base - 0x%08x\tsize - %dM bytes\n", base,
385 size >> 20);
386 /* ronen currently only first PCI MEM is used 3 */
387 for (j = 0; j <= PCI_REGION0; j++) {
388 base = pciGetSpaceBase (i, j);
389 size = pciGetSpaceSize (i, j);
390 printf ("MEMORY %d: base - 0x%08x\tsize - %dM bytes\n",
391 j, base, size >> 20);
392 }
393 }
394#endif /* of CONFIG_PCI */
395
396 /* Bootrom */
397 base = memoryGetDeviceBaseAddress (BOOT_DEVICE); /* Boot */
398 size = memoryGetDeviceSize (BOOT_DEVICE);
399 width = memoryGetDeviceWidth (BOOT_DEVICE) * 8;
400 printf (" BOOT: base - 0x%08x size - %dM bytes\twidth - %d bits\t- FLASH\n",
401 base, size >> 20, width);
402
403 return (0);
404}
405
406/* DRAM check routines copied from gw8260 */
407
408#if defined (CFG_DRAM_TEST)
409
410/*********************************************************************/
411/* NAME: move64() - moves a double word (64-bit) */
412/* */
413/* DESCRIPTION: */
414/* this function performs a double word move from the data at */
415/* the source pointer to the location at the destination pointer. */
416/* */
417/* INPUTS: */
418/* unsigned long long *src - pointer to data to move */
419/* */
420/* OUTPUTS: */
421/* unsigned long long *dest - pointer to locate to move data */
422/* */
423/* RETURNS: */
424/* None */
425/* */
426/* RESTRICTIONS/LIMITATIONS: */
427/* May cloober fr0. */
428/* */
429/*********************************************************************/
430static void move64 (unsigned long long *src, unsigned long long *dest)
431{
432 asm ("lfd 0, 0(3)\n\t" /* fpr0 = *scr */
433 "stfd 0, 0(4)" /* *dest = fpr0 */
434 : : : "fr0"); /* Clobbers fr0 */
435 return;
436}
437
438
439#if defined (CFG_DRAM_TEST_DATA)
440
441unsigned long long pattern[] = {
442 0xaaaaaaaaaaaaaaaaULL,
443 0xccccccccccccccccULL,
444 0xf0f0f0f0f0f0f0f0ULL,
445 0xff00ff00ff00ff00ULL,
446 0xffff0000ffff0000ULL,
447 0xffffffff00000000ULL,
448 0x00000000ffffffffULL,
449 0x0000ffff0000ffffULL,
450 0x00ff00ff00ff00ffULL,
451 0x0f0f0f0f0f0f0f0fULL,
452 0x3333333333333333ULL,
453 0x5555555555555555ULL
454};
455
456/*********************************************************************/
457/* NAME: mem_test_data() - test data lines for shorts and opens */
458/* */
459/* DESCRIPTION: */
460/* Tests data lines for shorts and opens by forcing adjacent data */
461/* to opposite states. Because the data lines could be routed in */
462/* an arbitrary manner the must ensure test patterns ensure that */
463/* every case is tested. By using the following series of binary */
464/* patterns every combination of adjacent bits is test regardless */
465/* of routing. */
466/* */
467/* ...101010101010101010101010 */
468/* ...110011001100110011001100 */
469/* ...111100001111000011110000 */
470/* ...111111110000000011111111 */
471/* */
472/* Carrying this out, gives us six hex patterns as follows: */
473/* */
474/* 0xaaaaaaaaaaaaaaaa */
475/* 0xcccccccccccccccc */
476/* 0xf0f0f0f0f0f0f0f0 */
477/* 0xff00ff00ff00ff00 */
478/* 0xffff0000ffff0000 */
479/* 0xffffffff00000000 */
480/* */
481/* The number test patterns will always be given by: */
482/* */
483/* log(base 2)(number data bits) = log2 (64) = 6 */
484/* */
485/* To test for short and opens to other signals on our boards. we */
486/* simply */
487/* test with the 1's complemnt of the paterns as well. */
488/* */
489/* OUTPUTS: */
490/* Displays failing test pattern */
491/* */
492/* RETURNS: */
493/* 0 - Passed test */
494/* 1 - Failed test */
495/* */
496/* RESTRICTIONS/LIMITATIONS: */
497/* Assumes only one one SDRAM bank */
498/* */
499/*********************************************************************/
500int mem_test_data (void)
501{
502 unsigned long long *pmem = (unsigned long long *) CFG_MEMTEST_START;
503 unsigned long long temp64 = 0;
504 int num_patterns = sizeof (pattern) / sizeof (pattern[0]);
505 int i;
506 unsigned int hi, lo;
507
508 for (i = 0; i < num_patterns; i++) {
509 move64 (&(pattern[i]), pmem);
510 move64 (pmem, &temp64);
511
512 /* hi = (temp64>>32) & 0xffffffff; */
513 /* lo = temp64 & 0xffffffff; */
514 /* printf("\ntemp64 = 0x%08x%08x", hi, lo); */
515
516 hi = (pattern[i] >> 32) & 0xffffffff;
517 lo = pattern[i] & 0xffffffff;
518 /* printf("\npattern[%d] = 0x%08x%08x", i, hi, lo); */
519
520 if (temp64 != pattern[i]) {
521 printf ("\n Data Test Failed, pattern 0x%08x%08x",
522 hi, lo);
523 return 1;
524 }
525 }
526
527 return 0;
528}
529#endif /* CFG_DRAM_TEST_DATA */
530
531#if defined (CFG_DRAM_TEST_ADDRESS)
532/*********************************************************************/
533/* NAME: mem_test_address() - test address lines */
534/* */
535/* DESCRIPTION: */
536/* This function performs a test to verify that each word im */
537/* memory is uniquly addressable. The test sequence is as follows: */
538/* */
539/* 1) write the address of each word to each word. */
540/* 2) verify that each location equals its address */
541/* */
542/* OUTPUTS: */
543/* Displays failing test pattern and address */
544/* */
545/* RETURNS: */
546/* 0 - Passed test */
547/* 1 - Failed test */
548/* */
549/* RESTRICTIONS/LIMITATIONS: */
550/* */
551/* */
552/*********************************************************************/
553int mem_test_address (void)
554{
555 volatile unsigned int *pmem =
556 (volatile unsigned int *) CFG_MEMTEST_START;
557 const unsigned int size = (CFG_MEMTEST_END - CFG_MEMTEST_START) / 4;
558 unsigned int i;
559
560 /* write address to each location */
561 for (i = 0; i < size; i++)
562 pmem[i] = i;
563
564 /* verify each loaction */
565 for (i = 0; i < size; i++) {
566 if (pmem[i] != i) {
567 printf ("\n Address Test Failed at 0x%x", i);
568 return 1;
569 }
570 }
571 return 0;
572}
573#endif /* CFG_DRAM_TEST_ADDRESS */
574
575#if defined (CFG_DRAM_TEST_WALK)
576/*********************************************************************/
577/* NAME: mem_march() - memory march */
578/* */
579/* DESCRIPTION: */
580/* Marches up through memory. At each location verifies rmask if */
581/* read = 1. At each location write wmask if write = 1. Displays */
582/* failing address and pattern. */
583/* */
584/* INPUTS: */
585/* volatile unsigned long long * base - start address of test */
586/* unsigned int size - number of dwords(64-bit) to test */
587/* unsigned long long rmask - read verify mask */
588/* unsigned long long wmask - wrtie verify mask */
589/* short read - verifies rmask if read = 1 */
590/* short write - writes wmask if write = 1 */
591/* */
592/* OUTPUTS: */
593/* Displays failing test pattern and address */
594/* */
595/* RETURNS: */
596/* 0 - Passed test */
597/* 1 - Failed test */
598/* */
599/* RESTRICTIONS/LIMITATIONS: */
600/* */
601/* */
602/*********************************************************************/
603int mem_march (volatile unsigned long long *base,
604 unsigned int size,
605 unsigned long long rmask,
606 unsigned long long wmask, short read, short write)
607{
608 unsigned int i;
609 unsigned long long temp = 0;
610 unsigned int hitemp, lotemp, himask, lomask;
611
612 for (i = 0; i < size; i++) {
613 if (read != 0) {
614 /* temp = base[i]; */
615 move64 ((unsigned long long *) &(base[i]), &temp);
616 if (rmask != temp) {
617 hitemp = (temp >> 32) & 0xffffffff;
618 lotemp = temp & 0xffffffff;
619 himask = (rmask >> 32) & 0xffffffff;
620 lomask = rmask & 0xffffffff;
621
622 printf ("\n Walking one's test failed: address = 0x%08x," "\n\texpected 0x%08x%08x, found 0x%08x%08x", i << 3, himask, lomask, hitemp, lotemp);
623 return 1;
624 }
625 }
626 if (write != 0) {
627 /* base[i] = wmask; */
628 move64 (&wmask, (unsigned long long *) &(base[i]));
629 }
630 }
631 return 0;
632}
633#endif /* CFG_DRAM_TEST_WALK */
634
635/*********************************************************************/
636/* NAME: mem_test_walk() - a simple walking ones test */
637/* */
638/* DESCRIPTION: */
639/* Performs a walking ones through entire physical memory. The */
640/* test uses as series of memory marches, mem_march(), to verify */
641/* and write the test patterns to memory. The test sequence is as */
642/* follows: */
643/* 1) march writing 0000...0001 */
644/* 2) march verifying 0000...0001 , writing 0000...0010 */
645/* 3) repeat step 2 shifting masks left 1 bit each time unitl */
646/* the write mask equals 1000...0000 */
647/* 4) march verifying 1000...0000 */
648/* The test fails if any of the memory marches return a failure. */
649/* */
650/* OUTPUTS: */
651/* Displays which pass on the memory test is executing */
652/* */
653/* RETURNS: */
654/* 0 - Passed test */
655/* 1 - Failed test */
656/* */
657/* RESTRICTIONS/LIMITATIONS: */
658/* */
659/* */
660/*********************************************************************/
661int mem_test_walk (void)
662{
663 unsigned long long mask;
664 volatile unsigned long long *pmem =
665 (volatile unsigned long long *) CFG_MEMTEST_START;
666 const unsigned long size = (CFG_MEMTEST_END - CFG_MEMTEST_START) / 8;
667
668 unsigned int i;
669
670 mask = 0x01;
671
672 printf ("Initial Pass");
673 mem_march (pmem, size, 0x0, 0x1, 0, 1);
674
675 printf ("\b\b\b\b\b\b\b\b\b\b\b\b");
676 printf (" ");
677 printf (" ");
678 printf ("\b\b\b\b\b\b\b\b\b\b\b\b");
679
680 for (i = 0; i < 63; i++) {
681 printf ("Pass %2d", i + 2);
682 if (mem_march (pmem, size, mask, mask << 1, 1, 1) != 0) {
683 /*printf("mask: 0x%x, pass: %d, ", mask, i); */
684 return 1;
685 }
686 mask = mask << 1;
687 printf ("\b\b\b\b\b\b\b");
688 }
689
690 printf ("Last Pass");
691 if (mem_march (pmem, size, 0, mask, 0, 1) != 0) {
692 /* printf("mask: 0x%x", mask); */
693 return 1;
694 }
695 printf ("\b\b\b\b\b\b\b\b\b");
696 printf (" ");
697 printf ("\b\b\b\b\b\b\b\b\b");
698
699 return 0;
700}
701
702/*********************************************************************/
703/* NAME: testdram() - calls any enabled memory tests */
704/* */
705/* DESCRIPTION: */
706/* Runs memory tests if the environment test variables are set to */
707/* 'y'. */
708/* */
709/* INPUTS: */
710/* testdramdata - If set to 'y', data test is run. */
711/* testdramaddress - If set to 'y', address test is run. */
712/* testdramwalk - If set to 'y', walking ones test is run */
713/* */
714/* OUTPUTS: */
715/* None */
716/* */
717/* RETURNS: */
718/* 0 - Passed test */
719/* 1 - Failed test */
720/* */
721/* RESTRICTIONS/LIMITATIONS: */
722/* */
723/* */
724/*********************************************************************/
725int testdram (void)
726{
727 char *s;
728 int rundata = 0;
729 int runaddress = 0;
730 int runwalk = 0;
731
732#ifdef CFG_DRAM_TEST_DATA
733 s = getenv ("testdramdata");
734 rundata = (s && (*s == 'y')) ? 1 : 0;
735#endif
736#ifdef CFG_DRAM_TEST_ADDRESS
737 s = getenv ("testdramaddress");
738 runaddress = (s && (*s == 'y')) ? 1 : 0;
739#endif
740#ifdef CFG_DRAM_TEST_WALK
741 s = getenv ("testdramwalk");
742 runwalk = (s && (*s == 'y')) ? 1 : 0;
743#endif
744
745 if ((rundata == 1) || (runaddress == 1) || (runwalk == 1))
746 printf ("Testing RAM from 0x%08x to 0x%08x ... "
747 "(don't panic... that will take a moment !!!!)\n",
748 CFG_MEMTEST_START, CFG_MEMTEST_END);
749#ifdef CFG_DRAM_TEST_DATA
750 if (rundata == 1) {
751 printf ("Test DATA ... ");
752 if (mem_test_data () == 1) {
753 printf ("failed \n");
754 return 1;
755 } else
756 printf ("ok \n");
757 }
758#endif
759#ifdef CFG_DRAM_TEST_ADDRESS
760 if (runaddress == 1) {
761 printf ("Test ADDRESS ... ");
762 if (mem_test_address () == 1) {
763 printf ("failed \n");
764 return 1;
765 } else
766 printf ("ok \n");
767 }
768#endif
769#ifdef CFG_DRAM_TEST_WALK
770 if (runwalk == 1) {
771 printf ("Test WALKING ONEs ... ");
772 if (mem_test_walk () == 1) {
773 printf ("failed \n");
774 return 1;
775 } else
776 printf ("ok \n");
777 }
778#endif
779 if ((rundata == 1) || (runaddress == 1) || (runwalk == 1))
780 printf ("passed\n");
781 return 0;
782
783}
784#endif /* CFG_DRAM_TEST */
785
786/* ronen - the below functions are used by the bootm function */
787/* - we map the base register to fbe00000 (same mapping as in the LSP) */
788/* - we turn off the RX gig dmas - to prevent the dma from overunning */
789/* the kernel data areas. */
790/* - we diable and invalidate the icache and dcache. */
791void my_remap_gt_regs_bootm (u32 cur_loc, u32 new_loc)
792{
793 u32 temp;
794
795 temp = in_le32 ((u32 *) (new_loc + INTERNAL_SPACE_DECODE));
796 if ((temp & 0xffff) == new_loc >> 16)
797 return;
798
799 temp = (in_le32 ((u32 *) (cur_loc + INTERNAL_SPACE_DECODE)) &
800 0xffff0000) | (new_loc >> 16);
801
802 out_le32 ((u32 *) (cur_loc + INTERNAL_SPACE_DECODE), temp);
803
804 while ((WORD_SWAP (*((volatile unsigned int *) (NONE_CACHEABLE |
805 new_loc |
806 (INTERNAL_SPACE_DECODE)))))
807 != temp);
808
809}