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