common_util.c 17 KB

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