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
29
30
31
32
33#include <common.h>
34#include <asm/processor.h>
35#include <asm/io.h>
36#include "sc3.h"
37#include <pci.h>
38#include <i2c.h>
39#include <malloc.h>
40#include <netdev.h>
41
42#undef writel
43#undef writeb
44#define writeb(b,addr) ((*(volatile u8 *) (addr)) = (b))
45#define writel(b,addr) ((*(volatile u32 *) (addr)) = (b))
46
47
48#define CPLD_CONTROL_1 0x79000102
49#define CPLD_VERSION 0x79000103
50
51#define IS_CAMERON ((*(unsigned char *)(CPLD_VERSION)== 0x32) ? 1 : 0)
52
53static struct pci_controller hose={0,};
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97#define USB_CHIP_ENABLE 0x04
98#define IDE_BOOSTING 0x40
99
100
101#ifdef CONFIG_ISP1161_PRESENT
102
103
104
105
106
107
108
109
110static void initUsbHost (unsigned char *cpldConfig)
111{
112 int i;
113 unsigned long usbBase;
114
115
116
117 mtdcr (0x012, 0x04);
118 usbBase = mfdcr (0x013);
119 if (!(usbBase & 0x18000))
120 return;
121 usbBase &= 0xFFF00000;
122
123
124
125
126 writeb (*cpldConfig | USB_CHIP_ENABLE,CPLD_CONTROL_1);
127
128
129
130
131 hcWriteWord (usbBase, 0x5555, HcScratch);
132 if (hcReadWord (usbBase, HcScratch) == 0x5555) {
133 hcWriteWord (usbBase, 0xAAAA, HcScratch);
134 if (hcReadWord (usbBase, HcScratch) == 0xAAAA) {
135 if ((hcReadWord (usbBase, HcChipID) & 0xFF00) != 0x6100)
136 return;
137
138
139
140 hcWriteDWord (usbBase, 0x00000001, HcCommandStatus);
141 for (i = 1000; i > 0; i--) {
142 udelay (10);
143 if (!(hcReadDWord (usbBase, HcCommandStatus) & 0x01))
144 break;
145 }
146
147 if (!i)
148 return;
149
150
151
152
153 hcWriteDWord (usbBase, 0x00000000, HcControl);
154
155
156
157
158 hcWriteDWord (usbBase, 0x8000007D, HcInterruptDisable);
159
160
161
162
163
164
165 hcWriteDWord (usbBase, 0x32000902, HcRhDescriptorA);
166 hcWriteDWord (usbBase, 0x00060000, HcRhDescriptorB);
167
168
169
170
171
172
173 hcWriteDWord (usbBase, 0x00000200, HcRhPortStatus1);
174 hcWriteDWord (usbBase, 0x00000200, HcRhPortStatus2);
175 hcWriteWord (usbBase, 0x0428, HcHardwareConfiguration);
176 hcWriteWord (usbBase, 0x0040, HcDMAConfiguration);
177 hcWriteWord (usbBase, 0x0000, HcuPInterruptEnable);
178 hcWriteWord (usbBase, 0xA000 | (0x03 << 8) | 27, HcScratch);
179
180
181
182 *cpldConfig |= USB_CHIP_ENABLE;
183 }
184 }
185}
186#endif
187
188#if defined(CONFIG_START_IDE)
189int board_start_ide(void)
190{
191 if (IS_CAMERON) {
192 puts ("no IDE on cameron board.\n");
193 return 0;
194 }
195 return 1;
196}
197#endif
198
199static int sc3_cameron_init (void)
200{
201
202 mtebc (PB4AP, 0x01805940);
203 mtebc (PB4CR, 0x7401a000);
204 mtebc (PB5AP, 0x01805940);
205 mtebc (PB5CR, 0x7401a000);
206 mtebc (PB6AP, 0x0);
207 mtebc (PB6CR, 0x0);
208 mtebc (PB7AP, 0x0);
209 mtebc (PB7CR, 0x0);
210 return 0;
211}
212
213void sc3_read_eeprom (void)
214{
215 uchar i2c_buffer[18];
216
217 i2c_read (0x50, 0x03, 1, i2c_buffer, 9);
218 i2c_buffer[9] = 0;
219 setenv ("serial#", (char *)i2c_buffer);
220
221
222 i2c_read (0x50, 0x11, 1, i2c_buffer, 15);
223 i2c_buffer[17] = 0;
224 i2c_buffer[16] = i2c_buffer[14];
225 i2c_buffer[15] = i2c_buffer[13];
226 i2c_buffer[14] = ':';
227 i2c_buffer[13] = i2c_buffer[12];
228 i2c_buffer[12] = i2c_buffer[11];
229 i2c_buffer[11] = ':';
230 i2c_buffer[8] = ':';
231 i2c_buffer[5] = ':';
232 i2c_buffer[2] = ':';
233 setenv ("ethaddr", (char *)i2c_buffer);
234}
235
236int board_early_init_f (void)
237{
238
239 unsigned char cpldConfig_1=0x00;
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295 writeb (cpldConfig_1, CPLD_CONTROL_1);
296
297 mtdcr (UIC0SR, 0xFFFFFFFF);
298 mtdcr (UIC0ER, 0x00000000);
299 mtdcr (UIC0CR, 0x00000000);
300
301 if (IS_CAMERON) {
302 sc3_cameron_init();
303 mtdcr (0x0B6, 0x18000000);
304 mtdcr (UIC0PR, 0xFFFFFFF0);
305 mtdcr (UIC0TR, 0x10001030);
306 } else {
307 mtdcr (0x0B6, 0x0000000);
308 mtdcr (UIC0PR, 0xFFFFFFE0);
309 mtdcr (UIC0TR, 0x10000020);
310 }
311 mtdcr (UIC0VCR, 0x00000001);
312 mtdcr (UIC0SR, 0xFFFFFFFF);
313
314
315 mtdcr (CPC0_ECR, 0x60606000);
316
317 mtdcr (CPC0_CR1, 0x000042C0);
318
319 if (IS_CAMERON) {
320 mtdcr (CPC0_CR0, 0x01380000);
321
322 writel (0x08008000, 0xEF600700);
323 writel (0x00000000, 0xEF600718);
324 writel (0x68098000, 0xEF600704);
325 } else {
326 mtdcr (CPC0_CR0,0x00080000);
327
328 writel (0x08000000, 0xEF600700);
329 writel (0x14000000, 0xEF600718);
330 writel (0x7C000000, 0xEF600704);
331 }
332
333
334 mtdcr (KIAR, KCONF);
335 mtdcr (KIDR, 0x2B);
336
337
338
339 mtdcr (CPMER, 0x3F800000);
340 mtdcr (CPMFR, 0x14000000);
341
342
343 mtdcr (0x87, 0x08000000);
344
345
346 mtdcr (0x126, 0x49200000);
347
348#ifndef IDE_USES_ISA_EMULATION
349 cpldConfig_1 |= IDE_BOOSTING;
350
351 writeb (cpldConfig_1, CPLD_CONTROL_1);
352#endif
353
354#ifdef CONFIG_ISP1161_PRESENT
355 initUsbHost (&cpldConfig_1);
356 writeb (cpldConfig_1, CPLD_CONTROL_1);
357#endif
358
359 *(unsigned long *)0x79000080 = 0x0001;
360 return(0);
361}
362
363int misc_init_r (void)
364{
365 char *s1;
366 int i, xilinx_val;
367 volatile char *xilinx_adr;
368 xilinx_adr = (char *)0x79000102;
369
370 *xilinx_adr = 0x00;
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387 if ((s1 = getenv ("xilinx"))) {
388 i=0;
389 xilinx_val = 0;
390 while (i < 3 && s1[i]) {
391 if (s1[i] >= '0' && s1[i] <= '9')
392 xilinx_val = (xilinx_val << 4) + s1[i] - '0';
393 else
394 if (s1[i] >= 'A' && s1[i] <= 'F')
395 xilinx_val = (xilinx_val << 4) + s1[i] - 'A' + 10;
396 else
397 if (s1[i] >= 'a' && s1[i] <= 'f')
398 xilinx_val = (xilinx_val << 4) + s1[i] - 'a' + 10;
399 else {
400 xilinx_val = -1;
401 break;
402 }
403 i++;
404 }
405 if (xilinx_val >= 0 && xilinx_val <=255 && i < 3) {
406 printf ("Xilinx: set to %s\n", s1);
407 *xilinx_adr = (unsigned char) xilinx_val;
408 } else
409 printf ("Xilinx: rejected value %s\n", s1);
410 }
411 return 0;
412}
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429#ifdef SC3_DEBUGOUT
430static void printCSConfig(int reg,unsigned long ap,unsigned long cr)
431{
432 const char *bsize[4] = {"8","16","32","?"};
433 const unsigned char banks[8] = {1, 2, 4, 8, 16, 32, 64, 128};
434 const char *bankaccess[4] = {"disabled", "RO", "WO", "RW"};
435
436#define CYCLE 30
437
438 printf("\nCS#%d",reg);
439 if (!(cr & 0x00018000))
440 puts(" unused");
441 else {
442 if (((cr&0xFFF00000U) & ((banks[(cr & 0x000E0000) >> 17]-1) << 20)))
443 puts(" Address is not multiple of bank size!");
444
445 printf("\n -%s bit device",
446 bsize[(cr & 0x00006000) >> 13]);
447 printf(" at 0x%08lX", cr & 0xFFF00000U);
448 printf(" size: %u MB", banks[(cr & 0x000E0000) >> 17]);
449 printf(" rights: %s", bankaccess[(cr & 0x00018000) >> 15]);
450 if (ap & 0x80000000) {
451 printf("\n -Burst device (%luns/%luns)",
452 (((ap & 0x7C000000) >> 26) + 1) * CYCLE,
453 (((ap & 0x03800000) >> 23) + 1) * CYCLE);
454 } else {
455 printf("\n -Non burst device, active cycle %luns",
456 (((ap & 0x7F800000) >> 23) + 1) * CYCLE);
457 printf("\n -Address setup %luns",
458 ((ap & 0xC0000) >> 18) * CYCLE);
459 printf("\n -CS active to RD %luns/WR %luns",
460 ((ap & 0x30000) >> 16) * CYCLE,
461 ((ap & 0xC000) >> 14) * CYCLE);
462 printf("\n -WR to CS inactive %luns",
463 ((ap & 0x3000) >> 12) * CYCLE);
464 printf("\n -Hold after access %luns",
465 ((ap & 0xE00) >> 9) * CYCLE);
466 printf("\n -Ready is %sabled",
467 ap & 0x100 ? "en" : "dis");
468 }
469 }
470}
471#endif
472
473#ifdef SC3_DEBUGOUT
474
475static unsigned int ap[] = {PB0AP, PB1AP, PB2AP, PB3AP, PB4AP,
476 PB5AP, PB6AP, PB7AP};
477static unsigned int cr[] = {PB0CR, PB1CR, PB2CR, PB3CR, PB4CR,
478 PB5CR, PB6CR, PB7CR};
479
480static int show_reg (int nr)
481{
482 unsigned long ul1, ul2;
483
484 mtdcr (EBC0_CFGADDR, ap[nr]);
485 ul1 = mfdcr (EBC0_CFGDATA);
486 mtdcr (EBC0_CFGADDR, cr[nr]);
487 ul2 = mfdcr(EBC0_CFGDATA);
488 printCSConfig(nr, ul1, ul2);
489 return 0;
490}
491#endif
492
493int checkboard (void)
494{
495#ifdef SC3_DEBUGOUT
496 unsigned long ul1;
497 int i;
498
499 for (i = 0; i < 8; i++) {
500 show_reg (i);
501 }
502
503 mtdcr (EBC0_CFGADDR, EBC0_CFG);
504 ul1 = mfdcr (EBC0_CFGDATA);
505
506 puts ("\nGeneral configuration:\n");
507
508 if (ul1 & 0x80000000)
509 printf(" -External Bus is always driven\n");
510
511 if (ul1 & 0x400000)
512 printf(" -CS signals are always driven\n");
513
514 if (ul1 & 0x20000)
515 printf(" -PowerDown after %lu clocks\n",
516 (ul1 & 0x1F000) >> 7);
517
518 switch (ul1 & 0xC0000)
519 {
520 case 0xC0000:
521 printf(" -No external master present\n");
522 break;
523 case 0x00000:
524 printf(" -8 bit external master present\n");
525 break;
526 case 0x40000:
527 printf(" -16 bit external master present\n");
528 break;
529 case 0x80000:
530 printf(" -32 bit external master present\n");
531 break;
532 }
533
534 switch (ul1 & 0x300000)
535 {
536 case 0x300000:
537 printf(" -Prefetch: Illegal setting!\n");
538 break;
539 case 0x000000:
540 printf(" -1 doubleword prefetch\n");
541 break;
542 case 0x100000:
543 printf(" -2 doublewords prefetch\n");
544 break;
545 case 0x200000:
546 printf(" -4 doublewords prefetch\n");
547 break;
548 }
549 putc ('\n');
550#endif
551 printf("Board: SolidCard III %s %s version.\n",
552 (IS_CAMERON ? "Cameron" : "Eurodesign"), CONFIG_SC3_VERSION);
553 return 0;
554}
555
556static int printSDRAMConfig(char reg, unsigned long cr)
557{
558 const int bisize[8]={4, 8, 16, 32, 64, 128, 256, 0};
559#ifdef SC3_DEBUGOUT
560 const char *basize[8]=
561 {"4", "8", "16", "32", "64", "128", "256", "Reserved"};
562
563 printf("SDRAM bank %d",reg);
564
565 if (!(cr & 0x01))
566 puts(" disabled\n");
567 else {
568 printf(" at 0x%08lX, size %s MB",cr & 0xFFC00000,basize[(cr&0xE0000)>>17]);
569 printf(" mode %lu\n",((cr & 0xE000)>>13)+1);
570 }
571#endif
572
573 if (cr & 0x01)
574 return(bisize[(cr & 0xE0000) >> 17]);
575
576 return 0;
577}
578
579#ifdef SC3_DEBUGOUT
580static unsigned int mbcf[] = {SDRAM0_B0CR, SDRAM0_B1CR, SDRAM0_B2CR, SDRAM0_B3CR};
581#endif
582
583phys_size_t initdram (int board_type)
584{
585 unsigned int mems=0;
586 unsigned long ul1;
587
588#ifdef SC3_DEBUGOUT
589 unsigned long ul2;
590 int i;
591
592 puts("\nSDRAM configuration:\n");
593
594 mtdcr (SDRAM0_CFGADDR, SDRAM0_CFG);
595 ul1 = mfdcr(SDRAM0_CFGDATA);
596
597 if (!(ul1 & 0x80000000)) {
598 puts(" Controller disabled\n");
599 return 0;
600 }
601 for (i = 0; i < 4; i++) {
602 mtdcr (SDRAM0_CFGADDR, mbcf[i]);
603 ul1 = mfdcr (SDRAM0_CFGDATA);
604 mems += printSDRAMConfig (i, ul1);
605 }
606
607 mtdcr (SDRAM0_CFGADDR, SDRAM0_TR);
608 ul1 = mfdcr(SDRAM0_CFGDATA);
609
610 printf ("Timing:\n -CAS latency %lu\n", ((ul1 & 0x1800000) >> 23)+1);
611 printf (" -Precharge %lu (PTA) \n", ((ul1 & 0xC0000) >> 18) + 1);
612 printf (" -R/W to Precharge %lu (CTP)\n", ((ul1 & 0x30000) >> 16) + 1);
613 printf (" -Leadoff %lu\n", ((ul1 & 0xC000) >> 14) + 1);
614 printf (" -CAS to RAS %lu\n", ((ul1 & 0x1C) >> 2) + 4);
615 printf (" -RAS to CAS %lu\n", ((ul1 & 0x3) + 1));
616 puts ("Misc:\n");
617 mtdcr (SDRAM0_CFGADDR, SDRAM0_RTR);
618 ul1 = mfdcr(SDRAM0_CFGDATA);
619 printf (" -Refresh rate: %luns\n", (ul1 >> 16) * 7);
620
621 mtdcr(SDRAM0_CFGADDR,SDRAM0_PMIT);
622 ul2=mfdcr(SDRAM0_CFGDATA);
623
624 mtdcr(SDRAM0_CFGADDR,SDRAM0_CFG);
625 ul1=mfdcr(SDRAM0_CFGDATA);
626
627 if (ul1 & 0x20000000)
628 printf(" -Power Down after: %luns\n",
629 ((ul2 & 0xFFC00000) >> 22) * 7);
630 else
631 puts(" -Power Down disabled\n");
632
633 if (ul1 & 0x40000000)
634 printf(" -Self refresh feature active\n");
635 else
636 puts(" -Self refresh disabled\n");
637
638 if (ul1 & 0x10000000)
639 puts(" -ECC enabled\n");
640 else
641 puts(" -ECC disabled\n");
642
643 if (ul1 & 0x8000000)
644 puts(" -Using registered SDRAM\n");
645
646 if (!(ul1 & 0x6000000))
647 puts(" -Using 32 bit data width\n");
648 else
649 puts(" -Illegal data width!\n");
650
651 if (ul1 & 0x400000)
652 puts(" -ECC drivers inactive\n");
653 else
654 puts(" -ECC drivers active\n");
655
656 if (ul1 & 0x200000)
657 puts(" -Memory lines always active outputs\n");
658 else
659 puts(" -Memory lines only at write cycles active outputs\n");
660
661 mtdcr (SDRAM0_CFGADDR, SDRAM0_STATUS);
662 ul1 = mfdcr (SDRAM0_CFGDATA);
663 if (ul1 & 0x80000000)
664 puts(" -SDRAM Controller ready\n");
665 else
666 puts(" -SDRAM Controller not ready\n");
667
668 if (ul1 & 0x4000000)
669 puts(" -SDRAM in self refresh mode!\n");
670
671 return (mems * 1024 * 1024);
672#else
673 mtdcr (SDRAM0_CFGADDR, SDRAM0_B0CR);
674 ul1 = mfdcr (SDRAM0_CFGDATA);
675 mems = printSDRAMConfig (0, ul1);
676
677 mtdcr (SDRAM0_CFGADDR, SDRAM0_B1CR);
678 ul1 = mfdcr (SDRAM0_CFGDATA);
679 mems += printSDRAMConfig (1, ul1);
680
681 mtdcr (SDRAM0_CFGADDR, SDRAM0_B2CR);
682 ul1 = mfdcr(SDRAM0_CFGDATA);
683 mems += printSDRAMConfig (2, ul1);
684
685 mtdcr (SDRAM0_CFGADDR, SDRAM0_B3CR);
686 ul1 = mfdcr(SDRAM0_CFGDATA);
687 mems += printSDRAMConfig (3, ul1);
688
689 return (mems * 1024 * 1024);
690#endif
691}
692
693static void pci_solidcard3_fixup_irq (struct pci_controller *hose, pci_dev_t dev)
694{
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709 unsigned char int_line = 0xff;
710
711 switch (PCI_DEV(dev)) {
712 case 10:
713 int_line = 31;
714 POST_OUT(0x42);
715 break;
716
717 case 11:
718 int_line = 30;
719 POST_OUT(0x43);
720 break;
721
722 case 12:
723 int_line = 29;
724 POST_OUT(0x44);
725 break;
726
727 case 13:
728 int_line = 28;
729 POST_OUT(0x45);
730 break;
731 }
732 pci_hose_write_config_byte(hose, dev, PCI_INTERRUPT_LINE, int_line);
733}
734
735extern void pci_405gp_init(struct pci_controller *hose);
736extern void pci_405gp_fixup_irq(struct pci_controller *hose, pci_dev_t dev);
737extern void pci_405gp_setup_bridge(struct pci_controller *hose, pci_dev_t dev,struct pci_config_table *entry);
738
739
740
741
742
743
744
745static struct pci_config_table pci_solidcard3_config_table[] =
746{
747
748 {
749 vendor: 0x1014,
750 device: 0x0156,
751 class: PCI_CLASS_BRIDGE_HOST,
752 bus: 0,
753 dev: 0,
754 func: 0,
755 config_device: pci_405gp_setup_bridge
756 },
757 { }
758};
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773void pci_init_board(void)
774{
775 POST_OUT(0x41);
776
777
778
779 hose.fixup_irq = pci_solidcard3_fixup_irq;
780 hose.config_table = pci_solidcard3_config_table;
781 pci_405gp_init(&hose);
782}
783
784int board_eth_init(bd_t *bis)
785{
786 return pci_eth_init(bis);
787}
788