blob: 647f4b705b46f6d6797cc5778215a4cdd76f4b03 [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
stroese842053a2004-12-16 18:17:50 +000028#define MEM_MCOPT1_INIT_VAL 0x00800000
29#define MEM_RTR_INIT_VAL 0x04070000
30#define MEM_PMIT_INIT_VAL 0x07c00000
31#define MEM_MB0CF_INIT_VAL 0x00082001
32#define MEM_MB1CF_INIT_VAL 0x04082000
33#define MEM_SDTR1_INIT_VAL 0x00854005
34#define SDRAM0_CFG_ENABLE 0x80000000
35
stroese842053a2004-12-16 18:17:50 +000036#define CFG_SDRAM_SIZE 0x04000000 /* 64 MB */
37
stroese842053a2004-12-16 18:17:50 +000038int board_early_init_f (void)
39{
40#if 0 /* test-only */
41 mtdcr (uicsr, 0xFFFFFFFF); /* clear all ints */
42 mtdcr (uicer, 0x00000000); /* disable all ints */
43 mtdcr (uiccr, 0x00000010);
44 mtdcr (uicpr, 0xFFFF7FF0); /* set int polarities */
45 mtdcr (uictr, 0x00000010); /* set int trigger levels */
46 mtdcr (uicsr, 0xFFFFFFFF); /* clear all ints */
47#else
48 mtdcr(uicsr, 0xFFFFFFFF); /* clear all ints */
49 mtdcr(uicer, 0x00000000); /* disable all ints */
50 mtdcr(uiccr, 0x00000000); /* set all to be non-critical*/
51 mtdcr(uicpr, 0xFFFFFFF0); /* set int polarities */
52 mtdcr(uictr, 0x10000000); /* set int trigger levels */
53 mtdcr(uicvcr, 0x00000001); /* set vect base=0,INT0 highest priority*/
54 mtdcr(uicsr, 0xFFFFFFFF); /* clear all ints */
55#endif
56
57#if 1 /* test-only */
58 /*
59 * EBC Configuration Register: set ready timeout to 512 ebc-clks -> ca. 15 us
60 */
61 mtebc (epcr, 0xa8400000); /* ebc always driven */
62#endif
63
64 return 0;
65}
66
67
68int misc_init_f (void)
69{
70 return 0; /* dummy implementation */
71}
72
73
74int misc_init_r (void)
75{
Jon Loeliger96892a92007-07-09 18:31:28 -050076#if defined(CONFIG_CMD_NAND)
stroese842053a2004-12-16 18:17:50 +000077 /*
78 * Set NAND-FLASH GPIO signals to default
79 */
80 out32(GPIO0_OR, in32(GPIO0_OR) & ~(CFG_NAND_CLE | CFG_NAND_ALE));
81 out32(GPIO0_OR, in32(GPIO0_OR) | CFG_NAND_CE);
82#endif
83
84 return (0);
85}
86
87
88/*
89 * Check Board Identity:
90 */
91int checkboard (void)
92{
Wolfgang Denk7fb52662005-10-13 16:45:02 +020093 char str[64];
stroese842053a2004-12-16 18:17:50 +000094 int i = getenv_r ("serial#", str, sizeof(str));
95
96 puts ("Board: ");
97
98 if (i == -1) {
99 puts ("### No HW ID - assuming G2000");
100 } else {
101 puts(str);
102 }
103
104 putc ('\n');
105
106 return 0;
107}
108
109
110/* -------------------------------------------------------------------------
111 G2000 rev B is an embeded design. we don't read for spd of this version.
112 Doing static SDRAM controller configuration in the following section.
113 ------------------------------------------------------------------------- */
114
115long int init_sdram_static_settings(void)
116{
117#define mtsdram0(reg, data) mtdcr(memcfga,reg);mtdcr(memcfgd,data)
wdenk07d7e6b2004-12-16 21:44:03 +0000118 /* disable memcontroller so updates work */
119 mtsdram0( mem_mcopt1, MEM_MCOPT1_INIT_VAL );
120 mtsdram0( mem_rtr , MEM_RTR_INIT_VAL );
121 mtsdram0( mem_pmit , MEM_PMIT_INIT_VAL );
122 mtsdram0( mem_mb0cf , MEM_MB0CF_INIT_VAL );
123 mtsdram0( mem_mb1cf , MEM_MB1CF_INIT_VAL );
124 mtsdram0( mem_sdtr1 , MEM_SDTR1_INIT_VAL );
stroese842053a2004-12-16 18:17:50 +0000125
wdenk07d7e6b2004-12-16 21:44:03 +0000126 /* SDRAM have a power on delay, 500 micro should do */
127 udelay(500);
128 mtsdram0( mem_mcopt1, MEM_MCOPT1_INIT_VAL|SDRAM0_CFG_ENABLE );
stroese842053a2004-12-16 18:17:50 +0000129
wdenk07d7e6b2004-12-16 21:44:03 +0000130 return (CFG_SDRAM_SIZE); /* CFG_SDRAM_SIZE is in G2000.h */
stroese842053a2004-12-16 18:17:50 +0000131 }
132
133
Becky Brucebd99ae72008-06-09 16:03:40 -0500134phys_size_t initdram (int board_type)
stroese842053a2004-12-16 18:17:50 +0000135{
136 long int ret;
137
138/* flzt, we can still turn this on in the future */
139/* #ifdef CONFIG_SPD_EEPROM
wdenk07d7e6b2004-12-16 21:44:03 +0000140 ret = spd_sdram ();
stroese842053a2004-12-16 18:17:50 +0000141#else
wdenk07d7e6b2004-12-16 21:44:03 +0000142 ret = init_sdram_static_settings();
stroese842053a2004-12-16 18:17:50 +0000143#endif
144*/
145
146 ret = init_sdram_static_settings();
147
148 return ret;
149}
150
151
Jon Loeliger96892a92007-07-09 18:31:28 -0500152#if defined(CONFIG_CMD_NAND)
Bartlomiej Sieka582f1a32006-03-05 18:57:33 +0100153#include <linux/mtd/nand_legacy.h>
stroese842053a2004-12-16 18:17:50 +0000154extern struct nand_chip nand_dev_desc[CFG_MAX_NAND_DEVICE];
155
156void nand_init(void)
157{
158 nand_probe(CFG_NAND_BASE);
159 if (nand_dev_desc[0].ChipID != NAND_ChipID_UNKNOWN) {
160 print_size(nand_dev_desc[0].totlen, "\n");
161 }
162}
163#endif
164
165
166#if 0 /* test-only !!! */
167int do_dumpebc(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
168{
169 ulong ap, cr;
170
171 printf("\nEBC registers for PPC405GP:\n");
172 mfebc(pb0ap, ap); mfebc(pb0cr, cr);
173 printf("0: AP=%08lx CP=%08lx\n", ap, cr);
174 mfebc(pb1ap, ap); mfebc(pb1cr, cr);
175 printf("1: AP=%08lx CP=%08lx\n", ap, cr);
176 mfebc(pb2ap, ap); mfebc(pb2cr, cr);
177 printf("2: AP=%08lx CP=%08lx\n", ap, cr);
178 mfebc(pb3ap, ap); mfebc(pb3cr, cr);
179 printf("3: AP=%08lx CP=%08lx\n", ap, cr);
180 mfebc(pb4ap, ap); mfebc(pb4cr, cr);
181 printf("4: AP=%08lx CP=%08lx\n", ap, cr);
182 printf("\n");
183
184 return 0;
185}
186U_BOOT_CMD(
187 dumpebc, 1, 1, do_dumpebc,
188 "dumpebc - Dump all EBC registers\n",
189 NULL
190);
191
192
193int do_dumpdcr(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
194{
195 int i;
196
197 printf("\nDevice Configuration Registers (DCR's) for PPC405GP:");
198 for (i=0; i<=0x1e0; i++) {
199 if (!(i % 0x8)) {
200 printf("\n%04x ", i);
201 }
202 printf("%08lx ", get_dcr(i));
203 }
204 printf("\n");
205
206 return 0;
207}
208U_BOOT_CMD(
209 dumpdcr, 1, 1, do_dumpdcr,
210 "dumpdcr - Dump all DCR registers\n",
211 NULL
212);
213
214
215int do_dumpspr(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
216{
217 printf("\nSpecial Purpose Registers (SPR's) for PPC405GP:");
218 printf("\n%04x %08x ", 947, mfspr(947));
219 printf("\n%04x %08x ", 9, mfspr(9));
220 printf("\n%04x %08x ", 1014, mfspr(1014));
221 printf("\n%04x %08x ", 1015, mfspr(1015));
222 printf("\n%04x %08x ", 1010, mfspr(1010));
223 printf("\n%04x %08x ", 957, mfspr(957));
224 printf("\n%04x %08x ", 1008, mfspr(1008));
225 printf("\n%04x %08x ", 1018, mfspr(1018));
226 printf("\n%04x %08x ", 954, mfspr(954));
227 printf("\n%04x %08x ", 950, mfspr(950));
228 printf("\n%04x %08x ", 951, mfspr(951));
229 printf("\n%04x %08x ", 981, mfspr(981));
230 printf("\n%04x %08x ", 980, mfspr(980));
231 printf("\n%04x %08x ", 982, mfspr(982));
232 printf("\n%04x %08x ", 1012, mfspr(1012));
233 printf("\n%04x %08x ", 1013, mfspr(1013));
234 printf("\n%04x %08x ", 948, mfspr(948));
235 printf("\n%04x %08x ", 949, mfspr(949));
236 printf("\n%04x %08x ", 1019, mfspr(1019));
237 printf("\n%04x %08x ", 979, mfspr(979));
238 printf("\n%04x %08x ", 8, mfspr(8));
239 printf("\n%04x %08x ", 945, mfspr(945));
240 printf("\n%04x %08x ", 987, mfspr(987));
241 printf("\n%04x %08x ", 287, mfspr(287));
242 printf("\n%04x %08x ", 953, mfspr(953));
243 printf("\n%04x %08x ", 955, mfspr(955));
244 printf("\n%04x %08x ", 272, mfspr(272));
245 printf("\n%04x %08x ", 273, mfspr(273));
246 printf("\n%04x %08x ", 274, mfspr(274));
247 printf("\n%04x %08x ", 275, mfspr(275));
248 printf("\n%04x %08x ", 260, mfspr(260));
249 printf("\n%04x %08x ", 276, mfspr(276));
250 printf("\n%04x %08x ", 261, mfspr(261));
251 printf("\n%04x %08x ", 277, mfspr(277));
252 printf("\n%04x %08x ", 262, mfspr(262));
253 printf("\n%04x %08x ", 278, mfspr(278));
254 printf("\n%04x %08x ", 263, mfspr(263));
255 printf("\n%04x %08x ", 279, mfspr(279));
256 printf("\n%04x %08x ", 26, mfspr(26));
257 printf("\n%04x %08x ", 27, mfspr(27));
258 printf("\n%04x %08x ", 990, mfspr(990));
259 printf("\n%04x %08x ", 991, mfspr(991));
260 printf("\n%04x %08x ", 956, mfspr(956));
261 printf("\n%04x %08x ", 284, mfspr(284));
262 printf("\n%04x %08x ", 285, mfspr(285));
263 printf("\n%04x %08x ", 986, mfspr(986));
264 printf("\n%04x %08x ", 984, mfspr(984));
265 printf("\n%04x %08x ", 256, mfspr(256));
266 printf("\n%04x %08x ", 1, mfspr(1));
267 printf("\n%04x %08x ", 944, mfspr(944));
268 printf("\n");
269
270 return 0;
271}
272U_BOOT_CMD(
273 dumpspr, 1, 1, do_dumpspr,
274 "dumpspr - Dump all SPR registers\n",
275 NULL
276);
277#endif