]> git.kernelconcepts.de Git - karo-tx-uboot.git/blob - board/sc3/sc3.c
Raname solidcard3 into sc3; add redundant env for sc3
[karo-tx-uboot.git] / board / sc3 / sc3.c
1 /*
2  * (C) Copyright 2007
3  * Heiko Schocher, DENX Software Engineering, <hs@denx.de>.
4  *
5  * (C) Copyright 2003
6  * Juergen Beisert, EuroDesign embedded technologies, info@eurodsn.de
7  * Derived from walnut.c
8  *
9  * (C) Copyright 2000
10  * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
11  *
12  * See file CREDITS for list of people who contributed to this
13  * project.
14  *
15  * This program is free software; you can redistribute it and/or
16  * modify it under the terms of the GNU General Public License as
17  * published by the Free Software Foundation; either version 2 of
18  * the License, or (at your option) any later version.
19  *
20  * This program is distributed in the hope that it will be useful,
21  * but WITHOUT ANY WARRANTY; without even the implied warranty of
22  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
23  * GNU General Public License for more details.
24  *
25  * You should have received a copy of the GNU General Public License
26  * along with this program; if not, write to the Free Software
27  * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
28  * MA 02111-1307 USA
29  *
30  * $Log:$
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
41 #undef writel
42 #undef writeb
43 #define writeb(b,addr) ((*(volatile u8 *) (addr)) = (b))
44 #define writel(b,addr) ((*(volatile u32 *) (addr)) = (b))
45
46 /* write only register to configure things in our CPLD */
47 #define CPLD_CONTROL_1  0x79000102
48 #define CPLD_VERSION    0x79000103
49
50 #define IS_CAMERON ((*(unsigned char *)(CPLD_VERSION)== 0x32) ? 1 : 0)
51
52 static struct pci_controller hose={0,};
53
54 /************************************************************
55  * Standard definition
56  ************************************************************/
57
58 /* CPC0_CR0        Function                                 ISA bus
59         -  GPIO0
60         -  GPIO1      -> Output: NAND-Command Latch Enable
61         -  GPIO2      -> Output: NAND Address Latch Enable
62         -  GPIO3      -> IRQ input                               ISA-IRQ #5 (through CPLD)
63         -  GPIO4      -> Output: NAND-Chip Enable
64         -  GPIO5      -> IRQ input                               ISA-IRQ#7 (through CPLD)
65         -  GPIO6      -> IRQ input                               ISA-IRQ#9 (through CPLD)
66         -  GPIO7      -> IRQ input                               ISA-IRQ#10 (through CPLD)
67         -  GPIO8      -> IRQ input                               ISA-IRQ#11 (through CPLD)
68         -  GPIO9      -> IRQ input                               ISA-IRQ#12 (through CPLD)
69         - GPIO10/CS1# -> CS1# NAND                               ISA-CS#0
70         - GPIO11/CS2# -> CS2# ISA emulation                      ISA-CS#1
71         - GPIO12/CS3# -> CS3# 2nd Flash-Bank                     ISA-CS#2 or ISA-CS#7
72         - GPIO13/CS4# -> CS4# USB HC or ISA emulation            ISA-CS#3
73         - GPIO14/CS5# -> CS5# Boosted IDE access                 ISA-CS#4
74         - GPIO15/CS6# -> CS6# ISA emulation                      ISA-CS#5
75         - GPIO16/CS7# -> CS7# ISA emulation                      ISA-CS#6
76         - GPIO17/IRQ0 -> GPIO, in, NAND-Ready/Busy# line         ISA-IRQ#3
77         - GPIO18/IRQ1 -> IRQ input                               ISA-IRQ#14
78         - GPIO19/IRQ2 -> IRQ input or USB                        ISA-IRQ#4
79         - GPIO20/IRQ3 -> IRQ input                               PCI-IRQ#D
80         - GPIO21/IRQ4 -> IRQ input                               PCI-IRQ#C
81         - GPIO22/IRQ5 -> IRQ input                               PCI-IRQ#B
82         - GPIO23/IRQ6 -> IRQ input                               PCI-IRQ#A
83         - GPIO24 -> if GPIO output: 0=JTAG CPLD activ, 1=JTAG CPLD inactiv
84 */
85 /*
86 | CPLD register: io-space at offset 0x102 (write only)
87 | 0
88 | 1
89 | 2 0=CS#4 USB CS#, 1=ISA or GP bus
90 | 3
91 | 4
92 | 5
93 | 6 1=enable faster IDE access
94 | 7
95 */
96 #define USB_CHIP_ENABLE 0x04
97 #define IDE_BOOSTING 0x40
98
99 /* --------------- USB stuff ------------------------------------- */
100 #ifdef CONFIG_ISP1161_PRESENT
101 /**
102  * initUsbHost- Initialize the Philips isp1161 HC part if present
103  * @cpldConfig: Pointer to value in write only CPLD register
104  *
105  * Initialize the USB host controller if present and fills the
106  * scratch register to inform the driver about used resources
107  */
108
109 static void initUsbHost (unsigned char *cpldConfig)
110 {
111         int i;
112         unsigned long usbBase;
113         /*
114          * Read back where init.S has located the USB chip
115          */
116         mtdcr (0x012, 0x04);
117         usbBase = mfdcr (0x013);
118         if (!(usbBase & 0x18000))       /* enabled? */
119                 return;
120         usbBase &= 0xFFF00000;
121
122         /*
123          * to test for the USB controller enable using of CS#4 and DMA 3 for USB access
124          */
125         writeb (*cpldConfig | USB_CHIP_ENABLE,CPLD_CONTROL_1);
126
127         /*
128          * first check: is the controller assembled?
129          */
130         hcWriteWord (usbBase, 0x5555, HcScratch);
131         if (hcReadWord (usbBase, HcScratch) == 0x5555) {
132                 hcWriteWord (usbBase, 0xAAAA, HcScratch);
133                 if (hcReadWord (usbBase, HcScratch) == 0xAAAA) {
134                         if ((hcReadWord (usbBase, HcChipID) & 0xFF00) != 0x6100)
135                                 return; /* this is not our controller */
136                 /*
137                  * try a software reset. This needs up to 10 seconds (see datasheet)
138                  */
139                         hcWriteDWord (usbBase, 0x00000001, HcCommandStatus);
140                         for (i = 1000; i > 0; i--) {    /* loop up to 10 seconds */
141                                 udelay (10);
142                                 if (!(hcReadDWord (usbBase, HcCommandStatus) & 0x01))
143                                         break;
144                         }
145
146                         if (!i)
147                                 return;  /* the controller doesn't responding. Broken? */
148                 /*
149                  * OK. USB controller is ready. Initialize it in such way the later driver
150                  * can us it (without any knowing about specific implementation)
151                  */
152                         hcWriteDWord (usbBase, 0x00000000, HcControl);
153                 /*
154                  * disable all interrupt sources. Because we
155                  * don't know where we come from (hard reset, cold start, soft reset...)
156                  */
157                         hcWriteDWord (usbBase, 0x8000007D, HcInterruptDisable);
158                 /*
159                  * our current setup hardware configuration
160                  * - every port power supply can switched indepently
161                  * - every port can signal overcurrent
162                  * - every port is "outside" and the devices are removeable
163                  */
164                         hcWriteDWord (usbBase, 0x32000902, HcRhDescriptorA);
165                         hcWriteDWord (usbBase, 0x00060000, HcRhDescriptorB);
166                 /*
167                  * don't forget to switch off power supply of each port
168                  * The later running driver can reenable them to find and use
169                  * the (maybe) connected devices.
170                  *
171                  */
172                         hcWriteDWord (usbBase, 0x00000200, HcRhPortStatus1);
173                         hcWriteDWord (usbBase, 0x00000200, HcRhPortStatus2);
174                         hcWriteWord (usbBase, 0x0428, HcHardwareConfiguration);
175                         hcWriteWord (usbBase, 0x0040, HcDMAConfiguration);
176                         hcWriteWord (usbBase, 0x0000, HcuPInterruptEnable);
177                         hcWriteWord (usbBase, 0xA000 | (0x03 << 8) | 27, HcScratch);
178                 /*
179                  * controller is present and usable
180                  */
181                         *cpldConfig |= USB_CHIP_ENABLE;
182                 }
183         }
184 }
185 #endif
186
187 #if defined(CONFIG_START_IDE)
188 int board_start_ide(void)
189 {
190         if (IS_CAMERON) {
191                 puts ("no IDE on cameron board.\n");
192                 return 0;
193         }
194         return 1;
195 }
196 #endif
197
198 static int sc3_cameron_init (void)
199 {
200         /* Set up the Memory Controller for the CAMERON version */
201         mtebc (pb4ap, 0x01805940);
202         mtebc (pb4cr, 0x7401a000);
203         mtebc (pb5ap, 0x01805940);
204         mtebc (pb5cr, 0x7401a000);
205         mtebc (pb6ap, 0x0);
206         mtebc (pb6cr, 0x0);
207         mtebc (pb7ap, 0x0);
208         mtebc (pb7cr, 0x0);
209         return 0;
210 }
211
212 void sc3_read_eeprom (void)
213 {
214         uchar i2c_buffer[18];
215
216         i2c_read (0x50, 0x03, 1, i2c_buffer, 9);
217         i2c_buffer[9] = 0;
218         setenv ("serial#", (char *)i2c_buffer);
219
220         /* read mac-address from eeprom */
221         i2c_read (0x50, 0x11, 1, i2c_buffer, 15);
222         i2c_buffer[17] = 0;
223         i2c_buffer[16] = i2c_buffer[14];
224         i2c_buffer[15] = i2c_buffer[13];
225         i2c_buffer[14] = ':';
226         i2c_buffer[13] = i2c_buffer[12];
227         i2c_buffer[12] = i2c_buffer[11];
228         i2c_buffer[11] = ':';
229         i2c_buffer[8] = ':';
230         i2c_buffer[5] = ':';
231         i2c_buffer[2] = ':';
232         setenv ("ethaddr", (char *)i2c_buffer);
233 }
234
235 int board_early_init_f (void)
236 {
237         /* write only register to configure things in our CPLD */
238         unsigned char cpldConfig_1=0x00;
239
240 /*-------------------------------------------------------------------------+
241 | Interrupt controller setup for the SolidCard III CPU card (plus Evaluation board).
242 |
243 | Note: IRQ 0  UART 0, active high; level sensitive
244 |       IRQ 1  UART 1, active high; level sensitive
245 |       IRQ 2  IIC, active high; level sensitive
246 |       IRQ 3  Ext. master, rising edge, edge sensitive
247 |       IRQ 4  PCI, active high; level sensitive
248 |       IRQ 5  DMA Channel 0, active high; level sensitive
249 |       IRQ 6  DMA Channel 1, active high; level sensitive
250 |       IRQ 7  DMA Channel 2, active high; level sensitive
251 |       IRQ 8  DMA Channel 3, active high; level sensitive
252 |       IRQ 9  Ethernet Wakeup, active high; level sensitive
253 |       IRQ 10 MAL System Error (SERR), active high; level sensitive
254 |       IRQ 11 MAL Tx End of Buffer, active high; level sensitive
255 |       IRQ 12 MAL Rx End of Buffer, active high; level sensitive
256 |       IRQ 13 MAL Tx Descriptor Error, active high; level sensitive
257 |       IRQ 14 MAL Rx Descriptor Error, active high; level sensitive
258 |       IRQ 15 Ethernet, active high; level sensitive
259 |       IRQ 16 External PCI SERR, active high; level sensitive
260 |       IRQ 17 ECC Correctable Error, active high; level sensitive
261 |       IRQ 18 PCI Power Management, active high; level sensitive
262 |
263 |       IRQ 19 (EXT IRQ7 405GPr only)
264 |       IRQ 20 (EXT IRQ8 405GPr only)
265 |       IRQ 21 (EXT IRQ9 405GPr only)
266 |       IRQ 22 (EXT IRQ10 405GPr only)
267 |       IRQ 23 (EXT IRQ11 405GPr only)
268 |       IRQ 24 (EXT IRQ12 405GPr only)
269 |
270 |       IRQ 25 (EXT IRQ 0) NAND-Flash R/B# (raising edge means flash is ready)
271 |       IRQ 26 (EXT IRQ 1) IDE0 interrupt (x86 = IRQ14). Active high (edge sensitive)
272 |       IRQ 27 (EXT IRQ 2) USB controller
273 |       IRQ 28 (EXT IRQ 3) INT D, VGA; active low; level sensitive
274 |       IRQ 29 (EXT IRQ 4) INT C, Ethernet; active low; level sensitive
275 |       IRQ 30 (EXT IRQ 5) INT B, PC104+ SLOT; active low; level sensitive
276 |       IRQ 31 (EXT IRQ 6) INT A, PC104+ SLOT; active low; level sensitive
277 |
278 | Direct Memory Access Controller Signal Polarities
279 |       DRQ0 active high (like ISA)
280 |       ACK0 active low (like ISA)
281 |       EOT0 active high (like ISA)
282 |       DRQ1 active high (like ISA)
283 |       ACK1 active low (like ISA)
284 |       EOT1 active high (like ISA)
285 |       DRQ2 active high (like ISA)
286 |       ACK2 active low (like ISA)
287 |       EOT2 active high (like ISA)
288 |       DRQ3 active high (like ISA)
289 |       ACK3 active low (like ISA)
290 |       EOT3 active high (like ISA)
291 |
292 +-------------------------------------------------------------------------*/
293
294         writeb (cpldConfig_1, CPLD_CONTROL_1);  /* disable everything in CPLD */
295
296         mtdcr (uicsr, 0xFFFFFFFF);    /* clear all ints */
297         mtdcr (uicer, 0x00000000);    /* disable all ints */
298         mtdcr (uiccr, 0x00000000);    /* set all to be non-critical */
299
300         if (IS_CAMERON) {
301                 sc3_cameron_init();
302                 mtdcr (0x0B6, 0x18000000);
303                 mtdcr (uicpr, 0xFFFFFFF0);
304                 mtdcr (uictr, 0x10001030);
305         } else {
306                 mtdcr (0x0B6, 0x0000000);
307                 mtdcr (uicpr, 0xFFFFFFE0);
308                 mtdcr (uictr, 0x10000020);
309         }
310         mtdcr (uicvcr, 0x00000001);   /* set vect base=0,INT0 highest priority */
311         mtdcr (uicsr, 0xFFFFFFFF);    /* clear all ints */
312
313         /* setup other implementation specific details */
314         mtdcr (ecr, 0x60606000);
315
316         mtdcr (cntrl1, 0x000042C0);
317
318         if (IS_CAMERON) {
319                 mtdcr (cntrl0, 0x01380000);
320                 /* Setup the GPIOs */
321                 writel (0x08008000, 0xEF600700);        /* Output states */
322                 writel (0x00000000, 0xEF600718);        /* Open Drain control */
323                 writel (0x68098000, 0xEF600704);        /* Output control */
324         } else {
325                 mtdcr (cntrl0,0x00080000);
326                 /* Setup the GPIOs */
327                 writel (0x08000000, 0xEF600700);        /* Output states */
328                 writel (0x14000000, 0xEF600718);        /* Open Drain control */
329                 writel (0x7C000000, 0xEF600704);        /* Output control */
330         }
331
332         /* Code decompression disabled */
333         mtdcr (kiar, kconf);
334         mtdcr (kidr, 0x2B);
335
336         /* CPC0_ER: enable sleep mode of (currently) unused components */
337         /* CPC0_FR: force unused components into sleep mode */
338         mtdcr (cpmer, 0x3F800000);
339         mtdcr (cpmfr, 0x14000000);
340
341         /* set PLB priority */
342         mtdcr (0x87, 0x08000000);
343
344         /* --------------- DMA stuff ------------------------------------- */
345         mtdcr (0x126, 0x49200000);
346
347 #ifndef IDE_USES_ISA_EMULATION
348         cpldConfig_1 |= IDE_BOOSTING;   /* enable faster IDE */
349         /* cpldConfig |= 0x01; */       /* enable 8.33MHz output, if *not* present on your baseboard */
350         writeb (cpldConfig_1, CPLD_CONTROL_1);
351 #endif
352
353 #ifdef CONFIG_ISP1161_PRESENT
354         initUsbHost (&cpldConfig_1);
355         writeb (cpldConfig_1, CPLD_CONTROL_1);
356 #endif
357         return(0);
358 }
359
360 int misc_init_r (void)
361 {
362         char *s1;
363         int i, xilinx_val;
364         volatile char *xilinx_adr;
365         xilinx_adr = (char *)0x79000102;
366
367         *xilinx_adr = 0x00;
368
369 /* customer settings ***************************************** */
370 /*
371         s1 = getenv ("function");
372         if (s1) {
373                 if (!strcmp (s1, "Rosho")) {
374                         printf ("function 'Rosho' activated\n");
375                         *xilinx_adr = 0x40;
376                 }
377                 else {
378                         printf (">>>>>>>>>> function %s not recognized\n",s1);
379                 }
380         }
381 */
382
383 /* individual settings ***************************************** */
384         if ((s1 = getenv ("xilinx"))) {
385                 i=0;
386                 xilinx_val = 0;
387                 while (i < 3 && s1[i]) {
388                         if (s1[i] >= '0' && s1[i] <= '9')
389                                 xilinx_val = (xilinx_val << 4) + s1[i] - '0';
390                         else
391                                 if (s1[i] >= 'A' && s1[i] <= 'F')
392                                         xilinx_val = (xilinx_val << 4) + s1[i] - 'A' + 10;
393                                 else
394                                         if (s1[i] >= 'a' && s1[i] <= 'f')
395                                                 xilinx_val = (xilinx_val << 4) + s1[i] - 'a' + 10;
396                                         else {
397                                                 xilinx_val = -1;
398                                                 break;
399                                         }
400                         i++;
401                 }
402                 if (xilinx_val >= 0 && xilinx_val <=255 && i < 3) {
403                         printf ("Xilinx: set to %s\n", s1);
404                         *xilinx_adr = (unsigned char) xilinx_val;
405                 } else
406                         printf ("Xilinx: rejected value %s\n", s1);
407         }
408         return 0;
409 }
410
411 /* -------------------------------------------------------------------------
412  * printCSConfig
413  *
414  * Print some informations about chips select configurations
415  * Only used while debugging.
416  *
417  * Params:
418  * - No. of CS pin
419  * - AP of this CS
420  * - CR of this CS
421  *
422  * Returns
423  * nothing
424    ------------------------------------------------------------------------- */
425
426 #ifdef SC3_DEBUGOUT
427 static void printCSConfig(int reg,unsigned long ap,unsigned long cr)
428 {
429         const char *bsize[4] = {"8","16","32","?"};
430         const unsigned char banks[8] = {1, 2, 4, 8, 16, 32, 64, 128};
431         const char *bankaccess[4] = {"disabled", "RO", "WO", "RW"};
432
433 #define CYCLE 30  /* time of one clock (based on 33MHz) */
434
435         printf("\nCS#%d",reg);
436         if (!(cr & 0x00018000))
437                 puts(" unused");
438         else {
439                 if (((cr&0xFFF00000U) & ((banks[(cr & 0x000E0000) >> 17]-1) << 20)))
440                         puts(" Address is not multiple of bank size!");
441
442                 printf("\n -%s bit device",
443                         bsize[(cr & 0x00006000) >> 13]);
444                 printf(" at 0x%08lX", cr & 0xFFF00000U);
445                 printf(" size: %u MB", banks[(cr & 0x000E0000) >> 17]);
446                 printf(" rights: %s", bankaccess[(cr & 0x00018000) >> 15]);
447                 if (ap & 0x80000000) {
448                         printf("\n -Burst device (%luns/%luns)",
449                                 (((ap & 0x7C000000) >> 26) + 1) * CYCLE,
450                                 (((ap & 0x03800000) >> 23) + 1) * CYCLE);
451                 } else {
452                         printf("\n -Non burst device, active cycle %luns",
453                                 (((ap & 0x7F800000) >> 23) + 1) * CYCLE);
454                         printf("\n -Address setup %luns",
455                                 ((ap & 0xC0000) >> 18) * CYCLE);
456                         printf("\n -CS active to RD %luns/WR %luns",
457                                 ((ap & 0x30000) >> 16) * CYCLE,
458                                 ((ap & 0xC000) >> 14) * CYCLE);
459                         printf("\n -WR to CS inactive %luns",
460                                 ((ap & 0x3000) >> 12) * CYCLE);
461                         printf("\n -Hold after access %luns",
462                                 ((ap & 0xE00) >> 9) * CYCLE);
463                         printf("\n -Ready is %sabled",
464                                 ap & 0x100 ? "en" : "dis");
465                 }
466         }
467 }
468 #endif
469
470 #ifdef SC3_DEBUGOUT
471
472 static unsigned int ap[] = {pb0ap, pb1ap, pb2ap, pb3ap, pb4ap,
473                                 pb5ap, pb6ap, pb7ap};
474 static unsigned int cr[] = {pb0cr, pb1cr, pb2cr, pb3cr, pb4cr,
475                                 pb5cr, pb6cr, pb7cr};
476
477 static int show_reg (int nr)
478 {
479         unsigned long ul1, ul2;
480
481         mtdcr (ebccfga, ap[nr]);
482         ul1 = mfdcr (ebccfgd);
483         mtdcr (ebccfga, cr[nr]);
484         ul2 = mfdcr(ebccfgd);
485         printCSConfig(nr, ul1, ul2);
486         return 0;
487 }
488 #endif
489
490 int checkboard (void)
491 {
492 #ifdef SC3_DEBUGOUT
493         unsigned long ul1;
494         int     i;
495
496         for (i = 0; i < 8; i++) {
497                 show_reg (i);
498         }
499
500         mtdcr (ebccfga, epcr);
501         ul1 = mfdcr (ebccfgd);
502
503         puts ("\nGeneral configuration:\n");
504
505         if (ul1 & 0x80000000)
506                 printf(" -External Bus is always driven\n");
507
508         if (ul1 & 0x400000)
509                 printf(" -CS signals are always driven\n");
510
511         if (ul1 & 0x20000)
512                 printf(" -PowerDown after %lu clocks\n",
513                         (ul1 & 0x1F000) >> 7);
514
515         switch (ul1 & 0xC0000)
516         {
517         case 0xC0000:
518                 printf(" -No external master present\n");
519                 break;
520         case 0x00000:
521                 printf(" -8 bit external master present\n");
522                 break;
523         case 0x40000:
524                 printf(" -16 bit external master present\n");
525                 break;
526         case 0x80000:
527                 printf(" -32 bit external master present\n");
528                 break;
529         }
530
531         switch (ul1 & 0x300000)
532         {
533         case 0x300000:
534                 printf(" -Prefetch: Illegal setting!\n");
535                 break;
536         case 0x000000:
537                 printf(" -1 doubleword prefetch\n");
538                 break;
539         case 0x100000:
540                 printf(" -2 doublewords prefetch\n");
541                 break;
542         case 0x200000:
543                 printf(" -4 doublewords prefetch\n");
544                 break;
545         }
546         putc ('\n');
547 #endif
548         printf("Board: SolidCard III %s %s version.\n",
549                 (IS_CAMERON ? "Cameron" : "Eurodesign"), CONFIG_SC3_VERSION);
550         return 0;
551 }
552
553 static int printSDRAMConfig(char reg, unsigned long cr)
554 {
555         const int bisize[8]={4, 8, 16, 32, 64, 128, 256, 0};
556 #ifdef SC3_DEBUGOUT
557         const char *basize[8]=
558                 {"4", "8", "16", "32", "64", "128", "256", "Reserved"};
559
560         printf("SDRAM bank %d",reg);
561
562         if (!(cr & 0x01))
563                 puts(" disabled\n");
564         else {
565                 printf(" at 0x%08lX, size %s MB",cr & 0xFFC00000,basize[(cr&0xE0000)>>17]);
566                 printf(" mode %lu\n",((cr & 0xE000)>>13)+1);
567         }
568 #endif
569
570         if (cr & 0x01)
571                 return(bisize[(cr & 0xE0000) >> 17]);
572
573         return 0;
574 }
575
576 #ifdef SC3_DEBUGOUT
577 static unsigned int mbcf[] = {mem_mb0cf, mem_mb1cf, mem_mb2cf, mem_mb3cf};
578 #endif
579
580 long int initdram (int board_type)
581 {
582         unsigned int mems=0;
583         unsigned long ul1;
584
585 #ifdef SC3_DEBUGOUT
586         unsigned long ul2;
587         int     i;
588
589         puts("\nSDRAM configuration:\n");
590
591         mtdcr (memcfga, mem_mcopt1);
592         ul1 = mfdcr(memcfgd);
593
594         if (!(ul1 & 0x80000000)) {
595                 puts(" Controller disabled\n");
596                 return 0;
597         }
598         for (i = 0; i < 4; i++) {
599                 mtdcr (memcfga, mbcf[i]);
600                 ul1 = mfdcr (memcfgd);
601                 mems += printSDRAMConfig (i, ul1);
602         }
603
604         mtdcr (memcfga, mem_sdtr1);
605         ul1 = mfdcr(memcfgd);
606
607         printf ("Timing:\n -CAS latency %lu\n", ((ul1 & 0x1800000) >> 23)+1);
608         printf (" -Precharge %lu (PTA) \n", ((ul1 & 0xC0000) >> 18) + 1);
609         printf (" -R/W to Precharge %lu (CTP)\n", ((ul1 & 0x30000) >> 16) + 1);
610         printf (" -Leadoff %lu\n", ((ul1 & 0xC000) >> 14) + 1);
611         printf (" -CAS to RAS %lu\n", ((ul1 & 0x1C) >> 2) + 4);
612         printf (" -RAS to CAS %lu\n", ((ul1 & 0x3) + 1));
613         puts ("Misc:\n");
614         mtdcr (memcfga, mem_rtr);
615         ul1 = mfdcr(memcfgd);
616         printf (" -Refresh rate: %luns\n", (ul1 >> 16) * 7);
617
618         mtdcr(memcfga,mem_pmit);
619         ul2=mfdcr(memcfgd);
620
621         mtdcr(memcfga,mem_mcopt1);
622         ul1=mfdcr(memcfgd);
623
624         if (ul1 & 0x20000000)
625                 printf(" -Power Down after: %luns\n",
626                         ((ul2 & 0xFFC00000) >> 22) * 7);
627         else
628                 puts(" -Power Down disabled\n");
629
630         if (ul1 & 0x40000000)
631                 printf(" -Self refresh feature active\n");
632         else
633                 puts(" -Self refresh disabled\n");
634
635         if (ul1 & 0x10000000)
636                 puts(" -ECC enabled\n");
637         else
638                 puts(" -ECC disabled\n");
639
640         if (ul1 & 0x8000000)
641                 puts(" -Using registered SDRAM\n");
642
643         if (!(ul1 & 0x6000000))
644                 puts(" -Using 32 bit data width\n");
645         else
646                 puts(" -Illegal data width!\n");
647
648         if (ul1 & 0x400000)
649                 puts(" -ECC drivers inactive\n");
650         else
651                 puts(" -ECC drivers active\n");
652
653         if (ul1 & 0x200000)
654                 puts(" -Memory lines always active outputs\n");
655         else
656                 puts(" -Memory lines only at write cycles active outputs\n");
657
658         mtdcr (memcfga, mem_status);
659         ul1 = mfdcr (memcfgd);
660         if (ul1 & 0x80000000)
661                 puts(" -SDRAM Controller ready\n");
662         else
663                 puts(" -SDRAM Controller not ready\n");
664
665         if (ul1 & 0x4000000)
666                 puts(" -SDRAM in self refresh mode!\n");
667
668         return (mems * 1024 * 1024);
669 #else
670         mtdcr (memcfga, mem_mb0cf);
671         ul1 = mfdcr (memcfgd);
672         mems = printSDRAMConfig (0, ul1);
673
674         mtdcr (memcfga, mem_mb1cf);
675         ul1 = mfdcr (memcfgd);
676         mems += printSDRAMConfig (1, ul1);
677
678         mtdcr (memcfga, mem_mb2cf);
679         ul1 = mfdcr(memcfgd);
680         mems += printSDRAMConfig (2, ul1);
681
682         mtdcr (memcfga, mem_mb3cf);
683         ul1 = mfdcr(memcfgd);
684         mems += printSDRAMConfig (3, ul1);
685
686         return (mems * 1024 * 1024);
687 #endif
688 }
689
690 static void pci_solidcard3_fixup_irq (struct pci_controller *hose, pci_dev_t dev)
691 {
692 /*-------------------------------------------------------------------------+
693  |             ,-.     ,-.        ,-.        ,-.        ,-.
694  |   INTD# ----|B|-----|P|-.    ,-|P|-.    ,-| |-.    ,-|G|
695  |             |R|     |C|  \  /  |C|  \  /  |E|  \  /  |r|
696  |   INTC# ----|I|-----|1|-. `/---|1|-. `/---|t|-. `/---|a|
697  |             |D|     |0|  \/    |0|  \/    |h|  \/    |f|
698  |   INTB# ----|G|-----|4|-./`----|4|-./`----|e|-./`----|i|
699  |             |E|     |+| /\     |+| /\     |r| /\     |k|
700  |   INTA# ----| |-----| |-  `----| |-  `----| |-  `----| |
701  |             `-'     `-'        `-'        `-'        `-'
702  |   Slot      0       10         11         12         13
703  |   REQ#              0          1          2          *
704  |   GNT#              0          1          2          *
705  +-------------------------------------------------------------------------*/
706         unsigned char int_line = 0xff;
707
708         switch (PCI_DEV(dev)) {
709         case 10:
710                 int_line = 31; /* INT A */
711                 POST_OUT(0x42);
712                 break;
713
714         case 11:
715                 int_line = 30; /* INT B */
716                 POST_OUT(0x43);
717                 break;
718
719         case 12:
720                 int_line = 29; /* INT C */
721                 POST_OUT(0x44);
722                 break;
723
724         case 13:
725                 int_line = 28; /* INT D */
726                 POST_OUT(0x45);
727                 break;
728         }
729         pci_hose_write_config_byte(hose, dev, PCI_INTERRUPT_LINE, int_line);
730 }
731
732 extern void pci_405gp_init(struct pci_controller *hose);
733 extern void pci_405gp_fixup_irq(struct pci_controller *hose, pci_dev_t dev);
734 extern void pci_405gp_setup_bridge(struct pci_controller *hose, pci_dev_t dev,struct pci_config_table *entry);
735 /*
736  * The following table is used when there is a special need to setup a PCI device.
737  * For every PCI device found in this table is called the given init function with given
738  * parameters. So never let all IDs at PCI_ANY_ID. In this case any found device gets the same
739  * parameters!
740  *
741 */
742 static struct pci_config_table pci_solidcard3_config_table[] =
743 {
744 /* Host to PCI Bridge device (405GP) */
745         {
746                 vendor: 0x1014,
747                 device: 0x0156,
748                 class: PCI_CLASS_BRIDGE_HOST,
749                 bus: 0,
750                 dev: 0,
751                 func: 0,
752                 config_device: pci_405gp_setup_bridge
753         },
754         { }
755 };
756
757 /*-------------------------------------------------------------------------+
758  | pci_init_board (Called from pci_init() in drivers/pci.c)
759  |
760  | Init the PCI part of the SolidCard III
761  |
762  | Params:
763  * - Pointer to current PCI hose
764  * - Current Device
765  *
766  * Returns
767  * nothing
768  +-------------------------------------------------------------------------*/
769
770 void pci_init_board(void)
771 {
772         POST_OUT(0x41);
773 /*
774  * we want the ptrs to RAM not flash (ie don't use init list)
775  */
776         hose.fixup_irq    = pci_solidcard3_fixup_irq;
777         hose.config_table = pci_solidcard3_config_table;
778         pci_405gp_init(&hose);
779 }