cmd_bdinfo.c 14 KB

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