]> Git Repo - u-boot.git/blame - cmd/bdinfo.c
Restore patch series "arm: dts: am62-beagleplay: Fix Beagleplay Ethernet"
[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 9#include <command.h>
308b1a96 10#include <dm.h>
7b51b576 11#include <env.h>
b6a90ac0 12#include <getopt.h>
9996cea7 13#include <lmb.h>
55922ed5 14#include <mapmem.h>
90526e9f 15#include <net.h>
347a845a 16#include <serial.h>
308b1a96 17#include <video.h>
2189d5f1 18#include <vsprintf.h>
90526e9f 19#include <asm/cache.h>
401d1c4f 20#include <asm/global_data.h>
ae90d16a 21#include <display_options.h>
8bde7f77 22
d87080b7 23DECLARE_GLOBAL_DATA_PTR;
8bde7f77 24
ae90d16a
OP
25void bdinfo_print_size(const char *name, uint64_t size)
26{
27 printf("%-12s= ", name);
28 print_size(size, "\n");
29}
30
40b8afe6
SG
31void bdinfo_print_str(const char *name, const char *str)
32{
33 printf("%-12s= %s\n", name, str);
34}
35
98592c75 36void bdinfo_print_num_l(const char *name, ulong value)
d88af4da 37{
95187bb7 38 printf("%-12s= 0x%0*lx\n", name, 2 * (int)sizeof(value), value);
d88af4da 39}
8bde7f77 40
98592c75
BM
41void bdinfo_print_num_ll(const char *name, unsigned long long value)
42{
43 printf("%-12s= 0x%.*llx\n", name, 2 * (int)sizeof(ulong), value);
44}
45
a7631505 46static void print_eth(void)
d88af4da 47{
a7631505
MV
48 const int idx = eth_get_dev_index();
49 uchar enetaddr[6];
50 char name[10];
51 int ret;
52
d88af4da
MF
53 if (idx)
54 sprintf(name, "eth%iaddr", idx);
55 else
56 strcpy(name, "ethaddr");
a7631505
MV
57
58 ret = eth_env_get_enetaddr_by_index("eth", idx, enetaddr);
d8eb4e2c
MV
59
60 printf("current eth = %s\n", eth_get_name());
a7631505
MV
61 if (!ret)
62 printf("%-12s= (not set)\n", name);
63 else
64 printf("%-12s= %pM\n", name, enetaddr);
d8eb4e2c 65 printf("IP addr = %s\n", env_get("ipaddr"));
d88af4da 66}
de2dff6f 67
655f17ff 68void bdinfo_print_mhz(const char *name, unsigned long hz)
d88af4da
MF
69{
70 char buf[32];
71
72 printf("%-12s= %6s MHz\n", name, strmhz(buf, hz));
73}
8bde7f77 74
b75d8dc5 75static void print_bi_dram(const struct bd_info *bd)
fd60e99f 76{
fd60e99f
MF
77 int i;
78
79 for (i = 0; i < CONFIG_NR_DRAM_BANKS; ++i) {
ddd917b8 80 if (bd->bi_dram[i].size) {
98592c75 81 bdinfo_print_num_l("DRAM bank", i);
6424fba1
BM
82 bdinfo_print_num_ll("-> start", bd->bi_dram[i].start);
83 bdinfo_print_num_ll("-> size", bd->bi_dram[i].size);
ddd917b8 84 }
fd60e99f 85 }
fd60e99f
MF
86}
87
59b0d7d8
SG
88__weak void arch_print_bdinfo(void)
89{
90}
91
308b1a96
SG
92static void show_video_info(void)
93{
94 const struct udevice *dev;
95 struct uclass *uc;
96
97 uclass_id_foreach_dev(UCLASS_VIDEO, dev, uc) {
98 printf("%-12s= %s %sactive\n", "Video", dev->name,
99 device_active(dev) ? "" : "in");
100 if (device_active(dev)) {
101 struct video_priv *upriv = dev_get_uclass_priv(dev);
38191594 102 struct video_uc_plat *plat = dev_get_uclass_plat(dev);
308b1a96 103
98592c75 104 bdinfo_print_num_ll("FB base", (ulong)upriv->fb);
38191594 105 if (upriv->copy_fb) {
98592c75
BM
106 bdinfo_print_num_ll("FB copy",
107 (ulong)upriv->copy_fb);
38191594
SG
108 bdinfo_print_num_l(" copy size",
109 plat->copy_size);
110 }
308b1a96
SG
111 printf("%-12s= %dx%dx%d\n", "FB size", upriv->xsize,
112 upriv->ysize, 1 << upriv->bpix);
113 }
114 }
115}
116
347a845a
SG
117static void print_serial(struct udevice *dev)
118{
119 struct serial_device_info info;
120 int ret;
121
122 if (!dev || !IS_ENABLED(CONFIG_DM_SERIAL))
123 return;
124
125 ret = serial_getinfo(dev, &info);
126 if (ret)
127 return;
128
129 bdinfo_print_num_l("serial addr", info.addr);
130 bdinfo_print_num_l(" width", info.reg_width);
131 bdinfo_print_num_l(" shift", info.reg_shift);
132 bdinfo_print_num_l(" offset", info.reg_offset);
133 bdinfo_print_num_l(" clock", info.clock);
134}
135
b6a90ac0 136static int bdinfo_print_all(struct bd_info *bd)
de5e5cea 137{
2e0fa217 138#ifdef DEBUG
98592c75 139 bdinfo_print_num_l("bd address", (ulong)bd);
2e0fa217 140#endif
98592c75 141 bdinfo_print_num_l("boot_params", (ulong)bd->bi_boot_params);
2e0fa217 142 print_bi_dram(bd);
6ecefcfb 143 if (IS_ENABLED(CONFIG_SYS_HAS_SRAM)) {
98592c75
BM
144 bdinfo_print_num_l("sramstart", (ulong)bd->bi_sramstart);
145 bdinfo_print_num_l("sramsize", (ulong)bd->bi_sramsize);
6ecefcfb 146 }
98592c75
BM
147 bdinfo_print_num_l("flashstart", (ulong)bd->bi_flashstart);
148 bdinfo_print_num_l("flashsize", (ulong)bd->bi_flashsize);
149 bdinfo_print_num_l("flashoffset", (ulong)bd->bi_flashoffset);
3e1cca2a 150 printf("baudrate = %u bps\n", gd->baudrate);
98592c75
BM
151 bdinfo_print_num_l("relocaddr", gd->relocaddr);
152 bdinfo_print_num_l("reloc off", gd->reloc_off);
db76c9be 153 printf("%-12s= %u-bit\n", "Build", (uint)sizeof(void *) * 8);
d8eb4e2c 154 if (IS_ENABLED(CONFIG_CMD_NET))
a7631505 155 print_eth();
55922ed5
MV
156 bdinfo_print_num_l("fdt_blob", (ulong)map_to_sysmem(gd->fdt_blob));
157 bdinfo_print_num_l("new_fdt", (ulong)map_to_sysmem(gd->new_fdt));
98592c75 158 bdinfo_print_num_l("fdt_size", (ulong)gd->fdt_size);
b86986c7 159 if (IS_ENABLED(CONFIG_VIDEO))
308b1a96 160 show_video_info();
1aeeaeb5 161#if CONFIG_IS_ENABLED(MULTI_DTB_FIT)
98592c75 162 bdinfo_print_num_l("multi_dtb_fit", (ulong)gd->multi_dtb_fit);
1aeeaeb5 163#endif
85007da9 164 if (IS_ENABLED(CONFIG_LMB) && gd->fdt_blob) {
9996cea7
TK
165 struct lmb lmb;
166
167 lmb_init_and_reserve(&lmb, gd->bd, (void *)gd->fdt_blob);
168 lmb_dump_all_force(&lmb);
ff66e7bb
SG
169 if (IS_ENABLED(CONFIG_OF_REAL))
170 printf("devicetree = %s\n", fdtdec_get_srcname());
9996cea7 171 }
347a845a 172 print_serial(gd->cur_serial_dev);
59b0d7d8 173
b279f517
SG
174 if (IS_ENABLED(CONFIG_CMD_BDINFO_EXTRA)) {
175 bdinfo_print_num_ll("stack ptr", (ulong)&bd);
176 bdinfo_print_num_ll("ram_top ptr", (ulong)gd->ram_top);
0be0f205 177 bdinfo_print_num_l("malloc base", gd_malloc_start());
b279f517
SG
178 }
179
59b0d7d8 180 arch_print_bdinfo();
1af9756d 181
de5e5cea
CZ
182 return 0;
183}
8bde7f77 184
b6a90ac0
MV
185int do_bdinfo(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
186{
187 struct bd_info *bd = gd->bd;
188 struct getopt_state gs;
189 int opt;
190
191 if (!CONFIG_IS_ENABLED(GETOPT) || argc == 1)
192 return bdinfo_print_all(bd);
193
194 getopt_init_state(&gs);
ea9637c9 195 while ((opt = getopt(&gs, argc, argv, "aem")) > 0) {
b6a90ac0
MV
196 switch (opt) {
197 case 'a':
198 return bdinfo_print_all(bd);
ea9637c9
MV
199 case 'e':
200 if (!IS_ENABLED(CONFIG_CMD_NET))
201 return CMD_RET_USAGE;
202 print_eth();
203 return CMD_RET_SUCCESS;
f1774a80
MV
204 case 'm':
205 print_bi_dram(bd);
206 return CMD_RET_SUCCESS;
b6a90ac0
MV
207 default:
208 return CMD_RET_USAGE;
209 }
210 }
211
212 return CMD_RET_USAGE;
213}
214
0d498393 215U_BOOT_CMD(
b6a90ac0 216 bdinfo, 2, 1, do_bdinfo,
2fb2604d 217 "print Board Info structure",
a89c33db 218 ""
8bde7f77 219);
This page took 0.406706 seconds and 4 git commands to generate.