blob: a64f946ab4acab29cfcad81eef1eabd018719815 [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 *
Wolfgang Denkd79de1d2013-07-08 09:37:19 +02005 * SPDX-License-Identifier: GPL-2.0+
stroese842053a2004-12-16 18:17:50 +00006 */
7
8#include <common.h>
9#include <asm/processor.h>
10#include <command.h>
11
stroese842053a2004-12-16 18:17:50 +000012#define MEM_MCOPT1_INIT_VAL 0x00800000
13#define MEM_RTR_INIT_VAL 0x04070000
14#define MEM_PMIT_INIT_VAL 0x07c00000
15#define MEM_MB0CF_INIT_VAL 0x00082001
16#define MEM_MB1CF_INIT_VAL 0x04082000
17#define MEM_SDTR1_INIT_VAL 0x00854005
18#define SDRAM0_CFG_ENABLE 0x80000000
19
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +020020#define CONFIG_SYS_SDRAM_SIZE 0x04000000 /* 64 MB */
stroese842053a2004-12-16 18:17:50 +000021
stroese842053a2004-12-16 18:17:50 +000022int board_early_init_f (void)
23{
24#if 0 /* test-only */
Stefan Roese707fd362009-09-24 09:55:50 +020025 mtdcr (UIC0SR, 0xFFFFFFFF); /* clear all ints */
26 mtdcr (UIC0ER, 0x00000000); /* disable all ints */
27 mtdcr (UIC0CR, 0x00000010);
28 mtdcr (UIC0PR, 0xFFFF7FF0); /* set int polarities */
29 mtdcr (UIC0TR, 0x00000010); /* set int trigger levels */
30 mtdcr (UIC0SR, 0xFFFFFFFF); /* clear all ints */
stroese842053a2004-12-16 18:17:50 +000031#else
Stefan Roese707fd362009-09-24 09:55:50 +020032 mtdcr(UIC0SR, 0xFFFFFFFF); /* clear all ints */
33 mtdcr(UIC0ER, 0x00000000); /* disable all ints */
34 mtdcr(UIC0CR, 0x00000000); /* set all to be non-critical*/
35 mtdcr(UIC0PR, 0xFFFFFFF0); /* set int polarities */
36 mtdcr(UIC0TR, 0x10000000); /* set int trigger levels */
37 mtdcr(UIC0VCR, 0x00000001); /* set vect base=0,INT0 highest priority*/
38 mtdcr(UIC0SR, 0xFFFFFFFF); /* clear all ints */
stroese842053a2004-12-16 18:17:50 +000039#endif
40
41#if 1 /* test-only */
42 /*
43 * EBC Configuration Register: set ready timeout to 512 ebc-clks -> ca. 15 us
44 */
Stefan Roese918010a2009-09-09 16:25:29 +020045 mtebc (EBC0_CFG, 0xa8400000); /* ebc always driven */
stroese842053a2004-12-16 18:17:50 +000046#endif
47
48 return 0;
49}
50
51
52int misc_init_f (void)
53{
54 return 0; /* dummy implementation */
55}
56
57
58int misc_init_r (void)
59{
Jon Loeliger96892a92007-07-09 18:31:28 -050060#if defined(CONFIG_CMD_NAND)
stroese842053a2004-12-16 18:17:50 +000061 /*
62 * Set NAND-FLASH GPIO signals to default
63 */
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +020064 out32(GPIO0_OR, in32(GPIO0_OR) & ~(CONFIG_SYS_NAND_CLE | CONFIG_SYS_NAND_ALE));
65 out32(GPIO0_OR, in32(GPIO0_OR) | CONFIG_SYS_NAND_CE);
stroese842053a2004-12-16 18:17:50 +000066#endif
67
68 return (0);
69}
70
71
72/*
73 * Check Board Identity:
74 */
75int checkboard (void)
76{
Wolfgang Denk7fb52662005-10-13 16:45:02 +020077 char str[64];
Wolfgang Denk76af2782010-07-24 21:55:43 +020078 int i = getenv_f("serial#", str, sizeof(str));
stroese842053a2004-12-16 18:17:50 +000079
80 puts ("Board: ");
81
82 if (i == -1) {
83 puts ("### No HW ID - assuming G2000");
84 } else {
85 puts(str);
86 }
87
88 putc ('\n');
89
90 return 0;
91}
92
93
94/* -------------------------------------------------------------------------
95 G2000 rev B is an embeded design. we don't read for spd of this version.
96 Doing static SDRAM controller configuration in the following section.
97 ------------------------------------------------------------------------- */
98
99long int init_sdram_static_settings(void)
100{
wdenk07d7e6b2004-12-16 21:44:03 +0000101 /* disable memcontroller so updates work */
Stefan Roese8f9cdda2009-09-24 14:10:30 +0200102 mtsdram(SDRAM0_CFG, MEM_MCOPT1_INIT_VAL);
103 mtsdram(SDRAM0_RTR, MEM_RTR_INIT_VAL);
104 mtsdram(SDRAM0_PMIT, MEM_PMIT_INIT_VAL);
105 mtsdram(SDRAM0_B0CR, MEM_MB0CF_INIT_VAL);
106 mtsdram(SDRAM0_B1CR, MEM_MB1CF_INIT_VAL);
107 mtsdram(SDRAM0_TR, MEM_SDTR1_INIT_VAL);
stroese842053a2004-12-16 18:17:50 +0000108
wdenk07d7e6b2004-12-16 21:44:03 +0000109 /* SDRAM have a power on delay, 500 micro should do */
110 udelay(500);
Stefan Roese8f9cdda2009-09-24 14:10:30 +0200111 mtsdram(SDRAM0_CFG, MEM_MCOPT1_INIT_VAL|SDRAM0_CFG_ENABLE);
stroese842053a2004-12-16 18:17:50 +0000112
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +0200113 return (CONFIG_SYS_SDRAM_SIZE); /* CONFIG_SYS_SDRAM_SIZE is in G2000.h */
stroese842053a2004-12-16 18:17:50 +0000114 }
115
116
Becky Brucebd99ae72008-06-09 16:03:40 -0500117phys_size_t initdram (int board_type)
stroese842053a2004-12-16 18:17:50 +0000118{
119 long int ret;
120
121/* flzt, we can still turn this on in the future */
122/* #ifdef CONFIG_SPD_EEPROM
wdenk07d7e6b2004-12-16 21:44:03 +0000123 ret = spd_sdram ();
stroese842053a2004-12-16 18:17:50 +0000124#else
wdenk07d7e6b2004-12-16 21:44:03 +0000125 ret = init_sdram_static_settings();
stroese842053a2004-12-16 18:17:50 +0000126#endif
127*/
128
129 ret = init_sdram_static_settings();
130
131 return ret;
132}
133
stroese842053a2004-12-16 18:17:50 +0000134#if 0 /* test-only !!! */
Wolfgang Denk6262d0212010-06-28 22:00:46 +0200135int do_dumpebc(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
stroese842053a2004-12-16 18:17:50 +0000136{
137 ulong ap, cr;
138
139 printf("\nEBC registers for PPC405GP:\n");
Stefan Roese918010a2009-09-09 16:25:29 +0200140 mfebc(PB0AP, ap); mfebc(PB0CR, cr);
stroese842053a2004-12-16 18:17:50 +0000141 printf("0: AP=%08lx CP=%08lx\n", ap, cr);
Stefan Roese918010a2009-09-09 16:25:29 +0200142 mfebc(PB1AP, ap); mfebc(PB1CR, cr);
stroese842053a2004-12-16 18:17:50 +0000143 printf("1: AP=%08lx CP=%08lx\n", ap, cr);
Stefan Roese918010a2009-09-09 16:25:29 +0200144 mfebc(PB2AP, ap); mfebc(PB2CR, cr);
stroese842053a2004-12-16 18:17:50 +0000145 printf("2: AP=%08lx CP=%08lx\n", ap, cr);
Stefan Roese918010a2009-09-09 16:25:29 +0200146 mfebc(PB3AP, ap); mfebc(PB3CR, cr);
stroese842053a2004-12-16 18:17:50 +0000147 printf("3: AP=%08lx CP=%08lx\n", ap, cr);
Stefan Roese918010a2009-09-09 16:25:29 +0200148 mfebc(PB4AP, ap); mfebc(PB4CR, cr);
stroese842053a2004-12-16 18:17:50 +0000149 printf("4: AP=%08lx CP=%08lx\n", ap, cr);
150 printf("\n");
151
152 return 0;
153}
154U_BOOT_CMD(
155 dumpebc, 1, 1, do_dumpebc,
Peter Tyserdfb72b82009-01-27 18:03:12 -0600156 "Dump all EBC registers",
Wolfgang Denkc54781c2009-05-24 17:06:54 +0200157 ""
stroese842053a2004-12-16 18:17:50 +0000158);
159
160
Wolfgang Denk6262d0212010-06-28 22:00:46 +0200161int do_dumpdcr(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
stroese842053a2004-12-16 18:17:50 +0000162{
163 int i;
164
165 printf("\nDevice Configuration Registers (DCR's) for PPC405GP:");
166 for (i=0; i<=0x1e0; i++) {
167 if (!(i % 0x8)) {
168 printf("\n%04x ", i);
169 }
170 printf("%08lx ", get_dcr(i));
171 }
172 printf("\n");
173
174 return 0;
175}
176U_BOOT_CMD(
177 dumpdcr, 1, 1, do_dumpdcr,
Peter Tyserdfb72b82009-01-27 18:03:12 -0600178 "Dump all DCR registers",
Wolfgang Denkc54781c2009-05-24 17:06:54 +0200179 ""
stroese842053a2004-12-16 18:17:50 +0000180);
181
182
Wolfgang Denk6262d0212010-06-28 22:00:46 +0200183int do_dumpspr(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
stroese842053a2004-12-16 18:17:50 +0000184{
185 printf("\nSpecial Purpose Registers (SPR's) for PPC405GP:");
186 printf("\n%04x %08x ", 947, mfspr(947));
187 printf("\n%04x %08x ", 9, mfspr(9));
188 printf("\n%04x %08x ", 1014, mfspr(1014));
189 printf("\n%04x %08x ", 1015, mfspr(1015));
190 printf("\n%04x %08x ", 1010, mfspr(1010));
191 printf("\n%04x %08x ", 957, mfspr(957));
192 printf("\n%04x %08x ", 1008, mfspr(1008));
193 printf("\n%04x %08x ", 1018, mfspr(1018));
194 printf("\n%04x %08x ", 954, mfspr(954));
195 printf("\n%04x %08x ", 950, mfspr(950));
196 printf("\n%04x %08x ", 951, mfspr(951));
197 printf("\n%04x %08x ", 981, mfspr(981));
198 printf("\n%04x %08x ", 980, mfspr(980));
199 printf("\n%04x %08x ", 982, mfspr(982));
200 printf("\n%04x %08x ", 1012, mfspr(1012));
201 printf("\n%04x %08x ", 1013, mfspr(1013));
202 printf("\n%04x %08x ", 948, mfspr(948));
203 printf("\n%04x %08x ", 949, mfspr(949));
204 printf("\n%04x %08x ", 1019, mfspr(1019));
205 printf("\n%04x %08x ", 979, mfspr(979));
206 printf("\n%04x %08x ", 8, mfspr(8));
207 printf("\n%04x %08x ", 945, mfspr(945));
208 printf("\n%04x %08x ", 987, mfspr(987));
209 printf("\n%04x %08x ", 287, mfspr(287));
210 printf("\n%04x %08x ", 953, mfspr(953));
211 printf("\n%04x %08x ", 955, mfspr(955));
212 printf("\n%04x %08x ", 272, mfspr(272));
213 printf("\n%04x %08x ", 273, mfspr(273));
214 printf("\n%04x %08x ", 274, mfspr(274));
215 printf("\n%04x %08x ", 275, mfspr(275));
216 printf("\n%04x %08x ", 260, mfspr(260));
217 printf("\n%04x %08x ", 276, mfspr(276));
218 printf("\n%04x %08x ", 261, mfspr(261));
219 printf("\n%04x %08x ", 277, mfspr(277));
220 printf("\n%04x %08x ", 262, mfspr(262));
221 printf("\n%04x %08x ", 278, mfspr(278));
222 printf("\n%04x %08x ", 263, mfspr(263));
223 printf("\n%04x %08x ", 279, mfspr(279));
224 printf("\n%04x %08x ", 26, mfspr(26));
225 printf("\n%04x %08x ", 27, mfspr(27));
226 printf("\n%04x %08x ", 990, mfspr(990));
227 printf("\n%04x %08x ", 991, mfspr(991));
228 printf("\n%04x %08x ", 956, mfspr(956));
229 printf("\n%04x %08x ", 284, mfspr(284));
230 printf("\n%04x %08x ", 285, mfspr(285));
231 printf("\n%04x %08x ", 986, mfspr(986));
232 printf("\n%04x %08x ", 984, mfspr(984));
233 printf("\n%04x %08x ", 256, mfspr(256));
234 printf("\n%04x %08x ", 1, mfspr(1));
235 printf("\n%04x %08x ", 944, mfspr(944));
236 printf("\n");
237
238 return 0;
239}
240U_BOOT_CMD(
241 dumpspr, 1, 1, do_dumpspr,
Peter Tyserdfb72b82009-01-27 18:03:12 -0600242 "Dump all SPR registers",
Wolfgang Denkc54781c2009-05-24 17:06:54 +0200243 ""
stroese842053a2004-12-16 18:17:50 +0000244);
245#endif