cmd_bdinfo.c 13 KB

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