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