cmd_bdinfo.c 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180
  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. #if (CONFIG_COMMANDS & CFG_CMD_BDI)
  29. static void print_num(const char *, ulong);
  30. #ifndef CONFIG_ARM /* PowerPC and other */
  31. #ifdef CONFIG_PPC
  32. static void print_str(const char *, const char *);
  33. int do_bdinfo ( cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
  34. {
  35. DECLARE_GLOBAL_DATA_PTR;
  36. int i;
  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_num ("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) || defined(CONFIG_8260)
  50. print_num ("immr_base", bd->bi_immr_base );
  51. #endif
  52. print_num ("bootflags", bd->bi_bootflags );
  53. #if defined(CONFIG_405GP) || defined(CONFIG_405CR) || defined(CONFIG_405EP)
  54. print_str ("procfreq", strmhz(buf, bd->bi_procfreq));
  55. print_str ("plb_busfreq", strmhz(buf, bd->bi_plb_busfreq));
  56. #if defined(CONFIG_405GP) || defined(CONFIG_405EP)
  57. print_str ("pci_busfreq", strmhz(buf, bd->bi_pci_busfreq));
  58. #endif
  59. #else /* ! CONFIG_405GP, CONFIG_405CR, CONFIG_405EP */
  60. #if defined(CONFIG_8260)
  61. print_str ("vco", strmhz(buf, bd->bi_vco));
  62. print_str ("sccfreq", strmhz(buf, bd->bi_sccfreq));
  63. print_str ("brgfreq", strmhz(buf, bd->bi_brgfreq));
  64. #endif
  65. print_str ("intfreq", strmhz(buf, bd->bi_intfreq));
  66. #if defined(CONFIG_8260)
  67. print_str ("cpmfreq", strmhz(buf, bd->bi_cpmfreq));
  68. #endif
  69. print_str ("busfreq", strmhz(buf, bd->bi_busfreq));
  70. #endif /* CONFIG_405GP, CONFIG_405CR, CONFIG_405EP */
  71. printf ("ethaddr =");
  72. for (i=0; i<6; ++i) {
  73. printf ("%c%02X", i ? ':' : ' ', bd->bi_enetaddr[i]);
  74. }
  75. #ifdef CONFIG_PN62
  76. printf ("\neth1addr =");
  77. for (i=0; i<6; ++i) {
  78. printf ("%c%02X", i ? ':' : ' ', bd->bi_enet1addr[i]);
  79. }
  80. #endif /* CONFIG_PN62 */
  81. #ifdef CONFIG_HERMES
  82. print_str ("ethspeed", strmhz(buf, bd->bi_ethspeed));
  83. #endif
  84. printf ("\nIP addr = "); print_IPaddr (bd->bi_ip_addr);
  85. printf ("\nbaudrate = %6ld bps\n", bd->bi_baudrate );
  86. return 0;
  87. }
  88. #else /* ! PPC, which leaves MIPS */
  89. int do_bdinfo ( cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
  90. {
  91. DECLARE_GLOBAL_DATA_PTR;
  92. int i;
  93. bd_t *bd = gd->bd;
  94. print_num ("boot_params", (ulong)bd->bi_boot_params);
  95. print_num ("memstart", (ulong)bd->bi_memstart);
  96. print_num ("memsize", (ulong)bd->bi_memsize);
  97. print_num ("flashstart", (ulong)bd->bi_flashstart);
  98. print_num ("flashsize", (ulong)bd->bi_flashsize);
  99. print_num ("flashoffset", (ulong)bd->bi_flashoffset);
  100. printf ("ethaddr =");
  101. for (i=0; i<6; ++i) {
  102. printf ("%c%02X", i ? ':' : ' ', bd->bi_enetaddr[i]);
  103. }
  104. printf ("\nip_addr = ");
  105. print_IPaddr (bd->bi_ip_addr);
  106. printf ("\nbaudrate = %d bps\n", bd->bi_baudrate);
  107. return 0;
  108. }
  109. #endif /* MIPS */
  110. #else /* ARM */
  111. int do_bdinfo ( cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
  112. {
  113. DECLARE_GLOBAL_DATA_PTR;
  114. int i;
  115. bd_t *bd = gd->bd;
  116. print_num ("arch_number", bd->bi_arch_number);
  117. print_num ("env_t", (ulong)bd->bi_env);
  118. print_num ("boot_params", (ulong)bd->bi_boot_params);
  119. for (i=0; i<CONFIG_NR_DRAM_BANKS; ++i) {
  120. print_num("DRAM bank", i);
  121. print_num("-> start", bd->bi_dram[i].start);
  122. print_num("-> size", bd->bi_dram[i].size);
  123. }
  124. printf ("ethaddr =");
  125. for (i=0; i<6; ++i) {
  126. printf ("%c%02X", i ? ':' : ' ', bd->bi_enetaddr[i]);
  127. }
  128. printf ("\n"
  129. "ip_addr = ");
  130. print_IPaddr (bd->bi_ip_addr);
  131. printf ("\n"
  132. "baudrate = %d bps\n", bd->bi_baudrate);
  133. return 0;
  134. }
  135. #endif /* CONFIG_ARM XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX */
  136. static void print_num(const char *name, ulong value)
  137. {
  138. printf ("%-12s= 0x%08lX\n", name, value);
  139. }
  140. #ifdef CONFIG_PPC
  141. static void print_str(const char *name, const char *str)
  142. {
  143. printf ("%-12s= %6s MHz\n", name, str);
  144. }
  145. #endif /* CONFIG_PPC */
  146. /* -------------------------------------------------------------------- */
  147. cmd_tbl_t U_BOOT_CMD(BDINFO) = MK_CMD_ENTRY(
  148. "bdinfo", 1, 1, do_bdinfo,
  149. "bdinfo - print Board Info structure\n",
  150. NULL
  151. );
  152. #endif /* CFG_CMD_BDI */