cmd_bdinfo.c 15 KB

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