1 // SPDX-License-Identifier: GPL-2.0+
3 * Implements the 'bd' command to show board information
6 * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
17 #include <asm/cache.h>
18 #include <asm/global_data.h>
19 #include <display_options.h>
21 DECLARE_GLOBAL_DATA_PTR;
23 void bdinfo_print_size(const char *name, uint64_t size)
25 printf("%-12s= ", name);
26 print_size(size, "\n");
29 void bdinfo_print_num_l(const char *name, ulong value)
31 printf("%-12s= 0x%0*lx\n", name, 2 * (int)sizeof(value), value);
34 void bdinfo_print_num_ll(const char *name, unsigned long long value)
36 printf("%-12s= 0x%.*llx\n", name, 2 * (int)sizeof(ulong), value);
39 static void print_eth(int idx)
43 sprintf(name, "eth%iaddr", idx);
45 strcpy(name, "ethaddr");
49 printf("%-12s= %s\n", name, val);
52 void bdinfo_print_mhz(const char *name, unsigned long hz)
56 printf("%-12s= %6s MHz\n", name, strmhz(buf, hz));
59 static void print_bi_dram(const struct bd_info *bd)
63 for (i = 0; i < CONFIG_NR_DRAM_BANKS; ++i) {
64 if (bd->bi_dram[i].size) {
65 bdinfo_print_num_l("DRAM bank", i);
66 bdinfo_print_num_ll("-> start", bd->bi_dram[i].start);
67 bdinfo_print_num_ll("-> size", bd->bi_dram[i].size);
72 __weak void arch_print_bdinfo(void)
76 static void show_video_info(void)
78 const struct udevice *dev;
81 uclass_id_foreach_dev(UCLASS_VIDEO, dev, uc) {
82 printf("%-12s= %s %sactive\n", "Video", dev->name,
83 device_active(dev) ? "" : "in");
84 if (device_active(dev)) {
85 struct video_priv *upriv = dev_get_uclass_priv(dev);
87 bdinfo_print_num_ll("FB base", (ulong)upriv->fb);
89 bdinfo_print_num_ll("FB copy",
90 (ulong)upriv->copy_fb);
91 printf("%-12s= %dx%dx%d\n", "FB size", upriv->xsize,
92 upriv->ysize, 1 << upriv->bpix);
97 int do_bdinfo(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
99 struct bd_info *bd = gd->bd;
102 bdinfo_print_num_l("bd address", (ulong)bd);
104 bdinfo_print_num_l("boot_params", (ulong)bd->bi_boot_params);
106 if (IS_ENABLED(CONFIG_SYS_HAS_SRAM)) {
107 bdinfo_print_num_l("sramstart", (ulong)bd->bi_sramstart);
108 bdinfo_print_num_l("sramsize", (ulong)bd->bi_sramsize);
110 bdinfo_print_num_l("flashstart", (ulong)bd->bi_flashstart);
111 bdinfo_print_num_l("flashsize", (ulong)bd->bi_flashsize);
112 bdinfo_print_num_l("flashoffset", (ulong)bd->bi_flashoffset);
113 printf("baudrate = %u bps\n", gd->baudrate);
114 bdinfo_print_num_l("relocaddr", gd->relocaddr);
115 bdinfo_print_num_l("reloc off", gd->reloc_off);
116 printf("%-12s= %u-bit\n", "Build", (uint)sizeof(void *) * 8);
117 if (IS_ENABLED(CONFIG_CMD_NET)) {
118 printf("current eth = %s\n", eth_get_name());
120 printf("IP addr = %s\n", env_get("ipaddr"));
122 bdinfo_print_num_l("fdt_blob", (ulong)gd->fdt_blob);
123 bdinfo_print_num_l("new_fdt", (ulong)gd->new_fdt);
124 bdinfo_print_num_l("fdt_size", (ulong)gd->fdt_size);
125 if (IS_ENABLED(CONFIG_DM_VIDEO))
127 #if defined(CONFIG_LCD)
128 bdinfo_print_num_l("FB base ", gd->fb_base);
130 #if CONFIG_IS_ENABLED(MULTI_DTB_FIT)
131 bdinfo_print_num_l("multi_dtb_fit", (ulong)gd->multi_dtb_fit);
133 if (IS_ENABLED(CONFIG_LMB) && gd->fdt_blob) {
136 lmb_init_and_reserve(&lmb, gd->bd, (void *)gd->fdt_blob);
137 lmb_dump_all_force(&lmb);
138 if (IS_ENABLED(CONFIG_OF_REAL))
139 printf("devicetree = %s\n", fdtdec_get_srcname());
148 bdinfo, 1, 1, do_bdinfo,
149 "print Board Info structure",