1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28#include <common.h>
29#include <74xx_7xx.h>
30#include <galileo/memory.h>
31#include <galileo/pci.h>
32#include <galileo/gt64260R.h>
33#include <net.h>
34#include <netdev.h>
35
36#include <asm/io.h>
37#include "eth.h"
38#include "mpsc.h"
39#include "i2c.h"
40#include "64260.h"
41
42DECLARE_GLOBAL_DATA_PTR;
43
44#ifdef CONFIG_ZUMA_V2
45extern void zuma_mbox_init(void);
46#endif
47
48#undef DEBUG
49#define MAP_PCI
50
51#ifdef DEBUG
52#define DP(x) x
53#else
54#define DP(x)
55#endif
56
57
58
59
60
61
62
63
64
65
66
67
68unsigned int INTERNAL_REG_BASE_ADDR = CONFIG_SYS_GT_REGS;
69
70
71
72
73
74
75
76
77
78
79
80void
81my_remap_gt_regs(u32 cur_loc, u32 new_loc)
82{
83 u32 temp;
84
85
86 temp = in_le32((u32 *)(new_loc + INTERNAL_SPACE_DECODE));
87 if ((temp & 0xffff) == new_loc >> 20)
88 return;
89
90 temp = (in_le32((u32 *)(cur_loc + INTERNAL_SPACE_DECODE)) &
91 0xffff0000) | (new_loc >> 20);
92
93 out_le32((u32 *)(cur_loc + INTERNAL_SPACE_DECODE), temp);
94
95 while (GTREGREAD(INTERNAL_SPACE_DECODE) != temp);
96}
97
98static void
99gt_pci_config(void)
100{
101
102
103 pciMapSpace(PCI_HOST0, PCI_REGION0, CONFIG_SYS_PCI0_0_MEM_SPACE,
104 CONFIG_SYS_PCI0_0_MEM_SPACE, CONFIG_SYS_PCI0_MEM_SIZE);
105
106 pciMapSpace(PCI_HOST0, PCI_REGION1, 0, 0, 0);
107 pciMapSpace(PCI_HOST0, PCI_REGION2, 0, 0, 0);
108 pciMapSpace(PCI_HOST0, PCI_REGION3, 0, 0, 0);
109
110 pciMapSpace(PCI_HOST0, PCI_IO, CONFIG_SYS_PCI0_IO_SPACE_PCI,
111 CONFIG_SYS_PCI0_IO_SPACE, CONFIG_SYS_PCI0_IO_SIZE);
112
113
114 pciMapSpace(PCI_HOST1, PCI_REGION0, CONFIG_SYS_PCI1_0_MEM_SPACE,
115 CONFIG_SYS_PCI1_0_MEM_SPACE, CONFIG_SYS_PCI1_MEM_SIZE);
116
117 pciMapSpace(PCI_HOST1, PCI_REGION1, 0, 0, 0);
118 pciMapSpace(PCI_HOST1, PCI_REGION2, 0, 0, 0);
119 pciMapSpace(PCI_HOST1, PCI_REGION3, 0, 0, 0);
120
121 pciMapSpace(PCI_HOST1, PCI_IO, CONFIG_SYS_PCI1_IO_SPACE_PCI,
122 CONFIG_SYS_PCI1_IO_SPACE, CONFIG_SYS_PCI1_IO_SIZE);
123
124
125 GT_REG_WRITE(PCI_0TIMEOUT_RETRY, 0xffff);
126 GT_REG_WRITE(PCI_1TIMEOUT_RETRY, 0xffff);
127 GT_REG_WRITE(PCI_0BASE_ADDRESS_REGISTERS_ENABLE, 0xfffff80e);
128 GT_REG_WRITE(PCI_1BASE_ADDRESS_REGISTERS_ENABLE, 0xfffff80e);
129
130
131}
132
133
134static void
135gt_cpu_config(void)
136{
137 cpu_t cpu = get_cpu_type();
138 ulong tmp;
139
140
141 tmp = GTREGREAD(CPU_CONFIGURATION);
142
143
144
145 tmp |= CPU_CONF_AACK_DELAY;
146 tmp &= ~CPU_CONF_AACK_DELAY_2;
147
148
149 tmp |= CPU_CONF_FAST_CLK;
150
151 if (cpu == CPU_750CX) {
152 tmp &= ~CPU_CONF_DP_VALID;
153 tmp &= ~CPU_CONF_AP_VALID;
154 } else {
155 tmp |= CPU_CONF_DP_VALID;
156 tmp |= CPU_CONF_AP_VALID;
157 }
158
159
160 tmp &= ~CPU_CONF_RD_OOO;
161 tmp |= CPU_CONF_PIPELINE;
162 tmp |= CPU_CONF_TA_DELAY;
163
164 GT_REG_WRITE(CPU_CONFIGURATION, tmp);
165
166
167 tmp = GTREGREAD(CPU_MASTER_CONTROL);
168
169 tmp |= CPU_MAST_CTL_ARB_EN;
170
171 if ((cpu == CPU_7400) ||
172 (cpu == CPU_7410) ||
173 (cpu == CPU_7450)) {
174
175 tmp |= CPU_MAST_CTL_CLEAN_BLK;
176 tmp |= CPU_MAST_CTL_FLUSH_BLK;
177
178 } else {
179
180
181
182 tmp &= ~CPU_MAST_CTL_CLEAN_BLK;
183 tmp &= ~CPU_MAST_CTL_FLUSH_BLK;
184 }
185 GT_REG_WRITE(CPU_MASTER_CONTROL, tmp);
186}
187
188
189
190
191
192
193int board_early_init_f (void)
194{
195 uchar sram_boot = 0;
196
197
198
199
200
201
202
203
204 my_remap_gt_regs(CONFIG_SYS_DFL_GT_REGS, CONFIG_SYS_GT_REGS);
205
206 gt_pci_config();
207
208
209 GT_REG_WRITE(CPU_INTERRUPT_MASK_REGISTER_LOW, 0);
210 GT_REG_WRITE(CPU_INTERRUPT_MASK_REGISTER_HIGH, 0);
211 GT_REG_WRITE(PCI_0INTERRUPT_CAUSE_MASK_REGISTER_LOW, 0);
212 GT_REG_WRITE(PCI_0INTERRUPT_CAUSE_MASK_REGISTER_HIGH, 0);
213 GT_REG_WRITE(PCI_1INTERRUPT_CAUSE_MASK_REGISTER_LOW, 0);
214 GT_REG_WRITE(PCI_1INTERRUPT_CAUSE_MASK_REGISTER_HIGH, 0);
215 GT_REG_WRITE(CPU_INT_0_MASK, 0);
216 GT_REG_WRITE(CPU_INT_1_MASK, 0);
217 GT_REG_WRITE(CPU_INT_2_MASK, 0);
218 GT_REG_WRITE(CPU_INT_3_MASK, 0);
219
220
221 GT_REG_WRITE(SDRAM_CONFIGURATION, CONFIG_SYS_SDRAM_CONFIG);
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244#if defined(CONFIG_ZUMA_V2) || defined(CONFIG_P3G4)
245
246 sram_boot = 0;
247#else
248 if (memoryGetDeviceBaseAddress(DEVICE0) && 0xfff00000 == CONFIG_SYS_MONITOR_BASE)
249 sram_boot = 1;
250#endif
251
252 memoryMapDeviceSpace(DEVICE0, CONFIG_SYS_DEV0_SPACE, CONFIG_SYS_DEV0_SIZE);
253
254 memoryMapDeviceSpace(DEVICE1, CONFIG_SYS_DEV1_SPACE, CONFIG_SYS_DEV1_SIZE);
255 memoryMapDeviceSpace(DEVICE2, CONFIG_SYS_DEV2_SPACE, CONFIG_SYS_DEV2_SIZE);
256 memoryMapDeviceSpace(DEVICE3, CONFIG_SYS_DEV3_SPACE, CONFIG_SYS_DEV3_SIZE);
257
258
259#ifdef CONFIG_SYS_DEV0_PAR
260 if (!sram_boot)
261 GT_REG_WRITE(DEVICE_BANK0PARAMETERS, CONFIG_SYS_DEV0_PAR);
262#endif
263
264#ifdef CONFIG_SYS_DEV1_PAR
265 GT_REG_WRITE(DEVICE_BANK1PARAMETERS, CONFIG_SYS_DEV1_PAR);
266#endif
267#ifdef CONFIG_SYS_DEV2_PAR
268 GT_REG_WRITE(DEVICE_BANK2PARAMETERS, CONFIG_SYS_DEV2_PAR);
269#endif
270
271#ifdef CONFIG_EVB64260
272#ifdef CONFIG_SYS_32BIT_BOOT_PAR
273
274 if (GTREGREAD(DEVICE_BOOT_BANK_PARAMETERS) & (0x3 << 20)) {
275
276 GT_REG_WRITE(DEVICE_BANK3PARAMETERS, CONFIG_SYS_8BIT_BOOT_PAR);
277 GT_REG_WRITE(DEVICE_BOOT_BANK_PARAMETERS, CONFIG_SYS_32BIT_BOOT_PAR);
278 } else {
279
280 GT_REG_WRITE(DEVICE_BANK3PARAMETERS, CONFIG_SYS_32BIT_BOOT_PAR);
281 GT_REG_WRITE(DEVICE_BOOT_BANK_PARAMETERS, CONFIG_SYS_8BIT_BOOT_PAR);
282 }
283#else
284
285 GT_REG_WRITE(DEVICE_BOOT_BANK_PARAMETERS, CONFIG_SYS_8BIT_BOOT_PAR);
286#endif
287#else
288
289
290 GT_REG_WRITE(DEVICE_BOOT_BANK_PARAMETERS, CONFIG_SYS_16BIT_BOOT_PAR);
291#endif
292
293 gt_cpu_config();
294
295
296 GT_REG_WRITE(MPP_CONTROL0, CONFIG_SYS_MPP_CONTROL_0);
297 GT_REG_WRITE(MPP_CONTROL1, CONFIG_SYS_MPP_CONTROL_1);
298 GT_REG_WRITE(MPP_CONTROL2, CONFIG_SYS_MPP_CONTROL_2);
299 GT_REG_WRITE(MPP_CONTROL3, CONFIG_SYS_MPP_CONTROL_3);
300
301 GT_REG_WRITE(GPP_LEVEL_CONTROL, CONFIG_SYS_GPP_LEVEL_CONTROL);
302 GT_REG_WRITE(SERIAL_PORT_MULTIPLEX, CONFIG_SYS_SERIAL_PORT_MUX);
303
304 return 0;
305}
306
307
308
309int misc_init_r (void)
310{
311 icache_enable();
312#ifdef CONFIG_SYS_L2
313 l2cache_enable();
314#endif
315
316#ifdef CONFIG_MPSC
317 mpsc_init2();
318#endif
319
320#ifdef CONFIG_ZUMA_V2
321 zuma_mbox_init();
322#endif
323 return (0);
324}
325
326void
327after_reloc(ulong dest_addr)
328{
329
330
331
332
333 if (memoryGetDeviceBaseAddress(DEVICE0) == CONFIG_SYS_MONITOR_BASE) {
334 memoryMapDeviceSpace(DEVICE0, CONFIG_SYS_DEV0_SPACE, CONFIG_SYS_DEV0_SIZE);
335 memoryMapDeviceSpace(BOOT_DEVICE, CONFIG_SYS_FLASH_BASE, _1M);
336 }
337
338
339 board_init_r ((gd_t *)gd, dest_addr);
340
341
342}
343
344
345
346
347
348
349
350int
351checkboard (void)
352{
353 puts ("Board: " CONFIG_SYS_BOARD_NAME "\n");
354 return (0);
355}
356
357
358void
359debug_led(int led, int mode)
360{
361#if !defined(CONFIG_ZUMA_V2) && !defined(CONFIG_P3G4)
362 volatile int *addr = NULL;
363 int dummy;
364
365 if (mode == 1) {
366 switch (led) {
367 case 0:
368 addr = (int *)((unsigned int)CONFIG_SYS_DEV1_SPACE | 0x08000);
369 break;
370
371 case 1:
372 addr = (int *)((unsigned int)CONFIG_SYS_DEV1_SPACE | 0x0c000);
373 break;
374
375 case 2:
376 addr = (int *)((unsigned int)CONFIG_SYS_DEV1_SPACE | 0x10000);
377 break;
378 }
379 } else if (mode == 0) {
380 switch (led) {
381 case 0:
382 addr = (int *)((unsigned int)CONFIG_SYS_DEV1_SPACE | 0x14000);
383 break;
384
385 case 1:
386 addr = (int *)((unsigned int)CONFIG_SYS_DEV1_SPACE | 0x18000);
387 break;
388
389 case 2:
390 addr = (int *)((unsigned int)CONFIG_SYS_DEV1_SPACE | 0x1c000);
391 break;
392 }
393 }
394 WRITE_CHAR(addr, 0);
395 dummy = *addr;
396#endif
397}
398
399void
400display_mem_map(void)
401{
402 int i,j;
403 unsigned int base,size,width;
404
405 printf("SDRAM\n");
406 for(i=0;i<=BANK3;i++) {
407 base = memoryGetBankBaseAddress(i);
408 size = memoryGetBankSize(i);
409 if(size !=0)
410 {
411 printf("BANK%d: base - 0x%08x\tsize - %dM bytes\n",i,base,size>>20);
412 }
413 }
414
415
416 for(i=0;i<=PCI_HOST1;i++) {
417 printf("\nCPU's PCI %d windows\n", i);
418 base=pciGetSpaceBase(i,PCI_IO);
419 size=pciGetSpaceSize(i,PCI_IO);
420 printf(" IO: base - 0x%08x\tsize - %dM bytes\n",base,size>>20);
421 for(j=0;j<=PCI_REGION3;j++) {
422 base = pciGetSpaceBase(i,j);
423 size = pciGetSpaceSize(i,j);
424 printf("MEMORY %d: base - 0x%08x\tsize - %dM bytes\n",j,base,
425 size>>20);
426 }
427 }
428
429
430 printf("\nDEVICES\n");
431 for(i=0;i<=DEVICE3;i++) {
432 base = memoryGetDeviceBaseAddress(i);
433 size = memoryGetDeviceSize(i);
434 width= memoryGetDeviceWidth(i) * 8;
435 printf("DEV %d: base - 0x%08x\tsize - %dM bytes\twidth - %d bits\n",
436 i, base, size>>20, width);
437 }
438
439
440 base = memoryGetDeviceBaseAddress(BOOT_DEVICE);
441 size = memoryGetDeviceSize(BOOT_DEVICE);
442 width= memoryGetDeviceWidth(BOOT_DEVICE) * 8;
443 printf(" BOOT: base - 0x%08x\tsize - %dM bytes\twidth - %d bits\n",
444 base, size>>20, width);
445}
446
447int board_eth_init(bd_t *bis)
448{
449 gt6426x_eth_initialize(bis);
450 return 0;
451}
452