1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30#include <common.h>
31#include <ioports.h>
32#include <mpc8260.h>
33#include <asm/io.h>
34
35
36
37
38
39
40
41
42#define CONFIG_SYS_FCC1 (CONFIG_ETHER_INDEX == 1)
43#define CONFIG_SYS_FCC2 (CONFIG_ETHER_INDEX == 2)
44#define CONFIG_SYS_FCC3 (CONFIG_ETHER_INDEX == 3)
45
46const iop_conf_t iop_conf_tab[4][32] = {
47
48 {
49 { CONFIG_SYS_FCC1, 1, 1, 0, 0, 0 },
50 { CONFIG_SYS_FCC1, 1, 1, 0, 0, 0 },
51 { CONFIG_SYS_FCC1, 1, 1, 1, 0, 0 },
52 { CONFIG_SYS_FCC1, 1, 1, 1, 0, 0 },
53 { CONFIG_SYS_FCC1, 1, 1, 0, 0, 0 },
54 { CONFIG_SYS_FCC1, 1, 1, 0, 0, 0 },
55 { 0, 0, 0, 0, 0, 0 },
56 { 0, 0, 0, 0, 0, 0 },
57 { 0, 0, 0, 0, 0, 0 },
58 { 0, 0, 0, 0, 0, 0 },
59 { CONFIG_SYS_FCC1, 1, 0, 1, 0, 0 },
60 { CONFIG_SYS_FCC1, 1, 0, 1, 0, 0 },
61 { CONFIG_SYS_FCC1, 1, 0, 1, 0, 0 },
62 { CONFIG_SYS_FCC1, 1, 0, 1, 0, 0 },
63 { CONFIG_SYS_FCC1, 1, 0, 0, 0, 0 },
64 { CONFIG_SYS_FCC1, 1, 0, 0, 0, 0 },
65 { CONFIG_SYS_FCC1, 1, 0, 0, 0, 0 },
66 { CONFIG_SYS_FCC1, 1, 0, 0, 0, 0 },
67 { 0, 0, 0, 0, 0, 0 },
68 { 0, 0, 0, 0, 0, 0 },
69 { 0, 0, 0, 0, 0, 0 },
70 { 0, 0, 0, 0, 0, 0 },
71 { 0, 1, 0, 1, 0, 0 },
72 { 0, 1, 0, 0, 0, 0 },
73 { 0, 0, 0, 0, 0, 0 },
74 { 0, 0, 0, 0, 0, 0 },
75 { 0, 0, 0, 0, 0, 0 },
76 { 0, 0, 0, 0, 0, 0 },
77 { 0, 0, 0, 0, 0, 0 },
78 { 0, 0, 0, 0, 0, 0 },
79 { 0, 0, 0, 0, 0, 0 },
80 { 0, 0, 0, 0, 0, 0 }
81 },
82
83
84 {
85 { CONFIG_SYS_FCC2, 1, 0, 1, 0, 0 },
86 { CONFIG_SYS_FCC2, 1, 0, 0, 0, 0 },
87 { CONFIG_SYS_FCC2, 1, 1, 1, 0, 0 },
88 { CONFIG_SYS_FCC2, 1, 0, 0, 0, 0 },
89 { CONFIG_SYS_FCC2, 1, 0, 0, 0, 0 },
90 { CONFIG_SYS_FCC2, 1, 0, 0, 0, 0 },
91 { CONFIG_SYS_FCC2, 1, 0, 1, 0, 0 },
92 { CONFIG_SYS_FCC2, 1, 0, 1, 0, 0 },
93 { CONFIG_SYS_FCC2, 1, 0, 1, 0, 0 },
94 { CONFIG_SYS_FCC2, 1, 0, 1, 0, 0 },
95 { CONFIG_SYS_FCC2, 1, 0, 0, 0, 0 },
96 { CONFIG_SYS_FCC2, 1, 0, 0, 0, 0 },
97 { CONFIG_SYS_FCC2, 1, 0, 0, 0, 0 },
98 { CONFIG_SYS_FCC2, 1, 0, 0, 0, 0 },
99 { CONFIG_SYS_FCC3, 1, 0, 0, 0, 0 },
100 { CONFIG_SYS_FCC3, 1, 0, 0, 0, 0 },
101 { CONFIG_SYS_FCC3, 1, 0, 1, 0, 0 },
102 { CONFIG_SYS_FCC3, 1, 0, 1, 0, 0 },
103 { CONFIG_SYS_FCC3, 1, 0, 0, 0, 0 },
104 { CONFIG_SYS_FCC3, 1, 0, 0, 0, 0 },
105 { CONFIG_SYS_FCC3, 1, 0, 0, 0, 0 },
106 { CONFIG_SYS_FCC3, 1, 0, 0, 0, 0 },
107 { CONFIG_SYS_FCC3, 1, 0, 0, 0, 0 },
108 { CONFIG_SYS_FCC3, 1, 0, 0, 0, 0 },
109 { CONFIG_SYS_FCC3, 1, 0, 1, 0, 0 },
110 { CONFIG_SYS_FCC3, 1, 0, 1, 0, 0 },
111 { CONFIG_SYS_FCC3, 1, 0, 1, 0, 0 },
112 { CONFIG_SYS_FCC3, 1, 0, 1, 0, 0 },
113 { 0, 0, 0, 0, 0, 0 },
114 { 0, 0, 0, 0, 0, 0 },
115 { 0, 0, 0, 0, 0, 0 },
116 { 0, 0, 0, 0, 0, 0 }
117 },
118
119
120 {
121 { 0, 0, 0, 0, 0, 0 },
122 { 0, 0, 0, 0, 0, 0 },
123 { 0, 0, 0, 0, 0, 0 },
124 { 0, 0, 0, 0, 0, 0 },
125 { 0, 0, 0, 0, 0, 0 },
126 { 0, 0, 0, 0, 0, 0 },
127 { 0, 0, 0, 0, 0, 0 },
128 { 0, 0, 0, 0, 0, 0 },
129 { 0, 0, 0, 0, 0, 0 },
130 { 0, 0, 0, 0, 0, 0 },
131 { 0, 0, 0, 0, 0, 0 },
132 { 0, 0, 0, 0, 0, 0 },
133 { 0, 0, 0, 0, 0, 0 },
134 { CONFIG_SYS_FCC3, 1, 0, 0, 0, 0 },
135 { 0, 0, 0, 0, 0, 0 },
136 { CONFIG_SYS_FCC3, 1, 0, 0, 0, 0 },
137 { 0, 0, 0, 0, 0, 0 },
138 { 0, 0, 0, 0, 0, 0 },
139 { 0, 0, 0, 0, 0, 0 },
140 { 0, 0, 0, 0, 0, 0 },
141 { 0, 0, 0, 0, 0, 0 },
142 { 0, 0, 0, 0, 0, 0 },
143 { 0, 0, 0, 0, 0, 0 },
144 { 0, 0, 0, 0, 0, 0 },
145 { 0, 0, 0, 0, 0, 0 },
146 { 0, 0, 0, 0, 0, 0 },
147 { 0, 0, 0, 0, 0, 0 },
148 { 0, 0, 0, 0, 0, 0 },
149 { 0, 0, 0, 0, 0, 0 },
150 { 0, 0, 0, 0, 0, 0 },
151 { 0, 0, 0, 0, 0, 0 },
152 { 0, 0, 0, 0, 0, 0 }
153 },
154
155
156 {
157 { 0, 0, 0, 0, 0, 0 },
158 { 0, 0, 0, 0, 0, 0 },
159 { 0, 0, 0, 0, 0, 0 },
160 { 0, 0, 0, 0, 0, 0 },
161 { 0, 0, 0, 0, 0, 0 },
162 { 0, 0, 0, 0, 0, 0 },
163 { 0, 0, 0, 0, 0, 0 },
164 { 0, 0, 0, 0, 0, 0 },
165 { 0, 0, 0, 0, 0, 0 },
166 { 0, 0, 0, 0, 0, 0 },
167 { 0, 0, 0, 0, 0, 0 },
168 { 0, 0, 0, 0, 0, 0 },
169 { 0, 0, 0, 0, 0, 0 },
170 { 0, 1, 1, 0, 0, 0 },
171 { 0, 1, 1, 0, 0, 0 },
172 { 0, 1, 1, 0, 0, 0 },
173 { 0, 1, 1, 0, 1, 0 },
174 { 0, 1, 1, 0, 1, 0 },
175 { 1, 0, 0, 0, 0, 0 },
176 { 1, 0, 0, 1, 0, 0 },
177 { 0, 0, 0, 0, 0, 0 },
178 { 0, 0, 0, 0, 0, 0 },
179 { 1, 1, 0, 1, 0, 0 },
180 { 1, 1, 0, 0, 0, 0 },
181 { 0, 0, 0, 0, 0, 0 },
182 { CONFIG_SYS_FCC3, 0, 0, 1, 0, 1 },
183 { CONFIG_SYS_FCC3, 0, 0, 1, 0, 0 },
184 { 0, 0, 0, 0, 0, 0 },
185 { 0, 0, 0, 0, 0, 0 },
186 { 0, 0, 0, 0, 0, 0 },
187 { 0, 0, 0, 0, 0, 0 },
188 { 0, 0, 0, 0, 0, 0 }
189 }
190};
191
192#define PSPAN_ADDR 0xF0020000
193#define EEPROM_REG 0x408
194#define EEPROM_READ_CMD 0xA000
195#define PSPAN_WRITE(a,v) \
196 *((volatile unsigned long *)(PSPAN_ADDR+(a))) = v; eieio()
197#define PSPAN_READ(a) \
198 *((volatile unsigned long *)(PSPAN_ADDR+(a)))
199
200static int seeprom_read (int addr, uchar * data, int size)
201{
202 ulong val, cmd;
203 int i;
204
205 for (i = 0; i < size; i++) {
206
207 cmd = EEPROM_READ_CMD;
208 cmd |= ((addr + i) << 24) & 0xff000000;
209
210
211 while ((val = PSPAN_READ (EEPROM_REG)) & 0x80)
212 eieio ();
213
214
215 PSPAN_WRITE (EEPROM_REG, cmd);
216
217
218 while ((val = PSPAN_READ (EEPROM_REG)) & 0x80)
219 eieio ();
220
221 while ((val = PSPAN_READ (EEPROM_REG)) & 0x80)
222 eieio ();
223
224
225 if (val & 0x00000040) {
226 return -1;
227 } else {
228 data[i] = (val >> 16) & 0xff;
229 }
230 }
231 return 0;
232}
233
234
235
236
237
238
239#ifdef DEBUG
240static int hwc_flash_size (void)
241{
242 uchar byte;
243
244 if (!seeprom_read (0x40, &byte, sizeof (byte))) {
245 switch ((byte >> 2) & 0x3) {
246 case 0x1:
247 return 0x0400000;
248 break;
249 case 0x2:
250 return 0x0800000;
251 break;
252 case 0x3:
253 return 0x1000000;
254 default:
255 return 0x0100000;
256 }
257 }
258 return -1;
259}
260
261static int hwc_local_sdram_size (void)
262{
263 uchar byte;
264
265 if (!seeprom_read (0x40, &byte, sizeof (byte))) {
266 switch ((byte & 0x03)) {
267 case 0x1:
268 return 0x0800000;
269 case 0x2:
270 return 0x1000000;
271 default:
272 return 0;
273 }
274 }
275 return -1;
276}
277#endif
278
279static int hwc_main_sdram_size (void)
280{
281 uchar byte;
282
283 if (!seeprom_read (0x41, &byte, sizeof (byte))) {
284 return 0x1000000 << ((byte >> 5) & 0x7);
285 }
286 return -1;
287}
288
289static int hwc_serial_number (void)
290{
291 int sn = -1;
292
293 if (!seeprom_read (0xa0, (uchar *) &sn, sizeof (sn))) {
294 sn = cpu_to_le32 (sn);
295 }
296 return sn;
297}
298
299static int hwc_mac_address (char *str)
300{
301 char mac[6];
302
303 if (!seeprom_read (0xb0, (uchar *)mac, sizeof (mac))) {
304 sprintf (str, "%02X:%02X:%02X:%02X:%02X:%02X",
305 mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]);
306 } else {
307 strcpy (str, "ERROR");
308 return -1;
309 }
310 return 0;
311}
312
313static int hwc_manufact_date (char *str)
314{
315 uchar byte;
316 int value;
317
318 if (seeprom_read (0x92, &byte, sizeof (byte)))
319 goto out;
320 value = byte;
321 if (seeprom_read (0x93, &byte, sizeof (byte)))
322 goto out;
323 value += byte << 8;
324 sprintf (str, "%02d/%02d/%04d",
325 value & 0x1F, (value >> 5) & 0xF,
326 1980 + ((value >> 9) & 0x1FF));
327 return 0;
328
329out:
330 strcpy (str, "ERROR");
331 return -1;
332}
333
334static int hwc_board_type (char **str)
335{
336 ushort id = 0;
337
338 if (seeprom_read (7, (uchar *) & id, sizeof (id)) == 0) {
339 switch (id) {
340 case 0x9080:
341 *str = "4532-002";
342 break;
343 case 0x9081:
344 *str = "4532-001";
345 break;
346 case 0x9082:
347 *str = "4532-000";
348 break;
349 default:
350 *str = "Unknown";
351 }
352 } else {
353 *str = "Unknown";
354 }
355
356 return id;
357}
358
359phys_size_t initdram (int board_type)
360{
361 long maxsize = hwc_main_sdram_size();
362
363#if !defined(CONFIG_SYS_RAMBOOT) && !defined(CONFIG_SYS_USE_FIRMWARE)
364 volatile immap_t *immap = (immap_t *) CONFIG_SYS_IMMR;
365 volatile memctl8260_t *memctl = &immap->im_memctl;
366 volatile uchar *base;
367 int i;
368
369 immap->im_siu_conf.sc_ppc_acr = 0x00000026;
370 immap->im_siu_conf.sc_ppc_alrh = 0x01276345;
371 immap->im_siu_conf.sc_ppc_alrl = 0x89ABCDEF;
372 immap->im_siu_conf.sc_lcl_acr = 0x00000000;
373 immap->im_siu_conf.sc_lcl_alrh = 0x01234567;
374 immap->im_siu_conf.sc_lcl_alrl = 0x89ABCDEF;
375 immap->im_siu_conf.sc_tescr1 = 0x00004000;
376 immap->im_siu_conf.sc_ltescr1 = 0x00004000;
377
378 memctl->memc_mptpr = CONFIG_SYS_MPTPR;
379
380
381 base = (uchar *)(CONFIG_SYS_SDRAM_BASE | 0x110);
382 memctl->memc_psrt = CONFIG_SYS_PSRT;
383 memctl->memc_or1 = CONFIG_SYS_60x_OR;
384 memctl->memc_br1 = CONFIG_SYS_SDRAM_BASE | CONFIG_SYS_60x_BR;
385
386 memctl->memc_psdmr = CONFIG_SYS_PSDMR | 0x28000000;
387 *base = 0xFF;
388 memctl->memc_psdmr = CONFIG_SYS_PSDMR | 0x08000000;
389 for (i = 0; i < 8; i++)
390 *base = 0xFF;
391 memctl->memc_psdmr = CONFIG_SYS_PSDMR | 0x18000000;
392 *base = 0xFF;
393 memctl->memc_psdmr = CONFIG_SYS_PSDMR | 0x40000000;
394
395
396 base = (uchar *)CONFIG_SYS_LSDRAM_BASE;
397 memctl->memc_lsrt = CONFIG_SYS_LSRT;
398 memctl->memc_or2 = CONFIG_SYS_LOC_OR;
399 memctl->memc_br2 = CONFIG_SYS_LSDRAM_BASE | CONFIG_SYS_LOC_BR;
400
401 memctl->memc_lsdmr = CONFIG_SYS_LSDMR | 0x28000000;
402 *base = 0xFF;
403 memctl->memc_lsdmr = CONFIG_SYS_LSDMR | 0x08000000;
404 for (i = 0; i < 8; i++)
405 *base = 0xFF;
406 memctl->memc_lsdmr = CONFIG_SYS_LSDMR | 0x18000000;
407 *base = 0xFF;
408 memctl->memc_lsdmr = CONFIG_SYS_LSDMR | 0x40000000;
409
410
411
412
413
414
415 maxsize = (~(memctl->memc_or1 & BRx_BA_MSK) + 1) / 2;
416
417 maxsize = get_ram_size((long *)(memctl->memc_br1 & BRx_BA_MSK), maxsize);
418
419 memctl->memc_or1 |= ~(maxsize - 1);
420
421 if (maxsize != hwc_main_sdram_size())
422 puts("Oops: memory test has not found all memory!\n");
423#endif
424
425
426 return maxsize;
427}
428
429int checkboard(void)
430{
431 char string[32], *id;
432
433 hwc_manufact_date(string);
434 hwc_board_type(&id);
435 printf("Board: Interphase iSPAN %s (#%d %s)\n",
436 id, hwc_serial_number(), string);
437#ifdef DEBUG
438 printf("Manufacturing date: %s\n", string);
439 printf("Serial number : %d\n", hwc_serial_number());
440 printf("FLASH size : %d MB\n", hwc_flash_size() >> 20);
441 printf("Main SDRAM size : %d MB\n", hwc_main_sdram_size() >> 20);
442 printf("Local SDRAM size : %d MB\n", hwc_local_sdram_size() >> 20);
443 hwc_mac_address(string);
444 printf("MAC address : %s\n", string);
445#endif
446 return 0;
447}
448
449int misc_init_r(void)
450{
451 char *s, str[32];
452 int num;
453
454 if ((s = getenv("serial#")) == NULL &&
455 (num = hwc_serial_number()) != -1) {
456 sprintf(str, "%06d", num);
457 setenv("serial#", str);
458 }
459 if ((s = getenv("ethaddr")) == NULL && hwc_mac_address(str) == 0) {
460 setenv("ethaddr", str);
461 }
462
463 return 0;
464}
465