cmd_bdinfo.c 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464
  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. DECLARE_GLOBAL_DATA_PTR;
  29. static void print_num(const char *, ulong);
  30. #if !(defined(CONFIG_ARM) || defined(CONFIG_M68K)) || defined(CONFIG_CMD_NET)
  31. static void print_eth(int idx);
  32. #endif
  33. #if (!defined(CONFIG_ARM) && !defined(CONFIG_X86))
  34. static void print_lnum(const char *, u64);
  35. #endif
  36. #if defined(CONFIG_PPC)
  37. static void print_str(const char *, const char *);
  38. int do_bdinfo(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
  39. {
  40. bd_t *bd = gd->bd;
  41. char buf[32];
  42. #ifdef DEBUG
  43. print_num("bd address", (ulong)bd);
  44. #endif
  45. print_num("memstart", bd->bi_memstart);
  46. print_lnum("memsize", bd->bi_memsize);
  47. print_num("flashstart", bd->bi_flashstart);
  48. print_num("flashsize", bd->bi_flashsize);
  49. print_num("flashoffset", bd->bi_flashoffset);
  50. print_num("sramstart", bd->bi_sramstart);
  51. print_num("sramsize", bd->bi_sramsize);
  52. #if defined(CONFIG_5xx) || defined(CONFIG_8xx) || \
  53. defined(CONFIG_8260) || defined(CONFIG_E500)
  54. print_num("immr_base", bd->bi_immr_base);
  55. #endif
  56. print_num("bootflags", bd->bi_bootflags);
  57. #if defined(CONFIG_405CR) || defined(CONFIG_405EP) || \
  58. defined(CONFIG_405GP) || \
  59. defined(CONFIG_440EP) || defined(CONFIG_440EPX) || \
  60. defined(CONFIG_440GR) || defined(CONFIG_440GRX) || \
  61. defined(CONFIG_440SP) || defined(CONFIG_440SPE) || \
  62. defined(CONFIG_XILINX_405)
  63. print_str("procfreq", strmhz(buf, bd->bi_procfreq));
  64. print_str("plb_busfreq", strmhz(buf, bd->bi_plb_busfreq));
  65. #if defined(CONFIG_405EP) || defined(CONFIG_405GP) || \
  66. defined(CONFIG_440EP) || defined(CONFIG_440EPX) || \
  67. defined(CONFIG_440GR) || defined(CONFIG_440GRX) || \
  68. defined(CONFIG_440SPE) || defined(CONFIG_XILINX_405)
  69. print_str("pci_busfreq", strmhz(buf, bd->bi_pci_busfreq));
  70. #endif
  71. #else /* ! CONFIG_405GP, CONFIG_405CR, CONFIG_405EP, CONFIG_XILINX_405, CONFIG_440EP CONFIG_440GR */
  72. #if defined(CONFIG_CPM2)
  73. print_str("vco", strmhz(buf, bd->bi_vco));
  74. print_str("sccfreq", strmhz(buf, bd->bi_sccfreq));
  75. print_str("brgfreq", strmhz(buf, bd->bi_brgfreq));
  76. #endif
  77. print_str("intfreq", strmhz(buf, bd->bi_intfreq));
  78. #if defined(CONFIG_CPM2)
  79. print_str("cpmfreq", strmhz(buf, bd->bi_cpmfreq));
  80. #endif
  81. print_str("busfreq", strmhz(buf, bd->bi_busfreq));
  82. #endif /* CONFIG_405GP, CONFIG_405CR, CONFIG_405EP, CONFIG_XILINX_405, CONFIG_440EP CONFIG_440GR */
  83. #if defined(CONFIG_MPC8220)
  84. print_str("inpfreq", strmhz(buf, bd->bi_inpfreq));
  85. print_str("flbfreq", strmhz(buf, bd->bi_flbfreq));
  86. print_str("pcifreq", strmhz(buf, bd->bi_pcifreq));
  87. print_str("vcofreq", strmhz(buf, bd->bi_vcofreq));
  88. print_str("pevfreq", strmhz(buf, bd->bi_pevfreq));
  89. #endif
  90. print_eth(0);
  91. #if defined(CONFIG_HAS_ETH1)
  92. print_eth(1);
  93. #endif
  94. #if defined(CONFIG_HAS_ETH2)
  95. print_eth(2);
  96. #endif
  97. #if defined(CONFIG_HAS_ETH3)
  98. print_eth(3);
  99. #endif
  100. #if defined(CONFIG_HAS_ETH4)
  101. print_eth(4);
  102. #endif
  103. #if defined(CONFIG_HAS_ETH5)
  104. print_eth(5);
  105. #endif
  106. #ifdef CONFIG_HERMES
  107. print_str("ethspeed", strmhz(buf, bd->bi_ethspeed));
  108. #endif
  109. printf("IP addr = %pI4\n", &bd->bi_ip_addr);
  110. printf("baudrate = %6ld bps\n", bd->bi_baudrate);
  111. print_num("relocaddr", gd->relocaddr);
  112. return 0;
  113. }
  114. #elif defined(CONFIG_NIOS2)
  115. int do_bdinfo(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
  116. {
  117. bd_t *bd = gd->bd;
  118. print_num("mem start", (ulong)bd->bi_memstart);
  119. print_lnum("mem size", (u64)bd->bi_memsize);
  120. print_num("flash start", (ulong)bd->bi_flashstart);
  121. print_num("flash size", (ulong)bd->bi_flashsize);
  122. print_num("flash offset", (ulong)bd->bi_flashoffset);
  123. #if defined(CONFIG_SYS_SRAM_BASE)
  124. print_num ("sram start", (ulong)bd->bi_sramstart);
  125. print_num ("sram size", (ulong)bd->bi_sramsize);
  126. #endif
  127. #if defined(CONFIG_CMD_NET)
  128. print_eth(0);
  129. printf("ip_addr = %pI4\n", &bd->bi_ip_addr);
  130. #endif
  131. printf("baudrate = %ld bps\n", bd->bi_baudrate);
  132. return 0;
  133. }
  134. #elif defined(CONFIG_MICROBLAZE)
  135. int do_bdinfo(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
  136. {
  137. bd_t *bd = gd->bd;
  138. print_num("mem start ", (ulong)bd->bi_memstart);
  139. print_lnum("mem size ", (u64)bd->bi_memsize);
  140. print_num("flash start ", (ulong)bd->bi_flashstart);
  141. print_num("flash size ", (ulong)bd->bi_flashsize);
  142. print_num("flash offset ", (ulong)bd->bi_flashoffset);
  143. #if defined(CONFIG_SYS_SRAM_BASE)
  144. print_num("sram start ", (ulong)bd->bi_sramstart);
  145. print_num("sram size ", (ulong)bd->bi_sramsize);
  146. #endif
  147. #if defined(CONFIG_CMD_NET)
  148. print_eth(0);
  149. printf("ip_addr = %pI4\n", &bd->bi_ip_addr);
  150. #endif
  151. printf("baudrate = %ld bps\n", (ulong)bd->bi_baudrate);
  152. return 0;
  153. }
  154. #elif defined(CONFIG_SPARC)
  155. int do_bdinfo(cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[])
  156. {
  157. bd_t *bd = gd->bd;
  158. #ifdef DEBUG
  159. print_num("bd address ", (ulong) bd);
  160. #endif
  161. print_num("memstart ", bd->bi_memstart);
  162. print_lnum("memsize ", bd->bi_memsize);
  163. print_num("flashstart ", bd->bi_flashstart);
  164. print_num("CONFIG_SYS_MONITOR_BASE ", CONFIG_SYS_MONITOR_BASE);
  165. print_num("CONFIG_ENV_ADDR ", CONFIG_ENV_ADDR);
  166. printf("CONFIG_SYS_RELOC_MONITOR_BASE = 0x%lx (%d)\n", CONFIG_SYS_RELOC_MONITOR_BASE,
  167. CONFIG_SYS_MONITOR_LEN);
  168. printf("CONFIG_SYS_MALLOC_BASE = 0x%lx (%d)\n", CONFIG_SYS_MALLOC_BASE,
  169. CONFIG_SYS_MALLOC_LEN);
  170. printf("CONFIG_SYS_INIT_SP_OFFSET = 0x%lx (%d)\n", CONFIG_SYS_INIT_SP_OFFSET,
  171. CONFIG_SYS_STACK_SIZE);
  172. printf("CONFIG_SYS_PROM_OFFSET = 0x%lx (%d)\n", CONFIG_SYS_PROM_OFFSET,
  173. CONFIG_SYS_PROM_SIZE);
  174. printf("CONFIG_SYS_GBL_DATA_OFFSET = 0x%lx (%d)\n", CONFIG_SYS_GBL_DATA_OFFSET,
  175. GENERATED_GBL_DATA_SIZE);
  176. #if defined(CONFIG_CMD_NET)
  177. print_eth(0);
  178. printf("ip_addr = %pI4\n", &bd->bi_ip_addr);
  179. #endif
  180. printf("baudrate = %6ld bps\n", bd->bi_baudrate);
  181. return 0;
  182. }
  183. #elif defined(CONFIG_M68K)
  184. static void print_str(const char *, const char *);
  185. int do_bdinfo(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
  186. {
  187. bd_t *bd = gd->bd;
  188. char buf[32];
  189. print_num("memstart", (ulong)bd->bi_memstart);
  190. print_lnum("memsize", (u64)bd->bi_memsize);
  191. print_num("flashstart", (ulong)bd->bi_flashstart);
  192. print_num("flashsize", (ulong)bd->bi_flashsize);
  193. print_num("flashoffset", (ulong)bd->bi_flashoffset);
  194. #if defined(CONFIG_SYS_INIT_RAM_ADDR)
  195. print_num("sramstart", (ulong)bd->bi_sramstart);
  196. print_num("sramsize", (ulong)bd->bi_sramsize);
  197. #endif
  198. #if defined(CONFIG_SYS_MBAR)
  199. print_num("mbar", bd->bi_mbar_base);
  200. #endif
  201. print_str("cpufreq", strmhz(buf, bd->bi_intfreq));
  202. print_str("busfreq", strmhz(buf, bd->bi_busfreq));
  203. #ifdef CONFIG_PCI
  204. print_str("pcifreq", strmhz(buf, bd->bi_pcifreq));
  205. #endif
  206. #ifdef CONFIG_EXTRA_CLOCK
  207. print_str("flbfreq", strmhz(buf, bd->bi_flbfreq));
  208. print_str("inpfreq", strmhz(buf, bd->bi_inpfreq));
  209. print_str("vcofreq", strmhz(buf, bd->bi_vcofreq));
  210. #endif
  211. #if defined(CONFIG_CMD_NET)
  212. print_eth(0);
  213. #if defined(CONFIG_HAS_ETH1)
  214. print_eth(1);
  215. #endif
  216. #if defined(CONFIG_HAS_ETH2)
  217. print_eth(2);
  218. #endif
  219. #if defined(CONFIG_HAS_ETH3)
  220. print_eth(3);
  221. #endif
  222. printf("ip_addr = %pI4\n", &bd->bi_ip_addr);
  223. #endif
  224. printf("baudrate = %ld bps\n", bd->bi_baudrate);
  225. return 0;
  226. }
  227. #elif defined(CONFIG_BLACKFIN)
  228. static void print_str(const char *, const char *);
  229. int do_bdinfo(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
  230. {
  231. bd_t *bd = gd->bd;
  232. char buf[32];
  233. printf("U-Boot = %s\n", bd->bi_r_version);
  234. printf("CPU = %s\n", bd->bi_cpu);
  235. printf("Board = %s\n", bd->bi_board_name);
  236. print_str("VCO", strmhz(buf, bd->bi_vco));
  237. print_str("CCLK", strmhz(buf, bd->bi_cclk));
  238. print_str("SCLK", strmhz(buf, bd->bi_sclk));
  239. print_num("boot_params", (ulong)bd->bi_boot_params);
  240. print_num("memstart", (ulong)bd->bi_memstart);
  241. print_lnum("memsize", (u64)bd->bi_memsize);
  242. print_num("flashstart", (ulong)bd->bi_flashstart);
  243. print_num("flashsize", (ulong)bd->bi_flashsize);
  244. print_num("flashoffset", (ulong)bd->bi_flashoffset);
  245. print_eth(0);
  246. printf("ip_addr = %pI4\n", &bd->bi_ip_addr);
  247. printf("baudrate = %d bps\n", bd->bi_baudrate);
  248. return 0;
  249. }
  250. #elif defined(CONFIG_MIPS)
  251. int do_bdinfo(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
  252. {
  253. bd_t *bd = gd->bd;
  254. print_num("boot_params", (ulong)bd->bi_boot_params);
  255. print_num("memstart", (ulong)bd->bi_memstart);
  256. print_lnum("memsize", (u64)bd->bi_memsize);
  257. print_num("flashstart", (ulong)bd->bi_flashstart);
  258. print_num("flashsize", (ulong)bd->bi_flashsize);
  259. print_num("flashoffset", (ulong)bd->bi_flashoffset);
  260. print_eth(0);
  261. printf("ip_addr = %pI4\n", &bd->bi_ip_addr);
  262. printf("baudrate = %d bps\n", bd->bi_baudrate);
  263. return 0;
  264. }
  265. #elif defined(CONFIG_AVR32)
  266. int do_bdinfo(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
  267. {
  268. bd_t *bd = gd->bd;
  269. print_num("boot_params", (ulong)bd->bi_boot_params);
  270. print_num("memstart", (ulong)bd->bi_memstart);
  271. print_lnum("memsize", (u64)bd->bi_memsize);
  272. print_num("flashstart", (ulong)bd->bi_flashstart);
  273. print_num("flashsize", (ulong)bd->bi_flashsize);
  274. print_num("flashoffset", (ulong)bd->bi_flashoffset);
  275. print_eth(0);
  276. printf("ip_addr = %pI4\n", &bd->bi_ip_addr);
  277. printf("baudrate = %lu bps\n", bd->bi_baudrate);
  278. return 0;
  279. }
  280. #elif defined(CONFIG_ARM)
  281. int do_bdinfo(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
  282. {
  283. int i;
  284. bd_t *bd = gd->bd;
  285. print_num("arch_number", bd->bi_arch_number);
  286. print_num("boot_params", (ulong)bd->bi_boot_params);
  287. for (i = 0; i < CONFIG_NR_DRAM_BANKS; ++i) {
  288. print_num("DRAM bank", i);
  289. print_num("-> start", bd->bi_dram[i].start);
  290. print_num("-> size", bd->bi_dram[i].size);
  291. }
  292. #if defined(CONFIG_CMD_NET)
  293. print_eth(0);
  294. printf("ip_addr = %pI4\n", &bd->bi_ip_addr);
  295. #endif
  296. printf("baudrate = %d bps\n", bd->bi_baudrate);
  297. #if !(defined(CONFIG_SYS_NO_ICACHE) && defined(CONFIG_SYS_NO_DCACHE))
  298. print_num("TLB addr", gd->tlb_addr);
  299. #endif
  300. print_num("relocaddr", gd->relocaddr);
  301. print_num("reloc off", gd->reloc_off);
  302. print_num("irq_sp", gd->irq_sp); /* irq stack pointer */
  303. print_num("sp start ", gd->start_addr_sp);
  304. print_num("FB base ", gd->fb_base);
  305. return 0;
  306. }
  307. #elif defined(CONFIG_SH)
  308. int do_bdinfo(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
  309. {
  310. bd_t *bd = gd->bd;
  311. print_num("mem start ", (ulong)bd->bi_memstart);
  312. print_lnum("mem size ", (u64)bd->bi_memsize);
  313. print_num("flash start ", (ulong)bd->bi_flashstart);
  314. print_num("flash size ", (ulong)bd->bi_flashsize);
  315. print_num("flash offset ", (ulong)bd->bi_flashoffset);
  316. #if defined(CONFIG_CMD_NET)
  317. print_eth(0);
  318. printf("ip_addr = %pI4\n", &bd->bi_ip_addr);
  319. #endif
  320. printf("baudrate = %ld bps\n", (ulong)bd->bi_baudrate);
  321. return 0;
  322. }
  323. #elif defined(CONFIG_X86)
  324. static void print_str(const char *, const char *);
  325. int do_bdinfo(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
  326. {
  327. int i;
  328. bd_t *bd = gd->bd;
  329. char buf[32];
  330. print_num("boot_params", (ulong)bd->bi_boot_params);
  331. print_num("bi_memstart", bd->bi_memstart);
  332. print_num("bi_memsize", bd->bi_memsize);
  333. print_num("bi_flashstart", bd->bi_flashstart);
  334. print_num("bi_flashsize", bd->bi_flashsize);
  335. print_num("bi_flashoffset", bd->bi_flashoffset);
  336. print_num("bi_sramstart", bd->bi_sramstart);
  337. print_num("bi_sramsize", bd->bi_sramsize);
  338. print_num("bi_bootflags", bd->bi_bootflags);
  339. print_str("cpufreq", strmhz(buf, bd->bi_intfreq));
  340. print_str("busfreq", strmhz(buf, bd->bi_busfreq));
  341. for (i = 0; i < CONFIG_NR_DRAM_BANKS; ++i) {
  342. print_num("DRAM bank", i);
  343. print_num("-> start", bd->bi_dram[i].start);
  344. print_num("-> size", bd->bi_dram[i].size);
  345. }
  346. #if defined(CONFIG_CMD_NET)
  347. print_eth(0);
  348. printf("ip_addr = %pI4\n", &bd->bi_ip_addr);
  349. print_str("ethspeed", strmhz(buf, bd->bi_ethspeed));
  350. #endif
  351. printf("baudrate = %d bps\n", bd->bi_baudrate);
  352. return 0;
  353. }
  354. #else
  355. #error "a case for this architecture does not exist!"
  356. #endif
  357. static void print_num(const char *name, ulong value)
  358. {
  359. printf("%-12s= 0x%08lX\n", name, value);
  360. }
  361. #if !(defined(CONFIG_ARM) || defined(CONFIG_M68K)) || defined(CONFIG_CMD_NET)
  362. static void print_eth(int idx)
  363. {
  364. char name[10], *val;
  365. if (idx)
  366. sprintf(name, "eth%iaddr", idx);
  367. else
  368. strcpy(name, "ethaddr");
  369. val = getenv(name);
  370. if (!val)
  371. val = "(not set)";
  372. printf("%-12s= %s\n", name, val);
  373. }
  374. #endif
  375. #if (!defined(CONFIG_ARM) && !defined(CONFIG_X86))
  376. static void print_lnum(const char *name, u64 value)
  377. {
  378. printf("%-12s= 0x%.8llX\n", name, value);
  379. }
  380. #endif
  381. #if defined(CONFIG_PPC) || \
  382. defined(CONFIG_M68K) || \
  383. defined(CONFIG_BLACKFIN) || \
  384. defined(CONFIG_X86)
  385. static void print_str(const char *name, const char *str)
  386. {
  387. printf("%-12s= %6s MHz\n", name, str);
  388. }
  389. #endif /* CONFIG_PPC */
  390. /* -------------------------------------------------------------------- */
  391. U_BOOT_CMD(
  392. bdinfo, 1, 1, do_bdinfo,
  393. "print Board Info structure",
  394. ""
  395. );