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