cmd_bdinfo.c 14 KB

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