]> git.sur5r.net Git - u-boot/blob - board/mpl/common/common_util.c
* Patches by David Müller, 12 Jun 2003:
[u-boot] / 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 <devices.h>
33 #include <pci.h>
34
35 #ifdef CONFIG_PIP405
36 #include "../pip405/pip405.h"
37 #include <405gp_pci.h>
38 #endif
39 #ifdef CONFIG_MIP405
40 #include "../mip405/mip405.h"
41 #include <405gp_pci.h>
42 #endif
43
44 extern int  gunzip (void *, int, unsigned char *, int *);
45 extern int mem_test(unsigned long start, unsigned long ramsize, int quiet);
46
47 #define I2C_BACKUP_ADDR 0x7C00 /* 0x200 bytes for backup */
48 #if defined(CONFIG_PIP405) || defined(CONFIG_MIP405)
49 #define IMAGE_SIZE 0x80000
50 #elif defined(CONFIG_VCMA9)
51 #define IMAGE_SIZE 0x40000              /* ugly, but it works for now */
52 #endif
53
54 extern flash_info_t flash_info[];       /* info for FLASH chips */
55
56 static image_header_t header;
57
58
59
60 int mpl_prg(unsigned long src,unsigned long size)
61 {
62         unsigned long start;
63         flash_info_t *info;
64         int i,rc;
65 #if defined(CONFIG_PIP405) || defined(CONFIG_MIP405)
66         char *copystr = (char *)src;
67         unsigned long *magic = (unsigned long *)src;
68 #endif
69
70         info = &flash_info[0];
71
72 #if defined(CONFIG_PIP405) || defined(CONFIG_MIP405)
73         if(ntohl(magic[0]) != IH_MAGIC) {
74                 printf("Bad Magic number\n");
75                 return -1;
76         }
77         /* some more checks before we delete the Flash... */
78         /* Checking the ISO_STRING prevents to program a
79          * wrong Firmware Image into the flash.
80          */
81         i=4; /* skip Magic number */
82         while(1) {
83                 if(strncmp(&copystr[i],"MEV-",4)==0)
84                         break;
85                 if(i++>=0x100) {
86                         printf("Firmware Image for unknown Target\n");
87                         return -1;
88                 }
89         }
90         /* we have the ISO STRING, check */
91         if(strncmp(&copystr[i],CONFIG_ISO_STRING,sizeof(CONFIG_ISO_STRING)-1)!=0) {
92                 printf("Wrong Firmware Image: %s\n",&copystr[i]);
93                 return -1;
94         }
95         start = 0 - size;
96         for(i=info->sector_count-1;i>0;i--)
97         {
98                 info->protect[i] = 0; /* unprotect this sector */
99                 if(start>=info->start[i])
100                 break;
101         }
102         /* set-up flash location */
103         /* now erase flash */
104         printf("Erasing at %lx (sector %d) (start %lx)\n",
105                                 start,i,info->start[i]);
106         flash_erase (info, i, info->sector_count-1);
107
108 #elif defined(CONFIG_VCMA9)
109         start = 0;
110         for (i = 0; i <info->sector_count; i++)
111         {
112                 info->protect[i] = 0; /* unprotect this sector */
113                 if (size < info->start[i])
114                     break;
115         }
116         /* set-up flash location */
117         /* now erase flash */
118         printf("Erasing at %lx (sector %d) (start %lx)\n",
119                                 start,0,info->start[0]);
120         flash_erase (info, 0, i);
121
122 #endif
123         printf("flash erased, programming from 0x%lx 0x%lx Bytes\n",src,size);
124         if ((rc = flash_write ((uchar *)src, start, size)) != 0) {
125                 puts ("ERROR ");
126                 flash_perror (rc);
127                 return (1);
128         }
129         puts ("OK programming done\n");
130         return 0;
131 }
132
133
134 int mpl_prg_image(unsigned long ld_addr)
135 {
136         unsigned long data,len,checksum;
137         image_header_t *hdr=&header;
138         /* Copy header so we can blank CRC field for re-calculation */
139         memcpy (&header, (char *)ld_addr, sizeof(image_header_t));
140         if (ntohl(hdr->ih_magic)  != IH_MAGIC) {
141                 printf ("Bad Magic Number\n");
142                 return 1;
143         }
144         print_image_hdr(hdr);
145         if (hdr->ih_os  != IH_OS_U_BOOT) {
146                 printf ("No U-Boot Image\n");
147                 return 1;
148         }
149         if (hdr->ih_type  != IH_TYPE_FIRMWARE) {
150                 printf ("No Firmware Image\n");
151                 return 1;
152         }
153         data = (ulong)&header;
154         len  = sizeof(image_header_t);
155         checksum = ntohl(hdr->ih_hcrc);
156         hdr->ih_hcrc = 0;
157         if (crc32 (0, (char *)data, len) != checksum) {
158                 printf ("Bad Header Checksum\n");
159                 return 1;
160         }
161         data = ld_addr + sizeof(image_header_t);
162         len  = ntohl(hdr->ih_size);
163         printf ("Verifying Checksum ... ");
164         if (crc32 (0, (char *)data, len) != ntohl(hdr->ih_dcrc)) {
165                 printf ("Bad Data CRC\n");
166                 return 1;
167         }
168         switch (hdr->ih_comp) {
169         case IH_COMP_NONE:
170                 break;
171         case IH_COMP_GZIP:
172                 printf ("  Uncompressing  ... ");
173                 if (gunzip ((void *)(data+0x100000), 0x400000,
174                             (uchar *)data, (int *)&len) != 0) {
175                         printf ("GUNZIP ERROR\n");
176                         return 1;
177                 }
178                 data+=0x100000;
179                 break;
180         default:
181                 printf ("   Unimplemented compression type %d\n", hdr->ih_comp);
182                 return 1;
183         }
184
185         printf ("  OK\n");
186         return(mpl_prg(data,len));
187 }
188
189
190 void get_backup_values(backup_t *buf)
191 {
192         i2c_read(CFG_DEF_EEPROM_ADDR, I2C_BACKUP_ADDR,2,(void *)buf,sizeof(backup_t));
193 }
194
195 void set_backup_values(int overwrite)
196 {
197         backup_t back;
198         int i;
199
200         get_backup_values(&back);
201         if(!overwrite) {
202                 if(strncmp(back.signature,"MPL\0",4)==0) {
203                         printf("Not possible to write Backup\n");
204                         return;
205                 }
206         }
207         memcpy(back.signature,"MPL\0",4);
208         i = getenv_r("serial#",back.serial_name,16);
209         if(i < 0) {
210                 printf("Not possible to write Backup\n");
211                 return;
212         }
213         back.serial_name[16]=0;
214         i = getenv_r("ethaddr",back.eth_addr,20);
215         if(i < 0) {
216                 printf("Not possible to write Backup\n");
217                 return;
218         }
219         back.eth_addr[20]=0;
220         i2c_write(CFG_DEF_EEPROM_ADDR, I2C_BACKUP_ADDR,2,(void *)&back,sizeof(backup_t));
221 }
222
223 void clear_env_values(void)
224 {
225         backup_t back;
226         unsigned char env_crc[4];
227
228         memset(&back,0xff,sizeof(backup_t));
229         memset(env_crc,0x00,4);
230         i2c_write(CFG_DEF_EEPROM_ADDR,I2C_BACKUP_ADDR,2,(void *)&back,sizeof(backup_t));
231         i2c_write(CFG_DEF_EEPROM_ADDR,CFG_ENV_OFFSET,2,(void *)env_crc,4);
232 }
233
234 /*
235  * check crc of "older" environment
236  */
237 int check_env_old_size(ulong oldsize)
238 {
239         ulong crc, len, new;
240         unsigned off;
241         uchar buf[64];
242
243         /* read old CRC */
244         eeprom_read (CFG_DEF_EEPROM_ADDR,
245                      CFG_ENV_OFFSET,
246                      (uchar *)&crc, sizeof(ulong));
247
248         new = 0;
249         len = oldsize;
250         off = sizeof(long);
251         len = oldsize-off;
252         while (len > 0) {
253                 int n = (len > sizeof(buf)) ? sizeof(buf) : len;
254
255                 eeprom_read (CFG_DEF_EEPROM_ADDR, CFG_ENV_OFFSET+off, buf, n);
256                 new = crc32 (new, buf, n);
257                 len -= n;
258                 off += n;
259         }
260
261         return (crc == new);
262 }
263
264 static ulong oldsizes[] = {
265         0x200,
266         0x800,
267         0
268 };
269
270 void copy_old_env(ulong size)
271 {
272         uchar name_buf[64];
273         uchar value_buf[0x800];
274         uchar c;
275         ulong len;
276         unsigned off;
277         uchar *name, *value;
278
279         name=&name_buf[0];
280         value=&value_buf[0];
281         len=size;
282         off = sizeof(long);
283         while (len > off) {
284                 eeprom_read (CFG_DEF_EEPROM_ADDR, CFG_ENV_OFFSET+off, &c, 1);
285                 if(c != '=') {
286                         *name++=c;
287                         off++;
288                 }
289                 else {
290                         *name++='\0';
291                         off++;
292                         do {
293                                 eeprom_read (CFG_DEF_EEPROM_ADDR, CFG_ENV_OFFSET+off, &c, 1);
294                                 *value++=c;
295                                 off++;
296                                 if(c == '\0')
297                                         break;
298                         } while(len > off);
299                         name=&name_buf[0];
300                         value=&value_buf[0];
301                         if(strncmp(name,"baudrate",8)!=0) {
302                                 setenv(name,value);
303                         }
304
305                 }
306         }
307 }
308
309
310 void check_env(void)
311 {
312         unsigned char *s;
313         int i=0;
314         char buf[32];
315         backup_t back;
316
317         s=getenv("serial#");
318         if(!s) {
319                 while(oldsizes[i]) {
320                         if(check_env_old_size(oldsizes[i]))
321                                 break;
322                         i++;
323                 }
324                 if(!oldsizes[i]) {
325                         /* no old environment has been found */
326                         get_backup_values (&back);
327                         if (strncmp (back.signature, "MPL\0", 4) == 0) {
328                                 sprintf (buf, "%s", back.serial_name);
329                                 setenv ("serial#", buf);
330                                 sprintf (buf, "%s", back.eth_addr);
331                                 setenv ("ethaddr", buf);
332                                 printf ("INFO:  serial# and ethaddr recovered, use saveenv\n");
333                                 return;
334                         }
335                 }
336                 else {
337                         copy_old_env(oldsizes[i]);
338                         printf ("INFO:  old environment ajusted, use saveenv\n");
339                 }
340         }
341         else {
342                 /* check if back up is set */
343                 get_backup_values(&back);
344                 if(strncmp(back.signature,"MPL\0",4)!=0) {
345                         set_backup_values(0);
346                 }
347         }
348 }
349
350
351
352 extern device_t *stdio_devices[];
353 extern char *stdio_names[];
354
355 void show_stdio_dev(void)
356 {
357         /* Print information */
358         printf ("In:    ");
359         if (stdio_devices[stdin] == NULL) {
360                 printf ("No input devices available!\n");
361         } else {
362                 printf ("%s\n", stdio_devices[stdin]->name);
363         }
364
365         printf ("Out:   ");
366         if (stdio_devices[stdout] == NULL) {
367                 printf ("No output devices available!\n");
368         } else {
369                 printf ("%s\n", stdio_devices[stdout]->name);
370         }
371
372         printf ("Err:   ");
373         if (stdio_devices[stderr] == NULL) {
374                 printf ("No error devices available!\n");
375         } else {
376                 printf ("%s\n", stdio_devices[stderr]->name);
377         }
378 }
379
380 /* ------------------------------------------------------------------------- */
381
382         /* switches the cs0 and the cs1 to the locations.
383            When boot is TRUE, the the mapping is switched
384            to the boot configuration, If it is FALSE, the
385            flash will be switched in the boot area */
386
387 #undef SW_CS_DBG
388 #ifdef SW_CS_DBG
389 #define SW_CS_PRINTF(fmt,args...)       printf (fmt ,##args)
390 #else
391 #define SW_CS_PRINTF(fmt,args...)
392 #endif
393
394 #if defined(CONFIG_PIP405) || defined(CONFIG_MIP405)
395 int switch_cs(unsigned char boot)
396 {
397         unsigned long pbcr;
398         int mode;
399
400         mode=get_boot_mode();
401         mtdcr(ebccfga, pb0cr);
402         pbcr = mfdcr (ebccfgd);
403         if (mode & BOOT_MPS) {
404                 /* Boot width = 8 bit MPS Boot, set up MPS on CS0 */
405                 /* we need only to switch if boot from MPS */
406                 /* printf(" MPS boot mode detected. ");*/
407                 /* printf("cs0 cfg: %lx\n",pbcr); */
408                 if(boot) {
409                         /* switch to boot configuration */
410                         /* this is a 8bit boot, switch cs0 to flash location */
411                         SW_CS_PRINTF("switch to boot mode (MPS on High address\n");
412                         pbcr&=0x000FFFFF; /*mask base address of the cs0 */
413                         pbcr|=(FLASH_BASE0_PRELIM & 0xFFF00000);
414                         mtdcr(ebccfga, pb0cr);
415                         mtdcr(ebccfgd, pbcr);
416                         SW_CS_PRINTF("  new cs0 cfg: %lx\n",pbcr);
417                         mtdcr(ebccfga, pb1cr); /* get cs1 config reg (flash) */
418                         pbcr = mfdcr(ebccfgd);
419                         SW_CS_PRINTF(" old cs1 cfg: %lx\n",pbcr);
420                         pbcr&=0x000FFFFF; /*mask base address of the cs1 */
421                         pbcr|=(MULTI_PURPOSE_SOCKET_ADDR & 0xFFF00000);
422                         mtdcr(ebccfga, pb1cr);
423                         mtdcr(ebccfgd, pbcr);
424                         SW_CS_PRINTF("  new cs1 cfg: %lx, MPS is on High Address\n",pbcr);
425                 }
426                 else {
427                         /* map flash to boot area, */
428                         SW_CS_PRINTF("map Flash to boot area\n");
429                         pbcr&=0x000FFFFF; /*mask base address of the cs0 */
430                         pbcr|=(MULTI_PURPOSE_SOCKET_ADDR & 0xFFF00000);
431                         mtdcr(ebccfga, pb0cr);
432                         mtdcr(ebccfgd, pbcr);
433                         SW_CS_PRINTF("  new cs0 cfg: %lx\n",pbcr);
434                         mtdcr(ebccfga, pb1cr); /* get cs1 config reg (flash) */
435                         pbcr = mfdcr(ebccfgd);
436                         SW_CS_PRINTF("  cs1 cfg: %lx\n",pbcr);
437                         pbcr&=0x000FFFFF; /*mask base address of the cs1 */
438                         pbcr|=(FLASH_BASE0_PRELIM & 0xFFF00000);
439                         mtdcr(ebccfga, pb1cr);
440                         mtdcr(ebccfgd, pbcr);
441                         SW_CS_PRINTF("  new cs1 cfg: %lx Flash is on High Address\n",pbcr);
442                 }
443                 return 1;
444         }
445         else {
446                 SW_CS_PRINTF("Normal boot, no switching necessary\n");
447                 return 0;
448         }
449
450 }
451
452 int get_boot_mode(void)
453 {
454         unsigned long pbcr;
455         int res = 0;
456         pbcr = mfdcr (strap);
457         if ((pbcr & PSR_ROM_WIDTH_MASK) == 0) 
458                 /* boot via MPS or MPS mapping */
459                 res = BOOT_MPS;
460         if(pbcr & PSR_ROM_LOC) 
461                 /* boot via PCI.. */
462                 res |= BOOT_PCI;
463          return res;
464 }
465
466 /* Setup cs0 parameter finally.
467    Map the flash high (in boot area)
468    This code can only be executed from SDRAM (after relocation).
469 */
470 void setup_cs_reloc(void)
471 {
472         unsigned long pbcr;
473         /* Since we are relocated, we can set-up the CS finaly
474          * but first of all, switch off PCI mapping (in case it was a PCI boot) */
475         out32r(PMM0MA,0L);
476         icache_enable (); /* we are relocated */
477         /* for PCI Boot, we have to set-up the remaining CS correctly */
478         pbcr = mfdcr (strap);
479         if(pbcr & PSR_ROM_LOC) {
480                 /* boot via PCI.. */
481                 if ((pbcr & PSR_ROM_WIDTH_MASK) == 0) {
482                 /* Boot width = 8 bit MPS Boot, set up MPS on CS0 */
483                         #ifdef DEBUG
484                         printf("Mapping MPS to CS0 @ 0x%lx\n",(MPS_CR_B & 0xfff00000));
485                         #endif
486                         mtdcr (ebccfga, pb0ap);
487                         mtdcr (ebccfgd, MPS_AP);
488                         mtdcr (ebccfga, pb0cr);
489                         mtdcr (ebccfgd, MPS_CR_B);
490                 }
491                 else {
492                         /* Flash boot, set up the Flash on CS0 */
493                         #ifdef DEBUG
494                         printf("Mapping Flash to CS0 @ 0x%lx\n",(FLASH_CR_B & 0xfff00000));
495                         #endif
496                         mtdcr (ebccfga, pb0ap);
497                         mtdcr (ebccfgd, FLASH_AP);
498                         mtdcr (ebccfga, pb0cr);
499                         mtdcr (ebccfgd, FLASH_CR_B);
500                 }
501         }
502         switch_cs(0); /* map Flash High */
503 }
504
505
506 #elif defined(CONFIG_VCMA9)
507 int switch_cs(unsigned char boot)
508 {
509     return 0;
510 }
511 #endif /* CONFIG_VCMA9 */
512
513 int do_mplcommon(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
514 {
515         ulong size,src,ld_addr;
516         int result;
517         backup_t back;
518         src = MULTI_PURPOSE_SOCKET_ADDR;
519         size = IMAGE_SIZE;
520
521         if (strcmp(argv[1], "flash") == 0)
522         {
523 #if (CONFIG_COMMANDS & CFG_CMD_FDC)
524                 if (strcmp(argv[2], "floppy") == 0) {
525                         char *local_args[3];
526                         extern int do_fdcboot (cmd_tbl_t *, int, int, char *[]);
527                         printf ("\nupdating bootloader image from floppy\n");
528                         local_args[0] = argv[0];
529                         if(argc==4) {
530                                 local_args[1] = argv[3];
531                                 local_args[2] = NULL;
532                                 ld_addr=simple_strtoul(argv[3], NULL, 16);
533                                 result=do_fdcboot(cmdtp, 0, 2, local_args);
534                         }
535                         else {
536                                 local_args[1] = NULL;
537                                 ld_addr=CFG_LOAD_ADDR;
538                                 result=do_fdcboot(cmdtp, 0, 1, local_args);
539                         }
540                         result=mpl_prg_image(ld_addr);
541                         return result;
542                 }
543 #endif /* (CONFIG_COMMANDS & CFG_CMD_FDC) */
544                 if (strcmp(argv[2], "mem") == 0) {
545                         if(argc==4) {
546                                 ld_addr=simple_strtoul(argv[3], NULL, 16);
547                         }
548                         else {
549                                 ld_addr=load_addr;
550                         }
551                         printf ("\nupdating bootloader image from memory at %lX\n",ld_addr);
552                         result=mpl_prg_image(ld_addr);
553                         return result;
554                 }
555                 if (strcmp(argv[2], "mps") == 0) {
556                         printf ("\nupdating bootloader image from MPS\n");
557                         result=mpl_prg(src,size);
558                         return result;
559                 }
560         }
561         if (strcmp(argv[1], "mem") == 0)
562         {
563                 result=0;
564                 if(argc==3)
565                 {
566                         result = (int)simple_strtol(argv[2], NULL, 16);
567             }
568             src=(unsigned long)&result;
569             src-=CFG_MEMTEST_START;
570             src-=(100*1024); /* - 100k */
571             src&=0xfff00000;
572             size=0;
573             do {
574                 size++;
575                         printf("\n\nPass %ld\n",size);
576                         mem_test(CFG_MEMTEST_START,src,1);
577                         if(ctrlc())
578                                 break;
579                         if(result>0)
580                                 result--;
581
582                 }while(result);
583                 return 0;
584         }
585         if (strcmp(argv[1], "clearenvvalues") == 0)
586         {
587                 if (strcmp(argv[2], "yes") == 0)
588                 {
589                         clear_env_values();
590                         return 0;
591                 }
592         }
593         if (strcmp(argv[1], "getback") == 0) {
594                 get_backup_values(&back);
595                 back.signature[3]=0;
596                 back.serial_name[16]=0;
597                 back.eth_addr[20]=0;
598                 printf("GetBackUp: signature: %s\n",back.signature);
599                 printf("           serial#:   %s\n",back.serial_name);
600                 printf("           ethaddr:   %s\n",back.eth_addr);
601                 return 0;
602         }
603         if (strcmp(argv[1], "setback") == 0) {
604                 set_backup_values(1);
605                 return 0;
606         }
607         printf("Usage:\n%s\n", cmdtp->usage);
608         return 1;
609 }
610
611
612 #if (CONFIG_COMMANDS & CFG_CMD_DOC)
613 extern void doc_probe(ulong physadr);
614 void doc_init (void)
615 {
616   doc_probe(MULTI_PURPOSE_SOCKET_ADDR);
617 }
618 #endif
619
620
621 #ifdef CONFIG_VIDEO
622 /******************************************************
623  * Routines to display the Board information
624  * to the screen (since the VGA will be initialized as last,
625  * we must resend the infos)
626  */
627
628 #ifdef CONFIG_CONSOLE_EXTRA_INFO
629 extern GraphicDevice ctfb;
630
631 void video_get_info_str (int line_number, char *info)
632 {
633         /* init video info strings for graphic console */
634         DECLARE_GLOBAL_DATA_PTR;
635         PPC405_SYS_INFO sys_info;
636         char rev;
637         int i,boot;
638         unsigned long pvr;
639         char buf[64];
640         char tmp[16];
641         char cpustr[16];
642         unsigned char *s, *e, bc;
643         switch (line_number)
644         {
645         case 2:
646                 /* CPU and board infos */
647                 pvr=get_pvr();
648                 get_sys_info (&sys_info);
649                 switch (pvr) {
650                         case PVR_405GP_RB: rev='B'; break;
651                         case PVR_405GP_RC: rev='C'; break;
652                         case PVR_405GP_RD: rev='D'; break;
653                         case PVR_405GP_RE: rev='E'; break;
654                         case PVR_405GPR_RB: rev='B'; break;
655                         default:           rev='?'; break;
656                 }
657                 if(pvr==PVR_405GPR_RB)
658                         sprintf(cpustr,"PPC405GPr %c",rev);
659                 else
660                         sprintf(cpustr,"PPC405GP %c",rev);
661                 /* Board info */
662                 i=0;
663                 s=getenv ("serial#");
664 #ifdef CONFIG_PIP405
665                 if (!s || strncmp (s, "PIP405", 6)) {
666                         sprintf(buf,"### No HW ID - assuming PIP405");
667                 }
668 #endif
669 #ifdef CONFIG_MIP405
670                 if (!s || strncmp (s, "MIP405", 6)) {
671                         sprintf(buf,"### No HW ID - assuming MIP405");
672                 }
673 #endif
674                 else {
675                         for (e = s; *e; ++e) {
676                                 if (*e == ' ')
677                                         break;
678                         }
679                         for (; s < e; ++s) {
680                                 if (*s == '_') {
681                                         ++s;
682                                         break;
683                                 }
684                                 buf[i++]=*s;
685                         }
686                         sprintf(&buf[i]," SN ");
687                         i+=4;
688                         for (; s < e; ++s) {
689                                 buf[i++]=*s;
690                         }
691                         buf[i++]=0;
692                 }
693                 sprintf (info," %s %s %s MHz (%lu/%lu/%lu MHz)",
694                         buf, cpustr,
695                         strmhz (tmp, gd->cpu_clk), sys_info.freqPLB / 1000000,
696                         sys_info.freqPLB / sys_info.pllOpbDiv / 1000000,
697                         sys_info.freqPLB / sys_info.pllExtBusDiv / 1000000);
698                 return;
699         case 3:
700                 /* Memory Info */
701                 boot = get_boot_mode();
702                 bc = in8 (CONFIG_PORT_ADDR);
703                 sprintf(info, " %luMB RAM, %luMB Flash Cfg 0x%02X %s %s",
704                         gd->bd->bi_memsize / 0x100000,
705                         gd->bd->bi_flashsize / 0x100000,
706                         bc,
707                         (boot & BOOT_MPS) ? "MPS boot" : "Flash boot",
708                         ctfb.modeIdent);
709                 return;
710         case 1:
711                 sprintf (buf, "%s",CONFIG_IDENT_STRING);
712                 sprintf (info, " %s", &buf[1]);
713                 return;
714     }
715     /* no more info lines */
716     *info = 0;
717     return;
718 }
719 #endif /* CONFIG_CONSOLE_EXTRA_INFO */
720
721 #endif /* CONFIG_VIDEO */