cmd_bdinfo.c 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425
  1. /*
  2. * (C) Copyright 2003
  3. * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
  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. * Boot support
  25. */
  26. #include <common.h>
  27. #include <command.h>
  28. #include <net.h> /* for print_IPaddr */
  29. DECLARE_GLOBAL_DATA_PTR;
  30. static void print_num(const char *, ulong);
  31. #ifndef CONFIG_ARM /* PowerPC and other */
  32. #ifdef CONFIG_PPC
  33. static void print_str(const char *, const char *);
  34. int do_bdinfo ( cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
  35. {
  36. int i;
  37. bd_t *bd = gd->bd;
  38. char buf[32];
  39. #ifdef DEBUG
  40. print_num ("bd address", (ulong)bd );
  41. #endif
  42. print_num ("memstart", bd->bi_memstart );
  43. print_num ("memsize", bd->bi_memsize );
  44. print_num ("flashstart", bd->bi_flashstart );
  45. print_num ("flashsize", bd->bi_flashsize );
  46. print_num ("flashoffset", bd->bi_flashoffset );
  47. print_num ("sramstart", bd->bi_sramstart );
  48. print_num ("sramsize", bd->bi_sramsize );
  49. #if defined(CONFIG_5xx) || defined(CONFIG_8xx) || \
  50. defined(CONFIG_8260) || defined(CONFIG_E500)
  51. print_num ("immr_base", bd->bi_immr_base );
  52. #endif
  53. print_num ("bootflags", bd->bi_bootflags );
  54. #if defined(CONFIG_405GP) || defined(CONFIG_405CR) || \
  55. defined(CONFIG_405EP) || defined(CONFIG_XILINX_ML300) || \
  56. defined(CONFIG_440EP) || defined(CONFIG_440GR) || \
  57. defined(CONFIG_440EPX) || defined(CONFIG_440GRX) || \
  58. defined(CONFIG_440SP) || defined(CONFIG_440SPE)
  59. print_str ("procfreq", strmhz(buf, bd->bi_procfreq));
  60. print_str ("plb_busfreq", strmhz(buf, bd->bi_plb_busfreq));
  61. #if defined(CONFIG_405GP) || defined(CONFIG_405EP) || defined(CONFIG_XILINX_ML300) || \
  62. defined(CONFIG_440EP) || defined(CONFIG_440GR) || defined(CONFIG_440SPE) || \
  63. defined(CONFIG_440EPX) || defined(CONFIG_440GRX)
  64. print_str ("pci_busfreq", strmhz(buf, bd->bi_pci_busfreq));
  65. #endif
  66. #else /* ! CONFIG_405GP, CONFIG_405CR, CONFIG_405EP, CONFIG_XILINX_ML300, CONFIG_440EP CONFIG_440GR */
  67. #if defined(CONFIG_CPM2)
  68. print_str ("vco", strmhz(buf, bd->bi_vco));
  69. print_str ("sccfreq", strmhz(buf, bd->bi_sccfreq));
  70. print_str ("brgfreq", strmhz(buf, bd->bi_brgfreq));
  71. #endif
  72. print_str ("intfreq", strmhz(buf, bd->bi_intfreq));
  73. #if defined(CONFIG_CPM2)
  74. print_str ("cpmfreq", strmhz(buf, bd->bi_cpmfreq));
  75. #endif
  76. print_str ("busfreq", strmhz(buf, bd->bi_busfreq));
  77. #endif /* CONFIG_405GP, CONFIG_405CR, CONFIG_405EP, CONFIG_XILINX_ML300, CONFIG_440EP CONFIG_440GR */
  78. #if defined(CONFIG_MPC8220)
  79. print_str ("inpfreq", strmhz(buf, bd->bi_inpfreq));
  80. print_str ("flbfreq", strmhz(buf, bd->bi_flbfreq));
  81. print_str ("pcifreq", strmhz(buf, bd->bi_pcifreq));
  82. print_str ("vcofreq", strmhz(buf, bd->bi_vcofreq));
  83. print_str ("pevfreq", strmhz(buf, bd->bi_pevfreq));
  84. #endif
  85. puts ("ethaddr =");
  86. for (i=0; i<6; ++i) {
  87. printf ("%c%02X", i ? ':' : ' ', bd->bi_enetaddr[i]);
  88. }
  89. #if defined(CONFIG_HAS_ETH1)
  90. puts ("\neth1addr =");
  91. for (i=0; i<6; ++i) {
  92. printf ("%c%02X", i ? ':' : ' ', bd->bi_enet1addr[i]);
  93. }
  94. #endif
  95. #if defined(CONFIG_HAS_ETH2)
  96. puts ("\neth2addr =");
  97. for (i=0; i<6; ++i) {
  98. printf ("%c%02X", i ? ':' : ' ', bd->bi_enet2addr[i]);
  99. }
  100. #endif
  101. #if defined(CONFIG_HAS_ETH3)
  102. puts ("\neth3addr =");
  103. for (i=0; i<6; ++i) {
  104. printf ("%c%02X", i ? ':' : ' ', bd->bi_enet3addr[i]);
  105. }
  106. #endif
  107. #ifdef CONFIG_HERMES
  108. print_str ("ethspeed", strmhz(buf, bd->bi_ethspeed));
  109. #endif
  110. puts ("\nIP addr = "); print_IPaddr (bd->bi_ip_addr);
  111. printf ("\nbaudrate = %6ld bps\n", bd->bi_baudrate );
  112. return 0;
  113. }
  114. #elif defined(CONFIG_NIOS) /* NIOS*/
  115. int do_bdinfo ( cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
  116. {
  117. int i;
  118. bd_t *bd = gd->bd;
  119. print_num ("memstart", (ulong)bd->bi_memstart);
  120. print_num ("memsize", (ulong)bd->bi_memsize);
  121. print_num ("flashstart", (ulong)bd->bi_flashstart);
  122. print_num ("flashsize", (ulong)bd->bi_flashsize);
  123. print_num ("flashoffset", (ulong)bd->bi_flashoffset);
  124. puts ("ethaddr =");
  125. for (i=0; i<6; ++i) {
  126. printf ("%c%02X", i ? ':' : ' ', bd->bi_enetaddr[i]);
  127. }
  128. puts ("\nip_addr = ");
  129. print_IPaddr (bd->bi_ip_addr);
  130. printf ("\nbaudrate = %ld bps\n", bd->bi_baudrate);
  131. return 0;
  132. }
  133. #elif defined(CONFIG_NIOS2) /* Nios-II */
  134. int do_bdinfo ( cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
  135. {
  136. #if defined(CONFIG_CMD_NET)
  137. int i;
  138. #endif
  139. bd_t *bd = gd->bd;
  140. print_num ("mem start", (ulong)bd->bi_memstart);
  141. print_num ("mem size", (ulong)bd->bi_memsize);
  142. print_num ("flash start", (ulong)bd->bi_flashstart);
  143. print_num ("flash size", (ulong)bd->bi_flashsize);
  144. print_num ("flash offset", (ulong)bd->bi_flashoffset);
  145. #if defined(CFG_SRAM_BASE)
  146. print_num ("sram start", (ulong)bd->bi_sramstart);
  147. print_num ("sram size", (ulong)bd->bi_sramsize);
  148. #endif
  149. #if defined(CONFIG_CMD_NET)
  150. puts ("ethaddr =");
  151. for (i=0; i<6; ++i) {
  152. printf ("%c%02X", i ? ':' : ' ', bd->bi_enetaddr[i]);
  153. }
  154. puts ("\nip_addr = ");
  155. print_IPaddr (bd->bi_ip_addr);
  156. #endif
  157. printf ("\nbaudrate = %ld bps\n", bd->bi_baudrate);
  158. return 0;
  159. }
  160. #elif defined(CONFIG_MICROBLAZE) /* ! PPC, which leaves Microblaze */
  161. int do_bdinfo ( cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
  162. {
  163. int i;
  164. bd_t *bd = gd->bd;
  165. print_num ("mem start ", (ulong)bd->bi_memstart);
  166. print_num ("mem size ", (ulong)bd->bi_memsize);
  167. print_num ("flash start ", (ulong)bd->bi_flashstart);
  168. print_num ("flash size ", (ulong)bd->bi_flashsize);
  169. print_num ("flash offset ", (ulong)bd->bi_flashoffset);
  170. #if defined(CFG_SRAM_BASE)
  171. print_num ("sram start ", (ulong)bd->bi_sramstart);
  172. print_num ("sram size ", (ulong)bd->bi_sramsize);
  173. #endif
  174. #if defined(CONFIG_CMD_NET)
  175. puts ("ethaddr =");
  176. for (i=0; i<6; ++i) {
  177. printf ("%c%02X", i ? ':' : ' ', bd->bi_enetaddr[i]);
  178. }
  179. puts ("\nip_addr = ");
  180. print_IPaddr (bd->bi_ip_addr);
  181. #endif
  182. printf ("\nbaudrate = %d bps\n", (ulong)bd->bi_baudrate);
  183. return 0;
  184. }
  185. #elif defined(CONFIG_SPARC) /* SPARC */
  186. int do_bdinfo(cmd_tbl_t * cmdtp, int flag, int argc, char *argv[])
  187. {
  188. bd_t *bd = gd->bd;
  189. #if defined(CONFIG_CMD_NET)
  190. int i;
  191. #endif
  192. #ifdef DEBUG
  193. print_num("bd address ", (ulong) bd);
  194. #endif
  195. print_num("memstart ", bd->bi_memstart);
  196. print_num("memsize ", bd->bi_memsize);
  197. print_num("flashstart ", bd->bi_flashstart);
  198. print_num("CFG_MONITOR_BASE ", CFG_MONITOR_BASE);
  199. print_num("CFG_ENV_ADDR ", CFG_ENV_ADDR);
  200. printf("CFG_RELOC_MONITOR_BASE = 0x%lx (%d)\n", CFG_RELOC_MONITOR_BASE,
  201. CFG_MONITOR_LEN);
  202. printf("CFG_MALLOC_BASE = 0x%lx (%d)\n", CFG_MALLOC_BASE,
  203. CFG_MALLOC_LEN);
  204. printf("CFG_INIT_SP_OFFSET = 0x%lx (%d)\n", CFG_INIT_SP_OFFSET,
  205. CFG_STACK_SIZE);
  206. printf("CFG_PROM_OFFSET = 0x%lx (%d)\n", CFG_PROM_OFFSET,
  207. CFG_PROM_SIZE);
  208. printf("CFG_GBL_DATA_OFFSET = 0x%lx (%d)\n", CFG_GBL_DATA_OFFSET,
  209. CFG_GBL_DATA_SIZE);
  210. #if defined(CONFIG_CMD_NET)
  211. puts("ethaddr =");
  212. for (i = 0; i < 6; ++i) {
  213. printf("%c%02X", i ? ':' : ' ', bd->bi_enetaddr[i]);
  214. }
  215. puts("\nIP addr = ");
  216. print_IPaddr(bd->bi_ip_addr);
  217. #endif
  218. printf("\nbaudrate = %6ld bps\n", bd->bi_baudrate);
  219. return 0;
  220. }
  221. #elif defined(CONFIG_M68K) /* M68K */
  222. static void print_str(const char *, const char *);
  223. int do_bdinfo ( cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
  224. {
  225. int i;
  226. bd_t *bd = gd->bd;
  227. char buf[32];
  228. print_num ("memstart", (ulong)bd->bi_memstart);
  229. print_num ("memsize", (ulong)bd->bi_memsize);
  230. print_num ("flashstart", (ulong)bd->bi_flashstart);
  231. print_num ("flashsize", (ulong)bd->bi_flashsize);
  232. print_num ("flashoffset", (ulong)bd->bi_flashoffset);
  233. #if defined(CFG_INIT_RAM_ADDR)
  234. print_num ("sramstart", (ulong)bd->bi_sramstart);
  235. print_num ("sramsize", (ulong)bd->bi_sramsize);
  236. #endif
  237. #if defined(CFG_MBAR)
  238. print_num ("mbar", bd->bi_mbar_base);
  239. #endif
  240. print_str ("busfreq", strmhz(buf, bd->bi_busfreq));
  241. #ifdef CONFIG_PCI
  242. print_str ("pcifreq", strmhz(buf, bd->bi_pcifreq));
  243. #endif
  244. #ifdef CONFIG_EXTRA_CLOCK
  245. print_str ("flbfreq", strmhz(buf, bd->bi_flbfreq));
  246. print_str ("inpfreq", strmhz(buf, bd->bi_inpfreq));
  247. print_str ("vcofreq", strmhz(buf, bd->bi_vcofreq));
  248. #endif
  249. #if defined(CONFIG_CMD_NET)
  250. puts ("ethaddr =");
  251. for (i=0; i<6; ++i) {
  252. printf ("%c%02X", i ? ':' : ' ', bd->bi_enetaddr[i]);
  253. }
  254. #if defined(CONFIG_HAS_ETH1)
  255. puts ("\neth1addr =");
  256. for (i=0; i<6; ++i) {
  257. printf ("%c%02X", i ? ':' : ' ', bd->bi_enet1addr[i]);
  258. }
  259. #endif
  260. #if defined(CONFIG_HAS_ETH2)
  261. puts ("\neth2addr =");
  262. for (i=0; i<6; ++i) {
  263. printf ("%c%02X", i ? ':' : ' ', bd->bi_enet2addr[i]);
  264. }
  265. #endif
  266. #if defined(CONFIG_HAS_ETH3)
  267. puts ("\neth3addr =");
  268. for (i=0; i<6; ++i) {
  269. printf ("%c%02X", i ? ':' : ' ', bd->bi_enet3addr[i]);
  270. }
  271. #endif
  272. puts ("\nip_addr = ");
  273. print_IPaddr (bd->bi_ip_addr);
  274. #endif
  275. printf ("\nbaudrate = %d bps\n", bd->bi_baudrate);
  276. return 0;
  277. }
  278. #elif defined(CONFIG_BLACKFIN)
  279. int do_bdinfo(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
  280. {
  281. int i;
  282. bd_t *bd = gd->bd;
  283. printf("U-Boot = %s\n", bd->bi_r_version);
  284. printf("CPU = %s\n", bd->bi_cpu);
  285. printf("Board = %s\n", bd->bi_board_name);
  286. printf("VCO = %lu MHz\n", bd->bi_vco / 1000000);
  287. printf("CCLK = %lu MHz\n", bd->bi_cclk / 1000000);
  288. printf("SCLK = %lu MHz\n", bd->bi_sclk / 1000000);
  289. print_num("boot_params", (ulong)bd->bi_boot_params);
  290. print_num("memstart", (ulong)bd->bi_memstart);
  291. print_num("memsize", (ulong)bd->bi_memsize);
  292. print_num("flashstart", (ulong)bd->bi_flashstart);
  293. print_num("flashsize", (ulong)bd->bi_flashsize);
  294. print_num("flashoffset", (ulong)bd->bi_flashoffset);
  295. puts("ethaddr =");
  296. for (i = 0; i < 6; ++i)
  297. printf("%c%02X", i ? ':' : ' ', bd->bi_enetaddr[i]);
  298. puts("\nip_addr = ");
  299. print_IPaddr(bd->bi_ip_addr);
  300. printf("\nbaudrate = %d bps\n", bd->bi_baudrate);
  301. return 0;
  302. }
  303. #else /* ! PPC, which leaves MIPS */
  304. int do_bdinfo ( cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
  305. {
  306. int i;
  307. bd_t *bd = gd->bd;
  308. print_num ("boot_params", (ulong)bd->bi_boot_params);
  309. print_num ("memstart", (ulong)bd->bi_memstart);
  310. print_num ("memsize", (ulong)bd->bi_memsize);
  311. print_num ("flashstart", (ulong)bd->bi_flashstart);
  312. print_num ("flashsize", (ulong)bd->bi_flashsize);
  313. print_num ("flashoffset", (ulong)bd->bi_flashoffset);
  314. puts ("ethaddr =");
  315. for (i=0; i<6; ++i) {
  316. printf ("%c%02X", i ? ':' : ' ', bd->bi_enetaddr[i]);
  317. }
  318. puts ("\nip_addr = ");
  319. print_IPaddr (bd->bi_ip_addr);
  320. printf ("\nbaudrate = %d bps\n", bd->bi_baudrate);
  321. return 0;
  322. }
  323. #endif /* MIPS */
  324. #else /* ARM */
  325. int do_bdinfo ( cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
  326. {
  327. int i;
  328. bd_t *bd = gd->bd;
  329. print_num ("arch_number", bd->bi_arch_number);
  330. print_num ("env_t", (ulong)bd->bi_env);
  331. print_num ("boot_params", (ulong)bd->bi_boot_params);
  332. for (i=0; i<CONFIG_NR_DRAM_BANKS; ++i) {
  333. print_num("DRAM bank", i);
  334. print_num("-> start", bd->bi_dram[i].start);
  335. print_num("-> size", bd->bi_dram[i].size);
  336. }
  337. #if defined(CONFIG_CMD_NET)
  338. puts ("ethaddr =");
  339. for (i=0; i<6; ++i) {
  340. printf ("%c%02X", i ? ':' : ' ', bd->bi_enetaddr[i]);
  341. }
  342. puts ( "\n"
  343. "ip_addr = ");
  344. print_IPaddr (bd->bi_ip_addr);
  345. #endif
  346. printf ("\n"
  347. "baudrate = %d bps\n", bd->bi_baudrate);
  348. return 0;
  349. }
  350. #endif /* CONFIG_ARM XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX */
  351. static void print_num(const char *name, ulong value)
  352. {
  353. printf ("%-12s= 0x%08lX\n", name, value);
  354. }
  355. #if defined(CONFIG_PPC) || defined(CONFIG_M68K)
  356. static void print_str(const char *name, const char *str)
  357. {
  358. printf ("%-12s= %6s MHz\n", name, str);
  359. }
  360. #endif /* CONFIG_PPC */
  361. /* -------------------------------------------------------------------- */
  362. U_BOOT_CMD(
  363. bdinfo, 1, 1, do_bdinfo,
  364. "bdinfo - print Board Info structure\n",
  365. NULL
  366. );