cmd_bdinfo.c 11 KB

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