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