cmd_bdinfo.c 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389
  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. DECLARE_GLOBAL_DATA_PTR;
  29. static void print_num(const char *, ulong);
  30. #if !(defined(CONFIG_ARM) || defined(CONFIG_M68K)) || defined(CONFIG_CMD_NET)
  31. static void print_eth(int idx);
  32. #endif
  33. #ifndef CONFIG_ARM /* PowerPC and other */
  34. static void print_lnum(const char *, u64);
  35. #ifdef CONFIG_PPC
  36. static void print_str(const char *, const char *);
  37. int do_bdinfo ( cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
  38. {
  39. bd_t *bd = gd->bd;
  40. char buf[32];
  41. #ifdef DEBUG
  42. print_num ("bd address", (ulong)bd );
  43. #endif
  44. print_num ("memstart", bd->bi_memstart );
  45. print_lnum ("memsize", bd->bi_memsize );
  46. print_num ("flashstart", bd->bi_flashstart );
  47. print_num ("flashsize", bd->bi_flashsize );
  48. print_num ("flashoffset", bd->bi_flashoffset );
  49. print_num ("sramstart", bd->bi_sramstart );
  50. print_num ("sramsize", bd->bi_sramsize );
  51. #if defined(CONFIG_5xx) || defined(CONFIG_8xx) || \
  52. defined(CONFIG_8260) || defined(CONFIG_E500)
  53. print_num ("immr_base", bd->bi_immr_base );
  54. #endif
  55. print_num ("bootflags", bd->bi_bootflags );
  56. #if defined(CONFIG_405GP) || defined(CONFIG_405CR) || \
  57. defined(CONFIG_405EP) || defined(CONFIG_XILINX_405) || \
  58. defined(CONFIG_440EP) || defined(CONFIG_440GR) || \
  59. defined(CONFIG_440EPX) || defined(CONFIG_440GRX) || \
  60. defined(CONFIG_440SP) || defined(CONFIG_440SPE)
  61. print_str ("procfreq", strmhz(buf, bd->bi_procfreq));
  62. print_str ("plb_busfreq", strmhz(buf, bd->bi_plb_busfreq));
  63. #if defined(CONFIG_405GP) || defined(CONFIG_405EP) || defined(CONFIG_XILINX_405) || \
  64. defined(CONFIG_440EP) || defined(CONFIG_440GR) || defined(CONFIG_440SPE) || \
  65. defined(CONFIG_440EPX) || defined(CONFIG_440GRX)
  66. print_str ("pci_busfreq", strmhz(buf, bd->bi_pci_busfreq));
  67. #endif
  68. #else /* ! CONFIG_405GP, CONFIG_405CR, CONFIG_405EP, CONFIG_XILINX_405, CONFIG_440EP CONFIG_440GR */
  69. #if defined(CONFIG_CPM2)
  70. print_str ("vco", strmhz(buf, bd->bi_vco));
  71. print_str ("sccfreq", strmhz(buf, bd->bi_sccfreq));
  72. print_str ("brgfreq", strmhz(buf, bd->bi_brgfreq));
  73. #endif
  74. print_str ("intfreq", strmhz(buf, bd->bi_intfreq));
  75. #if defined(CONFIG_CPM2)
  76. print_str ("cpmfreq", strmhz(buf, bd->bi_cpmfreq));
  77. #endif
  78. print_str ("busfreq", strmhz(buf, bd->bi_busfreq));
  79. #endif /* CONFIG_405GP, CONFIG_405CR, CONFIG_405EP, CONFIG_XILINX_405, CONFIG_440EP CONFIG_440GR */
  80. #if defined(CONFIG_MPC8220)
  81. print_str ("inpfreq", strmhz(buf, bd->bi_inpfreq));
  82. print_str ("flbfreq", strmhz(buf, bd->bi_flbfreq));
  83. print_str ("pcifreq", strmhz(buf, bd->bi_pcifreq));
  84. print_str ("vcofreq", strmhz(buf, bd->bi_vcofreq));
  85. print_str ("pevfreq", strmhz(buf, bd->bi_pevfreq));
  86. #endif
  87. print_eth(0);
  88. #if defined(CONFIG_HAS_ETH1)
  89. print_eth(1);
  90. #endif
  91. #if defined(CONFIG_HAS_ETH2)
  92. print_eth(2);
  93. #endif
  94. #if defined(CONFIG_HAS_ETH3)
  95. print_eth(3);
  96. #endif
  97. #if defined(CONFIG_HAS_ETH4)
  98. print_eth(4);
  99. #endif
  100. #if defined(CONFIG_HAS_ETH5)
  101. print_eth(5);
  102. #endif
  103. #ifdef CONFIG_HERMES
  104. print_str ("ethspeed", strmhz(buf, bd->bi_ethspeed));
  105. #endif
  106. printf ("IP addr = %pI4\n", &bd->bi_ip_addr);
  107. printf ("baudrate = %6ld bps\n", bd->bi_baudrate );
  108. print_num ("relocaddr", gd->relocaddr);
  109. return 0;
  110. }
  111. #elif defined(CONFIG_NIOS) /* NIOS*/
  112. int do_bdinfo ( cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
  113. {
  114. bd_t *bd = gd->bd;
  115. print_num ("memstart", (ulong)bd->bi_memstart);
  116. print_lnum ("memsize", (u64)bd->bi_memsize);
  117. print_num ("flashstart", (ulong)bd->bi_flashstart);
  118. print_num ("flashsize", (ulong)bd->bi_flashsize);
  119. print_num ("flashoffset", (ulong)bd->bi_flashoffset);
  120. print_eth(0);
  121. printf ("ip_addr = %pI4\n", &bd->bi_ip_addr);
  122. printf ("baudrate = %ld bps\n", bd->bi_baudrate);
  123. return 0;
  124. }
  125. #elif defined(CONFIG_NIOS2) /* Nios-II */
  126. int do_bdinfo ( cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
  127. {
  128. bd_t *bd = gd->bd;
  129. print_num ("mem start", (ulong)bd->bi_memstart);
  130. print_lnum ("mem size", (u64)bd->bi_memsize);
  131. print_num ("flash start", (ulong)bd->bi_flashstart);
  132. print_num ("flash size", (ulong)bd->bi_flashsize);
  133. print_num ("flash offset", (ulong)bd->bi_flashoffset);
  134. #if defined(CONFIG_SYS_SRAM_BASE)
  135. print_num ("sram start", (ulong)bd->bi_sramstart);
  136. print_num ("sram size", (ulong)bd->bi_sramsize);
  137. #endif
  138. #if defined(CONFIG_CMD_NET)
  139. print_eth(0);
  140. printf ("ip_addr = %pI4\n", &bd->bi_ip_addr);
  141. #endif
  142. printf ("baudrate = %ld bps\n", bd->bi_baudrate);
  143. return 0;
  144. }
  145. #elif defined(CONFIG_MICROBLAZE) /* ! PPC, which leaves Microblaze */
  146. int do_bdinfo ( cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
  147. {
  148. bd_t *bd = gd->bd;
  149. print_num ("mem start ", (ulong)bd->bi_memstart);
  150. print_lnum ("mem size ", (u64)bd->bi_memsize);
  151. print_num ("flash start ", (ulong)bd->bi_flashstart);
  152. print_num ("flash size ", (ulong)bd->bi_flashsize);
  153. print_num ("flash offset ", (ulong)bd->bi_flashoffset);
  154. #if defined(CONFIG_SYS_SRAM_BASE)
  155. print_num ("sram start ", (ulong)bd->bi_sramstart);
  156. print_num ("sram size ", (ulong)bd->bi_sramsize);
  157. #endif
  158. #if defined(CONFIG_CMD_NET)
  159. print_eth(0);
  160. printf ("ip_addr = %pI4\n", &bd->bi_ip_addr);
  161. #endif
  162. printf ("baudrate = %ld bps\n", (ulong)bd->bi_baudrate);
  163. return 0;
  164. }
  165. #elif defined(CONFIG_SPARC) /* SPARC */
  166. int do_bdinfo(cmd_tbl_t * cmdtp, int flag, int argc, char *argv[])
  167. {
  168. bd_t *bd = gd->bd;
  169. #ifdef DEBUG
  170. print_num("bd address ", (ulong) bd);
  171. #endif
  172. print_num("memstart ", bd->bi_memstart);
  173. print_lnum("memsize ", bd->bi_memsize);
  174. print_num("flashstart ", bd->bi_flashstart);
  175. print_num("CONFIG_SYS_MONITOR_BASE ", CONFIG_SYS_MONITOR_BASE);
  176. print_num("CONFIG_ENV_ADDR ", CONFIG_ENV_ADDR);
  177. printf("CONFIG_SYS_RELOC_MONITOR_BASE = 0x%lx (%d)\n", CONFIG_SYS_RELOC_MONITOR_BASE,
  178. CONFIG_SYS_MONITOR_LEN);
  179. printf("CONFIG_SYS_MALLOC_BASE = 0x%lx (%d)\n", CONFIG_SYS_MALLOC_BASE,
  180. CONFIG_SYS_MALLOC_LEN);
  181. printf("CONFIG_SYS_INIT_SP_OFFSET = 0x%lx (%d)\n", CONFIG_SYS_INIT_SP_OFFSET,
  182. CONFIG_SYS_STACK_SIZE);
  183. printf("CONFIG_SYS_PROM_OFFSET = 0x%lx (%d)\n", CONFIG_SYS_PROM_OFFSET,
  184. CONFIG_SYS_PROM_SIZE);
  185. printf("CONFIG_SYS_GBL_DATA_OFFSET = 0x%lx (%d)\n", CONFIG_SYS_GBL_DATA_OFFSET,
  186. CONFIG_SYS_GBL_DATA_SIZE);
  187. #if defined(CONFIG_CMD_NET)
  188. print_eth(0);
  189. printf("ip_addr = %pI4\n", &bd->bi_ip_addr);
  190. #endif
  191. printf("baudrate = %6ld bps\n", bd->bi_baudrate);
  192. return 0;
  193. }
  194. #elif defined(CONFIG_M68K) /* M68K */
  195. static void print_str(const char *, const char *);
  196. int do_bdinfo ( cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
  197. {
  198. bd_t *bd = gd->bd;
  199. char buf[32];
  200. print_num ("memstart", (ulong)bd->bi_memstart);
  201. print_lnum ("memsize", (u64)bd->bi_memsize);
  202. print_num ("flashstart", (ulong)bd->bi_flashstart);
  203. print_num ("flashsize", (ulong)bd->bi_flashsize);
  204. print_num ("flashoffset", (ulong)bd->bi_flashoffset);
  205. #if defined(CONFIG_SYS_INIT_RAM_ADDR)
  206. print_num ("sramstart", (ulong)bd->bi_sramstart);
  207. print_num ("sramsize", (ulong)bd->bi_sramsize);
  208. #endif
  209. #if defined(CONFIG_SYS_MBAR)
  210. print_num ("mbar", bd->bi_mbar_base);
  211. #endif
  212. print_str ("cpufreq", strmhz(buf, bd->bi_intfreq));
  213. print_str ("busfreq", strmhz(buf, bd->bi_busfreq));
  214. #ifdef CONFIG_PCI
  215. print_str ("pcifreq", strmhz(buf, bd->bi_pcifreq));
  216. #endif
  217. #ifdef CONFIG_EXTRA_CLOCK
  218. print_str ("flbfreq", strmhz(buf, bd->bi_flbfreq));
  219. print_str ("inpfreq", strmhz(buf, bd->bi_inpfreq));
  220. print_str ("vcofreq", strmhz(buf, bd->bi_vcofreq));
  221. #endif
  222. #if defined(CONFIG_CMD_NET)
  223. print_eth(0);
  224. #if defined(CONFIG_HAS_ETH1)
  225. print_eth(1);
  226. #endif
  227. #if defined(CONFIG_HAS_ETH2)
  228. print_eth(2);
  229. #endif
  230. #if defined(CONFIG_HAS_ETH3)
  231. print_eth(3);
  232. #endif
  233. printf ("ip_addr = %pI4\n", &bd->bi_ip_addr);
  234. #endif
  235. printf ("baudrate = %ld bps\n", bd->bi_baudrate);
  236. return 0;
  237. }
  238. #elif defined(CONFIG_BLACKFIN)
  239. static void print_str(const char *, const char *);
  240. int do_bdinfo(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
  241. {
  242. bd_t *bd = gd->bd;
  243. char buf[32];
  244. printf("U-Boot = %s\n", bd->bi_r_version);
  245. printf("CPU = %s\n", bd->bi_cpu);
  246. printf("Board = %s\n", bd->bi_board_name);
  247. print_str("VCO", strmhz(buf, bd->bi_vco));
  248. print_str("CCLK", strmhz(buf, bd->bi_cclk));
  249. print_str("SCLK", strmhz(buf, bd->bi_sclk));
  250. print_num("boot_params", (ulong)bd->bi_boot_params);
  251. print_num("memstart", (ulong)bd->bi_memstart);
  252. print_lnum("memsize", (u64)bd->bi_memsize);
  253. print_num("flashstart", (ulong)bd->bi_flashstart);
  254. print_num("flashsize", (ulong)bd->bi_flashsize);
  255. print_num("flashoffset", (ulong)bd->bi_flashoffset);
  256. print_eth(0);
  257. printf("ip_addr = %pI4\n", &bd->bi_ip_addr);
  258. printf("baudrate = %d bps\n", bd->bi_baudrate);
  259. return 0;
  260. }
  261. #else /* ! PPC, which leaves MIPS */
  262. int do_bdinfo ( cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
  263. {
  264. bd_t *bd = gd->bd;
  265. print_num ("boot_params", (ulong)bd->bi_boot_params);
  266. print_num ("memstart", (ulong)bd->bi_memstart);
  267. print_lnum ("memsize", (u64)bd->bi_memsize);
  268. print_num ("flashstart", (ulong)bd->bi_flashstart);
  269. print_num ("flashsize", (ulong)bd->bi_flashsize);
  270. print_num ("flashoffset", (ulong)bd->bi_flashoffset);
  271. print_eth(0);
  272. printf ("ip_addr = %pI4\n", &bd->bi_ip_addr);
  273. printf ("baudrate = %d bps\n", bd->bi_baudrate);
  274. return 0;
  275. }
  276. #endif /* MIPS */
  277. #else /* ARM */
  278. int do_bdinfo ( cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
  279. {
  280. int i;
  281. bd_t *bd = gd->bd;
  282. print_num ("arch_number", bd->bi_arch_number);
  283. print_num ("env_t", (ulong)bd->bi_env);
  284. print_num ("boot_params", (ulong)bd->bi_boot_params);
  285. for (i=0; i<CONFIG_NR_DRAM_BANKS; ++i) {
  286. print_num("DRAM bank", i);
  287. print_num("-> start", bd->bi_dram[i].start);
  288. print_num("-> size", bd->bi_dram[i].size);
  289. }
  290. #if defined(CONFIG_CMD_NET)
  291. print_eth(0);
  292. printf ("ip_addr = %pI4\n", &bd->bi_ip_addr);
  293. #endif
  294. printf ("baudrate = %d bps\n", bd->bi_baudrate);
  295. return 0;
  296. }
  297. #endif /* CONFIG_ARM XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX */
  298. static void print_num(const char *name, ulong value)
  299. {
  300. printf ("%-12s= 0x%08lX\n", name, value);
  301. }
  302. #if !(defined(CONFIG_ARM) || defined(CONFIG_M68K)) || defined(CONFIG_CMD_NET)
  303. static void print_eth(int idx)
  304. {
  305. char name[10], *val;
  306. if (idx)
  307. sprintf(name, "eth%iaddr", idx);
  308. else
  309. strcpy(name, "ethaddr");
  310. val = getenv(name);
  311. if (!val)
  312. val = "(not set)";
  313. printf("%-12s= %s\n", name, val);
  314. }
  315. #endif
  316. #ifndef CONFIG_ARM
  317. static void print_lnum(const char *name, u64 value)
  318. {
  319. printf ("%-12s= 0x%.8llX\n", name, value);
  320. }
  321. #endif
  322. #if defined(CONFIG_PPC) || defined(CONFIG_M68K) || defined(CONFIG_BLACKFIN)
  323. static void print_str(const char *name, const char *str)
  324. {
  325. printf ("%-12s= %6s MHz\n", name, str);
  326. }
  327. #endif /* CONFIG_PPC */
  328. /* -------------------------------------------------------------------- */
  329. U_BOOT_CMD(
  330. bdinfo, 1, 1, do_bdinfo,
  331. "print Board Info structure",
  332. ""
  333. );