blob: c0b36762b2888267ae4339c5aa08aa0584c4a856 [file] [log] [blame]
stroese842053a2004-12-16 18:17:50 +00001/*
2 * (C) Copyright 2004
3 * Stefan Roese, esd gmbh germany, stefan.roese@esd-electronics.com
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 <asm/processor.h>
26#include <command.h>
27
28
29#define MEM_MCOPT1_INIT_VAL 0x00800000
30#define MEM_RTR_INIT_VAL 0x04070000
31#define MEM_PMIT_INIT_VAL 0x07c00000
32#define MEM_MB0CF_INIT_VAL 0x00082001
33#define MEM_MB1CF_INIT_VAL 0x04082000
34#define MEM_SDTR1_INIT_VAL 0x00854005
35#define SDRAM0_CFG_ENABLE 0x80000000
36
37
38
39#define CFG_SDRAM_SIZE 0x04000000 /* 64 MB */
40
41
42int board_early_init_f (void)
43{
44#if 0 /* test-only */
45 mtdcr (uicsr, 0xFFFFFFFF); /* clear all ints */
46 mtdcr (uicer, 0x00000000); /* disable all ints */
47 mtdcr (uiccr, 0x00000010);
48 mtdcr (uicpr, 0xFFFF7FF0); /* set int polarities */
49 mtdcr (uictr, 0x00000010); /* set int trigger levels */
50 mtdcr (uicsr, 0xFFFFFFFF); /* clear all ints */
51#else
52 mtdcr(uicsr, 0xFFFFFFFF); /* clear all ints */
53 mtdcr(uicer, 0x00000000); /* disable all ints */
54 mtdcr(uiccr, 0x00000000); /* set all to be non-critical*/
55 mtdcr(uicpr, 0xFFFFFFF0); /* set int polarities */
56 mtdcr(uictr, 0x10000000); /* set int trigger levels */
57 mtdcr(uicvcr, 0x00000001); /* set vect base=0,INT0 highest priority*/
58 mtdcr(uicsr, 0xFFFFFFFF); /* clear all ints */
59#endif
60
61#if 1 /* test-only */
62 /*
63 * EBC Configuration Register: set ready timeout to 512 ebc-clks -> ca. 15 us
64 */
65 mtebc (epcr, 0xa8400000); /* ebc always driven */
66#endif
67
68 return 0;
69}
70
71
72int misc_init_f (void)
73{
74 return 0; /* dummy implementation */
75}
76
77
78int misc_init_r (void)
79{
80#if (CONFIG_COMMANDS & CFG_CMD_NAND)
81 /*
82 * Set NAND-FLASH GPIO signals to default
83 */
84 out32(GPIO0_OR, in32(GPIO0_OR) & ~(CFG_NAND_CLE | CFG_NAND_ALE));
85 out32(GPIO0_OR, in32(GPIO0_OR) | CFG_NAND_CE);
86#endif
87
88 return (0);
89}
90
91
92/*
93 * Check Board Identity:
94 */
95int checkboard (void)
96{
97 unsigned char str[64];
98 int i = getenv_r ("serial#", str, sizeof(str));
99
100 puts ("Board: ");
101
102 if (i == -1) {
103 puts ("### No HW ID - assuming G2000");
104 } else {
105 puts(str);
106 }
107
108 putc ('\n');
109
110 return 0;
111}
112
113
114/* -------------------------------------------------------------------------
115 G2000 rev B is an embeded design. we don't read for spd of this version.
116 Doing static SDRAM controller configuration in the following section.
117 ------------------------------------------------------------------------- */
118
119long int init_sdram_static_settings(void)
120{
121#define mtsdram0(reg, data) mtdcr(memcfga,reg);mtdcr(memcfgd,data)
122 /* disable memcontroller so updates work */
123 mtsdram0( mem_mcopt1, MEM_MCOPT1_INIT_VAL );
124 mtsdram0( mem_rtr , MEM_RTR_INIT_VAL );
125 mtsdram0( mem_pmit , MEM_PMIT_INIT_VAL );
126 mtsdram0( mem_mb0cf , MEM_MB0CF_INIT_VAL );
127 mtsdram0( mem_mb1cf , MEM_MB1CF_INIT_VAL );
128 mtsdram0( mem_sdtr1 , MEM_SDTR1_INIT_VAL );
129
130 /* SDRAM have a power on delay, 500 micro should do */
131 udelay(500);
132 mtsdram0( mem_mcopt1, MEM_MCOPT1_INIT_VAL|SDRAM0_CFG_ENABLE );
133
134 return (CFG_SDRAM_SIZE); /* CFG_SDRAM_SIZE is in G2000.h */
135 }
136
137
138long int initdram (int board_type)
139{
140 long int ret;
141
142/* flzt, we can still turn this on in the future */
143/* #ifdef CONFIG_SPD_EEPROM
144 ret = spd_sdram ();
145#else
146 ret = init_sdram_static_settings();
147#endif
148*/
149
150 ret = init_sdram_static_settings();
151
152 return ret;
153}
154
155
156#if 1 /* test-only */
157void sdram_init(void)
158{
159 init_sdram_static_settings();
160}
161#endif
162
163
164#if 0 /* test-only */
165long int initdram (int board_type)
166{
167 unsigned long val;
168
169 mtdcr(memcfga, mem_mb0cf);
170 val = mfdcr(memcfgd);
171
172#if 0
173 printf("\nmb0cf=%x\n", val); /* test-only */
174 printf("strap=%x\n", mfdcr(strap)); /* test-only */
175#endif
176
177 return (4*1024*1024 << ((val & 0x000e0000) >> 17));
178}
179#endif
180
181
182int testdram (void)
183{
184 /* TODO: XXX XXX XXX */
185 printf ("test: 16 MB - ok\n");
186
187 return (0);
188}
189
190
191#if (CONFIG_COMMANDS & CFG_CMD_NAND)
192#include <linux/mtd/nand.h>
193extern struct nand_chip nand_dev_desc[CFG_MAX_NAND_DEVICE];
194
195void nand_init(void)
196{
197 nand_probe(CFG_NAND_BASE);
198 if (nand_dev_desc[0].ChipID != NAND_ChipID_UNKNOWN) {
199 print_size(nand_dev_desc[0].totlen, "\n");
200 }
201}
202#endif
203
204
205#if 0 /* test-only !!! */
206int do_dumpebc(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
207{
208 ulong ap, cr;
209
210 printf("\nEBC registers for PPC405GP:\n");
211 mfebc(pb0ap, ap); mfebc(pb0cr, cr);
212 printf("0: AP=%08lx CP=%08lx\n", ap, cr);
213 mfebc(pb1ap, ap); mfebc(pb1cr, cr);
214 printf("1: AP=%08lx CP=%08lx\n", ap, cr);
215 mfebc(pb2ap, ap); mfebc(pb2cr, cr);
216 printf("2: AP=%08lx CP=%08lx\n", ap, cr);
217 mfebc(pb3ap, ap); mfebc(pb3cr, cr);
218 printf("3: AP=%08lx CP=%08lx\n", ap, cr);
219 mfebc(pb4ap, ap); mfebc(pb4cr, cr);
220 printf("4: AP=%08lx CP=%08lx\n", ap, cr);
221 printf("\n");
222
223 return 0;
224}
225U_BOOT_CMD(
226 dumpebc, 1, 1, do_dumpebc,
227 "dumpebc - Dump all EBC registers\n",
228 NULL
229);
230
231
232int do_dumpdcr(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
233{
234 int i;
235
236 printf("\nDevice Configuration Registers (DCR's) for PPC405GP:");
237 for (i=0; i<=0x1e0; i++) {
238 if (!(i % 0x8)) {
239 printf("\n%04x ", i);
240 }
241 printf("%08lx ", get_dcr(i));
242 }
243 printf("\n");
244
245 return 0;
246}
247U_BOOT_CMD(
248 dumpdcr, 1, 1, do_dumpdcr,
249 "dumpdcr - Dump all DCR registers\n",
250 NULL
251);
252
253
254int do_dumpspr(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
255{
256 printf("\nSpecial Purpose Registers (SPR's) for PPC405GP:");
257 printf("\n%04x %08x ", 947, mfspr(947));
258 printf("\n%04x %08x ", 9, mfspr(9));
259 printf("\n%04x %08x ", 1014, mfspr(1014));
260 printf("\n%04x %08x ", 1015, mfspr(1015));
261 printf("\n%04x %08x ", 1010, mfspr(1010));
262 printf("\n%04x %08x ", 957, mfspr(957));
263 printf("\n%04x %08x ", 1008, mfspr(1008));
264 printf("\n%04x %08x ", 1018, mfspr(1018));
265 printf("\n%04x %08x ", 954, mfspr(954));
266 printf("\n%04x %08x ", 950, mfspr(950));
267 printf("\n%04x %08x ", 951, mfspr(951));
268 printf("\n%04x %08x ", 981, mfspr(981));
269 printf("\n%04x %08x ", 980, mfspr(980));
270 printf("\n%04x %08x ", 982, mfspr(982));
271 printf("\n%04x %08x ", 1012, mfspr(1012));
272 printf("\n%04x %08x ", 1013, mfspr(1013));
273 printf("\n%04x %08x ", 948, mfspr(948));
274 printf("\n%04x %08x ", 949, mfspr(949));
275 printf("\n%04x %08x ", 1019, mfspr(1019));
276 printf("\n%04x %08x ", 979, mfspr(979));
277 printf("\n%04x %08x ", 8, mfspr(8));
278 printf("\n%04x %08x ", 945, mfspr(945));
279 printf("\n%04x %08x ", 987, mfspr(987));
280 printf("\n%04x %08x ", 287, mfspr(287));
281 printf("\n%04x %08x ", 953, mfspr(953));
282 printf("\n%04x %08x ", 955, mfspr(955));
283 printf("\n%04x %08x ", 272, mfspr(272));
284 printf("\n%04x %08x ", 273, mfspr(273));
285 printf("\n%04x %08x ", 274, mfspr(274));
286 printf("\n%04x %08x ", 275, mfspr(275));
287 printf("\n%04x %08x ", 260, mfspr(260));
288 printf("\n%04x %08x ", 276, mfspr(276));
289 printf("\n%04x %08x ", 261, mfspr(261));
290 printf("\n%04x %08x ", 277, mfspr(277));
291 printf("\n%04x %08x ", 262, mfspr(262));
292 printf("\n%04x %08x ", 278, mfspr(278));
293 printf("\n%04x %08x ", 263, mfspr(263));
294 printf("\n%04x %08x ", 279, mfspr(279));
295 printf("\n%04x %08x ", 26, mfspr(26));
296 printf("\n%04x %08x ", 27, mfspr(27));
297 printf("\n%04x %08x ", 990, mfspr(990));
298 printf("\n%04x %08x ", 991, mfspr(991));
299 printf("\n%04x %08x ", 956, mfspr(956));
300 printf("\n%04x %08x ", 284, mfspr(284));
301 printf("\n%04x %08x ", 285, mfspr(285));
302 printf("\n%04x %08x ", 986, mfspr(986));
303 printf("\n%04x %08x ", 984, mfspr(984));
304 printf("\n%04x %08x ", 256, mfspr(256));
305 printf("\n%04x %08x ", 1, mfspr(1));
306 printf("\n%04x %08x ", 944, mfspr(944));
307 printf("\n");
308
309 return 0;
310}
311U_BOOT_CMD(
312 dumpspr, 1, 1, do_dumpspr,
313 "dumpspr - Dump all SPR registers\n",
314 NULL
315);
316#endif