bdinfo.c 12.3 KB
Newer Older
wdenk's avatar
wdenk committed
1 2 3 4
/*
 * (C) Copyright 2003
 * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
 *
5
 * SPDX-License-Identifier:	GPL-2.0+
wdenk's avatar
wdenk committed
6 7 8 9 10 11 12
 */

/*
 * Boot support
 */
#include <common.h>
#include <command.h>
13
#include <linux/compiler.h>
wdenk's avatar
wdenk committed
14

15
DECLARE_GLOBAL_DATA_PTR;
wdenk's avatar
wdenk committed
16

17 18 19 20 21
__maybe_unused
static void print_num(const char *name, ulong value)
{
	printf("%-12s= 0x%08lX\n", name, value);
}
wdenk's avatar
wdenk committed
22

23
__maybe_unused
24 25 26 27 28 29 30 31 32 33 34 35
static void print_eth(int idx)
{
	char name[10], *val;
	if (idx)
		sprintf(name, "eth%iaddr", idx);
	else
		strcpy(name, "ethaddr");
	val = getenv(name);
	if (!val)
		val = "(not set)";
	printf("%-12s= %s\n", name, val);
}
36

37
#ifndef CONFIG_DM_ETH
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55
__maybe_unused
static void print_eths(void)
{
	struct eth_device *dev;
	int i = 0;

	do {
		dev = eth_get_dev_by_index(i);
		if (dev) {
			printf("eth%dname    = %s\n", i, dev->name);
			print_eth(i);
			i++;
		}
	} while (dev);

	printf("current eth = %s\n", eth_get_name());
	printf("ip_addr     = %s\n", getenv("ipaddr"));
}
56
#endif
57

58
__maybe_unused
59
static void print_lnum(const char *name, unsigned long long value)
60 61 62 63 64 65 66 67 68 69 70
{
	printf("%-12s= 0x%.8llX\n", name, value);
}

__maybe_unused
static void print_mhz(const char *name, unsigned long hz)
{
	char buf[32];

	printf("%-12s= %6s MHz\n", name, strmhz(buf, hz));
}
wdenk's avatar
wdenk committed
71

72 73 74 75 76 77

static inline void print_bi_boot_params(const bd_t *bd)
{
	print_num("boot_params",	(ulong)bd->bi_boot_params);
}

78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94
static inline void print_bi_mem(const bd_t *bd)
{
#if defined(CONFIG_SH)
	print_num("mem start      ",	(ulong)bd->bi_memstart);
	print_lnum("mem size       ",	(u64)bd->bi_memsize);
#elif defined(CONFIG_ARC)
	print_num("mem start",		(ulong)bd->bi_memstart);
	print_lnum("mem size",		(u64)bd->bi_memsize);
#elif defined(CONFIG_AVR32)
	print_num("memstart",		(ulong)bd->bi_dram[0].start);
	print_lnum("memsize",		(u64)bd->bi_dram[0].size);
#else
	print_num("memstart",		(ulong)bd->bi_memstart);
	print_lnum("memsize",		(u64)bd->bi_memsize);
#endif
}

95 96 97 98 99 100
static inline void print_bi_dram(const bd_t *bd)
{
#ifdef CONFIG_NR_DRAM_BANKS
	int i;

	for (i = 0; i < CONFIG_NR_DRAM_BANKS; ++i) {
101 102 103 104 105
		if (bd->bi_dram[i].size) {
			print_num("DRAM bank",	i);
			print_num("-> start",	bd->bi_dram[i].start);
			print_num("-> size",	bd->bi_dram[i].size);
		}
106 107 108 109
	}
#endif
}

110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127
static inline void print_bi_flash(const bd_t *bd)
{
#if defined(CONFIG_MICROBLAZE) || defined(CONFIG_SH)
	print_num("flash start    ",	(ulong)bd->bi_flashstart);
	print_num("flash size     ",	(ulong)bd->bi_flashsize);
	print_num("flash offset   ",	(ulong)bd->bi_flashoffset);

#elif defined(CONFIG_NIOS2) || defined(CONFIG_OPENRISC)
	print_num("flash start",	(ulong)bd->bi_flashstart);
	print_num("flash size",		(ulong)bd->bi_flashsize);
	print_num("flash offset",	(ulong)bd->bi_flashoffset);
#else
	print_num("flashstart",		(ulong)bd->bi_flashstart);
	print_num("flashsize",		(ulong)bd->bi_flashsize);
	print_num("flashoffset",	(ulong)bd->bi_flashoffset);
#endif
}

128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150
static inline void print_eth_ip_addr(void)
{
#if defined(CONFIG_CMD_NET)
	print_eth(0);
#if defined(CONFIG_HAS_ETH1)
	print_eth(1);
#endif
#if defined(CONFIG_HAS_ETH2)
	print_eth(2);
#endif
#if defined(CONFIG_HAS_ETH3)
	print_eth(3);
#endif
#if defined(CONFIG_HAS_ETH4)
	print_eth(4);
#endif
#if defined(CONFIG_HAS_ETH5)
	print_eth(5);
#endif
	printf("IP addr     = %s\n", getenv("ipaddr"));
#endif
}

151 152 153 154 155 156 157 158 159 160 161
static inline void print_baudrate(void)
{
#if defined(CONFIG_PPC)
	printf("baudrate    = %6u bps\n", gd->baudrate);
#elif defined(CONFIG_SPARC)
	printf("baudrate               = %6u bps\n", gd->baudrate);
#else
	printf("baudrate    = %u bps\n", gd->baudrate);
#endif
}

162 163 164 165 166 167 168 169 170
static inline void print_std_bdinfo(const bd_t *bd)
{
	print_bi_boot_params(bd);
	print_bi_mem(bd);
	print_bi_flash(bd);
	print_eth_ip_addr();
	print_baudrate();
}

171
#if defined(CONFIG_PPC)
172 173 174 175
void __weak board_detail(void)
{
	/* Please define boot_detail() for your platform */
}
wdenk's avatar
wdenk committed
176

177
int do_bdinfo(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
wdenk's avatar
wdenk committed
178 179 180 181
{
	bd_t *bd = gd->bd;

#ifdef DEBUG
182 183
	print_num("bd address",		(ulong)bd);
#endif
184
	print_bi_mem(bd);
185
	print_bi_flash(bd);
186 187 188
	print_num("sramstart",		bd->bi_sramstart);
	print_num("sramsize",		bd->bi_sramsize);
#if	defined(CONFIG_5xx)  || defined(CONFIG_8xx) || \
189
	defined(CONFIG_MPC8260) || defined(CONFIG_E500)
190 191 192
	print_num("immr_base",		bd->bi_immr_base);
#endif
	print_num("bootflags",		bd->bi_bootflags);
193
#if	defined(CONFIG_405EP) || \
194 195 196 197 198
	defined(CONFIG_405GP) || \
	defined(CONFIG_440EP) || defined(CONFIG_440EPX) || \
	defined(CONFIG_440GR) || defined(CONFIG_440GRX) || \
	defined(CONFIG_440SP) || defined(CONFIG_440SPE) || \
	defined(CONFIG_XILINX_405)
199 200
	print_mhz("procfreq",		bd->bi_procfreq);
	print_mhz("plb_busfreq",	bd->bi_plb_busfreq);
201 202 203 204
#if	defined(CONFIG_405EP) || defined(CONFIG_405GP) || \
	defined(CONFIG_440EP) || defined(CONFIG_440EPX) || \
	defined(CONFIG_440GR) || defined(CONFIG_440GRX) || \
	defined(CONFIG_440SPE) || defined(CONFIG_XILINX_405)
205
	print_mhz("pci_busfreq",	bd->bi_pci_busfreq);
wdenk's avatar
wdenk committed
206
#endif
207
#else	/* ! CONFIG_405GP, CONFIG_405EP, CONFIG_XILINX_405, CONFIG_440EP CONFIG_440GR */
208
#if defined(CONFIG_CPM2)
209 210 211
	print_mhz("vco",		bd->bi_vco);
	print_mhz("sccfreq",		bd->bi_sccfreq);
	print_mhz("brgfreq",		bd->bi_brgfreq);
wdenk's avatar
wdenk committed
212
#endif
213
	print_mhz("intfreq",		bd->bi_intfreq);
214
#if defined(CONFIG_CPM2)
215
	print_mhz("cpmfreq",		bd->bi_cpmfreq);
wdenk's avatar
wdenk committed
216
#endif
217
	print_mhz("busfreq",		bd->bi_busfreq);
218
#endif /* CONFIG_405GP, CONFIG_405EP, CONFIG_XILINX_405, CONFIG_440EP CONFIG_440GR */
219

220 221 222 223 224 225 226 227
#ifdef CONFIG_ENABLE_36BIT_PHYS
#ifdef CONFIG_PHYS_64BIT
	puts("addressing  = 36-bit\n");
#else
	puts("addressing  = 32-bit\n");
#endif
#endif

228
	print_eth_ip_addr();
229
	print_baudrate();
230
	print_num("relocaddr", gd->relocaddr);
231
	board_detail();
wdenk's avatar
wdenk committed
232 233 234
	return 0;
}

235
#elif defined(CONFIG_NIOS2)
236

237
int do_bdinfo(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
238 239 240
{
	bd_t *bd = gd->bd;

241
	print_bi_dram(bd);
242
	print_bi_flash(bd);
243

244
#if defined(CONFIG_SYS_SRAM_BASE)
245 246 247 248
	print_num ("sram start",	(ulong)bd->bi_sramstart);
	print_num ("sram size",		(ulong)bd->bi_sramsize);
#endif

249
	print_eth_ip_addr();
250
	print_baudrate();
251 252 253

	return 0;
}
254 255

#elif defined(CONFIG_MICROBLAZE)
256

257
int do_bdinfo(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
258 259
{
	bd_t *bd = gd->bd;
260

261
	print_bi_dram(bd);
262
	print_bi_flash(bd);
263
#if defined(CONFIG_SYS_SRAM_BASE)
264 265
	print_num("sram start     ",	(ulong)bd->bi_sramstart);
	print_num("sram size      ",	(ulong)bd->bi_sramsize);
266
#endif
267
#if defined(CONFIG_CMD_NET) && !defined(CONFIG_DM_ETH)
268
	print_eths();
269
#endif
270
	print_baudrate();
271 272
	print_num("relocaddr", gd->relocaddr);
	print_num("reloc off", gd->reloc_off);
273 274 275
	print_num("fdt_blob", (ulong)gd->fdt_blob);
	print_num("new_fdt", (ulong)gd->new_fdt);
	print_num("fdt_size", (ulong)gd->fdt_size);
276

277 278
	return 0;
}
279

280 281
#elif defined(CONFIG_SPARC)

282
int do_bdinfo(cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[])
283 284 285 286 287 288 289
{
	bd_t *bd = gd->bd;

#ifdef DEBUG
	print_num("bd address             ", (ulong) bd);
#endif
	print_num("memstart               ", bd->bi_memstart);
290
	print_lnum("memsize                ", bd->bi_memsize);
291
	print_num("flashstart             ", bd->bi_flashstart);
292
	print_num("CONFIG_SYS_MONITOR_BASE       ", CONFIG_SYS_MONITOR_BASE);
293
	print_num("CONFIG_ENV_ADDR           ", CONFIG_ENV_ADDR);
294
	printf("CONFIG_SYS_RELOC_MONITOR_BASE = 0x%x (%d)\n", CONFIG_SYS_RELOC_MONITOR_BASE,
295
	       CONFIG_SYS_MONITOR_LEN);
296
	printf("CONFIG_SYS_MALLOC_BASE        = 0x%x (%d)\n", CONFIG_SYS_MALLOC_BASE,
297
	       CONFIG_SYS_MALLOC_LEN);
298
	printf("CONFIG_SYS_INIT_SP_OFFSET     = 0x%x (%d)\n", CONFIG_SYS_INIT_SP_OFFSET,
299
	       CONFIG_SYS_STACK_SIZE);
300
	printf("CONFIG_SYS_PROM_OFFSET        = 0x%x (%d)\n", CONFIG_SYS_PROM_OFFSET,
301
	       CONFIG_SYS_PROM_SIZE);
302
	printf("CONFIG_SYS_GBL_DATA_OFFSET    = 0x%x (%d)\n", CONFIG_SYS_GBL_DATA_OFFSET,
303
	       GENERATED_GBL_DATA_SIZE);
304

305
	print_eth_ip_addr();
306
	print_baudrate();
307 308 309
	return 0;
}

310 311
#elif defined(CONFIG_M68K)

312
int do_bdinfo(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
313 314
{
	bd_t *bd = gd->bd;
315

316
	print_bi_mem(bd);
317
	print_bi_flash(bd);
318
#if defined(CONFIG_SYS_INIT_RAM_ADDR)
319 320
	print_num("sramstart",		(ulong)bd->bi_sramstart);
	print_num("sramsize",		(ulong)bd->bi_sramsize);
321
#endif
322
#if defined(CONFIG_SYS_MBAR)
323
	print_num("mbar",		bd->bi_mbar_base);
324
#endif
325 326
	print_mhz("cpufreq",		bd->bi_intfreq);
	print_mhz("busfreq",		bd->bi_busfreq);
327
#ifdef CONFIG_PCI
328
	print_mhz("pcifreq",		bd->bi_pcifreq);
329 330
#endif
#ifdef CONFIG_EXTRA_CLOCK
331 332 333
	print_mhz("flbfreq",		bd->bi_flbfreq);
	print_mhz("inpfreq",		bd->bi_inpfreq);
	print_mhz("vcofreq",		bd->bi_vcofreq);
334
#endif
335
	print_eth_ip_addr();
336
	print_baudrate();
337 338 339 340

	return 0;
}

341
#elif defined(CONFIG_BLACKFIN)
342

343
int do_bdinfo(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
344 345 346 347 348 349
{
	bd_t *bd = gd->bd;

	printf("U-Boot      = %s\n", bd->bi_r_version);
	printf("CPU         = %s\n", bd->bi_cpu);
	printf("Board       = %s\n", bd->bi_board_name);
350 351 352
	print_mhz("VCO",	bd->bi_vco);
	print_mhz("CCLK",	bd->bi_cclk);
	print_mhz("SCLK",	bd->bi_sclk);
353

354
	print_std_bdinfo(bd);
355 356 357 358

	return 0;
}

359
#elif defined(CONFIG_MIPS)
wdenk's avatar
wdenk committed
360

361
int do_bdinfo(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
wdenk's avatar
wdenk committed
362
{
363
	print_std_bdinfo(gd->bd);
364 365
	print_num("relocaddr", gd->relocaddr);
	print_num("reloc off", gd->reloc_off);
wdenk's avatar
wdenk committed
366 367 368 369

	return 0;
}

370 371
#elif defined(CONFIG_AVR32)

372
int do_bdinfo(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
373
{
374
	print_std_bdinfo(gd->bd);
375 376 377 378
	return 0;
}

#elif defined(CONFIG_ARM)
wdenk's avatar
wdenk committed
379

380 381
static int do_bdinfo(cmd_tbl_t *cmdtp, int flag, int argc,
			char * const argv[])
wdenk's avatar
wdenk committed
382 383 384
{
	bd_t *bd = gd->bd;

385
	print_num("arch_number",	bd->bi_arch_number);
386
	print_bi_boot_params(bd);
387
	print_bi_dram(bd);
wdenk's avatar
wdenk committed
388

York Sun's avatar
York Sun committed
389
#ifdef CONFIG_SYS_MEM_RESERVE_SECURE
390
	if (gd->arch.secure_ram & MEM_RESERVE_SECURE_SECURED) {
York Sun's avatar
York Sun committed
391
		print_num("Secure ram",
392
			  gd->arch.secure_ram & MEM_RESERVE_SECURE_ADDR_MASK);
York Sun's avatar
York Sun committed
393 394
	}
#endif
395
#if defined(CONFIG_CMD_NET) && !defined(CONFIG_DM_ETH)
396
	print_eths();
397
#endif
398
	print_baudrate();
399
#if !(defined(CONFIG_SYS_ICACHE_OFF) && defined(CONFIG_SYS_DCACHE_OFF))
400
	print_num("TLB addr", gd->arch.tlb_addr);
401
#endif
402 403 404 405
	print_num("relocaddr", gd->relocaddr);
	print_num("reloc off", gd->reloc_off);
	print_num("irq_sp", gd->irq_sp);	/* irq stack pointer */
	print_num("sp start ", gd->start_addr_sp);
406
#if defined(CONFIG_LCD) || defined(CONFIG_VIDEO)
407
	print_num("FB base  ", gd->fb_base);
408
#endif
409 410 411 412 413 414 415 416
	/*
	 * TODO: Currently only support for davinci SOC's is added.
	 * Remove this check once all the board implement this.
	 */
#ifdef CONFIG_CLOCKS
	printf("ARM frequency = %ld MHz\n", gd->bd->bi_arm_freq);
	printf("DSP frequency = %ld MHz\n", gd->bd->bi_dsp_freq);
	printf("DDR frequency = %ld MHz\n", gd->bd->bi_ddr_freq);
417 418 419
#endif
#ifdef CONFIG_BOARD_TYPES
	printf("Board Type  = %ld\n", gd->board_type);
420
#endif
421 422 423 424 425
#ifdef CONFIG_SYS_MALLOC_F
	printf("Early malloc usage: %lx / %x\n", gd->malloc_ptr,
	       CONFIG_SYS_MALLOC_F_LEN);
#endif

wdenk's avatar
wdenk committed
426 427 428
	return 0;
}

429 430
#elif defined(CONFIG_SH)

431
int do_bdinfo(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
432 433
{
	bd_t *bd = gd->bd;
434 435

	print_bi_mem(bd);
436
	print_bi_flash(bd);
437
	print_eth_ip_addr();
438
	print_baudrate();
439 440 441
	return 0;
}

Graeme Russ's avatar
Graeme Russ committed
442 443
#elif defined(CONFIG_X86)

444
int do_bdinfo(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
Graeme Russ's avatar
Graeme Russ committed
445 446 447
{
	bd_t *bd = gd->bd;

448
	print_bi_boot_params(bd);
449

450
	print_bi_dram(bd);
Graeme Russ's avatar
Graeme Russ committed
451 452

#if defined(CONFIG_CMD_NET)
453
	print_eth_ip_addr();
454
	print_mhz("ethspeed",	    bd->bi_ethspeed);
Graeme Russ's avatar
Graeme Russ committed
455
#endif
456
	print_baudrate();
Graeme Russ's avatar
Graeme Russ committed
457 458 459 460

	return 0;
}

461 462 463 464 465 466
#elif defined(CONFIG_SANDBOX)

int do_bdinfo(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
{
	bd_t *bd = gd->bd;

467
	print_bi_boot_params(bd);
468
	print_bi_dram(bd);
469
	print_eth_ip_addr();
470

471
#if defined(CONFIG_LCD) || defined(CONFIG_VIDEO)
472
	print_num("FB base  ", gd->fb_base);
473
#endif
474 475 476
	return 0;
}

477 478 479 480 481 482 483
#elif defined(CONFIG_NDS32)

int do_bdinfo(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
{
	bd_t *bd = gd->bd;

	print_num("arch_number",	bd->bi_arch_number);
484
	print_bi_boot_params(bd);
485
	print_bi_dram(bd);
486
	print_eth_ip_addr();
487
	print_baudrate();
488 489 490 491

	return 0;
}

492 493 494 495 496 497
#elif defined(CONFIG_OPENRISC)

int do_bdinfo(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
{
	bd_t *bd = gd->bd;

498
	print_bi_mem(bd);
499
	print_bi_flash(bd);
500
	print_eth_ip_addr();
501
	print_baudrate();
502 503 504 505

	return 0;
}

506
#elif defined(CONFIG_ARC)
507 508 509 510 511

int do_bdinfo(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
{
	bd_t *bd = gd->bd;

512
	print_bi_mem(bd);
513
	print_eth_ip_addr();
514
	print_baudrate();
515 516 517 518

	return 0;
}

519 520 521 522 523 524 525 526
#elif defined(CONFIG_XTENSA)

int do_bdinfo(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
{
	print_std_bdinfo(gd->bd);
	return 0;
}

527 528 529
#else
 #error "a case for this architecture does not exist!"
#endif
wdenk's avatar
wdenk committed
530 531 532

/* -------------------------------------------------------------------- */

533 534
U_BOOT_CMD(
	bdinfo,	1,	1,	do_bdinfo,
Peter Tyser's avatar
Peter Tyser committed
535
	"print Board Info structure",
536
	""
wdenk's avatar
wdenk committed
537
);