1 // SPDX-License-Identifier: GPL-2.0+
4 * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
14 #include <linux/compiler.h>
16 DECLARE_GLOBAL_DATA_PTR;
18 __maybe_unused void print_cpu_word_size(void)
20 printf("%-12s= %u-bit\n", "Build", (uint)sizeof(void *) * 8);
24 static void print_num(const char *name, ulong value)
26 printf("%-12s= 0x%0*lx\n", name, 2 * (int)sizeof(value), value);
30 static void print_eth(int idx)
34 sprintf(name, "eth%iaddr", idx);
36 strcpy(name, "ethaddr");
40 printf("%-12s= %s\n", name, val);
45 static void print_eths(void)
47 struct eth_device *dev;
51 dev = eth_get_dev_by_index(i);
53 printf("eth%dname = %s\n", i, dev->name);
59 printf("current eth = %s\n", eth_get_name());
60 printf("ip_addr = %s\n", env_get("ipaddr"));
65 static void print_lnum(const char *name, unsigned long long value)
67 printf("%-12s= 0x%.8llX\n", name, value);
71 static void print_mhz(const char *name, unsigned long hz)
75 printf("%-12s= %6s MHz\n", name, strmhz(buf, hz));
79 static inline void print_bi_boot_params(const bd_t *bd)
81 print_num("boot_params", (ulong)bd->bi_boot_params);
84 static inline void print_bi_mem(const bd_t *bd)
86 #if defined(CONFIG_SH)
87 print_num("mem start ", (ulong)bd->bi_memstart);
88 print_lnum("mem size ", (u64)bd->bi_memsize);
89 #elif defined(CONFIG_ARC)
90 print_num("mem start", (ulong)bd->bi_memstart);
91 print_lnum("mem size", (u64)bd->bi_memsize);
93 print_num("memstart", (ulong)bd->bi_memstart);
94 print_lnum("memsize", (u64)bd->bi_memsize);
98 static inline void print_bi_dram(const bd_t *bd)
100 #ifdef CONFIG_NR_DRAM_BANKS
103 for (i = 0; i < CONFIG_NR_DRAM_BANKS; ++i) {
104 if (bd->bi_dram[i].size) {
105 print_num("DRAM bank", i);
106 print_num("-> start", bd->bi_dram[i].start);
107 print_num("-> size", bd->bi_dram[i].size);
113 static inline void print_bi_flash(const bd_t *bd)
115 #if defined(CONFIG_MICROBLAZE) || defined(CONFIG_SH)
116 print_num("flash start ", (ulong)bd->bi_flashstart);
117 print_num("flash size ", (ulong)bd->bi_flashsize);
118 print_num("flash offset ", (ulong)bd->bi_flashoffset);
120 #elif defined(CONFIG_NIOS2)
121 print_num("flash start", (ulong)bd->bi_flashstart);
122 print_num("flash size", (ulong)bd->bi_flashsize);
123 print_num("flash offset", (ulong)bd->bi_flashoffset);
125 print_num("flashstart", (ulong)bd->bi_flashstart);
126 print_num("flashsize", (ulong)bd->bi_flashsize);
127 print_num("flashoffset", (ulong)bd->bi_flashoffset);
131 static inline void print_eth_ip_addr(void)
133 #if defined(CONFIG_CMD_NET)
135 #if defined(CONFIG_HAS_ETH1)
138 #if defined(CONFIG_HAS_ETH2)
141 #if defined(CONFIG_HAS_ETH3)
144 #if defined(CONFIG_HAS_ETH4)
147 #if defined(CONFIG_HAS_ETH5)
150 printf("IP addr = %s\n", env_get("ipaddr"));
154 static inline void print_baudrate(void)
156 #if defined(CONFIG_PPC)
157 printf("baudrate = %6u bps\n", gd->baudrate);
159 printf("baudrate = %u bps\n", gd->baudrate);
163 static inline void __maybe_unused print_std_bdinfo(const bd_t *bd)
165 print_bi_boot_params(bd);
172 #if defined(CONFIG_PPC)
173 void __weak board_detail(void)
175 /* Please define board_detail() for your platform */
178 int do_bdinfo(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
183 print_num("bd address", (ulong)bd);
187 print_num("sramstart", bd->bi_sramstart);
188 print_num("sramsize", bd->bi_sramsize);
189 #if defined(CONFIG_MPC8xx) || defined(CONFIG_E500)
190 print_num("immr_base", bd->bi_immr_base);
192 print_num("bootflags", bd->bi_bootflags);
193 #if defined(CONFIG_CPM2)
194 print_mhz("vco", bd->bi_vco);
195 print_mhz("sccfreq", bd->bi_sccfreq);
196 print_mhz("brgfreq", bd->bi_brgfreq);
198 print_mhz("intfreq", bd->bi_intfreq);
199 #if defined(CONFIG_CPM2)
200 print_mhz("cpmfreq", bd->bi_cpmfreq);
202 print_mhz("busfreq", bd->bi_busfreq);
204 #ifdef CONFIG_ENABLE_36BIT_PHYS
205 #ifdef CONFIG_PHYS_64BIT
206 puts("addressing = 36-bit\n");
208 puts("addressing = 32-bit\n");
214 print_num("relocaddr", gd->relocaddr);
216 print_cpu_word_size();
221 #elif defined(CONFIG_NIOS2)
223 int do_bdinfo(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
230 #if defined(CONFIG_SYS_SRAM_BASE)
231 print_num ("sram start", (ulong)bd->bi_sramstart);
232 print_num ("sram size", (ulong)bd->bi_sramsize);
237 print_cpu_word_size();
242 #elif defined(CONFIG_MICROBLAZE)
244 int do_bdinfo(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
250 #if defined(CONFIG_SYS_SRAM_BASE)
251 print_num("sram start ", (ulong)bd->bi_sramstart);
252 print_num("sram size ", (ulong)bd->bi_sramsize);
254 #if defined(CONFIG_CMD_NET) && !defined(CONFIG_DM_ETH)
258 print_num("relocaddr", gd->relocaddr);
259 print_num("reloc off", gd->reloc_off);
260 print_num("fdt_blob", (ulong)gd->fdt_blob);
261 print_num("new_fdt", (ulong)gd->new_fdt);
262 print_num("fdt_size", (ulong)gd->fdt_size);
263 print_cpu_word_size();
268 #elif defined(CONFIG_M68K)
270 int do_bdinfo(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
276 #if defined(CONFIG_SYS_INIT_RAM_ADDR)
277 print_num("sramstart", (ulong)bd->bi_sramstart);
278 print_num("sramsize", (ulong)bd->bi_sramsize);
280 #if defined(CONFIG_SYS_MBAR)
281 print_num("mbar", bd->bi_mbar_base);
283 print_mhz("cpufreq", bd->bi_intfreq);
284 print_mhz("busfreq", bd->bi_busfreq);
286 print_mhz("pcifreq", bd->bi_pcifreq);
288 #ifdef CONFIG_EXTRA_CLOCK
289 print_mhz("flbfreq", bd->bi_flbfreq);
290 print_mhz("inpfreq", bd->bi_inpfreq);
291 print_mhz("vcofreq", bd->bi_vcofreq);
295 print_cpu_word_size();
300 #elif defined(CONFIG_MIPS)
302 int do_bdinfo(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
304 print_std_bdinfo(gd->bd);
305 print_num("relocaddr", gd->relocaddr);
306 print_num("reloc off", gd->reloc_off);
307 print_cpu_word_size();
312 #elif defined(CONFIG_ARM)
314 static int do_bdinfo(cmd_tbl_t *cmdtp, int flag, int argc,
319 print_num("arch_number", bd->bi_arch_number);
320 print_bi_boot_params(bd);
323 #ifdef CONFIG_SYS_MEM_RESERVE_SECURE
324 if (gd->arch.secure_ram & MEM_RESERVE_SECURE_SECURED) {
325 print_num("Secure ram",
326 gd->arch.secure_ram & MEM_RESERVE_SECURE_ADDR_MASK);
329 #ifdef CONFIG_RESV_RAM
330 if (gd->arch.resv_ram)
331 print_num("Reserved ram", gd->arch.resv_ram);
333 #if defined(CONFIG_CMD_NET) && !defined(CONFIG_DM_ETH)
337 #if !(CONFIG_IS_ENABLED(SYS_ICACHE_OFF) && CONFIG_IS_ENABLED(SYS_DCACHE_OFF))
338 print_num("TLB addr", gd->arch.tlb_addr);
340 print_num("relocaddr", gd->relocaddr);
341 print_num("reloc off", gd->reloc_off);
342 print_num("irq_sp", gd->irq_sp); /* irq stack pointer */
343 print_num("sp start ", gd->start_addr_sp);
344 #if defined(CONFIG_LCD) || defined(CONFIG_VIDEO) || defined(CONFIG_DM_VIDEO)
345 print_num("FB base ", gd->fb_base);
348 * TODO: Currently only support for davinci SOC's is added.
349 * Remove this check once all the board implement this.
352 printf("ARM frequency = %ld MHz\n", gd->bd->bi_arm_freq);
353 printf("DSP frequency = %ld MHz\n", gd->bd->bi_dsp_freq);
354 printf("DDR frequency = %ld MHz\n", gd->bd->bi_ddr_freq);
356 #ifdef CONFIG_BOARD_TYPES
357 printf("Board Type = %ld\n", gd->board_type);
359 #if CONFIG_VAL(SYS_MALLOC_F_LEN)
360 printf("Early malloc usage: %lx / %x\n", gd->malloc_ptr,
361 CONFIG_VAL(SYS_MALLOC_F_LEN));
363 #if CONFIG_IS_ENABLED(MULTI_DTB_FIT)
364 print_num("multi_dtb_fit", (ulong)gd->multi_dtb_fit);
367 print_num("fdt_blob", (ulong)gd->fdt_blob);
368 print_cpu_word_size();
373 #elif defined(CONFIG_SH)
375 int do_bdinfo(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
383 print_cpu_word_size();
388 #elif defined(CONFIG_X86)
390 int do_bdinfo(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
394 print_bi_boot_params(bd);
398 print_num("relocaddr", gd->relocaddr);
399 print_num("reloc off", gd->reloc_off);
400 #if defined(CONFIG_CMD_NET)
402 print_mhz("ethspeed", bd->bi_ethspeed);
405 print_cpu_word_size();
410 #elif defined(CONFIG_SANDBOX)
412 int do_bdinfo(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
416 print_bi_boot_params(bd);
420 #if defined(CONFIG_LCD) || defined(CONFIG_VIDEO)
421 print_num("FB base ", gd->fb_base);
423 print_cpu_word_size();
428 #elif defined(CONFIG_NDS32)
430 int do_bdinfo(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
434 print_num("arch_number", bd->bi_arch_number);
435 print_bi_boot_params(bd);
439 print_cpu_word_size();
444 #elif defined(CONFIG_RISCV)
446 int do_bdinfo(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
450 print_bi_boot_params(bd);
452 print_num("relocaddr", gd->relocaddr);
453 print_num("reloc off", gd->reloc_off);
456 print_cpu_word_size();
461 #elif defined(CONFIG_ARC)
463 int do_bdinfo(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
470 print_cpu_word_size();
475 #elif defined(CONFIG_XTENSA)
477 int do_bdinfo(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
479 print_std_bdinfo(gd->bd);
484 #error "a case for this architecture does not exist!"
487 /* -------------------------------------------------------------------- */
490 bdinfo, 1, 1, do_bdinfo,
491 "print Board Info structure",