cmd_bdinfo.c 15 KB

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