blob: fccdc521cd84d2cb23677083f3b625b1b85c21ea [file] [log] [blame]
stroese771e05b2004-12-16 18:21:17 +00001/*
2 * (C) Copyright 2001
3 * Josh Huber <huber@mclx.com>, Mission Critical Linux, Inc.
4 *
5 * See file CREDITS for list of people who contributed to this
6 * project.
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License as
10 * published by the Free Software Foundation; either version 2 of
11 * the License, or (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
21 * MA 02111-1307 USA
22 *
23 * modifications for the DB64360 eval board based by Ingo.Assmus@keymile.com
24 * modifications for the cpci750 by reinhard.arlt@esd-electronics.com
25 */
26
27/*
28 * cpci750.c - main board support/init for the esd cpci750.
29 */
30
31#include <common.h>
Stefan Roesed5ea2872007-01-31 16:38:04 +010032#include <command.h>
stroese771e05b2004-12-16 18:21:17 +000033#include <74xx_7xx.h>
34#include "../../Marvell/include/memory.h"
35#include "../../Marvell/include/pci.h"
36#include "../../Marvell/include/mv_gen_reg.h"
37#include <net.h>
38
39#include "eth.h"
40#include "mpsc.h"
41#include "i2c.h"
42#include "64360.h"
43#include "mv_regs.h"
44
45#undef DEBUG
46/*#define DEBUG */
47
48#ifdef CONFIG_PCI
49#define MAP_PCI
50#endif /* of CONFIG_PCI */
51
52#ifdef DEBUG
53#define DP(x) x
54#else
55#define DP(x)
56#endif
57
Stefan Roese2d780742007-06-22 17:32:28 +020058static char show_config_tab[][15] = {{"PCI0DLL_2 "}, /* 31 */
59 {"PCI0DLL_1 "}, /* 30 */
60 {"PCI0DLL_0 "}, /* 29 */
61 {"PCI1DLL_2 "}, /* 28 */
62 {"PCI1DLL_1 "}, /* 27 */
63 {"PCI1DLL_0 "}, /* 26 */
64 {"BbEP2En "}, /* 25 */
65 {"SDRAMRdDataDel"}, /* 24 */
66 {"SDRAMRdDel "}, /* 23 */
67 {"SDRAMSync "}, /* 22 */
68 {"SDRAMPipeSel_1"}, /* 21 */
69 {"SDRAMPipeSel_0"}, /* 20 */
70 {"SDRAMAddDel "}, /* 19 */
71 {"SDRAMClkSel "}, /* 18 */
72 {"Reserved(1!) "}, /* 17 */
73 {"PCIRty "}, /* 16 */
74 {"BootCSWidth_1 "}, /* 15 */
75 {"BootCSWidth_0 "}, /* 14 */
76 {"PCI1PadsCal "}, /* 13 */
77 {"PCI0PadsCal "}, /* 12 */
78 {"MultiMVId_1 "}, /* 11 */
79 {"MultiMVId_0 "}, /* 10 */
80 {"MultiGTEn "}, /* 09 */
81 {"Int60xArb "}, /* 08 */
82 {"CPUBusConfig_1"}, /* 07 */
83 {"CPUBusConfig_0"}, /* 06 */
84 {"DefIntSpc "}, /* 05 */
85 {0 }, /* 04 */
86 {"SROMAdd_1 "}, /* 03 */
87 {"SROMAdd_0 "}, /* 02 */
88 {"DRAMPadCal "}, /* 01 */
89 {"SInitEn "}, /* 00 */
90 {0 }, /* 31 */
91 {0 }, /* 30 */
92 {0 }, /* 29 */
93 {0 }, /* 28 */
94 {0 }, /* 27 */
95 {0 }, /* 26 */
96 {0 }, /* 25 */
97 {0 }, /* 24 */
98 {0 }, /* 23 */
99 {0 }, /* 22 */
100 {"JTAGCalBy "}, /* 21 */
101 {"GB2Sel "}, /* 20 */
102 {"GB1Sel "}, /* 19 */
103 {"DRAMPLL_MDiv_5"}, /* 18 */
104 {"DRAMPLL_MDiv_4"}, /* 17 */
105 {"DRAMPLL_MDiv_3"}, /* 16 */
106 {"DRAMPLL_MDiv_2"}, /* 15 */
107 {"DRAMPLL_MDiv_1"}, /* 14 */
108 {"DRAMPLL_MDiv_0"}, /* 13 */
109 {"GB0Sel "}, /* 12 */
110 {"DRAMPLLPU "}, /* 11 */
111 {"DRAMPLL_HIKVCO"}, /* 10 */
112 {"DRAMPLLNP "}, /* 09 */
113 {"DRAMPLL_NDiv_7"}, /* 08 */
114 {"DRAMPLL_NDiv_6"}, /* 07 */
115 {"CPUPadCal "}, /* 06 */
116 {"DRAMPLL_NDiv_5"}, /* 05 */
117 {"DRAMPLL_NDiv_4"}, /* 04 */
118 {"DRAMPLL_NDiv_3"}, /* 03 */
119 {"DRAMPLL_NDiv_2"}, /* 02 */
120 {"DRAMPLL_NDiv_1"}, /* 01 */
121 {"DRAMPLL_NDiv_0"}}; /* 00 */
122
Stefan Roese79830d52006-02-08 15:54:15 +0100123extern flash_info_t flash_info[];
stroese771e05b2004-12-16 18:21:17 +0000124
Stefan Roese0e5ef072009-06-04 13:35:36 +0200125extern int do_bootm (cmd_tbl_t *, int, int, char *[]);
126extern int do_bootvx (cmd_tbl_t *, int, int, char *[]);
127
stroese771e05b2004-12-16 18:21:17 +0000128/* ------------------------------------------------------------------------- */
129
130/* this is the current GT register space location */
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200131/* it starts at CONFIG_SYS_DFL_GT_REGS but moves later to CONFIG_SYS_GT_REGS */
stroese771e05b2004-12-16 18:21:17 +0000132
133/* Unfortunately, we cant change it while we are in flash, so we initialize it
134 * to the "final" value. This means that any debug_led calls before
135 * board_early_init_f wont work right (like in cpu_init_f).
136 * See also my_remap_gt_regs below. (NTL)
137 */
138
139void board_prebootm_init (void);
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200140unsigned int INTERNAL_REG_BASE_ADDR = CONFIG_SYS_GT_REGS;
stroese771e05b2004-12-16 18:21:17 +0000141int display_mem_map (void);
142
143/* ------------------------------------------------------------------------- */
144
145/*
146 * This is a version of the GT register space remapping function that
147 * doesn't touch globals (meaning, it's ok to run from flash.)
148 *
149 * Unfortunately, this has the side effect that a writable
150 * INTERNAL_REG_BASE_ADDR is impossible. Oh well.
151 */
152
153void my_remap_gt_regs (u32 cur_loc, u32 new_loc)
154{
155 u32 temp;
156
157 /* check and see if it's already moved */
158
159/* original ppcboot 1.1.6 source
160
161 temp = in_le32((u32 *)(new_loc + INTERNAL_SPACE_DECODE));
162 if ((temp & 0xffff) == new_loc >> 20)
163 return;
164
165 temp = (in_le32((u32 *)(cur_loc + INTERNAL_SPACE_DECODE)) &
166 0xffff0000) | (new_loc >> 20);
167
168 out_le32((u32 *)(cur_loc + INTERNAL_SPACE_DECODE), temp);
169
170 while (GTREGREAD(INTERNAL_SPACE_DECODE) != temp);
171original ppcboot 1.1.6 source end */
172
173 temp = in_le32 ((u32 *) (new_loc + INTERNAL_SPACE_DECODE));
174 if ((temp & 0xffff) == new_loc >> 16)
175 return;
176
177 temp = (in_le32 ((u32 *) (cur_loc + INTERNAL_SPACE_DECODE)) &
178 0xffff0000) | (new_loc >> 16);
179
180 out_le32 ((u32 *) (cur_loc + INTERNAL_SPACE_DECODE), temp);
181
182 while (GTREGREAD (INTERNAL_SPACE_DECODE) != temp);
183}
184
185#ifdef CONFIG_PCI
186
187static void gt_pci_config (void)
188{
189 unsigned int stat;
190 unsigned int val = 0x00fff864; /* DINK32: BusNum 23:16, DevNum 15:11, FuncNum 10:8, RegNum 7:2 */
191
192 /* In PCIX mode devices provide their own bus and device numbers. We query the Discovery II's
193 * config registers by writing ones to the bus and device.
194 * We then update the Virtual register with the correct value for the bus and device.
195 */
196 if ((GTREGREAD (PCI_0_MODE) & (BIT4 | BIT5)) != 0) { /*if PCI-X */
197 GT_REG_WRITE (PCI_0_CONFIG_ADDR, BIT31 | val);
198
199 GT_REG_READ (PCI_0_CONFIG_DATA_VIRTUAL_REG, &stat);
200
201 GT_REG_WRITE (PCI_0_CONFIG_ADDR, BIT31 | val);
202 GT_REG_WRITE (PCI_0_CONFIG_DATA_VIRTUAL_REG,
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200203 (stat & 0xffff0000) | CONFIG_SYS_PCI_IDSEL);
stroese771e05b2004-12-16 18:21:17 +0000204
205 }
206 if ((GTREGREAD (PCI_1_MODE) & (BIT4 | BIT5)) != 0) { /*if PCI-X */
207 GT_REG_WRITE (PCI_1_CONFIG_ADDR, BIT31 | val);
208 GT_REG_READ (PCI_1_CONFIG_DATA_VIRTUAL_REG, &stat);
209
210 GT_REG_WRITE (PCI_1_CONFIG_ADDR, BIT31 | val);
211 GT_REG_WRITE (PCI_1_CONFIG_DATA_VIRTUAL_REG,
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200212 (stat & 0xffff0000) | CONFIG_SYS_PCI_IDSEL);
stroese771e05b2004-12-16 18:21:17 +0000213 }
214
215 /* Enable master */
216 PCI_MASTER_ENABLE (0, SELF);
217 PCI_MASTER_ENABLE (1, SELF);
218
219 /* Enable PCI0/1 Mem0 and IO 0 disable all others */
220 GT_REG_READ (BASE_ADDR_ENABLE, &stat);
221 stat |= (1 << 11) | (1 << 12) | (1 << 13) | (1 << 16) | (1 << 17) | (1
222 <<
223 18);
224 stat &= ~((1 << 9) | (1 << 10) | (1 << 14) | (1 << 15));
225 GT_REG_WRITE (BASE_ADDR_ENABLE, stat);
226
227 /* ronen- add write to pci remap registers for 64460.
228 in 64360 when writing to pci base go and overide remap automaticaly,
229 in 64460 it doesn't */
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200230 GT_REG_WRITE (PCI_0_IO_BASE_ADDR, CONFIG_SYS_PCI0_IO_SPACE >> 16);
231 GT_REG_WRITE (PCI_0I_O_ADDRESS_REMAP, CONFIG_SYS_PCI0_IO_SPACE_PCI >> 16);
232 GT_REG_WRITE (PCI_0_IO_SIZE, (CONFIG_SYS_PCI0_IO_SIZE - 1) >> 16);
stroese771e05b2004-12-16 18:21:17 +0000233
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200234 GT_REG_WRITE (PCI_0_MEMORY0_BASE_ADDR, CONFIG_SYS_PCI0_MEM_BASE >> 16);
235 GT_REG_WRITE (PCI_0MEMORY0_ADDRESS_REMAP, CONFIG_SYS_PCI0_MEM_BASE >> 16);
236 GT_REG_WRITE (PCI_0_MEMORY0_SIZE, (CONFIG_SYS_PCI0_MEM_SIZE - 1) >> 16);
stroese771e05b2004-12-16 18:21:17 +0000237
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200238 GT_REG_WRITE (PCI_1_IO_BASE_ADDR, CONFIG_SYS_PCI1_IO_SPACE >> 16);
239 GT_REG_WRITE (PCI_1I_O_ADDRESS_REMAP, CONFIG_SYS_PCI1_IO_SPACE_PCI >> 16);
240 GT_REG_WRITE (PCI_1_IO_SIZE, (CONFIG_SYS_PCI1_IO_SIZE - 1) >> 16);
stroese771e05b2004-12-16 18:21:17 +0000241
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200242 GT_REG_WRITE (PCI_1_MEMORY0_BASE_ADDR, CONFIG_SYS_PCI1_MEM_BASE >> 16);
243 GT_REG_WRITE (PCI_1MEMORY0_ADDRESS_REMAP, CONFIG_SYS_PCI1_MEM_BASE >> 16);
244 GT_REG_WRITE (PCI_1_MEMORY0_SIZE, (CONFIG_SYS_PCI1_MEM_SIZE - 1) >> 16);
stroese771e05b2004-12-16 18:21:17 +0000245
246 /* PCI interface settings */
247 /* Timeout set to retry forever */
248 GT_REG_WRITE (PCI_0TIMEOUT_RETRY, 0x0);
249 GT_REG_WRITE (PCI_1TIMEOUT_RETRY, 0x0);
250
251 /* ronen - enable only CS0 and Internal reg!! */
252 GT_REG_WRITE (PCI_0BASE_ADDRESS_REGISTERS_ENABLE, 0xfffffdfe);
253 GT_REG_WRITE (PCI_1BASE_ADDRESS_REGISTERS_ENABLE, 0xfffffdfe);
254
255/*ronen update the pci internal registers base address.*/
256#ifdef MAP_PCI
257 for (stat = 0; stat <= PCI_HOST1; stat++)
258 pciWriteConfigReg (stat,
259 PCI_INTERNAL_REGISTERS_MEMORY_MAPPED_BASE_ADDRESS,
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200260 SELF, CONFIG_SYS_GT_REGS);
stroese771e05b2004-12-16 18:21:17 +0000261#endif
262
263}
264#endif
265
266/* Setup CPU interface paramaters */
267static void gt_cpu_config (void)
268{
269 cpu_t cpu = get_cpu_type ();
270 ulong tmp;
271
272 /* cpu configuration register */
273 tmp = GTREGREAD (CPU_CONFIGURATION);
274
275 /* set the SINGLE_CPU bit see MV64360 P.399 */
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200276#ifndef CONFIG_SYS_GT_DUAL_CPU /* SINGLE_CPU seems to cause JTAG problems */
stroese771e05b2004-12-16 18:21:17 +0000277 tmp |= CPU_CONF_SINGLE_CPU;
278#endif
279
280 tmp &= ~CPU_CONF_AACK_DELAY_2;
281
282 tmp |= CPU_CONF_DP_VALID;
283 tmp |= CPU_CONF_AP_VALID;
284
285 tmp |= CPU_CONF_PIPELINE;
286
287 GT_REG_WRITE (CPU_CONFIGURATION, tmp); /* Marvell (VXWorks) writes 0x20220FF */
288
289 /* CPU master control register */
290 tmp = GTREGREAD (CPU_MASTER_CONTROL);
291
292 tmp |= CPU_MAST_CTL_ARB_EN;
293
294 if ((cpu == CPU_7400) ||
295 (cpu == CPU_7410) || (cpu == CPU_7455) || (cpu == CPU_7450)) {
296
297 tmp |= CPU_MAST_CTL_CLEAN_BLK;
298 tmp |= CPU_MAST_CTL_FLUSH_BLK;
299
300 } else {
301 /* cleanblock must be cleared for CPUs
302 * that do not support this command (603e, 750)
303 * see Res#1 */
304 tmp &= ~CPU_MAST_CTL_CLEAN_BLK;
305 tmp &= ~CPU_MAST_CTL_FLUSH_BLK;
306 }
307 GT_REG_WRITE (CPU_MASTER_CONTROL, tmp);
308}
309
310/*
311 * board_early_init_f.
312 *
313 * set up gal. device mappings, etc.
314 */
315int board_early_init_f (void)
316{
317
318 /*
319 * set up the GT the way the kernel wants it
320 * the call to move the GT register space will obviously
321 * fail if it has already been done, but we're going to assume
322 * that if it's not at the power-on location, it's where we put
323 * it last time. (huber)
324 */
325
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200326 my_remap_gt_regs (CONFIG_SYS_DFL_GT_REGS, CONFIG_SYS_GT_REGS);
stroese771e05b2004-12-16 18:21:17 +0000327
328 /* No PCI in first release of Port To_do: enable it. */
329#ifdef CONFIG_PCI
330 gt_pci_config ();
331#endif
332 /* mask all external interrupt sources */
333 GT_REG_WRITE (CPU_INTERRUPT_MASK_REGISTER_LOW, 0);
334 GT_REG_WRITE (CPU_INTERRUPT_MASK_REGISTER_HIGH, 0);
335 /* new in MV6436x */
336 GT_REG_WRITE (CPU_INTERRUPT_1_MASK_REGISTER_LOW, 0);
337 GT_REG_WRITE (CPU_INTERRUPT_1_MASK_REGISTER_HIGH, 0);
338 /* --------------------- */
339 GT_REG_WRITE (PCI_0INTERRUPT_CAUSE_MASK_REGISTER_LOW, 0);
340 GT_REG_WRITE (PCI_0INTERRUPT_CAUSE_MASK_REGISTER_HIGH, 0);
341 GT_REG_WRITE (PCI_1INTERRUPT_CAUSE_MASK_REGISTER_LOW, 0);
342 GT_REG_WRITE (PCI_1INTERRUPT_CAUSE_MASK_REGISTER_HIGH, 0);
343 /* does not exist in MV6436x
344 GT_REG_WRITE(CPU_INT_0_MASK, 0);
345 GT_REG_WRITE(CPU_INT_1_MASK, 0);
346 GT_REG_WRITE(CPU_INT_2_MASK, 0);
347 GT_REG_WRITE(CPU_INT_3_MASK, 0);
348 --------------------- */
349
350
351 /* ----- DEVICE BUS SETTINGS ------ */
352
353 /*
354 * EVB
355 * 0 - SRAM ????
356 * 1 - RTC ????
357 * 2 - UART ????
358 * 3 - Flash checked 32Bit Intel Strata
359 * boot - BootCS checked 8Bit 29LV040B
360 *
361 */
362
363 /*
364 * the dual 7450 module requires burst access to the boot
365 * device, so the serial rom copies the boot device to the
366 * on-board sram on the eval board, and updates the correct
367 * registers to boot from the sram. (device0)
368 */
369
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200370 memoryMapDeviceSpace (DEVICE0, CONFIG_SYS_DEV0_SPACE, CONFIG_SYS_DEV0_SIZE);
371 memoryMapDeviceSpace (DEVICE1, CONFIG_SYS_DEV1_SPACE, CONFIG_SYS_DEV1_SIZE);
372 memoryMapDeviceSpace (DEVICE2, CONFIG_SYS_DEV2_SPACE, CONFIG_SYS_DEV2_SIZE);
373 memoryMapDeviceSpace (DEVICE3, CONFIG_SYS_DEV3_SPACE, CONFIG_SYS_DEV3_SIZE);
stroese771e05b2004-12-16 18:21:17 +0000374
375
376 /* configure device timing */
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200377 GT_REG_WRITE (DEVICE_BANK0PARAMETERS, CONFIG_SYS_DEV0_PAR);
378 GT_REG_WRITE (DEVICE_BANK1PARAMETERS, CONFIG_SYS_DEV1_PAR);
379 GT_REG_WRITE (DEVICE_BANK2PARAMETERS, CONFIG_SYS_DEV2_PAR);
380 GT_REG_WRITE (DEVICE_BANK3PARAMETERS, CONFIG_SYS_DEV3_PAR);
stroese771e05b2004-12-16 18:21:17 +0000381
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200382#ifdef CONFIG_SYS_32BIT_BOOT_PAR /* set port parameters for Flash device module access */
stroese771e05b2004-12-16 18:21:17 +0000383 /* detect if we are booting from the 32 bit flash */
384 if (GTREGREAD (DEVICE_BOOT_BANK_PARAMETERS) & (0x3 << 20)) {
385 /* 32 bit boot flash */
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200386 GT_REG_WRITE (DEVICE_BANK3PARAMETERS, CONFIG_SYS_8BIT_BOOT_PAR);
stroese771e05b2004-12-16 18:21:17 +0000387 GT_REG_WRITE (DEVICE_BOOT_BANK_PARAMETERS,
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200388 CONFIG_SYS_32BIT_BOOT_PAR);
stroese771e05b2004-12-16 18:21:17 +0000389 } else {
390 /* 8 bit boot flash */
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200391 GT_REG_WRITE (DEVICE_BANK3PARAMETERS, CONFIG_SYS_32BIT_BOOT_PAR);
392 GT_REG_WRITE (DEVICE_BOOT_BANK_PARAMETERS, CONFIG_SYS_8BIT_BOOT_PAR);
stroese771e05b2004-12-16 18:21:17 +0000393 }
394#else
395 /* 8 bit boot flash only */
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200396/* GT_REG_WRITE(DEVICE_BOOT_BANK_PARAMETERS, CONFIG_SYS_8BIT_BOOT_PAR);*/
stroese771e05b2004-12-16 18:21:17 +0000397#endif
398
399
400 gt_cpu_config ();
401
402 /* MPP setup */
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200403 GT_REG_WRITE (MPP_CONTROL0, CONFIG_SYS_MPP_CONTROL_0);
404 GT_REG_WRITE (MPP_CONTROL1, CONFIG_SYS_MPP_CONTROL_1);
405 GT_REG_WRITE (MPP_CONTROL2, CONFIG_SYS_MPP_CONTROL_2);
406 GT_REG_WRITE (MPP_CONTROL3, CONFIG_SYS_MPP_CONTROL_3);
stroese771e05b2004-12-16 18:21:17 +0000407
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200408 GT_REG_WRITE (GPP_LEVEL_CONTROL, CONFIG_SYS_GPP_LEVEL_CONTROL);
stroese771e05b2004-12-16 18:21:17 +0000409 DEBUG_LED0_ON ();
410 DEBUG_LED1_ON ();
411 DEBUG_LED2_ON ();
412
413 return 0;
414}
415
416/* various things to do after relocation */
417
418int misc_init_r ()
419{
420 icache_enable ();
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200421#ifdef CONFIG_SYS_L2
stroese771e05b2004-12-16 18:21:17 +0000422 l2cache_enable ();
423#endif
424#ifdef CONFIG_MPSC
425
426 mpsc_sdma_init ();
427 mpsc_init2 ();
428#endif
429
430#if 0
431 /* disable the dcache and MMU */
432 dcache_lock ();
433#endif
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200434 if (flash_info[3].size < CONFIG_SYS_FLASH_INCREMENT) {
Wolfgang Denk74357112007-02-27 14:26:04 +0100435 unsigned int flash_offset;
Stefan Roese79830d52006-02-08 15:54:15 +0100436 unsigned int l;
437
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200438 flash_offset = CONFIG_SYS_FLASH_INCREMENT - flash_info[3].size;
439 for (l = 0; l < CONFIG_SYS_MAX_FLASH_SECT; l++) {
Wolfgang Denk74357112007-02-27 14:26:04 +0100440 if (flash_info[3].start[l] != 0) {
Stefan Roese79830d52006-02-08 15:54:15 +0100441 flash_info[3].start[l] += flash_offset;
442 }
443 }
444 flash_protect (FLAG_PROTECT_SET,
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200445 CONFIG_SYS_MONITOR_BASE,
446 CONFIG_SYS_MONITOR_BASE + monitor_flash_len - 1,
Stefan Roese79830d52006-02-08 15:54:15 +0100447 &flash_info[3]);
Stefan Roese79830d52006-02-08 15:54:15 +0100448 }
stroese771e05b2004-12-16 18:21:17 +0000449 return 0;
450}
451
452void after_reloc (ulong dest_addr, gd_t * gd)
453{
Stefan Roesee5b563e2009-06-04 13:35:37 +0200454 memoryMapDeviceSpace (BOOT_DEVICE, CONFIG_SYS_BOOT_SPACE, CONFIG_SYS_BOOT_SIZE);
stroese771e05b2004-12-16 18:21:17 +0000455
Stefan Roesee5b563e2009-06-04 13:35:37 +0200456 display_mem_map ();
457 /* now, jump to the main ppcboot board init code */
458 board_init_r (gd, dest_addr);
459 /* NOTREACHED */
stroese771e05b2004-12-16 18:21:17 +0000460}
461
462/* ------------------------------------------------------------------------- */
463
464/*
465 * Check Board Identity:
466 *
467 * right now, assume borad type. (there is just one...after all)
468 */
469
470int checkboard (void)
471{
472 int l_type = 0;
473
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200474 printf ("BOARD: %s\n", CONFIG_SYS_BOARD_NAME);
stroese771e05b2004-12-16 18:21:17 +0000475 return (l_type);
476}
477
478/* utility functions */
479void debug_led (int led, int mode)
480{
481}
482
483int display_mem_map (void)
484{
485 int i, j;
486 unsigned int base, size, width;
487
488 /* SDRAM */
489 printf ("SD (DDR) RAM\n");
490 for (i = 0; i <= BANK3; i++) {
491 base = memoryGetBankBaseAddress (i);
492 size = memoryGetBankSize (i);
493 if (size != 0) {
494 printf ("BANK%d: base - 0x%08x\tsize - %dM bytes\n",
495 i, base, size >> 20);
496 }
497 }
498#ifdef CONFIG_PCI
499 /* CPU's PCI windows */
500 for (i = 0; i <= PCI_HOST1; i++) {
501 printf ("\nCPU's PCI %d windows\n", i);
502 base = pciGetSpaceBase (i, PCI_IO);
503 size = pciGetSpaceSize (i, PCI_IO);
504 printf (" IO: base - 0x%08x\tsize - %dM bytes\n", base,
505 size >> 20);
506 for (j = 0;
507 j <=
508 PCI_REGION0
509 /*ronen currently only first PCI MEM is used 3 */ ;
510 j++) {
511 base = pciGetSpaceBase (i, j);
512 size = pciGetSpaceSize (i, j);
513 printf ("MEMORY %d: base - 0x%08x\tsize - %dM bytes\n", j, base, size >> 20);
514 }
515 }
516#endif /* of CONFIG_PCI */
517 /* Devices */
518 printf ("\nDEVICES\n");
519 for (i = 0; i <= DEVICE3; i++) {
520 base = memoryGetDeviceBaseAddress (i);
521 size = memoryGetDeviceSize (i);
522 width = memoryGetDeviceWidth (i) * 8;
523 printf ("DEV %d: base - 0x%08x size - %dM bytes\twidth - %d bits", i, base, size >> 20, width);
524 if (i == 0)
525 printf ("\t- FLASH\n");
526 else if (i == 1)
527 printf ("\t- FLASH\n");
528 else if (i == 2)
529 printf ("\t- FLASH\n");
530 else
531 printf ("\t- RTC/REGS/CAN\n");
532 }
533
534 /* Bootrom */
535 base = memoryGetDeviceBaseAddress (BOOT_DEVICE); /* Boot */
536 size = memoryGetDeviceSize (BOOT_DEVICE);
537 width = memoryGetDeviceWidth (BOOT_DEVICE) * 8;
538 printf (" BOOT: base - 0x%08x size - %dM bytes\twidth - %d bits\t- FLASH\n",
539 base, size >> 20, width);
540 return (0);
541}
542
Stefan Roese0e5ef072009-06-04 13:35:36 +0200543/*
544 * Command loadpci: wait for signal from host and boot image.
545 */
546int do_loadpci(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
547{
548 volatile unsigned int *ptr;
549 int count = 0;
550 int count2 = 0;
551 int status;
552 char addr[16];
553 char str[] = "\\|/-";
554 char *local_args[2];
555
556 /*
557 * Mark sync address
558 */
559 ptr = 0;
560 ptr[0] = 0xffffffff;
561 ptr[1] = 0xffffffff;
562 puts("\nWaiting for image from pci host -");
563
564 /*
565 * Wait for host to write the start address
566 */
567 while (*ptr == 0xffffffff) {
568 count++;
569 if (!(count % 100)) {
570 count2++;
571 putc(0x08); /* backspace */
572 putc(str[count2 % 4]);
573 }
574
575 /* Abort if ctrl-c was pressed */
576 if (ctrlc()) {
577 puts("\nAbort\n");
578 return 0;
579 }
580
581 udelay(1000);
582 }
583
584 sprintf(addr, "%08x", *ptr);
585 printf("\nBooting Image at addr 0x%s ...\n", addr);
586 setenv("loadaddr", addr);
587
588 switch (ptr[1] == 0) {
589 case 0:
590 /*
591 * Boot image via bootm
592 */
593 local_args[0] = argv[0];
594 local_args[1] = NULL;
595 status = do_bootm (cmdtp, 0, 1, local_args);
596 break;
597 case 1:
598 /*
599 * Boot image via bootvx
600 */
601 local_args[0] = argv[0];
602 local_args[1] = NULL;
603 status = do_bootvx (cmdtp, 0, 1, local_args);
604 break;
605 }
606
607 return 0;
608}
609
610U_BOOT_CMD(
611 loadpci, 1, 1, do_loadpci,
612 "loadpci - Wait for pci-image and boot it\n",
613 NULL
614 );
615
stroese771e05b2004-12-16 18:21:17 +0000616/* DRAM check routines copied from gw8260 */
617
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200618#if defined (CONFIG_SYS_DRAM_TEST)
stroese771e05b2004-12-16 18:21:17 +0000619
620/*********************************************************************/
621/* NAME: move64() - moves a double word (64-bit) */
622/* */
623/* DESCRIPTION: */
624/* this function performs a double word move from the data at */
625/* the source pointer to the location at the destination pointer. */
626/* */
627/* INPUTS: */
628/* unsigned long long *src - pointer to data to move */
629/* */
630/* OUTPUTS: */
631/* unsigned long long *dest - pointer to locate to move data */
632/* */
633/* RETURNS: */
634/* None */
635/* */
636/* RESTRICTIONS/LIMITATIONS: */
637/* May cloober fr0. */
638/* */
639/*********************************************************************/
640static void move64 (unsigned long long *src, unsigned long long *dest)
641{
642 asm ("lfd 0, 0(3)\n\t" /* fpr0 = *scr */
643 "stfd 0, 0(4)" /* *dest = fpr0 */
Wolfgang Denk74357112007-02-27 14:26:04 +0100644 : : : "fr0"); /* Clobbers fr0 */
stroese771e05b2004-12-16 18:21:17 +0000645 return;
646}
647
648
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200649#if defined (CONFIG_SYS_DRAM_TEST_DATA)
stroese771e05b2004-12-16 18:21:17 +0000650
651unsigned long long pattern[] = {
wdenke2ffd592004-12-31 09:32:47 +0000652 0xaaaaaaaaaaaaaaaaLL,
653 0xccccccccccccccccLL,
654 0xf0f0f0f0f0f0f0f0LL,
655 0xff00ff00ff00ff00LL,
656 0xffff0000ffff0000LL,
657 0xffffffff00000000LL,
658 0x00000000ffffffffLL,
659 0x0000ffff0000ffffLL,
660 0x00ff00ff00ff00ffLL,
661 0x0f0f0f0f0f0f0f0fLL,
662 0x3333333333333333LL,
663 0x5555555555555555LL,
stroese771e05b2004-12-16 18:21:17 +0000664};
665
666/*********************************************************************/
667/* NAME: mem_test_data() - test data lines for shorts and opens */
668/* */
669/* DESCRIPTION: */
670/* Tests data lines for shorts and opens by forcing adjacent data */
671/* to opposite states. Because the data lines could be routed in */
672/* an arbitrary manner the must ensure test patterns ensure that */
673/* every case is tested. By using the following series of binary */
674/* patterns every combination of adjacent bits is test regardless */
675/* of routing. */
676/* */
677/* ...101010101010101010101010 */
678/* ...110011001100110011001100 */
679/* ...111100001111000011110000 */
680/* ...111111110000000011111111 */
681/* */
682/* Carrying this out, gives us six hex patterns as follows: */
683/* */
684/* 0xaaaaaaaaaaaaaaaa */
685/* 0xcccccccccccccccc */
686/* 0xf0f0f0f0f0f0f0f0 */
687/* 0xff00ff00ff00ff00 */
688/* 0xffff0000ffff0000 */
689/* 0xffffffff00000000 */
690/* */
691/* The number test patterns will always be given by: */
692/* */
693/* log(base 2)(number data bits) = log2 (64) = 6 */
694/* */
695/* To test for short and opens to other signals on our boards. we */
696/* simply */
697/* test with the 1's complemnt of the paterns as well. */
698/* */
699/* OUTPUTS: */
700/* Displays failing test pattern */
701/* */
702/* RETURNS: */
703/* 0 - Passed test */
704/* 1 - Failed test */
705/* */
706/* RESTRICTIONS/LIMITATIONS: */
707/* Assumes only one one SDRAM bank */
708/* */
709/*********************************************************************/
710int mem_test_data (void)
711{
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200712 unsigned long long *pmem = (unsigned long long *) CONFIG_SYS_MEMTEST_START;
Wolfgang Denk77ddac92005-10-13 16:45:02 +0200713 unsigned long long temp64 = 0;
stroese771e05b2004-12-16 18:21:17 +0000714 int num_patterns = sizeof (pattern) / sizeof (pattern[0]);
715 int i;
716 unsigned int hi, lo;
717
718 for (i = 0; i < num_patterns; i++) {
719 move64 (&(pattern[i]), pmem);
720 move64 (pmem, &temp64);
721
Wolfgang Denk74357112007-02-27 14:26:04 +0100722 /* hi = (temp64>>32) & 0xffffffff; */
723 /* lo = temp64 & 0xffffffff; */
724 /* printf("\ntemp64 = 0x%08x%08x", hi, lo); */
stroese771e05b2004-12-16 18:21:17 +0000725
726 hi = (pattern[i] >> 32) & 0xffffffff;
727 lo = pattern[i] & 0xffffffff;
728 /* printf("\npattern[%d] = 0x%08x%08x", i, hi, lo); */
729
730 if (temp64 != pattern[i]) {
731 printf ("\n Data Test Failed, pattern 0x%08x%08x",
732 hi, lo);
733 return 1;
734 }
735 }
736
737 return 0;
738}
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200739#endif /* CONFIG_SYS_DRAM_TEST_DATA */
stroese771e05b2004-12-16 18:21:17 +0000740
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200741#if defined (CONFIG_SYS_DRAM_TEST_ADDRESS)
stroese771e05b2004-12-16 18:21:17 +0000742/*********************************************************************/
743/* NAME: mem_test_address() - test address lines */
744/* */
745/* DESCRIPTION: */
746/* This function performs a test to verify that each word im */
747/* memory is uniquly addressable. The test sequence is as follows: */
748/* */
749/* 1) write the address of each word to each word. */
750/* 2) verify that each location equals its address */
751/* */
752/* OUTPUTS: */
753/* Displays failing test pattern and address */
754/* */
755/* RETURNS: */
756/* 0 - Passed test */
757/* 1 - Failed test */
758/* */
759/* RESTRICTIONS/LIMITATIONS: */
760/* */
761/* */
762/*********************************************************************/
763int mem_test_address (void)
764{
765 volatile unsigned int *pmem =
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200766 (volatile unsigned int *) CONFIG_SYS_MEMTEST_START;
767 const unsigned int size = (CONFIG_SYS_MEMTEST_END - CONFIG_SYS_MEMTEST_START) / 4;
stroese771e05b2004-12-16 18:21:17 +0000768 unsigned int i;
769
770 /* write address to each location */
771 for (i = 0; i < size; i++) {
772 pmem[i] = i;
773 }
774
775 /* verify each loaction */
776 for (i = 0; i < size; i++) {
777 if (pmem[i] != i) {
778 printf ("\n Address Test Failed at 0x%x", i);
779 return 1;
780 }
781 }
782 return 0;
783}
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200784#endif /* CONFIG_SYS_DRAM_TEST_ADDRESS */
stroese771e05b2004-12-16 18:21:17 +0000785
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200786#if defined (CONFIG_SYS_DRAM_TEST_WALK)
stroese771e05b2004-12-16 18:21:17 +0000787/*********************************************************************/
788/* NAME: mem_march() - memory march */
789/* */
790/* DESCRIPTION: */
791/* Marches up through memory. At each location verifies rmask if */
792/* read = 1. At each location write wmask if write = 1. Displays */
793/* failing address and pattern. */
794/* */
795/* INPUTS: */
796/* volatile unsigned long long * base - start address of test */
797/* unsigned int size - number of dwords(64-bit) to test */
798/* unsigned long long rmask - read verify mask */
799/* unsigned long long wmask - wrtie verify mask */
800/* short read - verifies rmask if read = 1 */
801/* short write - writes wmask if write = 1 */
802/* */
803/* OUTPUTS: */
804/* Displays failing test pattern and address */
805/* */
806/* RETURNS: */
807/* 0 - Passed test */
808/* 1 - Failed test */
809/* */
810/* RESTRICTIONS/LIMITATIONS: */
811/* */
812/* */
813/*********************************************************************/
814int mem_march (volatile unsigned long long *base,
815 unsigned int size,
816 unsigned long long rmask,
817 unsigned long long wmask, short read, short write)
818{
819 unsigned int i;
Wolfgang Denk77ddac92005-10-13 16:45:02 +0200820 unsigned long long temp = 0;
stroese771e05b2004-12-16 18:21:17 +0000821 unsigned int hitemp, lotemp, himask, lomask;
822
823 for (i = 0; i < size; i++) {
824 if (read != 0) {
825 /* temp = base[i]; */
826 move64 ((unsigned long long *) &(base[i]), &temp);
827 if (rmask != temp) {
828 hitemp = (temp >> 32) & 0xffffffff;
829 lotemp = temp & 0xffffffff;
830 himask = (rmask >> 32) & 0xffffffff;
831 lomask = rmask & 0xffffffff;
832
833 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);
834 return 1;
835 }
836 }
837 if (write != 0) {
838 /* base[i] = wmask; */
839 move64 (&wmask, (unsigned long long *) &(base[i]));
840 }
841 }
842 return 0;
843}
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200844#endif /* CONFIG_SYS_DRAM_TEST_WALK */
stroese771e05b2004-12-16 18:21:17 +0000845
846/*********************************************************************/
847/* NAME: mem_test_walk() - a simple walking ones test */
848/* */
849/* DESCRIPTION: */
850/* Performs a walking ones through entire physical memory. The */
851/* test uses as series of memory marches, mem_march(), to verify */
852/* and write the test patterns to memory. The test sequence is as */
853/* follows: */
854/* 1) march writing 0000...0001 */
855/* 2) march verifying 0000...0001 , writing 0000...0010 */
856/* 3) repeat step 2 shifting masks left 1 bit each time unitl */
857/* the write mask equals 1000...0000 */
858/* 4) march verifying 1000...0000 */
859/* The test fails if any of the memory marches return a failure. */
860/* */
861/* OUTPUTS: */
862/* Displays which pass on the memory test is executing */
863/* */
864/* RETURNS: */
865/* 0 - Passed test */
866/* 1 - Failed test */
867/* */
868/* RESTRICTIONS/LIMITATIONS: */
869/* */
870/* */
871/*********************************************************************/
872int mem_test_walk (void)
873{
874 unsigned long long mask;
875 volatile unsigned long long *pmem =
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200876 (volatile unsigned long long *) CONFIG_SYS_MEMTEST_START;
877 const unsigned long size = (CONFIG_SYS_MEMTEST_END - CONFIG_SYS_MEMTEST_START) / 8;
stroese771e05b2004-12-16 18:21:17 +0000878
879 unsigned int i;
880
881 mask = 0x01;
882
883 printf ("Initial Pass");
884 mem_march (pmem, size, 0x0, 0x1, 0, 1);
885
886 printf ("\b\b\b\b\b\b\b\b\b\b\b\b");
887 printf (" ");
888 printf (" ");
889 printf ("\b\b\b\b\b\b\b\b\b\b\b\b");
890
891 for (i = 0; i < 63; i++) {
892 printf ("Pass %2d", i + 2);
893 if (mem_march (pmem, size, mask, mask << 1, 1, 1) != 0) {
894 /*printf("mask: 0x%x, pass: %d, ", mask, i); */
895 return 1;
896 }
897 mask = mask << 1;
898 printf ("\b\b\b\b\b\b\b");
899 }
900
901 printf ("Last Pass");
902 if (mem_march (pmem, size, 0, mask, 0, 1) != 0) {
903 /* printf("mask: 0x%x", mask); */
904 return 1;
905 }
906 printf ("\b\b\b\b\b\b\b\b\b");
907 printf (" ");
908 printf ("\b\b\b\b\b\b\b\b\b");
909
910 return 0;
911}
912
913/*********************************************************************/
914/* NAME: testdram() - calls any enabled memory tests */
915/* */
916/* DESCRIPTION: */
917/* Runs memory tests if the environment test variables are set to */
918/* 'y'. */
919/* */
920/* INPUTS: */
921/* testdramdata - If set to 'y', data test is run. */
922/* testdramaddress - If set to 'y', address test is run. */
923/* testdramwalk - If set to 'y', walking ones test is run */
924/* */
925/* OUTPUTS: */
926/* None */
927/* */
928/* RETURNS: */
929/* 0 - Passed test */
930/* 1 - Failed test */
931/* */
932/* RESTRICTIONS/LIMITATIONS: */
933/* */
934/* */
935/*********************************************************************/
936int testdram (void)
937{
938 char *s;
939 int rundata = 0;
940 int runaddress = 0;
941 int runwalk = 0;
942
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200943#ifdef CONFIG_SYS_DRAM_TEST_DATA
stroese771e05b2004-12-16 18:21:17 +0000944 s = getenv ("testdramdata");
945 rundata = (s && (*s == 'y')) ? 1 : 0;
946#endif
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200947#ifdef CONFIG_SYS_DRAM_TEST_ADDRESS
stroese771e05b2004-12-16 18:21:17 +0000948 s = getenv ("testdramaddress");
949 runaddress = (s && (*s == 'y')) ? 1 : 0;
950#endif
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200951#ifdef CONFIG_SYS_DRAM_TEST_WALK
stroese771e05b2004-12-16 18:21:17 +0000952 s = getenv ("testdramwalk");
953 runwalk = (s && (*s == 'y')) ? 1 : 0;
954#endif
955
956 if ((rundata == 1) || (runaddress == 1) || (runwalk == 1)) {
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200957 printf ("Testing RAM from 0x%08x to 0x%08x ... (don't panic... that will take a moment !!!!)\n", CONFIG_SYS_MEMTEST_START, CONFIG_SYS_MEMTEST_END);
stroese771e05b2004-12-16 18:21:17 +0000958 }
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200959#ifdef CONFIG_SYS_DRAM_TEST_DATA
stroese771e05b2004-12-16 18:21:17 +0000960 if (rundata == 1) {
961 printf ("Test DATA ... ");
962 if (mem_test_data () == 1) {
963 printf ("failed \n");
964 return 1;
965 } else
966 printf ("ok \n");
967 }
968#endif
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200969#ifdef CONFIG_SYS_DRAM_TEST_ADDRESS
stroese771e05b2004-12-16 18:21:17 +0000970 if (runaddress == 1) {
971 printf ("Test ADDRESS ... ");
972 if (mem_test_address () == 1) {
973 printf ("failed \n");
974 return 1;
975 } else
976 printf ("ok \n");
977 }
978#endif
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200979#ifdef CONFIG_SYS_DRAM_TEST_WALK
stroese771e05b2004-12-16 18:21:17 +0000980 if (runwalk == 1) {
981 printf ("Test WALKING ONEs ... ");
982 if (mem_test_walk () == 1) {
983 printf ("failed \n");
984 return 1;
985 } else
986 printf ("ok \n");
987 }
988#endif
989 if ((rundata == 1) || (runaddress == 1) || (runwalk == 1)) {
990 printf ("passed\n");
991 }
992 return 0;
993
994}
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200995#endif /* CONFIG_SYS_DRAM_TEST */
stroese771e05b2004-12-16 18:21:17 +0000996
Wolfgang Denk74357112007-02-27 14:26:04 +0100997/* ronen - the below functions are used by the bootm function */
stroese771e05b2004-12-16 18:21:17 +0000998/* - we map the base register to fbe00000 (same mapping as in the LSP) */
999/* - we turn off the RX gig dmas - to prevent the dma from overunning */
Wolfgang Denk74357112007-02-27 14:26:04 +01001000/* the kernel data areas. */
1001/* - we diable and invalidate the icache and dcache. */
stroese771e05b2004-12-16 18:21:17 +00001002void my_remap_gt_regs_bootm (u32 cur_loc, u32 new_loc)
1003{
1004 u32 temp;
1005
1006 temp = in_le32 ((u32 *) (new_loc + INTERNAL_SPACE_DECODE));
1007 if ((temp & 0xffff) == new_loc >> 16)
1008 return;
1009
1010 temp = (in_le32 ((u32 *) (cur_loc + INTERNAL_SPACE_DECODE)) &
1011 0xffff0000) | (new_loc >> 16);
1012
1013 out_le32 ((u32 *) (cur_loc + INTERNAL_SPACE_DECODE), temp);
1014
1015 while ((WORD_SWAP (*((volatile unsigned int *) (NONE_CACHEABLE |
1016 new_loc |
1017 (INTERNAL_SPACE_DECODE)))))
1018 != temp);
1019
1020}
1021
1022void board_prebootm_init ()
1023{
1024
1025/* change window size of PCI1 IO in order tp prevent overlaping with REG BASE. */
1026 GT_REG_WRITE (PCI_1_IO_SIZE, (_64K - 1) >> 16);
1027
1028/* Stop GigE Rx DMA engines */
1029 GT_REG_WRITE (MV64360_ETH_RECEIVE_QUEUE_COMMAND_REG (0), 0x0000ff00);
1030/* GT_REG_WRITE (MV64360_ETH_RECEIVE_QUEUE_COMMAND_REG (1), 0x0000ff00); */
1031/* GV_REG_WRITE (MV64360_ETH_RECEIVE_QUEUE_COMMAND_REG (2), 0x0000ff00); */
1032
1033/* Relocate MV64360 internal regs */
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +02001034 my_remap_gt_regs_bootm (CONFIG_SYS_GT_REGS, CONFIG_SYS_DFL_GT_REGS);
stroese771e05b2004-12-16 18:21:17 +00001035
1036 icache_disable ();
stroese771e05b2004-12-16 18:21:17 +00001037 dcache_disable ();
1038}
Stefan Roesed5ea2872007-01-31 16:38:04 +01001039
Stefan Roese2d780742007-06-22 17:32:28 +02001040int do_show_config(cmd_tbl_t * cmdtp, int flag, int argc, char *argv[])
Stefan Roesed5ea2872007-01-31 16:38:04 +01001041{
1042 unsigned int reset_sample_low;
1043 unsigned int reset_sample_high;
Stefan Roese2d780742007-06-22 17:32:28 +02001044 unsigned int l, l1, l2;
Stefan Roesed5ea2872007-01-31 16:38:04 +01001045
1046 GT_REG_READ(0x3c4, &reset_sample_low);
1047 GT_REG_READ(0x3d4, &reset_sample_high);
1048 printf("Reset configuration 0x%08x 0x%08x\n", reset_sample_low, reset_sample_high);
1049
Stefan Roese2d780742007-06-22 17:32:28 +02001050 l2 = 0;
1051 for (l=0; l<63; l++) {
1052 if (show_config_tab[l][0] != 0) {
1053 printf("%14s:%1x ", show_config_tab[l],
1054 ((reset_sample_low >> (31 - (l & 0x1f)))) & 0x01);
1055 l2++;
1056 if ((l2 % 4) == 0)
1057 printf("\n");
1058 } else {
1059 l1++;
1060 }
1061 if (l == 32)
1062 reset_sample_low = reset_sample_high;
1063 }
1064 printf("\n");
1065
Wolfgang Denk74357112007-02-27 14:26:04 +01001066 return(0);
Stefan Roesed5ea2872007-01-31 16:38:04 +01001067}
1068
Stefan Roesed5ea2872007-01-31 16:38:04 +01001069U_BOOT_CMD(
Stefan Roese2d780742007-06-22 17:32:28 +02001070 show_config, 1, 1, do_show_config,
Peter Tyser2fb26042009-01-27 18:03:12 -06001071 "Show Marvell strapping register",
Wolfgang Denka89c33d2009-05-24 17:06:54 +02001072 "Show Marvell strapping register (ResetSampleLow ResetSampleHigh)"
1073);