cmd_bdinfo.c 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513
  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_SANDBOX)) \
  31. || defined(CONFIG_CMD_NET)
  32. #define HAVE_PRINT_ETH
  33. static void print_eth(int idx);
  34. #endif
  35. #if (!defined(CONFIG_ARM) && !defined(CONFIG_X86) && !defined(CONFIG_SANDBOX))
  36. #define HAVE_PRINT_LNUM
  37. static void print_lnum(const char *, u64);
  38. #endif
  39. #if defined(CONFIG_PPC)
  40. static void print_mhz(const char *, unsigned long);
  41. int do_bdinfo(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
  42. {
  43. bd_t *bd = gd->bd;
  44. #ifdef DEBUG
  45. print_num("bd address", (ulong)bd);
  46. #endif
  47. print_num("memstart", bd->bi_memstart);
  48. print_lnum("memsize", bd->bi_memsize);
  49. print_num("flashstart", bd->bi_flashstart);
  50. print_num("flashsize", bd->bi_flashsize);
  51. print_num("flashoffset", bd->bi_flashoffset);
  52. print_num("sramstart", bd->bi_sramstart);
  53. print_num("sramsize", bd->bi_sramsize);
  54. #if defined(CONFIG_5xx) || defined(CONFIG_8xx) || \
  55. defined(CONFIG_8260) || defined(CONFIG_E500)
  56. print_num("immr_base", bd->bi_immr_base);
  57. #endif
  58. print_num("bootflags", bd->bi_bootflags);
  59. #if defined(CONFIG_405CR) || defined(CONFIG_405EP) || \
  60. defined(CONFIG_405GP) || \
  61. defined(CONFIG_440EP) || defined(CONFIG_440EPX) || \
  62. defined(CONFIG_440GR) || defined(CONFIG_440GRX) || \
  63. defined(CONFIG_440SP) || defined(CONFIG_440SPE) || \
  64. defined(CONFIG_XILINX_405)
  65. print_mhz("procfreq", bd->bi_procfreq);
  66. print_mhz("plb_busfreq", bd->bi_plb_busfreq);
  67. #if defined(CONFIG_405EP) || defined(CONFIG_405GP) || \
  68. defined(CONFIG_440EP) || defined(CONFIG_440EPX) || \
  69. defined(CONFIG_440GR) || defined(CONFIG_440GRX) || \
  70. defined(CONFIG_440SPE) || defined(CONFIG_XILINX_405)
  71. print_mhz("pci_busfreq", bd->bi_pci_busfreq);
  72. #endif
  73. #else /* ! CONFIG_405GP, CONFIG_405CR, CONFIG_405EP, CONFIG_XILINX_405, CONFIG_440EP CONFIG_440GR */
  74. #if defined(CONFIG_CPM2)
  75. print_mhz("vco", bd->bi_vco);
  76. print_mhz("sccfreq", bd->bi_sccfreq);
  77. print_mhz("brgfreq", bd->bi_brgfreq);
  78. #endif
  79. print_mhz("intfreq", bd->bi_intfreq);
  80. #if defined(CONFIG_CPM2)
  81. print_mhz("cpmfreq", bd->bi_cpmfreq);
  82. #endif
  83. print_mhz("busfreq", bd->bi_busfreq);
  84. #endif /* CONFIG_405GP, CONFIG_405CR, CONFIG_405EP, CONFIG_XILINX_405, CONFIG_440EP CONFIG_440GR */
  85. #if defined(CONFIG_MPC8220)
  86. print_mhz("inpfreq", bd->bi_inpfreq);
  87. print_mhz("flbfreq", bd->bi_flbfreq);
  88. print_mhz("pcifreq", bd->bi_pcifreq);
  89. print_mhz("vcofreq", bd->bi_vcofreq);
  90. print_mhz("pevfreq", bd->bi_pevfreq);
  91. #endif
  92. print_eth(0);
  93. #if defined(CONFIG_HAS_ETH1)
  94. print_eth(1);
  95. #endif
  96. #if defined(CONFIG_HAS_ETH2)
  97. print_eth(2);
  98. #endif
  99. #if defined(CONFIG_HAS_ETH3)
  100. print_eth(3);
  101. #endif
  102. #if defined(CONFIG_HAS_ETH4)
  103. print_eth(4);
  104. #endif
  105. #if defined(CONFIG_HAS_ETH5)
  106. print_eth(5);
  107. #endif
  108. #ifdef CONFIG_HERMES
  109. print_mhz("ethspeed", bd->bi_ethspeed);
  110. #endif
  111. printf("IP addr = %pI4\n", &bd->bi_ip_addr);
  112. printf("baudrate = %6ld bps\n", bd->bi_baudrate);
  113. print_num("relocaddr", gd->relocaddr);
  114. return 0;
  115. }
  116. #elif defined(CONFIG_NIOS2)
  117. int do_bdinfo(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
  118. {
  119. bd_t *bd = gd->bd;
  120. print_num("mem start", (ulong)bd->bi_memstart);
  121. print_lnum("mem size", (u64)bd->bi_memsize);
  122. print_num("flash start", (ulong)bd->bi_flashstart);
  123. print_num("flash size", (ulong)bd->bi_flashsize);
  124. print_num("flash offset", (ulong)bd->bi_flashoffset);
  125. #if defined(CONFIG_SYS_SRAM_BASE)
  126. print_num ("sram start", (ulong)bd->bi_sramstart);
  127. print_num ("sram size", (ulong)bd->bi_sramsize);
  128. #endif
  129. #if defined(CONFIG_CMD_NET)
  130. print_eth(0);
  131. printf("ip_addr = %pI4\n", &bd->bi_ip_addr);
  132. #endif
  133. printf("baudrate = %ld bps\n", bd->bi_baudrate);
  134. return 0;
  135. }
  136. #elif defined(CONFIG_MICROBLAZE)
  137. int do_bdinfo(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
  138. {
  139. bd_t *bd = gd->bd;
  140. print_num("mem start ", (ulong)bd->bi_memstart);
  141. print_lnum("mem size ", (u64)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(CONFIG_SYS_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. print_eth(0);
  151. printf("ip_addr = %pI4\n", &bd->bi_ip_addr);
  152. #endif
  153. printf("baudrate = %ld bps\n", (ulong)bd->bi_baudrate);
  154. return 0;
  155. }
  156. #elif defined(CONFIG_SPARC)
  157. int do_bdinfo(cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[])
  158. {
  159. bd_t *bd = gd->bd;
  160. #ifdef DEBUG
  161. print_num("bd address ", (ulong) bd);
  162. #endif
  163. print_num("memstart ", bd->bi_memstart);
  164. print_lnum("memsize ", bd->bi_memsize);
  165. print_num("flashstart ", bd->bi_flashstart);
  166. print_num("CONFIG_SYS_MONITOR_BASE ", CONFIG_SYS_MONITOR_BASE);
  167. print_num("CONFIG_ENV_ADDR ", CONFIG_ENV_ADDR);
  168. printf("CONFIG_SYS_RELOC_MONITOR_BASE = 0x%lx (%d)\n", CONFIG_SYS_RELOC_MONITOR_BASE,
  169. CONFIG_SYS_MONITOR_LEN);
  170. printf("CONFIG_SYS_MALLOC_BASE = 0x%lx (%d)\n", CONFIG_SYS_MALLOC_BASE,
  171. CONFIG_SYS_MALLOC_LEN);
  172. printf("CONFIG_SYS_INIT_SP_OFFSET = 0x%lx (%d)\n", CONFIG_SYS_INIT_SP_OFFSET,
  173. CONFIG_SYS_STACK_SIZE);
  174. printf("CONFIG_SYS_PROM_OFFSET = 0x%lx (%d)\n", CONFIG_SYS_PROM_OFFSET,
  175. CONFIG_SYS_PROM_SIZE);
  176. printf("CONFIG_SYS_GBL_DATA_OFFSET = 0x%lx (%d)\n", CONFIG_SYS_GBL_DATA_OFFSET,
  177. GENERATED_GBL_DATA_SIZE);
  178. #if defined(CONFIG_CMD_NET)
  179. print_eth(0);
  180. printf("ip_addr = %pI4\n", &bd->bi_ip_addr);
  181. #endif
  182. printf("baudrate = %6ld bps\n", bd->bi_baudrate);
  183. return 0;
  184. }
  185. #elif defined(CONFIG_M68K)
  186. static void print_mhz(const char *, unsigned long);
  187. int do_bdinfo(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
  188. {
  189. bd_t *bd = gd->bd;
  190. print_num("memstart", (ulong)bd->bi_memstart);
  191. print_lnum("memsize", (u64)bd->bi_memsize);
  192. print_num("flashstart", (ulong)bd->bi_flashstart);
  193. print_num("flashsize", (ulong)bd->bi_flashsize);
  194. print_num("flashoffset", (ulong)bd->bi_flashoffset);
  195. #if defined(CONFIG_SYS_INIT_RAM_ADDR)
  196. print_num("sramstart", (ulong)bd->bi_sramstart);
  197. print_num("sramsize", (ulong)bd->bi_sramsize);
  198. #endif
  199. #if defined(CONFIG_SYS_MBAR)
  200. print_num("mbar", bd->bi_mbar_base);
  201. #endif
  202. print_mhz("cpufreq", bd->bi_intfreq);
  203. print_mhz("busfreq", bd->bi_busfreq);
  204. #ifdef CONFIG_PCI
  205. print_mhz("pcifreq", bd->bi_pcifreq);
  206. #endif
  207. #ifdef CONFIG_EXTRA_CLOCK
  208. print_mhz("flbfreq", bd->bi_flbfreq);
  209. print_mhz("inpfreq", bd->bi_inpfreq);
  210. print_mhz("vcofreq", bd->bi_vcofreq);
  211. #endif
  212. #if defined(CONFIG_CMD_NET)
  213. print_eth(0);
  214. #if defined(CONFIG_HAS_ETH1)
  215. print_eth(1);
  216. #endif
  217. #if defined(CONFIG_HAS_ETH2)
  218. print_eth(2);
  219. #endif
  220. #if defined(CONFIG_HAS_ETH3)
  221. print_eth(3);
  222. #endif
  223. printf("ip_addr = %pI4\n", &bd->bi_ip_addr);
  224. #endif
  225. printf("baudrate = %ld bps\n", bd->bi_baudrate);
  226. return 0;
  227. }
  228. #elif defined(CONFIG_BLACKFIN)
  229. static void print_mhz(const char *, unsigned long);
  230. int do_bdinfo(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
  231. {
  232. bd_t *bd = gd->bd;
  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_mhz("VCO", bd->bi_vco);
  237. print_mhz("CCLK", bd->bi_cclk);
  238. print_mhz("SCLK", 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_ICACHE_OFF) && defined(CONFIG_SYS_DCACHE_OFF))
  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_mhz(const char *, unsigned long);
  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. print_num("boot_params", (ulong)bd->bi_boot_params);
  330. print_num("bi_memstart", bd->bi_memstart);
  331. print_num("bi_memsize", bd->bi_memsize);
  332. print_num("bi_flashstart", bd->bi_flashstart);
  333. print_num("bi_flashsize", bd->bi_flashsize);
  334. print_num("bi_flashoffset", bd->bi_flashoffset);
  335. print_num("bi_sramstart", bd->bi_sramstart);
  336. print_num("bi_sramsize", bd->bi_sramsize);
  337. print_num("bi_bootflags", bd->bi_bootflags);
  338. print_mhz("cpufreq", bd->bi_intfreq);
  339. print_mhz("busfreq", bd->bi_busfreq);
  340. for (i = 0; i < CONFIG_NR_DRAM_BANKS; ++i) {
  341. print_num("DRAM bank", i);
  342. print_num("-> start", bd->bi_dram[i].start);
  343. print_num("-> size", bd->bi_dram[i].size);
  344. }
  345. #if defined(CONFIG_CMD_NET)
  346. print_eth(0);
  347. printf("ip_addr = %pI4\n", &bd->bi_ip_addr);
  348. print_mhz("ethspeed", bd->bi_ethspeed);
  349. #endif
  350. printf("baudrate = %d bps\n", bd->bi_baudrate);
  351. return 0;
  352. }
  353. #elif defined(CONFIG_SANDBOX)
  354. int do_bdinfo(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
  355. {
  356. int i;
  357. bd_t *bd = gd->bd;
  358. print_num("boot_params", (ulong)bd->bi_boot_params);
  359. for (i = 0; i < CONFIG_NR_DRAM_BANKS; ++i) {
  360. print_num("DRAM bank", i);
  361. print_num("-> start", bd->bi_dram[i].start);
  362. print_num("-> size", bd->bi_dram[i].size);
  363. }
  364. #if defined(CONFIG_CMD_NET)
  365. print_eth(0);
  366. printf("ip_addr = %pI4\n", &bd->bi_ip_addr);
  367. #endif
  368. print_num("FB base ", gd->fb_base);
  369. return 0;
  370. }
  371. #elif defined(CONFIG_NDS32)
  372. int do_bdinfo(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
  373. {
  374. int i;
  375. bd_t *bd = gd->bd;
  376. print_num("arch_number", bd->bi_arch_number);
  377. print_num("boot_params", (ulong)bd->bi_boot_params);
  378. for (i = 0; i < CONFIG_NR_DRAM_BANKS; ++i) {
  379. print_num("DRAM bank", i);
  380. print_num("-> start", bd->bi_dram[i].start);
  381. print_num("-> size", bd->bi_dram[i].size);
  382. }
  383. #if defined(CONFIG_CMD_NET)
  384. print_eth(0);
  385. printf("ip_addr = %pI4\n", &bd->bi_ip_addr);
  386. #endif
  387. printf("baudrate = %d bps\n", bd->bi_baudrate);
  388. return 0;
  389. }
  390. #else
  391. #error "a case for this architecture does not exist!"
  392. #endif
  393. static void print_num(const char *name, ulong value)
  394. {
  395. printf("%-12s= 0x%08lX\n", name, value);
  396. }
  397. #ifdef HAVE_PRINT_ETH
  398. static void print_eth(int idx)
  399. {
  400. char name[10], *val;
  401. if (idx)
  402. sprintf(name, "eth%iaddr", idx);
  403. else
  404. strcpy(name, "ethaddr");
  405. val = getenv(name);
  406. if (!val)
  407. val = "(not set)";
  408. printf("%-12s= %s\n", name, val);
  409. }
  410. #endif
  411. #ifdef HAVE_PRINT_LNUM
  412. static void print_lnum(const char *name, u64 value)
  413. {
  414. printf("%-12s= 0x%.8llX\n", name, value);
  415. }
  416. #endif
  417. #if defined(CONFIG_PPC) || \
  418. defined(CONFIG_M68K) || \
  419. defined(CONFIG_BLACKFIN) || \
  420. defined(CONFIG_X86)
  421. static void print_mhz(const char *name, unsigned long hz)
  422. {
  423. char buf[32];
  424. printf("%-12s= %6s MHz\n", name, strmhz(buf, hz));
  425. }
  426. #endif /* CONFIG_PPC */
  427. /* -------------------------------------------------------------------- */
  428. U_BOOT_CMD(
  429. bdinfo, 1, 1, do_bdinfo,
  430. "print Board Info structure",
  431. ""
  432. );