xref: /openbmc/u-boot/cmd/bdinfo.c (revision a381bcf5)
1 /*
2  * (C) Copyright 2003
3  * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
4  *
5  * SPDX-License-Identifier:	GPL-2.0+
6  */
7 
8 /*
9  * Boot support
10  */
11 #include <common.h>
12 #include <command.h>
13 #include <linux/compiler.h>
14 
15 DECLARE_GLOBAL_DATA_PTR;
16 
17 __maybe_unused
18 static void print_num(const char *name, ulong value)
19 {
20 	printf("%-12s= 0x%08lX\n", name, value);
21 }
22 
23 __maybe_unused
24 static void print_eth(int idx)
25 {
26 	char name[10], *val;
27 	if (idx)
28 		sprintf(name, "eth%iaddr", idx);
29 	else
30 		strcpy(name, "ethaddr");
31 	val = getenv(name);
32 	if (!val)
33 		val = "(not set)";
34 	printf("%-12s= %s\n", name, val);
35 }
36 
37 #ifndef CONFIG_DM_ETH
38 __maybe_unused
39 static void print_eths(void)
40 {
41 	struct eth_device *dev;
42 	int i = 0;
43 
44 	do {
45 		dev = eth_get_dev_by_index(i);
46 		if (dev) {
47 			printf("eth%dname    = %s\n", i, dev->name);
48 			print_eth(i);
49 			i++;
50 		}
51 	} while (dev);
52 
53 	printf("current eth = %s\n", eth_get_name());
54 	printf("ip_addr     = %s\n", getenv("ipaddr"));
55 }
56 #endif
57 
58 __maybe_unused
59 static void print_lnum(const char *name, unsigned long long value)
60 {
61 	printf("%-12s= 0x%.8llX\n", name, value);
62 }
63 
64 __maybe_unused
65 static void print_mhz(const char *name, unsigned long hz)
66 {
67 	char buf[32];
68 
69 	printf("%-12s= %6s MHz\n", name, strmhz(buf, hz));
70 }
71 
72 #if defined(CONFIG_PPC)
73 void __weak board_detail(void)
74 {
75 	/* Please define boot_detail() for your platform */
76 }
77 
78 int do_bdinfo(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
79 {
80 	bd_t *bd = gd->bd;
81 
82 #ifdef DEBUG
83 	print_num("bd address",		(ulong)bd);
84 #endif
85 	print_num("memstart",		bd->bi_memstart);
86 	print_lnum("memsize",		bd->bi_memsize);
87 	print_num("flashstart",		bd->bi_flashstart);
88 	print_num("flashsize",		bd->bi_flashsize);
89 	print_num("flashoffset",	bd->bi_flashoffset);
90 	print_num("sramstart",		bd->bi_sramstart);
91 	print_num("sramsize",		bd->bi_sramsize);
92 #if	defined(CONFIG_5xx)  || defined(CONFIG_8xx) || \
93 	defined(CONFIG_MPC8260) || defined(CONFIG_E500)
94 	print_num("immr_base",		bd->bi_immr_base);
95 #endif
96 	print_num("bootflags",		bd->bi_bootflags);
97 #if	defined(CONFIG_405EP) || \
98 	defined(CONFIG_405GP) || \
99 	defined(CONFIG_440EP) || defined(CONFIG_440EPX) || \
100 	defined(CONFIG_440GR) || defined(CONFIG_440GRX) || \
101 	defined(CONFIG_440SP) || defined(CONFIG_440SPE) || \
102 	defined(CONFIG_XILINX_405)
103 	print_mhz("procfreq",		bd->bi_procfreq);
104 	print_mhz("plb_busfreq",	bd->bi_plb_busfreq);
105 #if	defined(CONFIG_405EP) || defined(CONFIG_405GP) || \
106 	defined(CONFIG_440EP) || defined(CONFIG_440EPX) || \
107 	defined(CONFIG_440GR) || defined(CONFIG_440GRX) || \
108 	defined(CONFIG_440SPE) || defined(CONFIG_XILINX_405)
109 	print_mhz("pci_busfreq",	bd->bi_pci_busfreq);
110 #endif
111 #else	/* ! CONFIG_405GP, CONFIG_405EP, CONFIG_XILINX_405, CONFIG_440EP CONFIG_440GR */
112 #if defined(CONFIG_CPM2)
113 	print_mhz("vco",		bd->bi_vco);
114 	print_mhz("sccfreq",		bd->bi_sccfreq);
115 	print_mhz("brgfreq",		bd->bi_brgfreq);
116 #endif
117 	print_mhz("intfreq",		bd->bi_intfreq);
118 #if defined(CONFIG_CPM2)
119 	print_mhz("cpmfreq",		bd->bi_cpmfreq);
120 #endif
121 	print_mhz("busfreq",		bd->bi_busfreq);
122 #endif /* CONFIG_405GP, CONFIG_405EP, CONFIG_XILINX_405, CONFIG_440EP CONFIG_440GR */
123 
124 #ifdef CONFIG_ENABLE_36BIT_PHYS
125 #ifdef CONFIG_PHYS_64BIT
126 	puts("addressing  = 36-bit\n");
127 #else
128 	puts("addressing  = 32-bit\n");
129 #endif
130 #endif
131 
132 	print_eth(0);
133 #if defined(CONFIG_HAS_ETH1)
134 	print_eth(1);
135 #endif
136 #if defined(CONFIG_HAS_ETH2)
137 	print_eth(2);
138 #endif
139 #if defined(CONFIG_HAS_ETH3)
140 	print_eth(3);
141 #endif
142 #if defined(CONFIG_HAS_ETH4)
143 	print_eth(4);
144 #endif
145 #if defined(CONFIG_HAS_ETH5)
146 	print_eth(5);
147 #endif
148 
149 	printf("IP addr     = %s\n", getenv("ipaddr"));
150 	printf("baudrate    = %6u bps\n", gd->baudrate);
151 	print_num("relocaddr", gd->relocaddr);
152 	board_detail();
153 	return 0;
154 }
155 
156 #elif defined(CONFIG_NIOS2)
157 
158 int do_bdinfo(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
159 {
160 	int i;
161 	bd_t *bd = gd->bd;
162 
163 	for (i = 0; i < CONFIG_NR_DRAM_BANKS; ++i) {
164 		print_num("DRAM bank",	i);
165 		print_num("-> start",	bd->bi_dram[i].start);
166 		print_num("-> size",	bd->bi_dram[i].size);
167 	}
168 
169 	print_num("flash start",	(ulong)bd->bi_flashstart);
170 	print_num("flash size",		(ulong)bd->bi_flashsize);
171 	print_num("flash offset",	(ulong)bd->bi_flashoffset);
172 
173 #if defined(CONFIG_SYS_SRAM_BASE)
174 	print_num ("sram start",	(ulong)bd->bi_sramstart);
175 	print_num ("sram size",		(ulong)bd->bi_sramsize);
176 #endif
177 
178 #if defined(CONFIG_CMD_NET)
179 	print_eth(0);
180 	printf("ip_addr     = %s\n", getenv("ipaddr"));
181 #endif
182 
183 	printf("baudrate    = %u bps\n", gd->baudrate);
184 
185 	return 0;
186 }
187 
188 #elif defined(CONFIG_MICROBLAZE)
189 
190 int do_bdinfo(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
191 {
192 	bd_t *bd = gd->bd;
193 	int i;
194 
195 	for (i = 0; i < CONFIG_NR_DRAM_BANKS; ++i) {
196 		print_num("DRAM bank",	i);
197 		print_num("-> start",	bd->bi_dram[i].start);
198 		print_num("-> size",	bd->bi_dram[i].size);
199 	}
200 
201 	print_num("flash start    ",	(ulong)bd->bi_flashstart);
202 	print_num("flash size     ",	(ulong)bd->bi_flashsize);
203 	print_num("flash offset   ",	(ulong)bd->bi_flashoffset);
204 #if defined(CONFIG_SYS_SRAM_BASE)
205 	print_num("sram start     ",	(ulong)bd->bi_sramstart);
206 	print_num("sram size      ",	(ulong)bd->bi_sramsize);
207 #endif
208 #if defined(CONFIG_CMD_NET) && !defined(CONFIG_DM_ETH)
209 	print_eths();
210 #endif
211 	printf("baudrate    = %u bps\n", gd->baudrate);
212 	print_num("relocaddr", gd->relocaddr);
213 	print_num("reloc off", gd->reloc_off);
214 	print_num("fdt_blob", (ulong)gd->fdt_blob);
215 	print_num("new_fdt", (ulong)gd->new_fdt);
216 	print_num("fdt_size", (ulong)gd->fdt_size);
217 
218 	return 0;
219 }
220 
221 #elif defined(CONFIG_SPARC)
222 
223 int do_bdinfo(cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[])
224 {
225 	bd_t *bd = gd->bd;
226 
227 #ifdef DEBUG
228 	print_num("bd address             ", (ulong) bd);
229 #endif
230 	print_num("memstart               ", bd->bi_memstart);
231 	print_lnum("memsize                ", bd->bi_memsize);
232 	print_num("flashstart             ", bd->bi_flashstart);
233 	print_num("CONFIG_SYS_MONITOR_BASE       ", CONFIG_SYS_MONITOR_BASE);
234 	print_num("CONFIG_ENV_ADDR           ", CONFIG_ENV_ADDR);
235 	printf("CONFIG_SYS_RELOC_MONITOR_BASE = 0x%x (%d)\n", CONFIG_SYS_RELOC_MONITOR_BASE,
236 	       CONFIG_SYS_MONITOR_LEN);
237 	printf("CONFIG_SYS_MALLOC_BASE        = 0x%x (%d)\n", CONFIG_SYS_MALLOC_BASE,
238 	       CONFIG_SYS_MALLOC_LEN);
239 	printf("CONFIG_SYS_INIT_SP_OFFSET     = 0x%x (%d)\n", CONFIG_SYS_INIT_SP_OFFSET,
240 	       CONFIG_SYS_STACK_SIZE);
241 	printf("CONFIG_SYS_PROM_OFFSET        = 0x%x (%d)\n", CONFIG_SYS_PROM_OFFSET,
242 	       CONFIG_SYS_PROM_SIZE);
243 	printf("CONFIG_SYS_GBL_DATA_OFFSET    = 0x%x (%d)\n", CONFIG_SYS_GBL_DATA_OFFSET,
244 	       GENERATED_GBL_DATA_SIZE);
245 
246 #if defined(CONFIG_CMD_NET)
247 	print_eth(0);
248 	printf("ip_addr     = %s\n", getenv("ipaddr"));
249 #endif
250 	printf("baudrate               = %6u bps\n", gd->baudrate);
251 	return 0;
252 }
253 
254 #elif defined(CONFIG_M68K)
255 
256 int do_bdinfo(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
257 {
258 	bd_t *bd = gd->bd;
259 
260 	print_num("memstart",		(ulong)bd->bi_memstart);
261 	print_lnum("memsize",		(u64)bd->bi_memsize);
262 	print_num("flashstart",		(ulong)bd->bi_flashstart);
263 	print_num("flashsize",		(ulong)bd->bi_flashsize);
264 	print_num("flashoffset",	(ulong)bd->bi_flashoffset);
265 #if defined(CONFIG_SYS_INIT_RAM_ADDR)
266 	print_num("sramstart",		(ulong)bd->bi_sramstart);
267 	print_num("sramsize",		(ulong)bd->bi_sramsize);
268 #endif
269 #if defined(CONFIG_SYS_MBAR)
270 	print_num("mbar",		bd->bi_mbar_base);
271 #endif
272 	print_mhz("cpufreq",		bd->bi_intfreq);
273 	print_mhz("busfreq",		bd->bi_busfreq);
274 #ifdef CONFIG_PCI
275 	print_mhz("pcifreq",		bd->bi_pcifreq);
276 #endif
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);
281 #endif
282 #if defined(CONFIG_CMD_NET)
283 	print_eth(0);
284 #if defined(CONFIG_HAS_ETH1)
285 	print_eth(1);
286 #endif
287 #if defined(CONFIG_HAS_ETH2)
288 	print_eth(2);
289 #endif
290 #if defined(CONFIG_HAS_ETH3)
291 	print_eth(3);
292 #endif
293 
294 	printf("ip_addr     = %s\n", getenv("ipaddr"));
295 #endif
296 	printf("baudrate    = %u bps\n", gd->baudrate);
297 
298 	return 0;
299 }
300 
301 #elif defined(CONFIG_BLACKFIN)
302 
303 int do_bdinfo(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
304 {
305 	bd_t *bd = gd->bd;
306 
307 	printf("U-Boot      = %s\n", bd->bi_r_version);
308 	printf("CPU         = %s\n", bd->bi_cpu);
309 	printf("Board       = %s\n", bd->bi_board_name);
310 	print_mhz("VCO",	bd->bi_vco);
311 	print_mhz("CCLK",	bd->bi_cclk);
312 	print_mhz("SCLK",	bd->bi_sclk);
313 
314 	print_num("boot_params",	(ulong)bd->bi_boot_params);
315 	print_num("memstart",		(ulong)bd->bi_memstart);
316 	print_lnum("memsize",		(u64)bd->bi_memsize);
317 	print_num("flashstart",		(ulong)bd->bi_flashstart);
318 	print_num("flashsize",		(ulong)bd->bi_flashsize);
319 	print_num("flashoffset",	(ulong)bd->bi_flashoffset);
320 
321 	print_eth(0);
322 	printf("ip_addr     = %s\n", getenv("ipaddr"));
323 	printf("baudrate    = %u bps\n", gd->baudrate);
324 
325 	return 0;
326 }
327 
328 #elif defined(CONFIG_MIPS)
329 
330 int do_bdinfo(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
331 {
332 	bd_t *bd = gd->bd;
333 
334 	print_num("boot_params",	(ulong)bd->bi_boot_params);
335 	print_num("memstart",		(ulong)bd->bi_memstart);
336 	print_lnum("memsize",		(u64)bd->bi_memsize);
337 	print_num("flashstart",		(ulong)bd->bi_flashstart);
338 	print_num("flashsize",		(ulong)bd->bi_flashsize);
339 	print_num("flashoffset",	(ulong)bd->bi_flashoffset);
340 
341 	print_eth(0);
342 	printf("ip_addr     = %s\n", getenv("ipaddr"));
343 	printf("baudrate    = %u bps\n", gd->baudrate);
344 	print_num("relocaddr", gd->relocaddr);
345 	print_num("reloc off", gd->reloc_off);
346 
347 	return 0;
348 }
349 
350 #elif defined(CONFIG_AVR32)
351 
352 int do_bdinfo(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
353 {
354 	bd_t *bd = gd->bd;
355 
356 	print_num("boot_params",	(ulong)bd->bi_boot_params);
357 	print_num("memstart",		(ulong)bd->bi_dram[0].start);
358 	print_lnum("memsize",		(u64)bd->bi_dram[0].size);
359 	print_num("flashstart",		(ulong)bd->bi_flashstart);
360 	print_num("flashsize",		(ulong)bd->bi_flashsize);
361 	print_num("flashoffset",	(ulong)bd->bi_flashoffset);
362 
363 	print_eth(0);
364 	printf("ip_addr     = %s\n", getenv("ipaddr"));
365 	printf("baudrate    = %u bps\n", gd->baudrate);
366 
367 	return 0;
368 }
369 
370 #elif defined(CONFIG_ARM)
371 
372 static int do_bdinfo(cmd_tbl_t *cmdtp, int flag, int argc,
373 			char * const argv[])
374 {
375 	int i;
376 	bd_t *bd = gd->bd;
377 
378 	print_num("arch_number",	bd->bi_arch_number);
379 	print_num("boot_params",	(ulong)bd->bi_boot_params);
380 
381 	for (i = 0; i < CONFIG_NR_DRAM_BANKS; ++i) {
382 		print_num("DRAM bank",	i);
383 		print_num("-> start",	bd->bi_dram[i].start);
384 		print_num("-> size",	bd->bi_dram[i].size);
385 	}
386 
387 #ifdef CONFIG_SYS_MEM_RESERVE_SECURE
388 	if (gd->arch.secure_ram & MEM_RESERVE_SECURE_SECURED) {
389 		print_num("Secure ram",
390 			  gd->arch.secure_ram & MEM_RESERVE_SECURE_ADDR_MASK);
391 	}
392 #endif
393 #if defined(CONFIG_CMD_NET) && !defined(CONFIG_DM_ETH)
394 	print_eths();
395 #endif
396 	printf("baudrate    = %u bps\n", gd->baudrate);
397 #if !(defined(CONFIG_SYS_ICACHE_OFF) && defined(CONFIG_SYS_DCACHE_OFF))
398 	print_num("TLB addr", gd->arch.tlb_addr);
399 #endif
400 	print_num("relocaddr", gd->relocaddr);
401 	print_num("reloc off", gd->reloc_off);
402 	print_num("irq_sp", gd->irq_sp);	/* irq stack pointer */
403 	print_num("sp start ", gd->start_addr_sp);
404 #if defined(CONFIG_LCD) || defined(CONFIG_VIDEO)
405 	print_num("FB base  ", gd->fb_base);
406 #endif
407 	/*
408 	 * TODO: Currently only support for davinci SOC's is added.
409 	 * Remove this check once all the board implement this.
410 	 */
411 #ifdef CONFIG_CLOCKS
412 	printf("ARM frequency = %ld MHz\n", gd->bd->bi_arm_freq);
413 	printf("DSP frequency = %ld MHz\n", gd->bd->bi_dsp_freq);
414 	printf("DDR frequency = %ld MHz\n", gd->bd->bi_ddr_freq);
415 #endif
416 #ifdef CONFIG_BOARD_TYPES
417 	printf("Board Type  = %ld\n", gd->board_type);
418 #endif
419 	return 0;
420 }
421 
422 #elif defined(CONFIG_SH)
423 
424 int do_bdinfo(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
425 {
426 	bd_t *bd = gd->bd;
427 	print_num("mem start      ",	(ulong)bd->bi_memstart);
428 	print_lnum("mem size       ",	(u64)bd->bi_memsize);
429 	print_num("flash start    ",	(ulong)bd->bi_flashstart);
430 	print_num("flash size     ",	(ulong)bd->bi_flashsize);
431 	print_num("flash offset   ",	(ulong)bd->bi_flashoffset);
432 
433 #if defined(CONFIG_CMD_NET)
434 	print_eth(0);
435 	printf("ip_addr     = %s\n", getenv("ipaddr"));
436 #endif
437 	printf("baudrate    = %u bps\n", gd->baudrate);
438 	return 0;
439 }
440 
441 #elif defined(CONFIG_X86)
442 
443 int do_bdinfo(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
444 {
445 	int i;
446 	bd_t *bd = gd->bd;
447 
448 	print_num("boot_params",	(ulong)bd->bi_boot_params);
449 	print_num("bi_memstart",	bd->bi_memstart);
450 	print_num("bi_memsize",		bd->bi_memsize);
451 	print_num("bi_flashstart",	bd->bi_flashstart);
452 	print_num("bi_flashsize",	bd->bi_flashsize);
453 	print_num("bi_flashoffset",	bd->bi_flashoffset);
454 	print_num("bi_sramstart",	bd->bi_sramstart);
455 	print_num("bi_sramsize",	bd->bi_sramsize);
456 	print_num("bi_bootflags",	bd->bi_bootflags);
457 	print_mhz("cpufreq",		bd->bi_intfreq);
458 	print_mhz("busfreq",		bd->bi_busfreq);
459 
460 	for (i = 0; i < CONFIG_NR_DRAM_BANKS; ++i) {
461 		print_num("DRAM bank",	i);
462 		print_num("-> start",	bd->bi_dram[i].start);
463 		print_num("-> size",	bd->bi_dram[i].size);
464 	}
465 
466 #if defined(CONFIG_CMD_NET)
467 	print_eth(0);
468 	printf("ip_addr     = %s\n", getenv("ipaddr"));
469 	print_mhz("ethspeed",	    bd->bi_ethspeed);
470 #endif
471 	printf("baudrate    = %u bps\n", gd->baudrate);
472 
473 	return 0;
474 }
475 
476 #elif defined(CONFIG_SANDBOX)
477 
478 int do_bdinfo(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
479 {
480 	int i;
481 	bd_t *bd = gd->bd;
482 
483 	print_num("boot_params", (ulong)bd->bi_boot_params);
484 
485 	for (i = 0; i < CONFIG_NR_DRAM_BANKS; ++i) {
486 		print_num("DRAM bank", i);
487 		print_num("-> start", bd->bi_dram[i].start);
488 		print_num("-> size", bd->bi_dram[i].size);
489 	}
490 
491 #if defined(CONFIG_CMD_NET)
492 	print_eth(0);
493 	printf("ip_addr     = %s\n", getenv("ipaddr"));
494 #endif
495 #if defined(CONFIG_LCD) || defined(CONFIG_VIDEO)
496 	print_num("FB base  ", gd->fb_base);
497 #endif
498 	return 0;
499 }
500 
501 #elif defined(CONFIG_NDS32)
502 
503 int do_bdinfo(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
504 {
505 	int i;
506 	bd_t *bd = gd->bd;
507 
508 	print_num("arch_number",	bd->bi_arch_number);
509 	print_num("boot_params",	(ulong)bd->bi_boot_params);
510 
511 	for (i = 0; i < CONFIG_NR_DRAM_BANKS; ++i) {
512 		print_num("DRAM bank",	i);
513 		print_num("-> start",	bd->bi_dram[i].start);
514 		print_num("-> size",	bd->bi_dram[i].size);
515 	}
516 
517 #if defined(CONFIG_CMD_NET)
518 	print_eth(0);
519 	printf("ip_addr     = %s\n", getenv("ipaddr"));
520 #endif
521 	printf("baudrate    = %u bps\n", gd->baudrate);
522 
523 	return 0;
524 }
525 
526 #elif defined(CONFIG_OPENRISC)
527 
528 int do_bdinfo(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
529 {
530 	bd_t *bd = gd->bd;
531 
532 	print_num("mem start",		(ulong)bd->bi_memstart);
533 	print_lnum("mem size",		(u64)bd->bi_memsize);
534 	print_num("flash start",	(ulong)bd->bi_flashstart);
535 	print_num("flash size",		(ulong)bd->bi_flashsize);
536 	print_num("flash offset",	(ulong)bd->bi_flashoffset);
537 
538 #if defined(CONFIG_CMD_NET)
539 	print_eth(0);
540 	printf("ip_addr     = %s\n", getenv("ipaddr"));
541 #endif
542 
543 	printf("baudrate    = %u bps\n", gd->baudrate);
544 
545 	return 0;
546 }
547 
548 #elif defined(CONFIG_ARC)
549 
550 int do_bdinfo(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
551 {
552 	bd_t *bd = gd->bd;
553 
554 	print_num("mem start",		bd->bi_memstart);
555 	print_lnum("mem size",		bd->bi_memsize);
556 
557 #if defined(CONFIG_CMD_NET)
558 	print_eth(0);
559 	printf("ip_addr     = %s\n", getenv("ipaddr"));
560 #endif
561 	printf("baudrate    = %d bps\n", gd->baudrate);
562 
563 	return 0;
564 }
565 
566 #else
567  #error "a case for this architecture does not exist!"
568 #endif
569 
570 /* -------------------------------------------------------------------- */
571 
572 U_BOOT_CMD(
573 	bdinfo,	1,	1,	do_bdinfo,
574 	"print Board Info structure",
575 	""
576 );
577