1 // SPDX-License-Identifier: GPL-2.0+
3 * Implements the 'bd' command to show board information
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_str(const char *name, const char *str)
31 printf("%-12s= %s\n", name, str);
34 void bdinfo_print_num_l(const char *name, ulong value)
36 printf("%-12s= 0x%0*lx\n", name, 2 * (int)sizeof(value), value);
39 void bdinfo_print_num_ll(const char *name, unsigned long long value)
41 printf("%-12s= 0x%.*llx\n", name, 2 * (int)sizeof(ulong), value);
44 static void print_eth(int idx)
48 sprintf(name, "eth%iaddr", idx);
50 strcpy(name, "ethaddr");
54 printf("%-12s= %s\n", name, val);
57 void bdinfo_print_mhz(const char *name, unsigned long hz)
61 printf("%-12s= %6s MHz\n", name, strmhz(buf, hz));
64 static void print_bi_dram(const struct bd_info *bd)
68 for (i = 0; i < CONFIG_NR_DRAM_BANKS; ++i) {
69 if (bd->bi_dram[i].size) {
70 bdinfo_print_num_l("DRAM bank", i);
71 bdinfo_print_num_ll("-> start", bd->bi_dram[i].start);
72 bdinfo_print_num_ll("-> size", bd->bi_dram[i].size);
77 __weak void arch_print_bdinfo(void)
81 static void show_video_info(void)
83 const struct udevice *dev;
86 uclass_id_foreach_dev(UCLASS_VIDEO, dev, uc) {
87 printf("%-12s= %s %sactive\n", "Video", dev->name,
88 device_active(dev) ? "" : "in");
89 if (device_active(dev)) {
90 struct video_priv *upriv = dev_get_uclass_priv(dev);
91 struct video_uc_plat *plat = dev_get_uclass_plat(dev);
93 bdinfo_print_num_ll("FB base", (ulong)upriv->fb);
95 bdinfo_print_num_ll("FB copy",
96 (ulong)upriv->copy_fb);
97 bdinfo_print_num_l(" copy size",
100 printf("%-12s= %dx%dx%d\n", "FB size", upriv->xsize,
101 upriv->ysize, 1 << upriv->bpix);
106 int do_bdinfo(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
108 struct bd_info *bd = gd->bd;
111 bdinfo_print_num_l("bd address", (ulong)bd);
113 bdinfo_print_num_l("boot_params", (ulong)bd->bi_boot_params);
115 if (IS_ENABLED(CONFIG_SYS_HAS_SRAM)) {
116 bdinfo_print_num_l("sramstart", (ulong)bd->bi_sramstart);
117 bdinfo_print_num_l("sramsize", (ulong)bd->bi_sramsize);
119 bdinfo_print_num_l("flashstart", (ulong)bd->bi_flashstart);
120 bdinfo_print_num_l("flashsize", (ulong)bd->bi_flashsize);
121 bdinfo_print_num_l("flashoffset", (ulong)bd->bi_flashoffset);
122 printf("baudrate = %u bps\n", gd->baudrate);
123 bdinfo_print_num_l("relocaddr", gd->relocaddr);
124 bdinfo_print_num_l("reloc off", gd->reloc_off);
125 printf("%-12s= %u-bit\n", "Build", (uint)sizeof(void *) * 8);
126 if (IS_ENABLED(CONFIG_CMD_NET)) {
127 printf("current eth = %s\n", eth_get_name());
129 printf("IP addr = %s\n", env_get("ipaddr"));
131 bdinfo_print_num_l("fdt_blob", (ulong)gd->fdt_blob);
132 bdinfo_print_num_l("new_fdt", (ulong)gd->new_fdt);
133 bdinfo_print_num_l("fdt_size", (ulong)gd->fdt_size);
134 if (IS_ENABLED(CONFIG_VIDEO))
136 #if CONFIG_IS_ENABLED(MULTI_DTB_FIT)
137 bdinfo_print_num_l("multi_dtb_fit", (ulong)gd->multi_dtb_fit);
139 if (IS_ENABLED(CONFIG_LMB) && gd->fdt_blob) {
142 lmb_init_and_reserve(&lmb, gd->bd, (void *)gd->fdt_blob);
143 lmb_dump_all_force(&lmb);
144 if (IS_ENABLED(CONFIG_OF_REAL))
145 printf("devicetree = %s\n", fdtdec_get_srcname());
154 bdinfo, 1, 1, do_bdinfo,
155 "print Board Info structure",