cmd_bdinfo.c 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388
  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_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. return 0;
  109. }
  110. #elif defined(CONFIG_NIOS) /* NIOS*/
  111. int do_bdinfo ( cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
  112. {
  113. bd_t *bd = gd->bd;
  114. print_num ("memstart", (ulong)bd->bi_memstart);
  115. print_lnum ("memsize", (u64)bd->bi_memsize);
  116. print_num ("flashstart", (ulong)bd->bi_flashstart);
  117. print_num ("flashsize", (ulong)bd->bi_flashsize);
  118. print_num ("flashoffset", (ulong)bd->bi_flashoffset);
  119. print_eth(0);
  120. printf ("ip_addr = %pI4\n", &bd->bi_ip_addr);
  121. printf ("baudrate = %ld bps\n", bd->bi_baudrate);
  122. return 0;
  123. }
  124. #elif defined(CONFIG_NIOS2) /* Nios-II */
  125. int do_bdinfo ( cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
  126. {
  127. bd_t *bd = gd->bd;
  128. print_num ("mem start", (ulong)bd->bi_memstart);
  129. print_lnum ("mem size", (u64)bd->bi_memsize);
  130. print_num ("flash start", (ulong)bd->bi_flashstart);
  131. print_num ("flash size", (ulong)bd->bi_flashsize);
  132. print_num ("flash offset", (ulong)bd->bi_flashoffset);
  133. #if defined(CONFIG_SYS_SRAM_BASE)
  134. print_num ("sram start", (ulong)bd->bi_sramstart);
  135. print_num ("sram size", (ulong)bd->bi_sramsize);
  136. #endif
  137. #if defined(CONFIG_CMD_NET)
  138. print_eth(0);
  139. printf ("ip_addr = %pI4\n", &bd->bi_ip_addr);
  140. #endif
  141. printf ("baudrate = %ld bps\n", bd->bi_baudrate);
  142. return 0;
  143. }
  144. #elif defined(CONFIG_MICROBLAZE) /* ! PPC, which leaves Microblaze */
  145. int do_bdinfo ( cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
  146. {
  147. bd_t *bd = gd->bd;
  148. print_num ("mem start ", (ulong)bd->bi_memstart);
  149. print_lnum ("mem size ", (u64)bd->bi_memsize);
  150. print_num ("flash start ", (ulong)bd->bi_flashstart);
  151. print_num ("flash size ", (ulong)bd->bi_flashsize);
  152. print_num ("flash offset ", (ulong)bd->bi_flashoffset);
  153. #if defined(CONFIG_SYS_SRAM_BASE)
  154. print_num ("sram start ", (ulong)bd->bi_sramstart);
  155. print_num ("sram size ", (ulong)bd->bi_sramsize);
  156. #endif
  157. #if defined(CONFIG_CMD_NET)
  158. print_eth(0);
  159. printf ("ip_addr = %pI4\n", &bd->bi_ip_addr);
  160. #endif
  161. printf ("baudrate = %ld bps\n", (ulong)bd->bi_baudrate);
  162. return 0;
  163. }
  164. #elif defined(CONFIG_SPARC) /* SPARC */
  165. int do_bdinfo(cmd_tbl_t * cmdtp, int flag, int argc, char *argv[])
  166. {
  167. bd_t *bd = gd->bd;
  168. #ifdef DEBUG
  169. print_num("bd address ", (ulong) bd);
  170. #endif
  171. print_num("memstart ", bd->bi_memstart);
  172. print_lnum("memsize ", bd->bi_memsize);
  173. print_num("flashstart ", bd->bi_flashstart);
  174. print_num("CONFIG_SYS_MONITOR_BASE ", CONFIG_SYS_MONITOR_BASE);
  175. print_num("CONFIG_ENV_ADDR ", CONFIG_ENV_ADDR);
  176. printf("CONFIG_SYS_RELOC_MONITOR_BASE = 0x%lx (%d)\n", CONFIG_SYS_RELOC_MONITOR_BASE,
  177. CONFIG_SYS_MONITOR_LEN);
  178. printf("CONFIG_SYS_MALLOC_BASE = 0x%lx (%d)\n", CONFIG_SYS_MALLOC_BASE,
  179. CONFIG_SYS_MALLOC_LEN);
  180. printf("CONFIG_SYS_INIT_SP_OFFSET = 0x%lx (%d)\n", CONFIG_SYS_INIT_SP_OFFSET,
  181. CONFIG_SYS_STACK_SIZE);
  182. printf("CONFIG_SYS_PROM_OFFSET = 0x%lx (%d)\n", CONFIG_SYS_PROM_OFFSET,
  183. CONFIG_SYS_PROM_SIZE);
  184. printf("CONFIG_SYS_GBL_DATA_OFFSET = 0x%lx (%d)\n", CONFIG_SYS_GBL_DATA_OFFSET,
  185. CONFIG_SYS_GBL_DATA_SIZE);
  186. #if defined(CONFIG_CMD_NET)
  187. print_eth(0);
  188. printf("ip_addr = %pI4\n", &bd->bi_ip_addr);
  189. #endif
  190. printf("baudrate = %6ld bps\n", bd->bi_baudrate);
  191. return 0;
  192. }
  193. #elif defined(CONFIG_M68K) /* M68K */
  194. static void print_str(const char *, const char *);
  195. int do_bdinfo ( cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
  196. {
  197. bd_t *bd = gd->bd;
  198. char buf[32];
  199. print_num ("memstart", (ulong)bd->bi_memstart);
  200. print_lnum ("memsize", (u64)bd->bi_memsize);
  201. print_num ("flashstart", (ulong)bd->bi_flashstart);
  202. print_num ("flashsize", (ulong)bd->bi_flashsize);
  203. print_num ("flashoffset", (ulong)bd->bi_flashoffset);
  204. #if defined(CONFIG_SYS_INIT_RAM_ADDR)
  205. print_num ("sramstart", (ulong)bd->bi_sramstart);
  206. print_num ("sramsize", (ulong)bd->bi_sramsize);
  207. #endif
  208. #if defined(CONFIG_SYS_MBAR)
  209. print_num ("mbar", bd->bi_mbar_base);
  210. #endif
  211. print_str ("cpufreq", strmhz(buf, bd->bi_intfreq));
  212. print_str ("busfreq", strmhz(buf, bd->bi_busfreq));
  213. #ifdef CONFIG_PCI
  214. print_str ("pcifreq", strmhz(buf, bd->bi_pcifreq));
  215. #endif
  216. #ifdef CONFIG_EXTRA_CLOCK
  217. print_str ("flbfreq", strmhz(buf, bd->bi_flbfreq));
  218. print_str ("inpfreq", strmhz(buf, bd->bi_inpfreq));
  219. print_str ("vcofreq", strmhz(buf, bd->bi_vcofreq));
  220. #endif
  221. #if defined(CONFIG_CMD_NET)
  222. print_eth(0);
  223. #if defined(CONFIG_HAS_ETH1)
  224. print_eth(1);
  225. #endif
  226. #if defined(CONFIG_HAS_ETH2)
  227. print_eth(2);
  228. #endif
  229. #if defined(CONFIG_HAS_ETH3)
  230. print_eth(3);
  231. #endif
  232. printf ("ip_addr = %pI4\n", &bd->bi_ip_addr);
  233. #endif
  234. printf ("baudrate = %ld bps\n", bd->bi_baudrate);
  235. return 0;
  236. }
  237. #elif defined(CONFIG_BLACKFIN)
  238. static void print_str(const char *, const char *);
  239. int do_bdinfo(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
  240. {
  241. bd_t *bd = gd->bd;
  242. char buf[32];
  243. printf("U-Boot = %s\n", bd->bi_r_version);
  244. printf("CPU = %s\n", bd->bi_cpu);
  245. printf("Board = %s\n", bd->bi_board_name);
  246. print_str("VCO", strmhz(buf, bd->bi_vco));
  247. print_str("CCLK", strmhz(buf, bd->bi_cclk));
  248. print_str("SCLK", strmhz(buf, bd->bi_sclk));
  249. print_num("boot_params", (ulong)bd->bi_boot_params);
  250. print_num("memstart", (ulong)bd->bi_memstart);
  251. print_lnum("memsize", (u64)bd->bi_memsize);
  252. print_num("flashstart", (ulong)bd->bi_flashstart);
  253. print_num("flashsize", (ulong)bd->bi_flashsize);
  254. print_num("flashoffset", (ulong)bd->bi_flashoffset);
  255. print_eth(0);
  256. printf("ip_addr = %pI4\n", &bd->bi_ip_addr);
  257. printf("baudrate = %d bps\n", bd->bi_baudrate);
  258. return 0;
  259. }
  260. #else /* ! PPC, which leaves MIPS */
  261. int do_bdinfo ( cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
  262. {
  263. bd_t *bd = gd->bd;
  264. print_num ("boot_params", (ulong)bd->bi_boot_params);
  265. print_num ("memstart", (ulong)bd->bi_memstart);
  266. print_lnum ("memsize", (u64)bd->bi_memsize);
  267. print_num ("flashstart", (ulong)bd->bi_flashstart);
  268. print_num ("flashsize", (ulong)bd->bi_flashsize);
  269. print_num ("flashoffset", (ulong)bd->bi_flashoffset);
  270. print_eth(0);
  271. printf ("ip_addr = %pI4\n", &bd->bi_ip_addr);
  272. printf ("baudrate = %d bps\n", bd->bi_baudrate);
  273. return 0;
  274. }
  275. #endif /* MIPS */
  276. #else /* ARM */
  277. int do_bdinfo ( cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
  278. {
  279. int i;
  280. bd_t *bd = gd->bd;
  281. print_num ("arch_number", bd->bi_arch_number);
  282. print_num ("env_t", (ulong)bd->bi_env);
  283. print_num ("boot_params", (ulong)bd->bi_boot_params);
  284. for (i=0; i<CONFIG_NR_DRAM_BANKS; ++i) {
  285. print_num("DRAM bank", i);
  286. print_num("-> start", bd->bi_dram[i].start);
  287. print_num("-> size", bd->bi_dram[i].size);
  288. }
  289. #if defined(CONFIG_CMD_NET)
  290. print_eth(0);
  291. printf ("ip_addr = %pI4\n", &bd->bi_ip_addr);
  292. #endif
  293. printf ("baudrate = %d bps\n", bd->bi_baudrate);
  294. return 0;
  295. }
  296. #endif /* CONFIG_ARM XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX */
  297. static void print_num(const char *name, ulong value)
  298. {
  299. printf ("%-12s= 0x%08lX\n", name, value);
  300. }
  301. #if !defined(CONFIG_ARM) || defined(CONFIG_CMD_NET)
  302. static void print_eth(int idx)
  303. {
  304. char name[10], *val;
  305. if (idx)
  306. sprintf(name, "eth%iaddr", idx);
  307. else
  308. strcpy(name, "ethaddr");
  309. val = getenv(name);
  310. if (!val)
  311. val = "(not set)";
  312. printf("%-12s= %s\n", name, val);
  313. }
  314. #endif
  315. #ifndef CONFIG_ARM
  316. static void print_lnum(const char *name, u64 value)
  317. {
  318. printf ("%-12s= 0x%.8llX\n", name, value);
  319. }
  320. #endif
  321. #if defined(CONFIG_PPC) || defined(CONFIG_M68K) || defined(CONFIG_BLACKFIN)
  322. static void print_str(const char *name, const char *str)
  323. {
  324. printf ("%-12s= %6s MHz\n", name, str);
  325. }
  326. #endif /* CONFIG_PPC */
  327. /* -------------------------------------------------------------------- */
  328. U_BOOT_CMD(
  329. bdinfo, 1, 1, do_bdinfo,
  330. "print Board Info structure",
  331. ""
  332. );