Import upstream u-boot 1.1.4
[u-boot.git] / board / eric / eric.c
1 /*
2  * (C) Copyright 2001
3  * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
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
24 #include <common.h>
25 #include <i2c.h>
26 #include "eric.h"
27 #include <asm/processor.h>
28
29 #define PPC405GP_GPIO0_OR      0xef600700       /* GPIO Output */
30 #define PPC405GP_GPIO0_TCR     0xef600704       /* GPIO Three-State Control */
31 #define PPC405GP_GPIO0_ODR     0xef600718       /* GPIO Open Drain */
32 #define PPC405GP_GPIO0_IR      0xef60071c       /* GPIO Input */
33
34 int board_early_init_f (void)
35 {
36
37    /*-------------------------------------------------------------------------+
38    | Interrupt controller setup for the ERIC board.
39    | Note: IRQ 0-15  405GP internally generated; active high; level sensitive
40    |       IRQ 16    405GP internally generated; active low; level sensitive
41    |       IRQ 17-24 RESERVED
42    |       IRQ 25 (EXT IRQ 0) FLASH; active low; level sensitive
43    |       IRQ 26 (EXT IRQ 1) PHY ; active low; level sensitive
44    |       IRQ 27 (EXT IRQ 2) HOST FAIL, active low; level sensitive
45    |                          indicates NO Power or HOST RESET active
46    |                          check GPIO7 (HOST RESET#) and GPIO8 (NO Power#)
47    |                          for real IRQ source
48    |       IRQ 28 (EXT IRQ 3) HOST; active high; level sensitive
49    |       IRQ 29 (EXT IRQ 4) PCI INTC#; active low; level sensitive
50    |       IRQ 30 (EXT IRQ 5) PCI INTB#; active low; level sensitive
51    |       IRQ 31 (EXT IRQ 6) PCI INTA#; active low; level sensitive
52    |        -> IRQ6 Pin is NOW GPIO23 and can be activateted by setting
53    |           PPC405GP_GPIO0_TCR Bit 0 = 1 (driving the output as defined in PPC405GP_GPIO0_OR,
54    |           else tristate)
55    | Note for ERIC board:
56    |       An interrupt taken for the HOST (IRQ 28) indicates that
57    |       the HOST wrote a "1" to one of the following locations
58    |       - VGA CRT_GPIO0 (if R1216 is loaded)
59    |       - VGA CRT_GPIO1 (if R1217 is loaded)
60    |
61    +-------------------------------------------------------------------------*/
62
63         mtdcr (uicsr, 0xFFFFFFFF);      /* clear all ints */
64         mtdcr (uicer, 0x00000000);      /* disable all ints */
65         mtdcr (uiccr, 0x00000000);      /* set all SMI to be non-critical */
66         mtdcr (uicpr, 0xFFFFFF88);      /* set int polarities; IRQ3 to 1 */
67         mtdcr (uictr, 0x10000000);      /* set int trigger levels, UART0 is EDGE */
68         mtdcr (uicvcr, 0x00000001);     /* set vect base=0,INT0 highest priority */
69         mtdcr (uicsr, 0xFFFFFFFF);      /* clear all ints */
70
71         mtdcr (cntrl0, 0x00002000);     /* set IRQ6 as GPIO23 to generate an interrupt request to the PCP2PCI bridge */
72
73         out32 (PPC405GP_GPIO0_OR, 0x60000000);  /*fixme is SMB_INT high or low active??; IRQ6 is GPIO23 output */
74         out32 (PPC405GP_GPIO0_TCR, 0x7E400000);
75
76         return 0;
77 }
78
79
80 /* ------------------------------------------------------------------------- */
81
82 /*
83  * Check Board Identity:
84  */
85
86 int checkboard (void)
87 {
88         char *s = getenv ("serial#");
89         char *e;
90
91         puts ("Board: ");
92
93         if (!s || strncmp (s, "ERIC", 9)) {
94                 puts ("### No HW ID - assuming ERIC");
95         } else {
96                 for (e = s; *e; ++e) {
97                         if (*e == ' ')
98                                 break;
99                 }
100
101                 for (; s < e; ++s) {
102                         putc (*s);
103                 }
104         }
105
106
107         putc ('\n');
108
109         return (0);
110 }
111
112
113 /* ------------------------------------------------------------------------- */
114 /* ------------------------------------------------------------------------- */
115 /* ------------------------------------------------------------------------- */
116 /*
117   initdram(int board_type) reads EEPROM via I2c. EEPROM contains all of
118   the necessary info for SDRAM controller configuration
119 */
120 /* ------------------------------------------------------------------------- */
121 /* ------------------------------------------------------------------------- */
122 long int initdram (int board_type)
123 {
124 #ifndef CONFIG_ERIC
125         int i;
126         unsigned char datain[128];
127         int TotalSize;
128 #endif
129
130
131 #ifdef CONFIG_ERIC
132         /*
133          * we have no EEPROM on ERIC
134          * so let init.S do the init job for SDRAM
135          * and simply return 32MByte here
136          */
137         return (CFG_SDRAM_SIZE * 1024 * 1024);
138 #else
139
140         /* Read Serial Presence Detect Information */
141         for (i = 0; i < 128; i++)
142                 datain[i] = 127;
143         i2c_send (SPD_EEPROM_ADDRESS, 0, 1, datain, 128);
144         printf ("\nReading DIMM...\n");
145 #if 0
146         for (i = 0; i < 128; i++) {
147                 printf ("%d=0x%x ", i, datain[i]);
148                 if (((i + 1) % 10) == 0)
149                         printf ("\n");
150         }
151         printf ("\n");
152 #endif
153
154   /*****************************/
155         /* Retrieve interesting data */
156   /*****************************/
157         /* size of a SDRAM bank */
158         /* Number of bytes per side / number of banks per side */
159         if (datain[31] == 0x08)
160                 TotalSize = 32;
161         else if (datain[31] == 0x10)
162                 TotalSize = 64;
163         else {
164                 printf ("IIC READ ERROR!!!\n");
165                 TotalSize = 32;
166         }
167
168         /* single-sided DIMM or double-sided DIMM? */
169         if (datain[5] != 1) {
170                 /* double-sided DIMM => SDRAM banks 0..3 are valid */
171                 printf ("double-sided DIMM\n");
172                 TotalSize *= 2;
173         }
174         /* else single-sided DIMM => SDRAM bank 0 and bank 2 are valid */
175         else {
176                 printf ("single-sided DIMM\n");
177         }
178
179
180         /* return size in Mb unit => *(1024*1024) */
181         return (TotalSize * 1024 * 1024);
182 #endif
183 }
184
185 /* ------------------------------------------------------------------------- */
186
187 int testdram (void)
188 {
189         /* TODO: XXX XXX XXX */
190         printf ("test: xxx MB - ok\n");
191
192         return (0);
193 }
194
195 /* ------------------------------------------------------------------------- */