bdinfo.c 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. // SPDX-License-Identifier: GPL-2.0+
  2. /*
  3. * Implements the 'bd' command to show board information
  4. *
  5. * (C) Copyright 2003
  6. * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
  7. */
  8. #include <common.h>
  9. #include <command.h>
  10. #include <env.h>
  11. #include <lmb.h>
  12. #include <net.h>
  13. #include <vsprintf.h>
  14. #include <asm/cache.h>
  15. DECLARE_GLOBAL_DATA_PTR;
  16. void bdinfo_print_num(const char *name, ulong value)
  17. {
  18. printf("%-12s= 0x%0*lx\n", name, 2 * (int)sizeof(value), value);
  19. }
  20. static void print_eth(int idx)
  21. {
  22. char name[10], *val;
  23. if (idx)
  24. sprintf(name, "eth%iaddr", idx);
  25. else
  26. strcpy(name, "ethaddr");
  27. val = env_get(name);
  28. if (!val)
  29. val = "(not set)";
  30. printf("%-12s= %s\n", name, val);
  31. }
  32. static void print_phys_addr(const char *name, phys_addr_t value)
  33. {
  34. printf("%-12s= 0x%.*llx\n", name, 2 * (int)sizeof(ulong),
  35. (unsigned long long)value);
  36. }
  37. void bdinfo_print_mhz(const char *name, unsigned long hz)
  38. {
  39. char buf[32];
  40. printf("%-12s= %6s MHz\n", name, strmhz(buf, hz));
  41. }
  42. static void print_bi_dram(const struct bd_info *bd)
  43. {
  44. #ifdef CONFIG_NR_DRAM_BANKS
  45. int i;
  46. for (i = 0; i < CONFIG_NR_DRAM_BANKS; ++i) {
  47. if (bd->bi_dram[i].size) {
  48. bdinfo_print_num("DRAM bank", i);
  49. bdinfo_print_num("-> start", bd->bi_dram[i].start);
  50. bdinfo_print_num("-> size", bd->bi_dram[i].size);
  51. }
  52. }
  53. #endif
  54. }
  55. __weak void arch_print_bdinfo(void)
  56. {
  57. }
  58. int do_bdinfo(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
  59. {
  60. struct bd_info *bd = gd->bd;
  61. #ifdef DEBUG
  62. bdinfo_print_num("bd address", (ulong)bd);
  63. #endif
  64. bdinfo_print_num("boot_params", (ulong)bd->bi_boot_params);
  65. print_bi_dram(bd);
  66. bdinfo_print_num("memstart", (ulong)bd->bi_memstart);
  67. print_phys_addr("memsize", bd->bi_memsize);
  68. if (IS_ENABLED(CONFIG_SYS_HAS_SRAM)) {
  69. bdinfo_print_num("sramstart", (ulong)bd->bi_sramstart);
  70. bdinfo_print_num("sramsize", (ulong)bd->bi_sramsize);
  71. }
  72. bdinfo_print_num("flashstart", (ulong)bd->bi_flashstart);
  73. bdinfo_print_num("flashsize", (ulong)bd->bi_flashsize);
  74. bdinfo_print_num("flashoffset", (ulong)bd->bi_flashoffset);
  75. printf("baudrate = %u bps\n", gd->baudrate);
  76. bdinfo_print_num("relocaddr", gd->relocaddr);
  77. bdinfo_print_num("reloc off", gd->reloc_off);
  78. printf("%-12s= %u-bit\n", "Build", (uint)sizeof(void *) * 8);
  79. if (IS_ENABLED(CONFIG_CMD_NET)) {
  80. printf("current eth = %s\n", eth_get_name());
  81. print_eth(0);
  82. printf("IP addr = %s\n", env_get("ipaddr"));
  83. }
  84. bdinfo_print_num("fdt_blob", (ulong)gd->fdt_blob);
  85. bdinfo_print_num("new_fdt", (ulong)gd->new_fdt);
  86. bdinfo_print_num("fdt_size", (ulong)gd->fdt_size);
  87. #if defined(CONFIG_LCD) || defined(CONFIG_VIDEO) || defined(CONFIG_DM_VIDEO)
  88. bdinfo_print_num("FB base ", gd->fb_base);
  89. #endif
  90. #if CONFIG_IS_ENABLED(MULTI_DTB_FIT)
  91. bdinfo_print_num("multi_dtb_fit", (ulong)gd->multi_dtb_fit);
  92. #endif
  93. if (gd->fdt_blob) {
  94. struct lmb lmb;
  95. lmb_init_and_reserve(&lmb, gd->bd, (void *)gd->fdt_blob);
  96. lmb_dump_all_force(&lmb);
  97. }
  98. arch_print_bdinfo();
  99. return 0;
  100. }
  101. U_BOOT_CMD(
  102. bdinfo, 1, 1, do_bdinfo,
  103. "print Board Info structure",
  104. ""
  105. );