]> git.kernelconcepts.de Git - karo-tx-uboot.git/blob - common/cmd_bdinfo.c
Add a cli command to test the TPM device.
[karo-tx-uboot.git] / common / cmd_bdinfo.c
1 /*
2  * (C) Copyright 2003
3  * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
4  *
5  * See file CREDITS for list of people who contributed to this
6  * project.
7  *
8  * This program is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU General Public License as
10  * published by the Free Software Foundation; either version 2 of
11  * the License, or (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program; if not, write to the Free Software
20  * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
21  * MA 02111-1307 USA
22  */
23
24 /*
25  * Boot support
26  */
27 #include <common.h>
28 #include <command.h>
29 #include <linux/compiler.h>
30
31 DECLARE_GLOBAL_DATA_PTR;
32
33 __maybe_unused
34 static void print_num(const char *name, ulong value)
35 {
36         printf("%-12s= 0x%08lX\n", name, 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 = getenv(name);
47         if (!val)
48                 val = "(not set)";
49         printf("%-12s= %s\n", name, val);
50 }
51
52 __maybe_unused
53 static void print_lnum(const char *name, u64 value)
54 {
55         printf("%-12s= 0x%.8llX\n", name, value);
56 }
57
58 __maybe_unused
59 static void print_mhz(const char *name, unsigned long hz)
60 {
61         char buf[32];
62
63         printf("%-12s= %6s MHz\n", name, strmhz(buf, hz));
64 }
65
66 #if defined(CONFIG_PPC)
67
68 int do_bdinfo(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
69 {
70         bd_t *bd = gd->bd;
71
72 #ifdef DEBUG
73         print_num("bd address",         (ulong)bd);
74 #endif
75         print_num("memstart",           bd->bi_memstart);
76         print_lnum("memsize",           bd->bi_memsize);
77         print_num("flashstart",         bd->bi_flashstart);
78         print_num("flashsize",          bd->bi_flashsize);
79         print_num("flashoffset",        bd->bi_flashoffset);
80         print_num("sramstart",          bd->bi_sramstart);
81         print_num("sramsize",           bd->bi_sramsize);
82 #if     defined(CONFIG_5xx)  || defined(CONFIG_8xx) || \
83         defined(CONFIG_8260) || defined(CONFIG_E500)
84         print_num("immr_base",          bd->bi_immr_base);
85 #endif
86         print_num("bootflags",          bd->bi_bootflags);
87 #if     defined(CONFIG_405CR) || defined(CONFIG_405EP) || \
88         defined(CONFIG_405GP) || \
89         defined(CONFIG_440EP) || defined(CONFIG_440EPX) || \
90         defined(CONFIG_440GR) || defined(CONFIG_440GRX) || \
91         defined(CONFIG_440SP) || defined(CONFIG_440SPE) || \
92         defined(CONFIG_XILINX_405)
93         print_mhz("procfreq",           bd->bi_procfreq);
94         print_mhz("plb_busfreq",        bd->bi_plb_busfreq);
95 #if     defined(CONFIG_405EP) || defined(CONFIG_405GP) || \
96         defined(CONFIG_440EP) || defined(CONFIG_440EPX) || \
97         defined(CONFIG_440GR) || defined(CONFIG_440GRX) || \
98         defined(CONFIG_440SPE) || defined(CONFIG_XILINX_405)
99         print_mhz("pci_busfreq",        bd->bi_pci_busfreq);
100 #endif
101 #else   /* ! CONFIG_405GP, CONFIG_405CR, CONFIG_405EP, CONFIG_XILINX_405, CONFIG_440EP CONFIG_440GR */
102 #if defined(CONFIG_CPM2)
103         print_mhz("vco",                bd->bi_vco);
104         print_mhz("sccfreq",            bd->bi_sccfreq);
105         print_mhz("brgfreq",            bd->bi_brgfreq);
106 #endif
107         print_mhz("intfreq",            bd->bi_intfreq);
108 #if defined(CONFIG_CPM2)
109         print_mhz("cpmfreq",            bd->bi_cpmfreq);
110 #endif
111         print_mhz("busfreq",            bd->bi_busfreq);
112 #endif /* CONFIG_405GP, CONFIG_405CR, CONFIG_405EP, CONFIG_XILINX_405, CONFIG_440EP CONFIG_440GR */
113 #if defined(CONFIG_MPC8220)
114         print_mhz("inpfreq",            bd->bi_inpfreq);
115         print_mhz("flbfreq",            bd->bi_flbfreq);
116         print_mhz("pcifreq",            bd->bi_pcifreq);
117         print_mhz("vcofreq",            bd->bi_vcofreq);
118         print_mhz("pevfreq",            bd->bi_pevfreq);
119 #endif
120
121         print_eth(0);
122 #if defined(CONFIG_HAS_ETH1)
123         print_eth(1);
124 #endif
125 #if defined(CONFIG_HAS_ETH2)
126         print_eth(2);
127 #endif
128 #if defined(CONFIG_HAS_ETH3)
129         print_eth(3);
130 #endif
131 #if defined(CONFIG_HAS_ETH4)
132         print_eth(4);
133 #endif
134 #if defined(CONFIG_HAS_ETH5)
135         print_eth(5);
136 #endif
137
138 #ifdef CONFIG_HERMES
139         print_mhz("ethspeed",           bd->bi_ethspeed);
140 #endif
141         printf("IP addr     = %pI4\n", &bd->bi_ip_addr);
142         printf("baudrate    = %6ld bps\n", bd->bi_baudrate);
143         print_num("relocaddr", gd->relocaddr);
144         return 0;
145 }
146
147 #elif defined(CONFIG_NIOS2)
148
149 int do_bdinfo(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
150 {
151         bd_t *bd = gd->bd;
152
153         print_num("mem start",          (ulong)bd->bi_memstart);
154         print_lnum("mem size",          (u64)bd->bi_memsize);
155         print_num("flash start",        (ulong)bd->bi_flashstart);
156         print_num("flash size",         (ulong)bd->bi_flashsize);
157         print_num("flash offset",       (ulong)bd->bi_flashoffset);
158
159 #if defined(CONFIG_SYS_SRAM_BASE)
160         print_num ("sram start",        (ulong)bd->bi_sramstart);
161         print_num ("sram size",         (ulong)bd->bi_sramsize);
162 #endif
163
164 #if defined(CONFIG_CMD_NET)
165         print_eth(0);
166         printf("ip_addr     = %pI4\n", &bd->bi_ip_addr);
167 #endif
168
169         printf("baudrate    = %ld bps\n", bd->bi_baudrate);
170
171         return 0;
172 }
173
174 #elif defined(CONFIG_MICROBLAZE)
175
176 int do_bdinfo(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
177 {
178         bd_t *bd = gd->bd;
179         print_num("mem start      ",    (ulong)bd->bi_memstart);
180         print_lnum("mem size       ",   (u64)bd->bi_memsize);
181         print_num("flash start    ",    (ulong)bd->bi_flashstart);
182         print_num("flash size     ",    (ulong)bd->bi_flashsize);
183         print_num("flash offset   ",    (ulong)bd->bi_flashoffset);
184 #if defined(CONFIG_SYS_SRAM_BASE)
185         print_num("sram start     ",    (ulong)bd->bi_sramstart);
186         print_num("sram size      ",    (ulong)bd->bi_sramsize);
187 #endif
188 #if defined(CONFIG_CMD_NET)
189         print_eth(0);
190         printf("ip_addr     = %pI4\n", &bd->bi_ip_addr);
191 #endif
192         printf("baudrate    = %ld bps\n", (ulong)bd->bi_baudrate);
193         return 0;
194 }
195
196 #elif defined(CONFIG_SPARC)
197
198 int do_bdinfo(cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[])
199 {
200         bd_t *bd = gd->bd;
201
202 #ifdef DEBUG
203         print_num("bd address             ", (ulong) bd);
204 #endif
205         print_num("memstart               ", bd->bi_memstart);
206         print_lnum("memsize                ", bd->bi_memsize);
207         print_num("flashstart             ", bd->bi_flashstart);
208         print_num("CONFIG_SYS_MONITOR_BASE       ", CONFIG_SYS_MONITOR_BASE);
209         print_num("CONFIG_ENV_ADDR           ", CONFIG_ENV_ADDR);
210         printf("CONFIG_SYS_RELOC_MONITOR_BASE = 0x%lx (%d)\n", CONFIG_SYS_RELOC_MONITOR_BASE,
211                CONFIG_SYS_MONITOR_LEN);
212         printf("CONFIG_SYS_MALLOC_BASE        = 0x%lx (%d)\n", CONFIG_SYS_MALLOC_BASE,
213                CONFIG_SYS_MALLOC_LEN);
214         printf("CONFIG_SYS_INIT_SP_OFFSET     = 0x%lx (%d)\n", CONFIG_SYS_INIT_SP_OFFSET,
215                CONFIG_SYS_STACK_SIZE);
216         printf("CONFIG_SYS_PROM_OFFSET        = 0x%lx (%d)\n", CONFIG_SYS_PROM_OFFSET,
217                CONFIG_SYS_PROM_SIZE);
218         printf("CONFIG_SYS_GBL_DATA_OFFSET    = 0x%lx (%d)\n", CONFIG_SYS_GBL_DATA_OFFSET,
219                GENERATED_GBL_DATA_SIZE);
220
221 #if defined(CONFIG_CMD_NET)
222         print_eth(0);
223         printf("ip_addr     = %pI4\n", &bd->bi_ip_addr);
224 #endif
225         printf("baudrate               = %6ld bps\n", bd->bi_baudrate);
226         return 0;
227 }
228
229 #elif defined(CONFIG_M68K)
230
231 int do_bdinfo(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
232 {
233         bd_t *bd = gd->bd;
234
235         print_num("memstart",           (ulong)bd->bi_memstart);
236         print_lnum("memsize",           (u64)bd->bi_memsize);
237         print_num("flashstart",         (ulong)bd->bi_flashstart);
238         print_num("flashsize",          (ulong)bd->bi_flashsize);
239         print_num("flashoffset",        (ulong)bd->bi_flashoffset);
240 #if defined(CONFIG_SYS_INIT_RAM_ADDR)
241         print_num("sramstart",          (ulong)bd->bi_sramstart);
242         print_num("sramsize",           (ulong)bd->bi_sramsize);
243 #endif
244 #if defined(CONFIG_SYS_MBAR)
245         print_num("mbar",               bd->bi_mbar_base);
246 #endif
247         print_mhz("cpufreq",            bd->bi_intfreq);
248         print_mhz("busfreq",            bd->bi_busfreq);
249 #ifdef CONFIG_PCI
250         print_mhz("pcifreq",            bd->bi_pcifreq);
251 #endif
252 #ifdef CONFIG_EXTRA_CLOCK
253         print_mhz("flbfreq",            bd->bi_flbfreq);
254         print_mhz("inpfreq",            bd->bi_inpfreq);
255         print_mhz("vcofreq",            bd->bi_vcofreq);
256 #endif
257 #if defined(CONFIG_CMD_NET)
258         print_eth(0);
259 #if defined(CONFIG_HAS_ETH1)
260         print_eth(1);
261 #endif
262 #if defined(CONFIG_HAS_ETH2)
263         print_eth(2);
264 #endif
265 #if defined(CONFIG_HAS_ETH3)
266         print_eth(3);
267 #endif
268
269         printf("ip_addr     = %pI4\n", &bd->bi_ip_addr);
270 #endif
271         printf("baudrate    = %ld bps\n", bd->bi_baudrate);
272
273         return 0;
274 }
275
276 #elif defined(CONFIG_BLACKFIN)
277
278 int do_bdinfo(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
279 {
280         bd_t *bd = gd->bd;
281
282         printf("U-Boot      = %s\n", bd->bi_r_version);
283         printf("CPU         = %s\n", bd->bi_cpu);
284         printf("Board       = %s\n", bd->bi_board_name);
285         print_mhz("VCO",        bd->bi_vco);
286         print_mhz("CCLK",       bd->bi_cclk);
287         print_mhz("SCLK",       bd->bi_sclk);
288
289         print_num("boot_params",        (ulong)bd->bi_boot_params);
290         print_num("memstart",           (ulong)bd->bi_memstart);
291         print_lnum("memsize",           (u64)bd->bi_memsize);
292         print_num("flashstart",         (ulong)bd->bi_flashstart);
293         print_num("flashsize",          (ulong)bd->bi_flashsize);
294         print_num("flashoffset",        (ulong)bd->bi_flashoffset);
295
296         print_eth(0);
297         printf("ip_addr     = %pI4\n", &bd->bi_ip_addr);
298         printf("baudrate    = %d bps\n", bd->bi_baudrate);
299
300         return 0;
301 }
302
303 #elif defined(CONFIG_MIPS)
304
305 int do_bdinfo(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
306 {
307         bd_t *bd = gd->bd;
308
309         print_num("boot_params",        (ulong)bd->bi_boot_params);
310         print_num("memstart",           (ulong)bd->bi_memstart);
311         print_lnum("memsize",           (u64)bd->bi_memsize);
312         print_num("flashstart",         (ulong)bd->bi_flashstart);
313         print_num("flashsize",          (ulong)bd->bi_flashsize);
314         print_num("flashoffset",        (ulong)bd->bi_flashoffset);
315
316         print_eth(0);
317         printf("ip_addr     = %pI4\n", &bd->bi_ip_addr);
318         printf("baudrate    = %d bps\n", bd->bi_baudrate);
319
320         return 0;
321 }
322
323 #elif defined(CONFIG_AVR32)
324
325 int do_bdinfo(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
326 {
327         bd_t *bd = gd->bd;
328
329         print_num("boot_params",        (ulong)bd->bi_boot_params);
330         print_num("memstart",           (ulong)bd->bi_memstart);
331         print_lnum("memsize",           (u64)bd->bi_memsize);
332         print_num("flashstart",         (ulong)bd->bi_flashstart);
333         print_num("flashsize",          (ulong)bd->bi_flashsize);
334         print_num("flashoffset",        (ulong)bd->bi_flashoffset);
335
336         print_eth(0);
337         printf("ip_addr     = %pI4\n", &bd->bi_ip_addr);
338         printf("baudrate    = %lu bps\n", bd->bi_baudrate);
339
340         return 0;
341 }
342
343 #elif defined(CONFIG_ARM)
344
345 int do_bdinfo(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
346 {
347         int i;
348         bd_t *bd = gd->bd;
349
350         print_num("arch_number",        bd->bi_arch_number);
351         print_num("boot_params",        (ulong)bd->bi_boot_params);
352
353         for (i = 0; i < CONFIG_NR_DRAM_BANKS; ++i) {
354                 print_num("DRAM bank",  i);
355                 print_num("-> start",   bd->bi_dram[i].start);
356                 print_num("-> size",    bd->bi_dram[i].size);
357         }
358
359 #if defined(CONFIG_CMD_NET)
360         print_eth(0);
361         printf("ip_addr     = %pI4\n", &bd->bi_ip_addr);
362 #endif
363         printf("baudrate    = %d bps\n", bd->bi_baudrate);
364 #if !(defined(CONFIG_SYS_ICACHE_OFF) && defined(CONFIG_SYS_DCACHE_OFF))
365         print_num("TLB addr", gd->tlb_addr);
366 #endif
367         print_num("relocaddr", gd->relocaddr);
368         print_num("reloc off", gd->reloc_off);
369         print_num("irq_sp", gd->irq_sp);        /* irq stack pointer */
370         print_num("sp start ", gd->start_addr_sp);
371         print_num("FB base  ", gd->fb_base);
372         return 0;
373 }
374
375 #elif defined(CONFIG_SH)
376
377 int do_bdinfo(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
378 {
379         bd_t *bd = gd->bd;
380         print_num("mem start      ",    (ulong)bd->bi_memstart);
381         print_lnum("mem size       ",   (u64)bd->bi_memsize);
382         print_num("flash start    ",    (ulong)bd->bi_flashstart);
383         print_num("flash size     ",    (ulong)bd->bi_flashsize);
384         print_num("flash offset   ",    (ulong)bd->bi_flashoffset);
385
386 #if defined(CONFIG_CMD_NET)
387         print_eth(0);
388         printf("ip_addr     = %pI4\n", &bd->bi_ip_addr);
389 #endif
390         printf("baudrate    = %ld bps\n", (ulong)bd->bi_baudrate);
391         return 0;
392 }
393
394 #elif defined(CONFIG_X86)
395
396 int do_bdinfo(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
397 {
398         int i;
399         bd_t *bd = gd->bd;
400
401         print_num("boot_params",        (ulong)bd->bi_boot_params);
402         print_num("bi_memstart",        bd->bi_memstart);
403         print_num("bi_memsize",         bd->bi_memsize);
404         print_num("bi_flashstart",      bd->bi_flashstart);
405         print_num("bi_flashsize",       bd->bi_flashsize);
406         print_num("bi_flashoffset",     bd->bi_flashoffset);
407         print_num("bi_sramstart",       bd->bi_sramstart);
408         print_num("bi_sramsize",        bd->bi_sramsize);
409         print_num("bi_bootflags",       bd->bi_bootflags);
410         print_mhz("cpufreq",            bd->bi_intfreq);
411         print_mhz("busfreq",            bd->bi_busfreq);
412
413         for (i = 0; i < CONFIG_NR_DRAM_BANKS; ++i) {
414                 print_num("DRAM bank",  i);
415                 print_num("-> start",   bd->bi_dram[i].start);
416                 print_num("-> size",    bd->bi_dram[i].size);
417         }
418
419 #if defined(CONFIG_CMD_NET)
420         print_eth(0);
421         printf("ip_addr     = %pI4\n", &bd->bi_ip_addr);
422         print_mhz("ethspeed",       bd->bi_ethspeed);
423 #endif
424         printf("baudrate    = %d bps\n", bd->bi_baudrate);
425
426         return 0;
427 }
428
429 #elif defined(CONFIG_SANDBOX)
430
431 int do_bdinfo(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
432 {
433         int i;
434         bd_t *bd = gd->bd;
435
436         print_num("boot_params", (ulong)bd->bi_boot_params);
437
438         for (i = 0; i < CONFIG_NR_DRAM_BANKS; ++i) {
439                 print_num("DRAM bank", i);
440                 print_num("-> start", bd->bi_dram[i].start);
441                 print_num("-> size", bd->bi_dram[i].size);
442         }
443
444 #if defined(CONFIG_CMD_NET)
445         print_eth(0);
446         printf("ip_addr     = %pI4\n", &bd->bi_ip_addr);
447 #endif
448         print_num("FB base  ", gd->fb_base);
449         return 0;
450 }
451
452 #elif defined(CONFIG_NDS32)
453
454 int do_bdinfo(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
455 {
456         int i;
457         bd_t *bd = gd->bd;
458
459         print_num("arch_number",        bd->bi_arch_number);
460         print_num("boot_params",        (ulong)bd->bi_boot_params);
461
462         for (i = 0; i < CONFIG_NR_DRAM_BANKS; ++i) {
463                 print_num("DRAM bank",  i);
464                 print_num("-> start",   bd->bi_dram[i].start);
465                 print_num("-> size",    bd->bi_dram[i].size);
466         }
467
468 #if defined(CONFIG_CMD_NET)
469         print_eth(0);
470         printf("ip_addr     = %pI4\n", &bd->bi_ip_addr);
471 #endif
472         printf("baudrate    = %d bps\n", bd->bi_baudrate);
473
474         return 0;
475 }
476
477 #else
478  #error "a case for this architecture does not exist!"
479 #endif
480
481 /* -------------------------------------------------------------------- */
482
483 U_BOOT_CMD(
484         bdinfo, 1,      1,      do_bdinfo,
485         "print Board Info structure",
486         ""
487 );