]> Git Repo - u-boot.git/blob - cmd/bdinfo.c
ARM: dts: imx7d-sdb-u-boot: Fix usdhc1 UHS operation
[u-boot.git] / cmd / bdinfo.c
1 // SPDX-License-Identifier: GPL-2.0+
2 /*
3  * Implements the 'bd' command to show board information
4  *
5  * (C) Copyright 2003
6  * Wolfgang Denk, DENX Software Engineering, [email protected].
7  */
8
9 #include <common.h>
10 #include <command.h>
11 #include <dm.h>
12 #include <env.h>
13 #include <lmb.h>
14 #include <mapmem.h>
15 #include <net.h>
16 #include <video.h>
17 #include <vsprintf.h>
18 #include <asm/cache.h>
19 #include <asm/global_data.h>
20 #include <display_options.h>
21
22 DECLARE_GLOBAL_DATA_PTR;
23
24 void bdinfo_print_size(const char *name, uint64_t size)
25 {
26         printf("%-12s= ", name);
27         print_size(size, "\n");
28 }
29
30 void bdinfo_print_str(const char *name, const char *str)
31 {
32         printf("%-12s= %s\n", name, str);
33 }
34
35 void bdinfo_print_num_l(const char *name, ulong value)
36 {
37         printf("%-12s= 0x%0*lx\n", name, 2 * (int)sizeof(value), value);
38 }
39
40 void bdinfo_print_num_ll(const char *name, unsigned long long value)
41 {
42         printf("%-12s= 0x%.*llx\n", name, 2 * (int)sizeof(ulong), value);
43 }
44
45 static void print_eth(void)
46 {
47         const int idx = eth_get_dev_index();
48         uchar enetaddr[6];
49         char name[10];
50         int ret;
51
52         if (idx)
53                 sprintf(name, "eth%iaddr", idx);
54         else
55                 strcpy(name, "ethaddr");
56
57         ret = eth_env_get_enetaddr_by_index("eth", idx, enetaddr);
58
59         printf("current eth = %s\n", eth_get_name());
60         if (!ret)
61                 printf("%-12s= (not set)\n", name);
62         else
63                 printf("%-12s= %pM\n", name, enetaddr);
64         printf("IP addr     = %s\n", env_get("ipaddr"));
65 }
66
67 void bdinfo_print_mhz(const char *name, unsigned long hz)
68 {
69         char buf[32];
70
71         printf("%-12s= %6s MHz\n", name, strmhz(buf, hz));
72 }
73
74 static void print_bi_dram(const struct bd_info *bd)
75 {
76         int i;
77
78         for (i = 0; i < CONFIG_NR_DRAM_BANKS; ++i) {
79                 if (bd->bi_dram[i].size) {
80                         bdinfo_print_num_l("DRAM bank", i);
81                         bdinfo_print_num_ll("-> start", bd->bi_dram[i].start);
82                         bdinfo_print_num_ll("-> size",  bd->bi_dram[i].size);
83                 }
84         }
85 }
86
87 __weak void arch_print_bdinfo(void)
88 {
89 }
90
91 static void show_video_info(void)
92 {
93         const struct udevice *dev;
94         struct uclass *uc;
95
96         uclass_id_foreach_dev(UCLASS_VIDEO, dev, uc) {
97                 printf("%-12s= %s %sactive\n", "Video", dev->name,
98                        device_active(dev) ? "" : "in");
99                 if (device_active(dev)) {
100                         struct video_priv *upriv = dev_get_uclass_priv(dev);
101                         struct video_uc_plat *plat = dev_get_uclass_plat(dev);
102
103                         bdinfo_print_num_ll("FB base", (ulong)upriv->fb);
104                         if (upriv->copy_fb) {
105                                 bdinfo_print_num_ll("FB copy",
106                                                     (ulong)upriv->copy_fb);
107                                 bdinfo_print_num_l(" copy size",
108                                                    plat->copy_size);
109                         }
110                         printf("%-12s= %dx%dx%d\n", "FB size", upriv->xsize,
111                                upriv->ysize, 1 << upriv->bpix);
112                 }
113         }
114 }
115
116 int do_bdinfo(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
117 {
118         struct bd_info *bd = gd->bd;
119
120 #ifdef DEBUG
121         bdinfo_print_num_l("bd address", (ulong)bd);
122 #endif
123         bdinfo_print_num_l("boot_params", (ulong)bd->bi_boot_params);
124         print_bi_dram(bd);
125         if (IS_ENABLED(CONFIG_SYS_HAS_SRAM)) {
126                 bdinfo_print_num_l("sramstart", (ulong)bd->bi_sramstart);
127                 bdinfo_print_num_l("sramsize", (ulong)bd->bi_sramsize);
128         }
129         bdinfo_print_num_l("flashstart", (ulong)bd->bi_flashstart);
130         bdinfo_print_num_l("flashsize", (ulong)bd->bi_flashsize);
131         bdinfo_print_num_l("flashoffset", (ulong)bd->bi_flashoffset);
132         printf("baudrate    = %u bps\n", gd->baudrate);
133         bdinfo_print_num_l("relocaddr", gd->relocaddr);
134         bdinfo_print_num_l("reloc off", gd->reloc_off);
135         printf("%-12s= %u-bit\n", "Build", (uint)sizeof(void *) * 8);
136         if (IS_ENABLED(CONFIG_CMD_NET))
137                 print_eth();
138         bdinfo_print_num_l("fdt_blob", (ulong)map_to_sysmem(gd->fdt_blob));
139         bdinfo_print_num_l("new_fdt", (ulong)map_to_sysmem(gd->new_fdt));
140         bdinfo_print_num_l("fdt_size", (ulong)gd->fdt_size);
141         if (IS_ENABLED(CONFIG_VIDEO))
142                 show_video_info();
143 #if CONFIG_IS_ENABLED(MULTI_DTB_FIT)
144         bdinfo_print_num_l("multi_dtb_fit", (ulong)gd->multi_dtb_fit);
145 #endif
146         if (IS_ENABLED(CONFIG_LMB) && gd->fdt_blob) {
147                 struct lmb lmb;
148
149                 lmb_init_and_reserve(&lmb, gd->bd, (void *)gd->fdt_blob);
150                 lmb_dump_all_force(&lmb);
151                 if (IS_ENABLED(CONFIG_OF_REAL))
152                         printf("devicetree  = %s\n", fdtdec_get_srcname());
153         }
154
155         arch_print_bdinfo();
156
157         return 0;
158 }
159
160 U_BOOT_CMD(
161         bdinfo, 1,      1,      do_bdinfo,
162         "print Board Info structure",
163         ""
164 );
This page took 0.070197 seconds and 4 git commands to generate.