cmd_sf: Add print mesg for 'sf erase' command
[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
134 #ifdef CONFIG_ENABLE_36BIT_PHYS
135 #ifdef CONFIG_PHYS_64BIT
136         puts("addressing  = 36-bit\n");
137 #else
138         puts("addressing  = 32-bit\n");
139 #endif
140 #endif
141
142         print_eth(0);
143 #if defined(CONFIG_HAS_ETH1)
144         print_eth(1);
145 #endif
146 #if defined(CONFIG_HAS_ETH2)
147         print_eth(2);
148 #endif
149 #if defined(CONFIG_HAS_ETH3)
150         print_eth(3);
151 #endif
152 #if defined(CONFIG_HAS_ETH4)
153         print_eth(4);
154 #endif
155 #if defined(CONFIG_HAS_ETH5)
156         print_eth(5);
157 #endif
158
159 #ifdef CONFIG_HERMES
160         print_mhz("ethspeed",           bd->bi_ethspeed);
161 #endif
162         printf("IP addr     = %s\n", getenv("ipaddr"));
163         printf("baudrate    = %6u bps\n", bd->bi_baudrate);
164         print_num("relocaddr", gd->relocaddr);
165         return 0;
166 }
167
168 #elif defined(CONFIG_NIOS2)
169
170 int do_bdinfo(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
171 {
172         bd_t *bd = gd->bd;
173
174         print_num("mem start",          (ulong)bd->bi_memstart);
175         print_lnum("mem size",          (u64)bd->bi_memsize);
176         print_num("flash start",        (ulong)bd->bi_flashstart);
177         print_num("flash size",         (ulong)bd->bi_flashsize);
178         print_num("flash offset",       (ulong)bd->bi_flashoffset);
179
180 #if defined(CONFIG_SYS_SRAM_BASE)
181         print_num ("sram start",        (ulong)bd->bi_sramstart);
182         print_num ("sram size",         (ulong)bd->bi_sramsize);
183 #endif
184
185 #if defined(CONFIG_CMD_NET)
186         print_eth(0);
187         printf("ip_addr     = %s\n", getenv("ipaddr"));
188 #endif
189
190         printf("baudrate    = %u bps\n", bd->bi_baudrate);
191
192         return 0;
193 }
194
195 #elif defined(CONFIG_MICROBLAZE)
196
197 int do_bdinfo(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
198 {
199         bd_t *bd = gd->bd;
200         print_num("mem start      ",    (ulong)bd->bi_memstart);
201         print_lnum("mem size       ",   (u64)bd->bi_memsize);
202         print_num("flash start    ",    (ulong)bd->bi_flashstart);
203         print_num("flash size     ",    (ulong)bd->bi_flashsize);
204         print_num("flash offset   ",    (ulong)bd->bi_flashoffset);
205 #if defined(CONFIG_SYS_SRAM_BASE)
206         print_num("sram start     ",    (ulong)bd->bi_sramstart);
207         print_num("sram size      ",    (ulong)bd->bi_sramsize);
208 #endif
209 #if defined(CONFIG_CMD_NET)
210         print_eths();
211 #endif
212         printf("baudrate    = %u bps\n", bd->bi_baudrate);
213         return 0;
214 }
215
216 #elif defined(CONFIG_SPARC)
217
218 int do_bdinfo(cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[])
219 {
220         bd_t *bd = gd->bd;
221
222 #ifdef DEBUG
223         print_num("bd address             ", (ulong) bd);
224 #endif
225         print_num("memstart               ", bd->bi_memstart);
226         print_lnum("memsize                ", bd->bi_memsize);
227         print_num("flashstart             ", bd->bi_flashstart);
228         print_num("CONFIG_SYS_MONITOR_BASE       ", CONFIG_SYS_MONITOR_BASE);
229         print_num("CONFIG_ENV_ADDR           ", CONFIG_ENV_ADDR);
230         printf("CONFIG_SYS_RELOC_MONITOR_BASE = 0x%x (%d)\n", CONFIG_SYS_RELOC_MONITOR_BASE,
231                CONFIG_SYS_MONITOR_LEN);
232         printf("CONFIG_SYS_MALLOC_BASE        = 0x%x (%d)\n", CONFIG_SYS_MALLOC_BASE,
233                CONFIG_SYS_MALLOC_LEN);
234         printf("CONFIG_SYS_INIT_SP_OFFSET     = 0x%x (%d)\n", CONFIG_SYS_INIT_SP_OFFSET,
235                CONFIG_SYS_STACK_SIZE);
236         printf("CONFIG_SYS_PROM_OFFSET        = 0x%x (%d)\n", CONFIG_SYS_PROM_OFFSET,
237                CONFIG_SYS_PROM_SIZE);
238         printf("CONFIG_SYS_GBL_DATA_OFFSET    = 0x%x (%d)\n", CONFIG_SYS_GBL_DATA_OFFSET,
239                GENERATED_GBL_DATA_SIZE);
240
241 #if defined(CONFIG_CMD_NET)
242         print_eth(0);
243         printf("ip_addr     = %s\n", getenv("ipaddr"));
244 #endif
245         printf("baudrate               = %6u bps\n", bd->bi_baudrate);
246         return 0;
247 }
248
249 #elif defined(CONFIG_M68K)
250
251 int do_bdinfo(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
252 {
253         bd_t *bd = gd->bd;
254
255         print_num("memstart",           (ulong)bd->bi_memstart);
256         print_lnum("memsize",           (u64)bd->bi_memsize);
257         print_num("flashstart",         (ulong)bd->bi_flashstart);
258         print_num("flashsize",          (ulong)bd->bi_flashsize);
259         print_num("flashoffset",        (ulong)bd->bi_flashoffset);
260 #if defined(CONFIG_SYS_INIT_RAM_ADDR)
261         print_num("sramstart",          (ulong)bd->bi_sramstart);
262         print_num("sramsize",           (ulong)bd->bi_sramsize);
263 #endif
264 #if defined(CONFIG_SYS_MBAR)
265         print_num("mbar",               bd->bi_mbar_base);
266 #endif
267         print_mhz("cpufreq",            bd->bi_intfreq);
268         print_mhz("busfreq",            bd->bi_busfreq);
269 #ifdef CONFIG_PCI
270         print_mhz("pcifreq",            bd->bi_pcifreq);
271 #endif
272 #ifdef CONFIG_EXTRA_CLOCK
273         print_mhz("flbfreq",            bd->bi_flbfreq);
274         print_mhz("inpfreq",            bd->bi_inpfreq);
275         print_mhz("vcofreq",            bd->bi_vcofreq);
276 #endif
277 #if defined(CONFIG_CMD_NET)
278         print_eth(0);
279 #if defined(CONFIG_HAS_ETH1)
280         print_eth(1);
281 #endif
282 #if defined(CONFIG_HAS_ETH2)
283         print_eth(2);
284 #endif
285 #if defined(CONFIG_HAS_ETH3)
286         print_eth(3);
287 #endif
288
289         printf("ip_addr     = %s\n", getenv("ipaddr"));
290 #endif
291         printf("baudrate    = %u bps\n", bd->bi_baudrate);
292
293         return 0;
294 }
295
296 #elif defined(CONFIG_BLACKFIN)
297
298 int do_bdinfo(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
299 {
300         bd_t *bd = gd->bd;
301
302         printf("U-Boot      = %s\n", bd->bi_r_version);
303         printf("CPU         = %s\n", bd->bi_cpu);
304         printf("Board       = %s\n", bd->bi_board_name);
305         print_mhz("VCO",        bd->bi_vco);
306         print_mhz("CCLK",       bd->bi_cclk);
307         print_mhz("SCLK",       bd->bi_sclk);
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     = %s\n", getenv("ipaddr"));
318         printf("baudrate    = %u bps\n", bd->bi_baudrate);
319
320         return 0;
321 }
322
323 #elif defined(CONFIG_MIPS)
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     = %s\n", getenv("ipaddr"));
338         printf("baudrate    = %u bps\n", bd->bi_baudrate);
339
340         return 0;
341 }
342
343 #elif defined(CONFIG_AVR32)
344
345 int do_bdinfo(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
346 {
347         bd_t *bd = gd->bd;
348
349         print_num("boot_params",        (ulong)bd->bi_boot_params);
350         print_num("memstart",           (ulong)bd->bi_memstart);
351         print_lnum("memsize",           (u64)bd->bi_memsize);
352         print_num("flashstart",         (ulong)bd->bi_flashstart);
353         print_num("flashsize",          (ulong)bd->bi_flashsize);
354         print_num("flashoffset",        (ulong)bd->bi_flashoffset);
355
356         print_eth(0);
357         printf("ip_addr     = %s\n", getenv("ipaddr"));
358         printf("baudrate    = %u bps\n", bd->bi_baudrate);
359
360         return 0;
361 }
362
363 #elif defined(CONFIG_ARM)
364
365 int do_bdinfo(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
366 {
367         int i;
368         bd_t *bd = gd->bd;
369
370         print_num("arch_number",        bd->bi_arch_number);
371         print_num("boot_params",        (ulong)bd->bi_boot_params);
372
373         for (i = 0; i < CONFIG_NR_DRAM_BANKS; ++i) {
374                 print_num("DRAM bank",  i);
375                 print_num("-> start",   bd->bi_dram[i].start);
376                 print_num("-> size",    bd->bi_dram[i].size);
377         }
378
379 #if defined(CONFIG_CMD_NET)
380         print_eths();
381 #endif
382         printf("baudrate    = %u bps\n", bd->bi_baudrate);
383 #if !(defined(CONFIG_SYS_ICACHE_OFF) && defined(CONFIG_SYS_DCACHE_OFF))
384         print_num("TLB addr", gd->arch.tlb_addr);
385 #endif
386         print_num("relocaddr", gd->relocaddr);
387         print_num("reloc off", gd->reloc_off);
388         print_num("irq_sp", gd->irq_sp);        /* irq stack pointer */
389         print_num("sp start ", gd->start_addr_sp);
390 #if defined(CONFIG_LCD) || defined(CONFIG_VIDEO)
391         print_num("FB base  ", gd->fb_base);
392 #endif
393         /*
394          * TODO: Currently only support for davinci SOC's is added.
395          * Remove this check once all the board implement this.
396          */
397 #ifdef CONFIG_CLOCKS
398         printf("ARM frequency = %ld MHz\n", gd->bd->bi_arm_freq);
399         printf("DSP frequency = %ld MHz\n", gd->bd->bi_dsp_freq);
400         printf("DDR frequency = %ld MHz\n", gd->bd->bi_ddr_freq);
401 #endif
402         return 0;
403 }
404
405 #elif defined(CONFIG_SH)
406
407 int do_bdinfo(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
408 {
409         bd_t *bd = gd->bd;
410         print_num("mem start      ",    (ulong)bd->bi_memstart);
411         print_lnum("mem size       ",   (u64)bd->bi_memsize);
412         print_num("flash start    ",    (ulong)bd->bi_flashstart);
413         print_num("flash size     ",    (ulong)bd->bi_flashsize);
414         print_num("flash offset   ",    (ulong)bd->bi_flashoffset);
415
416 #if defined(CONFIG_CMD_NET)
417         print_eth(0);
418         printf("ip_addr     = %s\n", getenv("ipaddr"));
419 #endif
420         printf("baudrate    = %u bps\n", bd->bi_baudrate);
421         return 0;
422 }
423
424 #elif defined(CONFIG_X86)
425
426 int do_bdinfo(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
427 {
428         int i;
429         bd_t *bd = gd->bd;
430
431         print_num("boot_params",        (ulong)bd->bi_boot_params);
432         print_num("bi_memstart",        bd->bi_memstart);
433         print_num("bi_memsize",         bd->bi_memsize);
434         print_num("bi_flashstart",      bd->bi_flashstart);
435         print_num("bi_flashsize",       bd->bi_flashsize);
436         print_num("bi_flashoffset",     bd->bi_flashoffset);
437         print_num("bi_sramstart",       bd->bi_sramstart);
438         print_num("bi_sramsize",        bd->bi_sramsize);
439         print_num("bi_bootflags",       bd->bi_bootflags);
440         print_mhz("cpufreq",            bd->bi_intfreq);
441         print_mhz("busfreq",            bd->bi_busfreq);
442
443         for (i = 0; i < CONFIG_NR_DRAM_BANKS; ++i) {
444                 print_num("DRAM bank",  i);
445                 print_num("-> start",   bd->bi_dram[i].start);
446                 print_num("-> size",    bd->bi_dram[i].size);
447         }
448
449 #if defined(CONFIG_CMD_NET)
450         print_eth(0);
451         printf("ip_addr     = %s\n", getenv("ipaddr"));
452         print_mhz("ethspeed",       bd->bi_ethspeed);
453 #endif
454         printf("baudrate    = %u bps\n", bd->bi_baudrate);
455
456         return 0;
457 }
458
459 #elif defined(CONFIG_SANDBOX)
460
461 int do_bdinfo(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
462 {
463         int i;
464         bd_t *bd = gd->bd;
465
466         print_num("boot_params", (ulong)bd->bi_boot_params);
467
468         for (i = 0; i < CONFIG_NR_DRAM_BANKS; ++i) {
469                 print_num("DRAM bank", i);
470                 print_num("-> start", bd->bi_dram[i].start);
471                 print_num("-> size", bd->bi_dram[i].size);
472         }
473
474 #if defined(CONFIG_CMD_NET)
475         print_eth(0);
476         printf("ip_addr     = %s\n", getenv("ipaddr"));
477 #endif
478 #if defined(CONFIG_LCD) || defined(CONFIG_VIDEO)
479         print_num("FB base  ", gd->fb_base);
480 #endif
481         return 0;
482 }
483
484 #elif defined(CONFIG_NDS32)
485
486 int do_bdinfo(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
487 {
488         int i;
489         bd_t *bd = gd->bd;
490
491         print_num("arch_number",        bd->bi_arch_number);
492         print_num("boot_params",        (ulong)bd->bi_boot_params);
493
494         for (i = 0; i < CONFIG_NR_DRAM_BANKS; ++i) {
495                 print_num("DRAM bank",  i);
496                 print_num("-> start",   bd->bi_dram[i].start);
497                 print_num("-> size",    bd->bi_dram[i].size);
498         }
499
500 #if defined(CONFIG_CMD_NET)
501         print_eth(0);
502         printf("ip_addr     = %s\n", getenv("ipaddr"));
503 #endif
504         printf("baudrate    = %u bps\n", bd->bi_baudrate);
505
506         return 0;
507 }
508
509 #elif defined(CONFIG_OPENRISC)
510
511 int do_bdinfo(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
512 {
513         bd_t *bd = gd->bd;
514
515         print_num("mem start",          (ulong)bd->bi_memstart);
516         print_lnum("mem size",          (u64)bd->bi_memsize);
517         print_num("flash start",        (ulong)bd->bi_flashstart);
518         print_num("flash size",         (ulong)bd->bi_flashsize);
519         print_num("flash offset",       (ulong)bd->bi_flashoffset);
520
521 #if defined(CONFIG_CMD_NET)
522         print_eth(0);
523         printf("ip_addr     = %s\n", getenv("ipaddr"));
524 #endif
525
526         printf("baudrate    = %u bps\n", bd->bi_baudrate);
527
528         return 0;
529 }
530
531 #else
532  #error "a case for this architecture does not exist!"
533 #endif
534
535 /* -------------------------------------------------------------------- */
536
537 U_BOOT_CMD(
538         bdinfo, 1,      1,      do_bdinfo,
539         "print Board Info structure",
540         ""
541 );