cmd_bdinfo.c 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259
  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. #include <net.h> /* for print_IPaddr */
  29. DECLARE_GLOBAL_DATA_PTR;
  30. #if (CONFIG_COMMANDS & CFG_CMD_BDI)
  31. static void print_num(const char *, ulong);
  32. #ifndef CONFIG_ARM /* PowerPC and other */
  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. int i;
  38. bd_t *bd = gd->bd;
  39. char buf[32];
  40. #ifdef DEBUG
  41. print_num ("bd address", (ulong)bd );
  42. #endif
  43. print_num ("memstart", bd->bi_memstart );
  44. print_num ("memsize", bd->bi_memsize );
  45. print_num ("flashstart", bd->bi_flashstart );
  46. print_num ("flashsize", bd->bi_flashsize );
  47. print_num ("flashoffset", bd->bi_flashoffset );
  48. print_num ("sramstart", bd->bi_sramstart );
  49. print_num ("sramsize", bd->bi_sramsize );
  50. #if defined(CONFIG_5xx) || defined(CONFIG_8xx) || \
  51. defined(CONFIG_8260) || defined(CONFIG_E500)
  52. print_num ("immr_base", bd->bi_immr_base );
  53. #endif
  54. print_num ("bootflags", bd->bi_bootflags );
  55. #if defined(CONFIG_405GP) || defined(CONFIG_405CR) || \
  56. defined(CONFIG_405EP) || defined(CONFIG_XILINX_ML300) || \
  57. defined(CONFIG_440EP) || defined(CONFIG_440GR)
  58. print_str ("procfreq", strmhz(buf, bd->bi_procfreq));
  59. print_str ("plb_busfreq", strmhz(buf, bd->bi_plb_busfreq));
  60. #if defined(CONFIG_405GP) || defined(CONFIG_405EP) || defined(CONFIG_XILINX_ML300) || \
  61. defined(CONFIG_440EP) || defined(CONFIG_440GR)
  62. print_str ("pci_busfreq", strmhz(buf, bd->bi_pci_busfreq));
  63. #endif
  64. #else /* ! CONFIG_405GP, CONFIG_405CR, CONFIG_405EP, CONFIG_XILINX_ML300, CONFIG_440EP CONFIG_440GR */
  65. #if defined(CONFIG_CPM2)
  66. print_str ("vco", strmhz(buf, bd->bi_vco));
  67. print_str ("sccfreq", strmhz(buf, bd->bi_sccfreq));
  68. print_str ("brgfreq", strmhz(buf, bd->bi_brgfreq));
  69. #endif
  70. print_str ("intfreq", strmhz(buf, bd->bi_intfreq));
  71. #if defined(CONFIG_CPM2)
  72. print_str ("cpmfreq", strmhz(buf, bd->bi_cpmfreq));
  73. #endif
  74. print_str ("busfreq", strmhz(buf, bd->bi_busfreq));
  75. #endif /* CONFIG_405GP, CONFIG_405CR, CONFIG_405EP, CONFIG_XILINX_ML300, CONFIG_440EP CONFIG_440GR */
  76. #if defined(CONFIG_MPC8220)
  77. print_str ("inpfreq", strmhz(buf, bd->bi_inpfreq));
  78. print_str ("flbfreq", strmhz(buf, bd->bi_flbfreq));
  79. print_str ("pcifreq", strmhz(buf, bd->bi_pcifreq));
  80. print_str ("vcofreq", strmhz(buf, bd->bi_vcofreq));
  81. print_str ("pevfreq", strmhz(buf, bd->bi_pevfreq));
  82. #endif
  83. puts ("ethaddr =");
  84. for (i=0; i<6; ++i) {
  85. printf ("%c%02X", i ? ':' : ' ', bd->bi_enetaddr[i]);
  86. }
  87. #if defined(CONFIG_HAS_ETH1)
  88. puts ("\neth1addr =");
  89. for (i=0; i<6; ++i) {
  90. printf ("%c%02X", i ? ':' : ' ', bd->bi_enet1addr[i]);
  91. }
  92. #endif
  93. #if defined(CONFIG_HAS_ETH2)
  94. puts ("\neth2addr =");
  95. for (i=0; i<6; ++i) {
  96. printf ("%c%02X", i ? ':' : ' ', bd->bi_enet2addr[i]);
  97. }
  98. #endif
  99. #if defined(CONFIG_HAS_ETH3)
  100. puts ("\neth3addr =");
  101. for (i=0; i<6; ++i) {
  102. printf ("%c%02X", i ? ':' : ' ', bd->bi_enet3addr[i]);
  103. }
  104. #endif
  105. #ifdef CONFIG_HERMES
  106. print_str ("ethspeed", strmhz(buf, bd->bi_ethspeed));
  107. #endif
  108. puts ("\nIP addr = "); print_IPaddr (bd->bi_ip_addr);
  109. printf ("\nbaudrate = %6ld bps\n", bd->bi_baudrate );
  110. return 0;
  111. }
  112. #elif defined(CONFIG_NIOS) /* NIOS*/
  113. int do_bdinfo ( cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
  114. {
  115. int i;
  116. bd_t *bd = gd->bd;
  117. print_num ("memstart", (ulong)bd->bi_memstart);
  118. print_num ("memsize", (ulong)bd->bi_memsize);
  119. print_num ("flashstart", (ulong)bd->bi_flashstart);
  120. print_num ("flashsize", (ulong)bd->bi_flashsize);
  121. print_num ("flashoffset", (ulong)bd->bi_flashoffset);
  122. puts ("ethaddr =");
  123. for (i=0; i<6; ++i) {
  124. printf ("%c%02X", i ? ':' : ' ', bd->bi_enetaddr[i]);
  125. }
  126. puts ("\nip_addr = ");
  127. print_IPaddr (bd->bi_ip_addr);
  128. printf ("\nbaudrate = %ld bps\n", bd->bi_baudrate);
  129. return 0;
  130. }
  131. #elif defined(CONFIG_NIOS2) /* Nios-II */
  132. int do_bdinfo ( cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
  133. {
  134. int i;
  135. bd_t *bd = gd->bd;
  136. print_num ("mem start", (ulong)bd->bi_memstart);
  137. print_num ("mem size", (ulong)bd->bi_memsize);
  138. print_num ("flash start", (ulong)bd->bi_flashstart);
  139. print_num ("flash size", (ulong)bd->bi_flashsize);
  140. print_num ("flash offset", (ulong)bd->bi_flashoffset);
  141. #if defined(CFG_SRAM_BASE)
  142. print_num ("sram start", (ulong)bd->bi_sramstart);
  143. print_num ("sram size", (ulong)bd->bi_sramsize);
  144. #endif
  145. #if defined(CFG_CMD_NET)
  146. puts ("ethaddr =");
  147. for (i=0; i<6; ++i) {
  148. printf ("%c%02X", i ? ':' : ' ', bd->bi_enetaddr[i]);
  149. }
  150. puts ("\nip_addr = ");
  151. print_IPaddr (bd->bi_ip_addr);
  152. #endif
  153. printf ("\nbaudrate = %ld bps\n", bd->bi_baudrate);
  154. return 0;
  155. }
  156. #else /* ! PPC, which leaves MIPS */
  157. int do_bdinfo ( cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
  158. {
  159. int i;
  160. bd_t *bd = gd->bd;
  161. print_num ("boot_params", (ulong)bd->bi_boot_params);
  162. print_num ("memstart", (ulong)bd->bi_memstart);
  163. print_num ("memsize", (ulong)bd->bi_memsize);
  164. print_num ("flashstart", (ulong)bd->bi_flashstart);
  165. print_num ("flashsize", (ulong)bd->bi_flashsize);
  166. print_num ("flashoffset", (ulong)bd->bi_flashoffset);
  167. puts ("ethaddr =");
  168. for (i=0; i<6; ++i) {
  169. printf ("%c%02X", i ? ':' : ' ', bd->bi_enetaddr[i]);
  170. }
  171. puts ("\nip_addr = ");
  172. print_IPaddr (bd->bi_ip_addr);
  173. printf ("\nbaudrate = %d bps\n", bd->bi_baudrate);
  174. return 0;
  175. }
  176. #endif /* MIPS */
  177. #else /* ARM */
  178. int do_bdinfo ( cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
  179. {
  180. int i;
  181. bd_t *bd = gd->bd;
  182. print_num ("arch_number", bd->bi_arch_number);
  183. print_num ("env_t", (ulong)bd->bi_env);
  184. print_num ("boot_params", (ulong)bd->bi_boot_params);
  185. for (i=0; i<CONFIG_NR_DRAM_BANKS; ++i) {
  186. print_num("DRAM bank", i);
  187. print_num("-> start", bd->bi_dram[i].start);
  188. print_num("-> size", bd->bi_dram[i].size);
  189. }
  190. puts ("ethaddr =");
  191. for (i=0; i<6; ++i) {
  192. printf ("%c%02X", i ? ':' : ' ', bd->bi_enetaddr[i]);
  193. }
  194. puts ( "\n"
  195. "ip_addr = ");
  196. print_IPaddr (bd->bi_ip_addr);
  197. printf ("\n"
  198. "baudrate = %d bps\n", bd->bi_baudrate);
  199. return 0;
  200. }
  201. #endif /* CONFIG_ARM XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX */
  202. static void print_num(const char *name, ulong value)
  203. {
  204. printf ("%-12s= 0x%08lX\n", name, value);
  205. }
  206. #ifdef CONFIG_PPC
  207. static void print_str(const char *name, const char *str)
  208. {
  209. printf ("%-12s= %6s MHz\n", name, str);
  210. }
  211. #endif /* CONFIG_PPC */
  212. /* -------------------------------------------------------------------- */
  213. U_BOOT_CMD(
  214. bdinfo, 1, 1, do_bdinfo,
  215. "bdinfo - print Board Info structure\n",
  216. NULL
  217. );
  218. #endif /* CFG_CMD_BDI */