cmd_bdinfo.c 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527
  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. #ifdef CONFIG_ENABLE_36BIT_PHYS
  112. #ifdef CONFIG_PHYS_64BIT
  113. puts("addressing = 36-bit\n");
  114. #else
  115. puts("addressing = 32-bit\n");
  116. #endif
  117. #endif
  118. print_eth(0);
  119. #if defined(CONFIG_HAS_ETH1)
  120. print_eth(1);
  121. #endif
  122. #if defined(CONFIG_HAS_ETH2)
  123. print_eth(2);
  124. #endif
  125. #if defined(CONFIG_HAS_ETH3)
  126. print_eth(3);
  127. #endif
  128. #if defined(CONFIG_HAS_ETH4)
  129. print_eth(4);
  130. #endif
  131. #if defined(CONFIG_HAS_ETH5)
  132. print_eth(5);
  133. #endif
  134. #ifdef CONFIG_HERMES
  135. print_mhz("ethspeed", bd->bi_ethspeed);
  136. #endif
  137. printf("IP addr = %pI4\n", &bd->bi_ip_addr);
  138. printf("baudrate = %6ld bps\n", bd->bi_baudrate);
  139. print_num("relocaddr", gd->relocaddr);
  140. return 0;
  141. }
  142. #elif defined(CONFIG_NIOS2)
  143. int do_bdinfo(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
  144. {
  145. bd_t *bd = gd->bd;
  146. print_num("mem start", (ulong)bd->bi_memstart);
  147. print_lnum("mem size", (u64)bd->bi_memsize);
  148. print_num("flash start", (ulong)bd->bi_flashstart);
  149. print_num("flash size", (ulong)bd->bi_flashsize);
  150. print_num("flash offset", (ulong)bd->bi_flashoffset);
  151. #if defined(CONFIG_SYS_SRAM_BASE)
  152. print_num ("sram start", (ulong)bd->bi_sramstart);
  153. print_num ("sram size", (ulong)bd->bi_sramsize);
  154. #endif
  155. #if defined(CONFIG_CMD_NET)
  156. print_eth(0);
  157. printf("ip_addr = %pI4\n", &bd->bi_ip_addr);
  158. #endif
  159. printf("baudrate = %ld bps\n", bd->bi_baudrate);
  160. return 0;
  161. }
  162. #elif defined(CONFIG_MICROBLAZE)
  163. int do_bdinfo(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
  164. {
  165. bd_t *bd = gd->bd;
  166. print_num("mem start ", (ulong)bd->bi_memstart);
  167. print_lnum("mem size ", (u64)bd->bi_memsize);
  168. print_num("flash start ", (ulong)bd->bi_flashstart);
  169. print_num("flash size ", (ulong)bd->bi_flashsize);
  170. print_num("flash offset ", (ulong)bd->bi_flashoffset);
  171. #if defined(CONFIG_SYS_SRAM_BASE)
  172. print_num("sram start ", (ulong)bd->bi_sramstart);
  173. print_num("sram size ", (ulong)bd->bi_sramsize);
  174. #endif
  175. #if defined(CONFIG_CMD_NET)
  176. print_eth(0);
  177. printf("ip_addr = %pI4\n", &bd->bi_ip_addr);
  178. #endif
  179. printf("baudrate = %ld bps\n", (ulong)bd->bi_baudrate);
  180. return 0;
  181. }
  182. #elif defined(CONFIG_SPARC)
  183. int do_bdinfo(cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[])
  184. {
  185. bd_t *bd = gd->bd;
  186. #ifdef DEBUG
  187. print_num("bd address ", (ulong) bd);
  188. #endif
  189. print_num("memstart ", bd->bi_memstart);
  190. print_lnum("memsize ", bd->bi_memsize);
  191. print_num("flashstart ", bd->bi_flashstart);
  192. print_num("CONFIG_SYS_MONITOR_BASE ", CONFIG_SYS_MONITOR_BASE);
  193. print_num("CONFIG_ENV_ADDR ", CONFIG_ENV_ADDR);
  194. printf("CONFIG_SYS_RELOC_MONITOR_BASE = 0x%lx (%d)\n", CONFIG_SYS_RELOC_MONITOR_BASE,
  195. CONFIG_SYS_MONITOR_LEN);
  196. printf("CONFIG_SYS_MALLOC_BASE = 0x%lx (%d)\n", CONFIG_SYS_MALLOC_BASE,
  197. CONFIG_SYS_MALLOC_LEN);
  198. printf("CONFIG_SYS_INIT_SP_OFFSET = 0x%lx (%d)\n", CONFIG_SYS_INIT_SP_OFFSET,
  199. CONFIG_SYS_STACK_SIZE);
  200. printf("CONFIG_SYS_PROM_OFFSET = 0x%lx (%d)\n", CONFIG_SYS_PROM_OFFSET,
  201. CONFIG_SYS_PROM_SIZE);
  202. printf("CONFIG_SYS_GBL_DATA_OFFSET = 0x%lx (%d)\n", CONFIG_SYS_GBL_DATA_OFFSET,
  203. GENERATED_GBL_DATA_SIZE);
  204. #if defined(CONFIG_CMD_NET)
  205. print_eth(0);
  206. printf("ip_addr = %pI4\n", &bd->bi_ip_addr);
  207. #endif
  208. printf("baudrate = %6ld bps\n", bd->bi_baudrate);
  209. return 0;
  210. }
  211. #elif defined(CONFIG_M68K)
  212. int do_bdinfo(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
  213. {
  214. bd_t *bd = gd->bd;
  215. print_num("memstart", (ulong)bd->bi_memstart);
  216. print_lnum("memsize", (u64)bd->bi_memsize);
  217. print_num("flashstart", (ulong)bd->bi_flashstart);
  218. print_num("flashsize", (ulong)bd->bi_flashsize);
  219. print_num("flashoffset", (ulong)bd->bi_flashoffset);
  220. #if defined(CONFIG_SYS_INIT_RAM_ADDR)
  221. print_num("sramstart", (ulong)bd->bi_sramstart);
  222. print_num("sramsize", (ulong)bd->bi_sramsize);
  223. #endif
  224. #if defined(CONFIG_SYS_MBAR)
  225. print_num("mbar", bd->bi_mbar_base);
  226. #endif
  227. print_mhz("cpufreq", bd->bi_intfreq);
  228. print_mhz("busfreq", bd->bi_busfreq);
  229. #ifdef CONFIG_PCI
  230. print_mhz("pcifreq", bd->bi_pcifreq);
  231. #endif
  232. #ifdef CONFIG_EXTRA_CLOCK
  233. print_mhz("flbfreq", bd->bi_flbfreq);
  234. print_mhz("inpfreq", bd->bi_inpfreq);
  235. print_mhz("vcofreq", bd->bi_vcofreq);
  236. #endif
  237. #if defined(CONFIG_CMD_NET)
  238. print_eth(0);
  239. #if defined(CONFIG_HAS_ETH1)
  240. print_eth(1);
  241. #endif
  242. #if defined(CONFIG_HAS_ETH2)
  243. print_eth(2);
  244. #endif
  245. #if defined(CONFIG_HAS_ETH3)
  246. print_eth(3);
  247. #endif
  248. printf("ip_addr = %pI4\n", &bd->bi_ip_addr);
  249. #endif
  250. printf("baudrate = %ld bps\n", bd->bi_baudrate);
  251. return 0;
  252. }
  253. #elif defined(CONFIG_BLACKFIN)
  254. int do_bdinfo(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
  255. {
  256. bd_t *bd = gd->bd;
  257. printf("U-Boot = %s\n", bd->bi_r_version);
  258. printf("CPU = %s\n", bd->bi_cpu);
  259. printf("Board = %s\n", bd->bi_board_name);
  260. print_mhz("VCO", bd->bi_vco);
  261. print_mhz("CCLK", bd->bi_cclk);
  262. print_mhz("SCLK", bd->bi_sclk);
  263. print_num("boot_params", (ulong)bd->bi_boot_params);
  264. print_num("memstart", (ulong)bd->bi_memstart);
  265. print_lnum("memsize", (u64)bd->bi_memsize);
  266. print_num("flashstart", (ulong)bd->bi_flashstart);
  267. print_num("flashsize", (ulong)bd->bi_flashsize);
  268. print_num("flashoffset", (ulong)bd->bi_flashoffset);
  269. print_eth(0);
  270. printf("ip_addr = %pI4\n", &bd->bi_ip_addr);
  271. printf("baudrate = %d bps\n", bd->bi_baudrate);
  272. return 0;
  273. }
  274. #elif defined(CONFIG_MIPS)
  275. int do_bdinfo(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
  276. {
  277. bd_t *bd = gd->bd;
  278. print_num("boot_params", (ulong)bd->bi_boot_params);
  279. print_num("memstart", (ulong)bd->bi_memstart);
  280. print_lnum("memsize", (u64)bd->bi_memsize);
  281. print_num("flashstart", (ulong)bd->bi_flashstart);
  282. print_num("flashsize", (ulong)bd->bi_flashsize);
  283. print_num("flashoffset", (ulong)bd->bi_flashoffset);
  284. print_eth(0);
  285. printf("ip_addr = %pI4\n", &bd->bi_ip_addr);
  286. printf("baudrate = %d bps\n", bd->bi_baudrate);
  287. return 0;
  288. }
  289. #elif defined(CONFIG_AVR32)
  290. int do_bdinfo(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
  291. {
  292. bd_t *bd = gd->bd;
  293. print_num("boot_params", (ulong)bd->bi_boot_params);
  294. print_num("memstart", (ulong)bd->bi_memstart);
  295. print_lnum("memsize", (u64)bd->bi_memsize);
  296. print_num("flashstart", (ulong)bd->bi_flashstart);
  297. print_num("flashsize", (ulong)bd->bi_flashsize);
  298. print_num("flashoffset", (ulong)bd->bi_flashoffset);
  299. print_eth(0);
  300. printf("ip_addr = %pI4\n", &bd->bi_ip_addr);
  301. printf("baudrate = %lu bps\n", bd->bi_baudrate);
  302. return 0;
  303. }
  304. #elif defined(CONFIG_ARM)
  305. int do_bdinfo(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
  306. {
  307. int i;
  308. bd_t *bd = gd->bd;
  309. print_num("arch_number", bd->bi_arch_number);
  310. print_num("boot_params", (ulong)bd->bi_boot_params);
  311. for (i = 0; i < CONFIG_NR_DRAM_BANKS; ++i) {
  312. print_num("DRAM bank", i);
  313. print_num("-> start", bd->bi_dram[i].start);
  314. print_num("-> size", bd->bi_dram[i].size);
  315. }
  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 = %d bps\n", bd->bi_baudrate);
  321. #if !(defined(CONFIG_SYS_ICACHE_OFF) && defined(CONFIG_SYS_DCACHE_OFF))
  322. print_num("TLB addr", gd->tlb_addr);
  323. #endif
  324. print_num("relocaddr", gd->relocaddr);
  325. print_num("reloc off", gd->reloc_off);
  326. print_num("irq_sp", gd->irq_sp); /* irq stack pointer */
  327. print_num("sp start ", gd->start_addr_sp);
  328. print_num("FB base ", gd->fb_base);
  329. /*
  330. * TODO: Currently only support for davinci SOC's is added.
  331. * Remove this check once all the board implement this.
  332. */
  333. #ifdef CONFIG_CLOCKS
  334. printf("ARM frequency = %ld MHz\n", gd->bd->bi_arm_freq);
  335. printf("DSP frequency = %ld MHz\n", gd->bd->bi_dsp_freq);
  336. printf("DDR frequency = %ld MHz\n", gd->bd->bi_ddr_freq);
  337. #endif
  338. return 0;
  339. }
  340. #elif defined(CONFIG_SH)
  341. int do_bdinfo(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
  342. {
  343. bd_t *bd = gd->bd;
  344. print_num("mem start ", (ulong)bd->bi_memstart);
  345. print_lnum("mem size ", (u64)bd->bi_memsize);
  346. print_num("flash start ", (ulong)bd->bi_flashstart);
  347. print_num("flash size ", (ulong)bd->bi_flashsize);
  348. print_num("flash offset ", (ulong)bd->bi_flashoffset);
  349. #if defined(CONFIG_CMD_NET)
  350. print_eth(0);
  351. printf("ip_addr = %pI4\n", &bd->bi_ip_addr);
  352. #endif
  353. printf("baudrate = %ld bps\n", (ulong)bd->bi_baudrate);
  354. return 0;
  355. }
  356. #elif defined(CONFIG_X86)
  357. int do_bdinfo(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
  358. {
  359. int i;
  360. bd_t *bd = gd->bd;
  361. print_num("boot_params", (ulong)bd->bi_boot_params);
  362. print_num("bi_memstart", bd->bi_memstart);
  363. print_num("bi_memsize", bd->bi_memsize);
  364. print_num("bi_flashstart", bd->bi_flashstart);
  365. print_num("bi_flashsize", bd->bi_flashsize);
  366. print_num("bi_flashoffset", bd->bi_flashoffset);
  367. print_num("bi_sramstart", bd->bi_sramstart);
  368. print_num("bi_sramsize", bd->bi_sramsize);
  369. print_num("bi_bootflags", bd->bi_bootflags);
  370. print_mhz("cpufreq", bd->bi_intfreq);
  371. print_mhz("busfreq", bd->bi_busfreq);
  372. for (i = 0; i < CONFIG_NR_DRAM_BANKS; ++i) {
  373. print_num("DRAM bank", i);
  374. print_num("-> start", bd->bi_dram[i].start);
  375. print_num("-> size", bd->bi_dram[i].size);
  376. }
  377. #if defined(CONFIG_CMD_NET)
  378. print_eth(0);
  379. printf("ip_addr = %pI4\n", &bd->bi_ip_addr);
  380. print_mhz("ethspeed", bd->bi_ethspeed);
  381. #endif
  382. printf("baudrate = %d bps\n", bd->bi_baudrate);
  383. return 0;
  384. }
  385. #elif defined(CONFIG_SANDBOX)
  386. int do_bdinfo(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
  387. {
  388. int i;
  389. bd_t *bd = gd->bd;
  390. print_num("boot_params", (ulong)bd->bi_boot_params);
  391. for (i = 0; i < CONFIG_NR_DRAM_BANKS; ++i) {
  392. print_num("DRAM bank", i);
  393. print_num("-> start", bd->bi_dram[i].start);
  394. print_num("-> size", bd->bi_dram[i].size);
  395. }
  396. #if defined(CONFIG_CMD_NET)
  397. print_eth(0);
  398. printf("ip_addr = %pI4\n", &bd->bi_ip_addr);
  399. #endif
  400. print_num("FB base ", gd->fb_base);
  401. return 0;
  402. }
  403. #elif defined(CONFIG_NDS32)
  404. int do_bdinfo(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
  405. {
  406. int i;
  407. bd_t *bd = gd->bd;
  408. print_num("arch_number", bd->bi_arch_number);
  409. print_num("boot_params", (ulong)bd->bi_boot_params);
  410. for (i = 0; i < CONFIG_NR_DRAM_BANKS; ++i) {
  411. print_num("DRAM bank", i);
  412. print_num("-> start", bd->bi_dram[i].start);
  413. print_num("-> size", bd->bi_dram[i].size);
  414. }
  415. #if defined(CONFIG_CMD_NET)
  416. print_eth(0);
  417. printf("ip_addr = %pI4\n", &bd->bi_ip_addr);
  418. #endif
  419. printf("baudrate = %d bps\n", bd->bi_baudrate);
  420. return 0;
  421. }
  422. #elif defined(CONFIG_OPENRISC)
  423. int do_bdinfo(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
  424. {
  425. bd_t *bd = gd->bd;
  426. print_num("mem start", (ulong)bd->bi_memstart);
  427. print_lnum("mem size", (u64)bd->bi_memsize);
  428. print_num("flash start", (ulong)bd->bi_flashstart);
  429. print_num("flash size", (ulong)bd->bi_flashsize);
  430. print_num("flash offset", (ulong)bd->bi_flashoffset);
  431. #if defined(CONFIG_CMD_NET)
  432. print_eth(0);
  433. printf("ip_addr = %pI4\n", &bd->bi_ip_addr);
  434. #endif
  435. printf("baudrate = %ld bps\n", bd->bi_baudrate);
  436. return 0;
  437. }
  438. #else
  439. #error "a case for this architecture does not exist!"
  440. #endif
  441. /* -------------------------------------------------------------------- */
  442. U_BOOT_CMD(
  443. bdinfo, 1, 1, do_bdinfo,
  444. "print Board Info structure",
  445. ""
  446. );