cmd_bdinfo.c 14 KB

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