cmd_bdinfo.c 15 KB

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