1 // SPDX-License-Identifier: GPL-2.0+
4 * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
12 #include <linux/compiler.h>
14 DECLARE_GLOBAL_DATA_PTR;
17 static void print_num(const char *name, ulong value)
19 printf("%-12s= 0x%0*lx\n", name, 2 * (int)sizeof(value), value);
23 static void print_eth(int idx)
27 sprintf(name, "eth%iaddr", idx);
29 strcpy(name, "ethaddr");
33 printf("%-12s= %s\n", name, val);
38 static void print_eths(void)
40 struct eth_device *dev;
44 dev = eth_get_dev_by_index(i);
46 printf("eth%dname = %s\n", i, dev->name);
52 printf("current eth = %s\n", eth_get_name());
53 printf("ip_addr = %s\n", env_get("ipaddr"));
58 static void print_lnum(const char *name, unsigned long long value)
60 printf("%-12s= 0x%.8llX\n", name, value);
64 static void print_mhz(const char *name, unsigned long hz)
68 printf("%-12s= %6s MHz\n", name, strmhz(buf, hz));
72 static inline void print_bi_boot_params(const bd_t *bd)
74 print_num("boot_params", (ulong)bd->bi_boot_params);
77 static inline void print_bi_mem(const bd_t *bd)
79 #if defined(CONFIG_SH)
80 print_num("mem start ", (ulong)bd->bi_memstart);
81 print_lnum("mem size ", (u64)bd->bi_memsize);
82 #elif defined(CONFIG_ARC)
83 print_num("mem start", (ulong)bd->bi_memstart);
84 print_lnum("mem size", (u64)bd->bi_memsize);
86 print_num("memstart", (ulong)bd->bi_memstart);
87 print_lnum("memsize", (u64)bd->bi_memsize);
91 static inline void print_bi_dram(const bd_t *bd)
93 #ifdef CONFIG_NR_DRAM_BANKS
96 for (i = 0; i < CONFIG_NR_DRAM_BANKS; ++i) {
97 if (bd->bi_dram[i].size) {
98 print_num("DRAM bank", i);
99 print_num("-> start", bd->bi_dram[i].start);
100 print_num("-> size", bd->bi_dram[i].size);
106 static inline void print_bi_flash(const bd_t *bd)
108 #if defined(CONFIG_MICROBLAZE) || defined(CONFIG_SH)
109 print_num("flash start ", (ulong)bd->bi_flashstart);
110 print_num("flash size ", (ulong)bd->bi_flashsize);
111 print_num("flash offset ", (ulong)bd->bi_flashoffset);
113 #elif defined(CONFIG_NIOS2)
114 print_num("flash start", (ulong)bd->bi_flashstart);
115 print_num("flash size", (ulong)bd->bi_flashsize);
116 print_num("flash offset", (ulong)bd->bi_flashoffset);
118 print_num("flashstart", (ulong)bd->bi_flashstart);
119 print_num("flashsize", (ulong)bd->bi_flashsize);
120 print_num("flashoffset", (ulong)bd->bi_flashoffset);
124 static inline void print_eth_ip_addr(void)
126 #if defined(CONFIG_CMD_NET)
128 #if defined(CONFIG_HAS_ETH1)
131 #if defined(CONFIG_HAS_ETH2)
134 #if defined(CONFIG_HAS_ETH3)
137 #if defined(CONFIG_HAS_ETH4)
140 #if defined(CONFIG_HAS_ETH5)
143 printf("IP addr = %s\n", env_get("ipaddr"));
147 static inline void print_baudrate(void)
149 #if defined(CONFIG_PPC)
150 printf("baudrate = %6u bps\n", gd->baudrate);
152 printf("baudrate = %u bps\n", gd->baudrate);
156 static inline void __maybe_unused print_std_bdinfo(const bd_t *bd)
158 print_bi_boot_params(bd);
165 #if defined(CONFIG_PPC)
166 void __weak board_detail(void)
168 /* Please define board_detail() for your platform */
171 int do_bdinfo(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
176 print_num("bd address", (ulong)bd);
180 print_num("sramstart", bd->bi_sramstart);
181 print_num("sramsize", bd->bi_sramsize);
182 #if defined(CONFIG_MPC8xx) || defined(CONFIG_E500)
183 print_num("immr_base", bd->bi_immr_base);
185 print_num("bootflags", bd->bi_bootflags);
186 #if defined(CONFIG_CPM2)
187 print_mhz("vco", bd->bi_vco);
188 print_mhz("sccfreq", bd->bi_sccfreq);
189 print_mhz("brgfreq", bd->bi_brgfreq);
191 print_mhz("intfreq", bd->bi_intfreq);
192 #if defined(CONFIG_CPM2)
193 print_mhz("cpmfreq", bd->bi_cpmfreq);
195 print_mhz("busfreq", bd->bi_busfreq);
197 #ifdef CONFIG_ENABLE_36BIT_PHYS
198 #ifdef CONFIG_PHYS_64BIT
199 puts("addressing = 36-bit\n");
201 puts("addressing = 32-bit\n");
207 print_num("relocaddr", gd->relocaddr);
212 #elif defined(CONFIG_NIOS2)
214 int do_bdinfo(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
221 #if defined(CONFIG_SYS_SRAM_BASE)
222 print_num ("sram start", (ulong)bd->bi_sramstart);
223 print_num ("sram size", (ulong)bd->bi_sramsize);
232 #elif defined(CONFIG_MICROBLAZE)
234 int do_bdinfo(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
240 #if defined(CONFIG_SYS_SRAM_BASE)
241 print_num("sram start ", (ulong)bd->bi_sramstart);
242 print_num("sram size ", (ulong)bd->bi_sramsize);
244 #if defined(CONFIG_CMD_NET) && !defined(CONFIG_DM_ETH)
248 print_num("relocaddr", gd->relocaddr);
249 print_num("reloc off", gd->reloc_off);
250 print_num("fdt_blob", (ulong)gd->fdt_blob);
251 print_num("new_fdt", (ulong)gd->new_fdt);
252 print_num("fdt_size", (ulong)gd->fdt_size);
257 #elif defined(CONFIG_M68K)
259 int do_bdinfo(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
265 #if defined(CONFIG_SYS_INIT_RAM_ADDR)
266 print_num("sramstart", (ulong)bd->bi_sramstart);
267 print_num("sramsize", (ulong)bd->bi_sramsize);
269 #if defined(CONFIG_SYS_MBAR)
270 print_num("mbar", bd->bi_mbar_base);
272 print_mhz("cpufreq", bd->bi_intfreq);
273 print_mhz("busfreq", bd->bi_busfreq);
275 print_mhz("pcifreq", bd->bi_pcifreq);
277 #ifdef CONFIG_EXTRA_CLOCK
278 print_mhz("flbfreq", bd->bi_flbfreq);
279 print_mhz("inpfreq", bd->bi_inpfreq);
280 print_mhz("vcofreq", bd->bi_vcofreq);
288 #elif defined(CONFIG_MIPS)
290 int do_bdinfo(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
292 print_std_bdinfo(gd->bd);
293 print_num("relocaddr", gd->relocaddr);
294 print_num("reloc off", gd->reloc_off);
299 #elif defined(CONFIG_ARM)
301 static int do_bdinfo(cmd_tbl_t *cmdtp, int flag, int argc,
306 print_num("arch_number", bd->bi_arch_number);
307 print_bi_boot_params(bd);
310 #ifdef CONFIG_SYS_MEM_RESERVE_SECURE
311 if (gd->arch.secure_ram & MEM_RESERVE_SECURE_SECURED) {
312 print_num("Secure ram",
313 gd->arch.secure_ram & MEM_RESERVE_SECURE_ADDR_MASK);
316 #ifdef CONFIG_RESV_RAM
317 if (gd->arch.resv_ram)
318 print_num("Reserved ram", gd->arch.resv_ram);
320 #if defined(CONFIG_CMD_NET) && !defined(CONFIG_DM_ETH)
324 #if !(CONFIG_IS_ENABLED(SYS_ICACHE_OFF) && CONFIG_IS_ENABLED(SYS_DCACHE_OFF))
325 print_num("TLB addr", gd->arch.tlb_addr);
327 print_num("relocaddr", gd->relocaddr);
328 print_num("reloc off", gd->reloc_off);
329 print_num("irq_sp", gd->irq_sp); /* irq stack pointer */
330 print_num("sp start ", gd->start_addr_sp);
331 #if defined(CONFIG_LCD) || defined(CONFIG_VIDEO)
332 print_num("FB base ", gd->fb_base);
335 * TODO: Currently only support for davinci SOC's is added.
336 * Remove this check once all the board implement this.
339 printf("ARM frequency = %ld MHz\n", gd->bd->bi_arm_freq);
340 printf("DSP frequency = %ld MHz\n", gd->bd->bi_dsp_freq);
341 printf("DDR frequency = %ld MHz\n", gd->bd->bi_ddr_freq);
343 #ifdef CONFIG_BOARD_TYPES
344 printf("Board Type = %ld\n", gd->board_type);
346 #if CONFIG_VAL(SYS_MALLOC_F_LEN)
347 printf("Early malloc usage: %lx / %x\n", gd->malloc_ptr,
348 CONFIG_VAL(SYS_MALLOC_F_LEN));
351 print_num("fdt_blob", (ulong)gd->fdt_blob);
356 #elif defined(CONFIG_SH)
358 int do_bdinfo(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
369 #elif defined(CONFIG_X86)
371 int do_bdinfo(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
375 print_bi_boot_params(bd);
379 print_num("relocaddr", gd->relocaddr);
380 print_num("reloc off", gd->reloc_off);
381 #if defined(CONFIG_CMD_NET)
383 print_mhz("ethspeed", bd->bi_ethspeed);
390 #elif defined(CONFIG_SANDBOX)
392 int do_bdinfo(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
396 print_bi_boot_params(bd);
400 #if defined(CONFIG_LCD) || defined(CONFIG_VIDEO)
401 print_num("FB base ", gd->fb_base);
406 #elif defined(CONFIG_NDS32)
408 int do_bdinfo(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
412 print_num("arch_number", bd->bi_arch_number);
413 print_bi_boot_params(bd);
421 #elif defined(CONFIG_RISCV)
423 int do_bdinfo(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
427 print_bi_boot_params(bd);
429 print_num("relocaddr", gd->relocaddr);
430 print_num("reloc off", gd->reloc_off);
437 #elif defined(CONFIG_ARC)
439 int do_bdinfo(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
450 #elif defined(CONFIG_XTENSA)
452 int do_bdinfo(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
454 print_std_bdinfo(gd->bd);
459 #error "a case for this architecture does not exist!"
462 /* -------------------------------------------------------------------- */
465 bdinfo, 1, 1, do_bdinfo,
466 "print Board Info structure",