cmd_bdinfo.c 15 KB

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