ddr: fsl: Remove CONFIG_MEM_INIT_VALUE
[platform/kernel/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, wd@denx.de.
7  */
8
9 #include <common.h>
10 #include <command.h>
11 #include <dm.h>
12 #include <env.h>
13 #include <lmb.h>
14 #include <net.h>
15 #include <video.h>
16 #include <vsprintf.h>
17 #include <asm/cache.h>
18 #include <asm/global_data.h>
19 #include <display_options.h>
20
21 DECLARE_GLOBAL_DATA_PTR;
22
23 void bdinfo_print_size(const char *name, uint64_t size)
24 {
25         printf("%-12s= ", name);
26         print_size(size, "\n");
27 }
28
29 void bdinfo_print_num_l(const char *name, ulong value)
30 {
31         printf("%-12s= 0x%0*lx\n", name, 2 * (int)sizeof(value), value);
32 }
33
34 void bdinfo_print_num_ll(const char *name, unsigned long long value)
35 {
36         printf("%-12s= 0x%.*llx\n", name, 2 * (int)sizeof(ulong), value);
37 }
38
39 static void print_eth(int idx)
40 {
41         char name[10], *val;
42         if (idx)
43                 sprintf(name, "eth%iaddr", idx);
44         else
45                 strcpy(name, "ethaddr");
46         val = env_get(name);
47         if (!val)
48                 val = "(not set)";
49         printf("%-12s= %s\n", name, val);
50 }
51
52 void bdinfo_print_mhz(const char *name, unsigned long hz)
53 {
54         char buf[32];
55
56         printf("%-12s= %6s MHz\n", name, strmhz(buf, hz));
57 }
58
59 static void print_bi_dram(const struct bd_info *bd)
60 {
61         int i;
62
63         for (i = 0; i < CONFIG_NR_DRAM_BANKS; ++i) {
64                 if (bd->bi_dram[i].size) {
65                         bdinfo_print_num_l("DRAM bank", i);
66                         bdinfo_print_num_ll("-> start", bd->bi_dram[i].start);
67                         bdinfo_print_num_ll("-> size",  bd->bi_dram[i].size);
68                 }
69         }
70 }
71
72 __weak void arch_print_bdinfo(void)
73 {
74 }
75
76 static void show_video_info(void)
77 {
78         const struct udevice *dev;
79         struct uclass *uc;
80
81         uclass_id_foreach_dev(UCLASS_VIDEO, dev, uc) {
82                 printf("%-12s= %s %sactive\n", "Video", dev->name,
83                        device_active(dev) ? "" : "in");
84                 if (device_active(dev)) {
85                         struct video_priv *upriv = dev_get_uclass_priv(dev);
86
87                         bdinfo_print_num_ll("FB base", (ulong)upriv->fb);
88                         if (upriv->copy_fb)
89                                 bdinfo_print_num_ll("FB copy",
90                                                     (ulong)upriv->copy_fb);
91                         printf("%-12s= %dx%dx%d\n", "FB size", upriv->xsize,
92                                upriv->ysize, 1 << upriv->bpix);
93                 }
94         }
95 }
96
97 int do_bdinfo(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
98 {
99         struct bd_info *bd = gd->bd;
100
101 #ifdef DEBUG
102         bdinfo_print_num_l("bd address", (ulong)bd);
103 #endif
104         bdinfo_print_num_l("boot_params", (ulong)bd->bi_boot_params);
105         print_bi_dram(bd);
106         if (IS_ENABLED(CONFIG_SYS_HAS_SRAM)) {
107                 bdinfo_print_num_l("sramstart", (ulong)bd->bi_sramstart);
108                 bdinfo_print_num_l("sramsize", (ulong)bd->bi_sramsize);
109         }
110         bdinfo_print_num_l("flashstart", (ulong)bd->bi_flashstart);
111         bdinfo_print_num_l("flashsize", (ulong)bd->bi_flashsize);
112         bdinfo_print_num_l("flashoffset", (ulong)bd->bi_flashoffset);
113         printf("baudrate    = %u bps\n", gd->baudrate);
114         bdinfo_print_num_l("relocaddr", gd->relocaddr);
115         bdinfo_print_num_l("reloc off", gd->reloc_off);
116         printf("%-12s= %u-bit\n", "Build", (uint)sizeof(void *) * 8);
117         if (IS_ENABLED(CONFIG_CMD_NET)) {
118                 printf("current eth = %s\n", eth_get_name());
119                 print_eth(0);
120                 printf("IP addr     = %s\n", env_get("ipaddr"));
121         }
122         bdinfo_print_num_l("fdt_blob", (ulong)gd->fdt_blob);
123         bdinfo_print_num_l("new_fdt", (ulong)gd->new_fdt);
124         bdinfo_print_num_l("fdt_size", (ulong)gd->fdt_size);
125         if (IS_ENABLED(CONFIG_VIDEO))
126                 show_video_info();
127 #if CONFIG_IS_ENABLED(MULTI_DTB_FIT)
128         bdinfo_print_num_l("multi_dtb_fit", (ulong)gd->multi_dtb_fit);
129 #endif
130         if (IS_ENABLED(CONFIG_LMB) && gd->fdt_blob) {
131                 struct lmb lmb;
132
133                 lmb_init_and_reserve(&lmb, gd->bd, (void *)gd->fdt_blob);
134                 lmb_dump_all_force(&lmb);
135                 if (IS_ENABLED(CONFIG_OF_REAL))
136                         printf("devicetree  = %s\n", fdtdec_get_srcname());
137         }
138
139         arch_print_bdinfo();
140
141         return 0;
142 }
143
144 U_BOOT_CMD(
145         bdinfo, 1,      1,      do_bdinfo,
146         "print Board Info structure",
147         ""
148 );