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