]>
Commit | Line | Data |
---|---|---|
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> | |
308b1a96 | 11 | #include <dm.h> |
7b51b576 | 12 | #include <env.h> |
9996cea7 | 13 | #include <lmb.h> |
90526e9f | 14 | #include <net.h> |
308b1a96 | 15 | #include <video.h> |
2189d5f1 | 16 | #include <vsprintf.h> |
90526e9f | 17 | #include <asm/cache.h> |
401d1c4f | 18 | #include <asm/global_data.h> |
8bde7f77 | 19 | |
d87080b7 | 20 | DECLARE_GLOBAL_DATA_PTR; |
8bde7f77 | 21 | |
98592c75 | 22 | void bdinfo_print_num_l(const char *name, ulong value) |
d88af4da | 23 | { |
95187bb7 | 24 | printf("%-12s= 0x%0*lx\n", name, 2 * (int)sizeof(value), value); |
d88af4da | 25 | } |
8bde7f77 | 26 | |
98592c75 BM |
27 | void bdinfo_print_num_ll(const char *name, unsigned long long value) |
28 | { | |
29 | printf("%-12s= 0x%.*llx\n", name, 2 * (int)sizeof(ulong), value); | |
30 | } | |
31 | ||
d88af4da MF |
32 | static void print_eth(int idx) |
33 | { | |
34 | char name[10], *val; | |
35 | if (idx) | |
36 | sprintf(name, "eth%iaddr", idx); | |
37 | else | |
38 | strcpy(name, "ethaddr"); | |
00caae6d | 39 | val = env_get(name); |
d88af4da MF |
40 | if (!val) |
41 | val = "(not set)"; | |
42 | printf("%-12s= %s\n", name, val); | |
43 | } | |
de2dff6f | 44 | |
655f17ff | 45 | void bdinfo_print_mhz(const char *name, unsigned long hz) |
d88af4da MF |
46 | { |
47 | char buf[32]; | |
48 | ||
49 | printf("%-12s= %6s MHz\n", name, strmhz(buf, hz)); | |
50 | } | |
8bde7f77 | 51 | |
b75d8dc5 | 52 | static void print_bi_dram(const struct bd_info *bd) |
fd60e99f | 53 | { |
fd60e99f MF |
54 | int i; |
55 | ||
56 | for (i = 0; i < CONFIG_NR_DRAM_BANKS; ++i) { | |
ddd917b8 | 57 | if (bd->bi_dram[i].size) { |
98592c75 | 58 | bdinfo_print_num_l("DRAM bank", i); |
6424fba1 BM |
59 | bdinfo_print_num_ll("-> start", bd->bi_dram[i].start); |
60 | bdinfo_print_num_ll("-> size", bd->bi_dram[i].size); | |
ddd917b8 | 61 | } |
fd60e99f | 62 | } |
fd60e99f MF |
63 | } |
64 | ||
59b0d7d8 SG |
65 | __weak void arch_print_bdinfo(void) |
66 | { | |
67 | } | |
68 | ||
308b1a96 SG |
69 | static void show_video_info(void) |
70 | { | |
71 | const struct udevice *dev; | |
72 | struct uclass *uc; | |
73 | ||
74 | uclass_id_foreach_dev(UCLASS_VIDEO, dev, uc) { | |
75 | printf("%-12s= %s %sactive\n", "Video", dev->name, | |
76 | device_active(dev) ? "" : "in"); | |
77 | if (device_active(dev)) { | |
78 | struct video_priv *upriv = dev_get_uclass_priv(dev); | |
79 | ||
98592c75 | 80 | bdinfo_print_num_ll("FB base", (ulong)upriv->fb); |
308b1a96 | 81 | if (upriv->copy_fb) |
98592c75 BM |
82 | bdinfo_print_num_ll("FB copy", |
83 | (ulong)upriv->copy_fb); | |
308b1a96 SG |
84 | printf("%-12s= %dx%dx%d\n", "FB size", upriv->xsize, |
85 | upriv->ysize, 1 << upriv->bpix); | |
86 | } | |
87 | } | |
88 | } | |
89 | ||
09140113 | 90 | int do_bdinfo(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) |
de5e5cea | 91 | { |
b75d8dc5 | 92 | struct bd_info *bd = gd->bd; |
2e0fa217 SG |
93 | |
94 | #ifdef DEBUG | |
98592c75 | 95 | bdinfo_print_num_l("bd address", (ulong)bd); |
2e0fa217 | 96 | #endif |
98592c75 | 97 | bdinfo_print_num_l("boot_params", (ulong)bd->bi_boot_params); |
2e0fa217 | 98 | print_bi_dram(bd); |
6ecefcfb | 99 | if (IS_ENABLED(CONFIG_SYS_HAS_SRAM)) { |
98592c75 BM |
100 | bdinfo_print_num_l("sramstart", (ulong)bd->bi_sramstart); |
101 | bdinfo_print_num_l("sramsize", (ulong)bd->bi_sramsize); | |
6ecefcfb | 102 | } |
98592c75 BM |
103 | bdinfo_print_num_l("flashstart", (ulong)bd->bi_flashstart); |
104 | bdinfo_print_num_l("flashsize", (ulong)bd->bi_flashsize); | |
105 | bdinfo_print_num_l("flashoffset", (ulong)bd->bi_flashoffset); | |
3e1cca2a | 106 | printf("baudrate = %u bps\n", gd->baudrate); |
98592c75 BM |
107 | bdinfo_print_num_l("relocaddr", gd->relocaddr); |
108 | bdinfo_print_num_l("reloc off", gd->reloc_off); | |
db76c9be | 109 | printf("%-12s= %u-bit\n", "Build", (uint)sizeof(void *) * 8); |
8a2ba581 | 110 | if (IS_ENABLED(CONFIG_CMD_NET)) { |
441539f9 | 111 | printf("current eth = %s\n", eth_get_name()); |
8a2ba581 SG |
112 | print_eth(0); |
113 | printf("IP addr = %s\n", env_get("ipaddr")); | |
114 | } | |
98592c75 BM |
115 | bdinfo_print_num_l("fdt_blob", (ulong)gd->fdt_blob); |
116 | bdinfo_print_num_l("new_fdt", (ulong)gd->new_fdt); | |
117 | bdinfo_print_num_l("fdt_size", (ulong)gd->fdt_size); | |
308b1a96 SG |
118 | if (IS_ENABLED(CONFIG_DM_VIDEO)) |
119 | show_video_info(); | |
120 | #if defined(CONFIG_LCD) || defined(CONFIG_VIDEO) | |
98592c75 | 121 | bdinfo_print_num_l("FB base ", gd->fb_base); |
1aeeaeb5 | 122 | #endif |
1aeeaeb5 | 123 | #if CONFIG_IS_ENABLED(MULTI_DTB_FIT) |
98592c75 | 124 | bdinfo_print_num_l("multi_dtb_fit", (ulong)gd->multi_dtb_fit); |
1aeeaeb5 | 125 | #endif |
9996cea7 TK |
126 | if (gd->fdt_blob) { |
127 | struct lmb lmb; | |
128 | ||
129 | lmb_init_and_reserve(&lmb, gd->bd, (void *)gd->fdt_blob); | |
130 | lmb_dump_all_force(&lmb); | |
131 | } | |
59b0d7d8 SG |
132 | |
133 | arch_print_bdinfo(); | |
1af9756d | 134 | |
de5e5cea CZ |
135 | return 0; |
136 | } | |
8bde7f77 | 137 | |
0d498393 WD |
138 | U_BOOT_CMD( |
139 | bdinfo, 1, 1, do_bdinfo, | |
2fb2604d | 140 | "print Board Info structure", |
a89c33db | 141 | "" |
8bde7f77 | 142 | ); |