]> git.kernelconcepts.de Git - karo-tx-uboot.git/blob - board/mpl/common/common_util.c
a61a98cf77fa5a4831fa2d090c6a2e7d92962cda
[karo-tx-uboot.git] / board / mpl / common / common_util.c
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>
30 #include <asm/byteorder.h>
31 #include <i2c.h>
32 #include <pci.h>
33 #include <malloc.h>
34 #include <bzlib.h>
35
36 #ifdef CONFIG_PIP405
37 #include "../pip405/pip405.h"
38 #include <asm/4xx_pci.h>
39 #endif
40 #ifdef CONFIG_MIP405
41 #include "../mip405/mip405.h"
42 #include <asm/4xx_pci.h>
43 #endif
44
45 DECLARE_GLOBAL_DATA_PTR;
46
47 #if defined(CONFIG_PATI)
48 #define FIRM_START 0xFFF00000
49 #endif
50
51 extern int mem_test(ulong start, ulong ramsize, int quiet);
52
53 #define I2C_BACKUP_ADDR 0x7C00          /* 0x200 bytes for backup */
54 #define IMAGE_SIZE CONFIG_SYS_MONITOR_LEN       /* ugly, but it works for now */
55
56 #if defined(CONFIG_PIP405) || defined(CONFIG_MIP405)
57 /*-----------------------------------------------------------------------
58  * On PIP/MIP405 we have 3 (4) possible boot mode
59  *
60  * - Boot from Flash (Flash CS = CS0, MPS CS = CS1)
61  * - Boot from MPS   (Flash CS = CS1, MPS CS = CS0)
62  * - Boot from PCI with Flash map (Flash CS = CS0, MPS CS = CS1)
63  * - Boot from PCI with MPS map   (Flash CS = CS1, MPS CS = CS0)
64  * The flash init is the first board specific routine which is called
65  * after code relocation (running from SDRAM)
66  * The first thing we do is to map the Flash CS to the Flash area and
67  * the MPS CS to the MPS area. Since the flash size is unknown at this
68  * point, we use the max flash size and the lowest flash address as base.
69  *
70  * After flash detection we adjust the size of the CS area accordingly.
71  * update_flash_size() will fix in wrong values in the flash_info structure,
72  * misc_init_r() will fix the values in the board info structure
73  */
74 int get_boot_mode(void)
75 {
76         unsigned long pbcr;
77         int res = 0;
78         pbcr = mfdcr(CPC0_PSR);
79         if ((pbcr & PSR_ROM_WIDTH_MASK) == 0)
80                 /* boot via MPS or MPS mapping */
81                 res = BOOT_MPS;
82         if (pbcr & PSR_ROM_LOC)
83                 /* boot via PCI.. */
84                 res |= BOOT_PCI;
85          return res;
86 }
87
88 /* Map the flash high (in boot area)
89    This code can only be executed from SDRAM (after relocation).
90 */
91 void setup_cs_reloc(void)
92 {
93         int mode;
94         /*
95          * since we are relocated, we can set-up the CS finaly
96          * but first of all, switch off PCI mapping (in case it
97          * was a PCI boot)
98          */
99         out32r(PMM0MA, 0L);
100         /* get boot mode */
101         mode = get_boot_mode();
102         /*
103          * we map the flash high in every case
104          * first find out to which CS the flash is attached to
105          */
106         if (mode & BOOT_MPS) {
107                 /* map flash high on CS1 and MPS on CS0 */
108                 mtdcr(EBC0_CFGADDR, PB0AP);
109                 mtdcr(EBC0_CFGDATA, MPS_AP);
110                 mtdcr(EBC0_CFGADDR, PB0CR);
111                 mtdcr(EBC0_CFGDATA, MPS_CR);
112                 /*
113                  * we use the default values (max values) for the flash
114                  * because its real size is not yet known
115                  */
116                 mtdcr(EBC0_CFGADDR, PB1AP);
117                 mtdcr(EBC0_CFGDATA, FLASH_AP);
118                 mtdcr(EBC0_CFGADDR, PB1CR);
119                 mtdcr(EBC0_CFGDATA, FLASH_CR_B);
120         } else {
121                 /* map flash high on CS0 and MPS on CS1 */
122                 mtdcr(EBC0_CFGADDR, PB1AP);
123                 mtdcr(EBC0_CFGDATA, MPS_AP);
124                 mtdcr(EBC0_CFGADDR, PB1CR);
125                 mtdcr(EBC0_CFGDATA, MPS_CR);
126                 /*
127                  * we use the default values (max values) for the flash
128                  * because its real size is not yet known
129                  */
130                 mtdcr(EBC0_CFGADDR, PB0AP);
131                 mtdcr(EBC0_CFGDATA, FLASH_AP);
132                 mtdcr(EBC0_CFGADDR, PB0CR);
133                 mtdcr(EBC0_CFGDATA, FLASH_CR_B);
134         }
135 }
136 #endif /* #if defined(CONFIG_PIP405) || defined(CONFIG_MIP405) */
137
138 #ifdef CONFIG_SYS_UPDATE_FLASH_SIZE
139 /* adjust flash start and protection info */
140 int update_flash_size(int flash_size)
141 {
142         int i = 0, mode;
143         flash_info_t *info = &flash_info[0];
144         unsigned long flashcr;
145         unsigned long flash_base = (0 - flash_size) & 0xFFF00000;
146
147         if (flash_size > 128*1024*1024) {
148                 printf("\n ### ERROR, wrong flash size: %X, reset board ###\n",
149                        flash_size);
150                 hang();
151         }
152
153         if ((flash_size >> 20) != 0)
154                 i = __ilog2(flash_size >> 20);
155
156         /* set up flash CS according to the size */
157         mode = get_boot_mode();
158         if (mode & BOOT_MPS) {
159                 /* flash is on CS1 */
160                 mtdcr(EBC0_CFGADDR, PB1CR);
161                 flashcr = mfdcr(EBC0_CFGDATA);
162                 /* we map the flash high in every case */
163                 flashcr &= 0x0001FFFF; /* mask out address bits */
164                 flashcr |= flash_base; /* start addr */
165                 flashcr |= (i << 17); /* size addr */
166                 mtdcr(EBC0_CFGADDR, PB1CR);
167                 mtdcr(EBC0_CFGDATA, flashcr);
168         } else {
169                 /* flash is on CS0 */
170                 mtdcr(EBC0_CFGADDR, PB0CR);
171                 flashcr = mfdcr(EBC0_CFGDATA);
172                 /* we map the flash high in every case */
173                 flashcr &= 0x0001FFFF; /* mask out address bits */
174                 flashcr |= flash_base; /* start addr */
175                 flashcr |= (i << 17); /* size addr */
176                 mtdcr(EBC0_CFGADDR, PB0CR);
177                 mtdcr(EBC0_CFGDATA, flashcr);
178         }
179
180         for (i = 0; i < info->sector_count; i++)
181                 /* adjust sector start address */
182                 info->start[i] = flash_base +
183                                 (info->start[i] - CONFIG_SYS_FLASH_BASE);
184
185         /* unprotect all sectors */
186         flash_protect(FLAG_PROTECT_CLEAR,
187                       info->start[0],
188                       0xFFFFFFFF,
189                       info);
190         flash_protect_default();
191         /* protect reset vector too*/
192         flash_protect(FLAG_PROTECT_SET,
193                       info->start[info->sector_count-1],
194                       0xFFFFFFFF,
195                       info);
196
197         return 0;
198 }
199 #endif
200
201 static int
202 mpl_prg(uchar *src, ulong size)
203 {
204         ulong start;
205         flash_info_t *info = &flash_info[0];
206         int i, rc;
207 #if defined(CONFIG_PATI)
208         int start_sect;
209 #endif
210 #if defined(CONFIG_PIP405) || defined(CONFIG_MIP405) || defined(CONFIG_PATI)
211         char *copystr = (char *)src;
212         ulong *magic = (ulong *)src;
213 #endif
214
215 #if defined(CONFIG_PIP405) || defined(CONFIG_MIP405) || defined(CONFIG_PATI)
216         if (uimage_to_cpu (magic[0]) != IH_MAGIC) {
217                 puts("Bad Magic number\n");
218                 return -1;
219         }
220         /* some more checks before we delete the Flash... */
221         /* Checking the ISO_STRING prevents to program a
222          * wrong Firmware Image into the flash.
223          */
224         i = 4; /* skip Magic number */
225         while (1) {
226                 if (strncmp(&copystr[i], "MEV-", 4) == 0)
227                         break;
228                 if (i++ >= 0x100) {
229                         puts("Firmware Image for unknown Target\n");
230                         return -1;
231                 }
232         }
233         /* we have the ISO STRING, check */
234         if (strncmp(&copystr[i], CONFIG_ISO_STRING, sizeof(CONFIG_ISO_STRING)-1) != 0) {
235                 printf("Wrong Firmware Image: %s\n", &copystr[i]);
236                 return -1;
237         }
238 #if !defined(CONFIG_PATI)
239         start = 0 - size;
240
241         /* unprotect sectors used by u-boot */
242         flash_protect(FLAG_PROTECT_CLEAR,
243                       start,
244                       0xFFFFFFFF,
245                       info);
246
247         /* search start sector */
248         for (i = info->sector_count-1; i > 0; i--)
249                 if (start >= info->start[i])
250                         break;
251
252         /* now erase flash */
253         printf("Erasing at %lx (sector %d) (start %lx)\n",
254                                 start,i,info->start[i]);
255         if ((rc = flash_erase (info, i, info->sector_count-1)) != 0) {
256                 puts("ERROR ");
257                 flash_perror(rc);
258                 return (1);
259         }
260
261 #else /* #if !defined(CONFIG_PATI */
262         start = FIRM_START;
263         start_sect = -1;
264
265         /* search start sector */
266         for (i = info->sector_count-1; i > 0; i--)
267                 if (start >= info->start[i])
268                         break;
269
270         start_sect = i;
271
272         for (i = info->sector_count-1; i > 0; i--)
273                 if ((start + size) >= info->start[i])
274                         break;
275
276         /* unprotect sectors used by u-boot */
277         flash_protect(FLAG_PROTECT_CLEAR,
278                       start,
279                       start + size,
280                       info);
281
282         /* now erase flash */
283         printf ("Erasing at %lx to %lx (sector %d to %d) (%lx to %lx)\n",
284                 start, start + size, start_sect, i,
285                 info->start[start_sect], info->start[i]);
286         if ((rc = flash_erase (info, start_sect, i)) != 0) {
287                 puts ("ERROR ");
288                 flash_perror (rc);
289                 return (1);
290         }
291 #endif /* defined(CONFIG_PATI) */
292
293 #elif defined(CONFIG_VCMA9)
294         start = 0;
295
296         /* search end sector */
297         for (i = 0; i < info->sector_count; i++)
298                 if (size < info->start[i])
299                     break;
300
301         flash_protect(FLAG_PROTECT_CLEAR,
302                       start,
303                       size,
304                       info);
305
306         /* now erase flash */
307         printf("Erasing at %lx (sector %d) (start %lx)\n",
308                                 start,0,info->start[0]);
309         if ((rc = flash_erase (info, 0, i)) != 0) {
310                 puts("ERROR ");
311                 flash_perror(rc);
312                 return (1);
313         }
314
315 #endif
316         printf("flash erased, programming from 0x%lx 0x%lx Bytes\n",
317                 (ulong)src, size);
318         if ((rc = flash_write ((char *)src, start, size)) != 0) {
319                 puts("ERROR ");
320                 flash_perror(rc);
321                 return (1);
322         }
323         puts("OK programming done\n");
324         return 0;
325 }
326
327
328 static int
329 mpl_prg_image(uchar *ld_addr)
330 {
331         unsigned long len;
332         uchar *data;
333         image_header_t *hdr = (image_header_t *)ld_addr;
334         int rc;
335
336 #if defined(CONFIG_FIT)
337         if (genimg_get_format ((void *)hdr) != IMAGE_FORMAT_LEGACY) {
338                 puts ("Non legacy image format not supported\n");
339                 return -1;
340         }
341 #endif
342
343         if (!image_check_magic (hdr)) {
344                 puts("Bad Magic Number\n");
345                 return 1;
346         }
347         image_print_contents (hdr);
348         if (!image_check_os (hdr, IH_OS_U_BOOT)) {
349                 puts("No U-Boot Image\n");
350                 return 1;
351         }
352         if (!image_check_type (hdr, IH_TYPE_FIRMWARE)) {
353                 puts("No Firmware Image\n");
354                 return 1;
355         }
356         if (!image_check_hcrc (hdr)) {
357                 puts("Bad Header Checksum\n");
358                 return 1;
359         }
360         puts("Verifying Checksum ... ");
361         if (!image_check_dcrc (hdr)) {
362                 puts("Bad Data CRC\n");
363                 return 1;
364         }
365         puts("OK\n");
366
367         data = (uchar *)image_get_data (hdr);
368         len = image_get_data_size (hdr);
369
370         if (image_get_comp (hdr) != IH_COMP_NONE) {
371                 uchar *buf;
372                 /* reserve space for uncompressed image */
373                 if ((buf = malloc(IMAGE_SIZE)) == NULL) {
374                         puts("Insufficient space for decompression\n");
375                         return 1;
376                 }
377
378                 switch (image_get_comp (hdr)) {
379                 case IH_COMP_GZIP:
380                         puts("Uncompressing (GZIP) ... ");
381                         rc = gunzip ((void *)(buf), IMAGE_SIZE, data, &len);
382                         if (rc != 0) {
383                                 puts("GUNZIP ERROR\n");
384                                 free(buf);
385                                 return 1;
386                         }
387                         puts("OK\n");
388                         break;
389 #ifdef CONFIG_BZIP2
390                 case IH_COMP_BZIP2:
391                         puts("Uncompressing (BZIP2) ... ");
392                         {
393                         uint retlen = IMAGE_SIZE;
394                         rc = BZ2_bzBuffToBuffDecompress ((char *)(buf), &retlen,
395                                 (char *)data, len, 0, 0);
396                         len = retlen;
397                         }
398                         if (rc != BZ_OK) {
399                                 printf ("BUNZIP2 ERROR: %d\n", rc);
400                                 free(buf);
401                                 return 1;
402                         }
403                         puts("OK\n");
404                         break;
405 #endif
406                 default:
407                         printf ("Unimplemented compression type %d\n",
408                                 image_get_comp (hdr));
409                         free(buf);
410                         return 1;
411                 }
412
413                 rc = mpl_prg(buf, len);
414                 free(buf);
415         } else {
416                 rc = mpl_prg(data, len);
417         }
418
419         return(rc);
420 }
421
422 #if !defined(CONFIG_PATI)
423 void get_backup_values(backup_t *buf)
424 {
425         i2c_read(CONFIG_SYS_DEF_EEPROM_ADDR, I2C_BACKUP_ADDR,2,(void *)buf,sizeof(backup_t));
426 }
427
428 void set_backup_values(int overwrite)
429 {
430         backup_t back;
431         int i;
432
433         get_backup_values(&back);
434         if(!overwrite) {
435                 if(strncmp(back.signature,"MPL\0",4)==0) {
436                         puts("Not possible to write Backup\n");
437                         return;
438                 }
439         }
440         memcpy(back.signature,"MPL\0",4);
441         i = getenv_f("serial#",back.serial_name,16);
442         if(i < 0) {
443                 puts("Not possible to write Backup\n");
444                 return;
445         }
446         back.serial_name[16]=0;
447         i = getenv_f("ethaddr",back.eth_addr,20);
448         if(i < 0) {
449                 puts("Not possible to write Backup\n");
450                 return;
451         }
452         back.eth_addr[20]=0;
453         i2c_write(CONFIG_SYS_DEF_EEPROM_ADDR, I2C_BACKUP_ADDR,2,(void *)&back,sizeof(backup_t));
454 }
455
456 void clear_env_values(void)
457 {
458         backup_t back;
459         unsigned char env_crc[4];
460
461         memset(&back,0xff,sizeof(backup_t));
462         memset(env_crc,0x00,4);
463         i2c_write(CONFIG_SYS_DEF_EEPROM_ADDR,I2C_BACKUP_ADDR,2,(void *)&back,sizeof(backup_t));
464         i2c_write(CONFIG_SYS_DEF_EEPROM_ADDR,CONFIG_ENV_OFFSET,2,(void *)env_crc,4);
465 }
466
467 /*
468  * check crc of "older" environment
469  */
470 int check_env_old_size(ulong oldsize)
471 {
472         ulong crc, len, new;
473         unsigned off;
474         uchar buf[64];
475
476         /* read old CRC */
477         eeprom_read (CONFIG_SYS_DEF_EEPROM_ADDR,
478                      CONFIG_ENV_OFFSET,
479                      (uchar *)&crc, sizeof(ulong));
480
481         new = 0;
482         len = oldsize;
483         off = sizeof(long);
484         len = oldsize-off;
485         while (len > 0) {
486                 int n = (len > sizeof(buf)) ? sizeof(buf) : len;
487
488                 eeprom_read (CONFIG_SYS_DEF_EEPROM_ADDR, CONFIG_ENV_OFFSET+off, buf, n);
489                 new = crc32 (new, buf, n);
490                 len -= n;
491                 off += n;
492         }
493
494         return (crc == new);
495 }
496
497 static ulong oldsizes[] = {
498         0x200,
499         0x800,
500         0
501 };
502
503 void copy_old_env(ulong size)
504 {
505         uchar name_buf[64];
506         uchar value_buf[0x800];
507         uchar c;
508         ulong len;
509         unsigned off;
510         uchar *name, *value;
511
512         name = &name_buf[0];
513         value = &value_buf[0];
514         len=size;
515         off = sizeof(long);
516         while (len > off) {
517                 eeprom_read (CONFIG_SYS_DEF_EEPROM_ADDR, CONFIG_ENV_OFFSET+off, &c, 1);
518                 if(c != '=') {
519                         *name++=c;
520                         off++;
521                 }
522                 else {
523                         *name++='\0';
524                         off++;
525                         do {
526                                 eeprom_read (CONFIG_SYS_DEF_EEPROM_ADDR, CONFIG_ENV_OFFSET+off, &c, 1);
527                                 *value++=c;
528                                 off++;
529                                 if(c == '\0')
530                                         break;
531                         } while(len > off);
532                         name = &name_buf[0];
533                         value = &value_buf[0];
534                         if(strncmp((char *)name,"baudrate",8)!=0) {
535                                 setenv((char *)name,(char *)value);
536                         }
537
538                 }
539         }
540 }
541
542
543 void check_env(void)
544 {
545         char *s;
546         int i=0;
547         char buf[32];
548         backup_t back;
549
550         s=getenv("serial#");
551         if(!s) {
552                 while(oldsizes[i]) {
553                         if(check_env_old_size(oldsizes[i]))
554                                 break;
555                         i++;
556                 }
557                 if(!oldsizes[i]) {
558                         /* no old environment has been found */
559                         get_backup_values (&back);
560                         if (strncmp (back.signature, "MPL\0", 4) == 0) {
561                                 sprintf (buf, "%s", back.serial_name);
562                                 setenv ("serial#", buf);
563                                 sprintf (buf, "%s", back.eth_addr);
564                                 setenv ("ethaddr", buf);
565                                 printf ("INFO:  serial# and ethaddr recovered, use saveenv\n");
566                                 return;
567                         }
568                 }
569                 else {
570                         copy_old_env(oldsizes[i]);
571                         puts("INFO:  old environment ajusted, use saveenv\n");
572                 }
573         }
574         else {
575                 /* check if back up is set */
576                 get_backup_values(&back);
577                 if(strncmp(back.signature,"MPL\0",4)!=0) {
578                         set_backup_values(0);
579                 }
580         }
581 }
582
583 #endif /* #if !defined(CONFIG_PATI) */
584
585 int do_mplcommon(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
586 {
587         ulong ld_addr;
588         int result;
589 #if !defined(CONFIG_PATI)
590         ulong size = IMAGE_SIZE;
591         ulong src = MULTI_PURPOSE_SOCKET_ADDR;
592         backup_t back;
593 #endif
594
595         if (strcmp(argv[1], "flash") == 0)
596         {
597 #if defined(CONFIG_CMD_FDC)
598                 if (strcmp(argv[2], "floppy") == 0) {
599                         char *local_args[3];
600                         extern int do_fdcboot (cmd_tbl_t *, int, int, char *[]);
601                         puts("\nupdating bootloader image from floppy\n");
602                         local_args[0] = argv[0];
603                         if(argc==4) {
604                                 local_args[1] = argv[3];
605                                 local_args[2] = NULL;
606                                 ld_addr=simple_strtoul(argv[3], NULL, 16);
607                                 result=do_fdcboot(cmdtp, 0, 2, local_args);
608                         }
609                         else {
610                                 local_args[1] = NULL;
611                                 ld_addr=CONFIG_SYS_LOAD_ADDR;
612                                 result=do_fdcboot(cmdtp, 0, 1, local_args);
613                         }
614                         result=mpl_prg_image((uchar *)ld_addr);
615                         return result;
616                 }
617 #endif
618                 if (strcmp(argv[2], "mem") == 0) {
619                         if(argc==4) {
620                                 ld_addr=simple_strtoul(argv[3], NULL, 16);
621                         }
622                         else {
623                                 ld_addr=load_addr;
624                         }
625                         printf ("\nupdating bootloader image from memory at %lX\n",ld_addr);
626                         result=mpl_prg_image((uchar *)ld_addr);
627                         return result;
628                 }
629 #if !defined(CONFIG_PATI)
630                 if (strcmp(argv[2], "mps") == 0) {
631                         puts("\nupdating bootloader image from MPS\n");
632                         result=mpl_prg((uchar *)src,size);
633                         return result;
634                 }
635 #endif /* #if !defined(CONFIG_PATI)     */
636         }
637 #if !defined(CONFIG_PATI)
638         if (strcmp(argv[1], "clearenvvalues") == 0)
639         {
640                 if (strcmp(argv[2], "yes") == 0)
641                 {
642                         clear_env_values();
643                         return 0;
644                 }
645         }
646         if (strcmp(argv[1], "getback") == 0) {
647                 get_backup_values(&back);
648                 back.signature[3]=0;
649                 back.serial_name[16]=0;
650                 back.eth_addr[20]=0;
651                 printf("GetBackUp: signature: %s\n",back.signature);
652                 printf("           serial#:   %s\n",back.serial_name);
653                 printf("           ethaddr:   %s\n",back.eth_addr);
654                 return 0;
655         }
656         if (strcmp(argv[1], "setback") == 0) {
657                 set_backup_values(1);
658                 return 0;
659         }
660 #endif
661         return cmd_usage(cmdtp);
662 }
663
664
665 #if defined(CONFIG_CMD_DOC)
666 void doc_init (void)
667 {
668   doc_probe(MULTI_PURPOSE_SOCKET_ADDR);
669 }
670 #endif
671
672
673 #ifdef CONFIG_VIDEO
674 /******************************************************
675  * Routines to display the Board information
676  * to the screen (since the VGA will be initialized as last,
677  * we must resend the infos)
678  */
679
680 #ifdef CONFIG_CONSOLE_EXTRA_INFO
681 extern GraphicDevice ctfb;
682 extern int get_boot_mode(void);
683
684 void video_get_info_str (int line_number, char *info)
685 {
686         /* init video info strings for graphic console */
687         PPC4xx_SYS_INFO sys_info;
688         char rev;
689         int i,boot;
690         unsigned long pvr;
691         char buf[64];
692         char buf1[32], buf2[32], buf3[32], buf4[32];
693         char cpustr[16];
694         char *s, *e, bc;
695         switch (line_number)
696         {
697         case 2:
698                 /* CPU and board infos */
699                 pvr=get_pvr();
700                 get_sys_info (&sys_info);
701                 switch (pvr) {
702                         case PVR_405GP_RB: rev='B'; break;
703                         case PVR_405GP_RC: rev='C'; break;
704                         case PVR_405GP_RD: rev='D'; break;
705                         case PVR_405GP_RE: rev='E'; break;
706                         case PVR_405GPR_RB: rev='B'; break;
707                         default:           rev='?'; break;
708                 }
709                 if(pvr==PVR_405GPR_RB)
710                         sprintf(cpustr,"PPC405GPr %c",rev);
711                 else
712                         sprintf(cpustr,"PPC405GP %c",rev);
713                 /* Board info */
714                 i=0;
715                 s=getenv ("serial#");
716 #ifdef CONFIG_PIP405
717                 if (!s || strncmp (s, "PIP405", 6)) {
718                         sprintf(buf,"### No HW ID - assuming PIP405");
719                 }
720 #endif
721 #ifdef CONFIG_MIP405
722                 if (!s || strncmp (s, "MIP405", 6)) {
723                         sprintf(buf,"### No HW ID - assuming MIP405");
724                 }
725 #endif
726                 else {
727                         for (e = s; *e; ++e) {
728                                 if (*e == ' ')
729                                         break;
730                         }
731                         for (; s < e; ++s) {
732                                 if (*s == '_') {
733                                         ++s;
734                                         break;
735                                 }
736                                 buf[i++] = *s;
737                         }
738                         sprintf(&buf[i]," SN ");
739                         i+=4;
740                         for (; s < e; ++s) {
741                                 buf[i++] = *s;
742                         }
743                         buf[i++]=0;
744                 }
745                 sprintf (info," %s %s %s MHz (%s/%s/%s MHz)",
746                         buf, cpustr,
747                         strmhz (buf1, gd->cpu_clk),
748                         strmhz (buf2, sys_info.freqPLB),
749                         strmhz (buf3, sys_info.freqPLB / sys_info.pllOpbDiv),
750                         strmhz (buf4, sys_info.freqPLB / sys_info.pllExtBusDiv));
751                 return;
752         case 3:
753                 /* Memory Info */
754                 boot = get_boot_mode();
755                 bc = in8 (CONFIG_PORT_ADDR);
756                 sprintf(info, " %luMB RAM, %luMB Flash Cfg 0x%02X %s %s",
757                         gd->bd->bi_memsize / 0x100000,
758                         gd->bd->bi_flashsize / 0x100000,
759                         bc,
760                         (boot & BOOT_MPS) ? "MPS boot" : "Flash boot",
761                         ctfb.modeIdent);
762                 return;
763         case 1:
764                 sprintf (buf, "%s",CONFIG_IDENT_STRING);
765                 sprintf (info, " %s", &buf[1]);
766                 return;
767     }
768     /* no more info lines */
769     *info = 0;
770     return;
771 }
772 #endif /* CONFIG_CONSOLE_EXTRA_INFO */
773
774 #endif /* CONFIG_VIDEO */