]>
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) |
9a4daad0 | 77 | if (uimage_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 | |
d5934ad7 | 184 | #if defined(CONFIG_FIT) |
9a4daad0 | 185 | if (genimg_get_format ((void *)hdr) != IMAGE_FORMAT_LEGACY) { |
d5934ad7 MB |
186 | puts ("Non legacy image format not supported\n"); |
187 | return -1; | |
188 | } | |
189 | #endif | |
190 | ||
b97a2a0a | 191 | if (!image_check_magic (hdr)) { |
a2663ea4 | 192 | puts("Bad Magic Number\n"); |
c609719b WD |
193 | return 1; |
194 | } | |
2242f536 | 195 | image_print_contents (hdr); |
b97a2a0a | 196 | if (!image_check_os (hdr, IH_OS_U_BOOT)) { |
a2663ea4 | 197 | puts("No U-Boot Image\n"); |
c609719b WD |
198 | return 1; |
199 | } | |
b97a2a0a | 200 | if (!image_check_type (hdr, IH_TYPE_FIRMWARE)) { |
a2663ea4 | 201 | puts("No Firmware Image\n"); |
c609719b WD |
202 | return 1; |
203 | } | |
b97a2a0a | 204 | if (!image_check_hcrc (hdr)) { |
a2663ea4 | 205 | puts("Bad Header Checksum\n"); |
c609719b WD |
206 | return 1; |
207 | } | |
a2663ea4 | 208 | puts("Verifying Checksum ... "); |
b97a2a0a | 209 | if (!image_check_dcrc (hdr)) { |
a2663ea4 | 210 | puts("Bad Data CRC\n"); |
c609719b WD |
211 | return 1; |
212 | } | |
a2663ea4 WD |
213 | puts("OK\n"); |
214 | ||
b97a2a0a MB |
215 | data = (uchar *)image_get_data (hdr); |
216 | len = image_get_data_size (hdr); | |
217 | ||
218 | if (image_get_comp (hdr) != IH_COMP_NONE) { | |
a2663ea4 WD |
219 | uchar *buf; |
220 | /* reserve space for uncompressed image */ | |
221 | if ((buf = malloc(IMAGE_SIZE)) == NULL) { | |
53677ef1 | 222 | puts("Insufficient space for decompression\n"); |
c609719b WD |
223 | return 1; |
224 | } | |
d4ca31c4 | 225 | |
b97a2a0a | 226 | switch (image_get_comp (hdr)) { |
a2663ea4 WD |
227 | case IH_COMP_GZIP: |
228 | puts("Uncompressing (GZIP) ... "); | |
eedcd078 | 229 | rc = gunzip ((void *)(buf), IMAGE_SIZE, data, &len); |
a2663ea4 WD |
230 | if (rc != 0) { |
231 | puts("GUNZIP ERROR\n"); | |
232 | free(buf); | |
233 | return 1; | |
234 | } | |
235 | puts("OK\n"); | |
236 | break; | |
42dfe7a1 | 237 | #ifdef CONFIG_BZIP2 |
a2663ea4 WD |
238 | case IH_COMP_BZIP2: |
239 | puts("Uncompressing (BZIP2) ... "); | |
240 | { | |
241 | uint retlen = IMAGE_SIZE; | |
242 | rc = BZ2_bzBuffToBuffDecompress ((char *)(buf), &retlen, | |
243 | (char *)data, len, 0, 0); | |
244 | len = retlen; | |
245 | } | |
246 | if (rc != BZ_OK) { | |
247 | printf ("BUNZIP2 ERROR: %d\n", rc); | |
248 | free(buf); | |
249 | return 1; | |
250 | } | |
251 | puts("OK\n"); | |
252 | break; | |
253 | #endif | |
254 | default: | |
b97a2a0a MB |
255 | printf ("Unimplemented compression type %d\n", |
256 | image_get_comp (hdr)); | |
a2663ea4 WD |
257 | free(buf); |
258 | return 1; | |
259 | } | |
d4ca31c4 | 260 | |
a2663ea4 WD |
261 | rc = mpl_prg(buf, len); |
262 | free(buf); | |
263 | } else { | |
264 | rc = mpl_prg(data, len); | |
c609719b | 265 | } |
d4ca31c4 | 266 | |
a2663ea4 | 267 | return(rc); |
c609719b WD |
268 | } |
269 | ||
b6e4c403 | 270 | #if !defined(CONFIG_PATI) |
c609719b WD |
271 | void get_backup_values(backup_t *buf) |
272 | { | |
273 | i2c_read(CFG_DEF_EEPROM_ADDR, I2C_BACKUP_ADDR,2,(void *)buf,sizeof(backup_t)); | |
274 | } | |
275 | ||
276 | void set_backup_values(int overwrite) | |
277 | { | |
278 | backup_t back; | |
279 | int i; | |
280 | ||
281 | get_backup_values(&back); | |
282 | if(!overwrite) { | |
283 | if(strncmp(back.signature,"MPL\0",4)==0) { | |
a2663ea4 | 284 | puts("Not possible to write Backup\n"); |
c609719b WD |
285 | return; |
286 | } | |
287 | } | |
288 | memcpy(back.signature,"MPL\0",4); | |
1cb8e980 WD |
289 | i = getenv_r("serial#",back.serial_name,16); |
290 | if(i < 0) { | |
a2663ea4 | 291 | puts("Not possible to write Backup\n"); |
c609719b WD |
292 | return; |
293 | } | |
294 | back.serial_name[16]=0; | |
1cb8e980 WD |
295 | i = getenv_r("ethaddr",back.eth_addr,20); |
296 | if(i < 0) { | |
a2663ea4 | 297 | puts("Not possible to write Backup\n"); |
c609719b WD |
298 | return; |
299 | } | |
300 | back.eth_addr[20]=0; | |
301 | i2c_write(CFG_DEF_EEPROM_ADDR, I2C_BACKUP_ADDR,2,(void *)&back,sizeof(backup_t)); | |
302 | } | |
303 | ||
304 | void clear_env_values(void) | |
305 | { | |
306 | backup_t back; | |
307 | unsigned char env_crc[4]; | |
308 | ||
309 | memset(&back,0xff,sizeof(backup_t)); | |
310 | memset(env_crc,0x00,4); | |
311 | i2c_write(CFG_DEF_EEPROM_ADDR,I2C_BACKUP_ADDR,2,(void *)&back,sizeof(backup_t)); | |
312 | i2c_write(CFG_DEF_EEPROM_ADDR,CFG_ENV_OFFSET,2,(void *)env_crc,4); | |
313 | } | |
314 | ||
315 | /* | |
316 | * check crc of "older" environment | |
317 | */ | |
318 | int check_env_old_size(ulong oldsize) | |
319 | { | |
320 | ulong crc, len, new; | |
321 | unsigned off; | |
322 | uchar buf[64]; | |
323 | ||
324 | /* read old CRC */ | |
325 | eeprom_read (CFG_DEF_EEPROM_ADDR, | |
326 | CFG_ENV_OFFSET, | |
327 | (uchar *)&crc, sizeof(ulong)); | |
328 | ||
329 | new = 0; | |
330 | len = oldsize; | |
331 | off = sizeof(long); | |
332 | len = oldsize-off; | |
333 | while (len > 0) { | |
334 | int n = (len > sizeof(buf)) ? sizeof(buf) : len; | |
335 | ||
336 | eeprom_read (CFG_DEF_EEPROM_ADDR, CFG_ENV_OFFSET+off, buf, n); | |
337 | new = crc32 (new, buf, n); | |
338 | len -= n; | |
339 | off += n; | |
340 | } | |
341 | ||
342 | return (crc == new); | |
343 | } | |
344 | ||
345 | static ulong oldsizes[] = { | |
346 | 0x200, | |
347 | 0x800, | |
348 | 0 | |
349 | }; | |
350 | ||
351 | void copy_old_env(ulong size) | |
352 | { | |
353 | uchar name_buf[64]; | |
354 | uchar value_buf[0x800]; | |
355 | uchar c; | |
356 | ulong len; | |
357 | unsigned off; | |
358 | uchar *name, *value; | |
359 | ||
d0ff51ba WD |
360 | name = &name_buf[0]; |
361 | value = &value_buf[0]; | |
c609719b WD |
362 | len=size; |
363 | off = sizeof(long); | |
364 | while (len > off) { | |
365 | eeprom_read (CFG_DEF_EEPROM_ADDR, CFG_ENV_OFFSET+off, &c, 1); | |
366 | if(c != '=') { | |
367 | *name++=c; | |
368 | off++; | |
369 | } | |
370 | else { | |
371 | *name++='\0'; | |
372 | off++; | |
373 | do { | |
374 | eeprom_read (CFG_DEF_EEPROM_ADDR, CFG_ENV_OFFSET+off, &c, 1); | |
375 | *value++=c; | |
376 | off++; | |
377 | if(c == '\0') | |
378 | break; | |
379 | } while(len > off); | |
d0ff51ba WD |
380 | name = &name_buf[0]; |
381 | value = &value_buf[0]; | |
77ddac94 WD |
382 | if(strncmp((char *)name,"baudrate",8)!=0) { |
383 | setenv((char *)name,(char *)value); | |
c609719b WD |
384 | } |
385 | ||
386 | } | |
387 | } | |
388 | } | |
389 | ||
390 | ||
391 | void check_env(void) | |
392 | { | |
77ddac94 | 393 | char *s; |
c609719b WD |
394 | int i=0; |
395 | char buf[32]; | |
396 | backup_t back; | |
397 | ||
398 | s=getenv("serial#"); | |
399 | if(!s) { | |
400 | while(oldsizes[i]) { | |
401 | if(check_env_old_size(oldsizes[i])) | |
402 | break; | |
403 | i++; | |
404 | } | |
405 | if(!oldsizes[i]) { | |
406 | /* no old environment has been found */ | |
407 | get_backup_values (&back); | |
408 | if (strncmp (back.signature, "MPL\0", 4) == 0) { | |
409 | sprintf (buf, "%s", back.serial_name); | |
410 | setenv ("serial#", buf); | |
411 | sprintf (buf, "%s", back.eth_addr); | |
412 | setenv ("ethaddr", buf); | |
413 | printf ("INFO: serial# and ethaddr recovered, use saveenv\n"); | |
414 | return; | |
415 | } | |
416 | } | |
417 | else { | |
418 | copy_old_env(oldsizes[i]); | |
a2663ea4 | 419 | puts("INFO: old environment ajusted, use saveenv\n"); |
c609719b WD |
420 | } |
421 | } | |
422 | else { | |
423 | /* check if back up is set */ | |
424 | get_backup_values(&back); | |
425 | if(strncmp(back.signature,"MPL\0",4)!=0) { | |
426 | set_backup_values(0); | |
427 | } | |
428 | } | |
429 | } | |
430 | ||
431 | ||
c609719b WD |
432 | extern device_t *stdio_devices[]; |
433 | extern char *stdio_names[]; | |
434 | ||
435 | void show_stdio_dev(void) | |
436 | { | |
47cd00fa | 437 | /* Print information */ |
a2663ea4 | 438 | puts("In: "); |
c609719b | 439 | if (stdio_devices[stdin] == NULL) { |
a2663ea4 | 440 | puts("No input devices available!\n"); |
c609719b WD |
441 | } else { |
442 | printf ("%s\n", stdio_devices[stdin]->name); | |
443 | } | |
444 | ||
a2663ea4 | 445 | puts("Out: "); |
c609719b | 446 | if (stdio_devices[stdout] == NULL) { |
a2663ea4 | 447 | puts("No output devices available!\n"); |
c609719b WD |
448 | } else { |
449 | printf ("%s\n", stdio_devices[stdout]->name); | |
450 | } | |
451 | ||
a2663ea4 | 452 | puts("Err: "); |
c609719b | 453 | if (stdio_devices[stderr] == NULL) { |
a2663ea4 | 454 | puts("No error devices available!\n"); |
c609719b WD |
455 | } else { |
456 | printf ("%s\n", stdio_devices[stderr]->name); | |
457 | } | |
458 | } | |
459 | ||
b6e4c403 | 460 | #endif /* #if !defined(CONFIG_PATI) */ |
c609719b WD |
461 | |
462 | int do_mplcommon(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) | |
463 | { | |
53677ef1 | 464 | ulong size,src,ld_addr; |
c609719b | 465 | int result; |
b6e4c403 | 466 | #if !defined(CONFIG_PATI) |
c609719b | 467 | backup_t back; |
c609719b WD |
468 | src = MULTI_PURPOSE_SOCKET_ADDR; |
469 | size = IMAGE_SIZE; | |
b6e4c403 | 470 | #endif |
c609719b WD |
471 | |
472 | if (strcmp(argv[1], "flash") == 0) | |
473 | { | |
3fe00109 | 474 | #if defined(CONFIG_CMD_FDC) |
c609719b | 475 | if (strcmp(argv[2], "floppy") == 0) { |
53677ef1 | 476 | char *local_args[3]; |
c609719b | 477 | extern int do_fdcboot (cmd_tbl_t *, int, int, char *[]); |
a2663ea4 | 478 | puts("\nupdating bootloader image from floppy\n"); |
c609719b | 479 | local_args[0] = argv[0]; |
53677ef1 | 480 | if(argc==4) { |
c609719b WD |
481 | local_args[1] = argv[3]; |
482 | local_args[2] = NULL; | |
483 | ld_addr=simple_strtoul(argv[3], NULL, 16); | |
484 | result=do_fdcboot(cmdtp, 0, 2, local_args); | |
485 | } | |
486 | else { | |
487 | local_args[1] = NULL; | |
488 | ld_addr=CFG_LOAD_ADDR; | |
489 | result=do_fdcboot(cmdtp, 0, 1, local_args); | |
490 | } | |
d4ca31c4 | 491 | result=mpl_prg_image((uchar *)ld_addr); |
c609719b WD |
492 | return result; |
493 | } | |
3fe00109 | 494 | #endif |
c609719b | 495 | if (strcmp(argv[2], "mem") == 0) { |
53677ef1 | 496 | if(argc==4) { |
c609719b WD |
497 | ld_addr=simple_strtoul(argv[3], NULL, 16); |
498 | } | |
499 | else { | |
500 | ld_addr=load_addr; | |
501 | } | |
502 | printf ("\nupdating bootloader image from memory at %lX\n",ld_addr); | |
a2663ea4 | 503 | result=mpl_prg_image((uchar *)ld_addr); |
c609719b WD |
504 | return result; |
505 | } | |
b6e4c403 | 506 | #if !defined(CONFIG_PATI) |
c609719b | 507 | if (strcmp(argv[2], "mps") == 0) { |
a2663ea4 WD |
508 | puts("\nupdating bootloader image from MPS\n"); |
509 | result=mpl_prg((uchar *)src,size); | |
c609719b WD |
510 | return result; |
511 | } | |
b6e4c403 | 512 | #endif /* #if !defined(CONFIG_PATI) */ |
c609719b WD |
513 | } |
514 | if (strcmp(argv[1], "mem") == 0) | |
515 | { | |
516 | result=0; | |
517 | if(argc==3) | |
518 | { | |
519 | result = (int)simple_strtol(argv[2], NULL, 16); | |
520 | } | |
521 | src=(unsigned long)&result; | |
522 | src-=CFG_MEMTEST_START; | |
523 | src-=(100*1024); /* - 100k */ | |
524 | src&=0xfff00000; | |
525 | size=0; | |
526 | do { | |
53677ef1 | 527 | size++; |
c609719b WD |
528 | printf("\n\nPass %ld\n",size); |
529 | mem_test(CFG_MEMTEST_START,src,1); | |
530 | if(ctrlc()) | |
531 | break; | |
532 | if(result>0) | |
533 | result--; | |
534 | ||
535 | }while(result); | |
536 | return 0; | |
537 | } | |
b6e4c403 | 538 | #if !defined(CONFIG_PATI) |
c609719b WD |
539 | if (strcmp(argv[1], "clearenvvalues") == 0) |
540 | { | |
53677ef1 | 541 | if (strcmp(argv[2], "yes") == 0) |
c609719b WD |
542 | { |
543 | clear_env_values(); | |
544 | return 0; | |
545 | } | |
546 | } | |
547 | if (strcmp(argv[1], "getback") == 0) { | |
548 | get_backup_values(&back); | |
549 | back.signature[3]=0; | |
550 | back.serial_name[16]=0; | |
551 | back.eth_addr[20]=0; | |
552 | printf("GetBackUp: signature: %s\n",back.signature); | |
553 | printf(" serial#: %s\n",back.serial_name); | |
554 | printf(" ethaddr: %s\n",back.eth_addr); | |
555 | return 0; | |
556 | } | |
557 | if (strcmp(argv[1], "setback") == 0) { | |
558 | set_backup_values(1); | |
559 | return 0; | |
560 | } | |
b6e4c403 | 561 | #endif |
c609719b WD |
562 | printf("Usage:\n%s\n", cmdtp->usage); |
563 | return 1; | |
564 | } | |
565 | ||
566 | ||
3fe00109 | 567 | #if defined(CONFIG_CMD_DOC) |
c609719b WD |
568 | void doc_init (void) |
569 | { | |
570 | doc_probe(MULTI_PURPOSE_SOCKET_ADDR); | |
571 | } | |
572 | #endif | |
573 | ||
574 | ||
575 | #ifdef CONFIG_VIDEO | |
576 | /****************************************************** | |
577 | * Routines to display the Board information | |
578 | * to the screen (since the VGA will be initialized as last, | |
579 | * we must resend the infos) | |
580 | */ | |
581 | ||
582 | #ifdef CONFIG_CONSOLE_EXTRA_INFO | |
583 | extern GraphicDevice ctfb; | |
7205e407 | 584 | extern int get_boot_mode(void); |
c609719b WD |
585 | |
586 | void video_get_info_str (int line_number, char *info) | |
587 | { | |
588 | /* init video info strings for graphic console */ | |
087dfdb7 | 589 | PPC4xx_SYS_INFO sys_info; |
c609719b | 590 | char rev; |
33149b88 | 591 | int i,boot; |
c609719b WD |
592 | unsigned long pvr; |
593 | char buf[64]; | |
594 | char tmp[16]; | |
33149b88 | 595 | char cpustr[16]; |
77ddac94 | 596 | char *s, *e, bc; |
c609719b WD |
597 | switch (line_number) |
598 | { | |
599 | case 2: | |
600 | /* CPU and board infos */ | |
601 | pvr=get_pvr(); | |
602 | get_sys_info (&sys_info); | |
603 | switch (pvr) { | |
604 | case PVR_405GP_RB: rev='B'; break; | |
605 | case PVR_405GP_RC: rev='C'; break; | |
606 | case PVR_405GP_RD: rev='D'; break; | |
607 | case PVR_405GP_RE: rev='E'; break; | |
33149b88 | 608 | case PVR_405GPR_RB: rev='B'; break; |
c609719b WD |
609 | default: rev='?'; break; |
610 | } | |
33149b88 WD |
611 | if(pvr==PVR_405GPR_RB) |
612 | sprintf(cpustr,"PPC405GPr %c",rev); | |
613 | else | |
614 | sprintf(cpustr,"PPC405GP %c",rev); | |
c609719b WD |
615 | /* Board info */ |
616 | i=0; | |
617 | s=getenv ("serial#"); | |
618 | #ifdef CONFIG_PIP405 | |
619 | if (!s || strncmp (s, "PIP405", 6)) { | |
620 | sprintf(buf,"### No HW ID - assuming PIP405"); | |
621 | } | |
622 | #endif | |
623 | #ifdef CONFIG_MIP405 | |
624 | if (!s || strncmp (s, "MIP405", 6)) { | |
625 | sprintf(buf,"### No HW ID - assuming MIP405"); | |
626 | } | |
627 | #endif | |
628 | else { | |
629 | for (e = s; *e; ++e) { | |
630 | if (*e == ' ') | |
631 | break; | |
632 | } | |
633 | for (; s < e; ++s) { | |
634 | if (*s == '_') { | |
635 | ++s; | |
636 | break; | |
637 | } | |
d0ff51ba | 638 | buf[i++] = *s; |
c609719b WD |
639 | } |
640 | sprintf(&buf[i]," SN "); | |
641 | i+=4; | |
642 | for (; s < e; ++s) { | |
d0ff51ba | 643 | buf[i++] = *s; |
c609719b WD |
644 | } |
645 | buf[i++]=0; | |
646 | } | |
33149b88 WD |
647 | sprintf (info," %s %s %s MHz (%lu/%lu/%lu MHz)", |
648 | buf, cpustr, | |
c609719b WD |
649 | strmhz (tmp, gd->cpu_clk), sys_info.freqPLB / 1000000, |
650 | sys_info.freqPLB / sys_info.pllOpbDiv / 1000000, | |
651 | sys_info.freqPLB / sys_info.pllExtBusDiv / 1000000); | |
652 | return; | |
653 | case 3: | |
654 | /* Memory Info */ | |
33149b88 | 655 | boot = get_boot_mode(); |
c609719b WD |
656 | bc = in8 (CONFIG_PORT_ADDR); |
657 | sprintf(info, " %luMB RAM, %luMB Flash Cfg 0x%02X %s %s", | |
658 | gd->bd->bi_memsize / 0x100000, | |
659 | gd->bd->bi_flashsize / 0x100000, | |
660 | bc, | |
33149b88 | 661 | (boot & BOOT_MPS) ? "MPS boot" : "Flash boot", |
c609719b WD |
662 | ctfb.modeIdent); |
663 | return; | |
664 | case 1: | |
665 | sprintf (buf, "%s",CONFIG_IDENT_STRING); | |
666 | sprintf (info, " %s", &buf[1]); | |
667 | return; | |
668 | } | |
669 | /* no more info lines */ | |
670 | *info = 0; | |
671 | return; | |
672 | } | |
673 | #endif /* CONFIG_CONSOLE_EXTRA_INFO */ | |
674 | ||
675 | #endif /* CONFIG_VIDEO */ |