cmd_bdinfo.c 12 KB

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