]>
Commit | Line | Data |
---|---|---|
c609719b WD |
1 | /* |
2 | * (C) Copyright 2001 | |
3 | * Denis Peter, MPL AG Switzerland, d.peter@mpl.ch | |
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 | ||
25 | #include <common.h> | |
26 | #include <command.h> | |
27 | #include <video_fb.h> | |
28 | #include "common_util.h" | |
29 | #include <asm/processor.h> | |
1cb8e980 | 30 | #include <asm/byteorder.h> |
c609719b WD |
31 | #include <i2c.h> |
32 | #include <devices.h> | |
33 | #include <pci.h> | |
a2663ea4 WD |
34 | #include <malloc.h> |
35 | #include <bzlib.h> | |
c609719b | 36 | |
33149b88 WD |
37 | #ifdef CONFIG_PIP405 |
38 | #include "../pip405/pip405.h" | |
3048bcbf | 39 | #include <asm/4xx_pci.h> |
33149b88 WD |
40 | #endif |
41 | #ifdef CONFIG_MIP405 | |
42 | #include "../mip405/mip405.h" | |
3048bcbf | 43 | #include <asm/4xx_pci.h> |
33149b88 | 44 | #endif |
d87080b7 WD |
45 | |
46 | DECLARE_GLOBAL_DATA_PTR; | |
47 | ||
b6e4c403 WD |
48 | #if defined(CONFIG_PATI) |
49 | #define FIRM_START 0xFFF00000 | |
50 | #endif | |
33149b88 | 51 | |
eedcd078 | 52 | extern int gunzip(void *, int, uchar *, unsigned long *); |
a2663ea4 | 53 | extern int mem_test(ulong start, ulong ramsize, int quiet); |
c609719b | 54 | |
a2663ea4 WD |
55 | #define I2C_BACKUP_ADDR 0x7C00 /* 0x200 bytes for backup */ |
56 | #define IMAGE_SIZE CFG_MONITOR_LEN /* ugly, but it works for now */ | |
c609719b WD |
57 | |
58 | extern flash_info_t flash_info[]; /* info for FLASH chips */ | |
59 | ||
d4ca31c4 | 60 | static int |
a2663ea4 | 61 | mpl_prg(uchar *src, ulong size) |
c609719b | 62 | { |
a2663ea4 | 63 | ulong start; |
c609719b | 64 | flash_info_t *info; |
a2663ea4 | 65 | int i, rc; |
b6e4c403 WD |
66 | #if defined(CONFIG_PATI) |
67 | int start_sect; | |
68 | #endif | |
69 | #if defined(CONFIG_PIP405) || defined(CONFIG_MIP405) || defined(CONFIG_PATI) | |
f3e0de60 | 70 | char *copystr = (char *)src; |
a2663ea4 | 71 | ulong *magic = (ulong *)src; |
06d01dbe | 72 | #endif |
c609719b WD |
73 | |
74 | info = &flash_info[0]; | |
1cb8e980 | 75 | |
b6e4c403 | 76 | #if defined(CONFIG_PIP405) || defined(CONFIG_MIP405) || defined(CONFIG_PATI) |
b97a2a0a | 77 | if (image_to_cpu (magic[0]) != IH_MAGIC) { |
a2663ea4 | 78 | puts("Bad Magic number\n"); |
1cb8e980 WD |
79 | return -1; |
80 | } | |
f3e0de60 WD |
81 | /* some more checks before we delete the Flash... */ |
82 | /* Checking the ISO_STRING prevents to program a | |
83 | * wrong Firmware Image into the flash. | |
84 | */ | |
a2663ea4 WD |
85 | i = 4; /* skip Magic number */ |
86 | while (1) { | |
87 | if (strncmp(©str[i], "MEV-", 4) == 0) | |
f3e0de60 | 88 | break; |
a2663ea4 WD |
89 | if (i++ >= 0x100) { |
90 | puts("Firmware Image for unknown Target\n"); | |
f3e0de60 WD |
91 | return -1; |
92 | } | |
93 | } | |
94 | /* we have the ISO STRING, check */ | |
a2663ea4 WD |
95 | if (strncmp(©str[i], CONFIG_ISO_STRING, sizeof(CONFIG_ISO_STRING)-1) != 0) { |
96 | printf("Wrong Firmware Image: %s\n", ©str[i]); | |
f3e0de60 WD |
97 | return -1; |
98 | } | |
b6e4c403 | 99 | #if !defined(CONFIG_PATI) |
f3e0de60 | 100 | start = 0 - size; |
a2663ea4 | 101 | for (i = info->sector_count-1; i > 0; i--) { |
c609719b | 102 | info->protect[i] = 0; /* unprotect this sector */ |
a2663ea4 WD |
103 | if (start >= info->start[i]) |
104 | break; | |
c609719b WD |
105 | } |
106 | /* set-up flash location */ | |
107 | /* now erase flash */ | |
c609719b WD |
108 | printf("Erasing at %lx (sector %d) (start %lx)\n", |
109 | start,i,info->start[i]); | |
a2663ea4 WD |
110 | if ((rc = flash_erase (info, i, info->sector_count-1)) != 0) { |
111 | puts("ERROR "); | |
112 | flash_perror(rc); | |
113 | return (1); | |
114 | } | |
1cb8e980 | 115 | |
b6e4c403 WD |
116 | #else /* #if !defined(CONFIG_PATI */ |
117 | start = FIRM_START; | |
118 | start_sect = -1; | |
119 | for (i = 0; i < info->sector_count; i++) { | |
120 | if (start < info->start[i]) { | |
121 | start_sect = i - 1; | |
122 | break; | |
123 | } | |
124 | } | |
125 | ||
126 | info->protect[i - 1] = 0; /* unprotect this sector */ | |
127 | for (; i < info->sector_count; i++) { | |
128 | if ((start + size) < info->start[i]) | |
129 | break; | |
130 | info->protect[i] = 0; /* unprotect this sector */ | |
131 | } | |
132 | ||
133 | i--; | |
134 | /* set-up flash location */ | |
135 | /* now erase flash */ | |
136 | printf ("Erasing at %lx to %lx (sector %d to %d) (%lx to %lx)\n", | |
137 | start, start + size, start_sect, i, | |
138 | info->start[start_sect], info->start[i]); | |
139 | if ((rc = flash_erase (info, start_sect, i)) != 0) { | |
140 | puts ("ERROR "); | |
141 | flash_perror (rc); | |
142 | return (1); | |
143 | } | |
144 | #endif /* defined(CONFIG_PATI) */ | |
145 | ||
1cb8e980 WD |
146 | #elif defined(CONFIG_VCMA9) |
147 | start = 0; | |
a2663ea4 | 148 | for (i = 0; i <info->sector_count; i++) { |
1cb8e980 WD |
149 | info->protect[i] = 0; /* unprotect this sector */ |
150 | if (size < info->start[i]) | |
151 | break; | |
152 | } | |
153 | /* set-up flash location */ | |
154 | /* now erase flash */ | |
155 | printf("Erasing at %lx (sector %d) (start %lx)\n", | |
156 | start,0,info->start[0]); | |
a2663ea4 WD |
157 | if ((rc = flash_erase (info, 0, i)) != 0) { |
158 | puts("ERROR "); | |
159 | flash_perror(rc); | |
160 | return (1); | |
161 | } | |
1cb8e980 WD |
162 | |
163 | #endif | |
d4ca31c4 WD |
164 | printf("flash erased, programming from 0x%lx 0x%lx Bytes\n", |
165 | (ulong)src, size); | |
77ddac94 | 166 | if ((rc = flash_write ((char *)src, start, size)) != 0) { |
a2663ea4 WD |
167 | puts("ERROR "); |
168 | flash_perror(rc); | |
c609719b WD |
169 | return (1); |
170 | } | |
a2663ea4 | 171 | puts("OK programming done\n"); |
c609719b WD |
172 | return 0; |
173 | } | |
174 | ||
175 | ||
d4ca31c4 | 176 | static int |
a2663ea4 | 177 | mpl_prg_image(uchar *ld_addr) |
c609719b | 178 | { |
b97a2a0a | 179 | unsigned long len; |
a2663ea4 | 180 | uchar *data; |
b97a2a0a | 181 | image_header_t *hdr = (image_header_t *)ld_addr; |
a2663ea4 | 182 | int rc; |
d4ca31c4 | 183 | |
b97a2a0a | 184 | if (!image_check_magic (hdr)) { |
a2663ea4 | 185 | puts("Bad Magic Number\n"); |
c609719b WD |
186 | return 1; |
187 | } | |
2242f536 | 188 | image_print_contents (hdr); |
b97a2a0a | 189 | if (!image_check_os (hdr, IH_OS_U_BOOT)) { |
a2663ea4 | 190 | puts("No U-Boot Image\n"); |
c609719b WD |
191 | return 1; |
192 | } | |
b97a2a0a | 193 | if (!image_check_type (hdr, IH_TYPE_FIRMWARE)) { |
a2663ea4 | 194 | puts("No Firmware Image\n"); |
c609719b WD |
195 | return 1; |
196 | } | |
b97a2a0a | 197 | if (!image_check_hcrc (hdr)) { |
a2663ea4 | 198 | puts("Bad Header Checksum\n"); |
c609719b WD |
199 | return 1; |
200 | } | |
a2663ea4 | 201 | puts("Verifying Checksum ... "); |
b97a2a0a | 202 | if (!image_check_dcrc (hdr)) { |
a2663ea4 | 203 | puts("Bad Data CRC\n"); |
c609719b WD |
204 | return 1; |
205 | } | |
a2663ea4 WD |
206 | puts("OK\n"); |
207 | ||
b97a2a0a MB |
208 | data = (uchar *)image_get_data (hdr); |
209 | len = image_get_data_size (hdr); | |
210 | ||
211 | if (image_get_comp (hdr) != IH_COMP_NONE) { | |
a2663ea4 WD |
212 | uchar *buf; |
213 | /* reserve space for uncompressed image */ | |
214 | if ((buf = malloc(IMAGE_SIZE)) == NULL) { | |
215 | puts("Insufficient space for decompression\n"); | |
c609719b WD |
216 | return 1; |
217 | } | |
d4ca31c4 | 218 | |
b97a2a0a | 219 | switch (image_get_comp (hdr)) { |
a2663ea4 WD |
220 | case IH_COMP_GZIP: |
221 | puts("Uncompressing (GZIP) ... "); | |
eedcd078 | 222 | rc = gunzip ((void *)(buf), IMAGE_SIZE, data, &len); |
a2663ea4 WD |
223 | if (rc != 0) { |
224 | puts("GUNZIP ERROR\n"); | |
225 | free(buf); | |
226 | return 1; | |
227 | } | |
228 | puts("OK\n"); | |
229 | break; | |
42dfe7a1 | 230 | #ifdef CONFIG_BZIP2 |
a2663ea4 WD |
231 | case IH_COMP_BZIP2: |
232 | puts("Uncompressing (BZIP2) ... "); | |
233 | { | |
234 | uint retlen = IMAGE_SIZE; | |
235 | rc = BZ2_bzBuffToBuffDecompress ((char *)(buf), &retlen, | |
236 | (char *)data, len, 0, 0); | |
237 | len = retlen; | |
238 | } | |
239 | if (rc != BZ_OK) { | |
240 | printf ("BUNZIP2 ERROR: %d\n", rc); | |
241 | free(buf); | |
242 | return 1; | |
243 | } | |
244 | puts("OK\n"); | |
245 | break; | |
246 | #endif | |
247 | default: | |
b97a2a0a MB |
248 | printf ("Unimplemented compression type %d\n", |
249 | image_get_comp (hdr)); | |
a2663ea4 WD |
250 | free(buf); |
251 | return 1; | |
252 | } | |
d4ca31c4 | 253 | |
a2663ea4 WD |
254 | rc = mpl_prg(buf, len); |
255 | free(buf); | |
256 | } else { | |
257 | rc = mpl_prg(data, len); | |
c609719b | 258 | } |
d4ca31c4 | 259 | |
a2663ea4 | 260 | return(rc); |
c609719b WD |
261 | } |
262 | ||
b6e4c403 | 263 | #if !defined(CONFIG_PATI) |
c609719b WD |
264 | void get_backup_values(backup_t *buf) |
265 | { | |
266 | i2c_read(CFG_DEF_EEPROM_ADDR, I2C_BACKUP_ADDR,2,(void *)buf,sizeof(backup_t)); | |
267 | } | |
268 | ||
269 | void set_backup_values(int overwrite) | |
270 | { | |
271 | backup_t back; | |
272 | int i; | |
273 | ||
274 | get_backup_values(&back); | |
275 | if(!overwrite) { | |
276 | if(strncmp(back.signature,"MPL\0",4)==0) { | |
a2663ea4 | 277 | puts("Not possible to write Backup\n"); |
c609719b WD |
278 | return; |
279 | } | |
280 | } | |
281 | memcpy(back.signature,"MPL\0",4); | |
1cb8e980 WD |
282 | i = getenv_r("serial#",back.serial_name,16); |
283 | if(i < 0) { | |
a2663ea4 | 284 | puts("Not possible to write Backup\n"); |
c609719b WD |
285 | return; |
286 | } | |
287 | back.serial_name[16]=0; | |
1cb8e980 WD |
288 | i = getenv_r("ethaddr",back.eth_addr,20); |
289 | if(i < 0) { | |
a2663ea4 | 290 | puts("Not possible to write Backup\n"); |
c609719b WD |
291 | return; |
292 | } | |
293 | back.eth_addr[20]=0; | |
294 | i2c_write(CFG_DEF_EEPROM_ADDR, I2C_BACKUP_ADDR,2,(void *)&back,sizeof(backup_t)); | |
295 | } | |
296 | ||
297 | void clear_env_values(void) | |
298 | { | |
299 | backup_t back; | |
300 | unsigned char env_crc[4]; | |
301 | ||
302 | memset(&back,0xff,sizeof(backup_t)); | |
303 | memset(env_crc,0x00,4); | |
304 | i2c_write(CFG_DEF_EEPROM_ADDR,I2C_BACKUP_ADDR,2,(void *)&back,sizeof(backup_t)); | |
305 | i2c_write(CFG_DEF_EEPROM_ADDR,CFG_ENV_OFFSET,2,(void *)env_crc,4); | |
306 | } | |
307 | ||
308 | /* | |
309 | * check crc of "older" environment | |
310 | */ | |
311 | int check_env_old_size(ulong oldsize) | |
312 | { | |
313 | ulong crc, len, new; | |
314 | unsigned off; | |
315 | uchar buf[64]; | |
316 | ||
317 | /* read old CRC */ | |
318 | eeprom_read (CFG_DEF_EEPROM_ADDR, | |
319 | CFG_ENV_OFFSET, | |
320 | (uchar *)&crc, sizeof(ulong)); | |
321 | ||
322 | new = 0; | |
323 | len = oldsize; | |
324 | off = sizeof(long); | |
325 | len = oldsize-off; | |
326 | while (len > 0) { | |
327 | int n = (len > sizeof(buf)) ? sizeof(buf) : len; | |
328 | ||
329 | eeprom_read (CFG_DEF_EEPROM_ADDR, CFG_ENV_OFFSET+off, buf, n); | |
330 | new = crc32 (new, buf, n); | |
331 | len -= n; | |
332 | off += n; | |
333 | } | |
334 | ||
335 | return (crc == new); | |
336 | } | |
337 | ||
338 | static ulong oldsizes[] = { | |
339 | 0x200, | |
340 | 0x800, | |
341 | 0 | |
342 | }; | |
343 | ||
344 | void copy_old_env(ulong size) | |
345 | { | |
346 | uchar name_buf[64]; | |
347 | uchar value_buf[0x800]; | |
348 | uchar c; | |
349 | ulong len; | |
350 | unsigned off; | |
351 | uchar *name, *value; | |
352 | ||
353 | name=&name_buf[0]; | |
354 | value=&value_buf[0]; | |
355 | len=size; | |
356 | off = sizeof(long); | |
357 | while (len > off) { | |
358 | eeprom_read (CFG_DEF_EEPROM_ADDR, CFG_ENV_OFFSET+off, &c, 1); | |
359 | if(c != '=') { | |
360 | *name++=c; | |
361 | off++; | |
362 | } | |
363 | else { | |
364 | *name++='\0'; | |
365 | off++; | |
366 | do { | |
367 | eeprom_read (CFG_DEF_EEPROM_ADDR, CFG_ENV_OFFSET+off, &c, 1); | |
368 | *value++=c; | |
369 | off++; | |
370 | if(c == '\0') | |
371 | break; | |
372 | } while(len > off); | |
373 | name=&name_buf[0]; | |
374 | value=&value_buf[0]; | |
77ddac94 WD |
375 | if(strncmp((char *)name,"baudrate",8)!=0) { |
376 | setenv((char *)name,(char *)value); | |
c609719b WD |
377 | } |
378 | ||
379 | } | |
380 | } | |
381 | } | |
382 | ||
383 | ||
384 | void check_env(void) | |
385 | { | |
77ddac94 | 386 | char *s; |
c609719b WD |
387 | int i=0; |
388 | char buf[32]; | |
389 | backup_t back; | |
390 | ||
391 | s=getenv("serial#"); | |
392 | if(!s) { | |
393 | while(oldsizes[i]) { | |
394 | if(check_env_old_size(oldsizes[i])) | |
395 | break; | |
396 | i++; | |
397 | } | |
398 | if(!oldsizes[i]) { | |
399 | /* no old environment has been found */ | |
400 | get_backup_values (&back); | |
401 | if (strncmp (back.signature, "MPL\0", 4) == 0) { | |
402 | sprintf (buf, "%s", back.serial_name); | |
403 | setenv ("serial#", buf); | |
404 | sprintf (buf, "%s", back.eth_addr); | |
405 | setenv ("ethaddr", buf); | |
406 | printf ("INFO: serial# and ethaddr recovered, use saveenv\n"); | |
407 | return; | |
408 | } | |
409 | } | |
410 | else { | |
411 | copy_old_env(oldsizes[i]); | |
a2663ea4 | 412 | puts("INFO: old environment ajusted, use saveenv\n"); |
c609719b WD |
413 | } |
414 | } | |
415 | else { | |
416 | /* check if back up is set */ | |
417 | get_backup_values(&back); | |
418 | if(strncmp(back.signature,"MPL\0",4)!=0) { | |
419 | set_backup_values(0); | |
420 | } | |
421 | } | |
422 | } | |
423 | ||
424 | ||
c609719b WD |
425 | extern device_t *stdio_devices[]; |
426 | extern char *stdio_names[]; | |
427 | ||
428 | void show_stdio_dev(void) | |
429 | { | |
47cd00fa | 430 | /* Print information */ |
a2663ea4 | 431 | puts("In: "); |
c609719b | 432 | if (stdio_devices[stdin] == NULL) { |
a2663ea4 | 433 | puts("No input devices available!\n"); |
c609719b WD |
434 | } else { |
435 | printf ("%s\n", stdio_devices[stdin]->name); | |
436 | } | |
437 | ||
a2663ea4 | 438 | puts("Out: "); |
c609719b | 439 | if (stdio_devices[stdout] == NULL) { |
a2663ea4 | 440 | puts("No output devices available!\n"); |
c609719b WD |
441 | } else { |
442 | printf ("%s\n", stdio_devices[stdout]->name); | |
443 | } | |
444 | ||
a2663ea4 | 445 | puts("Err: "); |
c609719b | 446 | if (stdio_devices[stderr] == NULL) { |
a2663ea4 | 447 | puts("No error devices available!\n"); |
c609719b WD |
448 | } else { |
449 | printf ("%s\n", stdio_devices[stderr]->name); | |
450 | } | |
451 | } | |
452 | ||
b6e4c403 | 453 | #endif /* #if !defined(CONFIG_PATI) */ |
c609719b WD |
454 | |
455 | int do_mplcommon(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) | |
456 | { | |
457 | ulong size,src,ld_addr; | |
458 | int result; | |
b6e4c403 | 459 | #if !defined(CONFIG_PATI) |
c609719b | 460 | backup_t back; |
c609719b WD |
461 | src = MULTI_PURPOSE_SOCKET_ADDR; |
462 | size = IMAGE_SIZE; | |
b6e4c403 | 463 | #endif |
c609719b WD |
464 | |
465 | if (strcmp(argv[1], "flash") == 0) | |
466 | { | |
3fe00109 | 467 | #if defined(CONFIG_CMD_FDC) |
c609719b WD |
468 | if (strcmp(argv[2], "floppy") == 0) { |
469 | char *local_args[3]; | |
470 | extern int do_fdcboot (cmd_tbl_t *, int, int, char *[]); | |
a2663ea4 | 471 | puts("\nupdating bootloader image from floppy\n"); |
c609719b WD |
472 | local_args[0] = argv[0]; |
473 | if(argc==4) { | |
474 | local_args[1] = argv[3]; | |
475 | local_args[2] = NULL; | |
476 | ld_addr=simple_strtoul(argv[3], NULL, 16); | |
477 | result=do_fdcboot(cmdtp, 0, 2, local_args); | |
478 | } | |
479 | else { | |
480 | local_args[1] = NULL; | |
481 | ld_addr=CFG_LOAD_ADDR; | |
482 | result=do_fdcboot(cmdtp, 0, 1, local_args); | |
483 | } | |
d4ca31c4 | 484 | result=mpl_prg_image((uchar *)ld_addr); |
c609719b WD |
485 | return result; |
486 | } | |
3fe00109 | 487 | #endif |
c609719b WD |
488 | if (strcmp(argv[2], "mem") == 0) { |
489 | if(argc==4) { | |
490 | ld_addr=simple_strtoul(argv[3], NULL, 16); | |
491 | } | |
492 | else { | |
493 | ld_addr=load_addr; | |
494 | } | |
495 | printf ("\nupdating bootloader image from memory at %lX\n",ld_addr); | |
a2663ea4 | 496 | result=mpl_prg_image((uchar *)ld_addr); |
c609719b WD |
497 | return result; |
498 | } | |
b6e4c403 | 499 | #if !defined(CONFIG_PATI) |
c609719b | 500 | if (strcmp(argv[2], "mps") == 0) { |
a2663ea4 WD |
501 | puts("\nupdating bootloader image from MPS\n"); |
502 | result=mpl_prg((uchar *)src,size); | |
c609719b WD |
503 | return result; |
504 | } | |
b6e4c403 | 505 | #endif /* #if !defined(CONFIG_PATI) */ |
c609719b WD |
506 | } |
507 | if (strcmp(argv[1], "mem") == 0) | |
508 | { | |
509 | result=0; | |
510 | if(argc==3) | |
511 | { | |
512 | result = (int)simple_strtol(argv[2], NULL, 16); | |
513 | } | |
514 | src=(unsigned long)&result; | |
515 | src-=CFG_MEMTEST_START; | |
516 | src-=(100*1024); /* - 100k */ | |
517 | src&=0xfff00000; | |
518 | size=0; | |
519 | do { | |
520 | size++; | |
521 | printf("\n\nPass %ld\n",size); | |
522 | mem_test(CFG_MEMTEST_START,src,1); | |
523 | if(ctrlc()) | |
524 | break; | |
525 | if(result>0) | |
526 | result--; | |
527 | ||
528 | }while(result); | |
529 | return 0; | |
530 | } | |
b6e4c403 | 531 | #if !defined(CONFIG_PATI) |
c609719b WD |
532 | if (strcmp(argv[1], "clearenvvalues") == 0) |
533 | { | |
534 | if (strcmp(argv[2], "yes") == 0) | |
535 | { | |
536 | clear_env_values(); | |
537 | return 0; | |
538 | } | |
539 | } | |
540 | if (strcmp(argv[1], "getback") == 0) { | |
541 | get_backup_values(&back); | |
542 | back.signature[3]=0; | |
543 | back.serial_name[16]=0; | |
544 | back.eth_addr[20]=0; | |
545 | printf("GetBackUp: signature: %s\n",back.signature); | |
546 | printf(" serial#: %s\n",back.serial_name); | |
547 | printf(" ethaddr: %s\n",back.eth_addr); | |
548 | return 0; | |
549 | } | |
550 | if (strcmp(argv[1], "setback") == 0) { | |
551 | set_backup_values(1); | |
552 | return 0; | |
553 | } | |
b6e4c403 | 554 | #endif |
c609719b WD |
555 | printf("Usage:\n%s\n", cmdtp->usage); |
556 | return 1; | |
557 | } | |
558 | ||
559 | ||
3fe00109 | 560 | #if defined(CONFIG_CMD_DOC) |
c609719b WD |
561 | extern void doc_probe(ulong physadr); |
562 | void doc_init (void) | |
563 | { | |
564 | doc_probe(MULTI_PURPOSE_SOCKET_ADDR); | |
565 | } | |
566 | #endif | |
567 | ||
568 | ||
569 | #ifdef CONFIG_VIDEO | |
570 | /****************************************************** | |
571 | * Routines to display the Board information | |
572 | * to the screen (since the VGA will be initialized as last, | |
573 | * we must resend the infos) | |
574 | */ | |
575 | ||
576 | #ifdef CONFIG_CONSOLE_EXTRA_INFO | |
577 | extern GraphicDevice ctfb; | |
7205e407 | 578 | extern int get_boot_mode(void); |
c609719b WD |
579 | |
580 | void video_get_info_str (int line_number, char *info) | |
581 | { | |
582 | /* init video info strings for graphic console */ | |
087dfdb7 | 583 | PPC4xx_SYS_INFO sys_info; |
c609719b | 584 | char rev; |
33149b88 | 585 | int i,boot; |
c609719b WD |
586 | unsigned long pvr; |
587 | char buf[64]; | |
588 | char tmp[16]; | |
33149b88 | 589 | char cpustr[16]; |
77ddac94 | 590 | char *s, *e, bc; |
c609719b WD |
591 | switch (line_number) |
592 | { | |
593 | case 2: | |
594 | /* CPU and board infos */ | |
595 | pvr=get_pvr(); | |
596 | get_sys_info (&sys_info); | |
597 | switch (pvr) { | |
598 | case PVR_405GP_RB: rev='B'; break; | |
599 | case PVR_405GP_RC: rev='C'; break; | |
600 | case PVR_405GP_RD: rev='D'; break; | |
601 | case PVR_405GP_RE: rev='E'; break; | |
33149b88 | 602 | case PVR_405GPR_RB: rev='B'; break; |
c609719b WD |
603 | default: rev='?'; break; |
604 | } | |
33149b88 WD |
605 | if(pvr==PVR_405GPR_RB) |
606 | sprintf(cpustr,"PPC405GPr %c",rev); | |
607 | else | |
608 | sprintf(cpustr,"PPC405GP %c",rev); | |
c609719b WD |
609 | /* Board info */ |
610 | i=0; | |
611 | s=getenv ("serial#"); | |
612 | #ifdef CONFIG_PIP405 | |
613 | if (!s || strncmp (s, "PIP405", 6)) { | |
614 | sprintf(buf,"### No HW ID - assuming PIP405"); | |
615 | } | |
616 | #endif | |
617 | #ifdef CONFIG_MIP405 | |
618 | if (!s || strncmp (s, "MIP405", 6)) { | |
619 | sprintf(buf,"### No HW ID - assuming MIP405"); | |
620 | } | |
621 | #endif | |
622 | else { | |
623 | for (e = s; *e; ++e) { | |
624 | if (*e == ' ') | |
625 | break; | |
626 | } | |
627 | for (; s < e; ++s) { | |
628 | if (*s == '_') { | |
629 | ++s; | |
630 | break; | |
631 | } | |
632 | buf[i++]=*s; | |
633 | } | |
634 | sprintf(&buf[i]," SN "); | |
635 | i+=4; | |
636 | for (; s < e; ++s) { | |
637 | buf[i++]=*s; | |
638 | } | |
639 | buf[i++]=0; | |
640 | } | |
33149b88 WD |
641 | sprintf (info," %s %s %s MHz (%lu/%lu/%lu MHz)", |
642 | buf, cpustr, | |
c609719b WD |
643 | strmhz (tmp, gd->cpu_clk), sys_info.freqPLB / 1000000, |
644 | sys_info.freqPLB / sys_info.pllOpbDiv / 1000000, | |
645 | sys_info.freqPLB / sys_info.pllExtBusDiv / 1000000); | |
646 | return; | |
647 | case 3: | |
648 | /* Memory Info */ | |
33149b88 | 649 | boot = get_boot_mode(); |
c609719b WD |
650 | bc = in8 (CONFIG_PORT_ADDR); |
651 | sprintf(info, " %luMB RAM, %luMB Flash Cfg 0x%02X %s %s", | |
652 | gd->bd->bi_memsize / 0x100000, | |
653 | gd->bd->bi_flashsize / 0x100000, | |
654 | bc, | |
33149b88 | 655 | (boot & BOOT_MPS) ? "MPS boot" : "Flash boot", |
c609719b WD |
656 | ctfb.modeIdent); |
657 | return; | |
658 | case 1: | |
659 | sprintf (buf, "%s",CONFIG_IDENT_STRING); | |
660 | sprintf (info, " %s", &buf[1]); | |
661 | return; | |
662 | } | |
663 | /* no more info lines */ | |
664 | *info = 0; | |
665 | return; | |
666 | } | |
667 | #endif /* CONFIG_CONSOLE_EXTRA_INFO */ | |
668 | ||
669 | #endif /* CONFIG_VIDEO */ |