]> Git Repo - J-u-boot.git/blame - cmd/bdinfo.c
treewide: convert bd_t to struct bd_info by coccinelle
[J-u-boot.git] / cmd / bdinfo.c
CommitLineData
83d290c5 1// SPDX-License-Identifier: GPL-2.0+
8bde7f77 2/*
bda8909f
SG
3 * Implements the 'bd' command to show board information
4 *
8bde7f77
WD
5 * (C) Copyright 2003
6 * Wolfgang Denk, DENX Software Engineering, [email protected].
8bde7f77
WD
7 */
8
8bde7f77
WD
9#include <common.h>
10#include <command.h>
7b51b576 11#include <env.h>
90526e9f 12#include <net.h>
2189d5f1 13#include <vsprintf.h>
90526e9f 14#include <asm/cache.h>
8bde7f77 15
d87080b7 16DECLARE_GLOBAL_DATA_PTR;
8bde7f77 17
655f17ff 18void bdinfo_print_num(const char *name, ulong value)
d88af4da 19{
95187bb7 20 printf("%-12s= 0x%0*lx\n", name, 2 * (int)sizeof(value), value);
d88af4da 21}
8bde7f77 22
d88af4da
MF
23static void print_eth(int idx)
24{
25 char name[10], *val;
26 if (idx)
27 sprintf(name, "eth%iaddr", idx);
28 else
29 strcpy(name, "ethaddr");
00caae6d 30 val = env_get(name);
d88af4da
MF
31 if (!val)
32 val = "(not set)";
33 printf("%-12s= %s\n", name, val);
34}
de2dff6f 35
47708457 36static void print_lnum(const char *name, unsigned long long value)
d88af4da
MF
37{
38 printf("%-12s= 0x%.8llX\n", name, value);
39}
40
655f17ff 41void bdinfo_print_mhz(const char *name, unsigned long hz)
d88af4da
MF
42{
43 char buf[32];
44
45 printf("%-12s= %6s MHz\n", name, strmhz(buf, hz));
46}
8bde7f77 47
b75d8dc5 48static void print_bi_dram(const struct bd_info *bd)
fd60e99f
MF
49{
50#ifdef CONFIG_NR_DRAM_BANKS
51 int i;
52
53 for (i = 0; i < CONFIG_NR_DRAM_BANKS; ++i) {
ddd917b8 54 if (bd->bi_dram[i].size) {
655f17ff
SG
55 bdinfo_print_num("DRAM bank", i);
56 bdinfo_print_num("-> start", bd->bi_dram[i].start);
57 bdinfo_print_num("-> size", bd->bi_dram[i].size);
ddd917b8 58 }
fd60e99f
MF
59 }
60#endif
61}
62
59b0d7d8
SG
63__weak void arch_print_bdinfo(void)
64{
65}
66
09140113 67int do_bdinfo(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
de5e5cea 68{
b75d8dc5 69 struct bd_info *bd = gd->bd;
2e0fa217
SG
70
71#ifdef DEBUG
655f17ff 72 bdinfo_print_num("bd address", (ulong)bd);
2e0fa217 73#endif
655f17ff 74 bdinfo_print_num("boot_params", (ulong)bd->bi_boot_params);
2e0fa217 75 print_bi_dram(bd);
655f17ff 76 bdinfo_print_num("memstart", (ulong)bd->bi_memstart);
537cb0df 77 print_lnum("memsize", (u64)bd->bi_memsize);
655f17ff
SG
78 bdinfo_print_num("flashstart", (ulong)bd->bi_flashstart);
79 bdinfo_print_num("flashsize", (ulong)bd->bi_flashsize);
80 bdinfo_print_num("flashoffset", (ulong)bd->bi_flashoffset);
3e1cca2a 81 printf("baudrate = %u bps\n", gd->baudrate);
655f17ff
SG
82 bdinfo_print_num("relocaddr", gd->relocaddr);
83 bdinfo_print_num("reloc off", gd->reloc_off);
db76c9be 84 printf("%-12s= %u-bit\n", "Build", (uint)sizeof(void *) * 8);
8a2ba581 85 if (IS_ENABLED(CONFIG_CMD_NET)) {
441539f9 86 printf("current eth = %s\n", eth_get_name());
8a2ba581
SG
87 print_eth(0);
88 printf("IP addr = %s\n", env_get("ipaddr"));
89 }
655f17ff
SG
90 bdinfo_print_num("fdt_blob", (ulong)gd->fdt_blob);
91 bdinfo_print_num("new_fdt", (ulong)gd->new_fdt);
92 bdinfo_print_num("fdt_size", (ulong)gd->fdt_size);
1aeeaeb5 93#if defined(CONFIG_LCD) || defined(CONFIG_VIDEO) || defined(CONFIG_DM_VIDEO)
655f17ff 94 bdinfo_print_num("FB base ", gd->fb_base);
1aeeaeb5 95#endif
1aeeaeb5 96#if CONFIG_IS_ENABLED(MULTI_DTB_FIT)
655f17ff 97 bdinfo_print_num("multi_dtb_fit", (ulong)gd->multi_dtb_fit);
1aeeaeb5 98#endif
59b0d7d8
SG
99
100 arch_print_bdinfo();
1af9756d 101
de5e5cea
CZ
102 return 0;
103}
8bde7f77 104
0d498393
WD
105U_BOOT_CMD(
106 bdinfo, 1, 1, do_bdinfo,
2fb2604d 107 "print Board Info structure",
a89c33db 108 ""
8bde7f77 109);
This page took 0.517139 seconds and 4 git commands to generate.